### Question:
Activity { public double getProbabilityForTimeslot (int slot) { double result = 1.0; if (slot < 0 || slot > 23) { log.error("bad slot {} in probabilityForTimeslot", slot); result = 0.0; } else if (getDailyProfileOptional().isPresent()) { result = getDailyProfileOptional().get()[slot]; } else { result = 1.0; } return result; } Activity();  Activity(String name); double getDayWeight(int day); int getId(); String getName(); double getChargerProbability(); void setChargerProbability(double prob); int getInterval(); double getWeekdayWeight(); double getWeekendWeight(); @ConfigurableValue(valueType = "List", dump = false, description = "When this activity might start") void setWeeklyProfile(List<String> value); List<String> getWeeklyProfile(); Optional<double[]> getWeeklyProfileOptional(); @ConfigurableValue(valueType = "List", dump = false, description = "When this activity might start") void setDailyProfile(List<String> value); List<String> getDailyProfile(); Optional<double[]> getDailyProfileOptional(); double getDayProbability(int dayOfWeek); double getProbabilityForTimeslot(int slot); void setInterval(int value); void setId(int value);  }### Answer:
@Test public void probabilityForTimeslot () { TreeMap<String, String> map = new TreeMap<String, String>(); map.put("evcustomer.beans.activity.instances", "min,daily"); map.put("evcustomer.beans.activity.daily.dailyProfile", "0,0,0,0,0,0,0.8,1.0,0.2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0"); config = new MapConfiguration(map); Configurator configurator = new Configurator(); configurator.setConfiguration(config); Collection<?> instances = configurator.configureInstances(Activity.class); Map<String, Activity> acts = mapNames(instances); assertEquals(2, acts.size(), "two activities"); Activity min = acts.get("min"); assertEquals(1.0, min.getProbabilityForTimeslot(1)); assertEquals(1.0, min.getProbabilityForTimeslot(1)); assertEquals(1.0, min.getProbabilityForTimeslot(23)); assertEquals(1.0, min.getProbabilityForTimeslot(2)); assertEquals(1.0, min.getProbabilityForTimeslot(2)); assertEquals(0.0, min.getProbabilityForTimeslot(-1)); assertEquals(0.0, min.getProbabilityForTimeslot(24)); Activity daily = acts.get("daily"); assertEquals(0.0, daily.getProbabilityForTimeslot(0), 1e-6); assertEquals(0.0, daily.getProbabilityForTimeslot(5), 1e-6); assertEquals(0.4, daily.getProbabilityForTimeslot(6), 1e-6); assertEquals(0.5, daily.getProbabilityForTimeslot(7), 1e-6); assertEquals(0.1, daily.getProbabilityForTimeslot(8), 1e-6); assertEquals(0.0, daily.getProbabilityForTimeslot(9), 1e-6); assertEquals(0.5, daily.getProbabilityForTimeslot(7), 1e-6); }