You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by ok...@apache.org on 2016/05/02 16:23:34 UTC
[2/4] incubator-tinkerpop git commit: an untested addEdge method is
now tested and the NPE thrown is now not there. Thank you @dalaro.
an untested addEdge method is now tested and the NPE thrown is now not there. Thank you @dalaro.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/82295fe1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/82295fe1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/82295fe1
Branch: refs/heads/tp31
Commit: 82295fe1eaaeab86517c191c1d44dfe3f0b34d2a
Parents: 0563ec3
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Fri Apr 29 10:37:51 2016 -0600
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Fri Apr 29 10:37:51 2016 -0600
----------------------------------------------------------------------
.../gremlin/structure/util/star/StarGraph.java | 4 +++-
.../gremlin/structure/util/star/StarGraphTest.java | 16 ++++++++++++++++
2 files changed, 19 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/82295fe1/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/star/StarGraph.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/star/StarGraph.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/star/StarGraph.java
index a8a72ff..f516630 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/star/StarGraph.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/star/StarGraph.java
@@ -290,7 +290,9 @@ public final class StarGraph implements Graph, Serializable {
public Edge addEdge(final String label, final Vertex inVertex, final Object... keyValues) {
final Edge edge = this.addOutEdge(label, inVertex, keyValues);
if (inVertex.equals(this)) {
- List<Edge> inE = inEdges.get(label);
+ if(null == this.inEdges)
+ this.inEdges = new HashMap<>();
+ List<Edge> inE = this.inEdges.get(label);
if (null == inE) {
inE = new ArrayList<>();
this.inEdges.put(label, inE);
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/82295fe1/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/star/StarGraphTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/star/StarGraphTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/star/StarGraphTest.java
index fda6e37..034afad 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/star/StarGraphTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/star/StarGraphTest.java
@@ -229,8 +229,24 @@ public class StarGraphTest extends AbstractGremlinTest {
TestHelper.validateVertexEquality(vertex, starGraph.getStarVertex(), true);
TestHelper.validateVertexEquality(vertex, starGraphCopy.getStarVertex(), true);
TestHelper.validateVertexEquality(starGraph.getStarVertex(), starGraphCopy.getStarVertex(), true);
+ // test native non-clone-based methods
+ final StarGraph starGraphNative = StarGraph.open();
+ Vertex v1 = starGraphNative.addVertex(T.label, "thing", T.id, "v1");
+ assertEquals("v1", v1.id());
+ assertEquals("thing", v1.label());
+ Edge e1 = v1.addEdge("self", v1, "name", "pipes");
+ assertEquals(2l, IteratorUtils.count(v1.vertices(Direction.BOTH, "self", "nothing")));
+ assertEquals(1l, IteratorUtils.count(v1.vertices(Direction.OUT)));
+ assertEquals(1l, IteratorUtils.count(v1.vertices(Direction.IN, "self")));
+ edgeIterator = v1.edges(Direction.BOTH);
+ TestHelper.validateEdgeEquality(e1, edgeIterator.next());
+ TestHelper.validateEdgeEquality(e1, edgeIterator.next());
+ assertFalse(edgeIterator.hasNext());
+ TestHelper.validateEdgeEquality(e1, v1.edges(Direction.OUT, "self", "nothing").next());
+ TestHelper.validateEdgeEquality(e1, v1.edges(Direction.IN).next());
}
+
private Pair<StarGraph, Integer> serializeDeserialize(final StarGraph starGraph) {
final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
try {