KiePMMLASTFactoryUtils { public static KiePMMLFieldOperatorValue getConstraintEntryFromSimplePredicates(final String fieldName, final BOOLEAN_OPERATOR containerOperator, final List<SimplePredicate> simplePredicates, final Map<String, KiePMMLOriginalTypeGeneratedType> fieldTypeMap) { List<KiePMMLOperatorValue> kiePMMLOperatorValues = simplePredicates .stream() .map(simplePredicate -> new KiePMMLOperatorValue(OPERATOR.byName(simplePredicate.getOperator().value()), getCorrectlyFormattedObject(simplePredicate, fieldTypeMap))) .collect(Collectors.toList()); return new KiePMMLFieldOperatorValue(fieldName, containerOperator, kiePMMLOperatorValues, null); } private  KiePMMLASTFactoryUtils(); static List<KiePMMLFieldOperatorValue> getConstraintEntriesFromAndOrCompoundPredicate(final CompoundPredicate compoundPredicate, final Map<String, KiePMMLOriginalTypeGeneratedType> fieldTypeMap); static List<KiePMMLFieldOperatorValue> getConstraintEntriesFromXOrCompoundPredicate(final CompoundPredicate compoundPredicate, final Map<String, KiePMMLOriginalTypeGeneratedType> fieldTypeMap); static KiePMMLFieldOperatorValue getConstraintEntryFromSimplePredicates(final String fieldName,
                                                                                   final BOOLEAN_OPERATOR containerOperator,
                                                                                   final List<SimplePredicate> simplePredicates,
                                                                                   final Map<String, KiePMMLOriginalTypeGeneratedType> fieldTypeMap); static List<KiePMMLFieldOperatorValue> getXORConstraintEntryFromSimplePredicates(final List<Predicate> predicates, final Map<String, KiePMMLOriginalTypeGeneratedType> fieldTypeMap); static Object getCorrectlyFormattedObject(final SimplePredicate simplePredicate, final Map<String, KiePMMLOriginalTypeGeneratedType> fieldTypeMap);  }
@Test public void getConstraintEntryFromSimplePredicates() { final Map<String, KiePMMLOriginalTypeGeneratedType> fieldTypeMap = new HashMap<>(); String fieldName = "FIELD_NAME"; List<SimplePredicate> simplePredicates = IntStream.range(0, 2) .mapToObj(index -> { fieldTypeMap.put(fieldName, new KiePMMLOriginalTypeGeneratedType(DataType.STRING.value(), getSanitizedClassName(fieldName.toUpperCase()))); return PMMLModelTestUtils .getSimplePredicate(fieldName, "VALUE-" + index, SimplePredicate.Operator.LESS_THAN); }) .collect(Collectors.toList()); final KiePMMLFieldOperatorValue retrieved = KiePMMLASTFactoryUtils .getConstraintEntryFromSimplePredicates(fieldName, BOOLEAN_OPERATOR.OR, simplePredicates, fieldTypeMap); assertEquals(fieldName, retrieved.getName()); assertNotNull(retrieved.getConstraintsAsString()); String expected = "value < \"VALUE-0\" || value < \"VALUE-1\""; assertEquals(expected, retrieved.getConstraintsAsString()); }