### Question:
BuildByDateSorter { public static List<BuildImportSummary> sortBuildsByDateDescending(final Collection<BuildImportSummary> unsortedSummaries) { List<BuildImportSummary> summaries = new LinkedList<BuildImportSummary>(); summaries.addAll(unsortedSummaries); Collections.sort(summaries, new BuildImportSummaryDateDescendingComparator()); return summaries; }  static List<BuildImportSummary> sortBuildsByDateDescending(final Collection<BuildImportSummary> unsortedSummaries);  }### Answer:
@Test void sortBuildsByDateDescending_givenTwoBuildsInAscendingOder_resultsInTwoBuildsInDescendingOrder() { List<BuildImportSummary> buildsAscending = new LinkedList<>(); buildsAscending.add(OLDER_BUILD); buildsAscending.add(NEWER_BUILD); List<BuildImportSummary> buildsByDateDescending = BuildByDateSorter.sortBuildsByDateDescending(buildsAscending); assertBuildDescriptionIsEqual(NEWER_BUILD, buildsByDateDescending.get(0)); assertBuildDescriptionIsEqual(OLDER_BUILD, buildsByDateDescending.get(1)); }
@Test void sortBuildsByDateDescending_givenOneBuildWithoutDate_buildWithDateComesFirst() { List<BuildImportSummary> buildsAscending = new LinkedList<>(); buildsAscending.add(BUILD_WITHOUT_DATE); buildsAscending.add(NEWER_BUILD); List<BuildImportSummary> buildsByDateDescending = BuildByDateSorter.sortBuildsByDateDescending(buildsAscending); assertBuildDescriptionIsEqual(NEWER_BUILD, buildsByDateDescending.get(0)); assertBuildDescriptionIsEqual(BUILD_WITHOUT_DATE, buildsByDateDescending.get(1)); }
@Test void sortBuildsByDateDescending_givenFourBuilds_theyAreSortedInDescendingOrder() { List<BuildImportSummary> buildsAscending = new LinkedList<>(); buildsAscending.add(BUILD_WITHOUT_DATE); buildsAscending.add(NEWER_BUILD); buildsAscending.add(MIDDLE_BUILD); buildsAscending.add(OLDER_BUILD); List<BuildImportSummary> buildsByDateDescending = BuildByDateSorter.sortBuildsByDateDescending(buildsAscending); assertBuildDescriptionIsEqual(NEWER_BUILD, buildsByDateDescending.get(0)); assertBuildDescriptionIsEqual(MIDDLE_BUILD, buildsByDateDescending.get(1)); assertBuildDescriptionIsEqual(OLDER_BUILD, buildsByDateDescending.get(2)); assertBuildDescriptionIsEqual(BUILD_WITHOUT_DATE, buildsByDateDescending.get(3)); }