Search in sources :

Example 11 with Interval

use of org.kie.pmml.api.models.Interval in project drools by kiegroup.

the class BooleanFunctionsTest method getIsValidValueCorrectInput.

@Test
public void getIsValidValueCorrectInput() {
    Object[] input1 = { 35 };
    MiningField referredByFieldRef = getReferredByFieldRef(null, null, Arrays.asList(new Interval(20, 29), new Interval(30, 40), new Interval(41, 50)));
    Object retrieved = BooleanFunctions.IS_VALID.getValue(input1, referredByFieldRef);
    assertTrue((boolean) retrieved);
    referredByFieldRef = getReferredByFieldRef(null, null, Arrays.asList(new Interval(20, 29), new Interval(41, 50)));
    retrieved = BooleanFunctions.IS_VALID.getValue(input1, referredByFieldRef);
    assertFalse((boolean) retrieved);
    referredByFieldRef = getReferredByFieldRef(null, Arrays.asList("123", "35"), Arrays.asList(new Interval(20, 29), new Interval(41, 50)));
    retrieved = BooleanFunctions.IS_VALID.getValue(input1, referredByFieldRef);
    assertTrue((boolean) retrieved);
    referredByFieldRef = getReferredByFieldRef(null, Arrays.asList("123", "36"), Arrays.asList(new Interval(20, 29), new Interval(41, 50)));
    retrieved = BooleanFunctions.IS_VALID.getValue(input1, referredByFieldRef);
    assertFalse((boolean) retrieved);
    Object[] input2 = { "VALUE" };
    referredByFieldRef = getReferredByFieldRef(null, Arrays.asList("123", "VALUE"), Collections.emptyList());
    retrieved = BooleanFunctions.IS_VALID.getValue(input2, referredByFieldRef);
    assertTrue((boolean) retrieved);
    referredByFieldRef = getReferredByFieldRef(null, Arrays.asList("123", "VELUE"), Collections.emptyList());
    retrieved = BooleanFunctions.IS_VALID.getValue(input2, referredByFieldRef);
    assertFalse((boolean) retrieved);
    Object[] input3 = { null };
    retrieved = BooleanFunctions.IS_VALID.getValue(input3, referredByFieldRef);
    assertFalse((boolean) retrieved);
}
Also used : MiningField(org.kie.pmml.api.models.MiningField) Interval(org.kie.pmml.api.models.Interval) Test(org.junit.Test)

Example 12 with Interval

use of org.kie.pmml.api.models.Interval in project drools by kiegroup.

the class BooleanFunctionsTest method getIsNotMissingValueCorrectInput.

@Test
public void getIsNotMissingValueCorrectInput() {
    Object[] input1 = { 35 };
    Object retrieved = BooleanFunctions.IS_NOT_MISSING.getValue(input1, EMPTY_MINING_FIELD);
    assertTrue((boolean) retrieved);
    Object[] input2 = { null };
    retrieved = BooleanFunctions.IS_NOT_MISSING.getValue(input2, EMPTY_MINING_FIELD);
    assertFalse((boolean) retrieved);
    for (INVALID_VALUE_TREATMENT_METHOD invalidValueTreatmentMethod : INVALID_VALUE_TREATMENT_METHOD.values()) {
        MiningField referredByFieldRef = getReferredByFieldRef(invalidValueTreatmentMethod, null, Arrays.asList(new Interval(20, 29), new Interval(41, 50)));
        boolean expected = !INVALID_VALUE_TREATMENT_METHOD.AS_MISSING.equals(invalidValueTreatmentMethod);
        assertEquals(expected, BooleanFunctions.IS_NOT_MISSING.getValue(input1, referredByFieldRef));
    }
}
Also used : MiningField(org.kie.pmml.api.models.MiningField) INVALID_VALUE_TREATMENT_METHOD(org.kie.pmml.api.enums.INVALID_VALUE_TREATMENT_METHOD) Interval(org.kie.pmml.api.models.Interval) Test(org.junit.Test)

Aggregations

Interval (org.kie.pmml.api.models.Interval)12 Test (org.junit.Test)11 MiningField (org.kie.pmml.api.models.MiningField)10 Expression (com.github.javaparser.ast.expr.Expression)4 NullLiteralExpr (com.github.javaparser.ast.expr.NullLiteralExpr)4 ObjectCreationExpr (com.github.javaparser.ast.expr.ObjectCreationExpr)4 INVALID_VALUE_TREATMENT_METHOD (org.kie.pmml.api.enums.INVALID_VALUE_TREATMENT_METHOD)4 NodeList (com.github.javaparser.ast.NodeList)3 NameExpr (com.github.javaparser.ast.expr.NameExpr)3 CompilationUnit (com.github.javaparser.ast.CompilationUnit)2 ClassOrInterfaceDeclaration (com.github.javaparser.ast.body.ClassOrInterfaceDeclaration)2 ConstructorDeclaration (com.github.javaparser.ast.body.ConstructorDeclaration)2 MethodDeclaration (com.github.javaparser.ast.body.MethodDeclaration)2 MethodCallExpr (com.github.javaparser.ast.expr.MethodCallExpr)2 BlockStmt (com.github.javaparser.ast.stmt.BlockStmt)2 ExplicitConstructorInvocationStmt (com.github.javaparser.ast.stmt.ExplicitConstructorInvocationStmt)2 ExpressionStmt (com.github.javaparser.ast.stmt.ExpressionStmt)2 Statement (com.github.javaparser.ast.stmt.Statement)2 IOException (java.io.IOException)2 Arrays (java.util.Arrays)2