Search in sources :

Example 1 with ComplexPartialScore

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);
}
Also used : KiePMMLConstant(org.kie.pmml.commons.model.expressions.KiePMMLConstant) Constant(org.dmg.pmml.Constant) Statement(com.github.javaparser.ast.stmt.Statement) BlockStmt(com.github.javaparser.ast.stmt.BlockStmt) KiePMMLComplexPartialScore(org.kie.pmml.models.scorecard.model.KiePMMLComplexPartialScore) ComplexPartialScore(org.dmg.pmml.scorecard.ComplexPartialScore) Test(org.junit.Test)

Example 2 with ComplexPartialScore

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;
}
Also used : KiePMMLConstant(org.kie.pmml.commons.model.expressions.KiePMMLConstant) Constant(org.dmg.pmml.Constant) KiePMMLComplexPartialScore(org.kie.pmml.models.scorecard.model.KiePMMLComplexPartialScore) ComplexPartialScore(org.dmg.pmml.scorecard.ComplexPartialScore)

Example 3 with ComplexPartialScore

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;
}
Also used : KiePMMLConstant(org.kie.pmml.commons.model.expressions.KiePMMLConstant) Constant(org.dmg.pmml.Constant) KiePMMLComplexPartialScore(org.kie.pmml.models.scorecard.model.KiePMMLComplexPartialScore) ComplexPartialScore(org.dmg.pmml.scorecard.ComplexPartialScore)

Example 4 with ComplexPartialScore

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);
}
Also used : FieldRef(org.dmg.pmml.FieldRef) KiePMMLFieldRef(org.kie.pmml.commons.model.expressions.KiePMMLFieldRef) KiePMMLConstant(org.kie.pmml.commons.model.expressions.KiePMMLConstant) Constant(org.dmg.pmml.Constant) KiePMMLApply(org.kie.pmml.commons.model.expressions.KiePMMLApply) Apply(org.dmg.pmml.Apply) Statement(com.github.javaparser.ast.stmt.Statement) BlockStmt(com.github.javaparser.ast.stmt.BlockStmt) KiePMMLComplexPartialScore(org.kie.pmml.models.scorecard.model.KiePMMLComplexPartialScore) ComplexPartialScore(org.dmg.pmml.scorecard.ComplexPartialScore) Test(org.junit.Test)

Example 5 with ComplexPartialScore

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);
}
Also used : FieldRef(org.dmg.pmml.FieldRef) KiePMMLFieldRef(org.kie.pmml.commons.model.expressions.KiePMMLFieldRef) Statement(com.github.javaparser.ast.stmt.Statement) BlockStmt(com.github.javaparser.ast.stmt.BlockStmt) KiePMMLComplexPartialScore(org.kie.pmml.models.scorecard.model.KiePMMLComplexPartialScore) ComplexPartialScore(org.dmg.pmml.scorecard.ComplexPartialScore) Test(org.junit.Test)

Aggregations

ComplexPartialScore (org.dmg.pmml.scorecard.ComplexPartialScore)5 KiePMMLComplexPartialScore (org.kie.pmml.models.scorecard.model.KiePMMLComplexPartialScore)5 Constant (org.dmg.pmml.Constant)4 KiePMMLConstant (org.kie.pmml.commons.model.expressions.KiePMMLConstant)4 BlockStmt (com.github.javaparser.ast.stmt.BlockStmt)3 Statement (com.github.javaparser.ast.stmt.Statement)3 Test (org.junit.Test)3 FieldRef (org.dmg.pmml.FieldRef)2 KiePMMLFieldRef (org.kie.pmml.commons.model.expressions.KiePMMLFieldRef)2 Apply (org.dmg.pmml.Apply)1 KiePMMLApply (org.kie.pmml.commons.model.expressions.KiePMMLApply)1