use of org.kie.pmml.compiler.api.dto.CommonCompilationDTO 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());
}
use of org.kie.pmml.compiler.api.dto.CommonCompilationDTO 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());
}
use of org.kie.pmml.compiler.api.dto.CommonCompilationDTO 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);
}
use of org.kie.pmml.compiler.api.dto.CommonCompilationDTO in project drools by kiegroup.
the class KiePMMLMiningModelFactoryTest method getKiePMMLMiningModelSourcesMapCompiled.
@Test
public void getKiePMMLMiningModelSourcesMapCompiled() {
final List<KiePMMLModel> nestedModels = new ArrayList<>();
final HasKnowledgeBuilderMock hasKnowledgeBuilderMock = new HasKnowledgeBuilderMock(KNOWLEDGE_BUILDER);
final CommonCompilationDTO<MiningModel> source = CommonCompilationDTO.fromGeneratedPackageNameAndFields(PACKAGE_NAME, pmml, MINING_MODEL, hasKnowledgeBuilderMock);
final MiningModelCompilationDTO compilationDTO = MiningModelCompilationDTO.fromCompilationDTO(source);
final List<String> expectedGeneratedClasses = MINING_MODEL.getSegmentation().getSegments().stream().map(segment -> {
String modelName = segment.getModel().getModelName();
String sanitizedPackageName = getSanitizedPackageName(compilationDTO.getSegmentationPackageName() + "." + segment.getId());
String sanitizedClassName = getSanitizedClassName(modelName);
return String.format(PACKAGE_CLASS_TEMPLATE, sanitizedPackageName, sanitizedClassName);
}).collect(Collectors.toList());
expectedGeneratedClasses.forEach(expectedGeneratedClass -> {
try {
hasKnowledgeBuilderMock.getClassLoader().loadClass(expectedGeneratedClass);
fail("Expecting class not found: " + expectedGeneratedClass);
} catch (Exception e) {
assertTrue(e instanceof ClassNotFoundException);
}
});
final Map<String, String> retrieved = KiePMMLMiningModelFactory.getKiePMMLMiningModelSourcesMapCompiled(compilationDTO, nestedModels);
assertNotNull(retrieved);
int expectedNestedModels = MINING_MODEL.getSegmentation().getSegments().size();
assertEquals(expectedNestedModels, nestedModels.size());
expectedGeneratedClasses.forEach(expectedGeneratedClass -> {
try {
hasKnowledgeBuilderMock.getClassLoader().loadClass(expectedGeneratedClass);
} catch (Exception e) {
fail("Expecting class to be loaded, but got: " + e.getClass().getName() + " -> " + e.getMessage());
e.printStackTrace();
}
});
}
Aggregations