use of org.kie.pmml.compiler.commons.codegenfactories.KiePMMLModelFactoryUtils.GET_CREATED_KIEPMMLTARGETS in project drools by kiegroup.
the class KiePMMLModelFactoryUtilsTest method populateGetCreatedKiePMMLTargetsMethod.
@Test
public void populateGetCreatedKiePMMLTargetsMethod() throws IOException {
Random random = new Random();
List<TargetField> kiePMMLTargets = IntStream.range(0, 3).mapToObj(i -> new TargetField(Collections.emptyList(), OP_TYPE.byName(getRandomOpType().value()), "Target-" + i, CAST_INTEGER.byName(getRandomCastInteger().value()), (double) random.nextInt(20), (double) random.nextInt(60) + 20, (double) random.nextInt(100) / 100, (double) random.nextInt(100) / 100)).collect(Collectors.toList());
String opType0 = OP_TYPE.class.getCanonicalName() + "." + kiePMMLTargets.get(0).getOpType().toString();
String castInteger0 = CAST_INTEGER.class.getCanonicalName() + "." + kiePMMLTargets.get(0).getCastInteger().toString();
String opType1 = OP_TYPE.class.getCanonicalName() + "." + kiePMMLTargets.get(1).getOpType().toString();
String castInteger1 = CAST_INTEGER.class.getCanonicalName() + "." + kiePMMLTargets.get(1).getCastInteger().toString();
String opType2 = OP_TYPE.class.getCanonicalName() + "." + kiePMMLTargets.get(2).getOpType().toString();
String castInteger2 = CAST_INTEGER.class.getCanonicalName() + "." + kiePMMLTargets.get(2).getCastInteger().toString();
KiePMMLModelFactoryUtils.populateGetCreatedKiePMMLTargetsMethod(classOrInterfaceDeclaration, kiePMMLTargets);
final MethodDeclaration retrieved = classOrInterfaceDeclaration.getMethodsByName(GET_CREATED_KIEPMMLTARGETS).get(0);
String text = getFileContent(TEST_10_SOURCE);
MethodDeclaration expected = JavaParserUtils.parseMethod(String.format(text, kiePMMLTargets.get(0).getName(), opType0, castInteger0, kiePMMLTargets.get(0).getMin(), kiePMMLTargets.get(0).getMax(), kiePMMLTargets.get(0).getRescaleConstant(), kiePMMLTargets.get(0).getRescaleFactor(), kiePMMLTargets.get(1).getName(), opType1, castInteger1, kiePMMLTargets.get(1).getMin(), kiePMMLTargets.get(1).getMax(), kiePMMLTargets.get(1).getRescaleConstant(), kiePMMLTargets.get(1).getRescaleFactor(), kiePMMLTargets.get(2).getName(), opType2, castInteger2, kiePMMLTargets.get(2).getMin(), kiePMMLTargets.get(2).getMax(), kiePMMLTargets.get(2).getRescaleConstant(), kiePMMLTargets.get(2).getRescaleFactor()));
assertTrue(JavaParserUtils.equalsNode(expected, retrieved));
}
Aggregations