Search in sources :

Example 11 with HasClassLoaderMock

use of org.kie.pmml.compiler.commons.mocks.HasClassLoaderMock in project drools by kiegroup.

the class KiePMMLModelFactoryUtilsTest method populateGetCreatedKiePMMLMiningFieldsMethod.

@Test
public void populateGetCreatedKiePMMLMiningFieldsMethod() throws IOException {
    final CompilationDTO compilationDTO = CommonCompilationDTO.fromGeneratedPackageNameAndFields(PACKAGE_NAME, pmmlModel, model, new HasClassLoaderMock());
    KiePMMLModelFactoryUtils.populateGetCreatedKiePMMLMiningFieldsMethod(classOrInterfaceDeclaration, compilationDTO.getMiningSchema().getMiningFields(), compilationDTO.getFields());
    final MethodDeclaration retrieved = classOrInterfaceDeclaration.getMethodsByName(GET_CREATED_KIEPMMLMININGFIELDS).get(0);
    String text = getFileContent(TEST_12_SOURCE);
    BlockStmt expected = JavaParserUtils.parseBlock(text);
    assertTrue(JavaParserUtils.equalsNode(expected, retrieved.getBody().get()));
}
Also used : CommonCompilationDTO(org.kie.pmml.compiler.api.dto.CommonCompilationDTO) CompilationDTO(org.kie.pmml.compiler.api.dto.CompilationDTO) MethodDeclaration(com.github.javaparser.ast.body.MethodDeclaration) BlockStmt(com.github.javaparser.ast.stmt.BlockStmt) HasClassLoaderMock(org.kie.pmml.compiler.commons.mocks.HasClassLoaderMock) Test(org.junit.Test)

Example 12 with HasClassLoaderMock

use of org.kie.pmml.compiler.commons.mocks.HasClassLoaderMock in project drools by kiegroup.

the class KiePMMLModelFactoryUtilsTest method populateGetCreatedMiningFieldsMethod.

@Test
public void populateGetCreatedMiningFieldsMethod() throws IOException {
    final CompilationDTO compilationDTO = CommonCompilationDTO.fromGeneratedPackageNameAndFields(PACKAGE_NAME, pmmlModel, model, new HasClassLoaderMock());
    KiePMMLModelFactoryUtils.populateGetCreatedMiningFieldsMethod(classOrInterfaceDeclaration, compilationDTO.getKieMiningFields());
    final MethodDeclaration retrieved = classOrInterfaceDeclaration.getMethodsByName(GET_CREATED_MININGFIELDS).get(0);
    String text = getFileContent(TEST_14_SOURCE);
    MethodDeclaration expected = JavaParserUtils.parseMethod(text);
    assertTrue(JavaParserUtils.equalsNode(expected, retrieved));
}
Also used : CommonCompilationDTO(org.kie.pmml.compiler.api.dto.CommonCompilationDTO) CompilationDTO(org.kie.pmml.compiler.api.dto.CompilationDTO) MethodDeclaration(com.github.javaparser.ast.body.MethodDeclaration) HasClassLoaderMock(org.kie.pmml.compiler.commons.mocks.HasClassLoaderMock) Test(org.junit.Test)

Example 13 with HasClassLoaderMock

use of org.kie.pmml.compiler.commons.mocks.HasClassLoaderMock in project drools by kiegroup.

the class KiePMMLModelFactoryUtilsTest method commonPopulateGetCreatedKiePMMLMiningFieldsMethod.

@Test
public void commonPopulateGetCreatedKiePMMLMiningFieldsMethod() throws IOException {
    final CompilationDTO compilationDTO = CommonCompilationDTO.fromGeneratedPackageNameAndFields(PACKAGE_NAME, pmmlModel, model, new HasClassLoaderMock());
    final MethodDeclaration methodDeclaration = new MethodDeclaration();
    KiePMMLModelFactoryUtils.commonPopulateGetCreatedKiePMMLMiningFieldsMethod(methodDeclaration, compilationDTO.getMiningSchema().getMiningFields(), compilationDTO.getFields());
    String text = getFileContent(TEST_06_SOURCE);
    MethodDeclaration expected = JavaParserUtils.parseMethod(text);
    assertTrue(JavaParserUtils.equalsNode(expected, methodDeclaration));
}
Also used : CommonCompilationDTO(org.kie.pmml.compiler.api.dto.CommonCompilationDTO) CompilationDTO(org.kie.pmml.compiler.api.dto.CompilationDTO) MethodDeclaration(com.github.javaparser.ast.body.MethodDeclaration) HasClassLoaderMock(org.kie.pmml.compiler.commons.mocks.HasClassLoaderMock) Test(org.junit.Test)

