### Question:
TimedCounter extends ExpiringMap<K, Integer> { public int total() { long currentTime = System.currentTimeMillis(); return getEntries().values().stream() .filter(entry -> currentTime <= entry.getExpiration()) .map(ExpiringEntry::getValue) .reduce(0, Integer::sum); } TimedCounter(long duration, TimeUnit unit); @Override Integer get(K key); void increment(K key); void decrement(K key); int total();  }### Answer:
@Test public void shouldSumUpEntries() { TimedCounter<String> counter = new TimedCounter<>(90, TimeUnit.SECONDS); counter.getEntries().put("expired", new ExpiringMap.ExpiringEntry<>(800, 0)); counter.getEntries().put("expired2", new ExpiringMap.ExpiringEntry<>(24, System.currentTimeMillis() - 100)); counter.put("other", 10); counter.put("Another", 4); int totals = counter.total(); assertThat(totals, equalTo(14)); }