### Question:
HealthController { @Operation(summary = "Health Check Endpoint", description = "Returns HTTP 200 if the system believes it is healthy, or HTTP 5xx errors otherwise.") @GetMapping @Hidden public SystemHealthState getHealth () { switch (healthManager.getHealth()) { case OK: return SystemHealthState.OK; case ERROR: throw new HealthErrorException(); case UNKNOWN: default: throw new HealthUnknownException(); } } @Autowired  HealthController(); @Operation(summary = "Health Check Endpoint", description = "Returns HTTP 200 if the system believes it is healthy, or HTTP 5xx errors otherwise.") @GetMapping @Hidden SystemHealthState getHealth();  }### Answer:
@Test @WithAnonymousUser public void getHealthAsAnonymous () throws Exception { Mockito.when(healthManager.getHealth()).thenReturn(SystemHealthState.OK); mvc.perform(get("/health")).andExpect(status().isOk()); Mockito.when(healthManager.getHealth()).thenReturn(SystemHealthState.UNKNOWN); mvc.perform(get("/health")).andExpect(status().is5xxServerError()); Mockito.when(healthManager.getHealth()).thenReturn(SystemHealthState.ERROR); mvc.perform(get("/health")).andExpect(status().is5xxServerError()); }
@Test @WithAdmin public void getHealthAsAdmin () throws Exception { Mockito.when(healthManager.getHealth()).thenReturn(SystemHealthState.OK); mvc.perform(get("/health")).andExpect(status().isOk()); Mockito.when(healthManager.getHealth()).thenReturn(SystemHealthState.UNKNOWN); mvc.perform(get("/health")).andExpect(status().is5xxServerError()); Mockito.when(healthManager.getHealth()).thenReturn(SystemHealthState.ERROR); mvc.perform(get("/health")).andExpect(status().is5xxServerError()); }