@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()); Asserts.eventually( EntityFunctions.applications(getManagementContext()), Predicates.compose(Predicates.equalTo(size-1), CollectionFunctionals.sizeFunction()) ); }
@Override public Response delete(String application) { Application app = brooklyn().getApplication(application); if (!Entitlements.isEntitled(mgmt().getEntitlementManager(), Entitlements.INVOKE_EFFECTOR, Entitlements.EntityAndItem.of(app, StringAndArgument.of(Entitlements.LifecycleEffectors.DELETE, null)))) { throw WebResourceUtils.unauthorized("User '%s' is not authorized to delete application %s", Entitlements.getEntitlementContext().user(), app); } Task<?> t = brooklyn().destroy(app); TaskSummary ts = TaskTransformer.FROM_TASK.apply(t); return status(ACCEPTED).entity(ts).build(); }
ApplicationResource extends AbstractBrooklynRestResource implements ApplicationApi { @Override public Response delete(String application) { Application app = brooklyn().getApplication(application); if (!Entitlements.isEntitled(mgmt().getEntitlementManager(), Entitlements.INVOKE_EFFECTOR, Entitlements.EntityAndItem.of(app, StringAndArgument.of(Entitlements.LifecycleEffectors.DELETE, null)))) { throw WebResourceUtils.unauthorized("User '%s' is not authorized to delete application %s", Entitlements.getEntitlementContext().user(), app); } Task<?> t = brooklyn().destroy(app); TaskSummary ts = TaskTransformer.FROM_TASK.apply(t); return status(ACCEPTED).entity(ts).build(); } }
ApplicationResource extends AbstractBrooklynRestResource implements ApplicationApi { @Override public Response delete(String application) { Application app = brooklyn().getApplication(application); if (!Entitlements.isEntitled(mgmt().getEntitlementManager(), Entitlements.INVOKE_EFFECTOR, Entitlements.EntityAndItem.of(app, StringAndArgument.of(Entitlements.LifecycleEffectors.DELETE, null)))) { throw WebResourceUtils.unauthorized("User '%s' is not authorized to delete application %s", Entitlements.getEntitlementContext().user(), app); } Task<?> t = brooklyn().destroy(app); TaskSummary ts = TaskTransformer.FROM_TASK.apply(t); return status(ACCEPTED).entity(ts).build(); }  }
ApplicationResource extends AbstractBrooklynRestResource implements ApplicationApi { @Override public Response delete(String application) { Application app = brooklyn().getApplication(application); if (!Entitlements.isEntitled(mgmt().getEntitlementManager(), Entitlements.INVOKE_EFFECTOR, Entitlements.EntityAndItem.of(app, StringAndArgument.of(Entitlements.LifecycleEffectors.DELETE, null)))) { throw WebResourceUtils.unauthorized("User '%s' is not authorized to delete application %s", Entitlements.getEntitlementContext().user(), app); } Task<?> t = brooklyn().destroy(app); TaskSummary ts = TaskTransformer.FROM_TASK.apply(t); return status(ACCEPTED).entity(ts).build(); }  @Deprecated @Override JsonNode applicationTree(); @Override JsonNode fetch(String entityIds); @Override List<ApplicationSummary> list(String typeRegex); @Override ApplicationSummary get(String application); Response create(ApplicationSpec applicationSpec); @Override Response createFromYaml(String yaml); @Override Response createPoly(byte[] inputToAutodetectType); @Override Response createFromForm(String contents); @Override Response delete(String application); @Override List<EntitySummary> getDescendants(String application, String typeRegex); @Override Map<String, Object> getDescendantsSensor(String application, String sensor, String typeRegex); static Map<String, Object> getSensorMap(String sensor, Iterable<Entity> descs); }
ApplicationResource extends AbstractBrooklynRestResource implements ApplicationApi { @Override public Response delete(String application) { Application app = brooklyn().getApplication(application); if (!Entitlements.isEntitled(mgmt().getEntitlementManager(), Entitlements.INVOKE_EFFECTOR, Entitlements.EntityAndItem.of(app, StringAndArgument.of(Entitlements.LifecycleEffectors.DELETE, null)))) { throw WebResourceUtils.unauthorized("User '%s' is not authorized to delete application %s", Entitlements.getEntitlementContext().user(), app); } Task<?> t = brooklyn().destroy(app); TaskSummary ts = TaskTransformer.FROM_TASK.apply(t); return status(ACCEPTED).entity(ts).build(); }  @Deprecated @Override JsonNode applicationTree(); @Override JsonNode fetch(String entityIds); @Override List<ApplicationSummary> list(String typeRegex); @Override ApplicationSummary get(String application); Response create(ApplicationSpec applicationSpec); @Override Response createFromYaml(String yaml); @Override Response createPoly(byte[] inputToAutodetectType); @Override Response createFromForm(String contents); @Override Response delete(String application); @Override List<EntitySummary> getDescendants(String application, String typeRegex); @Override Map<String, Object> getDescendantsSensor(String application, String sensor, String typeRegex); static Map<String, Object> getSensorMap(String sensor, Iterable<Entity> descs);  }