@Test public void getHealth () { when(systemHealth.getHealth()).thenReturn(SystemHealthState.OK); when(adminHealth.getHealth()).thenReturn(SystemHealthState.OK); assertEquals(SystemHealthState.OK, healthManager.getHealth()); Mockito.reset(systemHealth, adminHealth); when(systemHealth.getHealth()).thenReturn(SystemHealthState.OK).thenReturn(SystemHealthState.ERROR); assertEquals(SystemHealthState.ERROR, healthManager.getHealth()); Mockito.reset(systemHealth, adminHealth); when(systemHealth.getHealth()).thenReturn(SystemHealthState.ERROR).thenReturn(SystemHealthState.OK); assertEquals(SystemHealthState.ERROR, healthManager.getHealth()); verify(systemHealth, times(1)).getHealth(); Mockito.reset(systemHealth, adminHealth); when(healthManager.getSystemHealth()).thenReturn(null); assertEquals(SystemHealthState.UNKNOWN, healthManager.getHealth()); }
SystemHealthState getHealth () { if (getSystemHealth() != null) { for (SystemHealth health : getSystemHealth()) { SystemHealthState healthCheck = health.getHealth(); if (healthCheck == SystemHealthState.OK) { log.debug("{} : {}", health.getClass().getSimpleName(), healthCheck); continue; } log.error("{} : {}", health.getClass().getSimpleName(), healthCheck); return SystemHealthState.ERROR; } return SystemHealthState.OK; } return SystemHealthState.UNKNOWN; }
HealthManager { SystemHealthState getHealth () { if (getSystemHealth() != null) { for (SystemHealth health : getSystemHealth()) { SystemHealthState healthCheck = health.getHealth(); if (healthCheck == SystemHealthState.OK) { log.debug("{} : {}", health.getClass().getSimpleName(), healthCheck); continue; } log.error("{} : {}", health.getClass().getSimpleName(), healthCheck); return SystemHealthState.ERROR; } return SystemHealthState.OK; } return SystemHealthState.UNKNOWN; } }
HealthManager { SystemHealthState getHealth () { if (getSystemHealth() != null) { for (SystemHealth health : getSystemHealth()) { SystemHealthState healthCheck = health.getHealth(); if (healthCheck == SystemHealthState.OK) { log.debug("{} : {}", health.getClass().getSimpleName(), healthCheck); continue; } log.error("{} : {}", health.getClass().getSimpleName(), healthCheck); return SystemHealthState.ERROR; } return SystemHealthState.OK; } return SystemHealthState.UNKNOWN; } @Autowired  HealthManager();   HealthManager(Collection<SystemHealth> systemHealth); }
HealthManager { SystemHealthState getHealth () { if (getSystemHealth() != null) { for (SystemHealth health : getSystemHealth()) { SystemHealthState healthCheck = health.getHealth(); if (healthCheck == SystemHealthState.OK) { log.debug("{} : {}", health.getClass().getSimpleName(), healthCheck); continue; } log.error("{} : {}", health.getClass().getSimpleName(), healthCheck); return SystemHealthState.ERROR; } return SystemHealthState.OK; } return SystemHealthState.UNKNOWN; } @Autowired  HealthManager();   HealthManager(Collection<SystemHealth> systemHealth);  }
HealthManager { SystemHealthState getHealth () { if (getSystemHealth() != null) { for (SystemHealth health : getSystemHealth()) { SystemHealthState healthCheck = health.getHealth(); if (healthCheck == SystemHealthState.OK) { log.debug("{} : {}", health.getClass().getSimpleName(), healthCheck); continue; } log.error("{} : {}", health.getClass().getSimpleName(), healthCheck); return SystemHealthState.ERROR; } return SystemHealthState.OK; } return SystemHealthState.UNKNOWN; } @Autowired  HealthManager();   HealthManager(Collection<SystemHealth> systemHealth);  static final Logger log; }