### Question:
ScenarioSimulatorMain { protected java.util.Map<Role, RoleSimulator> loadRoleSimulators(Scenario scenario, Simulation simulation) { java.util.Map<Role, RoleSimulator> ret=new java.util.HashMap<Role, RoleSimulator>(); for (Role role : scenario.getRole()) { for (RoleDetails details : simulation.getRoles()) { if (details.getScenarioRole().equals(role.getName())) { for (SimulatorDetails simdetails : simulation.getSimulators()) { if (simdetails.getName().equals(details.getSimulator())) { try { Class<?> cls=Class.forName(simdetails.getClassName()); Object obj=cls.newInstance(); if (obj instanceof RoleSimulator) { ret.put(role, (RoleSimulator)obj); break; } } catch(Throwable e) { logger.log(Level.SEVERE, "Failed to instantiate role simulator '"+ details.getSimulator()+"'", e); } } } } } } return(ret); }  static void main(String[] args); int simulate(Simulation simulation); int simulate(Simulation simulation, SimulationHandler handler);  }### Answer:
@Test public void testLoadRoleSimulators() { ScenarioSimulatorMain simulator=new ScenarioSimulatorMain(); Simulation simulation=new Simulation(); RoleDetails details=new RoleDetails(); details.setScenarioRole(STORE_ROLE); details.setSimulator(TEST_ROLE_SIMULATOR); simulation.getRoles().add(details); SimulatorDetails simdetails=new SimulatorDetails(); simdetails.setName(TEST_ROLE_SIMULATOR); simdetails.setClassName(TestRoleSimulator.class.getName()); simulation.getSimulators().add(simdetails); simulation.setScenario("scenarios/SuccessfulPurchase.scn"); Scenario scenario=simulator.loadScenario(simulation); java.util.Map<Role, RoleSimulator> rsims=simulator.loadRoleSimulators(scenario, simulation); if (rsims == null) { fail("No role simulators"); } RoleSimulator rsim=rsims.get(scenario.getRole().get(1)); if (rsim == null) { fail("No role simulator for '"+STORE_ROLE+"'"); } if ((rsim instanceof TestRoleSimulator) == false) { fail("TestRoleSimulator not instantiated: "+rsim); } }