use of org.dmg.pmml.scorecard.ComplexPartialScore in project drools by kiegroup.
the class KiePMMLComplexPartialScoreFactoryTest method getComplexPartialScoreVariableDeclaration.
@Test
public void getComplexPartialScoreVariableDeclaration() throws IOException {
final String variableName = "variableName";
Constant constant = new Constant();
constant.setValue(value1);
ComplexPartialScore complexPartialScore = new ComplexPartialScore();
complexPartialScore.setExpression(constant);
BlockStmt retrieved = KiePMMLComplexPartialScoreFactory.getComplexPartialScoreVariableDeclaration(variableName, complexPartialScore);
String text = getFileContent(TEST_01_SOURCE);
Statement expected = JavaParserUtils.parseBlock(String.format(text, constant.getValue(), variableName));
assertTrue(JavaParserUtils.equalsNode(expected, retrieved));
List<Class<?>> imports = Arrays.asList(KiePMMLConstant.class, KiePMMLComplexPartialScore.class, Collections.class);
commonValidateCompilationWithImports(retrieved, imports);
}
use of org.dmg.pmml.scorecard.ComplexPartialScore in project drools by kiegroup.
the class KiePMMLAttributeFactoryTest method getComplexPartialScore.
private ComplexPartialScore getComplexPartialScore() {
Constant constant = new Constant();
constant.setValue(value1);
ComplexPartialScore toReturn = new ComplexPartialScore();
toReturn.setExpression(constant);
return toReturn;
}
use of org.dmg.pmml.scorecard.ComplexPartialScore in project drools by kiegroup.
the class KiePMMLCharacteristicFactoryTest method getComplexPartialScore.
private ComplexPartialScore getComplexPartialScore() {
Constant constant = new Constant();
constant.setValue(value1);
ComplexPartialScore toReturn = new ComplexPartialScore();
toReturn.setExpression(constant);
return toReturn;
}
use of org.dmg.pmml.scorecard.ComplexPartialScore in project drools by kiegroup.
the class KiePMMLComplexPartialScoreFactoryTest method getComplexPartialScoreVariableDeclarationWithApply.
@Test
public void getComplexPartialScoreVariableDeclarationWithApply() throws IOException {
final String variableName = "variableName";
Constant constant = new Constant();
constant.setValue(value1);
FieldRef fieldRef = new FieldRef();
fieldRef.setField(FieldName.create("FIELD_REF"));
Apply apply = new Apply();
apply.setFunction("/");
apply.addExpressions(constant, fieldRef);
ComplexPartialScore complexPartialScore = new ComplexPartialScore();
complexPartialScore.setExpression(apply);
BlockStmt retrieved = KiePMMLComplexPartialScoreFactory.getComplexPartialScoreVariableDeclaration(variableName, complexPartialScore);
String text = getFileContent(TEST_03_SOURCE);
Statement expected = JavaParserUtils.parseBlock(String.format(text, constant.getValue(), fieldRef.getField().getValue(), apply.getFunction(), apply.getInvalidValueTreatment().value(), variableName));
assertTrue(JavaParserUtils.equalsNode(expected, retrieved));
List<Class<?>> imports = Arrays.asList(KiePMMLConstant.class, KiePMMLFieldRef.class, KiePMMLApply.class, KiePMMLComplexPartialScore.class, Arrays.class, Collections.class);
commonValidateCompilationWithImports(retrieved, imports);
}
use of org.dmg.pmml.scorecard.ComplexPartialScore in project drools by kiegroup.
the class KiePMMLComplexPartialScoreFactoryTest method getComplexPartialScoreVariableDeclarationWithFieldRef.
@Test
public void getComplexPartialScoreVariableDeclarationWithFieldRef() throws IOException {
final String variableName = "variableName";
FieldRef fieldRef = new FieldRef();
fieldRef.setField(FieldName.create("FIELD_REF"));
ComplexPartialScore complexPartialScore = new ComplexPartialScore();
complexPartialScore.setExpression(fieldRef);
BlockStmt retrieved = KiePMMLComplexPartialScoreFactory.getComplexPartialScoreVariableDeclaration(variableName, complexPartialScore);
String text = getFileContent(TEST_02_SOURCE);
Statement expected = JavaParserUtils.parseBlock(String.format(text, fieldRef.getField().getValue(), variableName));
assertTrue(JavaParserUtils.equalsNode(expected, retrieved));
List<Class<?>> imports = Arrays.asList(KiePMMLFieldRef.class, KiePMMLComplexPartialScore.class, Collections.class);
commonValidateCompilationWithImports(retrieved, imports);
}
Aggregations