falcon-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ajayyad...@apache.org
Subject falcon git commit: FALCON-1320 Adding equals() and hashCode() method in LineageGraphResult.Edge. Contributed by Pragya Mittal
Date Tue, 21 Jul 2015 12:14:44 GMT
Repository: falcon
Updated Branches:
  refs/heads/master 5b4cf24b7 -> 281e9e34b


FALCON-1320 Adding equals() and hashCode() method in LineageGraphResult.Edge. Contributed
by Pragya Mittal


Project: http://git-wip-us.apache.org/repos/asf/falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/falcon/commit/281e9e34
Tree: http://git-wip-us.apache.org/repos/asf/falcon/tree/281e9e34
Diff: http://git-wip-us.apache.org/repos/asf/falcon/diff/281e9e34

Branch: refs/heads/master
Commit: 281e9e34bdfb2f645fff20b5bc89e06d6e18d1e0
Parents: 5b4cf24
Author: Ajay Yadava <ajaynsit@gmail.com>
Authored: Tue Jul 21 17:44:21 2015 +0530
Committer: Ajay Yadava <ajaynsit@gmail.com>
Committed: Tue Jul 21 17:44:21 2015 +0530

----------------------------------------------------------------------
 CHANGES.txt                                     |  2 +
 .../falcon/resource/LineageGraphResult.java     | 26 ++++++++++
 .../falcon/resource/LineageGraphResultTest.java | 50 ++++++++++++++++++++
 3 files changed, 78 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/falcon/blob/281e9e34/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 5723867..0c8e31a 100755
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -9,6 +9,8 @@ Trunk (Unreleased)
     FALCON-796 Enable users to triage data processing issues through falcon (Ajay Yadava)
     
   IMPROVEMENTS
+    FALCON-1320 Adding equals() and hashCode() method in LineageGraphResult.Edge(Pragya Mittal
via Ajay Yadava)
+
     FALCON-1139 Validation issues in Falcon UI(Pallavi Rao via Ajay Yadava)
 
     FALCON-1204 Expose default configs for feed late data handling in runtime.properties(Balu
Vellanki via Ajay Yadava)

http://git-wip-us.apache.org/repos/asf/falcon/blob/281e9e34/client/src/main/java/org/apache/falcon/resource/LineageGraphResult.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/falcon/resource/LineageGraphResult.java b/client/src/main/java/org/apache/falcon/resource/LineageGraphResult.java
index 0e20b7e..0e10e38 100644
--- a/client/src/main/java/org/apache/falcon/resource/LineageGraphResult.java
+++ b/client/src/main/java/org/apache/falcon/resource/LineageGraphResult.java
@@ -118,6 +118,32 @@ public class LineageGraphResult {
             return getDotNotation();
         }
 
+        @Override
+        public boolean equals(Object o) {
+            if (o == this) {
+                return true;
+            }
+
+            if (o == null || getClass() != o.getClass()) {
+                return false;
+            }
+
+            Edge that = (Edge) o;
+            if (StringUtils.equals(that.getLabel(), label) && StringUtils.equals(that.getFrom(),
from)
+                    && StringUtils.equals(that.getTo(), to)) {
+                return true;
+            }
+            return false;
+        }
+
+        @Override
+        public int hashCode() {
+            int result = from != null ? from.hashCode() : 0;
+            result = 31 * result + (to != null ? to.hashCode() : 0);
+            result = 31 * result + (label != null ? label.hashCode() : 0);
+            return result;
+        }
+
     }
 
 

http://git-wip-us.apache.org/repos/asf/falcon/blob/281e9e34/client/src/test/java/org/apache/falcon/resource/LineageGraphResultTest.java
----------------------------------------------------------------------
diff --git a/client/src/test/java/org/apache/falcon/resource/LineageGraphResultTest.java b/client/src/test/java/org/apache/falcon/resource/LineageGraphResultTest.java
new file mode 100644
index 0000000..058d097
--- /dev/null
+++ b/client/src/test/java/org/apache/falcon/resource/LineageGraphResultTest.java
@@ -0,0 +1,50 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.falcon.resource;
+
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * Test frequency.
+ */
+@Test
+public class LineageGraphResultTest {
+
+    @Test
+    public void testEquals() {
+        Set<LineageGraphResult.Edge> set1 = new HashSet<>();
+        Set<LineageGraphResult.Edge> set2 = new HashSet<>();
+
+        List<String> from =  Arrays.asList(new String[]{"from1", "from2", "from3"});
+        List<String> to =  Arrays.asList(new String[]{"to1", "to2", "to3"});
+        List<String> label =  Arrays.asList(new String[]{"label1", "label2", "label3"});
+
+        for (int i = 0; i < 3; i++) {
+            set1.add(new LineageGraphResult.Edge(from.get(i), to.get(i), label.get(i)));
+            set2.add(new LineageGraphResult.Edge(from.get(i), to.get(i), label.get(i)));
+        }
+        Assert.assertEquals(set1, set2);
+    }
+}


Mime
View raw message