### Question:
TaskMonitor implements TaskRunner.Listener, Closeable { @Override public void exited(final long code) { flapController.exited(); updateThrottle(); updateState(EXITED); } TaskMonitor(final JobId jobId, final FlapController flapController,
                     final StatusUpdater statusUpdater); ThrottleState throttle(); @Override void close(); @Override void failed(final Throwable th, String containerError); @Override void pulling(); @Override void pulled(); @Override void pullFailed(); @Override void creating(); @Override void created(final String containerId); @Override void starting(); @Override void started(); @Override void healthChecking(); @Override void running(); @Override void exited(final long code);  }### Answer:
@Test public void verifyMonitorRecoversFromFlappingState() { final SettableFuture<Boolean> flappingRecoveryFuture = SettableFuture.create(); when(flapController.isFlapping()) .thenReturn(true) .thenAnswer(futureAnswer(flappingRecoveryFuture)); when(flapController.millisLeftToUnflap()).thenReturn(10L); sut.exited(17); verify(flapController).exited(); verify(statusUpdater).setThrottleState(FLAPPING); verify(flapController, timeout(30000).times(2)).isFlapping(); flappingRecoveryFuture.set(false); verify(statusUpdater, timeout(30000)).setThrottleState(NO); }