### Question:
Buckets { public static Buckets fromStep(long start, long end, long step) { checkTimeRange(start, end); checkArgument(step > 0, "step is not positive: %s", step); if (step > (end - start)) { return new Buckets(start, step, 1); } long quotient = (end - start) / step; long remainder = (end - start) % step; long count; if (remainder == 0) { count = quotient; } else { count = quotient + 1; } checkArgument(count <= Integer.MAX_VALUE, "Computed number of buckets is too big: %s", count); return new Buckets(start, step, (int) 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 testFromStep() throws Exception { assertEquals(new Buckets(4, 50, 1), Buckets.fromStep(4, 43, 50)); assertEquals(new Buckets(11, 47, 2734), Buckets.fromStep(11, 11 + 47 * 2734, 47)); assertEquals(new Buckets(5, 7, 2), Buckets.fromStep(5, 13, 7)); }
@Test public void testComputedNumberOfBucketsIsTooBig() { expectedException.expect(instanceOf(IllegalArgumentException.class)); expectedException.expectMessage(equalTo("Computed number of buckets is too big: " + Long.MAX_VALUE)); Buckets.fromStep(0, Long.MAX_VALUE, 1); }