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);
}
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));
}
}
Aggregations