TimeLapse { public void consume(long time) { checkArgument(time >= 0, "the time to consume must be a positive value, it is %s.", time); checkArgument(timeLeft - time >= 0, "there is not enough time left to consume %s.", time); timeLeft -= time; } TimeLapse(Unit<Duration> unit, long start, long end); void consume(long time); void consumeAll(); boolean hasTimeLeft(); long getTimeLeft(); long getTime(); long getTickLength(); long getTimeConsumed(); long getStartTime(); long getEndTime(); boolean isIn(long t); Unit<Duration> getTimeUnit(); @Override String toString();  }
@Test(expected = IllegalArgumentException.class) public void consumeFail1() { final TimeLapse tl = create(0, 10); tl.consume(-1); }
@Test(expected = IllegalArgumentException.class) public void consumeFail2() { final TimeLapse tl = create(0, 10); tl.consume(11); }