### Question:
Timer implements TimerEvent.Timer { Duration lap() { Instant now = clock.instant(); Duration duration = Duration.between(lapStartTime, now); lapStartTime = now; return duration; } Timer(Clock clock, @Nullable Timer parentTimer); @Override Optional<? extends Timer> getParent();  }### Answer:
@Test public void testLap() { Mockito.when(mockClock.instant()).thenReturn(Instant.EPOCH); Timer parentTimer = new Timer(mockClock, null); Mockito.when(mockClock.instant()).thenReturn(Instant.EPOCH.plusMillis(5)); Duration parentDuration1 = parentTimer.lap(); Mockito.when(mockClock.instant()).thenReturn(Instant.EPOCH.plusMillis(15)); Duration parentDuration2 = parentTimer.lap(); Mockito.when(mockClock.instant()).thenReturn(Instant.EPOCH.plusMillis(16)); Timer childTimer = new Timer(mockClock, parentTimer); Mockito.when(mockClock.instant()).thenReturn(Instant.EPOCH.plusMillis(16).plusNanos(1)); Duration childDuration = childTimer.lap(); Mockito.when(mockClock.instant()).thenReturn(Instant.EPOCH.plusMillis(16).plusNanos(2)); Duration parentDuration3 = parentTimer.lap(); Assert.assertTrue(parentDuration2.compareTo(parentDuration1) > 0); Assert.assertTrue(parentDuration1.compareTo(parentDuration3) > 0); Assert.assertTrue(parentDuration3.compareTo(childDuration) > 0); }