use of org.dmg.pmml.Constant in project drools by kiegroup.
the class KiePMMLDerivedFieldFactoryTest method getDerivedFieldVariableDeclarationWithApply.
@Test
public void getDerivedFieldVariableDeclarationWithApply() 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);
DerivedField derivedField = new DerivedField();
derivedField.setName(FieldName.create(PARAM_1));
derivedField.setDataType(DataType.DOUBLE);
derivedField.setOpType(OpType.CONTINUOUS);
derivedField.setExpression(apply);
String dataType = getDATA_TYPEString(derivedField.getDataType());
String opType = getOP_TYPEString(derivedField.getOpType());
BlockStmt retrieved = KiePMMLDerivedFieldFactory.getDerivedFieldVariableDeclaration(variableName, derivedField);
String text = getFileContent(TEST_03_SOURCE);
Statement expected = JavaParserUtils.parseBlock(String.format(text, constant.getValue(), fieldRef.getField().getValue(), apply.getFunction(), apply.getInvalidValueTreatment().value(), variableName, derivedField.getName().getValue(), dataType, opType));
assertTrue(JavaParserUtils.equalsNode(expected, retrieved));
List<Class<?>> imports = Arrays.asList(KiePMMLConstant.class, KiePMMLFieldRef.class, KiePMMLApply.class, KiePMMLDerivedField.class, Arrays.class, Collections.class);
commonValidateCompilationWithImports(retrieved, imports);
}
use of org.dmg.pmml.Constant in project drools by kiegroup.
the class KiePMMLLocalTransformationsFactoryTest method getDerivedField.
private DerivedField getDerivedField(int counter) {
Constant constant = new Constant();
constant.setValue(value1);
DerivedField toReturn = new DerivedField();
toReturn.setName(FieldName.create(PARAM_2 + counter));
toReturn.setDataType(DataType.DOUBLE);
toReturn.setOpType(OpType.CONTINUOUS);
toReturn.setExpression(constant);
return toReturn;
}
use of org.dmg.pmml.Constant 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.Constant 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.Constant 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;
}
Aggregations