KiePMMLSimplePredicate 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  KiePMMLSimplePredicate(final String name, final List<KiePMMLExtension> extensions, final OPERATOR operator); static Builder builder(String name, List<KiePMMLExtension> extensions, OPERATOR operator); @Override boolean evaluate(Map<String, Object> values); @Override String getName(); OPERATOR getOperator(); Object getValue(); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode();  }
@Test public void evaluateStringEqual() { Object value = "43"; KiePMMLSimplePredicate kiePMMLSimplePredicate = getKiePMMLSimplePredicate(OPERATOR.EQUAL, value); Map<String, Object> inputData = new HashMap<>(); inputData.put("FAKE", "NOT"); assertFalse(kiePMMLSimplePredicate.evaluate(inputData)); inputData = new HashMap<>(); inputData.put(SIMPLE_PREDICATE_NAME, "NOT"); assertFalse(kiePMMLSimplePredicate.evaluate(inputData)); inputData = new HashMap<>(); inputData.put(SIMPLE_PREDICATE_NAME, value); assertTrue(kiePMMLSimplePredicate.evaluate(inputData)); }
@Test public void evaluateStringNotEqual() { Object value = "43"; KiePMMLSimplePredicate kiePMMLSimplePredicate = getKiePMMLSimplePredicate(OPERATOR.NOT_EQUAL, value); Map<String, Object> inputData = new HashMap<>(); inputData.put("FAKE", "NOT"); assertFalse(kiePMMLSimplePredicate.evaluate(inputData)); inputData = new HashMap<>(); inputData.put(SIMPLE_PREDICATE_NAME, value); assertFalse(kiePMMLSimplePredicate.evaluate(inputData)); inputData = new HashMap<>(); inputData.put(SIMPLE_PREDICATE_NAME, "NOT"); assertTrue(kiePMMLSimplePredicate.evaluate(inputData)); }
@Test(expected = IllegalArgumentException.class) public void evaluateStringIsNotMissing() { Object value = "43"; KiePMMLSimplePredicate kiePMMLSimplePredicate = getKiePMMLSimplePredicate(OPERATOR.IS_NOT_MISSING, value); Map<String, Object> inputData = new HashMap<>(); inputData.put(SIMPLE_PREDICATE_NAME, value); kiePMMLSimplePredicate.evaluate(inputData); }
@Test(expected = IllegalArgumentException.class) public void evaluateStringIsMissing() { Object value = "43"; KiePMMLSimplePredicate kiePMMLSimplePredicate = getKiePMMLSimplePredicate(OPERATOR.IS_MISSING, value); Map<String, Object> inputData = new HashMap<>(); inputData.put(SIMPLE_PREDICATE_NAME, value); kiePMMLSimplePredicate.evaluate(inputData); }