SelfCheckHealthCheck implements HealthCheck { @Override public Result execute() { final FormattingResultLog resultLog = new FormattingResultLog(); checkServiceResolver(resultLog); if (resultLog.getAggregateStatus().equals(Status.CRITICAL)) { return new Result(resultLog); } checkHistoryNodeAccess(resultLog); checkHookHistoryNodeAccess(resultLog); return new Result(resultLog); }  @Override Result execute();  }
@Test public void checkServiceResolver_ok() { Result result = check.execute(); assertEquals(Result.Status.OK, result.getStatus()); }
@Test public void checkServiceResolver_failService() throws LoginException { when(resolverService.getServiceResourceResolver()).thenReturn(null); Result result = check.execute(); assertEquals(Result.Status.CRITICAL, result.getStatus()); }
@Test public void checkServiceResolver_failServiceException() throws LoginException { when(resolverService.getServiceResourceResolver()).thenThrow(LoginException.class); Result result = check.execute(); assertEquals(Result.Status.CRITICAL, result.getStatus()); }
@Test public void checkServiceResolver_failMigrationService() throws LoginException { when(resolverService.getContentMigratorResourceResolver()).thenReturn(null); Result result = check.execute(); assertEquals(Result.Status.CRITICAL, result.getStatus()); }
@Test public void checkServiceResolver_failMigrationServiceException() throws LoginException { when(resolverService.getContentMigratorResourceResolver()).thenThrow(LoginException.class); Result result = check.execute(); assertEquals(Result.Status.CRITICAL, result.getStatus()); }
@Test public void checkServiceResolver_failHistory() throws LoginException { when(resolver.getResource("/var/aecu")).thenReturn(null); Result result = check.execute(); assertEquals(Result.Status.CRITICAL, result.getStatus()); }
@Test public void checkServiceResolver_failHookHistory() throws LoginException { when(resolver.getResource("/var/aecu-installhook")).thenReturn(null); Result result = check.execute(); assertEquals(Result.Status.CRITICAL, result.getStatus()); }