tinkerpop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dkupp...@apache.org
Subject [24/39] tinkerpop git commit: resolve cyclic dependency by moving GraphHelper to gremlin-test
Date Tue, 26 Sep 2017 17:28:06 GMT
resolve cyclic dependency by moving GraphHelper to gremlin-test


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

Branch: refs/heads/TINKERPOP-1782
Commit: 3d0cd1a959b37ff3a829138859558ce1bcc90191
Parents: f6d0a2c
Author: Michael Pollmeier <michael@michaelpollmeier.com>
Authored: Mon Sep 18 16:38:48 2017 +1200
Committer: Michael Pollmeier <michael@michaelpollmeier.com>
Committed: Thu Sep 21 14:08:55 2017 +1200

----------------------------------------------------------------------
 gremlin-core/pom.xml                            |  6 --
 .../gremlin/structure/util/GraphHelper.java     | 39 -------------
 .../gremlin/structure/util/GraphHelperTest.java | 59 --------------------
 .../apache/tinkerpop/gremlin/GraphHelper.java   | 40 +++++++++++++
 .../tinkergraph/structure/TinkerGraphTest.java  | 32 +++++++++++
 5 files changed, 72 insertions(+), 104 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/3d0cd1a9/gremlin-core/pom.xml
----------------------------------------------------------------------
diff --git a/gremlin-core/pom.xml b/gremlin-core/pom.xml
index e690c5d..bab7b65 100644
--- a/gremlin-core/pom.xml
+++ b/gremlin-core/pom.xml
@@ -95,12 +95,6 @@ limitations under the License.
             <artifactId>hamcrest-all</artifactId>
             <scope>test</scope>
         </dependency>
-        <dependency>
-            <groupId>org.apache.tinkerpop</groupId>
-            <artifactId>tinkergraph-gremlin</artifactId>
-            <version>${project.version}</version>
-            <scope>test</scope>
-        </dependency>
         <!-- needed to test GraphFactory and xml based config via optional dependency
