@Test public void testInterval() { Registry r = new DefaultRegistry(clock); Id id = r.createId("test"); IntervalCounter c = IntervalCounter.get(r, id); Assertions.assertEquals(c.secondsSinceLastUpdate(), 0.0, EPSILON); clock.setWallTime(1000); Assertions.assertEquals(c.secondsSinceLastUpdate(), 1.0, EPSILON); c.increment(); Assertions.assertEquals(c.secondsSinceLastUpdate(), 0.0, EPSILON); }
@Test public void testInit() { Registry r = new DefaultRegistry(clock); clock.setWallTime(42 * 1000L); Id id = r.createId("test"); IntervalCounter c = IntervalCounter.get(r, id); Assertions.assertEquals(0L, c.count()); Assertions.assertEquals(42.0, c.secondsSinceLastUpdate(), EPSILON); }