ModelManagerFactory implements Serializable { public S newModelManager(PMML pmml, Model model){ return newModelManager(pmml, model, null); } protected  ModelManagerFactory(Class<S> serviceClazz); S newModelManager(PMML pmml, Model model); S newModelManager(PMML pmml, Model model, Set<ResultFeature> extraResultFeatures); List<Class<? extends S>> getServiceProviderClasses(Class<? extends Model> modelClazz); Class<S> getServiceClass(); ListMultimap<Class<? extends Model>, Class<? extends S>> getServiceProviderClasses();  }
@Test public void newModelManager(){ ModelManagerFactory<TreeModelManager> modelManagerFactory = new ModelManagerFactory<TreeModelManager>(TreeModelManager.class){ @Override public List<Class<? extends TreeModelManager>> getServiceProviderClasses(Class<? extends Model> modelClazz){ return Arrays.asList(RegressorManager.class, ClassifierManager.class); } }; TreeModel treeModel = new TreeModel() .setMiningFunction(null) .setMiningSchema(new MiningSchema()); PMML pmml = new PMML() .setHeader(new Header()) .setDataDictionary(new DataDictionary()) .addModels(treeModel); ModelManager<?> modelManager; try { modelManager = modelManagerFactory.newModelManager(pmml, treeModel); fail(); } catch(InvalidMarkupException ime){ } treeModel.setMiningFunction(MiningFunction.REGRESSION); modelManager = modelManagerFactory.newModelManager(pmml, treeModel); assertTrue(modelManager instanceof RegressorManager); treeModel.setMiningFunction(MiningFunction.CLASSIFICATION); modelManager = modelManagerFactory.newModelManager(pmml, treeModel); assertTrue(modelManager instanceof ClassifierManager); }