Leaderboard { public Map<String, Integer> driverResults() { Map<String, Integer> results = new HashMap<String, Integer>(); for (Race race : this.races) { for (Driver driver : race.getResults()) { String driverName = race.getDriverName(driver); int points = race.getPoints(driver); if (results.containsKey(driverName)) { results.put(driverName, results.get(driverName) + points); } else { results.put(driverName, 0 + points); } } } return results; } Leaderboard(Race... races); Map<String, Integer> driverResults(); List<String> driverRankings();  }
@Test public void itShouldSumThePoints() { Map<String, Integer> results = TestData.sampleLeaderboard1.driverResults(); assertTrue("results " + results, results.containsKey("Lewis Hamilton")); assertEquals(18 + 18 + 25, (int) results.get("Lewis Hamilton")); }