Route53RaiderImpl implements Route53Raider { @Override public HealthCheckStatus getSimpleHealthCheckerStatus(String healthCheckerId) { GetHealthCheckStatusRequest getHealthCheckStatusRequest = new GetHealthCheckStatusRequest(); getHealthCheckStatusRequest.withHealthCheckId(healthCheckerId); List<HealthCheckObservation> healthCheckObservations = route53Delegator.getAmazonRoute53().getHealthCheckStatus(getHealthCheckStatusRequest).getHealthCheckObservations(); for (HealthCheckObservation obs : healthCheckObservations) { if (obs.getStatusReport().getStatus().contains("Failure")) { return HealthCheckStatus.FAILURE; } } return HealthCheckStatus.SUCCESS; } Route53RaiderImpl(); @Override List<HealthCheck> listHealthCheckers(); @Override List<HealthCheckObservation> getHealthCheckerStatus(String healthCheckerId); @Override HealthCheckStatus getSimpleHealthCheckerStatus(String healthCheckerId); @Override void updateTrafficPolicy(String trafficPolicyName, int version); @Override int getTrafficPolicyVersion(String trafficPolicyName); String getR53PolicyId(String policyId); @Override void updateHealthCheckRegions(String healthCheckId, List<String> regions); @Override List<String> getHealthCheckRegions(String healthCheckId); @Override void updateHealthCheckToDefaultRegions(String healthCheckId);  }
@Test public void testSimpleGetHealthCheckerStatusWhenFailure() { Mockito.when(mockAmazonRoute53.getHealthCheckStatus(Mockito.any())) .thenReturn(new GetHealthCheckStatusResult().withHealthCheckObservations(Arrays.asList(createFailureHealthCheckOb()))); HealthCheckStatus actualHealthCheckResponse = route53RaiderUnderTest.getSimpleHealthCheckerStatus(SW2_R53_HEALTH_CHECK_ID); Assert.assertEquals(HealthCheckStatus.FAILURE, actualHealthCheckResponse); }
@Test public void testSimpleGetHealthCheckerStatusWhenSuccess() { Mockito.when(mockAmazonRoute53.getHealthCheckStatus(Mockito.any())) .thenReturn(new GetHealthCheckStatusResult().withHealthCheckObservations(Arrays.asList(createSuccessHealthCheckOb()))); HealthCheckStatus actualHealthCheckResponse = route53RaiderUnderTest.getSimpleHealthCheckerStatus(SW2_R53_HEALTH_CHECK_ID); Assert.assertEquals(HealthCheckStatus.SUCCESS, actualHealthCheckResponse); }
@Test public void testSimpleGetHealthCheckerStatusWhenMultipleSuccessesAndFailuresShouldBeFailure() { List<HealthCheckObservation> observations = createMultipleSuccessHealthObs(); observations.add(createFailureHealthCheckOb()); GetHealthCheckStatusResult healthCheckResult = new GetHealthCheckStatusResult().withHealthCheckObservations(observations); Mockito.when(mockAmazonRoute53.getHealthCheckStatus(Mockito.any())).thenReturn(healthCheckResult); HealthCheckStatus actualHealthCheckResponse = route53RaiderUnderTest.getSimpleHealthCheckerStatus(SW2_R53_HEALTH_CHECK_ID); Assert.assertEquals(HealthCheckStatus.FAILURE, actualHealthCheckResponse); }
@Test public void testSimpleGetHealthCheckerStatusWhenMultipleSuccessesShouldBeSuccess() { List<HealthCheckObservation> observations = createMultipleSuccessHealthObs(); observations.add(createSuccessHealthCheckOb()); GetHealthCheckStatusResult healthCheckResult = new GetHealthCheckStatusResult().withHealthCheckObservations(observations); Mockito.when(mockAmazonRoute53.getHealthCheckStatus(Mockito.any())).thenReturn(healthCheckResult); HealthCheckStatus actualHealthCheckResponse = route53RaiderUnderTest.getSimpleHealthCheckerStatus(SW2_R53_HEALTH_CHECK_ID); Assert.assertEquals(HealthCheckStatus.SUCCESS, actualHealthCheckResponse); }