Search in sources :

Example 11 with HasKnowledgeBuilderMock

use of org.kie.pmml.models.drools.commons.implementations.HasKnowledgeBuilderMock in project drools by kiegroup.

the class DroolsModelProviderTest method getKiePMMLModelWithSourcesWithKnowledgeBuilder.

@Test
public void getKiePMMLModelWithSourcesWithKnowledgeBuilder() {
    KnowledgeBuilderImpl knowledgeBuilder = new KnowledgeBuilderImpl();
    final CommonCompilationDTO<Scorecard> compilationDTO = CommonCompilationDTO.fromGeneratedPackageNameAndFields(PACKAGE_NAME, pmml, scorecard, new HasKnowledgeBuilderMock(knowledgeBuilder));
    KiePMMLDroolsModelWithSources retrieved = droolsModelProvider.getKiePMMLModelWithSources(compilationDTO);
    assertNotNull(retrieved);
    assertEquals(SOURCE_MAP, retrieved.getSourcesMap());
    String expectedPackageName = compilationDTO.getPackageName();
    assertEquals(expectedPackageName, retrieved.getKModulePackageName());
    assertEquals(scorecard.getModelName(), retrieved.getName());
    PackageDescr packageDescr = knowledgeBuilder.getPackageDescrs(expectedPackageName).get(0);
    commonVerifyPackageDescr(packageDescr, expectedPackageName);
    assertNotNull(retrieved);
    final String rootPath = expectedPackageName + ".";
    commonVerifyRulesSourcesMap(retrieved.getRulesSourcesMap(), packageDescr, rootPath);
}
Also used : HasKnowledgeBuilderMock(org.kie.pmml.models.drools.commons.implementations.HasKnowledgeBuilderMock) KnowledgeBuilderImpl(org.drools.compiler.builder.impl.KnowledgeBuilderImpl) Scorecard(org.dmg.pmml.scorecard.Scorecard) PackageDescr(org.drools.drl.ast.descr.PackageDescr) CompositePackageDescr(org.drools.compiler.lang.descr.CompositePackageDescr) KiePMMLDroolsModelWithSources(org.kie.pmml.models.drools.commons.model.KiePMMLDroolsModelWithSources) Test(org.junit.Test)

Example 12 with HasKnowledgeBuilderMock

use of org.kie.pmml.models.drools.commons.implementations.HasKnowledgeBuilderMock in project drools by kiegroup.

the class TreeModelImplementationProviderTest method getKiePMMLModelWithSources.

@Test
public void getKiePMMLModelWithSources() throws Exception {
    final PMML pmml = getPMML(SOURCE_1);
    KnowledgeBuilderImpl knowledgeBuilder = new KnowledgeBuilderImpl();
    final CommonCompilationDTO<TreeModel> compilationDTO = CommonCompilationDTO.fromGeneratedPackageNameAndFields(PACKAGE_NAME, pmml, (TreeModel) pmml.getModels().get(0), new HasKnowledgeBuilderMock(knowledgeBuilder));
    final KiePMMLDroolsModelWithSources retrieved = PROVIDER.getKiePMMLModelWithSources(compilationDTO);
    assertNotNull(retrieved);
    commonVerifyIsDeepCloneable(retrieved);
}
Also used : TreeModel(org.dmg.pmml.tree.TreeModel) KiePMMLTreeModel(org.kie.pmml.models.drools.tree.model.KiePMMLTreeModel) HasKnowledgeBuilderMock(org.kie.pmml.models.drools.commons.implementations.HasKnowledgeBuilderMock) KnowledgeBuilderImpl(org.drools.compiler.builder.impl.KnowledgeBuilderImpl) PMML(org.dmg.pmml.PMML) KiePMMLDroolsModelWithSources(org.kie.pmml.models.drools.commons.model.KiePMMLDroolsModelWithSources) Test(org.junit.Test)

Example 13 with HasKnowledgeBuilderMock

use of org.kie.pmml.models.drools.commons.implementations.HasKnowledgeBuilderMock in project drools by kiegroup.

the class KiePMMLTreeModelFactoryTest method getKiePMMLTreeModel.

