You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@metron.apache.org by an...@apache.org on 2019/03/25 05:34:49 UTC
[metron] branch master updated: METRON-2046 IS_EMPTY stellar
functions fails on empty map (anandsubbu) closes apache/metron#1363
This is an automated email from the ASF dual-hosted git repository.
anandsubbu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/metron.git
The following commit(s) were added to refs/heads/master by this push:
new af28bba METRON-2046 IS_EMPTY stellar functions fails on empty map (anandsubbu) closes apache/metron#1363
af28bba is described below
commit af28bba3a651f7a92642acd66db9b6d3a27d45d6
Author: anandsubbu <an...@gmail.com>
AuthorDate: Mon Mar 25 11:04:31 2019 +0530
METRON-2046 IS_EMPTY stellar functions fails on empty map (anandsubbu) closes apache/metron#1363
---
.../metron/stellar/dsl/functions/DataStructureFunctions.java | 3 +++
.../metron/stellar/dsl/functions/DataStructureFunctionsTest.java | 8 ++++++++
2 files changed, 11 insertions(+)
diff --git a/metron-stellar/stellar-common/src/main/java/org/apache/metron/stellar/dsl/functions/DataStructureFunctions.java b/metron-stellar/stellar-common/src/main/java/org/apache/metron/stellar/dsl/functions/DataStructureFunctions.java
index fa504a7..1cdcb84 100644
--- a/metron-stellar/stellar-common/src/main/java/org/apache/metron/stellar/dsl/functions/DataStructureFunctions.java
+++ b/metron-stellar/stellar-common/src/main/java/org/apache/metron/stellar/dsl/functions/DataStructureFunctions.java
@@ -163,6 +163,9 @@ public class DataStructureFunctions {
String val = (String) list.get(0);
return val == null || val.isEmpty() ? true : false;
}
+ else if(o instanceof Map) {
+ return (((Map)o).isEmpty());
+ }
else {
return o == null;
}
diff --git a/metron-stellar/stellar-common/src/test/java/org/apache/metron/stellar/dsl/functions/DataStructureFunctionsTest.java b/metron-stellar/stellar-common/src/test/java/org/apache/metron/stellar/dsl/functions/DataStructureFunctionsTest.java
index f9b0829..1af88ff 100644
--- a/metron-stellar/stellar-common/src/test/java/org/apache/metron/stellar/dsl/functions/DataStructureFunctionsTest.java
+++ b/metron-stellar/stellar-common/src/test/java/org/apache/metron/stellar/dsl/functions/DataStructureFunctionsTest.java
@@ -46,6 +46,10 @@ public class DataStructureFunctionsTest {
boolean empty = (boolean) isEmpty.apply(ImmutableList.of(1));
Assert.assertThat("should be false", empty, CoreMatchers.equalTo(false));
}
+ {
+ boolean empty = (boolean) isEmpty.apply(ImmutableList.of(ImmutableMap.of("mykey", "myvalue")));
+ Assert.assertThat("should be false", empty, CoreMatchers.equalTo(false));
+ }
}
@Test
@@ -63,6 +67,10 @@ public class DataStructureFunctionsTest {
boolean empty = (boolean) isEmpty.apply(ImmutableList.of(""));
Assert.assertThat("should be true", empty, CoreMatchers.equalTo(true));
}
+ {
+ boolean empty = (boolean) isEmpty.apply(ImmutableList.of(ImmutableMap.of()));
+ Assert.assertThat("should be true", empty, CoreMatchers.equalTo(true));
+ }
}
@Test