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/08/12 14:23:05 UTC
[2/8] tinkerpop git commit: TINKERPOP-1397 Add StarGraph bothE
filtering test
TINKERPOP-1397 Add StarGraph bothE filtering test
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/7842c4e7
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/7842c4e7
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/7842c4e7
Branch: refs/heads/master
Commit: 7842c4e7e2e3c2b33fc1bca7a8a80e165080bc59
Parents: fc79de8
Author: Dan LaRocque <da...@hopcount.org>
Authored: Wed Aug 10 18:59:54 2016 -0400
Committer: Dan LaRocque <da...@hopcount.org>
Committed: Wed Aug 10 19:21:56 2016 -0400
----------------------------------------------------------------------
.../structure/util/star/StarGraphTest.java | 34 ++++++++++++++++++++
1 file changed, 34 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/7842c4e7/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 034afad..c49dab0 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
@@ -23,6 +23,8 @@ import org.apache.tinkerpop.gremlin.AbstractGremlinTest;
import org.apache.tinkerpop.gremlin.FeatureRequirement;
import org.apache.tinkerpop.gremlin.LoadGraphWith;
import org.apache.tinkerpop.gremlin.TestHelper;
+import org.apache.tinkerpop.gremlin.process.computer.GraphFilter;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
import org.apache.tinkerpop.gremlin.structure.Direction;
import org.apache.tinkerpop.gremlin.structure.Edge;
import org.apache.tinkerpop.gremlin.structure.Graph;
@@ -246,6 +248,38 @@ public class StarGraphTest extends AbstractGremlinTest {
TestHelper.validateEdgeEquality(e1, v1.edges(Direction.IN).next());
}
+ @Test
+ @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_VERTICES)
+ @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_PROPERTY)
+ @FeatureRequirement(featureClass = Graph.Features.EdgeFeatures.class, feature = Graph.Features.EdgeFeatures.FEATURE_ADD_EDGES)
+ @FeatureRequirement(featureClass = Graph.Features.EdgeFeatures.class, feature = Graph.Features.EdgeFeatures.FEATURE_ADD_PROPERTY)
+ public void shouldHandleBothEdgesGraphFilterOnSelfLoop() {
+ assertEquals(0l, IteratorUtils.count(graph.vertices()));
+ assertEquals(0l, IteratorUtils.count(graph.edges()));
+
+ // these vertex label, edge label, and property names/values were copied from existing tests
+ StarGraph starGraph = StarGraph.open();
+ Vertex vertex = starGraph.addVertex(T.label, "person", "name", "furnace");
+ Edge edge = vertex.addEdge("self", vertex);
+ edge.property("acl", "private");
+
+ // traversing a self-loop should yield the edge once for inE/outE
+ // and the edge twice for bothE (one edge emitted two times, not two edges)
+ assertEquals(1L, IteratorUtils.count(starGraph.traversal().V().inE()));
+ assertEquals(1L, IteratorUtils.count(starGraph.traversal().V().outE()));
+ assertEquals(2L, IteratorUtils.count(starGraph.traversal().V().bothE()));
+
+ // Try a filter that retains BOTH
+ GraphFilter graphFilter = new GraphFilter();
+ graphFilter.setEdgeFilter(__.bothE("self"));
+ starGraph = starGraph.applyGraphFilter(graphFilter).get();
+
+ // Retest traversal counts after filtering
+ assertEquals(1L, IteratorUtils.count(starGraph.traversal().V().inE()));
+ assertEquals(1L, IteratorUtils.count(starGraph.traversal().V().outE()));
+ assertEquals(2L, IteratorUtils.count(starGraph.traversal().V().bothE()));
+ }
+
private Pair<StarGraph, Integer> serializeDeserialize(final StarGraph starGraph) {
final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();