@Test(
      dependsOnMethods = {
        "testListEffectors",
        "testFetchApplicationsAndEntity",
        "testTriggerSampleEffector",
        "testListApplications",
        "testReadEachSensor",
        "testPolicyWhichCapitalizes",
        "testLocatedLocation"
      })
  public void testDeleteApplication() throws TimeoutException, InterruptedException {
    waitForPageFoundResponse("/v1/applications/simple-app", ApplicationSummary.class);
    Collection<Application> apps = getManagementContext().getApplications();
    log.info("Deleting simple-app from " + apps);
    int size = apps.size();

    ClientResponse response =
        client().resource("/v1/applications/simple-app").delete(ClientResponse.class);

    assertEquals(response.getStatus(), Response.Status.ACCEPTED.getStatusCode());
    TaskSummary task = response.getEntity(TaskSummary.class);
    assertTrue(task.getDescription().toLowerCase().contains("destroy"), task.getDescription());
    assertTrue(task.getDescription().toLowerCase().contains("simple-app"), task.getDescription());

    waitForPageNotFoundResponse("/v1/applications/simple-app", ApplicationSummary.class);

    log.info("App appears gone, apps are: " + getManagementContext().getApplications());
    // more logging above, for failure in the check below

    Asserts.eventually(
        EntityFunctions.applications(getManagementContext()),
        Predicates.compose(Predicates.equalTo(size - 1), CollectionFunctionals.sizeFunction()));
  }
  @Test
  public void testDeployApplication() throws Exception {
    ClientResponse response = clientDeploy(simpleSpec);

    HttpTestUtils.assertHealthyStatusCode(response.getStatus());
    assertEquals(getManagementContext().getApplications().size(), 1);
    assertRegexMatches(response.getLocation().getPath(), "/v1/applications/.*");
    // Object taskO = response.getEntity(Object.class);
    TaskSummary task = response.getEntity(TaskSummary.class);
    log.info("deployed, got " + task);
    assertEquals(
        task.getEntityId(),
        getManagementContext().getApplications().iterator().next().getApplicationId());

    waitForApplicationToBeRunning(response.getLocation());
  }