eagle-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From h..@apache.org
Subject incubator-eagle git commit: Add test case for MapComparator function
Date Mon, 29 Aug 2016 02:16:58 GMT
Repository: incubator-eagle
Updated Branches:
  refs/heads/develop 000b74604 -> a10eeb701


Add test case for MapComparator function

- Add test case for getAdded/getRemoved/getModified method

Author: joe-hj <joe.heju@gmail.com>

Closes #397 from joe-hj/ut.


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

Branch: refs/heads/develop
Commit: a10eeb7019b8eff964316b084c0b25b68bf58b44
Parents: 000b746
Author: joe-hj <joe.heju@gmail.com>
Authored: Mon Aug 29 10:16:38 2016 +0800
Committer: Hao Chen <hao@apache.org>
Committed: Mon Aug 29 10:16:38 2016 +0800

----------------------------------------------------------------------
 .../engine/router/TestAlertPublisherBolt.java   | 53 ++++++++++++++++++++
 .../src/test/resources/testPublishForAdd0.json  | 22 ++++++++
 .../src/test/resources/testPublishForAdd1.json  | 32 ++++++++++++
 .../test/resources/testPublishForMdyValue.json  | 22 ++++++++
 4 files changed, 129 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/a10eeb70/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/test/java/org/apache/eagle/alert/engine/router/TestAlertPublisherBolt.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/test/java/org/apache/eagle/alert/engine/router/TestAlertPublisherBolt.java
b/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/test/java/org/apache/eagle/alert/engine/router/TestAlertPublisherBolt.java
index 9989068..1854c41 100644
--- a/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/test/java/org/apache/eagle/alert/engine/router/TestAlertPublisherBolt.java
+++ b/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/test/java/org/apache/eagle/alert/engine/router/TestAlertPublisherBolt.java
@@ -78,6 +78,59 @@ public class TestAlertPublisherBolt {
         return alert;
     }
 
