use of org.kie.pmml.models.drools.commons.model.KiePMMLDroolsModel in project drools by kiegroup.
the class DroolsModelProviderTest method getKiePMMLModelWithKnowledgeBuilder.
@Test
public void getKiePMMLModelWithKnowledgeBuilder() {
KnowledgeBuilderImpl knowledgeBuilder = new KnowledgeBuilderImpl();
final CommonCompilationDTO<Scorecard> compilationDTO = CommonCompilationDTO.fromGeneratedPackageNameAndFields(PACKAGE_NAME, pmml, scorecard, new HasKnowledgeBuilderMock(knowledgeBuilder));
KiePMMLDroolsModel retrieved = droolsModelProvider.getKiePMMLModel(compilationDTO);
assertNotNull(retrieved);
assertTrue(retrieved instanceof KiePMMLDroolsModelTest);
KiePMMLDroolsModelTest retrievedTest = (KiePMMLDroolsModelTest) retrieved;
final List<DataField> originalDataFields = pmml.getDataDictionary().getDataFields();
final List<DataField> retrievedDataFields = retrievedTest.dataDictionary.getDataFields();
assertEquals(originalDataFields.size(), retrievedTest.dataDictionary.getDataFields().size());
originalDataFields.forEach(dataField -> {
Optional<DataField> optRet = retrievedDataFields.stream().filter(retrievedDataField -> dataField.getName().equals(retrievedDataField.getName())).findFirst();
assertTrue(optRet.isPresent());
assertEquals(dataField.getDataType(), optRet.get().getDataType());
});
assertEquals(pmml.getTransformationDictionary(), retrievedTest.transformationDictionary);
assertEquals(scorecard, retrievedTest.model);
String expectedPackageName = getSanitizedPackageName(PACKAGE_NAME);
assertEquals(expectedPackageName, retrievedTest.getKModulePackageName());
assertEquals(PACKAGE_NAME, retrievedTest.getName());
PackageDescr packageDescr = knowledgeBuilder.getPackageDescrs("packagename").get(0);
assertTrue(packageDescr instanceof CompositePackageDescr);
}
Aggregations