DelayedHealthIndicator implements HealthIndicator { @Override public Health health() { final Builder responseBuilder; final long now = clock.get(); if (lastHealthStatus == null) { responseBuilder = Health.unknown(); } else { if (lastTimeUp == null) { responseBuilder = Health.status(lastHealthStatus.getStatus()); } else if (lastTimeUp + maxDowntime.toMillis() > now) { responseBuilder = Health.up(); } else { responseBuilder = Health.status(lastHealthStatus.getStatus()); } } return responseBuilder.withDetails(createDetails(now)).build(); } protected  DelayedHealthIndicator(
      final HealthIndicator originalHealthIndicator,
      final Duration maxDowntime,
      Supplier<Long> clock);  DelayedHealthIndicator(
      final HealthIndicator originalHealthIndicator, final Duration maxDowntime); @Scheduled(fixedDelay = 5000) void checkHealth(); @Override Health health();  }
@Test public void shouldReportUnknownHealthStatusIfAskedBeforeDelegateHealthIndicatorWasCalled() { final var sutDelayedHealthIndicator = new DelayedHealthIndicator(mockHealthIndicator, TEST_MAX_DOWNTIME); final Health actualHealth = sutDelayedHealthIndicator.health(); Assertions.assertThat(actualHealth).isNotNull(); Assertions.assertThat(actualHealth.getStatus()).isEqualTo(Status.UNKNOWN); }