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