@Test
public void getKiePMMLTreeModel() throws InstantiationException, IllegalAccessException {
    final Map<String, KiePMMLOriginalTypeGeneratedType> fieldTypeMap = getFieldTypeMap(pmml.getDataDictionary(), pmml.getTransformationDictionary(), treeModel.getLocalTransformations());
    KnowledgeBuilderImpl knowledgeBuilder = new KnowledgeBuilderImpl();
    final CommonCompilationDTO<TreeModel> compilationDTO = CommonCompilationDTO.fromGeneratedPackageNameAndFields(PACKAGE_NAME, pmml, treeModel, new HasKnowledgeBuilderMock(knowledgeBuilder));
    final DroolsCompilationDTO<TreeModel> droolsCompilationDTO = DroolsCompilationDTO.fromCompilationDTO(compilationDTO, fieldTypeMap);
    KiePMMLTreeModel retrieved = KiePMMLTreeModelFactory.getKiePMMLTreeModel(droolsCompilationDTO);
    assertNotNull(retrieved);
    assertEquals(treeModel.getModelName(), retrieved.getName());
    assertEquals(TARGET_FIELD, retrieved.getTargetField());
}
Also used : KiePMMLTreeModel(org.kie.pmml.models.drools.tree.model.KiePMMLTreeModel) TreeModel(org.dmg.pmml.tree.TreeModel) HasKnowledgeBuilderMock(org.kie.pmml.models.drools.commons.implementations.HasKnowledgeBuilderMock) KiePMMLTreeModel(org.kie.pmml.models.drools.tree.model.KiePMMLTreeModel) KnowledgeBuilderImpl(org.drools.compiler.builder.impl.KnowledgeBuilderImpl) KiePMMLOriginalTypeGeneratedType(org.kie.pmml.models.drools.tuples.KiePMMLOriginalTypeGeneratedType) Test(org.junit.Test)

Example 14 with HasKnowledgeBuilderMock

use of org.kie.pmml.models.drools.commons.implementations.HasKnowledgeBuilderMock in project drools by kiegroup.

the class KiePMMLTreeModelFactoryTest method getKiePMMLScorecardModelSourcesMap.

@Test
public void getKiePMMLScorecardModelSourcesMap() {
    final Map<String, KiePMMLOriginalTypeGeneratedType> fieldTypeMap = getFieldTypeMap(pmml.getDataDictionary(), pmml.getTransformationDictionary(), treeModel.getLocalTransformations());
    KnowledgeBuilderImpl knowledgeBuilder = new KnowledgeBuilderImpl();
    final CommonCompilationDTO<TreeModel> compilationDTO = CommonCompilationDTO.fromGeneratedPackageNameAndFields(PACKAGE_NAME, pmml, treeModel, new HasKnowledgeBuilderMock(knowledgeBuilder));
    final DroolsCompilationDTO<TreeModel> droolsCompilationDTO = DroolsCompilationDTO.fromCompilationDTO(compilationDTO, fieldTypeMap);
    Map<String, String> retrieved = KiePMMLTreeModelFactory.getKiePMMLTreeModelSourcesMap(droolsCompilationDTO);
    assertNotNull(retrieved);
    assertEquals(1, retrieved.size());
}
Also used : KiePMMLTreeModel(org.kie.pmml.models.drools.tree.model.KiePMMLTreeModel) TreeModel(org.dmg.pmml.tree.TreeModel) HasKnowledgeBuilderMock(org.kie.pmml.models.drools.commons.implementations.HasKnowledgeBuilderMock) KnowledgeBuilderImpl(org.drools.compiler.builder.impl.KnowledgeBuilderImpl) KiePMMLOriginalTypeGeneratedType(org.kie.pmml.models.drools.tuples.KiePMMLOriginalTypeGeneratedType) Test(org.junit.Test)

Aggregations

KnowledgeBuilderImpl (org.drools.compiler.builder.impl.KnowledgeBuilderImpl)14 Test (org.junit.Test)14 HasKnowledgeBuilderMock (org.kie.pmml.models.drools.commons.implementations.HasKnowledgeBuilderMock)14 Scorecard (org.dmg.pmml.scorecard.Scorecard)9 PMML (org.dmg.pmml.PMML)6 TreeModel (org.dmg.pmml.tree.TreeModel)5 KiePMMLDroolsModelWithSources (org.kie.pmml.models.drools.commons.model.KiePMMLDroolsModelWithSources)5 KiePMMLTreeModel (org.kie.pmml.models.drools.tree.model.KiePMMLTreeModel)5 HashMap (java.util.HashMap)4 DataDictionary (org.dmg.pmml.DataDictionary)4 CompositePackageDescr (org.drools.compiler.lang.descr.CompositePackageDescr)4 PackageDescr (org.drools.drl.ast.descr.PackageDescr)4 PMML_MODEL (org.kie.pmml.api.enums.PMML_MODEL)4 KiePMMLOriginalTypeGeneratedType (org.kie.pmml.models.drools.tuples.KiePMMLOriginalTypeGeneratedType)4 IOException (java.io.IOException)2 Collections (java.util.Collections)2 List (java.util.List)2 Map (java.util.Map)2 Optional (java.util.Optional)2 DataField (org.dmg.pmml.DataField)2