EntityResource extends AbstractBrooklynRestResource implements EntityApi { @Override public List<EntitySummary> getChildren(final String application, final String entity) { return FluentIterable .from(brooklyn().getEntity(application, entity).getChildren()) .filter(EntitlementPredicates.isEntitled(mgmt().getEntitlementManager(), Entitlements.SEE_ENTITY)) .transform(EntityTransformer.fromEntity(ui.getBaseUriBuilder())) .toList(); }  @Override List<EntitySummary> list(final String application); @Override EntitySummary get(String application, String entityName); @Override List<EntitySummary> getChildren(final String application, final String entity); @Override Response addChildren(String applicationToken, String entityToken, Boolean start, String timeoutS, String yaml); @Override List<TaskSummary> listTasks(String applicationId, String entityId, int limit, Boolean recurse); @Override @Deprecated List<TaskSummary> listTasks(String applicationId, String entityId); @Override TaskSummary getTask(final String application, final String entityToken, String taskId); @SuppressWarnings("unchecked") @Override List<Object> listTags(String applicationId, String entityId); @Override Response getIcon(String applicationId, String entityId); @Override Response rename(String application, String entity, String newName); @Override Response expunge(String application, String entity, boolean release); @Override List<EntitySummary> getDescendants(String application, String entity, String typeRegex); @Override Map<String, Object> getDescendantsSensor(String application, String entity, String sensor, String typeRegex); @Override List<LocationSummary> getLocations(String application, String entity); @Override String getSpec(String applicationToken, String entityToken);  }
@Test public void testAddChild() throws Exception { try { Response response = client().path(entityEndpoint + "/children").query("timeout", "10s") .post(javax.ws.rs.client.Entity.entity("services: [ { type: "+TestEntity.class.getName()+" }]", "application/yaml")); HttpAsserts.assertHealthyStatusCode(response.getStatus()); Assert.assertEquals(entity.getChildren().size(), 1); Entity child = Iterables.getOnlyElement(entity.getChildren()); Assert.assertTrue(Entities.isManaged(child)); TaskSummary task = response.readEntity(TaskSummary.class); Assert.assertEquals(task.getResult(), MutableList.of(child.getId())); } finally { Collection<Entity> children = entity.getChildren(); if (!children.isEmpty()) Entities.unmanage(Iterables.getOnlyElement(children)); } }