in apache configurations -->
         <dependency>
             <groupId>commons-collections</groupId>

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/3d0cd1a9/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/GraphHelper.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/GraphHelper.java
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/GraphHelper.java
deleted file mode 100644
index 5d4809c..0000000
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/GraphHelper.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * 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.tinkerpop.gremlin.structure.util;
-
-import org.apache.tinkerpop.gremlin.structure.Graph;
-import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedFactory;
-
-/**
- * Utility class supporting common functions for {@link org.apache.tinkerpop.gremlin.structure.Graph}.
- */
-public final class GraphHelper {
-
-  private GraphHelper() {
-  }
-
-  /**
-   * make a deep clone of the graph elements that preserves ids
-   */
-  public static void cloneElements(final Graph original, final Graph clone) {
-    original.vertices().forEachRemaining(v -> DetachedFactory.detach(v, true).attach(Attachable.Method.create(clone)));
-    original.edges().forEachRemaining(e -> DetachedFactory.detach(e, true).attach(Attachable.Method.create(clone)));
-  }
-}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/3d0cd1a9/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/structure/util/GraphHelperTest.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/structure/util/GraphHelperTest.java
b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/structure/util/GraphHelperTest.java
deleted file mode 100644
index c186caf..0000000
--- a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/structure/util/GraphHelperTest.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * 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.tinkerpop.gremlin.structure.util;
-
-import org.apache.tinkerpop.gremlin.structure.Vertex;
-import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph;
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-public class GraphHelperTest {
-
-  @Test
-  public void shouldCloneTinkergraph() {
-    final TinkerGraph original = TinkerGraph.open();
-    final TinkerGraph clone = TinkerGraph.open();
-
-    final Vertex marko = original.addVertex("name", "marko", "age", 29);
-    final Vertex stephen = original.addVertex("name", "stephen", "age", 35);
-    marko.addEdge("knows", stephen);
-    GraphHelper.cloneElements(original, clone);
-
-    final Vertex michael = clone.addVertex("name", "michael");
-    michael.addEdge("likes", marko);
-    michael.addEdge("likes", stephen);
-    clone.traversal().V().property("newProperty", "someValue").toList();
-    clone.traversal().E().property("newProperty", "someValue").toList();
-
-    assertEquals("original graph should be unchanged", new Long(2), original.traversal().V().count().next());
-    assertEquals("original graph should be unchanged", new Long(1), original.traversal().E().count().next());
-    assertEquals("original graph should be unchanged", new Long(0), original.traversal().V().has("newProperty").count().next());
-
-    assertEquals("cloned graph should contain new elements", new Long(3), clone.traversal().V().count().next());
-    assertEquals("cloned graph should contain new elements", new Long(3), clone.traversal().E().count().next());
-    assertEquals("cloned graph should contain new property", new Long(3), clone.traversal().V().has("newProperty").count().next());
-    assertEquals("cloned graph should contain new property", new Long(3), clone.traversal().E().has("newProperty").count().next());
-
-    assertNotSame("cloned elements should reference to different objects",
-        original.traversal().V().has("name", "stephen").next(),
-        clone.traversal().V().has("name", "stephen").next());
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/3d0cd1a9/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/GraphHelper.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/GraphHelper.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/GraphHelper.java
new file mode 100644
index 0000000..24393be
--- /dev/null
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/GraphHelper.java
@@ -0,0 +1,40 @@
+/*
+ * 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.tinkerpop.gremlin;
+
+import org.apache.tinkerpop.gremlin.structure.Graph;
+import org.apache.tinkerpop.gremlin.structure.util.Attachable;
+import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedFactory;
+
+/**
+ * Utility class supporting common functions for {@link org.apache.tinkerpop.gremlin.structure.Graph}.
+ */
+public final class GraphHelper {
+
+  private GraphHelper() {
+  }
+
+  /**
+   * make a deep clone of the graph elements that preserves ids
+   */
+  public static void cloneElements(final Graph original, final Graph clone) {
+    original.vertices().forEachRemaining(v -> DetachedFactory.detach(v, true).attach(Attachable.Method.create(clone)));
+    original.edges().forEachRemaining(e -> DetachedFactory.detach(e, true).attach(Attachable.Method.create(clone)));
+  }
+}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/3d0cd1a9/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphTest.java
----------------------------------------------------------------------
diff --git a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphTest.java
b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphTest.java
index a85b0ee..83bbe58 100644
--- a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphTest.java
+++ b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphTest.java
@@ -20,6 +20,7 @@ package org.apache.tinkerpop.gremlin.tinkergraph.structure;
 
 import org.apache.commons.configuration.BaseConfiguration;
 import org.apache.commons.configuration.Configuration;
+import org.apache.tinkerpop.gremlin.GraphHelper;
 import org.apache.tinkerpop.gremlin.TestHelper;
 import org.apache.tinkerpop.gremlin.process.traversal.P;
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
@@ -68,6 +69,7 @@ import java.util.function.Consumer;
 import java.util.function.Supplier;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotSame;
 import static org.junit.Assert.assertTrue;
 import static org.mockito.Mockito.mock;
 
@@ -593,6 +595,36 @@ public class TinkerGraphTest {
         }
     }
 
+    @Test
+    public void shouldCloneTinkergraph() {
+        final TinkerGraph original = TinkerGraph.open();
+        final TinkerGraph clone = TinkerGraph.open();
+
+        final Vertex marko = original.addVertex("name", "marko", "age", 29);
+        final Vertex stephen = original.addVertex("name", "stephen", "age", 35);
+        marko.addEdge("knows", stephen);
+        GraphHelper.cloneElements(original, clone);
+
+        final Vertex michael = clone.addVertex("name", "michael");
+        michael.addEdge("likes", marko);
+        michael.addEdge("likes", stephen);
+        clone.traversal().V().property("newProperty", "someValue").toList();
+        clone.traversal().E().property("newProperty", "someValue").toList();
+
+        assertEquals("original graph should be unchanged", new Long(2), original.traversal().V().count().next());
+        assertEquals("original graph should be unchanged", new Long(1), original.traversal().E().count().next());
+        assertEquals("original graph should be unchanged", new Long(0), original.traversal().V().has("newProperty").count().next());
+
+        assertEquals("cloned graph should contain new elements", new Long(3), clone.traversal().V().count().next());
+        assertEquals("cloned graph should contain new elements", new Long(3), clone.traversal().E().count().next());
+        assertEquals("cloned graph should contain new property", new Long(3), clone.traversal().V().has("newProperty").count().next());
+        assertEquals("cloned graph should contain new property", new Long(3), clone.traversal().E().has("newProperty").count().next());
+
+        assertNotSame("cloned elements should reference to different objects",
+            original.traversal().V().has("name", "stephen").next(),
+            clone.traversal().V().has("name", "stephen").next());
+    }
+
     /**
      * Coerces a {@code Color} to a {@link TinkerGraph} during serialization.  Demonstrates
how custom serializers
      * can be developed that can coerce one value to another during serialization.


Mime
View raw message