Search in sources :

Example 26 with HasClassLoaderMock

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

the class KiePMMLModelFactoryUtilsTest method commonPopulateGetCreatedKiePMMLOutputFieldsMethod.

@Test
public void commonPopulateGetCreatedKiePMMLOutputFieldsMethod() throws IOException {
    final CompilationDTO compilationDTO = CommonCompilationDTO.fromGeneratedPackageNameAndFields(PACKAGE_NAME, pmmlModel, model, new HasClassLoaderMock());
    final MethodDeclaration methodDeclaration = new MethodDeclaration();
    KiePMMLModelFactoryUtils.commonPopulateGetCreatedKiePMMLOutputFieldsMethod(methodDeclaration, compilationDTO.getOutput().getOutputFields());
    String text = getFileContent(TEST_05_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 27 with HasClassLoaderMock

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

the class KiePMMLModelRetrieverTest method getFromDataDictionaryAndModelWithSourcesWithoutProvider.

@Test
public void getFromDataDictionaryAndModelWithSourcesWithoutProvider() throws Exception {
    pmml = KiePMMLUtil.load(getFileInputStream(ONE_MINING_TARGET_SOURCE), ONE_MINING_TARGET_SOURCE);
    final CommonCompilationDTO compilationDTO = CommonCompilationDTO.fromGeneratedPackageNameAndFields(PACKAGE_NAME, pmml, pmml.getModels().get(0), new HasClassLoaderMock());
    final Optional<KiePMMLModel> retrieved = getFromCommonDataAndTransformationDictionaryAndModelWithSources(compilationDTO);
    assertNotNull(retrieved);
    assertFalse(retrieved.isPresent());
}
Also used : KiePMMLModel(org.kie.pmml.commons.model.KiePMMLModel) CommonCompilationDTO(org.kie.pmml.compiler.api.dto.CommonCompilationDTO) HasClassLoaderMock(org.kie.pmml.compiler.commons.mocks.HasClassLoaderMock) Test(org.junit.Test)

Example 28 with HasClassLoaderMock

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

the class KiePMMLModelRetrieverTest method getFromCommonDataAndTransformationDictionaryAndModelWithoutProvider.

@Test
public void getFromCommonDataAndTransformationDictionaryAndModelWithoutProvider() throws Exception {
    pmml = KiePMMLUtil.load(getFileInputStream(ONE_MINING_TARGET_SOURCE), ONE_MINING_TARGET_SOURCE);
    final CommonCompilationDTO compilationDTO = CommonCompilationDTO.fromGeneratedPackageNameAndFields(PACKAGE_NAME, pmml, pmml.getModels().get(0), new HasClassLoaderMock());
    final Optional<KiePMMLModel> retrieved = getFromCommonDataAndTransformationDictionaryAndModel(compilationDTO);
    assertNotNull(retrieved);
    assertFalse(retrieved.isPresent());
}
Also used : KiePMMLModel(org.kie.pmml.commons.model.KiePMMLModel) CommonCompilationDTO(org.kie.pmml.compiler.api.dto.CommonCompilationDTO) HasClassLoaderMock(org.kie.pmml.compiler.commons.mocks.HasClassLoaderMock) Test(org.junit.Test)

Example 29 with HasClassLoaderMock

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

the class KiePMMLModelRetrieverTest method getFromCommonDataAndTransformationDictionaryAndModelWithSourcesCompiledWithProvider.

@Test
public void getFromCommonDataAndTransformationDictionaryAndModelWithSourcesCompiledWithProvider() throws Exception {
    pmml = getPMMLWithMiningRandomTestModel();
    MiningModel parentModel = (MiningModel) pmml.getModels().get(0);
    Model model = parentModel.getSegmentation().getSegments().get(0).getModel();
    final CommonCompilationDTO compilationDTO = CommonCompilationDTO.fromGeneratedPackageNameAndFields(PACKAGE_NAME, pmml, model, new HasClassLoaderMock());
    final Optional<KiePMMLModel> retrieved = getFromCommonDataAndTransformationDictionaryAndModelWithSourcesCompiled(compilationDTO);
    assertNotNull(retrieved);
    assertTrue(retrieved.isPresent());
}
Also used : MiningModel(org.dmg.pmml.mining.MiningModel) KiePMMLModel(org.kie.pmml.commons.model.KiePMMLModel) PMMLModelTestUtils.getPMMLWithMiningRandomTestModel(org.kie.pmml.compiler.api.testutils.PMMLModelTestUtils.getPMMLWithMiningRandomTestModel) Model(org.dmg.pmml.Model) PMMLModelTestUtils.getPMMLWithRandomTestModel(org.kie.pmml.compiler.api.testutils.PMMLModelTestUtils.getPMMLWithRandomTestModel) KiePMMLTestingModel(org.kie.pmml.commons.testingutility.KiePMMLTestingModel) TestModel(org.kie.pmml.compiler.api.mocks.TestModel) KiePMMLModel(org.kie.pmml.commons.model.KiePMMLModel) KiePMMLModelRetriever.getFromCommonDataAndTransformationDictionaryAndModel(org.kie.pmml.compiler.commons.implementations.KiePMMLModelRetriever.getFromCommonDataAndTransformationDictionaryAndModel) MiningModel(org.dmg.pmml.mining.MiningModel) CommonCompilationDTO(org.kie.pmml.compiler.api.dto.CommonCompilationDTO) HasClassLoaderMock(org.kie.pmml.compiler.commons.mocks.HasClassLoaderMock) Test(org.junit.Test)

Example 30 with HasClassLoaderMock

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

the class KiePMMLModelRetrieverTest method getFromCommonDataAndTransformationDictionaryAndModelWithSourcesWithProvider.

@Test
public void getFromCommonDataAndTransformationDictionaryAndModelWithSourcesWithProvider() {
    pmml = getPMMLWithRandomTestModel();
    final CommonCompilationDTO compilationDTO = CommonCompilationDTO.fromGeneratedPackageNameAndFields(PACKAGE_NAME, pmml, pmml.getModels().get(0), new HasClassLoaderMock());
    final Optional<KiePMMLModel> retrieved = getFromCommonDataAndTransformationDictionaryAndModelWithSources(compilationDTO);
    assertNotNull(retrieved);
}
Also used : KiePMMLModel(org.kie.pmml.commons.model.KiePMMLModel) CommonCompilationDTO(org.kie.pmml.compiler.api.dto.CommonCompilationDTO) 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