Search in sources :

Example 6 with ARRAY_TYPE

use of org.kie.pmml.api.enums.ARRAY_TYPE in project drools by kiegroup.

the class KiePMMLSimpleSetPredicateTest method evaluationStringNotIn.

@Test
public void evaluationStringNotIn() {
    ARRAY_TYPE arrayType = ARRAY_TYPE.STRING;
    List<Object> values = getObjects(arrayType, 1);
    KiePMMLSimpleSetPredicate kiePMMLSimpleSetPredicate = getKiePMMLSimpleSetPredicate(values, arrayType, IN_NOTIN.NOT_IN);
    assertFalse(kiePMMLSimpleSetPredicate.evaluation(values.get(0)));
    assertTrue(kiePMMLSimpleSetPredicate.evaluation("NOT"));
}
Also used : ARRAY_TYPE(org.kie.pmml.api.enums.ARRAY_TYPE) Test(org.junit.Test)

Example 7 with ARRAY_TYPE

use of org.kie.pmml.api.enums.ARRAY_TYPE in project drools by kiegroup.

the class KiePMMLSimpleSetPredicateTest method evaluationRealIn.

@Test
public void evaluationRealIn() {
    ARRAY_TYPE arrayType = ARRAY_TYPE.REAL;
    List<Object> values = getObjects(arrayType, 1);
    KiePMMLSimpleSetPredicate kiePMMLSimpleSetPredicate = getKiePMMLSimpleSetPredicate(values, arrayType, IN_NOTIN.IN);
    assertFalse(kiePMMLSimpleSetPredicate.evaluation("23.4"));
    assertTrue(kiePMMLSimpleSetPredicate.evaluation(values.get(0)));
}
Also used : ARRAY_TYPE(org.kie.pmml.api.enums.ARRAY_TYPE) Test(org.junit.Test)

Example 8 with ARRAY_TYPE

use of org.kie.pmml.api.enums.ARRAY_TYPE in project drools by kiegroup.

the class KiePMMLSimpleSetPredicateTest method evaluateStringNotIn.

@Test
public void evaluateStringNotIn() {
    ARRAY_TYPE arrayType = ARRAY_TYPE.STRING;
    List<Object> values = getObjects(arrayType, 4);
    KiePMMLSimpleSetPredicate kiePMMLSimpleSetPredicate = getKiePMMLSimpleSetPredicate(values, arrayType, IN_NOTIN.NOT_IN);
    Map<String, Object> inputData = new HashMap<>();
    inputData.put("FAKE", "NOT");
    assertFalse(kiePMMLSimpleSetPredicate.evaluate(inputData));
    inputData.put(SIMPLE_SET_PREDICATE_NAME, values.get(0));
    assertFalse(kiePMMLSimpleSetPredicate.evaluate(inputData));
    inputData.put(SIMPLE_SET_PREDICATE_NAME, "NOT");
    assertTrue(kiePMMLSimpleSetPredicate.evaluate(inputData));
}
Also used : HashMap(java.util.HashMap) ARRAY_TYPE(org.kie.pmml.api.enums.ARRAY_TYPE) Test(org.junit.Test)

Example 9 with ARRAY_TYPE

use of org.kie.pmml.api.enums.ARRAY_TYPE in project drools by kiegroup.

the class KiePMMLSimpleSetPredicateTest method evaluationRealNotIn.

@Test
public void evaluationRealNotIn() {
    ARRAY_TYPE arrayType = ARRAY_TYPE.REAL;
    List<Object> values = getObjects(arrayType, 1);
    KiePMMLSimpleSetPredicate kiePMMLSimpleSetPredicate = getKiePMMLSimpleSetPredicate(values, arrayType, IN_NOTIN.NOT_IN);
    assertFalse(kiePMMLSimpleSetPredicate.evaluation(values.get(0)));
    assertTrue(kiePMMLSimpleSetPredicate.evaluation("23.4"));
}
Also used : ARRAY_TYPE(org.kie.pmml.api.enums.ARRAY_TYPE) Test(org.junit.Test)

Example 10 with ARRAY_TYPE

use of org.kie.pmml.api.enums.ARRAY_TYPE in project drools by kiegroup.

the class KiePMMLSimpleSetPredicateTest method evaluateIntIn.

@Test
public void evaluateIntIn() {
    ARRAY_TYPE arrayType = ARRAY_TYPE.INT;
    List<Object> values = getObjects(arrayType, 4);
    KiePMMLSimpleSetPredicate kiePMMLSimpleSetPredicate = getKiePMMLSimpleSetPredicate(values, arrayType, IN_NOTIN.IN);
    Map<String, Object> inputData = new HashMap<>();
    inputData.put("FAKE", "234");
    assertFalse(kiePMMLSimpleSetPredicate.evaluate(inputData));
    inputData.put(SIMPLE_SET_PREDICATE_NAME, "432");
    assertFalse(kiePMMLSimpleSetPredicate.evaluate(inputData));
    inputData.put(SIMPLE_SET_PREDICATE_NAME, values.get(0));
    assertTrue(kiePMMLSimpleSetPredicate.evaluate(inputData));
}
Also used : HashMap(java.util.HashMap) ARRAY_TYPE(org.kie.pmml.api.enums.ARRAY_TYPE) Test(org.junit.Test)

Aggregations

ARRAY_TYPE (org.kie.pmml.api.enums.ARRAY_TYPE)17 Test (org.junit.Test)16 HashMap (java.util.HashMap)10 NodeList (com.github.javaparser.ast.NodeList)1 MethodDeclaration (com.github.javaparser.ast.body.MethodDeclaration)1 VariableDeclarator (com.github.javaparser.ast.body.VariableDeclarator)1 Expression (com.github.javaparser.ast.expr.Expression)1 MethodCallExpr (com.github.javaparser.ast.expr.MethodCallExpr)1 NameExpr (com.github.javaparser.ast.expr.NameExpr)1 StringLiteralExpr (com.github.javaparser.ast.expr.StringLiteralExpr)1 BlockStmt (com.github.javaparser.ast.stmt.BlockStmt)1 IN_NOTIN (org.kie.pmml.api.enums.IN_NOTIN)1 KiePMMLException (org.kie.pmml.api.exceptions.KiePMMLException)1 CommonCodegenUtils.getExpressionForObject (org.kie.pmml.compiler.commons.utils.CommonCodegenUtils.getExpressionForObject)1 CommonCodegenUtils.getVariableDeclarator (org.kie.pmml.compiler.commons.utils.CommonCodegenUtils.getVariableDeclarator)1