PMMLLoaderService { static void loadPMMLRuleMappers(final KnowledgeBuilderImpl kbuilderImpl, final List<PMMLRuleMapper> pmmlRuleMappers) { if (!pmmlRuleMappers.isEmpty()) { List<Model> models = pmmlRuleMappers.stream() .map(PMMLRuleMapper::getModel) .collect(Collectors.toList()); KnowledgeBuilderImpl temp = new KnowledgeBuilderImpl(KieBaseBuilder.createKieBaseFromModel(models)); for (KiePackage kiePackage : temp.getKnowledgeBase().getKiePackages()) { kbuilderImpl.addPackage((InternalKnowledgePackage) kiePackage); } } } private  PMMLLoaderService(); static List<KiePMMLModel> getKiePMMLModelsLoadedFromResourcesWithConfigurations(KnowledgeBuilderImpl kbuilderImpl, Collection<ResourceWithConfiguration> resourceWithConfigurations); static List<KiePMMLModel> getKiePMMLModelsLoadedFromResource(final KnowledgeBuilderImpl kbuilderImpl,
                                                                        final Resource resource);  }
@Test public void loadPMMLRuleMappersNotEmpty() { final KnowledgeBuilderImpl kbuilderImpl = new KnowledgeBuilderImpl(); assertTrue(kbuilderImpl.getPackageNames().isEmpty()); assertNull(kbuilderImpl.getPackage(PACKAGE_NAME)); final List<PMMLRuleMapper> pmmlRuleMappers = getPMMLRuleMappers(); PMMLLoaderService.loadPMMLRuleMappers(kbuilderImpl, pmmlRuleMappers); assertEquals(1, kbuilderImpl.getPackageNames().size()); assertNotNull(kbuilderImpl.getPackage(PACKAGE_NAME)); }
@Test public void loadPMMLRuleMappersEmpty() { final KnowledgeBuilderImpl kbuilderImpl = new KnowledgeBuilderImpl(); assertTrue(kbuilderImpl.getPackageNames().isEmpty()); assertNull(kbuilderImpl.getPackage(PACKAGE_NAME)); final List<PMMLRuleMapper> pmmlRuleMappers = Collections.emptyList(); PMMLLoaderService.loadPMMLRuleMappers(kbuilderImpl, pmmlRuleMappers); assertTrue(kbuilderImpl.getPackageNames().isEmpty()); assertNull(kbuilderImpl.getPackage(PACKAGE_NAME)); }