use of org.kie.pmml.models.mining.model.KiePMMLMiningModelWithSources in project drools by kiegroup.
the class MiningModelImplementationProviderTest method commonGetKiePMMLModelWithSources.
private void commonGetKiePMMLModelWithSources(String source) throws Exception {
final PMML pmml = getPMML(source);
KnowledgeBuilderImpl knowledgeBuilder = new KnowledgeBuilderImpl();
final MiningModel miningmodel = (MiningModel) pmml.getModels().get(0);
final CommonCompilationDTO<MiningModel> compilationDTO = CommonCompilationDTO.fromGeneratedPackageNameAndFields(PACKAGE_NAME, pmml, miningmodel, new HasKnowledgeBuilderMock(knowledgeBuilder));
final KiePMMLMiningModelWithSources retrieved = (KiePMMLMiningModelWithSources) PROVIDER.getKiePMMLModelWithSources(compilationDTO);
assertNotNull(retrieved);
commonVerifyIsDeepCloneable(retrieved);
assertNotNull(retrieved.getNestedModels());
assertFalse(retrieved.getNestedModels().isEmpty());
final Map<String, String> sourcesMap = new HashMap<>(retrieved.getSourcesMap());
assertFalse(sourcesMap.isEmpty());
try {
KieMemoryCompiler.compile(sourcesMap, Thread.currentThread().getContextClassLoader());
fail("Expecting compilation error without nested models sources");
} catch (Exception e) {
// Expected
}
retrieved.getNestedModels().forEach(nestedModel -> sourcesMap.putAll(((HasSourcesMap) nestedModel).getSourcesMap()));
try {
KieMemoryCompiler.compile(sourcesMap, Thread.currentThread().getContextClassLoader());
} catch (Exception e) {
fail(e.getMessage());
}
}
Aggregations