EntityResource extends AbstractBrooklynRestResource implements EntityApi { @Override public Response rename(String application, String entity, String newName) { Entity instance = brooklyn().getEntity(application, entity); if (instance != null && !Entitlements.isEntitled(mgmt().getEntitlementManager(), Entitlements.RENAME_ENTITY, instance)) { throw WebResourceUtils.forbidden("User '%s' is not authorized to rename the entity '%s'", Entitlements.getEntitlementContext().user(), entity); } instance.setDisplayName(newName); return status(Response.Status.OK).build(); }  @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 testRename() throws Exception { try { Response response = client().path(entityEndpoint + "/name") .query("name", "New Name") .post(null); HttpAsserts.assertHealthyStatusCode(response.getStatus()); Assert.assertTrue(entity.getDisplayName().equals("New Name")); } finally { entity.setDisplayName("simple-ent"); } }