MainTypesUtil { public List<String> getMainTypesByTumorTypes(Set<TumorType> tumorTypes) { Set<String> mainTypes = new HashSet<>(); for (TumorType tumorType : tumorTypes) { if (tumorType.getMainType() != null && tumorType.getParent() != null) { mainTypes.add(tumorType.getMainType()); } } return new ArrayList<>(mainTypes); }  List<String> getMainTypesByTumorTypes(Set<TumorType> tumorTypes);  }
@Test public void testFullMainTypesListFromExpectedTumorTypes() { List<String> returnedMainTypeList = mainTypesUtil.getMainTypesByTumorTypes(new HashSet<>(expectedTumorTypeMap.values())); StringBuilder failureReport = new StringBuilder(); int failureCount = 0; if (returnedMainTypeList.size() != expectedMainTypeList.size()) { failureCount++; failureReport.append("Returned MainType list is of different length than the expected MainType list." + "\n\tReturned list length: " + String.valueOf(returnedMainTypeList.size()) + "\n\tExpected list length: " + String.valueOf(expectedMainTypeList.size()) + "\n\tDifference is: " + StringUtils.join(CollectionUtils.disjunction(returnedMainTypeList, expectedMainTypeList), ", ") + "\n"); } for (String mainType : expectedMainTypeList) { if (!returnedMainTypeList.contains(mainType)) { failureCount++; failureReport.append("MainType " + mainType + " missing in returned MainType list\n"); } } for (String mainType : returnedMainTypeList) { if (!expectedMainTypeList.contains(mainType)) { failureCount++; failureReport.append("MainType " + mainType + " from returned MainType list not found in expected MainType list\n"); } } if (failureCount > 0) { fail(Integer.toString(failureCount) + " failed test conditions. Details follow...\n" + failureReport.toString()); } }