@Test(groups = "Integration", dependsOnMethods = "testDeployRedisApplication")
  public void testDeployLegacyRedisApplication() throws Exception {
    @SuppressWarnings("deprecation")
    Response response = api.getApplicationApi().create(legacyRedisSpec);
    assertEquals(response.getStatus(), 201);
    assertEquals(getManagementContext().getApplications().size(), 2);
    assertServiceStateEventually("redis-legacy-app", "redis-ent", Lifecycle.RUNNING, LONG_WAIT);

    // Tear the app down so it doesn't interfere with other tests
    Response deleteResponse = api.getApplicationApi().delete("redis-legacy-app");
    assertEquals(deleteResponse.getStatus(), 202);
    assertEquals(getManagementContext().getApplications().size(), 1);
  }
  @Test(groups = "Integration", dependsOnMethods = "testTriggerRedisStopEffector")
  public void testDeleteRedisApplication() throws Exception {
    int size = getManagementContext().getApplications().size();
    Response response = api.getApplicationApi().delete("redis-app");
    Assert.assertNotNull(response);
    try {
      Asserts.succeedsEventually(
          ImmutableMap.of("timeout", Duration.minutes(1)),
          new Runnable() {
            public void run() {
              try {
                ApplicationSummary summary = api.getApplicationApi().get("redis-app");
                fail("Redis app failed to disappear: summary=" + summary);
              } catch (Exception failure) {
                // expected -- it will be a ClientResponseFailure but that class is deprecated so
                // catching all
                // and asserting contains the word 404
                Assert.assertTrue(failure.toString().indexOf("404") >= 0);
              }
            }
          });
    } catch (Exception failure) {
      // expected -- it will be a ClientResponseFailure but that class is deprecated so catching all
      // and asserting contains the word 404
      Assert.assertTrue(failure.toString().indexOf("404") >= 0);
    }

    assertEquals(getManagementContext().getApplications().size(), size - 1);
  }
 @Test(groups = "Integration")
 public void testDeployRedisApplication() throws Exception {
   Response response = api.getApplicationApi().createPoly(redisSpec.getBytes());
   assertEquals(response.getStatus(), 201);
   assertEquals(getManagementContext().getApplications().size(), 1);
   final String entityId =
       getManagementContext()
           .getApplications()
           .iterator()
           .next()
           .getChildren()
           .iterator()
           .next()
           .getId();
   assertServiceStateEventually("redis-app", entityId, Lifecycle.RUNNING, LONG_WAIT);
 }
  @Test(
      groups = "Integration",
      dependsOnMethods = {"testListSensorsRedis", "testListEntities"})
  public void testTriggerRedisStopEffector() throws Exception {
    final String entityId =
        getManagementContext()
            .getApplications()
            .iterator()
            .next()
            .getChildren()
            .iterator()
            .next()
            .getId();
    Response response =
        api.getEffectorApi()
            .invoke("redis-app", entityId, "stop", "5000", ImmutableMap.<String, Object>of());

    assertEquals(response.getStatus(), Response.Status.ACCEPTED.getStatusCode());
    assertServiceStateEventually("redis-app", entityId, Lifecycle.STOPPED, LONG_WAIT);
  }
 @Test(groups = "Integration", dependsOnMethods = "testDeployRedisApplication")
 public void testListSensorsRedis() throws Exception {
   String entityId =
       getManagementContext()
           .getApplications()
           .iterator()
           .next()
           .getChildren()
           .iterator()
           .next()
           .getId();
   Collection<SensorSummary> sensors = api.getSensorApi().list("redis-app", entityId);
   assertTrue(sensors.size() > 0);
   SensorSummary uptime =
       Iterables.find(
           sensors,
           new Predicate<SensorSummary>() {
             @Override
             public boolean apply(SensorSummary sensorSummary) {
               return sensorSummary.getName().equals("redis.uptime");
             }
           });
   assertEquals(uptime.getType(), "java.lang.Integer");
 }
 @Test(groups = "Integration", dependsOnMethods = "testDeployRedisApplication")
 public void testListEntities() {
   Collection<EntitySummary> entities = api.getEntityApi().list("redis-app");
   Assert.assertFalse(entities.isEmpty());
 }