### Question:
AllSessionsController { protected static Map<String, Map<String, Session>> groupSessionsByLocationsSlots(List<Location> locations, List<Session> sessions) { HashMap<String, Map<String, Session>> transformedSessions = new HashMap<String, Map<String, Session>>(); for (Location loc : locations) { transformedSessions.put(loc.getShortName(), new HashMap<String, Session>()); } for (Session session : sessions) { Map<String, Session> sessionOfLocation = new HashMap<String, Session>(); sessionOfLocation.put(session.getStart(), session); if (transformedSessions.containsKey(session.getLocation())) transformedSessions.get(session.getLocation()).put(session.getStart(), session); else transformedSessions.put(session.getLocation(), sessionOfLocation); } return transformedSessions; } AllSessionsController(); @RequestMapping(method = RequestMethod.GET) void setupForm(ModelMap modelMap);  }### Answer:
@Test public void shouldArrangeOneSessionByLocation() { List<Session> sessions = new ArrayList<Session>(); sessions.add(new Session("Wed", "15:30", "orange", "title1", "toto", "description")); List<Location> list = Arrays.asList(new Location("orange", NODESC)); Map<String, Map<String, Session>> transformedSessions = AllSessionsController.groupSessionsByLocationsSlots(list, sessions); notEmpty(transformedSessions); notEmpty(transformedSessions.get("orange")); }
@Test public void shouldArrangeTwoSessionsByLocations() { List<Session> sessions = new ArrayList<Session>(); sessions.add(new Session("Wed", "15:30", "orange", "title1", "toto", "description")); sessions.add(new Session("Wed", "15:30", "red", "title2", "toto", "description")); List<Location> list = Arrays.asList(new Location("orange", NODESC), new Location("red", NODESC)); Map<String, Map<String, Session>> transformedSessions = AllSessionsController.groupSessionsByLocationsSlots(list, sessions); isTrue(transformedSessions.size() == 2); notEmpty(transformedSessions.get("red")); isTrue(transformedSessions.get("red").size() == 1); }
@Test public void shouldArrangeSessionsInSameLocationBySlot() { List<Session> sessions = new ArrayList<Session>(); sessions.add(new Session("Wed", "15:30", "red", "title1", "toto", "description")); sessions.add(new Session("Wed", "16:15", "red", "title2", "toto", "description")); List<Location> list = Arrays.asList(new Location("red", NODESC)); Map<String, Map<String, Session>> transformedSessions = AllSessionsController.groupSessionsByLocationsSlots(list, sessions); isTrue(transformedSessions.size() == 1); isTrue(transformedSessions.get("red").size() == 2); }