@SuppressWarnings({ "rawtypes", "unchecked" }) @Test(dependsOnMethods = "testDeployApplication") public void testFetchApplicationsAndEntity() { Collection apps = client().resource("/v1/applications/fetch").get(Collection.class); log.info("Applications fetched are: " + apps); Map app = null; for (Object appI : apps) { Object name = ((Map) appI).get("name"); if ("simple-app".equals(name)) { app = (Map) appI; } if (ImmutableSet.of("simple-ent", "simple-group").contains(name)) Assert.fail(name + " should not be listed at high level: " + apps); } Assert.assertNotNull(app); Collection children = (Collection) app.get("children"); Assert.assertEquals(children.size(), 2); Map entitySummary = (Map) Iterables.find(children, withValueForKey("name", "simple-ent"), null); Map groupSummary = (Map) Iterables.find(children, withValueForKey("name", "simple-group"), null); Assert.assertNotNull(entitySummary); Assert.assertNotNull(groupSummary); String itemIds = app.get("id") + "," + entitySummary.get("id") + "," + groupSummary.get("id"); Collection entities = client().resource("/v1/applications/fetch?items="+itemIds) .get(Collection.class); log.info("Applications+Entities fetched are: " + entities); Assert.assertEquals(entities.size(), apps.size() + 2); Map entityDetails = (Map) Iterables.find(entities, withValueForKey("name", "simple-ent"), null); Map groupDetails = (Map) Iterables.find(entities, withValueForKey("name", "simple-group"), null); Assert.assertNotNull(entityDetails); Assert.assertNotNull(groupDetails); Assert.assertEquals(entityDetails.get("parentId"), app.get("id")); Assert.assertNull(entityDetails.get("children")); Assert.assertEquals(groupDetails.get("parentId"), app.get("id")); Assert.assertNull(groupDetails.get("children")); Collection entityGroupIds = (Collection) entityDetails.get("groupIds"); Assert.assertNotNull(entityGroupIds); Assert.assertEquals(entityGroupIds.size(), 1); Assert.assertEquals(entityGroupIds.iterator().next(), groupDetails.get("id")); Collection groupMembers = (Collection) groupDetails.get("members"); Assert.assertNotNull(groupMembers); for (Application appi : getManagementContext().getApplications()) { Entities.dumpInfo(appi); } log.info("MEMBERS: " + groupMembers); Assert.assertEquals(groupMembers.size(), 1); Map entityMemberDetails = (Map) Iterables.find(groupMembers, withValueForKey("name", "simple-ent"), null); Assert.assertNotNull(entityMemberDetails); Assert.assertEquals(entityMemberDetails.get("id"), entityDetails.get("id")); }
@Override public ApplicationSummary get(String application) { return ApplicationTransformer.summaryFromApplication(brooklyn().getApplication(application)); }
ApplicationResource extends AbstractBrooklynRestResource implements ApplicationApi { @Override public ApplicationSummary get(String application) { return ApplicationTransformer.summaryFromApplication(brooklyn().getApplication(application)); } }
ApplicationResource extends AbstractBrooklynRestResource implements ApplicationApi { @Override public ApplicationSummary get(String application) { return ApplicationTransformer.summaryFromApplication(brooklyn().getApplication(application)); }  }
ApplicationResource extends AbstractBrooklynRestResource implements ApplicationApi { @Override public ApplicationSummary get(String application) { return ApplicationTransformer.summaryFromApplication(brooklyn().getApplication(application)); }  @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 ApplicationSummary get(String application) { return ApplicationTransformer.summaryFromApplication(brooklyn().getApplication(application)); }  @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);  }