KiePMMLSimpleSetPredicate extends KiePMMLPredicate { @Override public boolean evaluate(Map<String, Object> values) { boolean toReturn = false; if (values.containsKey(name)) { logger.debug("found matching parameter, evaluating... "); toReturn = evaluation(values.get(name)); } return toReturn; } protected  KiePMMLSimpleSetPredicate(final String name, final List<KiePMMLExtension> extensions, final ARRAY_TYPE arrayType, final IN_NOTIN inNotIn); static Builder builder(final String name, final List<KiePMMLExtension> extensions, final ARRAY_TYPE arrayType, final IN_NOTIN inNotIn); @Override boolean evaluate(Map<String, Object> values); @Override String getName(); List<Object> getValues(); ARRAY_TYPE getArrayType(); IN_NOTIN getInNotIn(); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode();  }
@Test public void evaluateStringIn() { ARRAY_TYPE arrayType = ARRAY_TYPE.STRING; List<Object> values = getObjects(arrayType, 4); KiePMMLSimpleSetPredicate kiePMMLSimpleSetPredicate = getKiePMMLSimpleSetPredicate(values, arrayType, IN_NOTIN.IN); Map<String, Object> inputData = new HashMap<>(); inputData.put("FAKE", "NOT"); assertFalse(kiePMMLSimpleSetPredicate.evaluate(inputData)); inputData.put(SIMPLE_SET_PREDICATE_NAME, "NOT"); assertFalse(kiePMMLSimpleSetPredicate.evaluate(inputData)); inputData.put(SIMPLE_SET_PREDICATE_NAME, values.get(0)); assertTrue(kiePMMLSimpleSetPredicate.evaluate(inputData)); }
@Test public void evaluateStringNotIn() { ARRAY_TYPE arrayType = ARRAY_TYPE.STRING; List<Object> values = getObjects(arrayType, 4); KiePMMLSimpleSetPredicate kiePMMLSimpleSetPredicate = getKiePMMLSimpleSetPredicate(values, arrayType, IN_NOTIN.NOT_IN); Map<String, Object> inputData = new HashMap<>(); inputData.put("FAKE", "NOT"); assertFalse(kiePMMLSimpleSetPredicate.evaluate(inputData)); inputData.put(SIMPLE_SET_PREDICATE_NAME, values.get(0)); assertFalse(kiePMMLSimpleSetPredicate.evaluate(inputData)); inputData.put(SIMPLE_SET_PREDICATE_NAME, "NOT"); assertTrue(kiePMMLSimpleSetPredicate.evaluate(inputData)); }
@Test public void evaluateIntIn() { ARRAY_TYPE arrayType = ARRAY_TYPE.INT; List<Object> values = getObjects(arrayType, 4); KiePMMLSimpleSetPredicate kiePMMLSimpleSetPredicate = getKiePMMLSimpleSetPredicate(values, arrayType, IN_NOTIN.IN); Map<String, Object> inputData = new HashMap<>(); inputData.put("FAKE", "234"); assertFalse(kiePMMLSimpleSetPredicate.evaluate(inputData)); inputData.put(SIMPLE_SET_PREDICATE_NAME, "432"); assertFalse(kiePMMLSimpleSetPredicate.evaluate(inputData)); inputData.put(SIMPLE_SET_PREDICATE_NAME, values.get(0)); assertTrue(kiePMMLSimpleSetPredicate.evaluate(inputData)); }
@Test public void evaluateIntNotIn() { ARRAY_TYPE arrayType = ARRAY_TYPE.INT; List<Object> values = getObjects(arrayType, 4); KiePMMLSimpleSetPredicate kiePMMLSimpleSetPredicate = getKiePMMLSimpleSetPredicate(values, arrayType, IN_NOTIN.NOT_IN); Map<String, Object> inputData = new HashMap<>(); inputData.put("FAKE", "234"); assertFalse(kiePMMLSimpleSetPredicate.evaluate(inputData)); inputData.put(SIMPLE_SET_PREDICATE_NAME, values.get(0)); assertFalse(kiePMMLSimpleSetPredicate.evaluate(inputData)); inputData.put(SIMPLE_SET_PREDICATE_NAME, "432"); assertTrue(kiePMMLSimpleSetPredicate.evaluate(inputData)); }
@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)); }
@Test public void evaluateRealNotIn() { ARRAY_TYPE arrayType = ARRAY_TYPE.REAL; List<Object> values = getObjects(arrayType, 4); KiePMMLSimpleSetPredicate kiePMMLSimpleSetPredicate = getKiePMMLSimpleSetPredicate(values, arrayType, IN_NOTIN.NOT_IN); Map<String, Object> inputData = new HashMap<>(); inputData.put("FAKE", "23.4"); assertFalse(kiePMMLSimpleSetPredicate.evaluate(inputData)); inputData.put(SIMPLE_SET_PREDICATE_NAME, values.get(0)); assertFalse(kiePMMLSimpleSetPredicate.evaluate(inputData)); inputData.put(SIMPLE_SET_PREDICATE_NAME, "4.32"); assertTrue(kiePMMLSimpleSetPredicate.evaluate(inputData)); }