### Question:
WindowCounter { public int getHistory() { return Arrays.stream(history).sum(); } WindowCounter(int capacity); int getLastIndex(); void record(int snapshot); int getHistory(); boolean allMatch(IntPredicate predicate);  }### Answer:
@Test public void testGetHistory() throws Exception { WindowCounter counter = new WindowCounter(5); counter.record(1); counter.record(2); counter.record(3); Assert.assertEquals(6, counter.getHistory()); counter.record(4); counter.record(5); Assert.assertEquals(15, counter.getHistory()); counter.record(6); Assert.assertEquals(20, counter.getHistory()); counter.record(7); Assert.assertEquals(25, counter.getHistory()); counter.record(8); Assert.assertEquals(30, counter.getHistory()); }