Example 14 with HasClassLoaderMock

use of org.kie.pmml.compiler.commons.mocks.HasClassLoaderMock in project drools by kiegroup.

the class KiePMMLModelFactoryUtilsTest method initStaticGetter.

@Test
public void initStaticGetter() throws IOException {
    final CompilationDTO compilationDTO = CommonCompilationDTO.fromGeneratedPackageNameAndFields(PACKAGE_NAME, pmmlModel, model, new HasClassLoaderMock());
    KiePMMLModelFactoryUtils.initStaticGetter(compilationDTO, classOrInterfaceDeclaration);
    String text = getFileContent(TEST_04_SOURCE);
    MethodDeclaration expected = JavaParserUtils.parseMethod(text);
    assertEquals(expected.toString(), staticGetterMethod.toString());
    assertTrue(JavaParserUtils.equalsNode(expected, staticGetterMethod));
}
Also used : CommonCompilationDTO(org.kie.pmml.compiler.api.dto.CommonCompilationDTO) CompilationDTO(org.kie.pmml.compiler.api.dto.CompilationDTO) MethodDeclaration(com.github.javaparser.ast.body.MethodDeclaration) HasClassLoaderMock(org.kie.pmml.compiler.commons.mocks.HasClassLoaderMock) Test(org.junit.Test)

Example 15 with HasClassLoaderMock

use of org.kie.pmml.compiler.commons.mocks.HasClassLoaderMock in project drools by kiegroup.

the class KiePMMLModelFactoryUtilsTest method init.

@Test
public void init() throws IOException {
    final CompilationDTO compilationDTO = CommonCompilationDTO.fromGeneratedPackageNameAndFields(PACKAGE_NAME, pmmlModel, model, new HasClassLoaderMock());
    KiePMMLModelFactoryUtils.init(compilationDTO, classOrInterfaceDeclaration);
    BlockStmt body = constructorDeclaration.getBody();
    String text = getFileContent(TEST_03_SOURCE);
    Statement expected = JavaParserUtils.parseConstructorBlock(text);
    assertTrue(JavaParserUtils.equalsNode(expected, body));
}
Also used : CommonCompilationDTO(org.kie.pmml.compiler.api.dto.CommonCompilationDTO) CompilationDTO(org.kie.pmml.compiler.api.dto.CompilationDTO) Statement(com.github.javaparser.ast.stmt.Statement) BlockStmt(com.github.javaparser.ast.stmt.BlockStmt) HasClassLoaderMock(org.kie.pmml.compiler.commons.mocks.HasClassLoaderMock) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)48 HasClassLoaderMock (org.kie.pmml.compiler.commons.mocks.HasClassLoaderMock)48 RegressionModel (org.dmg.pmml.regression.RegressionModel)15 PMML (org.dmg.pmml.PMML)14 CommonCompilationDTO (org.kie.pmml.compiler.api.dto.CommonCompilationDTO)14 MethodDeclaration (com.github.javaparser.ast.body.MethodDeclaration)11 DataDictionary (org.dmg.pmml.DataDictionary)10 DataField (org.dmg.pmml.DataField)10 MiningField (org.dmg.pmml.MiningField)10 MiningSchema (org.dmg.pmml.MiningSchema)10 RegressionCompilationDTO (org.kie.pmml.models.regression.compiler.dto.RegressionCompilationDTO)10 Scorecard (org.dmg.pmml.scorecard.Scorecard)9 CompilationDTO (org.kie.pmml.compiler.api.dto.CompilationDTO)8 Serializable (java.io.Serializable)6 TreeModel (org.dmg.pmml.tree.TreeModel)6 KiePMMLModel (org.kie.pmml.commons.model.KiePMMLModel)6 ClassOrInterfaceDeclaration (com.github.javaparser.ast.body.ClassOrInterfaceDeclaration)5 Expression (com.github.javaparser.ast.expr.Expression)5 BlockStmt (com.github.javaparser.ast.stmt.BlockStmt)5 RegressionTable (org.dmg.pmml.regression.RegressionTable)5