use of org.kie.pmml.api.enums.ARRAY_TYPE in project drools by kiegroup.
the class KiePMMLCompoundPredicateTest method evaluateCompoundPredicateSinglePredicate.
@Test
public void evaluateCompoundPredicateSinglePredicate() {
ARRAY_TYPE arrayType = ARRAY_TYPE.STRING;
List<Object> stringValues = getObjects(arrayType, 4);
KiePMMLSimpleSetPredicate kiePMMLSimpleSetPredicateString = getKiePMMLSimpleSetPredicate(SIMPLE_SET_PREDICATE_STRING_NAME, stringValues, arrayType, IN_NOTIN.IN);
KiePMMLCompoundPredicate kiePMMLCompoundPredicate = getKiePMMLCompoundPredicate(BOOLEAN_OPERATOR.AND, Collections.singletonList(kiePMMLSimpleSetPredicateString));
Map<String, Object> inputData = new HashMap<>();
inputData.put(SIMPLE_SET_PREDICATE_STRING_NAME, "NOT");
assertFalse(kiePMMLCompoundPredicate.evaluate(inputData));
inputData.put(SIMPLE_SET_PREDICATE_STRING_NAME, stringValues.get(0));
assertTrue(kiePMMLCompoundPredicate.evaluate(inputData));
arrayType = ARRAY_TYPE.INT;
List<Object> intValues = getObjects(arrayType, 4);
KiePMMLSimpleSetPredicate kiePMMLSimpleSetPredicateInt = getKiePMMLSimpleSetPredicate(SIMPLE_SET_PREDICATE_INT_NAME, intValues, arrayType, IN_NOTIN.NOT_IN);
kiePMMLCompoundPredicate = getKiePMMLCompoundPredicate(BOOLEAN_OPERATOR.AND, Collections.singletonList(kiePMMLSimpleSetPredicateInt));
inputData = new HashMap<>();
inputData.put(SIMPLE_SET_PREDICATE_INT_NAME, intValues.get(0));
assertFalse(kiePMMLCompoundPredicate.evaluate(inputData));
inputData.put(SIMPLE_SET_PREDICATE_INT_NAME, "234");
assertTrue(kiePMMLCompoundPredicate.evaluate(inputData));
}
use of org.kie.pmml.api.enums.ARRAY_TYPE in project drools by kiegroup.
the class KiePMMLCompoundPredicateTest method evaluateCompoundPredicateOr.
@Test
public void evaluateCompoundPredicateOr() {
ARRAY_TYPE arrayType = ARRAY_TYPE.STRING;
List<Object> stringValues = getObjects(arrayType, 4);
KiePMMLSimpleSetPredicate kiePMMLSimpleSetPredicateString = getKiePMMLSimpleSetPredicate(SIMPLE_SET_PREDICATE_STRING_NAME, stringValues, arrayType, IN_NOTIN.IN);
arrayType = ARRAY_TYPE.INT;
List<Object> intValues = getObjects(arrayType, 4);
KiePMMLSimpleSetPredicate kiePMMLSimpleSetPredicateInt = getKiePMMLSimpleSetPredicate(SIMPLE_SET_PREDICATE_INT_NAME, intValues, arrayType, IN_NOTIN.NOT_IN);
KiePMMLCompoundPredicate kiePMMLCompoundPredicate = getKiePMMLCompoundPredicate(BOOLEAN_OPERATOR.OR, Arrays.asList(kiePMMLSimpleSetPredicateString, kiePMMLSimpleSetPredicateInt));
Map<String, Object> inputData = new HashMap<>();
inputData.put(SIMPLE_SET_PREDICATE_STRING_NAME, "NOT");
inputData.put(SIMPLE_SET_PREDICATE_INT_NAME, intValues.get(0));
assertFalse(kiePMMLCompoundPredicate.evaluate(inputData));
inputData.put(SIMPLE_SET_PREDICATE_STRING_NAME, stringValues.get(0));
inputData.put(SIMPLE_SET_PREDICATE_INT_NAME, intValues.get(0));
assertTrue(kiePMMLCompoundPredicate.evaluate(inputData));
inputData = new HashMap<>();
inputData.put(SIMPLE_SET_PREDICATE_STRING_NAME, "NOT");
inputData.put(SIMPLE_SET_PREDICATE_INT_NAME, "234");
assertTrue(kiePMMLCompoundPredicate.evaluate(inputData));
inputData = new HashMap<>();
inputData.put(SIMPLE_SET_PREDICATE_STRING_NAME, stringValues.get(0));
inputData.put(SIMPLE_SET_PREDICATE_INT_NAME, "234");
assertTrue(kiePMMLCompoundPredicate.evaluate(inputData));
}
use of org.kie.pmml.api.enums.ARRAY_TYPE in project drools by kiegroup.
the class KiePMMLSimpleSetPredicateTest method evaluationIntNotIn.
@Test
public void evaluationIntNotIn() {
ARRAY_TYPE arrayType = ARRAY_TYPE.INT;
List<Object> values = getObjects(arrayType, 1);
KiePMMLSimpleSetPredicate kiePMMLSimpleSetPredicate = getKiePMMLSimpleSetPredicate(values, arrayType, IN_NOTIN.NOT_IN);
assertFalse(kiePMMLSimpleSetPredicate.evaluation(values.get(0)));
assertTrue(kiePMMLSimpleSetPredicate.evaluation("234"));
}
use of org.kie.pmml.api.enums.ARRAY_TYPE in project drools by kiegroup.
the class KiePMMLSimpleSetPredicateTest method evaluateRealIn.
@Test
public void evaluateRealIn() {
ARRAY_TYPE arrayType = ARRAY_TYPE.REAL;
List<Object> values = getObjects(arrayType, 4);
KiePMMLSimpleSetPredicate kiePMMLSimpleSetPredicate = getKiePMMLSimpleSetPredicate(values, arrayType, IN_NOTIN.IN);
Map<String, Object> inputData = new HashMap<>();
inputData.put("FAKE", "23.4");
assertFalse(kiePMMLSimpleSetPredicate.evaluate(inputData));
inputData.put(SIMPLE_SET_PREDICATE_NAME, "4.32");
assertFalse(kiePMMLSimpleSetPredicate.evaluate(inputData));
inputData.put(SIMPLE_SET_PREDICATE_NAME, values.get(0));
assertTrue(kiePMMLSimpleSetPredicate.evaluate(inputData));
}
use of org.kie.pmml.api.enums.ARRAY_TYPE in project drools by kiegroup.
the class KiePMMLSimpleSetPredicateTest method evaluationIntIn.
@Test
public void evaluationIntIn() {
ARRAY_TYPE arrayType = ARRAY_TYPE.INT;
List<Object> values = getObjects(arrayType, 1);
KiePMMLSimpleSetPredicate kiePMMLSimpleSetPredicate = getKiePMMLSimpleSetPredicate(values, arrayType, IN_NOTIN.IN);
assertFalse(kiePMMLSimpleSetPredicate.evaluation("234"));
assertTrue(kiePMMLSimpleSetPredicate.evaluation(values.get(0)));
}
Aggregations