You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by sp...@apache.org on 2015/05/29 18:46:27 UTC

[1/2] incubator-tinkerpop git commit: Finalize a variable.

Repository: incubator-tinkerpop
Updated Branches:
  refs/heads/master 0b4e55524 -> 530c63e82


Finalize a variable.


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

Branch: refs/heads/master
Commit: da00130c63a89792bc8c69a3b7a1458fe7103165
Parents: 0b4e555
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri May 29 12:22:06 2015 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri May 29 12:22:06 2015 -0400

----------------------------------------------------------------------
 .../gremlin/driver/ser/JsonMessageSerializerV1d0Test.java          | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/da00130c/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/JsonMessageSerializerV1d0Test.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/JsonMessageSerializerV1d0Test.java b/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/JsonMessageSerializerV1d0Test.java
index ef7dcc2..fe81f70 100644
--- a/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/JsonMessageSerializerV1d0Test.java
+++ b/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/JsonMessageSerializerV1d0Test.java
@@ -106,7 +106,7 @@ public class JsonMessageSerializerV1d0Test {
     @Test
     public void serializeToJsonIteratorNullElement() throws Exception {
 
-        ArrayList<FunObject> funList = new ArrayList<>();
+        final ArrayList<FunObject> funList = new ArrayList<>();
         funList.add(new FunObject("x"));
         funList.add(null);
         funList.add(new FunObject("y"));


[2/2] incubator-tinkerpop git commit: Add unit tests to Comparators.

Posted by sp...@apache.org.
Add unit tests to Comparators.


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

Branch: refs/heads/master
Commit: 530c63e82d491f636a75a8cbd41a3b6ec3063c7e
Parents: da00130
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri May 29 12:46:09 2015 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri May 29 12:46:09 2015 -0400

----------------------------------------------------------------------
 .../gremlin/structure/util/Comparators.java     | 26 +++++-
 .../gremlin/structure/util/ComparatorsTest.java | 93 ++++++++++++++++++++
 .../structure/util/ElementHelperTest.java       |  5 ++
 3 files changed, 122 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/530c63e8/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/Comparators.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/Comparators.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/Comparators.java
index 657c9c7..86ceb27 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/Comparators.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/Comparators.java
@@ -27,13 +27,35 @@ import java.util.Comparator;
 import java.util.Map;
 
 /**
+ * A collection of commonly used {@link Comparator} instances.
+ *
  * @author Stephen Mallette (http://stephen.genoprime.com)
  */
 public final class Comparators {
+
+    private Comparators() {}
+
+    /**
+     * Sorts {@link Element} objects  by the {@code toString()} value of {@link Element#id()} using
+     * {@link String#CASE_INSENSITIVE_ORDER}.
+     */
     public static final Comparator<Element> ELEMENT_COMPARATOR = Comparator.comparing(e -> e.id().toString(), String.CASE_INSENSITIVE_ORDER);
+
+    /**
+     * Sorts {@link Vertex} objects  by the {@code toString()} value of {@link Vertex#id()} using
+     * {@link String#CASE_INSENSITIVE_ORDER}.
+     */
     public static final Comparator<Vertex> VERTEX_COMPARATOR = Comparator.comparing(e -> e.id().toString(), String.CASE_INSENSITIVE_ORDER);
+
+    /**
+     * Sorts {@link Edge} objects  by the {@code toString()} value of {@link Edge#id()} using
+     * {@link String#CASE_INSENSITIVE_ORDER}.
+     */
     public static final Comparator<Edge> EDGE_COMPARATOR = Comparator.comparing(e -> e.id().toString(), String.CASE_INSENSITIVE_ORDER);
+
+    /**
+     * Sorts {@link Property} objects  by the value of {@link Property#key()} using
+     * {@link String#CASE_INSENSITIVE_ORDER}.
+     */
     public static final Comparator<Property> PROPERTY_COMPARATOR = Comparator.comparing(Property::key, String.CASE_INSENSITIVE_ORDER);
-    public static final Comparator<Map.Entry<String, Property>> PROPERTY_ENTRY_COMPARATOR = Comparator.comparing(Map.Entry::getKey, String.CASE_INSENSITIVE_ORDER);
-    public static final Comparator<Map.Entry<String, Object>> OBJECT_ENTRY_COMPARATOR = Comparator.comparing(Map.Entry::getKey, String.CASE_INSENSITIVE_ORDER);
 }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/530c63e8/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/structure/util/ComparatorsTest.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/structure/util/ComparatorsTest.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/structure/util/ComparatorsTest.java
new file mode 100644
index 0000000..d42a8e5
--- /dev/null
+++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/structure/util/ComparatorsTest.java
@@ -0,0 +1,93 @@
+package org.apache.tinkerpop.gremlin.structure.util;
+
+import org.apache.tinkerpop.gremlin.TestHelper;
+import org.apache.tinkerpop.gremlin.structure.Edge;
+import org.apache.tinkerpop.gremlin.structure.Element;
+import org.apache.tinkerpop.gremlin.structure.Property;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+
+import java.util.Arrays;
+import java.util.List;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+/**
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public class ComparatorsTest {
+    @Test
+    public void shouldBeUtilityClass() throws Exception {
+        TestHelper.assertIsUtilityClass(Comparators.class);
+    }
+
+    @Test
+    public void shouldSortElement() {
+        final Element a = mock(Element.class);
+        when(a.id()).thenReturn("Ant");
+        final Element b = mock(Element.class);
+        when(b.id()).thenReturn("Bat");
+        final Element c = mock(Element.class);
+        when(c.id()).thenReturn("Cat");
+
+        final List<Element> l = Arrays.asList(c, b, a);
+        l.sort(Comparators.ELEMENT_COMPARATOR);
+
+        assertEquals(a.id(), l.get(0).id());
+        assertEquals(b.id(), l.get(1).id());
+        assertEquals(c.id(), l.get(2).id());
+    }
+
+    @Test
+    public void shouldSortVertex() {
+        final Vertex a = mock(Vertex.class);
+        when(a.id()).thenReturn("Ant");
+        final Vertex b = mock(Vertex.class);
+        when(b.id()).thenReturn("Bat");
+        final Vertex c = mock(Vertex.class);
+        when(c.id()).thenReturn("Cat");
+
+        final List<Vertex> l = Arrays.asList(c, b, a);
+        l.sort(Comparators.VERTEX_COMPARATOR);
+
+        assertEquals(a.id(), l.get(0).id());
+        assertEquals(b.id(), l.get(1).id());
+        assertEquals(c.id(), l.get(2).id());
+    }
+
+    @Test
+    public void shouldSortEdge() {
+        final Edge a = mock(Edge.class);
+        when(a.id()).thenReturn("Ant");
+        final Edge b = mock(Edge.class);
+        when(b.id()).thenReturn("Bat");
+        final Edge c = mock(Edge.class);
+        when(c.id()).thenReturn("Cat");
+
+        final List<Edge> l = Arrays.asList(c, b, a);
+        l.sort(Comparators.EDGE_COMPARATOR);
+
+        assertEquals(a.id(), l.get(0).id());
+        assertEquals(b.id(), l.get(1).id());
+        assertEquals(c.id(), l.get(2).id());
+    }
+
+    @Test
+    public void shouldSortProperty() {
+        final Property a = mock(Property.class);
+        when(a.key()).thenReturn("Ant");
+        final Property b = mock(Property.class);
+        when(b.key()).thenReturn("Bat");
+        final Property c = mock(Property.class);
+        when(c.key()).thenReturn("Cat");
+
+        final List<Property> l = Arrays.asList(c, b, a);
+        l.sort(Comparators.PROPERTY_COMPARATOR);
+
+        assertEquals(a.key(), l.get(0).key());
+        assertEquals(b.key(), l.get(1).key());
+        assertEquals(c.key(), l.get(2).key());
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/530c63e8/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/structure/util/ElementHelperTest.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/structure/util/ElementHelperTest.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/structure/util/ElementHelperTest.java
index 452a15b..2187298 100644
--- a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/structure/util/ElementHelperTest.java
+++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/structure/util/ElementHelperTest.java
@@ -18,6 +18,7 @@
  */
 package org.apache.tinkerpop.gremlin.structure.util;
 
+import org.apache.tinkerpop.gremlin.TestHelper;
 import org.apache.tinkerpop.gremlin.structure.T;
 import org.apache.tinkerpop.gremlin.structure.Edge;
 import org.apache.tinkerpop.gremlin.structure.Element;
@@ -40,6 +41,10 @@ import static org.mockito.Mockito.*;
  * @author Stephen Mallette (http://stephen.genoprime.com)
  */
 public class ElementHelperTest {
+    @Test
+    public void shouldBeUtilityClass() throws Exception {
+        TestHelper.assertIsUtilityClass(ElementHelper.class);
+    }
 
     @Test
     public void shouldValidatePropertyAndNotAllowNullValue() {