Search in sources :

Example 1 with MiningField

use of org.kie.pmml.api.models.MiningField 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 MiningField

use of org.kie.pmml.api.models.MiningField 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 MiningField

use of org.kie.pmml.api.models.MiningField 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 MiningField

use of org.kie.pmml.api.models.MiningField 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 MiningField

use of org.kie.pmml.api.models.MiningField 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

MiningField (org.kie.pmml.api.models.MiningField)18 Test (org.junit.Test)14 Interval (org.kie.pmml.api.models.Interval)11 INVALID_VALUE_TREATMENT_METHOD (org.kie.pmml.api.enums.INVALID_VALUE_TREATMENT_METHOD)8 List (java.util.List)7 Collections (java.util.Collections)6 Collectors (java.util.stream.Collectors)6 DATA_TYPE (org.kie.pmml.api.enums.DATA_TYPE)6 Arrays (java.util.Arrays)5 Optional (java.util.Optional)5 IntStream (java.util.stream.IntStream)5 Assert.assertEquals (org.junit.Assert.assertEquals)5 Assert.assertTrue (org.junit.Assert.assertTrue)5 ConstructorDeclaration (com.github.javaparser.ast.body.ConstructorDeclaration)4 Expression (com.github.javaparser.ast.expr.Expression)4 MethodCallExpr (com.github.javaparser.ast.expr.MethodCallExpr)4 NameExpr (com.github.javaparser.ast.expr.NameExpr)4 NullLiteralExpr (com.github.javaparser.ast.expr.NullLiteralExpr)4 BlockStmt (com.github.javaparser.ast.stmt.BlockStmt)4 ArrayList (java.util.ArrayList)4