http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4d08310c/core/src/main/java/org/apache/brooklyn/entity/group/DynamicClusterImpl.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/brooklyn/entity/group/DynamicClusterImpl.java b/core/src/main/java/org/apache/brooklyn/entity/group/DynamicClusterImpl.java index e335fd0..3fcebdf 100644 --- a/core/src/main/java/org/apache/brooklyn/entity/group/DynamicClusterImpl.java +++ b/core/src/main/java/org/apache/brooklyn/entity/group/DynamicClusterImpl.java @@ -160,9 +160,9 @@ public class DynamicClusterImpl extends AbstractGroupImpl implements DynamicClus if (config().getRaw(UP_QUORUM_CHECK).isAbsent() && getConfig(INITIAL_SIZE)==0) { // if initial size is 0 then override up check to allow zero if empty config().set(UP_QUORUM_CHECK, QuorumChecks.atLeastOneUnlessEmpty()); - setAttribute(SERVICE_UP, true); + sensors().set(SERVICE_UP, true); } else { - setAttribute(SERVICE_UP, false); + sensors().set(SERVICE_UP, false); } super.initEnrichers(); // override previous enricher so that only members are checked @@ -271,7 +271,7 @@ public class DynamicClusterImpl extends AbstractGroupImpl implements DynamicClus } if (isAvailabilityZoneEnabled()) { - setAttribute(SUB_LOCATIONS, findSubLocations(loc)); + sensors().set(SUB_LOCATIONS, findSubLocations(loc)); } ServiceStateLogic.setExpectedState(this, Lifecycle.STARTING); @@ -294,7 +294,7 @@ public class DynamicClusterImpl extends AbstractGroupImpl implements DynamicClus if (quarantineGroup==null || !Entities.isManaged(quarantineGroup)) { quarantineGroup = addChild(EntitySpec.create(QuarantineGroup.class).displayName("quarantine")); Entities.manage(quarantineGroup); - setAttribute(QUARANTINE_GROUP, quarantineGroup); + sensors().set(QUARANTINE_GROUP, quarantineGroup); } } @@ -351,7 +351,7 @@ public class DynamicClusterImpl extends AbstractGroupImpl implements DynamicClus new Object[] { this, currentSize, initialQuorumSize, initialSize }); } - for (Policy it : getPolicies()) { + for (Policy it : policies()) { it.resume(); } } @@ -397,7 +397,7 @@ public class DynamicClusterImpl extends AbstractGroupImpl implements DynamicClus public void stop() { ServiceStateLogic.setExpectedState(this, Lifecycle.STOPPING); try { - for (Policy it : getPolicies()) { it.suspend(); } + for (Policy it : policies()) { it.suspend(); } // run shrink without mutex to make things stop even if starting, int size = getCurrentSize(); @@ -553,8 +553,8 @@ public class DynamicClusterImpl extends AbstractGroupImpl implements DynamicClus Set<Location> newlyFailed = Sets.difference(failed, oldFailedSubLocations); Set<Location> newlyRecovered = Sets.difference(oldFailedSubLocations, failed); - setAttribute(FAILED_SUB_LOCATIONS, failed); - setAttribute(SUB_LOCATIONS, result); + sensors().set(FAILED_SUB_LOCATIONS, failed); + sensors().set(SUB_LOCATIONS, result); if (newlyFailed.size() > 0) { LOG.warn("Detected probably zone failures for {}: {}", this, newlyFailed); } @@ -712,7 +712,7 @@ public class DynamicClusterImpl extends AbstractGroupImpl implements DynamicClus protected void quarantineFailedNodes(Collection<Entity> failedEntities) { for (Entity entity : failedEntities) { - emit(ENTITY_QUARANTINED, entity); + sensors().emit(ENTITY_QUARANTINED, entity); getQuarantineGroup().addMember(entity); removeMember(entity); } @@ -772,8 +772,8 @@ public class DynamicClusterImpl extends AbstractGroupImpl implements DynamicClus Entity entity = createNode(loc, createFlags); - ((EntityLocal) entity).setAttribute(CLUSTER_MEMBER, true); - ((EntityLocal) entity).setAttribute(CLUSTER, this); + entity.sensors().set(CLUSTER_MEMBER, true); + entity.sensors().set(CLUSTER, this); Entities.manage(entity); addMember(entity);
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4d08310c/core/src/main/java/org/apache/brooklyn/entity/group/DynamicFabricImpl.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/brooklyn/entity/group/DynamicFabricImpl.java b/core/src/main/java/org/apache/brooklyn/entity/group/DynamicFabricImpl.java index 717b0e4..23c05b5 100644 --- a/core/src/main/java/org/apache/brooklyn/entity/group/DynamicFabricImpl.java +++ b/core/src/main/java/org/apache/brooklyn/entity/group/DynamicFabricImpl.java @@ -70,7 +70,7 @@ public class DynamicFabricImpl extends AbstractGroupImpl implements DynamicFabri public void init() { super.init(); - addEnricher(Enrichers.builder() + enrichers().add(Enrichers.builder() .aggregating(Changeable.GROUP_SIZE) .publishing(FABRIC_SIZE) .fromMembers() @@ -78,7 +78,7 @@ public class DynamicFabricImpl extends AbstractGroupImpl implements DynamicFabri .valueToReportIfNoSensors(0) .build()); - setAttribute(SERVICE_UP, false); + sensors().set(SERVICE_UP, false); } protected EntitySpec<?> getMemberSpec() { @@ -162,7 +162,7 @@ public class DynamicFabricImpl extends AbstractGroupImpl implements DynamicFabri waitForTasksOnStart(tasks); ServiceStateLogic.setExpectedState(this, Lifecycle.RUNNING); - setAttribute(SERVICE_UP, true); + sensors().set(SERVICE_UP, true); } catch (Exception e) { ServiceStateLogic.setExpectedState(this, Lifecycle.ON_FIRE); throw Exceptions.propagate(e); @@ -192,7 +192,7 @@ public class DynamicFabricImpl extends AbstractGroupImpl implements DynamicFabri Task<?> invoke = Entities.invokeEffector(this, stoppableChildren, Startable.STOP); if (invoke != null) invoke.get(); ServiceStateLogic.setExpectedState(this, Lifecycle.STOPPED); - setAttribute(SERVICE_UP, false); + sensors().set(SERVICE_UP, false); } catch (Exception e) { ServiceStateLogic.setExpectedState(this, Lifecycle.ON_FIRE); throw Exceptions.propagate(e); http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4d08310c/core/src/main/java/org/apache/brooklyn/entity/group/DynamicGroupImpl.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/brooklyn/entity/group/DynamicGroupImpl.java b/core/src/main/java/org/apache/brooklyn/entity/group/DynamicGroupImpl.java index 61f1437..7f56a03 100644 --- a/core/src/main/java/org/apache/brooklyn/entity/group/DynamicGroupImpl.java +++ b/core/src/main/java/org/apache/brooklyn/entity/group/DynamicGroupImpl.java @@ -61,7 +61,7 @@ public class DynamicGroupImpl extends AbstractGroupImpl implements DynamicGroup @Override public void init() { super.init(); - setAttribute(RUNNING, true); + sensors().set(RUNNING, true); } @Override @@ -93,7 +93,7 @@ public class DynamicGroupImpl extends AbstractGroupImpl implements DynamicGroup @Override public void stop() { - setAttribute(RUNNING, false); + sensors().set(RUNNING, false); if (setChangeListener != null) { ((ManagementContextInternal) getManagementContext()).removeEntitySetListener(setChangeListener); } @@ -107,7 +107,7 @@ public class DynamicGroupImpl extends AbstractGroupImpl implements DynamicGroup if (filter.apply(event)) onEntityChanged(event.getSource()); } }; - subscribe(producer, sensor, listener); + subscriptions().subscribe(producer, sensor, listener); } @Override http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4d08310c/core/src/main/java/org/apache/brooklyn/entity/group/DynamicMultiGroupImpl.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/brooklyn/entity/group/DynamicMultiGroupImpl.java b/core/src/main/java/org/apache/brooklyn/entity/group/DynamicMultiGroupImpl.java index e914bd2..b6f5d55 100644 --- a/core/src/main/java/org/apache/brooklyn/entity/group/DynamicMultiGroupImpl.java +++ b/core/src/main/java/org/apache/brooklyn/entity/group/DynamicMultiGroupImpl.java @@ -92,7 +92,7 @@ public class DynamicMultiGroupImpl extends DynamicGroupImpl implements DynamicMu @Override public void init() { super.init(); - setAttribute(BUCKETS, ImmutableMap.<String, BasicGroup>of()); + sensors().set(BUCKETS, ImmutableMap.<String, BasicGroup>of()); connectScanner(); } @@ -196,7 +196,7 @@ public class DynamicMultiGroupImpl extends DynamicGroupImpl implements DynamicMu } // Save the bucket mappings - setAttribute(BUCKETS, ImmutableMap.copyOf(buckets)); + sensors().set(BUCKETS, ImmutableMap.copyOf(buckets)); } } http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4d08310c/core/src/main/java/org/apache/brooklyn/entity/stock/BasicStartableImpl.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/brooklyn/entity/stock/BasicStartableImpl.java b/core/src/main/java/org/apache/brooklyn/entity/stock/BasicStartableImpl.java index 4906839..b5a8616 100644 --- a/core/src/main/java/org/apache/brooklyn/entity/stock/BasicStartableImpl.java +++ b/core/src/main/java/org/apache/brooklyn/entity/stock/BasicStartableImpl.java @@ -73,7 +73,7 @@ public class BasicStartableImpl extends AbstractEntity implements BasicStartable t.getUnchecked(); } } - setAttribute(Attributes.SERVICE_UP, true); + sensors().set(Attributes.SERVICE_UP, true); ServiceStateLogic.setExpectedState(this, Lifecycle.RUNNING); } catch (Throwable t) { ServiceStateLogic.setExpectedState(this, Lifecycle.ON_FIRE); @@ -84,7 +84,7 @@ public class BasicStartableImpl extends AbstractEntity implements BasicStartable @Override public void stop() { ServiceStateLogic.setExpectedState(this, Lifecycle.STOPPING); - setAttribute(SERVICE_UP, false); + sensors().set(SERVICE_UP, false); try { StartableMethods.stop(this); ServiceStateLogic.setExpectedState(this, Lifecycle.STOPPED); http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4d08310c/core/src/main/java/org/apache/brooklyn/entity/stock/DataEntityImpl.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/brooklyn/entity/stock/DataEntityImpl.java b/core/src/main/java/org/apache/brooklyn/entity/stock/DataEntityImpl.java index 7f10d5b..9ee3b28 100644 --- a/core/src/main/java/org/apache/brooklyn/entity/stock/DataEntityImpl.java +++ b/core/src/main/java/org/apache/brooklyn/entity/stock/DataEntityImpl.java @@ -39,12 +39,12 @@ public class DataEntityImpl extends AbstractEntity implements DataEntity { @Override public void start(Collection<? extends Location> locations) { connectSensors(); - setAttribute(SERVICE_UP, Boolean.TRUE); + sensors().set(SERVICE_UP, Boolean.TRUE); } @Override public void stop() { - setAttribute(SERVICE_UP, Boolean.FALSE); + sensors().set(SERVICE_UP, Boolean.FALSE); disconnectSensors(); } http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4d08310c/core/src/main/java/org/apache/brooklyn/entity/stock/DelegateEntityImpl.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/brooklyn/entity/stock/DelegateEntityImpl.java b/core/src/main/java/org/apache/brooklyn/entity/stock/DelegateEntityImpl.java index 5728635..52b4d6d 100644 --- a/core/src/main/java/org/apache/brooklyn/entity/stock/DelegateEntityImpl.java +++ b/core/src/main/java/org/apache/brooklyn/entity/stock/DelegateEntityImpl.java @@ -36,14 +36,14 @@ public class DelegateEntityImpl extends AbstractEntity implements DelegateEntity Preconditions.checkNotNull(delegate, "delegate"); // Propagate all sensors from the delegate entity - addEnricher(Enrichers.builder() + enrichers().add(Enrichers.builder() .propagatingAll() .from(delegate) .build()); // Publish the entity as an attribute for linking - setAttribute(DELEGATE_ENTITY, delegate); - setAttribute(DELEGATE_ENTITY_LINK, EntityUrl.entityUrl().apply(delegate)); + sensors().set(DELEGATE_ENTITY, delegate); + sensors().set(DELEGATE_ENTITY_LINK, EntityUrl.entityUrl().apply(delegate)); } } http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4d08310c/core/src/main/java/org/apache/brooklyn/feed/windows/WindowsPerformanceCounterFeed.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/brooklyn/feed/windows/WindowsPerformanceCounterFeed.java b/core/src/main/java/org/apache/brooklyn/feed/windows/WindowsPerformanceCounterFeed.java index d34d0a5..07cb8ea 100644 --- a/core/src/main/java/org/apache/brooklyn/feed/windows/WindowsPerformanceCounterFeed.java +++ b/core/src/main/java/org/apache/brooklyn/feed/windows/WindowsPerformanceCounterFeed.java @@ -305,7 +305,7 @@ public class WindowsPerformanceCounterFeed extends AbstractFeed { AttributeSensor<Object> attribute = (AttributeSensor<Object>) Sensors.newSensor(clazz, config.getSensor().getName(), config.getDescription()); try { Object value = TypeCoercions.coerce(rawValue, TypeToken.of(clazz)); - entity.setAttribute(attribute, value); + entity.sensors().set(attribute, value); } catch (Exception e) { Exceptions.propagateIfFatal(e); if (failedAttributes.add(attribute)) { @@ -324,7 +324,7 @@ public class WindowsPerformanceCounterFeed extends AbstractFeed { for (WindowsPerformanceCounterPollConfig<?> config : polls) { Class<?> clazz = config.getSensor().getType(); AttributeSensor<?> attribute = Sensors.newSensor(clazz, config.getSensor().getName(), config.getDescription()); - entity.setAttribute(attribute, null); + entity.sensors().set(attribute, null); } } @@ -333,7 +333,7 @@ public class WindowsPerformanceCounterFeed extends AbstractFeed { log.error("Detected exception while retrieving Windows Performance Counters from entity " + entity.getDisplayName(), exception); for (WindowsPerformanceCounterPollConfig<?> config : polls) { - entity.setAttribute(Sensors.newSensor(config.getSensor().getClass(), config.getPerformanceCounterName(), config.getDescription()), null); + entity.sensors().set(Sensors.newSensor(config.getSensor().getClass(), config.getPerformanceCounterName(), config.getDescription()), null); } } http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4d08310c/core/src/main/java/org/apache/brooklyn/location/winrm/AdvertiseWinrmLoginPolicy.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/brooklyn/location/winrm/AdvertiseWinrmLoginPolicy.java b/core/src/main/java/org/apache/brooklyn/location/winrm/AdvertiseWinrmLoginPolicy.java index 0945407..5d3a0c8 100644 --- a/core/src/main/java/org/apache/brooklyn/location/winrm/AdvertiseWinrmLoginPolicy.java +++ b/core/src/main/java/org/apache/brooklyn/location/winrm/AdvertiseWinrmLoginPolicy.java @@ -53,7 +53,7 @@ public class AdvertiseWinrmLoginPolicy extends AbstractPolicy implements SensorE public void setEntity(EntityLocal entity) { super.setEntity(entity); - subscribe(entity, AbstractEntity.LOCATION_ADDED, this); + subscriptions().subscribe(entity, AbstractEntity.LOCATION_ADDED, this); } @Override @@ -75,6 +75,6 @@ public class AdvertiseWinrmLoginPolicy extends AbstractPolicy implements SensorE LOG.info("Advertising user "+user+" @ "+hostname+":"+port); - ((EntityLocal)entity).setAttribute(VM_USER_CREDENTIALS, creds); + ((EntityLocal)entity).sensors().set(VM_USER_CREDENTIALS, creds); } } http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4d08310c/core/src/main/java/org/apache/brooklyn/util/core/flags/FlagUtils.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/brooklyn/util/core/flags/FlagUtils.java b/core/src/main/java/org/apache/brooklyn/util/core/flags/FlagUtils.java index 63cb13a..f59814e 100644 --- a/core/src/main/java/org/apache/brooklyn/util/core/flags/FlagUtils.java +++ b/core/src/main/java/org/apache/brooklyn/util/core/flags/FlagUtils.java @@ -392,7 +392,7 @@ public class FlagUtils { @SuppressWarnings({ "unchecked", "rawtypes" }) public static void setConfig(Object objectOfField, ConfigKey<?> key, Object value, SetFromFlag optionalAnnotation) { if (objectOfField instanceof Configurable) { - ((Configurable)objectOfField).setConfig((ConfigKey)key, value); + ((Configurable)objectOfField).config().set((ConfigKey)key, value); return; } else { if (optionalAnnotation==null) { http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4d08310c/core/src/test/java/org/apache/brooklyn/core/config/MapConfigKeyAndFriendsMoreTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/brooklyn/core/config/MapConfigKeyAndFriendsMoreTest.java b/core/src/test/java/org/apache/brooklyn/core/config/MapConfigKeyAndFriendsMoreTest.java index d217dd5..3e5d1e1 100644 --- a/core/src/test/java/org/apache/brooklyn/core/config/MapConfigKeyAndFriendsMoreTest.java +++ b/core/src/test/java/org/apache/brooklyn/core/config/MapConfigKeyAndFriendsMoreTest.java @@ -64,33 +64,33 @@ public class MapConfigKeyAndFriendsMoreTest extends BrooklynAppUnitTestSupport { } public void testMapModUsage() throws Exception { - entity.setConfig(TestEntity.CONF_MAP_THING_OBJECT, MapModifications.add(MutableMap.<String,Object>of("a", 1))); + entity.config().set(TestEntity.CONF_MAP_THING_OBJECT, MapModifications.add(MutableMap.<String,Object>of("a", 1))); log.info("Map-Mod: "+MutableMap.copyOf(entity.getConfigMap().asMapWithStringKeys())); Assert.assertEquals(entity.getConfig(TestEntity.CONF_MAP_THING_OBJECT), ImmutableMap.<String,Object>of("a", 1)); } public void testMapSubkeyUsage() throws Exception { - entity.setConfig(TestEntity.CONF_MAP_THING_OBJECT.subKey("a"), 1); + entity.config().set(TestEntity.CONF_MAP_THING_OBJECT.subKey("a"), 1); log.info("Map-SubKey: "+MutableMap.copyOf(entity.getConfigMap().asMapWithStringKeys())); Assert.assertEquals(entity.getConfig(TestEntity.CONF_MAP_THING_OBJECT), ImmutableMap.<String,Object>of("a", 1)); } public void testMapDirectUsage() throws Exception { - entity.setConfig(ConfigKeys.newConfigKey(Object.class, TestEntity.CONF_MAP_THING_OBJECT.getName()), ImmutableMap.<String,Object>of("a", 1)); + entity.config().set(ConfigKeys.newConfigKey(Object.class, TestEntity.CONF_MAP_THING_OBJECT.getName()), ImmutableMap.<String,Object>of("a", 1)); log.info("Map-Direct: "+MutableMap.copyOf(entity.getConfigMap().asMapWithStringKeys())); Assert.assertEquals(entity.getConfig(TestEntity.CONF_MAP_THING_OBJECT), ImmutableMap.<String,Object>of("a", 1)); } public void testMapDotExtensionUsage() throws Exception { - entity.setConfig(ConfigKeys.newConfigKey(Object.class, TestEntity.CONF_MAP_THING_OBJECT.getName()+".a"), 1); + entity.config().set(ConfigKeys.newConfigKey(Object.class, TestEntity.CONF_MAP_THING_OBJECT.getName()+".a"), 1); log.info("Map-DotExt: "+MutableMap.copyOf(entity.getConfigMap().asMapWithStringKeys())); Assert.assertEquals(entity.getConfig(TestEntity.CONF_MAP_THING_OBJECT), ImmutableMap.<String,Object>of("a", 1)); } public void testMapManyWays() throws Exception { - entity.setConfig(ConfigKeys.newConfigKey(Object.class, TestEntity.CONF_MAP_THING_OBJECT.getName()), ImmutableMap.<String,Object>of("map", 1, "subkey", 0, "dotext", 0)); - entity.setConfig(ConfigKeys.newConfigKey(Object.class, TestEntity.CONF_MAP_THING_OBJECT.getName()+".dotext"), 1); - entity.setConfig(TestEntity.CONF_MAP_THING_OBJECT.subKey("subkey"), 1); + entity.config().set(ConfigKeys.newConfigKey(Object.class, TestEntity.CONF_MAP_THING_OBJECT.getName()), ImmutableMap.<String,Object>of("map", 1, "subkey", 0, "dotext", 0)); + entity.config().set(ConfigKeys.newConfigKey(Object.class, TestEntity.CONF_MAP_THING_OBJECT.getName()+".dotext"), 1); + entity.config().set(TestEntity.CONF_MAP_THING_OBJECT.subKey("subkey"), 1); log.info("Map-ManyWays: "+MutableMap.copyOf(entity.getConfigMap().asMapWithStringKeys())); Assert.assertEquals(entity.getConfig(TestEntity.CONF_MAP_THING_OBJECT), ImmutableMap.<String,Object>of("map", 1, "subkey", 1, "dotext", 1)); @@ -101,40 +101,40 @@ public class MapConfigKeyAndFriendsMoreTest extends BrooklynAppUnitTestSupport { // ensure it is null before we pass something in, and passing an empty collection makes it be empty log.info("Map-Empty-1: "+MutableMap.copyOf(entity.getConfigMap().asMapWithStringKeys())); Assert.assertEquals(entity.getConfig(TestEntity.CONF_MAP_THING), null); - entity.setConfig((MapConfigKey)TestEntity.CONF_MAP_THING, MutableMap.of()); + entity.config().set((MapConfigKey)TestEntity.CONF_MAP_THING, MutableMap.of()); log.info("Map-Empty-2: "+MutableMap.copyOf(entity.getConfigMap().asMapWithStringKeys())); Assert.assertEquals(entity.getConfig(TestEntity.CONF_MAP_THING), ImmutableMap.of()); } public void testSetModUsage() throws Exception { - entity.setConfig(TestEntity.CONF_SET_THING, SetModifications.addItem("x")); + entity.config().set(TestEntity.CONF_SET_THING, SetModifications.addItem("x")); log.info("Set-Mod: "+MutableMap.copyOf(entity.getConfigMap().asMapWithStringKeys())); Assert.assertEquals(entity.getConfig(TestEntity.CONF_SET_THING), ImmutableSet.of("x")); } public void testSetSubKeyUsage() throws Exception { - entity.setConfig(TestEntity.CONF_SET_THING.subKey(), "x"); + entity.config().set(TestEntity.CONF_SET_THING.subKey(), "x"); log.info("Set-SubKey: "+MutableMap.copyOf(entity.getConfigMap().asMapWithStringKeys())); Assert.assertEquals(entity.getConfig(TestEntity.CONF_SET_THING), ImmutableSet.of("x")); } public void testSetPutDirectUsage() throws Exception { - entity.setConfig(ConfigKeys.newConfigKey(Object.class, TestEntity.CONF_SET_THING.getName()), ImmutableSet.of("x")); + entity.config().set(ConfigKeys.newConfigKey(Object.class, TestEntity.CONF_SET_THING.getName()), ImmutableSet.of("x")); log.info("Set-Direct: "+MutableMap.copyOf(entity.getConfigMap().asMapWithStringKeys())); Assert.assertEquals(entity.getConfig(TestEntity.CONF_SET_THING), ImmutableSet.of("x")); } public void testSetDotExtensionUsage() throws Exception { - entity.setConfig(ConfigKeys.newConfigKey(Object.class, TestEntity.CONF_SET_THING.getName()+".a"), "x"); + entity.config().set(ConfigKeys.newConfigKey(Object.class, TestEntity.CONF_SET_THING.getName()+".a"), "x"); log.info("Set-DotExt: "+MutableMap.copyOf(entity.getConfigMap().asMapWithStringKeys())); Assert.assertEquals(entity.getConfig(TestEntity.CONF_SET_THING), ImmutableSet.of("x")); } public void testSetManyWays() throws Exception { - entity.setConfig(ConfigKeys.newConfigKey(Object.class, TestEntity.CONF_SET_THING.getName()), ImmutableSet.of("directX")); - entity.setConfig(ConfigKeys.newConfigKey(Object.class, TestEntity.CONF_SET_THING.getName()+".dotext"), "dotextX"); - entity.setConfig(TestEntity.CONF_SET_THING.subKey(), "subkeyX"); + entity.config().set(ConfigKeys.newConfigKey(Object.class, TestEntity.CONF_SET_THING.getName()), ImmutableSet.of("directX")); + entity.config().set(ConfigKeys.newConfigKey(Object.class, TestEntity.CONF_SET_THING.getName()+".dotext"), "dotextX"); + entity.config().set(TestEntity.CONF_SET_THING.subKey(), "subkeyX"); log.info("Set-ManyWays: "+MutableMap.copyOf(entity.getConfigMap().asMapWithStringKeys())); Assert.assertEquals(entity.getConfig(TestEntity.CONF_SET_THING), ImmutableSet.of("directX", "subkeyX", "dotextX")); @@ -144,13 +144,13 @@ public class MapConfigKeyAndFriendsMoreTest extends BrooklynAppUnitTestSupport { // passing a collection to the RHS of setConfig can be ambiguous, // esp if there are already values set, but attempt to act sensibly // (logging warnings if the set is not empty) - entity.setConfig(TestEntity.CONF_SET_OBJ_THING, SetModifications.addItem("w")); - entity.setConfig(TestEntity.CONF_SET_OBJ_THING, MutableSet.of("x")); - entity.setConfig(TestEntity.CONF_SET_OBJ_THING, MutableSet.of("y")); - entity.setConfig(TestEntity.CONF_SET_OBJ_THING, MutableSet.of("a", "b")); - entity.setConfig(TestEntity.CONF_SET_OBJ_THING, SetModifications.addItem("z")); - entity.setConfig(TestEntity.CONF_SET_OBJ_THING, SetModifications.addItem(MutableSet.of("c", "d"))); - entity.setConfig(TestEntity.CONF_SET_OBJ_THING, MutableSet.of(MutableSet.of("e", "f"))); + entity.config().set(TestEntity.CONF_SET_OBJ_THING, SetModifications.addItem("w")); + entity.config().set(TestEntity.CONF_SET_OBJ_THING, MutableSet.of("x")); + entity.config().set(TestEntity.CONF_SET_OBJ_THING, MutableSet.of("y")); + entity.config().set(TestEntity.CONF_SET_OBJ_THING, MutableSet.of("a", "b")); + entity.config().set(TestEntity.CONF_SET_OBJ_THING, SetModifications.addItem("z")); + entity.config().set(TestEntity.CONF_SET_OBJ_THING, SetModifications.addItem(MutableSet.of("c", "d"))); + entity.config().set(TestEntity.CONF_SET_OBJ_THING, MutableSet.of(MutableSet.of("e", "f"))); log.info("Set-Coll: "+MutableMap.copyOf(entity.getConfigMap().asMapWithStringKeys())); Assert.assertEquals(entity.getConfig(TestEntity.CONF_SET_OBJ_THING), ImmutableSet.of( "a", "b", "w", "x", "y", "z", ImmutableSet.of("c", "d"), ImmutableSet.of("e", "f"))); @@ -161,34 +161,34 @@ public class MapConfigKeyAndFriendsMoreTest extends BrooklynAppUnitTestSupport { // ensure it is null before we pass something in, and passing an empty collection makes it be empty log.info("Set-Empty-1: "+MutableMap.copyOf(entity.getConfigMap().asMapWithStringKeys())); Assert.assertEquals(entity.getConfig(TestEntity.CONF_SET_THING), null); - entity.setConfig((SetConfigKey)TestEntity.CONF_SET_THING, MutableSet.of()); + entity.config().set((SetConfigKey)TestEntity.CONF_SET_THING, MutableSet.of()); log.info("Set-Empty-2: "+MutableMap.copyOf(entity.getConfigMap().asMapWithStringKeys())); Assert.assertEquals(entity.getConfig(TestEntity.CONF_SET_THING), ImmutableSet.of()); } public void testListModUsage() throws Exception { - entity.setConfig(TestEntity.CONF_LIST_THING, ListModifications.add("x", "x")); + entity.config().set(TestEntity.CONF_LIST_THING, ListModifications.add("x", "x")); log.info("List-Mod: "+MutableMap.copyOf(entity.getConfigMap().asMapWithStringKeys())); Assert.assertEquals(entity.getConfig(TestEntity.CONF_LIST_THING), ImmutableList.of("x", "x")); } public void testListSubKeyUsage() throws Exception { - entity.setConfig(TestEntity.CONF_LIST_THING.subKey(), "x"); - entity.setConfig(TestEntity.CONF_LIST_THING.subKey(), "x"); + entity.config().set(TestEntity.CONF_LIST_THING.subKey(), "x"); + entity.config().set(TestEntity.CONF_LIST_THING.subKey(), "x"); log.info("List-SubKey: "+MutableMap.copyOf(entity.getConfigMap().asMapWithStringKeys())); Assert.assertEquals(entity.getConfig(TestEntity.CONF_LIST_THING), ImmutableList.of("x", "x")); } public void testListPutDirectUsage() throws Exception { - entity.setConfig(ConfigKeys.newConfigKey(Object.class, TestEntity.CONF_LIST_THING.getName()), ImmutableList.of("x", "x")); + entity.config().set(ConfigKeys.newConfigKey(Object.class, TestEntity.CONF_LIST_THING.getName()), ImmutableList.of("x", "x")); log.info("List-Direct: "+MutableMap.copyOf(entity.getConfigMap().asMapWithStringKeys())); Assert.assertEquals(entity.getConfig(TestEntity.CONF_LIST_THING), ImmutableList.of("x", "x")); } public void testListDotExtensionUsage() throws Exception { - entity.setConfig(ConfigKeys.newConfigKey(Object.class, TestEntity.CONF_LIST_THING.getName()+".a"), "x"); - entity.setConfig(ConfigKeys.newConfigKey(Object.class, TestEntity.CONF_LIST_THING.getName()+".b"), "x"); + entity.config().set(ConfigKeys.newConfigKey(Object.class, TestEntity.CONF_LIST_THING.getName()+".a"), "x"); + entity.config().set(ConfigKeys.newConfigKey(Object.class, TestEntity.CONF_LIST_THING.getName()+".b"), "x"); log.info("List-DotExt: "+MutableMap.copyOf(entity.getConfigMap().asMapWithStringKeys())); Assert.assertEquals(entity.getConfig(TestEntity.CONF_LIST_THING), ImmutableList.of("x", "x")); } @@ -198,43 +198,43 @@ public class MapConfigKeyAndFriendsMoreTest extends BrooklynAppUnitTestSupport { @Test(enabled=false) public void testListModUsageMultiValues() throws Exception { - entity.setConfig(TestEntity.CONF_LIST_THING, ListModifications.add("x", "w", "x")); + entity.config().set(TestEntity.CONF_LIST_THING, ListModifications.add("x", "w", "x")); log.info("List-Mod: "+MutableMap.copyOf(entity.getConfigMap().asMapWithStringKeys())); Assert.assertEquals(entity.getConfig(TestEntity.CONF_LIST_THING), ImmutableList.of("x", "w", "x")); } @Test(enabled=false) public void testListSubKeyUsageMultiValues() throws Exception { - entity.setConfig(TestEntity.CONF_LIST_THING.subKey(), "x"); - entity.setConfig(TestEntity.CONF_LIST_THING.subKey(), "w"); - entity.setConfig(TestEntity.CONF_LIST_THING.subKey(), "x"); + entity.config().set(TestEntity.CONF_LIST_THING.subKey(), "x"); + entity.config().set(TestEntity.CONF_LIST_THING.subKey(), "w"); + entity.config().set(TestEntity.CONF_LIST_THING.subKey(), "x"); log.info("List-SubKey: "+MutableMap.copyOf(entity.getConfigMap().asMapWithStringKeys())); Assert.assertEquals(entity.getConfig(TestEntity.CONF_LIST_THING), ImmutableList.of("x", "w", "x")); } @Test(enabled=false) public void testListPutDirectUsageMultiValues() throws Exception { - entity.setConfig(ConfigKeys.newConfigKey(Object.class, TestEntity.CONF_LIST_THING.getName()), ImmutableList.of("x", "w", "x")); + entity.config().set(ConfigKeys.newConfigKey(Object.class, TestEntity.CONF_LIST_THING.getName()), ImmutableList.of("x", "w", "x")); log.info("List-Direct: "+MutableMap.copyOf(entity.getConfigMap().asMapWithStringKeys())); Assert.assertEquals(entity.getConfig(TestEntity.CONF_LIST_THING), ImmutableList.of("x", "w", "x")); } @Test(enabled=false) public void testListDotExtensionUsageMultiValues() throws Exception { - entity.setConfig(ConfigKeys.newConfigKey(Object.class, TestEntity.CONF_LIST_THING.getName()+".a"), "x"); - entity.setConfig(ConfigKeys.newConfigKey(Object.class, TestEntity.CONF_LIST_THING.getName()+".c"), "w"); - entity.setConfig(ConfigKeys.newConfigKey(Object.class, TestEntity.CONF_LIST_THING.getName()+".b"), "x"); + entity.config().set(ConfigKeys.newConfigKey(Object.class, TestEntity.CONF_LIST_THING.getName()+".a"), "x"); + entity.config().set(ConfigKeys.newConfigKey(Object.class, TestEntity.CONF_LIST_THING.getName()+".c"), "w"); + entity.config().set(ConfigKeys.newConfigKey(Object.class, TestEntity.CONF_LIST_THING.getName()+".b"), "x"); log.info("List-DotExt: "+MutableMap.copyOf(entity.getConfigMap().asMapWithStringKeys())); Assert.assertEquals(entity.getConfig(TestEntity.CONF_LIST_THING), ImmutableList.of("x", "w", "x")); } @Test(enabled=false) public void testListManyWaysMultiValues() throws Exception { - entity.setConfig(ConfigKeys.newConfigKey(Object.class, TestEntity.CONF_LIST_THING.getName()), ImmutableList.of("x1", "w1")); - entity.setConfig(ConfigKeys.newConfigKey(Object.class, TestEntity.CONF_LIST_THING.getName()+".dotext"), "x2"); - entity.setConfig(ConfigKeys.newConfigKey(Object.class, TestEntity.CONF_LIST_THING.getName()+".dotext"), "w2"); - entity.setConfig(TestEntity.CONF_LIST_THING.subKey(), "x3"); - entity.setConfig(TestEntity.CONF_LIST_THING.subKey(), "w3"); + entity.config().set(ConfigKeys.newConfigKey(Object.class, TestEntity.CONF_LIST_THING.getName()), ImmutableList.of("x1", "w1")); + entity.config().set(ConfigKeys.newConfigKey(Object.class, TestEntity.CONF_LIST_THING.getName()+".dotext"), "x2"); + entity.config().set(ConfigKeys.newConfigKey(Object.class, TestEntity.CONF_LIST_THING.getName()+".dotext"), "w2"); + entity.config().set(TestEntity.CONF_LIST_THING.subKey(), "x3"); + entity.config().set(TestEntity.CONF_LIST_THING.subKey(), "w3"); log.info("List-ManyWays: "+MutableMap.copyOf(entity.getConfigMap().asMapWithStringKeys())); Assert.assertEquals(entity.getConfig(TestEntity.CONF_LIST_THING), ImmutableList.of("x1", "w1", "x2", "x2", "x3", "w3")); @@ -244,13 +244,13 @@ public class MapConfigKeyAndFriendsMoreTest extends BrooklynAppUnitTestSupport { // passing a collection to the RHS of setConfig can be ambiguous, // esp if there are already values set, but attempt to act sensibly // (logging warnings if the set is not empty) - entity.setConfig(TestEntity.CONF_LIST_OBJ_THING, ListModifications.addItem("w")); - entity.setConfig(TestEntity.CONF_LIST_OBJ_THING, MutableList.of("x")); - entity.setConfig(TestEntity.CONF_LIST_OBJ_THING, MutableList.of("y")); - entity.setConfig(TestEntity.CONF_LIST_OBJ_THING, MutableList.of("a", "b")); - entity.setConfig(TestEntity.CONF_LIST_OBJ_THING, ListModifications.addItem("z")); - entity.setConfig(TestEntity.CONF_LIST_OBJ_THING, ListModifications.addItem(MutableList.of("c", "d"))); - entity.setConfig(TestEntity.CONF_LIST_OBJ_THING, MutableList.of(MutableList.of("e", "f"))); + entity.config().set(TestEntity.CONF_LIST_OBJ_THING, ListModifications.addItem("w")); + entity.config().set(TestEntity.CONF_LIST_OBJ_THING, MutableList.of("x")); + entity.config().set(TestEntity.CONF_LIST_OBJ_THING, MutableList.of("y")); + entity.config().set(TestEntity.CONF_LIST_OBJ_THING, MutableList.of("a", "b")); + entity.config().set(TestEntity.CONF_LIST_OBJ_THING, ListModifications.addItem("z")); + entity.config().set(TestEntity.CONF_LIST_OBJ_THING, ListModifications.addItem(MutableList.of("c", "d"))); + entity.config().set(TestEntity.CONF_LIST_OBJ_THING, MutableList.of(MutableList.of("e", "f"))); log.info("List-Coll: "+MutableMap.copyOf(entity.getConfigMap().asMapWithStringKeys())); List<? extends Object> list = entity.getConfig(TestEntity.CONF_LIST_OBJ_THING); Assert.assertEquals(list.size(), 8, "list is: "+list); @@ -262,7 +262,7 @@ public class MapConfigKeyAndFriendsMoreTest extends BrooklynAppUnitTestSupport { // ensure it is null before we pass something in, and passing an empty collection makes it be empty log.info("List-Empty-1: "+MutableMap.copyOf(entity.getConfigMap().asMapWithStringKeys())); Assert.assertEquals(entity.getConfig(TestEntity.CONF_LIST_THING), null); - entity.setConfig((ListConfigKey)TestEntity.CONF_LIST_THING, MutableList.of()); + entity.config().set((ListConfigKey)TestEntity.CONF_LIST_THING, MutableList.of()); log.info("List-Empty-2: "+MutableMap.copyOf(entity.getConfigMap().asMapWithStringKeys())); Assert.assertEquals(entity.getConfig(TestEntity.CONF_LIST_THING), ImmutableList.of()); } http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4d08310c/core/src/test/java/org/apache/brooklyn/core/config/MapListAndOtherStructuredConfigKeyTest.groovy ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/brooklyn/core/config/MapListAndOtherStructuredConfigKeyTest.groovy b/core/src/test/java/org/apache/brooklyn/core/config/MapListAndOtherStructuredConfigKeyTest.groovy index 8516df5..0b5e9a3 100644 --- a/core/src/test/java/org/apache/brooklyn/core/config/MapListAndOtherStructuredConfigKeyTest.groovy +++ b/core/src/test/java/org/apache/brooklyn/core/config/MapListAndOtherStructuredConfigKeyTest.groovy @@ -64,8 +64,8 @@ public class MapListAndOtherStructuredConfigKeyTest { @Test public void testMapConfigKeyCanStoreAndRetrieveVals() throws Exception { - entity.setConfig(TestEntity.CONF_MAP_THING.subKey("akey"), "aval") - entity.setConfig(TestEntity.CONF_MAP_THING.subKey("bkey"), "bval") + entity.config().set(TestEntity.CONF_MAP_THING.subKey("akey"), "aval") + entity.config().set(TestEntity.CONF_MAP_THING.subKey("bkey"), "bval") app.start(locs) assertEquals(entity.getConfig(TestEntity.CONF_MAP_THING), [akey:"aval",bkey:"bval"]) assertEquals(entity.getConfig(TestEntity.CONF_MAP_THING.subKey("akey")), "aval") @@ -74,8 +74,8 @@ public class MapListAndOtherStructuredConfigKeyTest { @Test public void testMapConfigKeyCanStoreAndRetrieveFutureValsPutByKeys() throws Exception { String bval = "bval-too-early" - entity.setConfig(TestEntity.CONF_MAP_THING.subKey("akey"), DependentConfiguration.whenDone( {return "aval"} as Callable)) - entity.setConfig(TestEntity.CONF_MAP_THING.subKey("bkey"), DependentConfiguration.whenDone( {return bval} as Callable)) + entity.config().set(TestEntity.CONF_MAP_THING.subKey("akey"), DependentConfiguration.whenDone( {return "aval"} as Callable)) + entity.config().set(TestEntity.CONF_MAP_THING.subKey("bkey"), DependentConfiguration.whenDone( {return bval} as Callable)) app.start(locs) bval = "bval"; @@ -85,7 +85,7 @@ public class MapListAndOtherStructuredConfigKeyTest { @Test public void testMapConfigKeyCanStoreAndRetrieveFutureValsPutAsMap() throws Exception { String bval = "bval-too-early" - entity.setConfig(TestEntity.CONF_MAP_THING, MutableMap.of("akey", DependentConfiguration.whenDone( {return "aval"} as Callable), + entity.config().set(TestEntity.CONF_MAP_THING, MutableMap.of("akey", DependentConfiguration.whenDone( {return "aval"} as Callable), "bkey", DependentConfiguration.whenDone( {return bval} as Callable))); app.start(locs) bval = "bval"; @@ -98,7 +98,7 @@ public class MapListAndOtherStructuredConfigKeyTest { final AtomicReference<String> bval = new AtomicReference<String>("bval-too-early"); final AtomicInteger bref = new AtomicInteger(0); - entity.setConfig(ConfigKeys.newConfigKey(Object.class, TestEntity.CONF_MAP_THING.getName()), + entity.config().set(ConfigKeys.newConfigKey(Object.class, TestEntity.CONF_MAP_THING.getName()), MutableMap.of("akey", DependentConfiguration.whenDone( {return "aval"} as Callable), "bkey", {bref.incrementAndGet(); return bval.get();} as DeferredSupplier)); app.start(locs) @@ -121,7 +121,7 @@ public class MapListAndOtherStructuredConfigKeyTest { @Test public void testResolvesMapKeysOnGetNotPut() throws Exception { - entity.setConfig(TestEntity.CONF_MAP_THING, + entity.config().set(TestEntity.CONF_MAP_THING, MutableMap.of({return "akey";} as DeferredSupplier, {return "aval";} as DeferredSupplier)); app.start(locs) @@ -136,7 +136,7 @@ public class MapListAndOtherStructuredConfigKeyTest { Map v1 = [a:1, b:"bb"] //it only allows strings try { - entity.setConfig(TestEntity.CONF_MAP_THING.subKey("akey"), v1) + entity.config().set(TestEntity.CONF_MAP_THING.subKey("akey"), v1) fail(); } catch (Exception e) { ClassCastException cce = Exceptions.getFirstThrowableOfType(e, ClassCastException.class); @@ -148,7 +148,7 @@ public class MapListAndOtherStructuredConfigKeyTest { @Test public void testConfigKeyCanStoreAndRetrieveMaps() throws Exception { Map v1 = [a:1, b:"bb"] - entity.setConfig(TestEntity.CONF_MAP_PLAIN, v1) + entity.config().set(TestEntity.CONF_MAP_PLAIN, v1) app.start(locs) assertEquals(entity.getConfig(TestEntity.CONF_MAP_PLAIN), v1) } @@ -170,8 +170,8 @@ public class MapListAndOtherStructuredConfigKeyTest { @Test public void testSetConfigKeyCanStoreAndRetrieveVals() throws Exception { - entity.setConfig(TestEntity.CONF_SET_THING.subKey(), "aval") - entity.setConfig(TestEntity.CONF_SET_THING.subKey(), "bval") + entity.config().set(TestEntity.CONF_SET_THING.subKey(), "aval") + entity.config().set(TestEntity.CONF_SET_THING.subKey(), "bval") app.start(locs) assertEquals(entity.getConfig(TestEntity.CONF_SET_THING), ImmutableSet.of("aval","bval")) @@ -179,8 +179,8 @@ public class MapListAndOtherStructuredConfigKeyTest { @Test public void testSetConfigKeyCanStoreAndRetrieveFutureVals() throws Exception { - entity.setConfig(TestEntity.CONF_SET_THING.subKey(), DependentConfiguration.whenDone( {return "aval"} as Callable)) - entity.setConfig(TestEntity.CONF_SET_THING.subKey(), DependentConfiguration.whenDone( {return "bval"} as Callable)) + entity.config().set(TestEntity.CONF_SET_THING.subKey(), DependentConfiguration.whenDone( {return "aval"} as Callable)) + entity.config().set(TestEntity.CONF_SET_THING.subKey(), DependentConfiguration.whenDone( {return "bval"} as Callable)) app.start(locs) assertEquals(entity.getConfig(TestEntity.CONF_SET_THING), ImmutableSet.of("aval","bval")) @@ -188,48 +188,48 @@ public class MapListAndOtherStructuredConfigKeyTest { @Test public void testSetConfigKeyAddDirect() throws Exception { - entity.setConfig(TestEntity.CONF_SET_THING.subKey(), "aval") - entity.setConfig(TestEntity.CONF_SET_THING, "bval") + entity.config().set(TestEntity.CONF_SET_THING.subKey(), "aval") + entity.config().set(TestEntity.CONF_SET_THING, "bval") assertEquals(entity.getConfig(TestEntity.CONF_SET_THING), ImmutableSet.of("aval","bval")) } @Test public void testSetConfigKeyClear() throws Exception { - entity.setConfig(TestEntity.CONF_SET_THING.subKey(), "aval") - entity.setConfig(TestEntity.CONF_SET_THING, SetModifications.clearing()) + entity.config().set(TestEntity.CONF_SET_THING.subKey(), "aval") + entity.config().set(TestEntity.CONF_SET_THING, SetModifications.clearing()) // for now defaults to null, but empty list might be better? or whatever the default is? assertEquals(entity.getConfig(TestEntity.CONF_SET_THING), null) } @Test public void testSetConfigKeyAddMod() throws Exception { - entity.setConfig(TestEntity.CONF_SET_THING.subKey(), "aval") - entity.setConfig(TestEntity.CONF_SET_THING, SetModifications.add("bval", "cval")) + entity.config().set(TestEntity.CONF_SET_THING.subKey(), "aval") + entity.config().set(TestEntity.CONF_SET_THING, SetModifications.add("bval", "cval")) assertEquals(entity.getConfig(TestEntity.CONF_SET_THING), ImmutableSet.of("aval","bval","cval")) } @Test public void testSetConfigKeyAddAllMod() throws Exception { - entity.setConfig(TestEntity.CONF_SET_THING.subKey(), "aval") - entity.setConfig(TestEntity.CONF_SET_THING, SetModifications.addAll(["bval", "cval"])) + entity.config().set(TestEntity.CONF_SET_THING.subKey(), "aval") + entity.config().set(TestEntity.CONF_SET_THING, SetModifications.addAll(["bval", "cval"])) assertEquals(entity.getConfig(TestEntity.CONF_SET_THING), ImmutableSet.of("aval","bval","cval")) } @Test public void testSetConfigKeyAddItemMod() throws Exception { - entity.setConfig(TestEntity.CONF_SET_THING.subKey(), "aval") - entity.setConfig(TestEntity.CONF_SET_THING, SetModifications.addItem(["bval", "cval"])) + entity.config().set(TestEntity.CONF_SET_THING.subKey(), "aval") + entity.config().set(TestEntity.CONF_SET_THING, SetModifications.addItem(["bval", "cval"])) assertEquals(entity.getConfig(TestEntity.CONF_SET_THING), ImmutableSet.of("aval",["bval","cval"])) } @Test public void testSetConfigKeyListMod() throws Exception { - entity.setConfig(TestEntity.CONF_SET_THING.subKey(), "aval") - entity.setConfig(TestEntity.CONF_SET_THING, SetModifications.set(["bval", "cval"])) + entity.config().set(TestEntity.CONF_SET_THING.subKey(), "aval") + entity.config().set(TestEntity.CONF_SET_THING, SetModifications.set(["bval", "cval"])) assertEquals(entity.getConfig(TestEntity.CONF_SET_THING), ImmutableSet.of("bval","cval")) } @Test // ListConfigKey deprecated, as order no longer guaranteed public void testListConfigKeyCanStoreAndRetrieveVals() throws Exception { - entity.setConfig(TestEntity.CONF_LIST_THING.subKey(), "aval") - entity.setConfig(TestEntity.CONF_LIST_THING.subKey(), "bval") + entity.config().set(TestEntity.CONF_LIST_THING.subKey(), "aval") + entity.config().set(TestEntity.CONF_LIST_THING.subKey(), "bval") app.start(locs) //assertEquals(entity.getConfig(TestEntity.CONF_LIST_THING), ["aval","bval"]) @@ -238,8 +238,8 @@ public class MapListAndOtherStructuredConfigKeyTest { @Test // ListConfigKey deprecated, as order no longer guaranteed public void testListConfigKeyCanStoreAndRetrieveFutureVals() throws Exception { - entity.setConfig(TestEntity.CONF_LIST_THING.subKey(), DependentConfiguration.whenDone( {return "aval"} as Callable)) - entity.setConfig(TestEntity.CONF_LIST_THING.subKey(), DependentConfiguration.whenDone( {return "bval"} as Callable)) + entity.config().set(TestEntity.CONF_LIST_THING.subKey(), DependentConfiguration.whenDone( {return "aval"} as Callable)) + entity.config().set(TestEntity.CONF_LIST_THING.subKey(), DependentConfiguration.whenDone( {return "bval"} as Callable)) app.start(locs) //assertEquals(entity.getConfig(TestEntity.CONF_LIST_THING), ["aval","bval"]) @@ -248,84 +248,84 @@ public class MapListAndOtherStructuredConfigKeyTest { @Test // ListConfigKey deprecated, as order no longer guaranteed public void testListConfigKeyAddDirect() throws Exception { - entity.setConfig(TestEntity.CONF_LIST_THING.subKey(), "aval") - entity.setConfig(TestEntity.CONF_LIST_THING, "bval") + entity.config().set(TestEntity.CONF_LIST_THING.subKey(), "aval") + entity.config().set(TestEntity.CONF_LIST_THING, "bval") //assertEquals(entity.getConfig(TestEntity.CONF_LIST_THING), ["aval","bval"]) assertEquals(entity.getConfig(TestEntity.CONF_LIST_THING) as Set, ["aval","bval"] as Set) } @Test // ListConfigKey deprecated, as order no longer guaranteed public void testListConfigKeyClear() throws Exception { - entity.setConfig(TestEntity.CONF_LIST_THING.subKey(), "aval") - entity.setConfig(TestEntity.CONF_LIST_THING, ListModifications.clearing()) + entity.config().set(TestEntity.CONF_LIST_THING.subKey(), "aval") + entity.config().set(TestEntity.CONF_LIST_THING, ListModifications.clearing()) // for now defaults to null, but empty list might be better? or whatever the default is? assertEquals(entity.getConfig(TestEntity.CONF_LIST_THING) as Set, null) } @Test // ListConfigKey deprecated, as order no longer guaranteed public void testListConfigKeyAddMod() throws Exception { - entity.setConfig(TestEntity.CONF_LIST_THING.subKey(), "aval") - entity.setConfig(TestEntity.CONF_LIST_THING, ListModifications.add("bval", "cval")) + entity.config().set(TestEntity.CONF_LIST_THING.subKey(), "aval") + entity.config().set(TestEntity.CONF_LIST_THING, ListModifications.add("bval", "cval")) //assertEquals(entity.getConfig(TestEntity.CONF_LIST_THING), ["aval","bval","cval"]) assertEquals(entity.getConfig(TestEntity.CONF_LIST_THING) as Set, ["aval","bval","cval"] as Set) } @Test // ListConfigKey deprecated, as order no longer guaranteed public void testListConfigKeyAddAllMod() throws Exception { - entity.setConfig(TestEntity.CONF_LIST_THING.subKey(), "aval") - entity.setConfig(TestEntity.CONF_LIST_THING, ListModifications.addAll(["bval", "cval"])) + entity.config().set(TestEntity.CONF_LIST_THING.subKey(), "aval") + entity.config().set(TestEntity.CONF_LIST_THING, ListModifications.addAll(["bval", "cval"])) //assertEquals(entity.getConfig(TestEntity.CONF_LIST_THING), ["aval","bval","cval"]) assertEquals(entity.getConfig(TestEntity.CONF_LIST_THING) as Set, ["aval","bval","cval"] as Set) } @Test // ListConfigKey deprecated, as order no longer guaranteed public void testListConfigKeyAddItemMod() throws Exception { - entity.setConfig(TestEntity.CONF_LIST_THING.subKey(), "aval") - entity.setConfig(TestEntity.CONF_LIST_THING, ListModifications.addItem(["bval", "cval"])) + entity.config().set(TestEntity.CONF_LIST_THING.subKey(), "aval") + entity.config().set(TestEntity.CONF_LIST_THING, ListModifications.addItem(["bval", "cval"])) //assertEquals(entity.getConfig(TestEntity.CONF_LIST_THING), ["aval",["bval","cval"]]) assertEquals(entity.getConfig(TestEntity.CONF_LIST_THING) as Set, ["aval",["bval","cval"]] as Set) } @Test // ListConfigKey deprecated, as order no longer guaranteed public void testListConfigKeyListMod() throws Exception { - entity.setConfig(TestEntity.CONF_LIST_THING.subKey(), "aval") - entity.setConfig(TestEntity.CONF_LIST_THING, ListModifications.set(["bval", "cval"])) + entity.config().set(TestEntity.CONF_LIST_THING.subKey(), "aval") + entity.config().set(TestEntity.CONF_LIST_THING, ListModifications.set(["bval", "cval"])) //assertEquals(entity.getConfig(TestEntity.CONF_LIST_THING), ["bval","cval"]) assertEquals(entity.getConfig(TestEntity.CONF_LIST_THING) as Set, ["bval","cval"] as Set) } @Test public void testMapConfigPutDirect() throws Exception { - entity.setConfig(TestEntity.CONF_MAP_THING.subKey("akey"), "aval") - entity.setConfig(TestEntity.CONF_MAP_THING, [bkey:"bval"]) + entity.config().set(TestEntity.CONF_MAP_THING.subKey("akey"), "aval") + entity.config().set(TestEntity.CONF_MAP_THING, [bkey:"bval"]) //assertEquals(entity.getConfig(TestEntity.CONF_MAP_THING), [akey:"aval",bkey:"bval"]) assertEquals(entity.getConfig(TestEntity.CONF_MAP_THING), [akey:"aval",bkey:"bval"]) } @Test public void testMapConfigPutAllMod() throws Exception { - entity.setConfig(TestEntity.CONF_MAP_THING.subKey("akey"), "aval") - entity.setConfig(TestEntity.CONF_MAP_THING, MapModifications.put([bkey:"bval"])) + entity.config().set(TestEntity.CONF_MAP_THING.subKey("akey"), "aval") + entity.config().set(TestEntity.CONF_MAP_THING, MapModifications.put([bkey:"bval"])) //assertEquals(entity.getConfig(TestEntity.CONF_MAP_THING), [akey:"aval",bkey:"bval"]) assertEquals(entity.getConfig(TestEntity.CONF_MAP_THING), [akey:"aval",bkey:"bval"]) } @Test public void testMapConfigClearMod() throws Exception { - entity.setConfig(TestEntity.CONF_MAP_THING.subKey("akey"), "aval") - entity.setConfig(TestEntity.CONF_MAP_THING, MapModifications.clearing()) + entity.config().set(TestEntity.CONF_MAP_THING.subKey("akey"), "aval") + entity.config().set(TestEntity.CONF_MAP_THING, MapModifications.clearing()) // for now defaults to null, but empty map might be better? or whatever the default is? assertEquals(entity.getConfig(TestEntity.CONF_MAP_THING), null) } @Test public void testMapConfigSetMod() throws Exception { - entity.setConfig(TestEntity.CONF_MAP_THING.subKey("akey"), "aval") - entity.setConfig(TestEntity.CONF_MAP_THING, MapModifications.set([bkey:"bval"])) + entity.config().set(TestEntity.CONF_MAP_THING.subKey("akey"), "aval") + entity.config().set(TestEntity.CONF_MAP_THING, MapModifications.set([bkey:"bval"])) assertEquals(entity.getConfig(TestEntity.CONF_MAP_THING), [bkey:"bval"]) } @Test public void testMapConfigDeepSetFromMap() throws Exception { - entity.setConfig(TestEntity.CONF_MAP_THING_OBJECT, [akey: [aa:"AA", a2:"A2"], bkey: "b"]) + entity.config().set(TestEntity.CONF_MAP_THING_OBJECT, [akey: [aa:"AA", a2:"A2"], bkey: "b"]) entity.getConfig(TestEntity.CONF_MAP_THING_OBJECT.subKey("akey"), [aa:"AA", a2:"A2"]) entity.getConfig(TestEntity.CONF_MAP_THING_OBJECT.subKey("bkey"), ["b"]) @@ -334,8 +334,8 @@ public class MapListAndOtherStructuredConfigKeyTest { } @Test public void testMapConfigDeepSetFromSubkeys() throws Exception { - entity.setConfig(TestEntity.CONF_MAP_THING_OBJECT.subKey("akey"), [aa:"AA", a2:"A2"]) - entity.setConfig(TestEntity.CONF_MAP_THING_OBJECT.subKey("bkey"), "b") + entity.config().set(TestEntity.CONF_MAP_THING_OBJECT.subKey("akey"), [aa:"AA", a2:"A2"]) + entity.config().set(TestEntity.CONF_MAP_THING_OBJECT.subKey("bkey"), "b") entity.getConfig(TestEntity.CONF_MAP_THING_OBJECT.subKey("akey"), [aa:"AA", a2:"A2"]) entity.getConfig(TestEntity.CONF_MAP_THING_OBJECT.subKey("bkey"), ["b"]) @@ -344,10 +344,10 @@ public class MapListAndOtherStructuredConfigKeyTest { } @Test public void testMapConfigAdd() throws Exception { - entity.setConfig(TestEntity.CONF_MAP_THING_OBJECT.subKey("0key"), 0) - entity.setConfig(TestEntity.CONF_MAP_THING_OBJECT.subKey("akey"), [aa:"AA", a2:"A2"]) - entity.setConfig(TestEntity.CONF_MAP_THING_OBJECT.subKey("bkey"), ["b"]) - entity.setConfig(TestEntity.CONF_MAP_THING_OBJECT, MapModifications.add([akey:[a3:3],bkey:"b2",ckey:"cc"])) + entity.config().set(TestEntity.CONF_MAP_THING_OBJECT.subKey("0key"), 0) + entity.config().set(TestEntity.CONF_MAP_THING_OBJECT.subKey("akey"), [aa:"AA", a2:"A2"]) + entity.config().set(TestEntity.CONF_MAP_THING_OBJECT.subKey("bkey"), ["b"]) + entity.config().set(TestEntity.CONF_MAP_THING_OBJECT, MapModifications.add([akey:[a3:3],bkey:"b2",ckey:"cc"])) assertEquals(entity.getConfig(TestEntity.CONF_MAP_THING_OBJECT), ["0key":0, akey:[aa:"AA",a2:"A2",a3:3],bkey:["b","b2"],ckey:"cc" ]) http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4d08310c/core/src/test/java/org/apache/brooklyn/core/enricher/BasicEnricherTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/brooklyn/core/enricher/BasicEnricherTest.java b/core/src/test/java/org/apache/brooklyn/core/enricher/BasicEnricherTest.java index be87f1f..6d58be0a 100644 --- a/core/src/test/java/org/apache/brooklyn/core/enricher/BasicEnricherTest.java +++ b/core/src/test/java/org/apache/brooklyn/core/enricher/BasicEnricherTest.java @@ -78,7 +78,7 @@ public class BasicEnricherTest extends BrooklynAppUnitTestSupport { enricher.setDisplayName("Bob"); enricher.config().set(MyEnricher.STR_KEY, "aval"); enricher.config().set(MyEnricher.INT_KEY, 2); - app.addEnricher(enricher); + app.enrichers().add(enricher); assertEquals(enricher.getDisplayName(), "Bob"); assertEquals(enricher.getConfig(MyEnricher.STR_KEY), "aval"); @@ -87,7 +87,7 @@ public class BasicEnricherTest extends BrooklynAppUnitTestSupport { @Test public void testAddSpec() throws Exception { - MyEnricher enricher = app.addEnricher(EnricherSpec.create(MyEnricher.class) + MyEnricher enricher = app.enrichers().add(EnricherSpec.create(MyEnricher.class) .displayName("Bob") .configure(MyEnricher.STR_KEY, "aval").configure(MyEnricher.INT_KEY, 2)); @@ -98,7 +98,7 @@ public class BasicEnricherTest extends BrooklynAppUnitTestSupport { @Test public void testTagsFromSpec() throws Exception { - MyEnricher enricher = app.addEnricher(EnricherSpec.create(MyEnricher.class).tag(99).uniqueTag("x")); + MyEnricher enricher = app.enrichers().add(EnricherSpec.create(MyEnricher.class).tag(99).uniqueTag("x")); assertEquals(enricher.tags().getTags(), MutableSet.of("x", 99)); assertEquals(enricher.getUniqueTag(), "x"); @@ -106,12 +106,12 @@ public class BasicEnricherTest extends BrooklynAppUnitTestSupport { @Test public void testSameUniqueTagEnricherNotAddedTwice() throws Exception { - app.addEnricher(EnricherSpec.create(MyEnricher.class).tag(99).uniqueTag("x")); - app.addEnricher(EnricherSpec.create(MyEnricher.class).tag(94).uniqueTag("x")); + app.enrichers().add(EnricherSpec.create(MyEnricher.class).tag(99).uniqueTag("x")); + app.enrichers().add(EnricherSpec.create(MyEnricher.class).tag(94).uniqueTag("x")); assertEquals(app.getEnrichers().size(), 1); // the more recent one should dominate - Enricher enricher = Iterables.getOnlyElement(app.getEnrichers()); + Enricher enricher = Iterables.getOnlyElement(app.enrichers()); Assert.assertTrue(enricher.tags().containsTag(94)); Assert.assertFalse(enricher.tags().containsTag(99)); } http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4d08310c/core/src/test/java/org/apache/brooklyn/core/enricher/EnricherConfigTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/brooklyn/core/enricher/EnricherConfigTest.java b/core/src/test/java/org/apache/brooklyn/core/enricher/EnricherConfigTest.java index 150a09b..fb60abd 100644 --- a/core/src/test/java/org/apache/brooklyn/core/enricher/EnricherConfigTest.java +++ b/core/src/test/java/org/apache/brooklyn/core/enricher/EnricherConfigTest.java @@ -43,7 +43,7 @@ public class EnricherConfigTest extends BrooklynAppUnitTestSupport { .put("strKey", "aval") .put("intKey", 2) .build()); - app.addEnricher(enricher); + app.enrichers().add(enricher); assertEquals(enricher.getConfig(MyEnricher.STR_KEY), "aval"); assertEquals(enricher.getConfig(MyEnricher.INT_KEY), (Integer)2); @@ -57,7 +57,7 @@ public class EnricherConfigTest extends BrooklynAppUnitTestSupport { MyEnricher enricher = new MyEnricher(MutableMap.builder() .put(differentKey, "aval") .build()); - app.addEnricher(enricher); + app.enrichers().add(enricher); assertEquals(enricher.getConfig(differentKey), null); assertEquals(enricher.getEnricherType().getConfigKey(differentKey.getName()), null); @@ -69,7 +69,7 @@ public class EnricherConfigTest extends BrooklynAppUnitTestSupport { .put(MyEnricher.STR_KEY, "aval") .put(MyEnricher.INT_KEY, 2) .build()); - app.addEnricher(enricher); + app.enrichers().add(enricher); assertEquals(enricher.getConfig(MyEnricher.STR_KEY), "aval"); assertEquals(enricher.getConfig(MyEnricher.INT_KEY), (Integer)2); @@ -82,7 +82,7 @@ public class EnricherConfigTest extends BrooklynAppUnitTestSupport { MyEnricher enricher = new MyEnricher(MutableMap.builder() .put(MyEnricher.INT_KEY_WITH_DEFAULT, 0) .build()); - app.addEnricher(enricher); + app.enrichers().add(enricher); assertEquals(enricher.getConfig(MyEnricher.INT_KEY_WITH_DEFAULT), (Integer)0); } @@ -92,7 +92,7 @@ public class EnricherConfigTest extends BrooklynAppUnitTestSupport { MyEnricher enricher = new MyEnricher(MutableMap.builder() .put(MyEnricher.STR_KEY_WITH_DEFAULT, null) .build()); - app.addEnricher(enricher); + app.enrichers().add(enricher); assertEquals(enricher.getConfig(MyEnricher.STR_KEY_WITH_DEFAULT), null); } @@ -102,7 +102,7 @@ public class EnricherConfigTest extends BrooklynAppUnitTestSupport { MyEnricher enricher = new MyEnricher(); enricher.config().set(MyEnricher.STR_KEY, "aval"); enricher.config().set(MyEnricher.INT_KEY, 2); - app.addEnricher(enricher); + app.enrichers().add(enricher); assertEquals(enricher.getConfig(MyEnricher.STR_KEY), "aval"); assertEquals(enricher.getConfig(MyEnricher.INT_KEY), (Integer)2); @@ -114,7 +114,7 @@ public class EnricherConfigTest extends BrooklynAppUnitTestSupport { .put(MyEnricher.STR_KEY, "aval") .build()); enricher.config().set(MyEnricher.STR_KEY, "diffval"); - app.addEnricher(enricher); + app.enrichers().add(enricher); assertEquals(enricher.getConfig(MyEnricher.STR_KEY), "diffval"); } @@ -124,7 +124,7 @@ public class EnricherConfigTest extends BrooklynAppUnitTestSupport { MyEnricher enricher = new MyEnricher(MutableMap.builder() .put(MyEnricher.STR_KEY, "origval") .build()); - app.addEnricher(enricher); + app.enrichers().add(enricher); try { enricher.config().set(MyEnricher.STR_KEY,"newval"); @@ -139,7 +139,7 @@ public class EnricherConfigTest extends BrooklynAppUnitTestSupport { @Test public void testConfigReturnsDefaultValueIfNotSet() throws Exception { MyEnricher enricher = new MyEnricher(); - app.addEnricher(enricher); + app.enrichers().add(enricher); assertEquals(enricher.getConfig(MyEnricher.STR_KEY_WITH_DEFAULT), "str key default"); } http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4d08310c/core/src/test/java/org/apache/brooklyn/core/entity/AttributeMapTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/brooklyn/core/entity/AttributeMapTest.java b/core/src/test/java/org/apache/brooklyn/core/entity/AttributeMapTest.java index 21529c8..95d9bad 100644 --- a/core/src/test/java/org/apache/brooklyn/core/entity/AttributeMapTest.java +++ b/core/src/test/java/org/apache/brooklyn/core/entity/AttributeMapTest.java @@ -189,7 +189,7 @@ public class AttributeMapTest { AttributeSensor<Integer> childSensor = Sensors.newIntegerSensor("a.b", ""); final RecordingSensorEventListener<Object> listener = new RecordingSensorEventListener<>(); - entity.subscribe(entity, sensor, listener); + entity.subscriptions().subscribe(entity, sensor, listener); map.modify(childSensor, Functions.constant(Maybe.<Integer>absent())); http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4d08310c/core/src/test/java/org/apache/brooklyn/core/entity/AttributeTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/brooklyn/core/entity/AttributeTest.java b/core/src/test/java/org/apache/brooklyn/core/entity/AttributeTest.java index 68fe527..8c4c3a0 100644 --- a/core/src/test/java/org/apache/brooklyn/core/entity/AttributeTest.java +++ b/core/src/test/java/org/apache/brooklyn/core/entity/AttributeTest.java @@ -45,7 +45,7 @@ public class AttributeTest { @Test public void canGetAndSetAttribute() { - e.setAttribute(COLOR, "red"); + e.sensors().set(COLOR, "red"); assertEquals(e.getAttribute(COLOR), "red"); } @@ -60,7 +60,7 @@ public class AttributeTest { assertNull(e.getAttributeByNameParts(COLOR.getNameParts())); // Once set, returns val - e.setAttribute(COLOR, "red"); + e.sensors().set(COLOR, "red"); assertEquals(e.getAttributeByNameParts(COLOR.getNameParts()), "red"); } } http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4d08310c/core/src/test/java/org/apache/brooklyn/core/entity/ConfigEntityInheritanceTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/brooklyn/core/entity/ConfigEntityInheritanceTest.java b/core/src/test/java/org/apache/brooklyn/core/entity/ConfigEntityInheritanceTest.java index afcd340..0334312 100644 --- a/core/src/test/java/org/apache/brooklyn/core/entity/ConfigEntityInheritanceTest.java +++ b/core/src/test/java/org/apache/brooklyn/core/entity/ConfigEntityInheritanceTest.java @@ -170,9 +170,9 @@ public class ConfigEntityInheritanceTest { @Test public void testConfigKeysInheritance() throws Exception { - app.setConfig(MyEntityWithPartiallyHeritableConfig.HERITABLE, "heritable"); - app.setConfig(MyEntityWithPartiallyHeritableConfig.UNINHERITABLE, "uninheritable"); - app.setConfig(MyEntityWithPartiallyHeritableConfig.ALWAYS_HERITABLE, "always_heritable"); + app.config().set(MyEntityWithPartiallyHeritableConfig.HERITABLE, "heritable"); + app.config().set(MyEntityWithPartiallyHeritableConfig.UNINHERITABLE, "uninheritable"); + app.config().set(MyEntityWithPartiallyHeritableConfig.ALWAYS_HERITABLE, "always_heritable"); Entity child = app.addChild(EntitySpec.create(MyEntityWithPartiallyHeritableConfig.class)); Assert.assertNotNull(child.getConfig(MyEntityWithPartiallyHeritableConfig.HERITABLE)); http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4d08310c/core/src/test/java/org/apache/brooklyn/core/entity/DependentConfigurationTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/brooklyn/core/entity/DependentConfigurationTest.java b/core/src/test/java/org/apache/brooklyn/core/entity/DependentConfigurationTest.java index 45fac8f..acd3a7d 100644 --- a/core/src/test/java/org/apache/brooklyn/core/entity/DependentConfigurationTest.java +++ b/core/src/test/java/org/apache/brooklyn/core/entity/DependentConfigurationTest.java @@ -114,7 +114,7 @@ public class DependentConfigurationTest extends BrooklynAppUnitTestSupport { final Task<String> t = submit(DependentConfiguration.attributeWhenReady(entity, TestEntity.NAME)); assertNotDoneContinually(t); - entity.setAttribute(TestEntity.NAME, "myval"); + entity.sensors().set(TestEntity.NAME, "myval"); assertEquals(assertDoneEventually(t), "myval"); } @@ -122,10 +122,10 @@ public class DependentConfigurationTest extends BrooklynAppUnitTestSupport { public void testAttributeWhenReadyWithPredicate() throws Exception { final Task<String> t = submit(DependentConfiguration.attributeWhenReady(entity, TestEntity.NAME, Predicates.equalTo("myval2"))); - entity.setAttribute(TestEntity.NAME, "myval"); + entity.sensors().set(TestEntity.NAME, "myval"); assertNotDoneContinually(t); - entity.setAttribute(TestEntity.NAME, "myval2"); + entity.sensors().set(TestEntity.NAME, "myval2"); assertEquals(assertDoneEventually(t), "myval2"); } @@ -134,7 +134,7 @@ public class DependentConfigurationTest extends BrooklynAppUnitTestSupport { final Task<String> t = submit(DependentConfiguration.valueWhenAttributeReady(entity, TestEntity.SEQUENCE, Functions.toStringFunction())); assertNotDoneContinually(t); - entity.setAttribute(TestEntity.SEQUENCE, 1); + entity.sensors().set(TestEntity.SEQUENCE, 1); assertEquals(assertDoneEventually(t), "1"); } @@ -147,7 +147,7 @@ public class DependentConfigurationTest extends BrooklynAppUnitTestSupport { assertNotDoneContinually(t); - entity.setAttribute(TestEntity.SEQUENCE, 1); + entity.sensors().set(TestEntity.SEQUENCE, 1); assertEquals(assertDoneEventually(t), "1"); } @@ -163,7 +163,7 @@ public class DependentConfigurationTest extends BrooklynAppUnitTestSupport { assertNotDoneContinually(t); - entity.setAttribute(TestEntity.SEQUENCE, 1); + entity.sensors().set(TestEntity.SEQUENCE, 1); assertEquals(assertDoneEventually(t), "1"); } @@ -175,7 +175,7 @@ public class DependentConfigurationTest extends BrooklynAppUnitTestSupport { .build()); assertNotDoneContinually(t); - entity.setAttribute(TestEntity.NAME, "myval"); + entity.sensors().set(TestEntity.NAME, "myval"); assertEquals(assertDoneEventually(t), "myval"); } @@ -188,10 +188,10 @@ public class DependentConfigurationTest extends BrooklynAppUnitTestSupport { assertNotDoneContinually(t); - entity2.setAttribute(TestEntity.SEQUENCE, 321); + entity2.sensors().set(TestEntity.SEQUENCE, 321); assertNotDoneContinually(t); - entity2.setAttribute(TestEntity.SEQUENCE, 1); + entity2.sensors().set(TestEntity.SEQUENCE, 1); try { assertDoneEventually(t); fail(); @@ -212,10 +212,10 @@ public class DependentConfigurationTest extends BrooklynAppUnitTestSupport { assertNotDoneContinually(t); - entity2.setAttribute(TestEntity.SEQUENCE, 321); + entity2.sensors().set(TestEntity.SEQUENCE, 321); assertNotDoneContinually(t); - entity2.setAttribute(TestEntity.SEQUENCE, 1); + entity2.sensors().set(TestEntity.SEQUENCE, 1); try { assertDoneEventually(t); fail(); @@ -226,7 +226,7 @@ public class DependentConfigurationTest extends BrooklynAppUnitTestSupport { @Test public void testAttributeWhenReadyWithAbortFailsWhenAbortConditionAlreadyHolds() throws Exception { - entity2.setAttribute(TestEntity.SEQUENCE, 1); + entity2.sensors().set(TestEntity.SEQUENCE, 1); final Task<String> t = submit(DependentConfiguration.builder() .attributeWhenReady(entity, TestEntity.NAME) .abortIf(entity2, TestEntity.SEQUENCE, Predicates.equalTo(1)) @@ -241,7 +241,7 @@ public class DependentConfigurationTest extends BrooklynAppUnitTestSupport { @Test public void testAttributeWhenReadyWithAbortFailsWhenAbortConditionAlreadyHoldsWaitingNow() throws Exception { - entity2.setAttribute(TestEntity.SEQUENCE, 1); + entity2.sensors().set(TestEntity.SEQUENCE, 1); final Task<String> t = submit(new Callable<String>() { public String call() { return DependentConfiguration.builder() @@ -267,7 +267,7 @@ public class DependentConfigurationTest extends BrooklynAppUnitTestSupport { .runNow(); } }); - entity.setAttribute(TestEntity.NAME, "myentity"); + entity.sensors().set(TestEntity.NAME, "myentity"); assertDoneEventually(t); assertEquals(t.get(), "myentity"); } @@ -325,10 +325,10 @@ public class DependentConfigurationTest extends BrooklynAppUnitTestSupport { .build()); assertNotDoneContinually(t); - entity.setAttribute(TestEntity.NAME, "myval"); + entity.sensors().set(TestEntity.NAME, "myval"); assertNotDoneContinually(t); - entity2.setAttribute(TestEntity.NAME, "myval2"); + entity2.sensors().set(TestEntity.NAME, "myval2"); assertEquals(ImmutableSet.copyOf(assertDoneEventually(t)), ImmutableSet.of("myval", "myval2")); } @@ -338,13 +338,13 @@ public class DependentConfigurationTest extends BrooklynAppUnitTestSupport { .attributeWhenReadyFromMultiple(ImmutableList.of(entity, entity2), TestEntity.NAME, StringPredicates.startsWith("myval")) .build()); - entity.setAttribute(TestEntity.NAME, "wrongval"); - entity2.setAttribute(TestEntity.NAME, "wrongval2"); + entity.sensors().set(TestEntity.NAME, "wrongval"); + entity2.sensors().set(TestEntity.NAME, "wrongval2"); assertNotDoneContinually(t); - entity.setAttribute(TestEntity.NAME, "myval"); + entity.sensors().set(TestEntity.NAME, "myval"); assertNotDoneContinually(t); - entity2.setAttribute(TestEntity.NAME, "myval2"); + entity2.sensors().set(TestEntity.NAME, "myval2"); assertEquals(ImmutableSet.copyOf(assertDoneEventually(t)), ImmutableSet.of("myval", "myval2")); } @@ -364,8 +364,8 @@ public class DependentConfigurationTest extends BrooklynAppUnitTestSupport { }}) .build()); - entity.setAttribute(TestEntity.SEQUENCE, 1); - entity2.setAttribute(TestEntity.SEQUENCE, 2); + entity.sensors().set(TestEntity.SEQUENCE, 1); + entity2.sensors().set(TestEntity.SEQUENCE, 2); assertEquals(assertDoneEventually(t), "1,2"); } http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4d08310c/core/src/test/java/org/apache/brooklyn/core/entity/EntitiesTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/brooklyn/core/entity/EntitiesTest.java b/core/src/test/java/org/apache/brooklyn/core/entity/EntitiesTest.java index 071d6d8..b5d2099 100644 --- a/core/src/test/java/org/apache/brooklyn/core/entity/EntitiesTest.java +++ b/core/src/test/java/org/apache/brooklyn/core/entity/EntitiesTest.java @@ -65,13 +65,13 @@ public class EntitiesTest extends BrooklynAppUnitTestSupport { @Test public void testAttributeSupplier() throws Exception { - entity.setAttribute(TestEntity.NAME, "myname"); + entity.sensors().set(TestEntity.NAME, "myname"); assertEquals(Entities.attributeSupplier(entity, TestEntity.NAME).get(), "myname"); } @Test public void testAttributeSupplierUsingTuple() throws Exception { - entity.setAttribute(TestEntity.NAME, "myname"); + entity.sensors().set(TestEntity.NAME, "myname"); assertEquals(Entities.attributeSupplier(EntityAndAttribute.supplier(entity, TestEntity.NAME)).get(), "myname"); } @@ -94,7 +94,7 @@ public class EntitiesTest extends BrooklynAppUnitTestSupport { } }); - entity.setAttribute(TestEntity.NAME, "myname"); + entity.sensors().set(TestEntity.NAME, "myname"); t.join(TIMEOUT_MS); assertFalse(t.isAlive()); assertEquals(result.get(), "myname"); http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4d08310c/core/src/test/java/org/apache/brooklyn/core/entity/EntityFunctionsTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/brooklyn/core/entity/EntityFunctionsTest.java b/core/src/test/java/org/apache/brooklyn/core/entity/EntityFunctionsTest.java index b120d98..7b68d28 100644 --- a/core/src/test/java/org/apache/brooklyn/core/entity/EntityFunctionsTest.java +++ b/core/src/test/java/org/apache/brooklyn/core/entity/EntityFunctionsTest.java @@ -47,14 +47,14 @@ public class EntityFunctionsTest extends BrooklynAppUnitTestSupport { @Test public void testAttribute() throws Exception { - entity.setAttribute(TestEntity.NAME, "myname"); + entity.sensors().set(TestEntity.NAME, "myname"); assertEquals(EntityFunctions.attribute(TestEntity.NAME).apply(entity), "myname"); assertNull(EntityFunctions.attribute(TestEntity.SEQUENCE).apply(entity)); } @Test public void testConfig() throws Exception { - entity.setConfig(TestEntity.CONF_NAME, "myname"); + entity.config().set(TestEntity.CONF_NAME, "myname"); assertEquals(EntityFunctions.config(TestEntity.CONF_NAME).apply(entity), "myname"); assertNull(EntityFunctions.config(TestEntity.CONF_OBJECT).apply(entity)); } http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4d08310c/core/src/test/java/org/apache/brooklyn/core/entity/EntityLocationsTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/brooklyn/core/entity/EntityLocationsTest.java b/core/src/test/java/org/apache/brooklyn/core/entity/EntityLocationsTest.java index 3aa68b6..22881d6 100644 --- a/core/src/test/java/org/apache/brooklyn/core/entity/EntityLocationsTest.java +++ b/core/src/test/java/org/apache/brooklyn/core/entity/EntityLocationsTest.java @@ -51,8 +51,8 @@ public class EntityLocationsTest extends BrooklynAppUnitTestSupport { final RecordingSensorEventListener<Object> addedEvents = new RecordingSensorEventListener<>(); final RecordingSensorEventListener<Object> removedEvents = new RecordingSensorEventListener<>(); - app.subscribe(app, AbstractEntity.LOCATION_ADDED, addedEvents); - app.subscribe(app, AbstractEntity.LOCATION_REMOVED, removedEvents); + app.subscriptions().subscribe(app, AbstractEntity.LOCATION_ADDED, addedEvents); + app.subscriptions().subscribe(app, AbstractEntity.LOCATION_REMOVED, removedEvents); // Add first location app.addLocations(ImmutableList.of(l)); @@ -85,8 +85,8 @@ public class EntityLocationsTest extends BrooklynAppUnitTestSupport { final RecordingSensorEventListener<Object> addedEvents = new RecordingSensorEventListener<>(); final RecordingSensorEventListener<Object> removedEvents = new RecordingSensorEventListener<>(); - app.subscribe(app, AbstractEntity.LOCATION_ADDED, addedEvents); - app.subscribe(app, AbstractEntity.LOCATION_REMOVED, removedEvents); + app.subscriptions().subscribe(app, AbstractEntity.LOCATION_ADDED, addedEvents); + app.subscriptions().subscribe(app, AbstractEntity.LOCATION_REMOVED, removedEvents); // Add first location app.addLocations(ImmutableList.of(l, l)); http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4d08310c/core/src/test/java/org/apache/brooklyn/core/entity/EntityPreManagementTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/brooklyn/core/entity/EntityPreManagementTest.java b/core/src/test/java/org/apache/brooklyn/core/entity/EntityPreManagementTest.java index e10c703..043de6d 100644 --- a/core/src/test/java/org/apache/brooklyn/core/entity/EntityPreManagementTest.java +++ b/core/src/test/java/org/apache/brooklyn/core/entity/EntityPreManagementTest.java @@ -68,7 +68,7 @@ public class EntityPreManagementTest { public void testSetSensorBeforeManaged() { TestEntity e = entityManager.createEntity(EntitySpec.create(TestEntity.class)); - e.setAttribute(Attributes.HOSTNAME, "martian.martian"); + e.sensors().set(Attributes.HOSTNAME, "martian.martian"); Assert.assertEquals(e.getAttribute(Attributes.HOSTNAME), "martian.martian"); Assert.assertFalse(e.getManagementSupport().isManagementContextReal()); @@ -79,11 +79,11 @@ public class EntityPreManagementTest { TestEntity e = entityManager.createEntity(EntitySpec.create(TestEntity.class)); final List events = new ArrayList(); - e.addPolicy(new AbstractPolicy() { + e.policies().add(new AbstractPolicy() { @Override public void setEntity(EntityLocal entity) { super.setEntity(entity); - subscribe(entity, Attributes.HOSTNAME, new SensorEventListener() { + subscriptions().subscribe(entity, Attributes.HOSTNAME, new SensorEventListener() { @Override public void onEvent(SensorEvent event) { events.add(event); @@ -92,7 +92,7 @@ public class EntityPreManagementTest { } }); - e.setAttribute(Attributes.HOSTNAME, "martian.martian"); + e.sensors().set(Attributes.HOSTNAME, "martian.martian"); Assert.assertEquals(e.getAttribute(Attributes.HOSTNAME), "martian.martian"); if (!events.isEmpty()) Assert.fail("Shouldn't have events yet: "+events); @@ -115,11 +115,11 @@ public class EntityPreManagementTest { app = entityManager.createEntity(EntitySpec.create(TestApplication.class)); final List events = new ArrayList(); - app.addPolicy(new AbstractPolicy() { + app.policies().add(new AbstractPolicy() { @Override public void setEntity(EntityLocal entity) { super.setEntity(entity); - subscribe(entity, Attributes.HOSTNAME, new SensorEventListener() { + subscriptions().subscribe(entity, Attributes.HOSTNAME, new SensorEventListener() { @Override public void onEvent(SensorEvent event) { events.add(event); @@ -128,7 +128,7 @@ public class EntityPreManagementTest { } }); - app.setAttribute(Attributes.HOSTNAME, "martian.martian"); + app.sensors().set(Attributes.HOSTNAME, "martian.martian"); Assert.assertEquals(app.getAttribute(Attributes.HOSTNAME), "martian.martian"); if (!events.isEmpty()) Assert.fail("Shouldn't have events yet: "+events); http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4d08310c/core/src/test/java/org/apache/brooklyn/core/entity/EntityPredicatesTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/brooklyn/core/entity/EntityPredicatesTest.java b/core/src/test/java/org/apache/brooklyn/core/entity/EntityPredicatesTest.java index dbd2972..6db1a55 100644 --- a/core/src/test/java/org/apache/brooklyn/core/entity/EntityPredicatesTest.java +++ b/core/src/test/java/org/apache/brooklyn/core/entity/EntityPredicatesTest.java @@ -64,14 +64,14 @@ public class EntityPredicatesTest extends BrooklynAppUnitTestSupport { @Test public void testAttributeEqualTo() throws Exception { - entity.setAttribute(TestEntity.NAME, "myname"); + entity.sensors().set(TestEntity.NAME, "myname"); assertTrue(EntityPredicates.attributeEqualTo(TestEntity.NAME, "myname").apply(entity)); assertFalse(EntityPredicates.attributeEqualTo(TestEntity.NAME, "wrongname").apply(entity)); } @Test public void testConfigEqualTo() throws Exception { - entity.setConfig(TestEntity.CONF_NAME, "myname"); + entity.config().set(TestEntity.CONF_NAME, "myname"); assertTrue(EntityPredicates.configEqualTo(TestEntity.CONF_NAME, "myname").apply(entity)); assertFalse(EntityPredicates.configEqualTo(TestEntity.CONF_NAME, "wrongname").apply(entity)); } http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4d08310c/core/src/test/java/org/apache/brooklyn/core/entity/EntityRegistrationTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/brooklyn/core/entity/EntityRegistrationTest.java b/core/src/test/java/org/apache/brooklyn/core/entity/EntityRegistrationTest.java index 018b82c..c373816 100644 --- a/core/src/test/java/org/apache/brooklyn/core/entity/EntityRegistrationTest.java +++ b/core/src/test/java/org/apache/brooklyn/core/entity/EntityRegistrationTest.java @@ -58,11 +58,11 @@ public class EntityRegistrationTest extends BrooklynAppUnitTestSupport { added = Lists.newCopyOnWriteArrayList(); removed = Lists.newCopyOnWriteArrayList(); - app.subscribe(app, AbstractEntity.CHILD_ADDED, new SensorEventListener<Entity>() { + app.subscriptions().subscribe(app, AbstractEntity.CHILD_ADDED, new SensorEventListener<Entity>() { @Override public void onEvent(SensorEvent<Entity> event) { added.add(event.getValue()); }}); - app.subscribe(app, AbstractEntity.CHILD_REMOVED, new SensorEventListener<Entity>() { + app.subscriptions().subscribe(app, AbstractEntity.CHILD_REMOVED, new SensorEventListener<Entity>() { @Override public void onEvent(SensorEvent<Entity> event) { removed.add(event.getValue()); }});