+
+    @Test
+    public void testMapComparatorAdded() {
+
+        PublishSpec spec1 = MetadataSerDeser.deserialize(getClass().getResourceAsStream("/testPublishForAdd1.json"),
PublishSpec.class);
+        PublishSpec spec2 = MetadataSerDeser.deserialize(getClass().getResourceAsStream("/testPublishForAdd0.json"),
PublishSpec.class);
+
+        Map<String, Publishment> map1 = new HashMap<>();
+        Map<String, Publishment> map2 = new HashMap<>();
+        spec1.getPublishments().forEach(p -> map1.put(p.getName(), p));
+        spec2.getPublishments().forEach(p -> map2.put(p.getName(), p));
+
+        MapComparator<String, Publishment> comparator = new MapComparator<>(map1,
map2);
+        comparator.compare();
+        Assert.assertTrue(comparator.getAdded().size() == 1);
+
+    }
+
+    @Test
+    public void testMapComparatorRemoved() {
+
+        PublishSpec spec1 = MetadataSerDeser.deserialize(getClass().getResourceAsStream("/testPublishForAdd0.json"),
PublishSpec.class);
+        PublishSpec spec2 = MetadataSerDeser.deserialize(getClass().getResourceAsStream("/testPublishForAdd1.json"),
PublishSpec.class);
+
+        Map<String, Publishment> map1 = new HashMap<>();
+        Map<String, Publishment> map2 = new HashMap<>();
+        spec1.getPublishments().forEach(p -> map1.put(p.getName(), p));
+        spec2.getPublishments().forEach(p -> map2.put(p.getName(), p));
+
+        MapComparator<String, Publishment> comparator = new MapComparator<>(map1,
map2);
+        comparator.compare();
+        Assert.assertTrue(comparator.getRemoved().size() == 1);
+
+    }
+
+    @Test
+    public void testMapComparatorModified() {
+
+        PublishSpec spec1 = MetadataSerDeser.deserialize(getClass().getResourceAsStream("/testPublishForAdd0.json"),
PublishSpec.class);
+        PublishSpec spec2 = MetadataSerDeser.deserialize(getClass().getResourceAsStream("/testPublishForMdyValue.json"),
PublishSpec.class);
+
+        Map<String, Publishment> map1 = new HashMap<>();
+        Map<String, Publishment> map2 = new HashMap<>();
+        spec1.getPublishments().forEach(p -> map1.put(p.getName(), p));
+        spec2.getPublishments().forEach(p -> map2.put(p.getName(), p));
+
+        MapComparator<String, Publishment> comparator = new MapComparator<>(map1,
map2);
+        comparator.compare();
+        Assert.assertTrue(comparator.getModified().size() == 1);
+
+    }
+
+
     @Test
     public void testMapComparator() {
         PublishSpec spec1 = MetadataSerDeser.deserialize(getClass().getResourceAsStream("/testPublishSpec.json"),
PublishSpec.class);

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/a10eeb70/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/test/resources/testPublishForAdd0.json
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/test/resources/testPublishForAdd0.json
b/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/test/resources/testPublishForAdd0.json
new file mode 100644
index 0000000..9ba7adb
--- /dev/null
+++ b/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/test/resources/testPublishForAdd0.json
@@ -0,0 +1,22 @@
+{
+  "version": "version1",
+  "topologyName": "testTopology",
+  "boltId": "alertPublishBolt",
+  "publishments": [
+    {
+      "type": "org.apache.eagle.alert.engine.publisher.impl.AlertEmailPublisher",
+      "name":"email-testAlertStream",
+      "policyIds": ["policy1", "policy2", "policy3"],
+      "dedupIntervalMin": "PT1M",
+      "properties":{
+        "subject":"UMP Test Alert",
+        "template":"",
+	  "sender": "sender@corp.com",
+	  "recipients": "receiver@corp.com",
+	  "smtp.server":"mailhost.com",
+        "connection": "plaintext",
+        "smtp.port": "25"
+      }
+    }
+  ]
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/a10eeb70/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/test/resources/testPublishForAdd1.json
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/test/resources/testPublishForAdd1.json
b/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/test/resources/testPublishForAdd1.json
new file mode 100644
index 0000000..3974584
--- /dev/null
+++ b/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/test/resources/testPublishForAdd1.json
@@ -0,0 +1,32 @@
+{
+  "version": "version1",
+  "topologyName": "testTopology",
+  "boltId": "alertPublishBolt",
+  "publishments": [
+    {
+      "type": "org.apache.eagle.alert.engine.publisher.impl.AlertEmailPublisher",
+      "name":"email-testAlertStream",
+      "policyIds": ["policy1", "policy2", "policy3"],
+      "dedupIntervalMin": "PT1M",
+      "properties":{
+        "subject":"UMP Test Alert",
+        "template":"",
+	  "sender": "sender@corp.com",
+	  "recipients": "receiver@corp.com",
+	  "smtp.server":"mailhost.com",
+        "connection": "plaintext",
+        "smtp.port": "25"
+      }
+    },
+    {
+      "type": "org.apache.eagle.alert.engine.publisher.impl.AlertKafkaPublisher",
+      "name":"kafka-testAlertStream",
+      "policyIds": ["testPolicy"],
+      "dedupIntervalMin": "PT1M",
+      "properties":{
+        "kafka_broker":"sandbox.hortonworks.com:6667",
+        "topic":"test_kafka"
+      }
+    }
+  ]
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/a10eeb70/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/test/resources/testPublishForMdyValue.json
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/test/resources/testPublishForMdyValue.json
b/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/test/resources/testPublishForMdyValue.json
new file mode 100644
index 0000000..4e1df83
--- /dev/null
+++ b/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/test/resources/testPublishForMdyValue.json
@@ -0,0 +1,22 @@
+{
+  "version": "version1",
+  "topologyName": "testTopology",
+  "boltId": "alertPublishBolt",
+  "publishments": [
+    {
+      "type": "org.apache.eagle.alert.engine.publisher.impl.AlertEmailPublisher",
+      "name":"email-testAlertStream",
+      "policyIds": ["policy1", "policy2", "policy3", "policy_MdyValue"],
+      "dedupIntervalMin": "PT1M",
+      "properties":{
+        "subject":"UMP Test Alert",
+        "template":"",
+	  "sender": "sender@corp.com",
+	  "recipients": "receiver@corp.com",
+	  "smtp.server":"mailhost.com",
+        "connection": "plaintext",
+        "smtp.port": "25"
+      }
+    }
+  ]
+}
\ No newline at end of file


Mime
View raw message