PMMLLoaderService { public static List<KiePMMLModel> getKiePMMLModelsLoadedFromResource(final KnowledgeBuilderImpl kbuilderImpl, final Resource resource) { String[] classNamePackageName = getFactoryClassNamePackageName(resource); String factoryClassName = classNamePackageName[0]; String packageName = classNamePackageName[1]; String fullFactoryClassName = packageName + "." + factoryClassName; try { final KiePMMLModelFactory aClass = loadKiePMMLModelFactory(kbuilderImpl.getRootClassLoader(), fullFactoryClassName); final List<PMMLRuleMapper> pmmlRuleMappers = loadPMMLRuleMappers(kbuilderImpl.getRootClassLoader(), resource); return getKiePMMLModelsLoadedFromResource(kbuilderImpl, aClass, pmmlRuleMappers); } catch (ClassNotFoundException e) { logger.info(String.format("%s class not found in rootClassLoader, going to compile model", fullFactoryClassName)); } catch (Exception e) { throw new KiePMMLException("Exception while instantiating " + fullFactoryClassName, e); } return Collections.emptyList(); } private  PMMLLoaderService(); static List<KiePMMLModel> getKiePMMLModelsLoadedFromResourcesWithConfigurations(KnowledgeBuilderImpl kbuilderImpl, Collection<ResourceWithConfiguration> resourceWithConfigurations); static List<KiePMMLModel> getKiePMMLModelsLoadedFromResource(final KnowledgeBuilderImpl kbuilderImpl,
                                                                        final Resource resource);  }
@Test public void getKiePMMLModelsLoadedFromResource() { final KnowledgeBuilderImpl kbuilderImpl = new KnowledgeBuilderImpl(); assertTrue(kbuilderImpl.getPackageNames().isEmpty()); assertNull(kbuilderImpl.getPackage(PACKAGE_NAME)); final List<PMMLRuleMapper> pmmlRuleMappers = getPMMLRuleMappers(); final KiePMMLModelFactory kiePMMLModelFactory = getKiePMMLModelFactory(); final List<KiePMMLModel> retrieved = PMMLLoaderService.getKiePMMLModelsLoadedFromResource(kbuilderImpl, kiePMMLModelFactory, pmmlRuleMappers); assertEquals(kiePMMLModelFactory.getKiePMMLModels(), retrieved); assertEquals(1, kbuilderImpl.getPackageNames().size()); assertNotNull(kbuilderImpl.getPackage(PACKAGE_NAME)); }