You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by al...@apache.org on 2014/10/31 13:32:52 UTC

[1/3] git commit: Adds failing test for DependentConfiguration.builder()..runNow()

Repository: incubator-brooklyn
Updated Branches:
  refs/heads/master 9eb58518c -> c34ebaa86


Adds failing test for DependentConfiguration.builder()..runNow()


Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/c599d760
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/c599d760
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/c599d760

Branch: refs/heads/master
Commit: c599d760c158ec4fbe0c861314e6d38dec8ae88e
Parents: 9eb5851
Author: Martin Harris <gi...@nakomis.com>
Authored: Fri Oct 31 12:12:12 2014 +0000
Committer: Martin Harris <gi...@nakomis.com>
Committed: Fri Oct 31 12:12:12 2014 +0000

----------------------------------------------------------------------
 .../entity/basic/DependentConfigurationTest.java     | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/c599d760/core/src/test/java/brooklyn/entity/basic/DependentConfigurationTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/entity/basic/DependentConfigurationTest.java b/core/src/test/java/brooklyn/entity/basic/DependentConfigurationTest.java
index db237ed..709ed8d 100644
--- a/core/src/test/java/brooklyn/entity/basic/DependentConfigurationTest.java
+++ b/core/src/test/java/brooklyn/entity/basic/DependentConfigurationTest.java
@@ -255,6 +255,21 @@ public class DependentConfigurationTest extends BrooklynAppUnitTestSupport {
     }
 
     @Test
+    public void testAttributeWhenReadyRunNowWithoutPostProcess() throws Exception {
+        Task<String> t  = submit(new Callable<String>() {
+            @Override
+            public String call() throws Exception {
+                return DependentConfiguration.builder()
+                        .attributeWhenReady(entity, TestEntity.NAME)
+                        .runNow();
+            }
+        });
+        entity.setAttribute(TestEntity.NAME, "myentity");
+        assertDoneEventually(t);
+        assertEquals(t.get(), "myentity");
+    }
+
+    @Test
     public void testAttributeWhenReadyAbortsWhenOnFireByDefault() {
         log.info("starting test "+JavaClassNames.niceClassAndMethod());
         final Task<String> t = submit(DependentConfiguration.builder()


[3/3] git commit: This closes #287

Posted by al...@apache.org.
This closes #287


Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/c34ebaa8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/c34ebaa8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/c34ebaa8

Branch: refs/heads/master
Commit: c34ebaa8635254a71cb2017a1da28d321107b69b
Parents: 9eb5851 95fc839
Author: Aled Sage <al...@gmail.com>
Authored: Fri Oct 31 12:32:34 2014 +0000
Committer: Aled Sage <al...@gmail.com>
Committed: Fri Oct 31 12:32:34 2014 +0000

----------------------------------------------------------------------
 .../brooklyn/event/basic/DependentConfiguration.java | 13 ++++++++-----
 .../entity/basic/DependentConfigurationTest.java     | 15 +++++++++++++++
 2 files changed, 23 insertions(+), 5 deletions(-)
----------------------------------------------------------------------



[2/3] git commit: Fixes DependentConfiguration.builder()...runNow()

Posted by al...@apache.org.
Fixes DependentConfiguration.builder()...runNow()


Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/95fc839a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/95fc839a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/95fc839a

Branch: refs/heads/master
Commit: 95fc839ae2062a0c1cc3d67483b9bf2d393d7e85
Parents: c599d76
Author: Martin Harris <gi...@nakomis.com>
Authored: Fri Oct 31 12:20:03 2014 +0000
Committer: Martin Harris <gi...@nakomis.com>
Committed: Fri Oct 31 12:20:03 2014 +0000

----------------------------------------------------------------------
 .../brooklyn/event/basic/DependentConfiguration.java   | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/95fc839a/core/src/main/java/brooklyn/event/basic/DependentConfiguration.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/event/basic/DependentConfiguration.java b/core/src/main/java/brooklyn/event/basic/DependentConfiguration.java
index fc85e0d..de45514 100644
--- a/core/src/main/java/brooklyn/event/basic/DependentConfiguration.java
+++ b/core/src/main/java/brooklyn/event/basic/DependentConfiguration.java
@@ -480,11 +480,7 @@ public class DependentConfiguration {
             return this;
         }
         public Task<V> build() {
-            checkNotNull(source, "Entity source");
-            checkNotNull(sensor, "Sensor");
-            if (readiness == null) readiness = GroovyJavaMethods.truthPredicate();
-            if (postProcess == null) postProcess = (Function) Functions.identity();
-            
+            validate();
             return new BasicTask<V>(
                     MutableMap.of("tag", "attributeWhenReady", "displayName", "retrieving sensor "+sensor.getName()+" from "+source.getDisplayName()), 
                     new Callable<V>() {
@@ -495,9 +491,16 @@ public class DependentConfiguration {
                     });
         }
         public V runNow() {
+            validate();
             T result = waitInTaskForAttributeReady(source, sensor, readiness, abortConditions, blockingDetails);
             return postProcess.apply(result);
         }
+        private void validate() {
+            checkNotNull(source, "Entity source");
+            checkNotNull(sensor, "Sensor");
+            if (readiness == null) readiness = GroovyJavaMethods.truthPredicate();
+            if (postProcess == null) postProcess = (Function) Functions.identity();
+        }
     }
 
     /**