http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4d08310c/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindEnricherTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindEnricherTest.java b/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindEnricherTest.java index e79ba8a..2db5862 100644 --- a/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindEnricherTest.java +++ b/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindEnricherTest.java @@ -84,7 +84,7 @@ public class RebindEnricherTest extends RebindTestFixtureWithApp { @Test public void testPropagatingEnricher() throws Exception { - origApp.addEnricher(Enrichers.builder() + origApp.enrichers().add(Enrichers.builder() .propagating(METRIC1) .from(origEntity) .build()); @@ -92,13 +92,13 @@ public class RebindEnricherTest extends RebindTestFixtureWithApp { TestApplication newApp = rebind(); TestEntity newEntity = (TestEntity) Iterables.find(newApp.getChildren(), Predicates.instanceOf(TestEntity.class)); - newEntity.setAttribute(METRIC1, "myval"); + newEntity.sensors().set(METRIC1, "myval"); EntityTestUtils.assertAttributeEqualsEventually(newApp, METRIC1, "myval"); } @Test public void testPropagatingAllEnricher() throws Exception { - origApp.addEnricher(Enrichers.builder() + origApp.enrichers().add(Enrichers.builder() .propagatingAll() .from(origEntity) .build()); @@ -106,13 +106,13 @@ public class RebindEnricherTest extends RebindTestFixtureWithApp { TestApplication newApp = rebind(); TestEntity newEntity = (TestEntity) Iterables.find(newApp.getChildren(), Predicates.instanceOf(TestEntity.class)); - newEntity.setAttribute(METRIC1, "myval"); + newEntity.sensors().set(METRIC1, "myval"); EntityTestUtils.assertAttributeEqualsEventually(newApp, METRIC1, "myval"); } @Test public void testPropagatingAsEnricher() throws Exception { - origApp.addEnricher(Enrichers.builder() + origApp.enrichers().add(Enrichers.builder() .propagating(ImmutableMap.of(METRIC1, METRIC2)) .from(origEntity) .build()); @@ -120,14 +120,14 @@ public class RebindEnricherTest extends RebindTestFixtureWithApp { TestApplication newApp = rebind(); TestEntity newEntity = (TestEntity) Iterables.find(newApp.getChildren(), Predicates.instanceOf(TestEntity.class)); - newEntity.setAttribute(METRIC1, "myval"); + newEntity.sensors().set(METRIC1, "myval"); EntityTestUtils.assertAttributeEqualsEventually(newApp, METRIC2, "myval"); } @SuppressWarnings("unchecked") @Test public void testCombiningEnricher() throws Exception { - origApp.addEnricher(Enrichers.builder() + origApp.enrichers().add(Enrichers.builder() .combining(METRIC1, METRIC2) .from(origEntity) .computing(StringFunctions.joiner(",")) @@ -137,8 +137,8 @@ public class RebindEnricherTest extends RebindTestFixtureWithApp { TestApplication newApp = rebind(); TestEntity newEntity = (TestEntity) Iterables.find(newApp.getChildren(), Predicates.instanceOf(TestEntity.class)); - newEntity.setAttribute(METRIC1, "myval"); - newEntity.setAttribute(METRIC2, "myval2"); + newEntity.sensors().set(METRIC1, "myval"); + newEntity.sensors().set(METRIC2, "myval2"); EntityTestUtils.assertAttributeEventually(newApp, METRIC2, Predicates.or(Predicates.equalTo("myval,myval2"), Predicates.equalTo("myval2,myval"))); } @@ -147,7 +147,7 @@ public class RebindEnricherTest extends RebindTestFixtureWithApp { origApp.start(ImmutableList.of(origLoc)); origCluster.resize(2); - origApp.addEnricher(Enrichers.builder() + origApp.enrichers().add(Enrichers.builder() .aggregating(METRIC1) .from(origCluster) .fromMembers() @@ -160,14 +160,14 @@ public class RebindEnricherTest extends RebindTestFixtureWithApp { int i = 1; for (Entity member : newCluster.getMembers()) { - ((EntityInternal)member).setAttribute(METRIC1, "myval"+(i++)); + ((EntityInternal)member).sensors().set(METRIC1, "myval"+(i++)); } EntityTestUtils.assertAttributeEventually(newApp, METRIC2, Predicates.or(Predicates.equalTo("myval1,myval2"), Predicates.equalTo("myval2,myval1"))); } @Test public void testRestoresConfig() throws Exception { - origApp.addEnricher(EnricherSpec.create(MyEnricher.class) + origApp.enrichers().add(EnricherSpec.create(MyEnricher.class) .displayName("My Enricher") .uniqueTag("tagU") .tag("tag1").tag("tag2") @@ -176,7 +176,7 @@ public class RebindEnricherTest extends RebindTestFixtureWithApp { .configure(MyEnricher.MY_CONFIG_WITHOUT_SETFROMFLAG, "myVal for witout setFromFlag")); newApp = (TestApplication) rebind(); - MyEnricher newEnricher = (MyEnricher) Iterables.getOnlyElement(newApp.getEnrichers()); + MyEnricher newEnricher = (MyEnricher) Iterables.getOnlyElement(newApp.enrichers()); assertEquals(newEnricher.getDisplayName(), "My Enricher"); @@ -190,10 +190,10 @@ public class RebindEnricherTest extends RebindTestFixtureWithApp { @Test public void testReboundConfigDoesNotContainId() throws Exception { - MyEnricher policy = origApp.addEnricher(EnricherSpec.create(MyEnricher.class)); + MyEnricher policy = origApp.enrichers().add(EnricherSpec.create(MyEnricher.class)); newApp = (TestApplication) rebind(); - MyEnricher newEnricher = (MyEnricher) Iterables.getOnlyElement(newApp.getEnrichers()); + MyEnricher newEnricher = (MyEnricher) Iterables.getOnlyElement(newApp.enrichers()); assertNull(newEnricher.getConfig(ConfigKeys.newStringConfigKey("id"))); assertEquals(newEnricher.getId(), policy.getId()); @@ -201,10 +201,10 @@ public class RebindEnricherTest extends RebindTestFixtureWithApp { @Test public void testIsRebinding() throws Exception { - origApp.addEnricher(EnricherSpec.create(EnricherChecksIsRebinding.class)); + origApp.enrichers().add(EnricherSpec.create(EnricherChecksIsRebinding.class)); newApp = (TestApplication) rebind(); - EnricherChecksIsRebinding newEnricher = (EnricherChecksIsRebinding) Iterables.getOnlyElement(newApp.getEnrichers()); + EnricherChecksIsRebinding newEnricher = (EnricherChecksIsRebinding) Iterables.getOnlyElement(newApp.enrichers()); assertTrue(newEnricher.isRebindingValWhenRebinding()); assertFalse(newEnricher.isRebinding()); @@ -212,12 +212,12 @@ public class RebindEnricherTest extends RebindTestFixtureWithApp { @Test public void testPolicyTags() throws Exception { - Enricher origEnricher = origApp.addEnricher(EnricherSpec.create(MyEnricher.class)); + Enricher origEnricher = origApp.enrichers().add(EnricherSpec.create(MyEnricher.class)); origEnricher.tags().addTag("foo"); origEnricher.tags().addTag(origApp); newApp = rebind(); - Enricher newEnricher = Iterables.getOnlyElement(newApp.getEnrichers()); + Enricher newEnricher = Iterables.getOnlyElement(newApp.enrichers()); Asserts.assertEqualsIgnoringOrder(newEnricher.tags().getTags(), ImmutableSet.of("foo", newApp)); } @@ -287,20 +287,20 @@ public class RebindEnricherTest extends RebindTestFixtureWithApp { @Override protected void initEnrichers() { // don't add default ones - addEnricher(EnricherSpec.create(MyEnricher.class).uniqueTag("x").tag(Identifiers.makeRandomId(8))); - addEnricher(EnricherSpec.create(MyEnricher.class)); + enrichers().add(EnricherSpec.create(MyEnricher.class).uniqueTag("x").tag(Identifiers.makeRandomId(8))); + enrichers().add(EnricherSpec.create(MyEnricher.class)); } @Override public void onManagementStarting() { super.onManagementStarted(); - addEnricher(EnricherSpec.create(MyEnricher.class).uniqueTag("y").tag(Identifiers.makeRandomId(8))); + enrichers().add(EnricherSpec.create(MyEnricher.class).uniqueTag("y").tag(Identifiers.makeRandomId(8))); } @Override public void onManagementStarted() { super.onManagementStarted(); - addEnricher(EnricherSpec.create(MyEnricher.class).uniqueTag("z").tag(Identifiers.makeRandomId(8))); + enrichers().add(EnricherSpec.create(MyEnricher.class).uniqueTag("z").tag(Identifiers.makeRandomId(8))); // all the enrichers above should not be added on rebind, but this one will be: - addEnricher(EnricherSpec.create(MyEnricher.class).uniqueTag( Identifiers.makeRandomId(8) ).tag(Identifiers.makeRandomId(8))); + enrichers().add(EnricherSpec.create(MyEnricher.class).uniqueTag( Identifiers.makeRandomId(8) ).tag(Identifiers.makeRandomId(8))); } }
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4d08310c/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindEntityDynamicTypeInfoTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindEntityDynamicTypeInfoTest.java b/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindEntityDynamicTypeInfoTest.java index 3b9bbfb..eba752d 100644 --- a/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindEntityDynamicTypeInfoTest.java +++ b/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindEntityDynamicTypeInfoTest.java @@ -66,11 +66,11 @@ public class RebindEntityDynamicTypeInfoTest extends RebindTestFixtureWithApp { origApp.addChild(EntitySpec.create(TestEntity.class)); // dynamic conf key - origApp.setConfig(TestEntity.CONF_NAME, "slim"); + origApp.config().set(TestEntity.CONF_NAME, "slim"); // declared sensor - origApp.setAttribute(TestApplication.MY_ATTRIBUTE, "foo"); + origApp.sensors().set(TestApplication.MY_ATTRIBUTE, "foo"); // dynamic sensor - origApp.setAttribute(TestEntity.SEQUENCE, 98765); + origApp.sensors().set(TestEntity.SEQUENCE, 98765); // dynamic effector origApp.getMutableEntityType().addEffector(SayHiBody.EFFECTOR); http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4d08310c/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindEntityTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindEntityTest.java b/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindEntityTest.java index f912e55..900b492 100644 --- a/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindEntityTest.java +++ b/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindEntityTest.java @@ -154,7 +154,7 @@ public class RebindEntityTest extends RebindTestFixtureWithApp { public void testRestoresEntityDependentConfigCompleted() throws Exception { MyEntity origE = origApp.createAndManageChild(EntitySpec.create(MyEntity.class) .configure("myconfig", DependentConfiguration.attributeWhenReady(origApp, TestApplication.MY_ATTRIBUTE))); - origApp.setAttribute(TestApplication.MY_ATTRIBUTE, "myval"); + origApp.sensors().set(TestApplication.MY_ATTRIBUTE, "myval"); origE.getConfig(MyEntity.MY_CONFIG); // wait for it to be done newApp = rebind(); @@ -169,7 +169,7 @@ public class RebindEntityTest extends RebindTestFixtureWithApp { newApp = rebind(); MyEntity newE = (MyEntity) Iterables.find(newApp.getChildren(), Predicates.instanceOf(MyEntity.class)); - newApp.setAttribute(TestApplication.MY_ATTRIBUTE, "myval"); + newApp.sensors().set(TestApplication.MY_ATTRIBUTE, "myval"); assertEquals(newE.getConfig(MyEntity.MY_CONFIG), "myval"); } @@ -179,7 +179,7 @@ public class RebindEntityTest extends RebindTestFixtureWithApp { AttributeSensor<String> myCustomAttribute = Sensors.newStringSensor("my.custom.attribute"); MyEntity origE = origApp.createAndManageChild(EntitySpec.create(MyEntity.class)); - origE.setAttribute(myCustomAttribute, "myval"); + origE.sensors().set(myCustomAttribute, "myval"); newApp = rebind(); MyEntity newE = (MyEntity) Iterables.find(newApp.getChildren(), Predicates.instanceOf(MyEntity.class)); @@ -247,7 +247,7 @@ public class RebindEntityTest extends RebindTestFixtureWithApp { newApp = rebind(); MyEntity2 newE = (MyEntity2) Iterables.find(newApp.getChildren(), Predicates.instanceOf(MyEntity2.class)); - newApp.setAttribute(TestApplication.MY_ATTRIBUTE, "mysensorval"); + newApp.sensors().set(TestApplication.MY_ATTRIBUTE, "mysensorval"); Asserts.eventually(Suppliers.ofInstance(newE.getEvents()), Predicates.<List<String>>equalTo(ImmutableList.of("mysensorval"))); Assert.assertEquals(newE, origE); } @@ -257,7 +257,7 @@ public class RebindEntityTest extends RebindTestFixtureWithApp { MyEntity origOtherE = origApp.createAndManageChild(EntitySpec.create(MyEntity.class)); MyEntityReffingOthers origE = origApp.createAndManageChild(EntitySpec.create(MyEntityReffingOthers.class) .configure("entityRef", origOtherE)); - origE.setAttribute(MyEntityReffingOthers.ENTITY_REF_SENSOR, origOtherE); + origE.sensors().set(MyEntityReffingOthers.ENTITY_REF_SENSOR, origOtherE); newApp = rebind(); MyEntityReffingOthers newE = (MyEntityReffingOthers) Iterables.find(newApp.getChildren(), Predicates.instanceOf(MyEntityReffingOthers.class)); @@ -274,7 +274,7 @@ public class RebindEntityTest extends RebindTestFixtureWithApp { reffer.obj = origE; reffer.entity = origE; reffer.myEntity = origE; - origApp.setConfig(TestEntity.CONF_OBJECT, reffer); + origApp.config().set(TestEntity.CONF_OBJECT, reffer); newApp = rebind(); MyEntity newE = (MyEntity) Iterables.find(newApp.getChildren(), Predicates.instanceOf(MyEntity.class)); @@ -294,7 +294,7 @@ public class RebindEntityTest extends RebindTestFixtureWithApp { ReffingEntity reffer = new ReffingEntity(); reffer.group = origE; reffer.resizable = origE; - origApp.setConfig(TestEntity.CONF_OBJECT, reffer); + origApp.config().set(TestEntity.CONF_OBJECT, reffer); newApp = rebind(); MyEntityWithMultipleInterfaces newE = (MyEntityWithMultipleInterfaces) Iterables.find(newApp.getChildren(), Predicates.instanceOf(MyEntityWithMultipleInterfaces.class)); @@ -343,7 +343,7 @@ public class RebindEntityTest extends RebindTestFixtureWithApp { MyLocation origLoc = new MyLocation(); MyEntityReffingOthers origE = origApp.createAndManageChild(EntitySpec.create(MyEntityReffingOthers.class) .configure("locationRef", origLoc)); - origE.setAttribute(MyEntityReffingOthers.LOCATION_REF_SENSOR, origLoc); + origE.sensors().set(MyEntityReffingOthers.LOCATION_REF_SENSOR, origLoc); origApp.start(ImmutableList.of(origLoc)); newApp = rebind(); @@ -527,7 +527,7 @@ public class RebindEntityTest extends RebindTestFixtureWithApp { @Test public void testRebindPreservesInheritedConfig() throws Exception { - origApp.setConfig(MyEntity.MY_CONFIG, "myValInSuper"); + origApp.config().set(MyEntity.MY_CONFIG, "myValInSuper"); origApp.createAndManageChild(EntitySpec.create(MyEntity.class)); // rebind: inherited config is preserved @@ -569,17 +569,17 @@ public class RebindEntityTest extends RebindTestFixtureWithApp { final TestEntity newE = (TestEntity) Iterables.find(newApp.getChildren(), Predicates.instanceOf(TestEntity.class)); final TestEntity newChildE = (TestEntity) Iterables.find(newE.getChildren(), Predicates.instanceOf(TestEntity.class)); - assertEquals(newE.getAllConfigBag().getStringKey("myunmatchedkey"), "myunmatchedval"); - assertEquals(newE.getLocalConfigBag().getStringKey("myunmatchedkey"), "myunmatchedval"); + assertEquals(newE.config().getBag().getStringKey("myunmatchedkey"), "myunmatchedval"); + assertEquals(newE.config().getLocalBag().getStringKey("myunmatchedkey"), "myunmatchedval"); - assertEquals(newChildE.getAllConfigBag().getStringKey("myunmatchedkey"), "myunmatchedval"); - assertFalse(newChildE.getLocalConfigBag().containsKey("myunmatchedkey")); + assertEquals(newChildE.config().getBag().getStringKey("myunmatchedkey"), "myunmatchedval"); + assertFalse(newChildE.config().getLocalBag().containsKey("myunmatchedkey")); } @Test public void testRebindPersistsNullAttribute() throws Exception { MyEntity origE = origApp.createAndManageChild(EntitySpec.create(MyEntity.class)); - origE.setAttribute(MyEntity.MY_SENSOR, null); + origE.sensors().set(MyEntity.MY_SENSOR, null); assertNull(origE.getAttribute(MyEntity.MY_SENSOR)); @@ -596,7 +596,7 @@ public class RebindEntityTest extends RebindTestFixtureWithApp { final AttributeSensor<String> MY_DYNAMIC_SENSOR = new BasicAttributeSensor<String>( String.class, sensorName, sensorDescription); - origApp.setAttribute(MY_DYNAMIC_SENSOR, "myval"); + origApp.sensors().set(MY_DYNAMIC_SENSOR, "myval"); assertEquals(origApp.getEntityType().getSensor(sensorName).getDescription(), sensorDescription); newApp = rebind(); @@ -617,7 +617,7 @@ public class RebindEntityTest extends RebindTestFixtureWithApp { Semaphore unrebindableObject = new Semaphore(1) { }; - origApp.setAttribute(MY_DYNAMIC_SENSOR, unrebindableObject); + origApp.sensors().set(MY_DYNAMIC_SENSOR, unrebindableObject); assertEquals(origApp.getAttribute(MY_DYNAMIC_SENSOR), unrebindableObject); newApp = rebind(); @@ -832,7 +832,7 @@ public class RebindEntityTest extends RebindTestFixtureWithApp { @Override public void onManagementStarting() { if (getConfig(SUBSCRIBE)) { - subscribe(getApplication(), TestApplication.MY_ATTRIBUTE, new SensorEventListener<String>() { + subscriptions().subscribe(getApplication(), TestApplication.MY_ATTRIBUTE, new SensorEventListener<String>() { @Override public void onEvent(SensorEvent<String> event) { events.add(event.getValue()); } @@ -905,7 +905,7 @@ public class RebindEntityTest extends RebindTestFixtureWithApp { } if (getConfig(PUBLISH) != null) { - setAttribute(MY_SENSOR, getConfig(PUBLISH)); + sensors().set(MY_SENSOR, getConfig(PUBLISH)); } if (latching) { http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4d08310c/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindFailuresTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindFailuresTest.java b/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindFailuresTest.java index e78f062..4ab2f1f 100644 --- a/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindFailuresTest.java +++ b/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindFailuresTest.java @@ -194,23 +194,23 @@ public class RebindFailuresTest extends RebindTestFixtureWithApp { @Test public void testRebindWithFailingPolicyContinuesWithoutPolicy() throws Exception { - origApp.addPolicy(PolicySpec.create(MyPolicyFailingImpl.class) + origApp.policies().add(PolicySpec.create(MyPolicyFailingImpl.class) .configure(MyPolicyFailingImpl.FAIL_ON_REBIND, true)); newApp = rebind(); - Optional<Policy> newPolicy = Iterables.tryFind(newApp.getPolicies(), Predicates.instanceOf(MyPolicyFailingImpl.class)); + Optional<Policy> newPolicy = Iterables.tryFind(newApp.policies(), Predicates.instanceOf(MyPolicyFailingImpl.class)); assertFalse(newPolicy.isPresent(), "policy="+newPolicy); } @Test public void testRebindWithFailingEnricherContinuesWithoutEnricher() throws Exception { - origApp.addEnricher(EnricherSpec.create(MyEnricherFailingImpl.class) + origApp.enrichers().add(EnricherSpec.create(MyEnricherFailingImpl.class) .configure(MyEnricherFailingImpl.FAIL_ON_REBIND, true)); newApp = rebind(); - Optional<Enricher> newEnricher = Iterables.tryFind(newApp.getEnrichers(), Predicates.instanceOf(MyEnricherFailingImpl.class)); + Optional<Enricher> newEnricher = Iterables.tryFind(newApp.enrichers(), Predicates.instanceOf(MyEnricherFailingImpl.class)); assertFalse(newEnricher.isPresent(), "enricher="+newEnricher); } http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4d08310c/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindFeedTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindFeedTest.java b/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindFeedTest.java index 4a724e4..1be1bb5 100644 --- a/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindFeedTest.java +++ b/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindFeedTest.java @@ -122,8 +122,8 @@ public class RebindFeedTest extends RebindTestFixtureWithApp { assertEquals(newFeeds.size(), 1); // Expect the feed to still be polling - newEntity.setAttribute(SENSOR_INT, null); - newEntity.setAttribute(SENSOR_STRING, null); + newEntity.sensors().set(SENSOR_INT, null); + newEntity.sensors().set(SENSOR_STRING, null); EntityTestUtils.assertAttributeEqualsEventually(newEntity, SENSOR_INT, (Integer)200); EntityTestUtils.assertAttributeEqualsEventually(newEntity, SENSOR_STRING, "{\"foo\":\"myfoo\"}"); @@ -153,7 +153,7 @@ public class RebindFeedTest extends RebindTestFixtureWithApp { assertEquals(newFeeds.size(), 2); // Expect the feed to still be polling - newEntity.setAttribute(SENSOR_INT, null); + newEntity.sensors().set(SENSOR_INT, null); EntityTestUtils.assertAttributeEqualsEventually(newEntity, SENSOR_INT, (Integer)1); } @@ -177,7 +177,7 @@ public class RebindFeedTest extends RebindTestFixtureWithApp { assertEquals(newFeeds.size(), 1); // Expect the feed to still be polling - newEntity.setAttribute(SENSOR_INT, null); + newEntity.sensors().set(SENSOR_INT, null); EntityTestUtils.assertAttributeEqualsEventually(newEntity, SENSOR_INT, (Integer)0); } http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4d08310c/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindFeedWithHaTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindFeedWithHaTest.java b/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindFeedWithHaTest.java index 9335bd4..502e098 100644 --- a/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindFeedWithHaTest.java +++ b/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindFeedWithHaTest.java @@ -117,8 +117,8 @@ public class RebindFeedWithHaTest extends RebindTestFixtureWithApp { assertEquals(newFeeds.size(), 1); // Expect the feed to still be polling - newEntity.setAttribute(SENSOR_INT, null); - newEntity.setAttribute(SENSOR_STRING, null); + newEntity.sensors().set(SENSOR_INT, null); + newEntity.sensors().set(SENSOR_STRING, null); EntityTestUtils.assertAttributeEqualsEventually(newEntity, SENSOR_INT, (Integer)200); EntityTestUtils.assertAttributeEqualsEventually(newEntity, SENSOR_STRING, "{\"foo\":\"myfoo\"}"); } http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4d08310c/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindManagerTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindManagerTest.java b/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindManagerTest.java index 29ec7c4..45589b1 100644 --- a/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindManagerTest.java +++ b/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindManagerTest.java @@ -56,7 +56,7 @@ public class RebindManagerTest extends RebindTestFixtureWithApp { .orSubmitAsync() .asTask() .getUnchecked(); - setAttribute(TestEntity.NAME, val); + sensors().set(TestEntity.NAME, val); } } } http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4d08310c/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindPolicyTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindPolicyTest.java b/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindPolicyTest.java index faff0c9..fb6446b 100644 --- a/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindPolicyTest.java +++ b/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindPolicyTest.java @@ -68,33 +68,33 @@ public class RebindPolicyTest extends RebindTestFixtureWithApp { @Test public void testRestoresSimplePolicyFromConstructor() throws Exception { MyPolicy origPolicy = new MyPolicy(MutableMap.of("myfield", "myFieldVal", "myconfigkey", "myConfigVal")); - origApp.addPolicy(origPolicy); + origApp.policies().add(origPolicy); runRestoresSimplePolicy(); } @Test public void testRestoresDeprecatedPolicyFromConstructorWithoutNoArgs() throws Exception { MyPolicyWithoutNoArgConstructor origPolicy = new MyPolicyWithoutNoArgConstructor(MutableMap.of("myfield", "myFieldVal", "myconfigkey", "myConfigVal")); - origApp.addPolicy(origPolicy); + origApp.policies().add(origPolicy); runRestoresSimplePolicy(); } @Test public void testRestoresSimplePolicyFromPolicySpec() throws Exception { - origApp.addPolicy(PolicySpec.create(MyPolicy.class) + origApp.policies().add(PolicySpec.create(MyPolicy.class) .configure("myfield", "myFieldVal") .configure(MyPolicy.MY_CONFIG, "myConfigVal")); runRestoresSimplePolicy(); } protected void runRestoresSimplePolicy() throws Exception { - MyPolicy origPolicy = (MyPolicy) Iterables.getOnlyElement(origApp.getPolicies()); + MyPolicy origPolicy = (MyPolicy) Iterables.getOnlyElement(origApp.policies()); assertTrue(origPolicy.isRunning()); assertTrue(origPolicy.initCalled); assertFalse(origPolicy.rebindCalled); newApp = rebind(); - MyPolicy newPolicy = (MyPolicy) Iterables.getOnlyElement(newApp.getPolicies()); + MyPolicy newPolicy = (MyPolicy) Iterables.getOnlyElement(newApp.policies()); assertEquals(newPolicy.myfield, "myFieldVal"); assertEquals(newPolicy.getConfig(MyPolicy.MY_CONFIG), "myConfigVal"); @@ -105,7 +105,7 @@ public class RebindPolicyTest extends RebindTestFixtureWithApp { @Test public void testRestoresConfig() throws Exception { - origApp.addPolicy(PolicySpec.create(MyPolicy.class) + origApp.policies().add(PolicySpec.create(MyPolicy.class) .displayName("My Policy") .uniqueTag("tagU") .tag("tag1").tag("tag2") @@ -114,7 +114,7 @@ public class RebindPolicyTest extends RebindTestFixtureWithApp { .configure(MyPolicy.MY_CONFIG_WITHOUT_SETFROMFLAG, "myVal for witout setFromFlag")); newApp = rebind(); - MyPolicy newPolicy = (MyPolicy) Iterables.getOnlyElement(newApp.getPolicies()); + MyPolicy newPolicy = (MyPolicy) Iterables.getOnlyElement(newApp.policies()); assertEquals(newPolicy.getDisplayName(), "My Policy"); @@ -130,8 +130,8 @@ public class RebindPolicyTest extends RebindTestFixtureWithApp { public void testExpungesOnEntityUnmanaged() throws Exception { Location loc = origManagementContext.getLocationRegistry().resolve("localhost"); TestEntity entity = origApp.createAndManageChild(EntitySpec.create(TestEntity.class)); - MyPolicy policy = entity.addPolicy(PolicySpec.create(MyPolicy.class)); - MyEnricher enricher = entity.addEnricher(EnricherSpec.create(MyEnricher.class)); + MyPolicy policy = entity.policies().add(PolicySpec.create(MyPolicy.class)); + MyEnricher enricher = entity.enrichers().add(EnricherSpec.create(MyEnricher.class)); RebindTestUtils.waitForPersisted(origApp); @@ -149,13 +149,13 @@ public class RebindPolicyTest extends RebindTestFixtureWithApp { @Test public void testExpungesOnPolicyRemoved() throws Exception { TestEntity entity = origApp.createAndManageChild(EntitySpec.create(TestEntity.class)); - MyPolicy policy = entity.addPolicy(PolicySpec.create(MyPolicy.class)); - MyEnricher enricher = entity.addEnricher(EnricherSpec.create(MyEnricher.class)); + MyPolicy policy = entity.policies().add(PolicySpec.create(MyPolicy.class)); + MyEnricher enricher = entity.enrichers().add(EnricherSpec.create(MyEnricher.class)); RebindTestUtils.waitForPersisted(origApp); - entity.removePolicy(policy); - entity.removeEnricher(enricher); + entity.policies().remove(policy); + entity.enrichers().remove(enricher); RebindTestUtils.waitForPersisted(origApp); BrooklynMementoManifest manifest = loadMementoManifest(); @@ -165,10 +165,10 @@ public class RebindPolicyTest extends RebindTestFixtureWithApp { @Test public void testReboundConfigDoesNotContainId() throws Exception { - MyPolicy policy = origApp.addPolicy(PolicySpec.create(MyPolicy.class)); + MyPolicy policy = origApp.policies().add(PolicySpec.create(MyPolicy.class)); newApp = rebind(); - MyPolicy newPolicy = (MyPolicy) Iterables.getOnlyElement(newApp.getPolicies()); + MyPolicy newPolicy = (MyPolicy) Iterables.getOnlyElement(newApp.policies()); assertNull(newPolicy.getConfig(ConfigKeys.newStringConfigKey("id"))); assertEquals(newPolicy.getId(), policy.getId()); @@ -176,22 +176,22 @@ public class RebindPolicyTest extends RebindTestFixtureWithApp { @Test public void testReconfigurePolicyPersistsChange() throws Exception { - MyPolicyReconfigurable policy = origApp.addPolicy(PolicySpec.create(MyPolicyReconfigurable.class) + MyPolicyReconfigurable policy = origApp.policies().add(PolicySpec.create(MyPolicyReconfigurable.class) .configure(MyPolicyReconfigurable.MY_CONFIG, "oldval")); policy.config().set(MyPolicyReconfigurable.MY_CONFIG, "newval"); newApp = rebind(); - MyPolicyReconfigurable newPolicy = (MyPolicyReconfigurable) Iterables.getOnlyElement(newApp.getPolicies()); + MyPolicyReconfigurable newPolicy = (MyPolicyReconfigurable) Iterables.getOnlyElement(newApp.policies()); assertEquals(newPolicy.getConfig(MyPolicyReconfigurable.MY_CONFIG), "newval"); } @Test public void testIsRebinding() throws Exception { - origApp.addPolicy(PolicySpec.create(PolicyChecksIsRebinding.class)); + origApp.policies().add(PolicySpec.create(PolicyChecksIsRebinding.class)); newApp = rebind(); - PolicyChecksIsRebinding newPolicy = (PolicyChecksIsRebinding) Iterables.getOnlyElement(newApp.getPolicies()); + PolicyChecksIsRebinding newPolicy = (PolicyChecksIsRebinding) Iterables.getOnlyElement(newApp.policies()); assertTrue(newPolicy.isRebindingValWhenRebinding()); assertFalse(newPolicy.isRebinding()); @@ -199,12 +199,12 @@ public class RebindPolicyTest extends RebindTestFixtureWithApp { @Test public void testPolicyTags() throws Exception { - Policy origPolicy = origApp.addPolicy(PolicySpec.create(MyPolicy.class)); + Policy origPolicy = origApp.policies().add(PolicySpec.create(MyPolicy.class)); origPolicy.tags().addTag("foo"); origPolicy.tags().addTag(origApp); newApp = rebind(); - Policy newPolicy = Iterables.getOnlyElement(newApp.getPolicies()); + Policy newPolicy = Iterables.getOnlyElement(newApp.policies()); Asserts.assertEqualsIgnoringOrder(newPolicy.tags().getTags(), ImmutableSet.of("foo", newApp)); } @@ -224,14 +224,14 @@ public class RebindPolicyTest extends RebindTestFixtureWithApp { TestEntity origEntity = origApp.createAndManageChild(EntitySpec.create(TestEntity.class)); origGroup.addMember(origEntity); - EnricherChecksEntityHierarchy origEnricher = origApp.addEnricher(EnricherSpec.create(EnricherChecksEntityHierarchy.class)); - PolicyChecksEntityHierarchy origPolicy = origApp.addPolicy(PolicySpec.create(PolicyChecksEntityHierarchy.class)); + EnricherChecksEntityHierarchy origEnricher = origApp.enrichers().add(EnricherSpec.create(EnricherChecksEntityHierarchy.class)); + PolicyChecksEntityHierarchy origPolicy = origApp.policies().add(PolicySpec.create(PolicyChecksEntityHierarchy.class)); assertTrue(origEnricher.success); assertTrue(origPolicy.success); newApp = (TestApplication) rebind(); - EnricherChecksEntityHierarchy newEnricher = (EnricherChecksEntityHierarchy) Iterables.getOnlyElement(newApp.getEnrichers()); - PolicyChecksEntityHierarchy newPolicy = (PolicyChecksEntityHierarchy) Iterables.getOnlyElement(newApp.getPolicies()); + EnricherChecksEntityHierarchy newEnricher = (EnricherChecksEntityHierarchy) Iterables.getOnlyElement(newApp.enrichers()); + PolicyChecksEntityHierarchy newPolicy = (PolicyChecksEntityHierarchy) Iterables.getOnlyElement(newApp.policies()); assertTrue(newEnricher.success); assertTrue(newPolicy.success); http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4d08310c/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/transformer/CompoundTransformerTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/transformer/CompoundTransformerTest.java b/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/transformer/CompoundTransformerTest.java index ae87123..ef4e468 100644 --- a/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/transformer/CompoundTransformerTest.java +++ b/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/transformer/CompoundTransformerTest.java @@ -172,7 +172,7 @@ public class CompoundTransformerTest extends RebindTestFixtureWithApp { public void testRenameClass() throws Exception { ConfigKey<Object> CONF1 = new BasicConfigKey<Object>(Object.class, "test.conf1"); - origApp.setConfig(CONF1, new OrigType("myfieldval")); + origApp.config().set(CONF1, new OrigType("myfieldval")); CompoundTransformer transformer = CompoundTransformer.builder() .renameClassTag(OrigType.class.getName(), RenamedType.class.getName()) @@ -189,7 +189,7 @@ public class CompoundTransformerTest extends RebindTestFixtureWithApp { ConfigKey<Object> CONF1 = new BasicConfigKey<Object>(Object.class, "test.conf1"); Predicate<Entity> origPredicate = idEqualTo(origApp.getId()); - origApp.setConfig(CONF1, origPredicate); + origApp.config().set(CONF1, origPredicate); CompoundTransformer transformer = CompoundTransformer.builder() .renameClassTag(origPredicate.getClass().getName(), RenamedIdEqualToPredicate.class.getName()) http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4d08310c/core/src/test/java/org/apache/brooklyn/core/policy/basic/BasicPolicyTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/brooklyn/core/policy/basic/BasicPolicyTest.java b/core/src/test/java/org/apache/brooklyn/core/policy/basic/BasicPolicyTest.java index 5feae60..db97c10 100644 --- a/core/src/test/java/org/apache/brooklyn/core/policy/basic/BasicPolicyTest.java +++ b/core/src/test/java/org/apache/brooklyn/core/policy/basic/BasicPolicyTest.java @@ -60,7 +60,7 @@ public class BasicPolicyTest extends BrooklynAppUnitTestSupport { policy.setDisplayName("Bob"); policy.config().set(MyPolicy.STR_KEY, "aval"); policy.config().set(MyPolicy.INT_KEY, 2); - app.addPolicy(policy); + app.policies().add(policy); assertEquals(policy.getDisplayName(), "Bob"); assertEquals(policy.getConfig(MyPolicy.STR_KEY), "aval"); @@ -69,7 +69,7 @@ public class BasicPolicyTest extends BrooklynAppUnitTestSupport { @Test public void testAddSpec() throws Exception { - MyPolicy policy = app.addPolicy(PolicySpec.create(MyPolicy.class) + MyPolicy policy = app.policies().add(PolicySpec.create(MyPolicy.class) .displayName("Bob") .configure(MyPolicy.STR_KEY, "aval").configure(MyPolicy.INT_KEY, 2)); @@ -80,7 +80,7 @@ public class BasicPolicyTest extends BrooklynAppUnitTestSupport { @Test public void testTagsFromSpec() throws Exception { - MyPolicy policy = app.addPolicy(PolicySpec.create(MyPolicy.class).tag(99).uniqueTag("x")); + MyPolicy policy = app.policies().add(PolicySpec.create(MyPolicy.class).tag(99).uniqueTag("x")); assertEquals(policy.tags().getTags(), MutableSet.of("x", 99)); assertEquals(policy.getUniqueTag(), "x"); http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4d08310c/core/src/test/java/org/apache/brooklyn/core/policy/basic/PolicyConfigTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/brooklyn/core/policy/basic/PolicyConfigTest.java b/core/src/test/java/org/apache/brooklyn/core/policy/basic/PolicyConfigTest.java index 0b5c877..7f9fd9c 100644 --- a/core/src/test/java/org/apache/brooklyn/core/policy/basic/PolicyConfigTest.java +++ b/core/src/test/java/org/apache/brooklyn/core/policy/basic/PolicyConfigTest.java @@ -50,7 +50,7 @@ public class PolicyConfigTest extends BrooklynAppUnitTestSupport { .put("strKey", "aval") .put("intKey", 2) .build()); - app.addPolicy(policy); + app.policies().add(policy); assertEquals(policy.getConfig(MyPolicy.STR_KEY), "aval"); assertEquals(policy.getConfig(MyPolicy.INT_KEY), (Integer)2); @@ -64,7 +64,7 @@ public class PolicyConfigTest extends BrooklynAppUnitTestSupport { MyPolicy policy = new MyPolicy(MutableMap.builder() .put(differentKey, "aval") .build()); - app.addPolicy(policy); + app.policies().add(policy); assertEquals(policy.getConfig(differentKey), null); assertEquals(policy.getPolicyType().getConfigKey(differentKey.getName()), null); @@ -76,7 +76,7 @@ public class PolicyConfigTest extends BrooklynAppUnitTestSupport { .put(MyPolicy.STR_KEY, "aval") .put(MyPolicy.INT_KEY, 2) .build()); - app.addPolicy(policy); + app.policies().add(policy); assertEquals(policy.getConfig(MyPolicy.STR_KEY), "aval"); assertEquals(policy.getConfig(MyPolicy.INT_KEY), (Integer)2); @@ -89,7 +89,7 @@ public class PolicyConfigTest extends BrooklynAppUnitTestSupport { MyPolicy policy = new MyPolicy(MutableMap.builder() .put(MyPolicy.INT_KEY_WITH_DEFAULT, 0) .build()); - app.addPolicy(policy); + app.policies().add(policy); assertEquals(policy.getConfig(MyPolicy.INT_KEY_WITH_DEFAULT), (Integer)0); } @@ -99,7 +99,7 @@ public class PolicyConfigTest extends BrooklynAppUnitTestSupport { MyPolicy policy = new MyPolicy(MutableMap.builder() .put(MyPolicy.STR_KEY_WITH_DEFAULT, null) .build()); - app.addPolicy(policy); + app.policies().add(policy); assertEquals(policy.getConfig(MyPolicy.STR_KEY_WITH_DEFAULT), null); } @@ -109,7 +109,7 @@ public class PolicyConfigTest extends BrooklynAppUnitTestSupport { MyPolicy policy = new MyPolicy(); policy.config().set(MyPolicy.STR_KEY, "aval"); policy.config().set(MyPolicy.INT_KEY, 2); - app.addPolicy(policy); + app.policies().add(policy); assertEquals(policy.getConfig(MyPolicy.STR_KEY), "aval"); assertEquals(policy.getConfig(MyPolicy.INT_KEY), (Integer)2); @@ -121,7 +121,7 @@ public class PolicyConfigTest extends BrooklynAppUnitTestSupport { .put(MyPolicy.STR_KEY, "aval") .build()); policy.config().set(MyPolicy.STR_KEY, "diffval"); - app.addPolicy(policy); + app.policies().add(policy); assertEquals(policy.getConfig(MyPolicy.STR_KEY), "diffval"); } @@ -131,7 +131,7 @@ public class PolicyConfigTest extends BrooklynAppUnitTestSupport { MyPolicy policy = new MyPolicy(MutableMap.builder() .put(MyPolicy.STR_KEY, "origval") .build()); - app.addPolicy(policy); + app.policies().add(policy); try { policy.config().set(MyPolicy.STR_KEY,"newval"); @@ -146,7 +146,7 @@ public class PolicyConfigTest extends BrooklynAppUnitTestSupport { @Test public void testConfigReturnsDefaultValueIfNotSet() throws Exception { MyPolicy policy = new MyPolicy(); - app.addPolicy(policy); + app.policies().add(policy); assertEquals(policy.getConfig(MyPolicy.STR_KEY_WITH_DEFAULT), "str key default"); } @@ -157,7 +157,7 @@ public class PolicyConfigTest extends BrooklynAppUnitTestSupport { MyPolicy policy = new MyPolicy(MutableMap.builder() .put(TestEntity.CONF_NAME, DependentConfiguration.whenDone(Callables.returning("aval"))) .build()); - app.addPolicy(policy); + app.policies().add(policy); assertEquals(policy.getConfig(TestEntity.CONF_NAME), "aval"); } @@ -176,7 +176,7 @@ public class PolicyConfigTest extends BrooklynAppUnitTestSupport { } }})) .build()); - app.addPolicy(policy); + app.policies().add(policy); Thread t = new Thread(new Runnable() { public void run() { http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4d08310c/core/src/test/java/org/apache/brooklyn/core/policy/basic/PolicySubscriptionTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/brooklyn/core/policy/basic/PolicySubscriptionTest.java b/core/src/test/java/org/apache/brooklyn/core/policy/basic/PolicySubscriptionTest.java index 0a7b003..fbe6105 100644 --- a/core/src/test/java/org/apache/brooklyn/core/policy/basic/PolicySubscriptionTest.java +++ b/core/src/test/java/org/apache/brooklyn/core/policy/basic/PolicySubscriptionTest.java @@ -56,15 +56,15 @@ public class PolicySubscriptionTest extends BrooklynAppUnitTestSupport { otherEntity = app.createAndManageChild(EntitySpec.create(TestEntity.class)); listener = new RecordingSensorEventListener<>(); policy = new AbstractPolicy() {}; - entity.addPolicy(policy); + entity.policies().add(policy); app.start(ImmutableList.of(loc)); } @Test public void testSubscriptionReceivesEvents() throws Exception { - policy.subscribe(entity, TestEntity.SEQUENCE, listener); - policy.subscribe(entity, TestEntity.NAME, listener); - policy.subscribe(entity, TestEntity.MY_NOTIF, listener); + policy.subscriptions().subscribe(entity, TestEntity.SEQUENCE, listener); + policy.subscriptions().subscribe(entity, TestEntity.NAME, listener); + policy.subscriptions().subscribe(entity, TestEntity.MY_NOTIF, listener); otherEntity.sensors().set(TestEntity.SEQUENCE, 456); entity.sensors().set(TestEntity.SEQUENCE, 123); @@ -82,11 +82,11 @@ public class PolicySubscriptionTest extends BrooklynAppUnitTestSupport { @Test public void testUnsubscribeRemovesAllSubscriptionsForThatEntity() throws Exception { - policy.subscribe(entity, TestEntity.SEQUENCE, listener); - policy.subscribe(entity, TestEntity.NAME, listener); - policy.subscribe(entity, TestEntity.MY_NOTIF, listener); - policy.subscribe(otherEntity, TestEntity.SEQUENCE, listener); - policy.unsubscribe(entity); + policy.subscriptions().subscribe(entity, TestEntity.SEQUENCE, listener); + policy.subscriptions().subscribe(entity, TestEntity.NAME, listener); + policy.subscriptions().subscribe(entity, TestEntity.MY_NOTIF, listener); + policy.subscriptions().subscribe(otherEntity, TestEntity.SEQUENCE, listener); + policy.subscriptions().unsubscribe(entity); entity.sensors().set(TestEntity.SEQUENCE, 123); entity.sensors().set(TestEntity.NAME, "myname"); @@ -103,11 +103,11 @@ public class PolicySubscriptionTest extends BrooklynAppUnitTestSupport { @Test public void testUnsubscribeUsingHandleStopsEvents() throws Exception { - SubscriptionHandle handle1 = policy.subscribe(entity, TestEntity.SEQUENCE, listener); - SubscriptionHandle handle2 = policy.subscribe(entity, TestEntity.NAME, listener); - SubscriptionHandle handle3 = policy.subscribe(otherEntity, TestEntity.SEQUENCE, listener); + SubscriptionHandle handle1 = policy.subscriptions().subscribe(entity, TestEntity.SEQUENCE, listener); + SubscriptionHandle handle2 = policy.subscriptions().subscribe(entity, TestEntity.NAME, listener); + SubscriptionHandle handle3 = policy.subscriptions().subscribe(otherEntity, TestEntity.SEQUENCE, listener); - policy.unsubscribe(entity, handle2); + policy.subscriptions().unsubscribe(entity, handle2); entity.sensors().set(TestEntity.SEQUENCE, 123); entity.sensors().set(TestEntity.NAME, "myname"); @@ -142,8 +142,8 @@ public class PolicySubscriptionTest extends BrooklynAppUnitTestSupport { entity.sensors().set(TestEntity.SEQUENCE, 123); entity.sensors().set(TestEntity.NAME, "myname"); - policy.subscribe(entity, TestEntity.SEQUENCE, listener); - policy.subscribe(entity, TestEntity.NAME, listener); + policy.subscriptions().subscribe(entity, TestEntity.SEQUENCE, listener); + policy.subscriptions().subscribe(entity, TestEntity.NAME, listener); Asserts.succeedsContinually(ImmutableMap.of("timeout", SHORT_WAIT_MS), new Runnable() { @Override public void run() { http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4d08310c/core/src/test/java/org/apache/brooklyn/core/sensor/http/HttpRequestSensorTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/brooklyn/core/sensor/http/HttpRequestSensorTest.java b/core/src/test/java/org/apache/brooklyn/core/sensor/http/HttpRequestSensorTest.java index 2fda742..0e7495f 100644 --- a/core/src/test/java/org/apache/brooklyn/core/sensor/http/HttpRequestSensorTest.java +++ b/core/src/test/java/org/apache/brooklyn/core/sensor/http/HttpRequestSensorTest.java @@ -77,7 +77,7 @@ public class HttpRequestSensorTest { .configure(HttpRequestSensor.JSON_PATH, "$.myKey") .configure(HttpRequestSensor.SENSOR_URI, serverUrl + "/myKey/myValue")); sensor.apply(entity); - entity.setAttribute(Attributes.SERVICE_UP, true); + entity.sensors().set(Attributes.SERVICE_UP, true); EntityTestUtils.assertAttributeEqualsEventually(entity, SENSOR_STRING, "myValue"); } http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4d08310c/core/src/test/java/org/apache/brooklyn/core/sensor/ssh/SshCommandSensorIntegrationTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/brooklyn/core/sensor/ssh/SshCommandSensorIntegrationTest.java b/core/src/test/java/org/apache/brooklyn/core/sensor/ssh/SshCommandSensorIntegrationTest.java index bdb4a81..54af885 100644 --- a/core/src/test/java/org/apache/brooklyn/core/sensor/ssh/SshCommandSensorIntegrationTest.java +++ b/core/src/test/java/org/apache/brooklyn/core/sensor/ssh/SshCommandSensorIntegrationTest.java @@ -78,7 +78,7 @@ public class SshCommandSensorIntegrationTest { .configure(SshCommandSensor.SENSOR_COMMAND, "echo foo > "+tempFile.getAbsolutePath()+"\n" + "wc "+tempFile.getAbsolutePath())) .apply(entity); - entity.setAttribute(Attributes.SERVICE_UP, true); + entity.sensors().set(Attributes.SERVICE_UP, true); String val = EntityTestUtils.assertAttributeEventuallyNonNull(entity, SENSOR_STRING); assertTrue(val.contains("1"), "val="+val); http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4d08310c/core/src/test/java/org/apache/brooklyn/core/server/entity/BrooklynMetricsTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/brooklyn/core/server/entity/BrooklynMetricsTest.java b/core/src/test/java/org/apache/brooklyn/core/server/entity/BrooklynMetricsTest.java index 49cab1e..73515ba 100644 --- a/core/src/test/java/org/apache/brooklyn/core/server/entity/BrooklynMetricsTest.java +++ b/core/src/test/java/org/apache/brooklyn/core/server/entity/BrooklynMetricsTest.java @@ -108,8 +108,8 @@ public class BrooklynMetricsTest { // Setting attribute causes event to be published and delivered to the subscriber // Note that the brooklyn metrics entity itself is also publishing sensors - app.subscribe(e, TestEntity.SEQUENCE, SensorEventListener.NOOP); - e.setAttribute(TestEntity.SEQUENCE, 1); + app.subscriptions().subscribe(e, TestEntity.SEQUENCE, SensorEventListener.NOOP); + e.sensors().set(TestEntity.SEQUENCE, 1); Asserts.succeedsEventually(MutableMap.of("timeout", Duration.FIVE_SECONDS), new Runnable() { public void run() { http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4d08310c/core/src/test/java/org/apache/brooklyn/core/test/entity/TestClusterImpl.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/brooklyn/core/test/entity/TestClusterImpl.java b/core/src/test/java/org/apache/brooklyn/core/test/entity/TestClusterImpl.java index debe110..bf8d0cb 100644 --- a/core/src/test/java/org/apache/brooklyn/core/test/entity/TestClusterImpl.java +++ b/core/src/test/java/org/apache/brooklyn/core/test/entity/TestClusterImpl.java @@ -35,7 +35,7 @@ public class TestClusterImpl extends DynamicClusterImpl implements TestCluster { public void init() { super.init(); size = getConfig(INITIAL_SIZE); - setAttribute(Startable.SERVICE_UP, true); + sensors().set(Startable.SERVICE_UP, true); } @Override http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4d08310c/core/src/test/java/org/apache/brooklyn/core/test/entity/TestEntityImpl.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/brooklyn/core/test/entity/TestEntityImpl.java b/core/src/test/java/org/apache/brooklyn/core/test/entity/TestEntityImpl.java index 786c908..6c3b913 100644 --- a/core/src/test/java/org/apache/brooklyn/core/test/entity/TestEntityImpl.java +++ b/core/src/test/java/org/apache/brooklyn/core/test/entity/TestEntityImpl.java @@ -115,7 +115,7 @@ public class TestEntityImpl extends AbstractEntity implements TestEntity { @Override public synchronized void setSequenceValue(int value) { sequenceValue = value; - setAttribute(SEQUENCE, value); + sensors().set(SEQUENCE, value); } @Override @@ -125,7 +125,7 @@ public class TestEntityImpl extends AbstractEntity implements TestEntity { ServiceStateLogic.setExpectedState(this, Lifecycle.STARTING); counter.incrementAndGet(); addLocations(locs); - setAttribute(SERVICE_UP, true); + sensors().set(SERVICE_UP, true); ServiceStateLogic.setExpectedState(this, Lifecycle.RUNNING); } @@ -135,7 +135,7 @@ public class TestEntityImpl extends AbstractEntity implements TestEntity { callHistory.add("stop"); ServiceStateLogic.setExpectedState(this, Lifecycle.STOPPING); counter.decrementAndGet(); - setAttribute(SERVICE_UP, false); + sensors().set(SERVICE_UP, false); ServiceStateLogic.setExpectedState(this, Lifecycle.STOPPED); } http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4d08310c/core/src/test/java/org/apache/brooklyn/core/test/qa/longevity/EntityCleanupLongevityTestFixture.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/brooklyn/core/test/qa/longevity/EntityCleanupLongevityTestFixture.java b/core/src/test/java/org/apache/brooklyn/core/test/qa/longevity/EntityCleanupLongevityTestFixture.java index 8fad0ae..69af3ce 100644 --- a/core/src/test/java/org/apache/brooklyn/core/test/qa/longevity/EntityCleanupLongevityTestFixture.java +++ b/core/src/test/java/org/apache/brooklyn/core/test/qa/longevity/EntityCleanupLongevityTestFixture.java @@ -164,11 +164,11 @@ public abstract class EntityCleanupLongevityTestFixture { protected TestApplication newApp() { final TestApplication result = ApplicationBuilder.newManagedApp(TestApplication.class, managementContext); TestEntity entity = result.createAndManageChild(EntitySpec.create(TestEntity.class)); - result.subscribe(entity, TestEntity.NAME, new SensorEventListener<String>() { + result.subscriptions().subscribe(entity, TestEntity.NAME, new SensorEventListener<String>() { @Override public void onEvent(SensorEvent<String> event) { - result.setAttribute(TestApplication.MY_ATTRIBUTE, event.getValue()); + result.sensors().set(TestApplication.MY_ATTRIBUTE, event.getValue()); }}); - entity.setAttribute(TestEntity.NAME, "myname"); + entity.sensors().set(TestEntity.NAME, "myname"); return result; } } http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4d08310c/core/src/test/java/org/apache/brooklyn/core/test/qa/performance/EntityPerformanceTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/brooklyn/core/test/qa/performance/EntityPerformanceTest.java b/core/src/test/java/org/apache/brooklyn/core/test/qa/performance/EntityPerformanceTest.java index aa9f7ff..16707d0 100644 --- a/core/src/test/java/org/apache/brooklyn/core/test/qa/performance/EntityPerformanceTest.java +++ b/core/src/test/java/org/apache/brooklyn/core/test/qa/performance/EntityPerformanceTest.java @@ -71,7 +71,7 @@ public class EntityPerformanceTest extends AbstractPerformanceTest { measureAndAssert("updateAttribute", numIterations, minRatePerSec, new Runnable() { public void run() { - entity.setAttribute(TestEntity.SEQUENCE, i.getAndIncrement()); + entity.sensors().set(TestEntity.SEQUENCE, i.getAndIncrement()); }}); } @@ -82,14 +82,14 @@ public class EntityPerformanceTest extends AbstractPerformanceTest { final AtomicInteger i = new AtomicInteger(); final AtomicInteger lastVal = new AtomicInteger(); - app.subscribe(entity, TestEntity.SEQUENCE, new SensorEventListener<Integer>() { + app.subscriptions().subscribe(entity, TestEntity.SEQUENCE, new SensorEventListener<Integer>() { @Override public void onEvent(SensorEvent<Integer> event) { lastVal.set(event.getValue()); }}); measureAndAssert("updateAttributeWithListener", numIterations, minRatePerSec, new Runnable() { public void run() { - entity.setAttribute(TestEntity.SEQUENCE, (i.getAndIncrement())); + entity.sensors().set(TestEntity.SEQUENCE, (i.getAndIncrement())); }}); Asserts.succeedsEventually(MutableMap.of("timeout", TIMEOUT_MS), new Runnable() { http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4d08310c/core/src/test/java/org/apache/brooklyn/core/test/qa/performance/EntityPersistencePerformanceTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/brooklyn/core/test/qa/performance/EntityPersistencePerformanceTest.java b/core/src/test/java/org/apache/brooklyn/core/test/qa/performance/EntityPersistencePerformanceTest.java index 11a965e..bbd10c9 100644 --- a/core/src/test/java/org/apache/brooklyn/core/test/qa/performance/EntityPersistencePerformanceTest.java +++ b/core/src/test/java/org/apache/brooklyn/core/test/qa/performance/EntityPersistencePerformanceTest.java @@ -70,7 +70,7 @@ public class EntityPersistencePerformanceTest extends RebindTestFixtureWithApp { for (int i = 0; i < numEntities; i++) { TestEntity entity = origApp.createAndManageChild(EntitySpec.create(TestEntity.class)); - entity.addPolicy(PolicySpec.create(TestPolicy.class)); + entity.policies().add(PolicySpec.create(TestPolicy.class)); SimulatedLocation loc = origManagementContext.getLocationManager().createLocation(LocationSpec.create(SimulatedLocation.class)); entities.add(entity); locs.add(loc); @@ -84,9 +84,9 @@ public class EntityPersistencePerformanceTest extends RebindTestFixtureWithApp { int i = 0; public void run() { for (TestEntity entity : entities) { - entity.setAttribute(TestEntity.SEQUENCE, i++); - Policy policy = Iterables.find(entity.getPolicies(), Predicates.instanceOf(TestPolicy.class)); - policy.setConfig(TestPolicy.CONF_NAME, "name-"+i); + entity.sensors().set(TestEntity.SEQUENCE, i++); + Policy policy = Iterables.find(entity.policies(), Predicates.instanceOf(TestPolicy.class)); + policy.config().set(TestPolicy.CONF_NAME, "name-"+i); } }}) .limitTimeTo(testLength) http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4d08310c/core/src/test/java/org/apache/brooklyn/enricher/stock/CustomAggregatingEnricherDeprecatedTest.groovy ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/brooklyn/enricher/stock/CustomAggregatingEnricherDeprecatedTest.groovy b/core/src/test/java/org/apache/brooklyn/enricher/stock/CustomAggregatingEnricherDeprecatedTest.groovy index 68d6804..72acb74 100644 --- a/core/src/test/java/org/apache/brooklyn/enricher/stock/CustomAggregatingEnricherDeprecatedTest.groovy +++ b/core/src/test/java/org/apache/brooklyn/enricher/stock/CustomAggregatingEnricherDeprecatedTest.groovy @@ -69,7 +69,7 @@ class CustomAggregatingEnricherDeprecatedTest { @Test public void testEnrichersWithNoProducers() { CustomAggregatingEnricher<Integer> cae = CustomAggregatingEnricher.<Integer>newSummingEnricher([:], intSensor, target, 11, 40) - producer.addEnricher(cae) + producer.enrichers().add(cae) assertEquals cae.getAggregate(), 40 } @@ -77,7 +77,7 @@ class CustomAggregatingEnricherDeprecatedTest { public void testSummingEnricherWhenNoSensorValuesYet() { CustomAggregatingEnricher<Integer> cae = CustomAggregatingEnricher.<Integer>newSummingEnricher( intSensor, target, producers:[producer], 11, 40) - producer.addEnricher(cae) + producer.enrichers().add(cae) assertEquals cae.getAggregate(), 11 } @@ -85,7 +85,7 @@ class CustomAggregatingEnricherDeprecatedTest { public void testSingleProducerSum() { CustomAggregatingEnricher<Integer> cae = CustomAggregatingEnricher.<Integer>newSummingEnricher( intSensor, target, null, null, producers:[producer]) - producer.addEnricher(cae) + producer.enrichers().add(cae) assertEquals cae.getAggregate(), null cae.onEvent(intSensor.newEvent(producer, 1)) assertEquals cae.getAggregate(), 1 @@ -95,7 +95,7 @@ class CustomAggregatingEnricherDeprecatedTest { public void testSummingEnricherWhenNoAndNullSensorValue() { CustomAggregatingEnricher<Integer> cae = CustomAggregatingEnricher.<Integer>newSummingEnricher( intSensor, target, null, null, producers:[producer]) - producer.addEnricher(cae) + producer.enrichers().add(cae) assertEquals cae.getAggregate(), null cae.onEvent(intSensor.newEvent(producer, null)) assertEquals cae.getAggregate(), null @@ -105,7 +105,7 @@ class CustomAggregatingEnricherDeprecatedTest { public void testSummingEnricherWhenNoAndNullSensorValueExplicitValue() { CustomAggregatingEnricher<Integer> cae = CustomAggregatingEnricher.<Integer>newSummingEnricher( intSensor, target, 3 /** if null */, 5 /** if none */, producers:[producer]) - producer.addEnricher(cae) + producer.enrichers().add(cae) assertEquals cae.getAggregate(), 3 cae.onEvent(intSensor.newEvent(producer, null)) assertEquals cae.getAggregate(), 3 @@ -125,7 +125,7 @@ class CustomAggregatingEnricherDeprecatedTest { CustomAggregatingEnricher<Integer> cae = CustomAggregatingEnricher.<Integer>newSummingEnricher( intSensor, target, null, null, producers:producers) - producer.addEnricher(cae) + producer.enrichers().add(cae) assertEquals cae.getAggregate(), null cae.onEvent(intSensor.newEvent(producers[2], 1)) assertEquals cae.getAggregate(), 1 @@ -143,7 +143,7 @@ class CustomAggregatingEnricherDeprecatedTest { ] CustomAggregatingEnricher<Double> cae = CustomAggregatingEnricher.<Double>newAveragingEnricher( intSensor, new BasicAttributeSensor<Double>(Double.class, "target sensor"), null, null, producers:producers) - producer.addEnricher(cae) + producer.enrichers().add(cae) assertEquals cae.getAggregate(), null cae.onEvent(intSensor.newEvent(producers[0], null)) assertEquals cae.getAggregate(), null @@ -157,7 +157,7 @@ class CustomAggregatingEnricherDeprecatedTest { CustomAggregatingEnricher<Double> cae = CustomAggregatingEnricher.<Double>newAveragingEnricher( intSensor, new BasicAttributeSensor<Double>(Double.class, "target sensor"), 3 /** if null */, 5 /** if none */, producers:producers) - producer.addEnricher(cae) + producer.enrichers().add(cae) assertEquals cae.getAggregate(), 3d cae.onEvent(intSensor.newEvent(producers[0], null)) @@ -173,7 +173,7 @@ class CustomAggregatingEnricherDeprecatedTest { CustomAggregatingEnricher<Double> cae = CustomAggregatingEnricher.<Double>newAveragingEnricher( intSensor, new BasicAttributeSensor<Double>(Double.class, "target sensor"), 3 /** if null */, 5 /** if none */, producers:producers) - producer.addEnricher(cae) + producer.enrichers().add(cae) assertEquals cae.getAggregate(), 5d } @@ -188,7 +188,7 @@ class CustomAggregatingEnricherDeprecatedTest { CustomAggregatingEnricher<Double> cae = CustomAggregatingEnricher.<Double>newAveragingEnricher( intSensor, new BasicAttributeSensor<Double>(Double.class, "target sensor"), null, null, producers:producers) - producer.addEnricher(cae) + producer.enrichers().add(cae) assertEquals cae.getAggregate(), null cae.onEvent(intSensor.newEvent(producers[0], 3)) @@ -215,7 +215,7 @@ class CustomAggregatingEnricherDeprecatedTest { CustomAggregatingEnricher<Double> cae = CustomAggregatingEnricher.<Double>newAveragingEnricher( intSensor, new BasicAttributeSensor<Double>(Double.class, "target sensor"), 0, 0, producers:producers) - producer.addEnricher(cae) + producer.enrichers().add(cae) assertEquals cae.getAggregate(), 0d cae.onEvent(intSensor.newEvent(producers[0], 3)) @@ -240,7 +240,7 @@ class CustomAggregatingEnricherDeprecatedTest { CustomAggregatingEnricher<Integer> cae = CustomAggregatingEnricher.<Integer>newSummingEnricher( intSensor, target, null, null, producers:[p1]) - producer.addEnricher(cae) + producer.enrichers().add(cae) assertEquals cae.getAggregate(), null // Event by initial producer @@ -265,18 +265,18 @@ class CustomAggregatingEnricherDeprecatedTest { log.debug("created $group and the entities it will contain $p1 $p2") CustomAggregatingEnricher<Integer> cae = CustomAggregatingEnricher.<Integer>newSummingEnricher(intSensor, target, 0, 0, allMembers:true) - group.addEnricher(cae) + group.enrichers().add(cae) assertEquals cae.getAggregate(), 0 group.addMember(p1) - p1.setAttribute(intSensor, 1) + p1.sensors().set(intSensor, 1) Asserts.succeedsEventually(timeout:TIMEOUT_MS) { assertEquals cae.getAggregate(), 1 } group.addMember(p2) - p2.setAttribute(intSensor, 2) + p2.sensors().set(intSensor, 2) Asserts.succeedsEventually(timeout:TIMEOUT_MS) { assertEquals cae.getAggregate(), 3 } @@ -306,15 +306,15 @@ class CustomAggregatingEnricherDeprecatedTest { TestEntity p2 = app.getManagementContext().getEntityManager().createEntity(EntitySpec.create(TestEntity.class).parent(group)); group.addMember(p1) group.addMember(p2) - p1.setAttribute(intSensor, 1) + p1.sensors().set(intSensor, 1) Entities.manage(group); CustomAggregatingEnricher<Integer> cae = CustomAggregatingEnricher.<Integer>newSummingEnricher(intSensor, target, null, null, allMembers:true) - group.addEnricher(cae) + group.enrichers().add(cae) assertEquals cae.getAggregate(), 1 - p2.setAttribute(intSensor, 2) + p2.sensors().set(intSensor, 2) Asserts.succeedsEventually(timeout:TIMEOUT_MS) { assertEquals cae.getAggregate(), 3 } @@ -333,12 +333,12 @@ class CustomAggregatingEnricherDeprecatedTest { TestEntity p3 = app.createAndManageChild(EntitySpec.create(TestEntity.class)); group.addMember(p1) group.addMember(p2) - p1.setAttribute(intSensor, 1) - p2.setAttribute(intSensor, 2) - p3.setAttribute(intSensor, 4) + p1.sensors().set(intSensor, 1) + p2.sensors().set(intSensor, 2) + p3.sensors().set(intSensor, 4) CustomAggregatingEnricher<Integer> cae = CustomAggregatingEnricher.<Integer>newSummingEnricher(intSensor, target, null, null, allMembers:true, filter:{it == p1}) - group.addEnricher(cae) + group.enrichers().add(cae) assertEquals cae.getAggregate(), 1 @@ -358,7 +358,7 @@ class CustomAggregatingEnricherDeprecatedTest { CustomAggregatingEnricher<Integer> cae = CustomAggregatingEnricher.<Integer>newEnricher( intSensor, target, aggregator, 0, producers:[p1]) - producer.addEnricher(cae) + producer.enrichers().add(cae) assertEquals cae.getAggregate(), 0 // Event by producer
