Search in sources :

Example 1 with KIE_PMML_RULE_MAPPER_CLASS_NAME

use of org.kie.pmml.evaluator.assembler.factories.PMMLRuleMapperFactory.KIE_PMML_RULE_MAPPER_CLASS_NAME in project drools by kiegroup.

the class PMMLCompilerServiceTest method addPMMLRuleMappersHasSourceMap.

@Test
public void addPMMLRuleMappersHasSourceMap() {
    KiePMMLTestingModelWithSources kiePmmlModel = new KiePMMLTestingModelWithSources("TEST", "kmodulePackageName", new HashMap<>());
    assertTrue(kiePmmlModel.getSourcesMap().isEmpty());
    final List<String> generatedRuleMappers = IntStream.range(0, 3).mapToObj(i -> "apackage" + i + "." + KIE_PMML_RULE_MAPPER_CLASS_NAME).collect(Collectors.toList());
    PMMLCompilerService.addPMMLRuleMappers(kiePmmlModel, generatedRuleMappers, "source_path");
    assertFalse(kiePmmlModel.getSourcesMap().isEmpty());
    String expected = kiePmmlModel.getKModulePackageName() + "." + KIE_PMML_RULE_MAPPERS_CLASS_NAME;
    assertTrue(kiePmmlModel.getSourcesMap().containsKey(expected));
}
Also used : IntStream(java.util.stream.IntStream) HasRule(org.kie.pmml.commons.HasRule) HashMap(java.util.HashMap) FileSystemResource(org.drools.core.io.impl.FileSystemResource) ArrayList(java.util.ArrayList) KiePMMLModel(org.kie.pmml.commons.model.KiePMMLModel) StringUtils.generateUUID(org.drools.core.util.StringUtils.generateUUID) KIE_PMML_RULE_MAPPER_CLASS_NAME(org.kie.pmml.evaluator.assembler.factories.PMMLRuleMapperFactory.KIE_PMML_RULE_MAPPER_CLASS_NAME) MINING_FUNCTION(org.kie.pmml.api.enums.MINING_FUNCTION) KiePMMLTestingModelWithSources(org.kie.pmml.commons.testingutility.KiePMMLTestingModelWithSources) HasNestedModels(org.kie.pmml.commons.model.HasNestedModels) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) Collectors(java.util.stream.Collectors) File(java.io.File) Resource(org.kie.api.io.Resource) List(java.util.List) HasSourcesMap(org.kie.pmml.commons.model.HasSourcesMap) KiePMMLTestingModel(org.kie.pmml.commons.testingutility.KiePMMLTestingModel) Assert.assertFalse(org.junit.Assert.assertFalse) KiePMMLExtension(org.kie.pmml.commons.model.KiePMMLExtension) Collections(java.util.Collections) KiePMMLException(org.kie.pmml.api.exceptions.KiePMMLException) Assert.assertEquals(org.junit.Assert.assertEquals) KIE_PMML_RULE_MAPPERS_CLASS_NAME(org.kie.pmml.evaluator.assembler.factories.PMMLRuleMappersFactory.KIE_PMML_RULE_MAPPERS_CLASS_NAME) KiePMMLTestingModelWithSources(org.kie.pmml.commons.testingutility.KiePMMLTestingModelWithSources) Test(org.junit.Test)

Example 2 with KIE_PMML_RULE_MAPPER_CLASS_NAME

use of org.kie.pmml.evaluator.assembler.factories.PMMLRuleMapperFactory.KIE_PMML_RULE_MAPPER_CLASS_NAME in project drools by kiegroup.

the class PMMLCompilerServiceTest method addPMMLRuleMappersNotHasSourceMap.

@Test(expected = KiePMMLException.class)
public void addPMMLRuleMappersNotHasSourceMap() {
    final KiePMMLModel kiePmmlModel = KiePMMLTestingModel.builder("name", Collections.emptyList(), MINING_FUNCTION.REGRESSION).build();
    final List<String> generatedRuleMappers = IntStream.range(0, 3).mapToObj(i -> "apackage" + i + "." + KIE_PMML_RULE_MAPPER_CLASS_NAME).collect(Collectors.toList());
    PMMLCompilerService.addPMMLRuleMappers(kiePmmlModel, generatedRuleMappers, "source_path");
}
Also used : IntStream(java.util.stream.IntStream) HasRule(org.kie.pmml.commons.HasRule) HashMap(java.util.HashMap) FileSystemResource(org.drools.core.io.impl.FileSystemResource) ArrayList(java.util.ArrayList) KiePMMLModel(org.kie.pmml.commons.model.KiePMMLModel) StringUtils.generateUUID(org.drools.core.util.StringUtils.generateUUID) KIE_PMML_RULE_MAPPER_CLASS_NAME(org.kie.pmml.evaluator.assembler.factories.PMMLRuleMapperFactory.KIE_PMML_RULE_MAPPER_CLASS_NAME) MINING_FUNCTION(org.kie.pmml.api.enums.MINING_FUNCTION) KiePMMLTestingModelWithSources(org.kie.pmml.commons.testingutility.KiePMMLTestingModelWithSources) HasNestedModels(org.kie.pmml.commons.model.HasNestedModels) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) Collectors(java.util.stream.Collectors) File(java.io.File) Resource(org.kie.api.io.Resource) List(java.util.List) HasSourcesMap(org.kie.pmml.commons.model.HasSourcesMap) KiePMMLTestingModel(org.kie.pmml.commons.testingutility.KiePMMLTestingModel) Assert.assertFalse(org.junit.Assert.assertFalse) KiePMMLExtension(org.kie.pmml.commons.model.KiePMMLExtension) Collections(java.util.Collections) KiePMMLException(org.kie.pmml.api.exceptions.KiePMMLException) Assert.assertEquals(org.junit.Assert.assertEquals) KIE_PMML_RULE_MAPPERS_CLASS_NAME(org.kie.pmml.evaluator.assembler.factories.PMMLRuleMappersFactory.KIE_PMML_RULE_MAPPERS_CLASS_NAME) KiePMMLModel(org.kie.pmml.commons.model.KiePMMLModel) Test(org.junit.Test)

Aggregations

File (java.io.File)2 ArrayList (java.util.ArrayList)2 Collections (java.util.Collections)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 IntStream (java.util.stream.IntStream)2 FileSystemResource (org.drools.core.io.impl.FileSystemResource)2 StringUtils.generateUUID (org.drools.core.util.StringUtils.generateUUID)2 Assert.assertEquals (org.junit.Assert.assertEquals)2 Assert.assertFalse (org.junit.Assert.assertFalse)2 Assert.assertTrue (org.junit.Assert.assertTrue)2 Test (org.junit.Test)2 Resource (org.kie.api.io.Resource)2 MINING_FUNCTION (org.kie.pmml.api.enums.MINING_FUNCTION)2 KiePMMLException (org.kie.pmml.api.exceptions.KiePMMLException)2 HasRule (org.kie.pmml.commons.HasRule)2 HasNestedModels (org.kie.pmml.commons.model.HasNestedModels)2 HasSourcesMap (org.kie.pmml.commons.model.HasSourcesMap)2 KiePMMLExtension (org.kie.pmml.commons.model.KiePMMLExtension)2