### Question:
Loader { public void teardown(String stack, Region region) throws SQLException { CloudFormationManager cf = new CloudFormationManager(region); cf.terminateStack(stack); spark.stop(); } Loader(Region region);  Loader(String app, String master, String warehouse); SparkSession getSparkSession(); void setConfiguration(Configuration configuration); void setDf(Dataset df); void loadSourceFiles(Mapping mapping); Dataset<Row> loadDf(InputStream stream); void teardown(String stack, Region region); void load(Configuration configuration); void write(String destination); void write(String destination, List<String> overflowColumns); void addMetadata(String destination); void materializeUUID(String prefix, String suffix);  }### Answer:
@Test public void testTeardown() throws IOException, SQLException, ClassNotFoundException { AmazonCloudFormationClient client = new AmazonCloudFormationClient(); String name = "TestTeardownCluster" + UUID.randomUUID().toString(); CreateStackRequest createStackRequest = new CreateStackRequest(); client.setRegion(Region.getRegion(Regions.US_WEST_2)); createStackRequest.setStackName(name); createStackRequest.setTemplateBody(IOUtils.toString(getClass().getResourceAsStream("cloudformation.template"), "UTF-8")); client.createStack(createStackRequest); loader.setConfiguration(configuration); loader.teardown(name, Region.getRegion(Regions.US_WEST_2)); 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()); } }