GraphDbHealthIndicator implements HealthIndicator { @Override public Health health() { Health health = AcsMonitoringUtilities.health(this::check, DESCRIPTION); Status status = health.getStatus(); if (status.equals(Status.UP) && !this.cassandraEnabled) { health = AcsMonitoringUtilities.health(status, AcsMonitoringUtilities.HealthCode.IN_MEMORY, DESCRIPTION); } return health; } @Autowired  GraphDbHealthIndicator(final GraphResourceRepository resourceHierarchicalRepository); @Override Health health();  }
@Test(dataProvider = "statuses") public void testHealth(final GraphResourceRepository graphResourceRepository, final Status status, final AcsMonitoringUtilities.HealthCode healthCode, final boolean cassandraEnabled) throws Exception { GraphDbHealthIndicator graphDbHealthIndicator = new GraphDbHealthIndicator(graphResourceRepository); ReflectionTestUtils.setField(graphDbHealthIndicator, "cassandraEnabled", cassandraEnabled); Assert.assertEquals(status, graphDbHealthIndicator.health().getStatus()); Assert.assertEquals(GraphDbHealthIndicator.DESCRIPTION, graphDbHealthIndicator.health().getDetails().get(AcsMonitoringUtilities.DESCRIPTION_KEY)); if (healthCode == AcsMonitoringUtilities.HealthCode.AVAILABLE) { Assert.assertFalse( graphDbHealthIndicator.health().getDetails().containsKey(AcsMonitoringUtilities.CODE_KEY)); } else { Assert.assertEquals(healthCode, graphDbHealthIndicator.health().getDetails().get(AcsMonitoringUtilities.CODE_KEY)); } }