### Question:
Windows { protected Windows<W> segments(final int segments) throws IllegalArgumentException { if (segments < 2) { throw new IllegalArgumentException("Number of segments must be at least 2."); } this.segments = segments; return this; } protected  Windows(); Windows<W> until(final long durationMs); long maintainMs(); abstract Map<Long, W> windowsFor(final long timestamp); abstract long size(); public int segments; }### Answer:
@Test public void shouldSetNumberOfSegments() { final int anySegmentSizeLargerThanOne = 5; assertEquals(anySegmentSizeLargerThanOne, new TestWindows().segments(anySegmentSizeLargerThanOne).segments); }
@Test(expected = IllegalArgumentException.class) public void numberOfSegmentsMustBeAtLeastTwo() { new TestWindows().segments(1); }