StateV1HealthMonitor implements HealthMonitor { @Override public ServiceStatusInfo getStatus() { return updater.getServiceStatusInfo(); } StateV1HealthMonitor(StateV1HealthUpdater updater, RunletExecutor executor, Duration delay); @Override ServiceStatusInfo getStatus(); @Override void close();  }
@Test public void downThenUpThenDown() throws Exception { StateV1HealthClient client = mock(StateV1HealthClient.class); StateV1HealthUpdater updater = new StateV1HealthUpdater("https: RunletExecutor executor = new RunletExecutorImpl(2); try (StateV1HealthMonitor monitor = new StateV1HealthMonitor(updater, executor, Duration.ofMillis(10))) { assertEquals(ServiceStatus.NOT_CHECKED, monitor.getStatus().serviceStatus()); when(client.get()).thenReturn(HealthInfo.fromHealthStatusCode(HealthInfo.UP_STATUS_CODE)); while (monitor.getStatus().serviceStatus() != ServiceStatus.UP) { try { Thread.sleep(2); } catch (InterruptedException ignored) { } } when(client.get()).thenReturn(HealthInfo.fromException(new IllegalStateException("foo"))); while (monitor.getStatus().serviceStatus() != ServiceStatus.DOWN) { try { Thread.sleep(2); } catch (InterruptedException ignored) { } } } }