### Question:
Histogram { public void add(T value) { int i = segmenter.segment(value); counts[i]++; totalCount++; if (this.recentAdditions.size() > Histogram.MAX_HISTORY_SIZE) { this.recentAdditions.pollLast(); } this.recentAdditions.push(value); } Histogram(Segmenter<B, T> segmenter); void add(T value); int[] getHistogram(); Segmenter<B, T> getSegmenter(); List<T> getRecentAdditions(); int getCount(); @Override String toString(); Iterable<Entry<B>> entries(); static final int MAX_HISTORY_SIZE; }### Answer:
@Test(expected = Histogram.SegmenterException.class) public void testBadValue() { Segmenter<String, Long> s = new Histogram.TreeMapSegmenter<>(new TreeSet<>(Arrays.asList(0L, 1L, 2L, 4L, 8L, 16L))); Histogram<String, Long> h = new Histogram<>(s); h.add(-1L); }