### Question:
CloudFormationManager { public void terminateStack(String name) { DeleteStackRequest deleteStackRequest = new DeleteStackRequest(); deleteStackRequest.setStackName(name); cf.deleteStack(deleteStackRequest); } CloudFormationManager(Region region); void terminateStack(String name);  }### Answer:
@Test public void testTerminateStack() throws IOException { AmazonCloudFormationClient client = new AmazonCloudFormationClient(); String name = "JUnitStack" + UUID.randomUUID().toString(); CreateStackRequest createStackRequest = new CreateStackRequest(); CloudFormationManager manager = new CloudFormationManager(Region.getRegion(Regions.US_WEST_2)); client.setRegion(Region.getRegion(Regions.US_WEST_2)); createStackRequest.setStackName(name); createStackRequest.setTemplateBody(IOUtils.toString(getClass().getResourceAsStream("cloudformation.template"), "UTF-8")); client.createStack(createStackRequest); manager.terminateStack(name); for(StackSummary stack : client.listStacks().getStackSummaries()) { if(stack.getStackStatus().equalsIgnoreCase("DELETE_COMPLETE")) continue; if(stack.getStackStatus().equalsIgnoreCase("DELETE_FAILED")) continue; if(stack.getStackStatus().equalsIgnoreCase("DELETE_IN_PROGRESS")) continue; if(stack.getStackName().equals(name)) fail(name + " should have been deleted but status is: " + stack.getStackStatus()); } }