KiePMMLPredicateFactory { static List<Object> getObjectsFromArray(Array source) { Array.Type type = source.getType(); List<Object> toReturn = new ArrayList<>(); String stringValue = (String) source.getValue(); String[] valuesArray = stringValue.split(" "); for (String s : valuesArray) { switch (type) { case INT: toReturn.add(Integer.valueOf(s)); break; case STRING: toReturn.add(s); break; case REAL: toReturn.add(Double.valueOf(s)); break; default: throw new KiePMMLException("Unknown Array " + type); } } return toReturn; } private  KiePMMLPredicateFactory(); static List<KiePMMLPredicate> getPredicates(List<Predicate> predicates, DataDictionary dataDictionary); static KiePMMLPredicate getPredicate(Predicate predicate, DataDictionary dataDictionary); static KiePMMLSimplePredicate getKiePMMLSimplePredicate(SimplePredicate predicate, DataType dataType); static KiePMMLSimpleSetPredicate getKiePMMLSimpleSetPredicate(SimpleSetPredicate predicate); static KiePMMLCompoundPredicate getKiePMMLCompoundPredicate(CompoundPredicate predicate,
                                                                       DataDictionary dataDictionary); static KiePMMLTruePredicate getKiePMMLTruePredicate(); static KiePMMLFalsePredicate getKiePMMLFalsePredicate(); static Map<String, String> getPredicateSourcesMap(final KiePMMLPredicate kiePMMLPredicate,
                                                             final String packageName);  }
@Test public void getObjectsFromArray() { List<String> values = Arrays.asList("32", "11", "43"); Array array = getArray(Array.Type.INT, values); List<Object> retrieved = KiePMMLPredicateFactory.getObjectsFromArray(array); assertEquals(values.size(), retrieved.size()); for (int i = 0; i < values.size(); i++) { Object obj = retrieved.get(i); assertTrue(obj instanceof Integer); Integer expected = Integer.valueOf(values.get(i)); assertEquals(expected, obj); } values = Arrays.asList("just", "11", "fun"); array = getArray(Array.Type.STRING, values); retrieved = KiePMMLPredicateFactory.getObjectsFromArray(array); assertEquals(values.size(), retrieved.size()); for (int i = 0; i < values.size(); i++) { Object obj = retrieved.get(i); assertTrue(obj instanceof String); assertEquals(values.get(i), obj); } values = Arrays.asList("23.11", "11", "123.123"); array = getArray(Array.Type.REAL, values); retrieved = KiePMMLPredicateFactory.getObjectsFromArray(array); assertEquals(values.size(), retrieved.size()); for (int i = 0; i < values.size(); i++) { Object obj = retrieved.get(i); assertTrue(obj instanceof Double); Double expected = Double.valueOf(values.get(i)); assertEquals(expected, obj); } }