Add testListExcludesBlank for aggregrator

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

Branch: refs/heads/master
Commit: 5d18f57e816d225fecc4c7b902e4c7c63d0f938a
Parents: b571592
Author: Aled Sage <aled.s...@gmail.com>
Authored: Fri Aug 4 19:18:47 2017 +0100
Committer: Aled Sage <aled.s...@gmail.com>
Committed: Fri Aug 4 19:23:48 2017 +0100

----------------------------------------------------------------------
 .../camp/brooklyn/AggregatorYamlTest.java       | 30 ++++++++++++++++++++
 .../enricher/stock/AbstractAggregator.java      |  3 +-
 2 files changed, 32 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/5d18f57e/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/AggregatorYamlTest.java
----------------------------------------------------------------------
diff --git 
a/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/AggregatorYamlTest.java
 
b/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/AggregatorYamlTest.java
index 578aab7..3326949 100644
--- 
a/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/AggregatorYamlTest.java
+++ 
b/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/AggregatorYamlTest.java
@@ -184,6 +184,36 @@ public class AggregatorYamlTest extends AbstractYamlTest {
     }
     
     @Test
+    public void testListExcludesBlank() throws Exception {
+        Entity app = createAndStartApplication(
+                "services:",
+                "- type: " + BasicApplication.class.getName(),
+                "  brooklyn.children:",
+                "    - type: " + TestEntity.class.getName(),
+                "    - type: " + TestEntity.class.getName(),
+                "  brooklyn.enrichers:",
+                "    - type: " + Aggregator.class.getName(),
+                "      brooklyn.config:",
+                "        "+Aggregator.SOURCE_SENSOR.getName()+": myVal",
+                "        "+Aggregator.TARGET_SENSOR.getName()+": myResult",
+                "        "+Aggregator.EXCLUDE_BLANK.getName()+": true",
+                "        "+Aggregator.TRANSFORMATION_UNTYPED.getName()+": 
list");
+        Entity child1 = Iterables.get(app.getChildren(), 0);
+        Entity child2 = Iterables.get(app.getChildren(), 1);
+
+        EntityAsserts.assertAttributeEqualsEventually(app, myResult, 
ImmutableList.of());
+
+        child1.sensors().set(myVal, "val1");
+        EntityAsserts.assertAttributeEqualsEventually(app, myResult, 
ImmutableList.of("val1"));
+        
+        child2.sensors().set(myVal, "val2");
+        EntityAsserts.assertAttributeEqualsEventually(app, myResult, 
ImmutableList.of("val1", "val2"));
+        
+        child1.sensors().set(myVal, null);
+        EntityAsserts.assertAttributeEqualsEventually(app, myResult, 
MutableList.of("val2"));
+    }
+    
+    @Test
     public void testFirst() throws Exception {
         Entity app = createAndStartApplication(
                 "services:",

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/5d18f57e/core/src/main/java/org/apache/brooklyn/enricher/stock/AbstractAggregator.java
----------------------------------------------------------------------
diff --git 
a/core/src/main/java/org/apache/brooklyn/enricher/stock/AbstractAggregator.java 
b/core/src/main/java/org/apache/brooklyn/enricher/stock/AbstractAggregator.java
index be80772..92363e6 100644
--- 
a/core/src/main/java/org/apache/brooklyn/enricher/stock/AbstractAggregator.java
+++ 
b/core/src/main/java/org/apache/brooklyn/enricher/stock/AbstractAggregator.java
@@ -80,7 +80,8 @@ public abstract class AbstractAggregator<T,U> extends 
AbstractEnricher implement
     public static final ConfigKey<Boolean> EXCLUDE_BLANK = 
ConfigKeys.newBooleanConfigKey(
             "enricher.aggregator.excludeBlank",
             "Whether explicit nulls or blank strings should be excluded 
(default false); " +
-                    "may only apply if no value filter set", false);
+                    "may only apply if no value filter set", 
+            false);
 
     protected Entity producer;
     protected Sensor<U> targetSensor;

Reply via email to