Search in sources :

Example 1 with Interval

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

the class BooleanFunctionsTest method getIsMissingValueCorrectInput.

@Test
public void getIsMissingValueCorrectInput() {
    Object[] input1 = { null };
    Object retrieved = BooleanFunctions.IS_MISSING.getValue(input1, EMPTY_MINING_FIELD);
    assertTrue((boolean) retrieved);
    Object[] input2 = { 35 };
    retrieved = BooleanFunctions.IS_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_MISSING.getValue(input2, 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)

Example 2 with Interval

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

the class BooleanFunctionsTest method getIsNotValidValueCorrectInput.

@Test
public void getIsNotValidValueCorrectInput() {
    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_NOT_VALID.getValue(input1, referredByFieldRef);
    assertFalse((boolean) retrieved);
    referredByFieldRef = getReferredByFieldRef(null, null, Arrays.asList(new Interval(20, 29), new Interval(41, 50)));
    retrieved = BooleanFunctions.IS_NOT_VALID.getValue(input1, referredByFieldRef);
    assertTrue((boolean) retrieved);
    referredByFieldRef = getReferredByFieldRef(null, Arrays.asList("123", "35"), Arrays.asList(new Interval(20, 29), new Interval(41, 50)));
    retrieved = BooleanFunctions.IS_NOT_VALID.getValue(input1, referredByFieldRef);
    assertFalse((boolean) retrieved);
    referredByFieldRef = getReferredByFieldRef(INVALID_VALUE_TREATMENT_METHOD.AS_MISSING, Arrays.asList("123", "36"), Arrays.asList(new Interval(20, 29), new Interval(41, 50)));
    retrieved = BooleanFunctions.IS_NOT_VALID.getValue(input1, referredByFieldRef);
    assertFalse((boolean) retrieved);
    referredByFieldRef = getReferredByFieldRef(INVALID_VALUE_TREATMENT_METHOD.AS_IS, Arrays.asList("123", "36"), Arrays.asList(new Interval(20, 29), new Interval(41, 50)));
    retrieved = BooleanFunctions.IS_NOT_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_NOT_VALID.getValue(input1, referredByFieldRef);
    assertTrue((boolean) retrieved);
    Object[] input2 = { "VALUE" };
    referredByFieldRef = getReferredByFieldRef(null, Arrays.asList("123", "VALUE"), Collections.emptyList());
    retrieved = BooleanFunctions.IS_NOT_VALID.getValue(input2, referredByFieldRef);
    assertFalse((boolean) retrieved);
    referredByFieldRef = getReferredByFieldRef(null, Arrays.asList("123", "VELUE"), Collections.emptyList());
    retrieved = BooleanFunctions.IS_NOT_VALID.getValue(input2, referredByFieldRef);
    assertTrue((boolean) retrieved);
    Object[] input3 = { null };
    retrieved = BooleanFunctions.IS_NOT_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 3 with Interval

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

the class BooleanFunctionsTest method getIsValidValueWrongTypeInput.

@Test(expected = IllegalArgumentException.class)
public void getIsValidValueWrongTypeInput() {
    final Object[] input = { "34" };
    MiningField referredByFieldRef = getReferredByFieldRef(null, null, Arrays.asList(new Interval(20, 29), new Interval(30, 40), new Interval(41, 50)));
    BooleanFunctions.IS_VALID.getValue(input, referredByFieldRef);
}
Also used : MiningField(org.kie.pmml.api.models.MiningField) Interval(org.kie.pmml.api.models.Interval) Test(org.junit.Test)

Example 4 with Interval

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

the class BooleanFunctionsTest method getIsNotValidValueWrongTypeInput.

@Test(expected = IllegalArgumentException.class)
public void getIsNotValidValueWrongTypeInput() {
    final Object[] input = { "34" };
    MiningField referredByFieldRef = getReferredByFieldRef(null, null, Arrays.asList(new Interval(20, 29), new Interval(30, 40), new Interval(41, 50)));
    BooleanFunctions.IS_NOT_VALID.getValue(input, referredByFieldRef);
}
Also used : MiningField(org.kie.pmml.api.models.MiningField) Interval(org.kie.pmml.api.models.Interval) Test(org.junit.Test)

Example 5 with Interval

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

the class BooleanFunctionsTest method getIsNotValidValueWrongSizeInput.

@Test(expected = IllegalArgumentException.class)
public void getIsNotValidValueWrongSizeInput() {
    final Object[] input = { 34, 34 };
    MiningField referredByFieldRef = getReferredByFieldRef(null, null, Arrays.asList(new Interval(20, 29), new Interval(30, 40), new Interval(41, 50)));
    BooleanFunctions.IS_NOT_VALID.getValue(input, referredByFieldRef);
}
Also used : MiningField(org.kie.pmml.api.models.MiningField) 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