[ 
https://issues.apache.org/jira/browse/TINKERPOP-3136?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17946227#comment-17946227
 ] 

ASF GitHub Bot commented on TINKERPOP-3136:
-------------------------------------------

xiazcy commented on code in PR #3097:
URL: https://github.com/apache/tinkerpop/pull/3097#discussion_r2052997666


##########
gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/features/StepDefinition.java:
##########
@@ -637,4 +723,70 @@ private static <T> List<org.hamcrest.Matcher<? super T>> 
getMatchers(final T[] i
         return matchers;
     }
 
+    /**
+     * Parse the tree structure as taken from the Gherkin feature file.
+     */
+    public List<TreeNode> parseTree(final String asciiTree) {
+        if (asciiTree.isEmpty()) return Collections.emptyList();
+
+        final List<String> lines = Arrays.asList(asciiTree.split("\n"));
+
+        final List<TreeNode> roots = new ArrayList<>();
+        final Map<Integer, TreeNode> levelMap = new HashMap<>();
+
+        for (String line : lines) {
+            final int level = countLeadingCharacters(line);
+            final String value = line.replace("|--", "").trim();
+
+            final TreeNode node = new TreeNode(convertToObject(value));
+            if (level == 0) {
+                roots.add(node);
+            } else {
+                levelMap.get(level - 1).addChild(node);
+            }
+            levelMap.put(level, node);
+        }
+
+        return roots;
+    }
+
+    private static int countLeadingCharacters(final String line) {
+        int count = 0;
+        for (char c : line.toCharArray()) {
+            if (c == ' ') count++;
+            else break;
+        }
+        return count / 3; // Assuming 4 spaces per level

Review Comment:
   ```suggestion
           return count / 3; // Assuming 3 spaces per level
   ```





> Complete move to Gherkin for implementation testing
> ---------------------------------------------------
>
>                 Key: TINKERPOP-3136
>                 URL: https://issues.apache.org/jira/browse/TINKERPOP-3136
>             Project: TinkerPop
>          Issue Type: Improvement
>          Components: test-suite
>    Affects Versions: 3.7.3
>            Reporter: Stephen Mallette
>            Priority: Major
>
> TinkerPop is most of the way to testing Gremlin exclusively with Gherkin. By 
> 4.0 that move should be complete with whatever deprecations necessary for 
> Java tests along 3.x. Retain the Java test suite for embedded {{Graph}} tests 
> that only make sense in that case.
> For 3.x - likely 3.8.x
> * Create {{ProcessEmbeddedSuite}} and deprecate {{ProcessLimitedSuite}} to 
> make it clear what aspects of Gremlin are meant for embedded cases and 
> Java/Groovy sugar only. Update provider documentation to reflect these 
> changes and ensure Gherkin is clear as the primary test suite for Gremlin.
> * Drop {{MergeVertexTest}} and {{MergeEdgeTest}} as remaining tests in there 
> seem to be covered by Gherkin already.
> * Drop {{SubgraphTest}} since it should be able to be converted to feature 
> tests but will need to add a way to assert a {{Graph}} though. Ignore in 
> languages that don't have {{{}Graph{}}}.
> * Drop {{TreeTest}} since it should be able to be converted to feature tests 
> but will need to add a way to assert a {{Tree}} though. Ignore in languages 
> that don't have {{{}Tree{}}}.
> * Implement Gherkin tests for {{match()}} - do a limited and simple set to 
> minimally test the capability since that feature is a bit up in the air for 
> 4.x. Retain {{MatchTest}} as it is for the embedded suite for now.
> * For {{{}ComplexTest{}}}:
>  ** {{cap('m')}} from {{classicRecommendation}} so that it can be asserted in 
> {{{}Recommendation.feature{}}}.
>  *** Figure out a way to assert the {{coworkerSummary}} tests in Gherkin. We 
> don't currently have a way to assert very complex {{{}Map{}}}. The basic test 
> could be run multiple times to try to break up the results to fit with the 
> assertion capabilities?
>  ** Move {{playlistPths}} to {{Paths.feature}}
>  ** Remove {{ComplexTest}} as all relevant tests will have been moved to 
> Gherkin.
> * Remove {{PartitionStrategyProcessTest}} - seems to be covered in Gherkin at 
> this point.
> * Convert {{TernaryBooleanLogicsTest}} to Gherkin - add it to the 
> {{/semantics}} directory.
> * Remove all lambda based tests from Gherkin since they are not supported by 
> gremlin-language. Ensure that they all exist in the embedded tests. Perhaps 
> put them all in a {{LambdaStepTest}} and combine in other embedded tests 
> there so that they are all in once place. Remove all infrastructure for 
> processing lambdas in the Gherkin suite. Test lambdas in GLVs independently.
> For 4.x
>  * Remove {{ProcessLimitedSuite}} in favor of {{ProcessEmbeddedSuite}}
>  * Since {{Tree}} and {{Graph}} will be present in 4.x for all languages, 
> ensure that test suites are updated in support of those assertions as these 
> tests will have been skipped prior.
> h3. Open questions
>  * Make a decision about {{profile()}} and {{explain()}} in terms of how they 
> are tested. Leaning toward them remaining an embedded case as they have 
> implementation specific output potentially
>  * Examine "Given an unsupported test" definitions....can any be supported 
> now? what do we do with those that cant?
> Note the linked JIRAs below as well.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to