Fix trusted (#40)

This commit is contained in:
Kostya 2021-01-27 10:17:20 +03:00 committed by GitHub
parent a9ee711d74
commit e541e47ebc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 2 deletions

View File

@ -11,7 +11,7 @@
</parent>
<artifactId>fraudo</artifactId>
<version>0.0.21</version>
<version>0.0.22</version>
<name>Fraudo</name>
<description>Language for describing antifraud patterns</description>

View File

@ -38,6 +38,7 @@ relationalExpression
| like
| is_mobile
| is_recurrent
| is_trusted
;
unaryExpression
@ -110,5 +111,5 @@ is_recurrent
;
is_trusted
: 'is_trusted' LPAREN RPAREN
: 'isTrusted' LPAREN RPAREN
;

View File

@ -134,6 +134,17 @@ public class CustomTest extends AbstractPaymentTest {
assertEquals(ResultStatus.ACCEPT, ResultUtils.findFirstNotNotifyStatus(result).get().getResultStatus());
}
@Test
public void trustedTest() throws Exception {
InputStream resourceAsStream = CustomTest.class.getResourceAsStream("/rules/is_trusted.frd");
when(customerTypeResolver.isTrusted(any())).thenReturn(true);
ParseContext parseContext = getParseContext(resourceAsStream);
PaymentModel model = new PaymentModel();
ResultModel result = invoke(parseContext, model);
assertEquals(ResultStatus.ACCEPT, ResultUtils.findFirstNotNotifyStatus(result).get().getResultStatus());
}
@Test
public void payerTypeTest() throws Exception {
InputStream resourceAsStream = CustomTest.class.getResourceAsStream("/rules/is_recurrent.frd");

View File

@ -0,0 +1 @@
rule: isTrusted() -> accept;