tags().addTag(BrooklynTags.newIconUrlTag((String) flags.remove(BrooklynConfigKeys.ICON_URL.getName())));
/** augments the given item with annotations and class data for the given class, then adds to catalog * @deprecated since 0.7.0 the classpath DO is replaced by libraries */ @Deprecated public CatalogItem<?,?> addCatalogEntry(CatalogItemDtoAbstract<?,?> item, Class<?> c) { Catalog catalogAnnotation = c.getAnnotation(Catalog.class); item.setSymbolicName(c.getName()); item.setJavaType(c.getName()); item.setDisplayName(firstNonEmpty(c.getSimpleName(), c.getName())); if (catalogAnnotation!=null) { item.setDisplayName(firstNonEmpty(catalogAnnotation.name(), item.getDisplayName())); item.setDescription(firstNonEmpty(catalogAnnotation.description())); item.setIconUrl(firstNonEmpty(catalogAnnotation.iconUrl())); } if (item instanceof CatalogEntityItemDto || item instanceof CatalogTemplateItemDto) { item.tags().addTag(BrooklynTags.newTraitsTag(ClassUtils.getAllInterfaces(c))); } if (log.isTraceEnabled()) log.trace("adding to catalog: "+c+" (from catalog "+catalog+")"); catalog.addEntry(item); return item; }
@Test public void testEntityTags() throws Exception { MyEntity origE = origApp.createAndManageChild(EntitySpec.create(MyEntity.class)); origE.tags().addTag("foo"); origE.tags().addTag(origApp); newApp = rebind(); MyEntity newE = Iterables.getOnlyElement( Entities.descendantsAndSelf(newApp, MyEntity.class) ); assertTrue(newE.tags().containsTag("foo"), "tags are "+newE.tags().getTags()); assertFalse(newE.tags().containsTag("bar")); assertTrue(newE.tags().containsTag(newE.getParent())); assertTrue(newE.tags().containsTag(origApp)); assertEquals(newE.tags().getTags(), MutableSet.of("foo", newE.getParent())); }
assertNotNull(origItem, "Item not in catalog (might be using new type registry where adding tags to items isn't supported as items come from BOM)"); final String tag = "tag1"; origItem.tags().addTag(tag); assertTrue(origItem.tags().containsTag(tag)); origManagementContext.getCatalog().persist(origItem);
@Test public void testCreateGetContainsAndRemoveTags() throws Exception { entity = app.createAndManageChild(EntitySpec.create(TestEntity.class) .tag(2) .addInitializer(EntityInitializers.addingTags("foo"))); entity.tags().addTag(app); Assert.assertTrue(entity.tags().containsTag(app)); Assert.assertTrue(entity.tags().containsTag("foo")); Assert.assertTrue(entity.tags().containsTag(2)); Assert.assertFalse(entity.tags().containsTag("bar")); Assert.assertEquals(entity.tags().getTags(), MutableSet.of(app, "foo", 2)); entity.tags().removeTag("foo"); Assert.assertFalse(entity.tags().containsTag("foo")); Assert.assertTrue(entity.tags().containsTag(entity.getParent())); Assert.assertFalse(entity.tags().containsTag(entity)); entity.tags().removeTag(2); Assert.assertEquals(entity.tags().getTags(), MutableSet.of(app)); }
@Test public void testHandlesDanglingReference() throws Exception { SshMachineLocation todelete = mgmt().getLocationManager().createLocation(LocationSpec.create(SshMachineLocation.class)); SshMachineLocation loc = mgmt().getLocationManager().createLocation(LocationSpec.create(SshMachineLocation.class)); origApp.addLocations(ImmutableList.of(todelete)); origApp.sensors().set(Sensors.newSensor(Object.class, "mysensor"), loc); origApp.config().set(ConfigKeys.newConfigKey(Object.class, "myconfig"), loc); origApp.tags().addTag(loc); loc.config().set(ConfigKeys.newConfigKey(Object.class, "myconfig"), todelete); Locations.unmanage(todelete); assertFalse(getRawData().getLocations().containsKey(todelete.getId())); assertTransformIsNoop(); }
@Test public void testKeepsLocationsReferencedInTag() throws Exception { SshMachineLocation loc = mgmt().getLocationManager().createLocation(LocationSpec.create(SshMachineLocation.class)); origApp.tags().addTag(loc); assertTransformIsNoop(); }
protected void addTags(RebindContext rebindContext, T memento) { if (instance instanceof EntityAdjunct && Strings.isNonBlank(memento.getUniqueTag())) { ((AdjunctTagSupport)(instance.tags())).setUniqueTag(memento.getUniqueTag()); } for (Object tag : memento.getTags()) { instance.tags().addTag(tag); } }
@Override public void run() { entity.tags().addTag(val); }}); futures.add(future);
@Test public void testPolicyTags() throws Exception { Enricher origEnricher = origApp.enrichers().add(EnricherSpec.create(MyEnricher.class)); origEnricher.tags().addTag("foo"); origEnricher.tags().addTag(origApp); newApp = rebind(); Enricher newEnricher = Iterables.getOnlyElement(newApp.enrichers()); Asserts.assertEqualsIgnoringOrder(newEnricher.tags().getTags(), ImmutableSet.of("foo", newApp)); }
@Test public void testLocationTags() throws Exception { Location origLoc = origManagementContext.getLocationManager().createLocation(LocationSpec.create(MyLocation.class)); origLoc.tags().addTag("foo"); origLoc.tags().addTag(origApp); origApp.start(ImmutableList.of(origLoc)); newApp = rebind(); Location newLoc = newManagementContext.getLocationManager().getLocation(origLoc.getId()); Asserts.assertEqualsIgnoringOrder(newLoc.tags().getTags(), ImmutableSet.of("foo", newApp)); }
public CatalogItemBuilder<CIConcreteType> tag(Object tag) { dto.tags().addTag(tag); return this; }
@Override public void apply(EntityLocal entity) { for (Object tag: tags) entity.tags().addTag(tag); } }
@Test public void testPolicyTags() throws Exception { Policy origPolicy = origApp.policies().add(PolicySpec.create(MyPolicy.class)); origPolicy.tags().addTag("foo"); origPolicy.tags().addTag(origApp); newApp = rebind(); Policy newPolicy = Iterables.getOnlyElement(newApp.policies()); Asserts.assertEqualsIgnoringOrder(newPolicy.tags().getTags(), ImmutableSet.of("foo", newApp)); }