mirror of
https://github.com/valitydev/fraudo.git
synced 2024-11-06 01:45:16 +00:00
Remove impl (#20)
* Change logic exception * Fix for factory * Remove impl model
This commit is contained in:
parent
d714889a6d
commit
4a70084387
2
pom.xml
2
pom.xml
@ -11,7 +11,7 @@
|
||||
</parent>
|
||||
|
||||
<artifactId>fraudo</artifactId>
|
||||
<version>0.0.9-SNAPSHOT</version>
|
||||
<version>0.0.10-SNAPSHOT</version>
|
||||
|
||||
<properties>
|
||||
<hamcrest.junit.version>2.0.0.0</hamcrest.junit.version>
|
||||
|
@ -14,10 +14,10 @@ import com.rbkmoney.fraudo.visitor.ListVisitor;
|
||||
import com.rbkmoney.fraudo.visitor.SumVisitor;
|
||||
import com.rbkmoney.fraudo.visitor.impl.*;
|
||||
|
||||
public class FastFraudVisitorFactory<T extends BaseModel, U> implements FraudVisitorFactory<T, U> {
|
||||
public class FirstFraudVisitorFactory implements FraudVisitorFactory {
|
||||
|
||||
@Override
|
||||
public FastFraudVisitorImpl<T> createVisitor(
|
||||
public <T extends BaseModel, U> FirstFindVisitorImpl<T, U> createVisitor(
|
||||
CountAggregator<T, U> countAggregator,
|
||||
SumAggregator<T, U> sumAggregator,
|
||||
UniqueValueAggregator<T, U> uniqueValueAggregator,
|
||||
@ -33,7 +33,7 @@ public class FastFraudVisitorFactory<T extends BaseModel, U> implements FraudVis
|
||||
countryResolver,
|
||||
fieldResolver,
|
||||
groupByModelResolver);
|
||||
return new FastFraudVisitorImpl<>(countVisitor, sumVisitor, listVisitor, customFuncVisitor);
|
||||
return new FirstFindVisitorImpl<>(countVisitor, sumVisitor, listVisitor, customFuncVisitor, fieldResolver);
|
||||
}
|
||||
|
||||
}
|
@ -4,14 +4,15 @@ import com.rbkmoney.fraudo.aggregator.CountAggregator;
|
||||
import com.rbkmoney.fraudo.aggregator.SumAggregator;
|
||||
import com.rbkmoney.fraudo.aggregator.UniqueValueAggregator;
|
||||
import com.rbkmoney.fraudo.finder.InListFinder;
|
||||
import com.rbkmoney.fraudo.model.BaseModel;
|
||||
import com.rbkmoney.fraudo.resolver.CountryResolver;
|
||||
import com.rbkmoney.fraudo.resolver.FieldResolver;
|
||||
import com.rbkmoney.fraudo.resolver.GroupByModelResolver;
|
||||
import com.rbkmoney.fraudo.visitor.impl.FastFraudVisitorImpl;
|
||||
import com.rbkmoney.fraudo.visitor.impl.FirstFindVisitorImpl;
|
||||
|
||||
public interface FraudVisitorFactory<T, U> {
|
||||
public interface FraudVisitorFactory {
|
||||
|
||||
FastFraudVisitorImpl createVisitor(CountAggregator<T, U> countAggregator,
|
||||
<T extends BaseModel, U> FirstFindVisitorImpl createVisitor(CountAggregator<T, U> countAggregator,
|
||||
SumAggregator<T, U> sumAggregator,
|
||||
UniqueValueAggregator<T, U> uniqueValueAggregator,
|
||||
CountryResolver<U> countryResolver,
|
||||
|
@ -1,42 +1,45 @@
|
||||
package com.rbkmoney.fraudo.utils.key.generator;
|
||||
|
||||
import com.rbkmoney.fraudo.FraudoParser;
|
||||
import com.rbkmoney.fraudo.constant.PaymentCheckedField;
|
||||
import com.rbkmoney.fraudo.utils.TextUtil;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.antlr.v4.runtime.tree.ParseTree;
|
||||
import org.antlr.v4.runtime.tree.TerminalNode;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public class CommonKeyGenerator {
|
||||
|
||||
static String generateKeyGroupedFunction(TerminalNode string,
|
||||
static <T> String generateKeyGroupedFunction(TerminalNode string,
|
||||
ParseTree parseTree,
|
||||
FraudoParser.Time_windowContext timeWindowContext,
|
||||
FraudoParser.Group_byContext groupByContext) {
|
||||
FraudoParser.Group_byContext groupByContext,
|
||||
Function<String, T> resolve) {
|
||||
String countTarget = TextUtil.safeGetText(string);
|
||||
return new StringBuilder()
|
||||
.append(parseTree)
|
||||
.append(countTarget)
|
||||
.append(PaymentCheckedField.getByValue(countTarget))
|
||||
.append(resolve.apply(countTarget))
|
||||
.append(timeWindowContext != null ? timeWindowContext.children : "")
|
||||
.append(groupByContext != null ? groupByContext.string_list().children : "")
|
||||
.toString();
|
||||
}
|
||||
|
||||
static String generateKeyGroupedTwoFieldFunction(TerminalNode firstField,
|
||||
static <T> String generateKeyGroupedTwoFieldFunction(TerminalNode firstField,
|
||||
TerminalNode secondField,
|
||||
ParseTree parseTree,
|
||||
FraudoParser.Time_windowContext timeWindowContext,
|
||||
FraudoParser.Group_byContext groupByContext) {
|
||||
FraudoParser.Group_byContext groupByContext,
|
||||
Function<String, T> resolve) {
|
||||
String target = TextUtil.safeGetText(firstField);
|
||||
String errorCode = TextUtil.safeGetText(secondField);
|
||||
return new StringBuilder()
|
||||
.append(parseTree)
|
||||
.append(target)
|
||||
.append(errorCode)
|
||||
.append(PaymentCheckedField.getByValue(target))
|
||||
.append(resolve.apply(target))
|
||||
.append(timeWindowContext != null ? timeWindowContext.children : "")
|
||||
.append(groupByContext != null ? groupByContext.string_list().children : "")
|
||||
.toString();
|
||||
|
@ -5,32 +5,37 @@ import lombok.AccessLevel;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.antlr.v4.runtime.ParserRuleContext;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public class CountKeyGenerator {
|
||||
|
||||
public static String generate(ParserRuleContext context) {
|
||||
public static <T> String generate(ParserRuleContext context, Function<String, T> resolve) {
|
||||
FraudoParser.CountContext ctx = (FraudoParser.CountContext) context;
|
||||
return CommonKeyGenerator.generateKeyGroupedFunction(ctx.STRING(),
|
||||
ctx.children.get(0),
|
||||
ctx.time_window(),
|
||||
ctx.group_by());
|
||||
ctx.group_by(),
|
||||
resolve);
|
||||
}
|
||||
|
||||
public static String generateSuccessKey(ParserRuleContext context) {
|
||||
public static <T> String generateSuccessKey(ParserRuleContext context, Function<String, T> resolve) {
|
||||
FraudoParser.Count_successContext ctx = (FraudoParser.Count_successContext) context;
|
||||
return CommonKeyGenerator.generateKeyGroupedFunction(ctx.STRING(),
|
||||
ctx.children.get(0),
|
||||
ctx.time_window(),
|
||||
ctx.group_by());
|
||||
ctx.group_by(),
|
||||
resolve);
|
||||
}
|
||||
|
||||
public static String generateErrorKey(ParserRuleContext context) {
|
||||
public static <T> String generateErrorKey(ParserRuleContext context, Function<String, T> resolve) {
|
||||
FraudoParser.Count_errorContext ctx = (FraudoParser.Count_errorContext) context;
|
||||
return CommonKeyGenerator.generateKeyGroupedTwoFieldFunction(ctx.STRING(0),
|
||||
ctx.STRING(1),
|
||||
ctx.children.get(0),
|
||||
ctx.time_window(),
|
||||
ctx.group_by());
|
||||
ctx.group_by(),
|
||||
resolve);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import org.antlr.v4.runtime.ParserRuleContext;
|
||||
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public class CountryKeyGenerator {
|
||||
|
||||
public static String generate(ParserRuleContext context) {
|
||||
FraudoParser.Country_byContext ctx = (FraudoParser.Country_byContext) context;
|
||||
String fieldName = TextUtil.safeGetText(ctx.STRING());
|
||||
@ -16,4 +17,5 @@ public class CountryKeyGenerator {
|
||||
.append(fieldName)
|
||||
.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,32 +5,37 @@ import lombok.AccessLevel;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.antlr.v4.runtime.ParserRuleContext;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public class SumKeyGenerator {
|
||||
|
||||
public static String generate(ParserRuleContext context) {
|
||||
public static <T> String generate(ParserRuleContext context, Function<String, T> resolve) {
|
||||
FraudoParser.SumContext ctx = (FraudoParser.SumContext) context;
|
||||
return CommonKeyGenerator.generateKeyGroupedFunction(ctx.STRING(),
|
||||
ctx.children.get(0),
|
||||
ctx.time_window(),
|
||||
ctx.group_by());
|
||||
ctx.group_by(),
|
||||
resolve);
|
||||
}
|
||||
|
||||
public static String generateSuccessKey(ParserRuleContext context) {
|
||||
public static <T> String generateSuccessKey(ParserRuleContext context, Function<String, T> resolve) {
|
||||
FraudoParser.Sum_successContext ctx = (FraudoParser.Sum_successContext) context;
|
||||
return CommonKeyGenerator.generateKeyGroupedFunction(ctx.STRING(),
|
||||
ctx.children.get(0),
|
||||
ctx.time_window(),
|
||||
ctx.group_by());
|
||||
ctx.group_by(),
|
||||
resolve);
|
||||
}
|
||||
|
||||
public static String generateErrorKey(ParserRuleContext context) {
|
||||
public static <T> String generateErrorKey(ParserRuleContext context, Function<String, T> resolve) {
|
||||
FraudoParser.Sum_errorContext ctx = (FraudoParser.Sum_errorContext) context;
|
||||
return CommonKeyGenerator.generateKeyGroupedTwoFieldFunction(ctx.STRING(0),
|
||||
ctx.STRING(1),
|
||||
ctx.children.get(0),
|
||||
ctx.time_window(),
|
||||
ctx.group_by());
|
||||
ctx.group_by(),
|
||||
resolve);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,15 +5,20 @@ import lombok.AccessLevel;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.antlr.v4.runtime.ParserRuleContext;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public class UniqueKeyGenerator {
|
||||
public static String generate(ParserRuleContext context) {
|
||||
|
||||
public static <T> String generate(ParserRuleContext context, Function<String, T> resolve) {
|
||||
FraudoParser.UniqueContext ctx = (FraudoParser.UniqueContext) context;
|
||||
return CommonKeyGenerator.generateKeyGroupedTwoFieldFunction(
|
||||
ctx.STRING(0),
|
||||
ctx.STRING(1),
|
||||
ctx.children.get(0),
|
||||
ctx.time_window(),
|
||||
ctx.group_by());
|
||||
ctx.group_by(),
|
||||
resolve);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,10 @@
|
||||
package com.rbkmoney.fraudo.visitor;
|
||||
|
||||
import com.rbkmoney.fraudo.model.BaseModel;
|
||||
import org.antlr.v4.runtime.tree.ParseTree;
|
||||
|
||||
public interface TemplateVisitor<T extends BaseModel> {
|
||||
|
||||
Object visit(ParseTree tree, T model);
|
||||
|
||||
}
|
@ -8,12 +8,10 @@ import com.rbkmoney.fraudo.exception.NotValidContextException;
|
||||
import com.rbkmoney.fraudo.exception.UnknownResultException;
|
||||
import com.rbkmoney.fraudo.model.BaseModel;
|
||||
import com.rbkmoney.fraudo.model.ResultModel;
|
||||
import com.rbkmoney.fraudo.resolver.FieldResolver;
|
||||
import com.rbkmoney.fraudo.utils.TextUtil;
|
||||
import com.rbkmoney.fraudo.utils.key.generator.*;
|
||||
import com.rbkmoney.fraudo.visitor.CountVisitor;
|
||||
import com.rbkmoney.fraudo.visitor.CustomFuncVisitor;
|
||||
import com.rbkmoney.fraudo.visitor.ListVisitor;
|
||||
import com.rbkmoney.fraudo.visitor.SumVisitor;
|
||||
import com.rbkmoney.fraudo.visitor.*;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.antlr.v4.runtime.tree.ParseTree;
|
||||
@ -25,7 +23,7 @@ import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
public class FastFraudVisitorImpl<T extends BaseModel> extends FraudoBaseVisitor<Object> {
|
||||
public class FirstFindVisitorImpl<T extends BaseModel, U> extends FraudoBaseVisitor<Object> implements TemplateVisitor <T>{
|
||||
|
||||
private ThreadLocal<Map<String, Object>> localFuncCache;
|
||||
private ThreadLocal<T> threadLocalModel;
|
||||
@ -34,7 +32,9 @@ public class FastFraudVisitorImpl<T extends BaseModel> extends FraudoBaseVisitor
|
||||
private final SumVisitor<T> sumVisitor;
|
||||
private final ListVisitor<T> listVisitor;
|
||||
private final CustomFuncVisitor<T> customFuncVisitor;
|
||||
private final FieldResolver<T, U> fieldResolver;
|
||||
|
||||
@Override
|
||||
public Object visit(ParseTree tree, T model) {
|
||||
if (model == null) {
|
||||
log.error("Model is not init!");
|
||||
@ -142,7 +142,7 @@ public class FastFraudVisitorImpl<T extends BaseModel> extends FraudoBaseVisitor
|
||||
|
||||
@Override
|
||||
public Object visitCount(FraudoParser.CountContext ctx) {
|
||||
String key = CountKeyGenerator.generate(ctx);
|
||||
String key = CountKeyGenerator.generate(ctx, fieldResolver::resolveName);
|
||||
return localFuncCache.get().computeIfAbsent(
|
||||
key,
|
||||
s -> Double.valueOf(countVisitor.visitCount(ctx, threadLocalModel.get()))
|
||||
@ -151,7 +151,7 @@ public class FastFraudVisitorImpl<T extends BaseModel> extends FraudoBaseVisitor
|
||||
|
||||
@Override
|
||||
public Object visitCount_success(FraudoParser.Count_successContext ctx) {
|
||||
String key = CountKeyGenerator.generateSuccessKey(ctx);
|
||||
String key = CountKeyGenerator.generateSuccessKey(ctx, fieldResolver::resolveName);
|
||||
return localFuncCache.get().computeIfAbsent(
|
||||
key,
|
||||
s -> Double.valueOf(countVisitor.visitCountSuccess(ctx, threadLocalModel.get()))
|
||||
@ -160,7 +160,7 @@ public class FastFraudVisitorImpl<T extends BaseModel> extends FraudoBaseVisitor
|
||||
|
||||
@Override
|
||||
public Object visitCount_error(FraudoParser.Count_errorContext ctx) {
|
||||
String key = CountKeyGenerator.generateErrorKey(ctx);
|
||||
String key = CountKeyGenerator.generateErrorKey(ctx, fieldResolver::resolveName);
|
||||
return localFuncCache.get().computeIfAbsent(
|
||||
key,
|
||||
s -> Double.valueOf(countVisitor.visitCountError(ctx, threadLocalModel.get()))
|
||||
@ -169,7 +169,7 @@ public class FastFraudVisitorImpl<T extends BaseModel> extends FraudoBaseVisitor
|
||||
|
||||
@Override
|
||||
public Object visitSum(FraudoParser.SumContext ctx) {
|
||||
String key = SumKeyGenerator.generate(ctx);
|
||||
String key = SumKeyGenerator.generate(ctx, fieldResolver::resolveName);
|
||||
return localFuncCache.get().computeIfAbsent(
|
||||
key,
|
||||
s -> sumVisitor.visitSum(ctx, threadLocalModel.get())
|
||||
@ -178,7 +178,7 @@ public class FastFraudVisitorImpl<T extends BaseModel> extends FraudoBaseVisitor
|
||||
|
||||
@Override
|
||||
public Object visitSum_success(FraudoParser.Sum_successContext ctx) {
|
||||
String key = SumKeyGenerator.generateSuccessKey(ctx);
|
||||
String key = SumKeyGenerator.generateSuccessKey(ctx, fieldResolver::resolveName);
|
||||
return localFuncCache.get().computeIfAbsent(
|
||||
key,
|
||||
s -> sumVisitor.visitSumSuccess(ctx, threadLocalModel.get())
|
||||
@ -187,7 +187,7 @@ public class FastFraudVisitorImpl<T extends BaseModel> extends FraudoBaseVisitor
|
||||
|
||||
@Override
|
||||
public Object visitSum_error(FraudoParser.Sum_errorContext ctx) {
|
||||
String key = SumKeyGenerator.generateErrorKey(ctx);
|
||||
String key = SumKeyGenerator.generateErrorKey(ctx, fieldResolver::resolveName);
|
||||
return localFuncCache.get().computeIfAbsent(
|
||||
key,
|
||||
s -> sumVisitor.visitSumError(ctx, threadLocalModel.get())
|
||||
@ -215,7 +215,7 @@ public class FastFraudVisitorImpl<T extends BaseModel> extends FraudoBaseVisitor
|
||||
|
||||
@Override
|
||||
public Object visitUnique(FraudoParser.UniqueContext ctx) {
|
||||
String key = UniqueKeyGenerator.generate(ctx);
|
||||
String key = UniqueKeyGenerator.generate(ctx, fieldResolver::resolveName);
|
||||
return localFuncCache.get().computeIfAbsent(
|
||||
key,
|
||||
s -> Double.valueOf(customFuncVisitor.visitUnique(ctx, threadLocalModel.get()))
|
@ -3,14 +3,14 @@ package com.rbkmoney.fraudo;
|
||||
import com.rbkmoney.fraudo.aggregator.CountAggregator;
|
||||
import com.rbkmoney.fraudo.aggregator.SumAggregator;
|
||||
import com.rbkmoney.fraudo.aggregator.UniqueValueAggregator;
|
||||
import com.rbkmoney.fraudo.constant.P2PCheckedField;
|
||||
import com.rbkmoney.fraudo.factory.FastFraudVisitorFactory;
|
||||
import com.rbkmoney.fraudo.test.constant.P2PCheckedField;
|
||||
import com.rbkmoney.fraudo.factory.FirstFraudVisitorFactory;
|
||||
import com.rbkmoney.fraudo.finder.InListFinder;
|
||||
import com.rbkmoney.fraudo.model.P2PModel;
|
||||
import com.rbkmoney.fraudo.test.model.P2PModel;
|
||||
import com.rbkmoney.fraudo.model.ResultModel;
|
||||
import com.rbkmoney.fraudo.resolver.CountryResolver;
|
||||
import com.rbkmoney.fraudo.resolver.GroupByModelResolver;
|
||||
import com.rbkmoney.fraudo.resolver.p2p.P2PModelFieldResolver;
|
||||
import com.rbkmoney.fraudo.test.p2p.P2PModelFieldResolver;
|
||||
import org.antlr.v4.runtime.ANTLRInputStream;
|
||||
import org.antlr.v4.runtime.CommonTokenStream;
|
||||
import org.mockito.Mock;
|
||||
@ -46,7 +46,7 @@ public class AbstractP2PTest {
|
||||
}
|
||||
|
||||
ResultModel invoke(com.rbkmoney.fraudo.FraudoParser.ParseContext parse, P2PModel model) {
|
||||
return (ResultModel) new FastFraudVisitorFactory<P2PModel, P2PCheckedField>()
|
||||
return (ResultModel) new FirstFraudVisitorFactory()
|
||||
.createVisitor(
|
||||
countAggregator,
|
||||
sumAggregator,
|
||||
|
@ -3,15 +3,15 @@ package com.rbkmoney.fraudo;
|
||||
import com.rbkmoney.fraudo.aggregator.CountAggregator;
|
||||
import com.rbkmoney.fraudo.aggregator.SumAggregator;
|
||||
import com.rbkmoney.fraudo.aggregator.UniqueValueAggregator;
|
||||
import com.rbkmoney.fraudo.constant.PaymentCheckedField;
|
||||
import com.rbkmoney.fraudo.factory.FastFraudVisitorFactory;
|
||||
import com.rbkmoney.fraudo.test.constant.PaymentCheckedField;
|
||||
import com.rbkmoney.fraudo.factory.FirstFraudVisitorFactory;
|
||||
import com.rbkmoney.fraudo.finder.InListFinder;
|
||||
import com.rbkmoney.fraudo.model.PaymentModel;
|
||||
import com.rbkmoney.fraudo.test.model.PaymentModel;
|
||||
import com.rbkmoney.fraudo.model.ResultModel;
|
||||
import com.rbkmoney.fraudo.resolver.CountryResolver;
|
||||
import com.rbkmoney.fraudo.resolver.FieldResolver;
|
||||
import com.rbkmoney.fraudo.resolver.GroupByModelResolver;
|
||||
import com.rbkmoney.fraudo.resolver.payout.PaymentModelFieldResolver;
|
||||
import com.rbkmoney.fraudo.test.payout.PaymentModelFieldResolver;
|
||||
import org.antlr.v4.runtime.ANTLRInputStream;
|
||||
import org.antlr.v4.runtime.CommonTokenStream;
|
||||
import org.mockito.Mock;
|
||||
@ -46,7 +46,7 @@ public class AbstractPaymentTest {
|
||||
}
|
||||
|
||||
ResultModel invoke(com.rbkmoney.fraudo.FraudoParser.ParseContext parse, PaymentModel model) {
|
||||
return (ResultModel) new FastFraudVisitorFactory<PaymentModel, PaymentCheckedField>()
|
||||
return (ResultModel) new FirstFraudVisitorFactory()
|
||||
.createVisitor(
|
||||
countAggregator,
|
||||
sumAggregator,
|
||||
|
@ -2,7 +2,7 @@ package com.rbkmoney.fraudo;
|
||||
|
||||
import com.rbkmoney.fraudo.constant.ResultStatus;
|
||||
import com.rbkmoney.fraudo.exception.UnknownResultException;
|
||||
import com.rbkmoney.fraudo.model.PaymentModel;
|
||||
import com.rbkmoney.fraudo.test.model.PaymentModel;
|
||||
import com.rbkmoney.fraudo.model.ResultModel;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.rbkmoney.fraudo;
|
||||
|
||||
import com.rbkmoney.fraudo.constant.ResultStatus;
|
||||
import com.rbkmoney.fraudo.model.P2PModel;
|
||||
import com.rbkmoney.fraudo.test.model.P2PModel;
|
||||
import com.rbkmoney.fraudo.model.ResultModel;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.rbkmoney.fraudo;
|
||||
|
||||
import com.rbkmoney.fraudo.constant.ResultStatus;
|
||||
import com.rbkmoney.fraudo.model.PaymentModel;
|
||||
import com.rbkmoney.fraudo.test.model.PaymentModel;
|
||||
import com.rbkmoney.fraudo.model.ResultModel;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
@ -0,0 +1,36 @@
|
||||
package com.rbkmoney.fraudo.test.constant;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public enum P2PCheckedField {
|
||||
|
||||
EMAIL("email"),
|
||||
IP("ip"),
|
||||
FINGERPRINT("fingerprint"),
|
||||
COUNTRY_BANK("country_bank"),
|
||||
BIN("bin"),
|
||||
PAN("pan"),
|
||||
CURRENCY("currency"),
|
||||
IDENTITY_ID("identity_id"),
|
||||
CARD_TOKEN_FROM("card_token_from"),
|
||||
CARD_TOKEN_TO("card_token_to");
|
||||
|
||||
private String value;
|
||||
private static Map<String, P2PCheckedField> valueMap = new HashMap<>();
|
||||
|
||||
static {
|
||||
for (P2PCheckedField value : P2PCheckedField.values()) {
|
||||
valueMap.put(value.value, value);
|
||||
}
|
||||
}
|
||||
|
||||
P2PCheckedField(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public static P2PCheckedField getByValue(String value) {
|
||||
return valueMap.get(value);
|
||||
}
|
||||
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.rbkmoney.fraudo.constant;
|
||||
package com.rbkmoney.fraudo.test.constant;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
@ -1,5 +1,6 @@
|
||||
package com.rbkmoney.fraudo.model;
|
||||
package com.rbkmoney.fraudo.test.model;
|
||||
|
||||
import com.rbkmoney.fraudo.model.BaseModel;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
@ -1,5 +1,6 @@
|
||||
package com.rbkmoney.fraudo.model;
|
||||
package com.rbkmoney.fraudo.test.model;
|
||||
|
||||
import com.rbkmoney.fraudo.model.BaseModel;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
@ -1,9 +1,9 @@
|
||||
package com.rbkmoney.fraudo.resolver.p2p;
|
||||
package com.rbkmoney.fraudo.test.p2p;
|
||||
|
||||
import com.rbkmoney.fraudo.constant.P2PCheckedField;
|
||||
import com.rbkmoney.fraudo.exception.UnresolvableFieldException;
|
||||
import com.rbkmoney.fraudo.model.P2PModel;
|
||||
import com.rbkmoney.fraudo.resolver.FieldResolver;
|
||||
import com.rbkmoney.fraudo.test.constant.P2PCheckedField;
|
||||
import com.rbkmoney.fraudo.test.model.P2PModel;
|
||||
|
||||
public class P2PModelFieldResolver implements FieldResolver<P2PModel, P2PCheckedField> {
|
||||
|
@ -1,9 +1,9 @@
|
||||
package com.rbkmoney.fraudo.resolver.payout;
|
||||
package com.rbkmoney.fraudo.test.payout;
|
||||
|
||||
import com.rbkmoney.fraudo.constant.PaymentCheckedField;
|
||||
import com.rbkmoney.fraudo.exception.UnresolvableFieldException;
|
||||
import com.rbkmoney.fraudo.model.PaymentModel;
|
||||
import com.rbkmoney.fraudo.resolver.FieldResolver;
|
||||
import com.rbkmoney.fraudo.test.constant.PaymentCheckedField;
|
||||
import com.rbkmoney.fraudo.test.model.PaymentModel;
|
||||
|
||||
public class PaymentModelFieldResolver implements FieldResolver<PaymentModel, PaymentCheckedField> {
|
||||
|
Loading…
Reference in New Issue
Block a user