Leaderboard { public List<String> driverRankings() { Map<String, Integer> results = driverResults(); List<String> resultsList = new ArrayList<String>(results.keySet()); Collections.sort(resultsList, new DriverByPointsDescendingComparator(results)); return resultsList; } Leaderboard(Race... races); Map<String, Integer> driverResults(); List<String> driverRankings();  }
@Test public void isShouldFindTheWinner() { assertEquals("Lewis Hamilton", TestData.sampleLeaderboard1.driverRankings().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); }