### Question:
Buckets { public static Buckets fromCount(long start, long end, int count) { checkTimeRange(start, end); checkArgument(count > 0, "count is not positive: %s", count); long quotient = (end - start) / count; long remainder = (end - start) % count; long step; if (remainder != 0 && (count - 1) * (quotient + 1) < (end - start)) { step = quotient + 1; } else { step = quotient; } checkArgument(step > 0, "Computed step is equal to zero"); return new Buckets(start, step, count); } Buckets(long start, long step, int count); long getStart(); long getStep(); int getCount(); int getIndex(long timestamp); long getBucketStart(int index); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); static Buckets fromCount(long start, long end, int count); static Buckets fromStep(long start, long end, long step);  }### Answer:
@Test public void testFromCount() throws Exception { assertEquals(new Buckets(5, 1, 5), Buckets.fromCount(5, 10, 5)); assertEquals(new Buckets(5, 1, 4), Buckets.fromCount(5, 10, 4)); assertEquals(new Buckets(14, 9, 3), Buckets.fromCount(14, 40, 3)); }
@Test public void testComputedStepIsEqualToZero() { expectedException.expect(instanceOf(IllegalArgumentException.class)); expectedException.expectMessage(equalTo("Computed step is equal to zero")); Buckets.fromCount(28, 37, (37 - 28) + 1); }