AutonomicClusterManagementHeuristicService { protected ClusterAdministrationHeuristicAlgorithm getInstanceOfClass(String algorithmName) { Class<? extends ClusterAdministrationHeuristicAlgorithm> clusterManagerHeuristicAlgorithmClass = algorithmsMap.get(algorithmName); if (clusterManagerHeuristicAlgorithmClass != null) { return getInstanceOfClass(clusterManagerHeuristicAlgorithmClass); } try { Class<? extends ClusterAdministrationHeuristicAlgorithm> algorithmClass = loadAlgorithmClass(algorithmName); return getInstanceOfClass(algorithmClass); } catch (Exception e) { logger.debug(String.format("Could not load heuristics from algorithm [algorithm class name=%s], using the Dummy management algorithm", algorithmName), e); return getDummyClusterManagementHeuristc(); } }  ClusterAdministrationHeuristicAlgorithm getAdministrationAlgorithm(); final static String CLUSTER_ADMINISTRATION_ALGORITHMS_IN_CONFIGURATION_KEY; }
@Test public void getInstanceOfClassTestMethodWithParameterStringHeuristicIsOnAlgorithmsMap() throws ClassNotFoundException { spy.algorithmsMap.put("br.com.autonomiccs.autonomic.administration.algorithms.impl.ConsolidationAlgorithmBase", ConsolidationAlgorithmBase.class); ClusterAdministrationHeuristicAlgorithm result = spy.getInstanceOfClass("br.com.autonomiccs.autonomic.administration.algorithms.impl.ConsolidationAlgorithmBase"); Mockito.verify(spy).getInstanceOfClass(Mockito.anyString()); Assert.assertEquals(ConsolidationAlgorithmBase.class, result.getClass()); }