ElastiCacheStepDefinitions { @Then("^assertElastiCache cluster status \"([^\"]*)\"$") public void assertElastiCacheClusterStatus(String expectedStatus) throws Throwable { String clusterName = executionStateCache.getElastiCacheClusterName(); if (clusterName == null || clusterName.isEmpty()) { throw new RuntimeException("Unable to reboot elastiCache cluster as no cluster information is available"); } org.testng.Assert.assertEquals(elastiCacheRaider.getElastiCacheClusterStatus(clusterName), expectedStatus); } ElastiCacheStepDefinitions(); ExecutionStateCache getExecutionStateCache(); void setExecutionStateCache(ExecutionStateCache executionStateCache); @Given("^ElastiCache \"([^\"]*)\"$") ElastiCacheStepDefinitions givenElastiCacheCluster(String elasticCacheClusterName); @When("^reboot ElastiCache nodes (\\d+)$") ElastiCacheStepDefinitions rebootElastiCacheCluster(int numNodes); @Then("^assertElastiCache cluster status \"([^\"]*)\"$") void assertElastiCacheClusterStatus(String expectedStatus); @When("^add ElastiCache nodes (\\d+)$") ElastiCacheStepDefinitions addElastiCacheNodes(int numNodes); @When("^remove ElastiCache nodes (\\d+)$") ElastiCacheStepDefinitions removeElastiCacheNodes(int numNodes); @When("^detach ElastiCache subnet \"([^\"]*)\"$") ElastiCacheStepDefinitions detachElastiCacheSubnet(String subnetId); @Then("^attach ElastiCache subnet \"([^\"]*)\"$") ElastiCacheStepDefinitions attachElastiCacheSubnet(String subnetId); @When("^change ElastiCache security group from \"([^\"]*)\" to \"([^\"]*)\"$") ElastiCacheStepDefinitions changeElastiCacheSecurityGroup(String secGroupFrom, String secGroupTo); @Given("^ElastiCache node \"([^\"]*)\"$") ElastiCacheStepDefinitions givenElastCacheNode(String nodeName); @When("^reboot ElastiCache node") ElastiCacheStepDefinitions rebootElastiCacheNode(); @Then("^assertElastiCache node status \"([^\"]*)\"$") void assertElastiCacheNodeStatus(String expectedStatus);  }
@Test public void testAssertElastiCacheClusterStatus() throws Throwable { executionStateCache.setElastiCacheClusterName("cacheCluster"); PowerMockito.when(elastiCacheRaider.getElastiCacheClusterStatus("cacheCluster")).thenReturn("available"); elastiCacheStepDefinitions.assertElastiCacheClusterStatus("available"); }
@Test (expected = AssertionError.class) public void testAssertElastiCacheClusterExceptionStatus() throws Throwable { executionStateCache.setElastiCacheClusterName("cacheCluster"); PowerMockito.when(elastiCacheRaider.getElastiCacheClusterStatus("cacheCluster")).thenReturn("available"); elastiCacheStepDefinitions.assertElastiCacheClusterStatus("unavailable"); }