Leaderboard { public List<String> driverRankings() { Map<String, Integer> results = driverResults(); List<String> resultsList = new ArrayList<>(results.keySet()); Collections.sort(resultsList, new DriverByPointsDescendingComparator(results)); return resultsList; } Leaderboard(Race... races); Map<String, Integer> driverResults(); List<String> driverRankings();  }
@Test public void isShouldFindTheWinner() { List<String> result = TestData.sampleLeaderboard1.driverRankings(); assertEquals("Lewis Hamilton", result.get(0)); }
@Test public void itShouldKeepAllDriversWhenSamePoints() { Race winDriver1 = new Race("Australian Grand Prix", driver1, driver2, driver3); Race winDriver2 = new Race("Malaysian Grand Prix", driver2, driver1, driver3); Leaderboard exEquoLeaderBoard = new Leaderboard(winDriver1, winDriver2); List<String> rankings = exEquoLeaderBoard.driverRankings(); assertEquals(Arrays.asList(driver1.getName(), driver2.getName(), driver3.getName()), rankings); }