This is an automated email from the ASF dual-hosted git repository. spmallette pushed a commit to branch TINKERPOP-3136 in repository https://gitbox.apache.org/repos/asf/tinkerpop.git
commit 2aa85ac875bc7a96ed21a23efdc734b9b87c2219 Author: Stephen Mallette <stepm...@amazon.com> AuthorDate: Wed Apr 16 08:50:22 2025 -0400 f --- docs/src/dev/developer/for-committers.asciidoc | 2 ++ .../org/apache/tinkerpop/gremlin/features/StepDefinition.java | 10 ++++++++-- .../gremlin/test/features/sideEffect/Subgraph.feature | 1 - 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/docs/src/dev/developer/for-committers.asciidoc b/docs/src/dev/developer/for-committers.asciidoc index 59f46161e8..067b7ae98d 100644 --- a/docs/src/dev/developer/for-committers.asciidoc +++ b/docs/src/dev/developer/for-committers.asciidoc @@ -502,6 +502,8 @@ of traversal iteration where "_comparison_" may be one of "containing", "startin * "the result should be unordered" - the exact results but can appear any order * "the result should be of" - results can be any of the specified values and in any order (use when guarantees regarding the exact results cannot be pre-determined easily - see the `range()`-step tests for examples) +* "the result should be a graph with _xxx_" - asserts a subgraph where the _xxx_ may be "vertices" or "edges" with a +follow-on table containing vertex or edge definitions respectively that are expected to exist in the subgraph These final three types of assertions mentioned above should be followed by a Gherkin table that has one column, where each row value in that column represents a value to assert in the result. These values are type notation respected as diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/features/StepDefinition.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/features/StepDefinition.java index 14e115e885..9eeff82abc 100644 --- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/features/StepDefinition.java +++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/features/StepDefinition.java @@ -393,6 +393,9 @@ public final class StepDefinition { final List<Edge> expectedEdges = dataTable.asList().stream().map(this::convertToObject). map(e -> (Edge) e).collect(Collectors.toList()); + // expected edges match the count in the graph + assertEquals(expectedEdges.size(), sg.E().count().next().intValue()); + // assert the structure of the subgraph. there should be no references here as this is serialized as // a full TinkerGraph. also, ids should be the same as they are in the source graph so we can use all // of this to do a complete assertion. there is only support for the modern graph right now but it @@ -417,14 +420,17 @@ public final class StepDefinition { final GraphTraversalSource sg = ((Graph) result).traversal(); // grab the expected vertex in the subgraph - final List<Vertex> expectedEdges = dataTable.asList().stream().map(this::convertToObject). + final List<Vertex> expectedVertices = dataTable.asList().stream().map(this::convertToObject). map(v -> (Vertex) v).collect(Collectors.toList()); + // expected vertices match the count in the graph + assertEquals(expectedVertices.size(), sg.E().count().next().intValue()); + // assert the structure of the subgraph. there should be no references here as this is serialized as // a full TinkerGraph. also, ids should be the same as they are in the source graph so we can use all // of this to do a complete assertion. there is only support for the modern graph right now but it // wouldn't be hard to add others. - for (Vertex vertex : expectedEdges) { + for (Vertex vertex : expectedVertices) { final String variableKey = vertex.label().equals("person") ? "age" : "lang"; assertThat(sg.V(vertex.id()).has(vertex.label(), "name", eq(vertex.value("name"))). diff --git a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/test/features/sideEffect/Subgraph.feature b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/test/features/sideEffect/Subgraph.feature index 93fb651fec..1eb2edfc32 100644 --- a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/test/features/sideEffect/Subgraph.feature +++ b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/test/features/sideEffect/Subgraph.feature @@ -36,7 +36,6 @@ Feature: Step - subgraph() Scenario: g_V_repeatXbothEXcreatedX_subgraphXsgX_outVX_timesX5X_name_dedup_capXsgX Given the modern graph - And using the parameter vid1 defined as "v[marko].id" And the traversal of """ g.V().repeat(__.bothE("created").subgraph("sg").outV()).times(5).values("name").dedup().cap("sg")