@Test public void withStartTime() throws Exception { final RandomDiscreteTimestampGenerator generator = new RandomDiscreteTimestampGenerator(60, TimeUnit.SECONDS, 1072915200L, 60); List<Long> generated = Lists.newArrayList(); for (int i = 0; i < 60; i++) { generated.add(generator.nextValue()); } assertEquals(generated.size(), 60); Collections.sort(generated); long ts = 1072915200L - 60; for (final long t : generated) { assertEquals(t, ts); ts += 60; } try { generator.nextValue(); fail("Expected IllegalStateException"); } catch (IllegalStateException e) { } }
@Override public Long nextValue() { if (offsetIndex >= offsets.length) { throw new IllegalStateException("Reached the end of the random timestamp " + "intervals: " + offsetIndex); } lastTimestamp = currentTimestamp; currentTimestamp = startTimestamp + (offsets[offsetIndex++] * getOffset(1)); return currentTimestamp; }
RandomDiscreteTimestampGenerator extends UnixEpochTimestampGenerator { @Override public Long nextValue() { if (offsetIndex >= offsets.length) { throw new IllegalStateException("Reached the end of the random timestamp " + "intervals: " + offsetIndex); } lastTimestamp = currentTimestamp; currentTimestamp = startTimestamp + (offsets[offsetIndex++] * getOffset(1)); return currentTimestamp; } }
RandomDiscreteTimestampGenerator extends UnixEpochTimestampGenerator { @Override public Long nextValue() { if (offsetIndex >= offsets.length) { throw new IllegalStateException("Reached the end of the random timestamp " + "intervals: " + offsetIndex); } lastTimestamp = currentTimestamp; currentTimestamp = startTimestamp + (offsets[offsetIndex++] * getOffset(1)); return currentTimestamp; } RandomDiscreteTimestampGenerator(final long interval, final TimeUnit timeUnits, 
                                          final int intervals);  RandomDiscreteTimestampGenerator(final long interval, final TimeUnit timeUnits,
                                          final long startTimestamp, final int intervals); }
RandomDiscreteTimestampGenerator extends UnixEpochTimestampGenerator { @Override public Long nextValue() { if (offsetIndex >= offsets.length) { throw new IllegalStateException("Reached the end of the random timestamp " + "intervals: " + offsetIndex); } lastTimestamp = currentTimestamp; currentTimestamp = startTimestamp + (offsets[offsetIndex++] * getOffset(1)); return currentTimestamp; } RandomDiscreteTimestampGenerator(final long interval, final TimeUnit timeUnits, 
                                          final int intervals);  RandomDiscreteTimestampGenerator(final long interval, final TimeUnit timeUnits,
                                          final long startTimestamp, final int intervals); @Override Long nextValue(); }
RandomDiscreteTimestampGenerator extends UnixEpochTimestampGenerator { @Override public Long nextValue() { if (offsetIndex >= offsets.length) { throw new IllegalStateException("Reached the end of the random timestamp " + "intervals: " + offsetIndex); } lastTimestamp = currentTimestamp; currentTimestamp = startTimestamp + (offsets[offsetIndex++] * getOffset(1)); return currentTimestamp; } RandomDiscreteTimestampGenerator(final long interval, final TimeUnit timeUnits, 
                                          final int intervals);  RandomDiscreteTimestampGenerator(final long interval, final TimeUnit timeUnits,
                                          final long startTimestamp, final int intervals); @Override Long nextValue(); static final int MAX_INTERVALS; }