コード例 #1
0
 @Test
 public void testDoesNotWrapsEntityIfNoNameOnService() throws Exception {
   Entity app =
       createAndStartApplication(
           "name: topLevel", "services:", "- type: " + BasicApplication.class.getName());
   assertNull(app.getConfig(EntityManagementUtils.WRAPPER_APP_MARKER));
   assertTrue(app instanceof BasicApplication);
   assertTrue(app.getChildren().isEmpty());
   assertEquals(app.getDisplayName(), "topLevel");
 }
コード例 #2
0
 private ArrayNode entitiesIdAndNameAsArray(Collection<? extends Entity> entities) {
   ArrayNode node = mapper().createArrayNode();
   for (Entity entity : entities) {
     if (Entitlements.isEntitled(
         mgmt().getEntitlementManager(), Entitlements.SEE_ENTITY, entity)) {
       ObjectNode holder = mapper().createObjectNode();
       holder.put("id", entity.getId());
       holder.put("name", entity.getDisplayName());
       node.add(holder);
     }
   }
   return node;
 }
コード例 #3
0
 @Test
 public void testWrapsEntityIfDifferentTopLevelName() throws Exception {
   Entity app =
       createAndStartApplication(
           "name: topLevel",
           "services:",
           "- type: " + BasicApplication.class.getName(),
           "  name: bottomLevel");
   assertTrue(app.getConfig(EntityManagementUtils.WRAPPER_APP_MARKER));
   assertTrue(app instanceof BasicApplication);
   assertEquals(app.getDisplayName(), "topLevel");
   assertTrue(Iterables.getOnlyElement(app.getChildren()) instanceof BasicApplication);
   assertTrue(Iterables.getOnlyElement(app.getChildren()).getChildren().isEmpty());
   assertEquals(Iterables.getOnlyElement(app.getChildren()).getDisplayName(), "bottomLevel");
 }
コード例 #4
0
  private ObjectNode entityBase(Entity entity) {
    ObjectNode aRoot = mapper().createObjectNode();
    aRoot.put("name", entity.getDisplayName());
    aRoot.put("id", entity.getId());
    aRoot.put("type", entity.getEntityType().getName());

    Boolean serviceUp = entity.getAttribute(Attributes.SERVICE_UP);
    if (serviceUp != null) aRoot.put("serviceUp", serviceUp);

    Lifecycle serviceState = entity.getAttribute(Attributes.SERVICE_STATE_ACTUAL);
    if (serviceState != null) aRoot.put("serviceState", serviceState.toString());

    String iconUrl = entity.getIconUrl();
    if (iconUrl != null) {
      if (brooklyn().isUrlServerSideAndSafe(iconUrl))
        // route to server if it is a server-side url
        iconUrl = EntityTransformer.entityUri(entity) + "/icon";
      aRoot.put("iconUrl", iconUrl);
    }

    return aRoot;
  }