AisProject implements IMultiObjectModel<AisProject, Interview>, IDetailCategoryProvider { @Override public Map<String, List<Interview>> getSubModelObjects() { final Map<String, List<Interview>> subModelMap = new HashMap<>(); final List<Interview> sortedInterviews = new ArrayList<>(this.interviews); Collections.sort(sortedInterviews); for (final Interview singleInterview : sortedInterviews) { final String groupKey = this.getGroupKey(singleInterview); final List<Interview> groupedInterviews; if (subModelMap.containsKey(groupKey)) { groupedInterviews = subModelMap.get(groupKey); } else { groupedInterviews = new LinkedList<>(); subModelMap.put(groupKey, groupedInterviews); } groupedInterviews.add(singleInterview); } return subModelMap; } AisProject(final String label, final List<DetailCategory> categories); String getLabel(); AisProject setLabel(final String value); List<Interview> getInterviews(); AisProject setInterviews(final List<Interview> value); AisProject setCategories(final List<DetailCategory> value); @Override String getGroupKey(final Object interview); @Override Map<String, List<Interview>> getSubModelObjects(); @Override List<DetailCategory> provide(); @Override List<DetailCategory> provideSelectables(); @Override AisProject clone(); @Override int hashCode(); @Override boolean equals(final Object otherObject);  }
@Test public void testGetSubModelObjects() { final AisProject project = new AisProject("", Arrays.asList(new DetailCategory(null, "x", "", true, null, null))); final Interview modelA1 = new Interview("a", 1); final Interview modelA2 = new Interview("a", 2); final Interview modelB = new Interview("b", 1); final Interview modelC = new Interview("c", 1); project.setInterviews(Arrays.asList(modelB, modelA2, modelC, modelA1)); final Map<String, List<Interview>> actual = project.getSubModelObjects(); Assert.assertEquals(3, actual.size()); Assert.assertEquals(Arrays.asList(modelA1, modelA2), actual.get("a")); Assert.assertEquals(Arrays.asList(modelB), actual.get("b")); Assert.assertEquals(Arrays.asList(modelC), actual.get("c")); }