Search in sources :

Example 16 with HasClassLoaderMock

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

the class KiePMMLModelRetrieverTest method getFromCommonDataAndTransformationDictionaryAndModelWithProvider.

@Test
public void getFromCommonDataAndTransformationDictionaryAndModelWithProvider() throws Exception {
    pmml = KiePMMLUtil.load(getFileInputStream(MULTIPLE_TARGETS_SOURCE), MULTIPLE_TARGETS_SOURCE);
    TestModel model = new TestModel();
    pmml.getModels().set(0, model);
    final CommonCompilationDTO<TestModel> compilationDTO = CommonCompilationDTO.fromGeneratedPackageNameAndFields(PACKAGE_NAME, pmml, model, new HasClassLoaderMock());
    final Optional<KiePMMLModel> retrieved = getFromCommonDataAndTransformationDictionaryAndModel(compilationDTO);
    assertNotNull(retrieved);
    assertTrue(retrieved.isPresent());
    assertTrue(retrieved.get() instanceof KiePMMLTestingModel);
}
Also used : KiePMMLModel(org.kie.pmml.commons.model.KiePMMLModel) KiePMMLTestingModel(org.kie.pmml.commons.testingutility.KiePMMLTestingModel) HasClassLoaderMock(org.kie.pmml.compiler.commons.mocks.HasClassLoaderMock) PMMLModelTestUtils.getPMMLWithMiningRandomTestModel(org.kie.pmml.compiler.api.testutils.PMMLModelTestUtils.getPMMLWithMiningRandomTestModel) PMMLModelTestUtils.getPMMLWithRandomTestModel(org.kie.pmml.compiler.api.testutils.PMMLModelTestUtils.getPMMLWithRandomTestModel) TestModel(org.kie.pmml.compiler.api.mocks.TestModel) Test(org.junit.Test)

Example 17 with HasClassLoaderMock

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

the class KiePMMLModelRetrieverTest method getFromCommonDataAndTransformationDictionaryAndModelWithSourcesCompiledWithoutProvider.

@Test
public void getFromCommonDataAndTransformationDictionaryAndModelWithSourcesCompiledWithoutProvider() throws Exception {
    pmml = KiePMMLUtil.load(getFileInputStream(MINING_MODEL_WITH_NESTED_REFERS_SOURCE), MINING_MODEL_WITH_NESTED_REFERS_SOURCE);
    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);
    assertFalse(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 18 with HasClassLoaderMock

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

the class ClusteringModelImplementationProviderTest method getKiePMMLModel.

@Test
public void getKiePMMLModel() throws Exception {
    PMML pmml = TestUtils.loadFromFile(SOURCE_FILE);
    ClusteringModel model = getModel(pmml);
    final CommonCompilationDTO<ClusteringModel> compilationDTO = CommonCompilationDTO.fromGeneratedPackageNameAndFields(PACKAGE_NAME, pmml, model, new HasClassLoaderMock());
    KiePMMLClusteringModel retrieved = PROVIDER.getKiePMMLModel(compilationDTO);
    assertNotNull(retrieved);
    assertTrue(retrieved instanceof Serializable);
}
Also used : Serializable(java.io.Serializable) PMML(org.dmg.pmml.PMML) KiePMMLClusteringModel(org.kie.pmml.models.clustering.model.KiePMMLClusteringModel) HasClassLoaderMock(org.kie.pmml.compiler.commons.mocks.HasClassLoaderMock) KiePMMLClusteringModel(org.kie.pmml.models.clustering.model.KiePMMLClusteringModel) ClusteringModel(org.dmg.pmml.clustering.ClusteringModel) Test(org.junit.Test)

Example 19 with HasClassLoaderMock

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

the class DroolsModelProviderTest method getKiePMMLModelWithSourcesNoKnowledgeBuilder.

@Test(expected = KiePMMLException.class)
public void getKiePMMLModelWithSourcesNoKnowledgeBuilder() {
    final CommonCompilationDTO<Scorecard> compilationDTO = CommonCompilationDTO.fromGeneratedPackageNameAndFields(PACKAGE_NAME, pmml, scorecard, new HasClassLoaderMock());
    droolsModelProvider.getKiePMMLModelWithSources(compilationDTO);
}
Also used : Scorecard(org.dmg.pmml.scorecard.Scorecard) HasClassLoaderMock(org.kie.pmml.compiler.commons.mocks.HasClassLoaderMock) Test(org.junit.Test)

Example 20 with HasClassLoaderMock

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

the class KiePMMLNodeFactoryTest method getKiePMMLNode.

@Test
public void getKiePMMLNode() {
    final KiePMMLNode retrieved = KiePMMLNodeFactory.getKiePMMLNode(node1, getFieldsFromDataDictionaryAndDerivedFields(dataDictionary1, derivedFields1), PACKAGE_NAME, 1.0, new HasClassLoaderMock());
    assertNotNull(retrieved);
    commonVerifyNode(retrieved, node1);
}
Also used : KiePMMLNode(org.kie.pmml.models.tree.model.KiePMMLNode) 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