Route53StepDefinitions { @Then("^assertFalse R53 failover from \"([^\"]*)\" to \"([^\"]*)\"$") public void assertFalseR53Failover(String primary, String secondary) throws Throwable { if (!isRegex(secondary)) { Assert.assertFalse("DNS Failover Check failed", DNSLookup.hostNameLookup(primary).equalsIgnoreCase(secondary)); } else { Assert.assertFalse("DNS Failover Check failed", DNSLookup.hostNameLookup(primary).matches(secondary)); } } Route53StepDefinitions(); ExecutionStateCache getExecutionStateCache(); void setExecutionStateCache(ExecutionStateCache executionStateCache); @Then("^assertTrue R53 failover from \"([^\"]*)\" to \"([^\"]*)\"$") void assertTrueR53Failover(String primary, String secondary); @Then("^assertFalse R53 failover from \"([^\"]*)\" to \"([^\"]*)\"$") void assertFalseR53Failover(String primary, String secondary); @Given("^R53 Healthcheck ID \"([^\"]*)\"$") Route53StepDefinitions givenR53HealthCheckID(String r53HealthCheckId); @Then("^assertR53 HealthCheck state = \"([^\"]*)\"$") void assertCloudWatchAlarmState(String expectedState); @Then("^assertR53 HealthCheckId \"([^\"]*)\" with state = \"([^\"]*)\"$") void assertCloudWatchAlarmState(String route53HealthCheckId, String expectedState); @Given("^R53 traffic policy name \"([^\"]*)\"$") Route53StepDefinitions giveR53TrafficPolicyName(String r53PolicyName); @When("^R53 update traffic policy version to (\\d+)$") void updateR53PolicyVersion(int version); @Then("^assertR53 traffic policy versionId = (\\d+)$") void assertR53VersionId(int expectedVersion); @When("^R53 update HealthCheck regions to \"([^\"]*)\"$") void updatR53HealthCheckRegions(String regions); @Then("^assertR53 HealthCheck regions = \"([^\"]*)\"$") void assertR53HealthCheckRegions(String regions); @When("^R53 reset HealthCheck to default regions$") void resetR53HealthCheckRegions();  }
@Test public void testAssertFalseR53Failover() throws Throwable { route53StepDefinitions.assertFalseR53Failover(PRIMARY, "(([^/])+)?blah.com."); }
@Test public void testAssertFalseR53FailoverInvalid() throws Throwable { route53StepDefinitions.assertFalseR53Failover(PRIMARY, ""); }
@Test (expected = UnknownHostException.class) public void testAssertFalseR53FailoverUnknownHost() throws Throwable { PowerMockito.when(DNSLookup.hostNameLookup("primary")).thenThrow(new UnknownHostException()); route53StepDefinitions.assertFalseR53Failover("primary", "secondary"); }
@Test (expected = AssertionError.class) public void testAssertFalseR53FailoverMismatchHost() throws Throwable { route53StepDefinitions.assertFalseR53Failover(PRIMARY, "(([^/])+)?.com"); }