PMMLCompilerService { static void populateWithPMMLRuleMappers(final List<KiePMMLModel> toReturn, final Resource resource) { for (KiePMMLModel kiePMMLModel : toReturn) { final List<String> generatedRuleMappers = new ArrayList<>(); addPMMLRuleMapper(kiePMMLModel, generatedRuleMappers, resource.getSourcePath()); addPMMLRuleMappers(kiePMMLModel, generatedRuleMappers, resource.getSourcePath()); } } private  PMMLCompilerService(); static List<KiePMMLModel> getKiePMMLModelsFromResourcesWithConfigurationsFromPlugin(KnowledgeBuilderImpl kbuilderImpl, Collection<ResourceWithConfiguration> resourceWithConfigurations); static List<KiePMMLModel> getKiePMMLModelsCompiledFromResourcesWithConfigurations(KnowledgeBuilderImpl kbuilderImpl, Collection<ResourceWithConfiguration> resourceWithConfigurations); static List<KiePMMLModel> getKiePMMLModelsCompiledFromResource(KnowledgeBuilderImpl kbuilderImpl,
                                                                          Resource resource); static List<KiePMMLModel> getKiePMMLModelsFromResourceFromPlugin(KnowledgeBuilderImpl kbuilderImpl,
                                                                            Resource resource);  }
@Test public void populateWithPMMLRuleMappers() { final List<KiePMMLModel> toPopulate = new ArrayList<>(); toPopulate.add( new KiePMMLModelHasSourceMap("TEST", Collections.emptyList())); toPopulate.add( new KiePMMLModelHasRule("TEST", Collections.emptyList())); toPopulate.add( new KiePMMLModelHasNestedModelsHasRule("TEST", Collections.emptyList())); toPopulate.add( new KiePMMLModelHasNestedModelsHasSourceMap("TEST", Collections.emptyList())); toPopulate.forEach(kiePMMLModel -> assertTrue(((HasSourcesMap) kiePMMLModel).getSourcesMap().isEmpty())); final File file = new File("foo.pmml"); final Resource resource = new FileSystemResource(file); PMMLCompilerService.populateWithPMMLRuleMappers(toPopulate, resource); toPopulate.forEach(kiePmmlModel -> { if (kiePmmlModel instanceof HasRule || kiePmmlModel instanceof KiePMMLModelHasNestedModelsHasRule) { assertFalse(((HasSourcesMap) kiePmmlModel).getSourcesMap().isEmpty()); String expected = kiePmmlModel.getKModulePackageName() + "." + KIE_PMML_RULE_MAPPERS_CLASS_NAME; assertTrue(((HasSourcesMap) kiePmmlModel).getSourcesMap().containsKey(expected)); if (kiePmmlModel instanceof HasRule) { expected = kiePmmlModel.getKModulePackageName() + "." + KIE_PMML_RULE_MAPPER_CLASS_NAME; assertTrue(((HasSourcesMap) kiePmmlModel).getSourcesMap().containsKey(expected)); } } else { assertTrue(((HasSourcesMap) kiePmmlModel).getSourcesMap().isEmpty()); } }); }