### Question:
DeadlockHealthCheck implements HealthCheck { @Override public HealthCheckResponse call() { if (disabled) { LOGGER.log(Level.FINEST, "Running in graal native image, this health-check always returns up."); return HealthCheckResponse.builder() .name(NAME) .withData("enabled", "false") .withData("description", "in native image") .up() .build(); } boolean noDeadLock = false; try { noDeadLock = (threadBean.findDeadlockedThreads() == null); } catch (Throwable e) { LOGGER.log(Level.FINEST, "Failed to find deadlocks in ThreadMXBean, ignoring this healthcheck", e); } return HealthCheckResponse.named(NAME) .state(noDeadLock) .build(); } @Inject  DeadlockHealthCheck(ThreadMXBean threadBean); static DeadlockHealthCheck create(ThreadMXBean threadBean); @Override HealthCheckResponse call();  }### Answer:
@Test void testThatHealthCheckNameDoesNotChange() { DeadlockHealthCheck check = new DeadlockHealthCheck(threadBean); HealthCheckResponse response = check.call(); MatcherAssert.assertThat("deadlock", is(response.getName())); }
@Test void deadlockDetected() { Mockito.when(threadBean.findDeadlockedThreads()).thenReturn(new long[] {123, 456}); DeadlockHealthCheck check = new DeadlockHealthCheck(threadBean); HealthCheckResponse response = check.call(); MatcherAssert.assertThat(HealthCheckResponse.State.DOWN, is(response.getState())); MatcherAssert.assertThat(response.getData().isPresent(), is(false)); }
@Test void noDeadlockDetected() { Mockito.when(threadBean.findDeadlockedThreads()).thenReturn(null); DeadlockHealthCheck check = new DeadlockHealthCheck(threadBean); HealthCheckResponse response = check.call(); MatcherAssert.assertThat(HealthCheckResponse.State.UP, is(response.getState())); MatcherAssert.assertThat(response.getData().isPresent(), is(false)); }