This is an automated email from the ASF dual-hosted git repository.

spmallette pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git


The following commit(s) were added to refs/heads/master by this push:
     new 963bece33c Loosen error message validation a bit by ignoring case.
963bece33c is described below

commit 963bece33ce0f662ea8e6106b1128e27b587aaed
Author: Stephen Mallette <stepm...@amazon.com>
AuthorDate: Thu Feb 1 10:50:23 2024 -0500

    Loosen error message validation a bit by ignoring case.
    
    Not sure this is a good long term solution but perhaps it will help a bit. 
We've been a bit oppressive with error message assertions in the past and it 
hasn't really worked well. Asserting just an error doesn't seem right either 
without some qualification that it is the right one. CTR
---
 .../gremlin/process/traversal/step/map/MergeEdgeStep.java   |  6 +++---
 .../test/Gremlin.Net.IntegrationTest/Gherkin/CommonSteps.cs |  6 +++---
 gremlin-go/driver/cucumber/cucumberSteps_test.go            |  6 +++---
 .../gremlin-javascript/test/cucumber/feature-steps.js       |  6 +++---
 gremlin-python/src/main/python/radish/feature_steps.py      |  6 +++---
 .../apache/tinkerpop/gremlin/features/StepDefinition.java   | 13 ++++++-------
 .../gremlin/process/traversal/step/map/MergeEdgeTest.java   |  2 +-
 .../tinkerpop/gremlin/test/features/map/MergeEdge.feature   |  4 ++--
 8 files changed, 24 insertions(+), 25 deletions(-)

diff --git 
a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/MergeEdgeStep.java
 
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/MergeEdgeStep.java
index 748df266e0..5a31664b1e 100644
--- 
a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/MergeEdgeStep.java
+++ 
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/MergeEdgeStep.java
@@ -400,7 +400,7 @@ public class MergeEdgeStep<S> extends MergeStep<S, Edge, 
Object> {
             return tryAttachVertex(v);
         }
         throw new IllegalArgumentException(
-                String.format("Vertex could not be resolved from mergeE: %s", 
o));
+                String.format("Vertex does not exist for mergeE: %s", o));
     }
 
     /*
@@ -415,7 +415,7 @@ public class MergeEdgeStep<S> extends MergeStep<S, Edge, 
Object> {
         try (CloseableIterator<Vertex> it = 
CloseableIterator.of(getGraph().vertices(arg))) {
             if (!it.hasNext())
                 throw new IllegalArgumentException(
-                        String.format("Vertex id could not be resolved from 
mergeE: %s", arg));
+                        String.format("Vertex does not exist for mergeE: %s", 
arg));
             return it.next();
         }
     }
@@ -430,7 +430,7 @@ public class MergeEdgeStep<S> extends MergeStep<S, Edge, 
Object> {
                 return ((Attachable<Vertex>) 
v).attach(Attachable.Method.get(getGraph()));
             } catch (IllegalStateException ise) {
                 throw new IllegalArgumentException(
-                        String.format("Vertex could not be resolved from 
mergeE: %s", v));
+                        String.format("Vertex does not exist for mergeE: %s", 
v));
             }
         } else {
             return v;
diff --git 
a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/CommonSteps.cs 
b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/CommonSteps.cs
index f6540019f4..98f8b0b5b4 100644
--- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/CommonSteps.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/CommonSteps.cs
@@ -229,13 +229,13 @@ namespace Gremlin.Net.IntegrationTest.Gherkin
 
             switch (comparison) {
                 case "containing":
-                    Assert.Contains(expectedMessage, _error.Message);
+                    Assert.Contains(expectedMessage.ToUpper(), 
_error.Message.ToUpper());
                     break;
                 case "starting":
-                    Assert.StartsWith(expectedMessage, _error.Message);
+                    Assert.StartsWith(expectedMessage.ToUpper(), 
_error.Message.ToUpper());
                     break;
                 case "ending":
-                    Assert.EndsWith(expectedMessage, _error.Message);
+                    Assert.EndsWith(expectedMessage.ToUpper(), 
_error.Message.ToUpper());
                     break;
                 default:
                     throw new NotSupportedException(
diff --git a/gremlin-go/driver/cucumber/cucumberSteps_test.go 
b/gremlin-go/driver/cucumber/cucumberSteps_test.go
index cab43a6870..fd49c7d8b4 100644
--- a/gremlin-go/driver/cucumber/cucumberSteps_test.go
+++ b/gremlin-go/driver/cucumber/cucumberSteps_test.go
@@ -846,19 +846,19 @@ func (tg *tinkerPopGraph) 
theTraversalWillRaiseAnErrorWithMessageContainingTextO
        }
        switch comparison {
        case "containing":
-               if strings.Contains(tg.error[true], expectedMessage) {
+               if strings.Contains(strings.ToUpper(tg.error[true]), 
strings.ToUpper(expectedMessage)) {
                        return nil
                } else {
                        return fmt.Errorf("traversal error message must contain 
%s", expectedMessage)
                }
        case "starting":
-               if strings.Contains(tg.error[true], expectedMessage) {
+               if strings.Contains(strings.ToUpper(tg.error[true]), 
strings.ToUpper(expectedMessage)) {
                        return nil
                } else {
                        return fmt.Errorf("traversal error message must contain 
%s", expectedMessage)
                }
        case "ending":
-               if strings.Contains(tg.error[true], expectedMessage) {
+               if strings.Contains(strings.ToUpper(tg.error[true]), 
strings.ToUpper(expectedMessage)) {
                        return nil
                } else {
                        return fmt.Errorf("traversal error message must contain 
%s", expectedMessage)
diff --git 
a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js
 
b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js
index e0b3e5664c..8465811557 100644
--- 
a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js
+++ 
b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js
@@ -173,11 +173,11 @@ Then('the traversal will raise an error', function() {
 Then(/^the traversal will raise an error with message (\w+) text of "(.+)"$/, 
function(comparison, expectedMessage) {
   expect(this.result).to.be.a.instanceof(Error);
   if (comparison === "containing") {
-    expect(this.result.message).to.contain(expectedMessage)
+    
expect(this.result.message.toUpperCase()).to.contain(expectedMessage.toUpperCase())
   } else if (comparison === "starting") {
-    expect(this.result.message).to.startWith(expectedMessage)
+    
expect(this.result.message.toUpperCase()).to.startWith(expectedMessage.toUpperCase())
   } else if (comparison === "ending") {
-    expect(this.result.message).to.endWith(expectedMessage)
+    
expect(this.result.message.toUpperCase()).to.endWith(expectedMessage.toUpperCase())
   } else {
     throw new Error('unknown comparison \'' + comparison + '\'- must be: 
containing, ending or starting');
   }
diff --git a/gremlin-python/src/main/python/radish/feature_steps.py 
b/gremlin-python/src/main/python/radish/feature_steps.py
index 7a5b8a0d1d..332fe119d4 100644
--- a/gremlin-python/src/main/python/radish/feature_steps.py
+++ b/gremlin-python/src/main/python/radish/feature_steps.py
@@ -129,11 +129,11 @@ def raise_an_error_with_message(step, comparison, 
expected_message):
     assert_that(step.context.failed, equal_to(True))
 
     if comparison == "containing":
-        assert_that(step.context.failed_message, 
contains_string(expected_message))
+        assert_that(step.context.failed_message.upper(), 
contains_string(expected_message.upper()))
     elif comparison == "ending":
-        assert_that(step.context.failed_message, ends_with(expected_message))
+        assert_that(step.context.failed_message.upper(), 
ends_with(expected_message.upper()))
     elif comparison == "starting":
-        assert_that(step.context.failed_message, starts_with(expected_message))
+        assert_that(step.context.failed_message.upper(), 
starts_with(expected_message.upper()))
     else:
         raise ValueError("unknown comparison '" + comparison + "'- must be: 
containing, ending or starting")
 
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 ba28d95a0b..38303b2738 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
@@ -59,9 +59,9 @@ import static 
org.apache.tinkerpop.gremlin.LoadGraphWith.GraphData;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.core.Every.everyItem;
 import static org.hamcrest.core.IsInstanceOf.instanceOf;
-import static org.hamcrest.core.StringContains.containsString;
-import static org.hamcrest.core.StringEndsWith.endsWith;
-import static org.hamcrest.core.StringStartsWith.startsWith;
+import static org.hamcrest.core.StringContains.containsStringIgnoringCase;
+import static org.hamcrest.core.StringEndsWith.endsWithIgnoringCase;
+import static org.hamcrest.core.StringStartsWith.startsWithIgnoringCase;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.fail;
@@ -69,7 +69,6 @@ import static org.junit.Assert.fail;
 import java.math.BigDecimal;
 import java.math.BigInteger;
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
@@ -408,13 +407,13 @@ public final class StepDefinition {
 
         switch (comparison) {
             case "containing":
-                assertThat(error.getMessage(), 
containsString(expectedMessage));
+                assertThat(error.getMessage(), 
containsStringIgnoringCase(expectedMessage));
                 break;
             case "starting":
-                assertThat(error.getMessage(), startsWith(expectedMessage));
+                assertThat(error.getMessage(), 
startsWithIgnoringCase(expectedMessage));
                 break;
             case "ending":
-                assertThat(error.getMessage(), endsWith(expectedMessage));
+                assertThat(error.getMessage(), 
endsWithIgnoringCase(expectedMessage));
                 break;
             default:
                 throw new IllegalStateException(String.format(
diff --git 
a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/MergeEdgeTest.java
 
b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/MergeEdgeTest.java
index 226c0f32ce..34fbc0891c 100644
--- 
a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/MergeEdgeTest.java
+++ 
b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/MergeEdgeTest.java
@@ -122,7 +122,7 @@ public abstract class MergeEdgeTest extends 
AbstractGremlinTest {
             traversal.next();
             fail("Should have failed as vertices are not created");
         } catch (Exception ex) {
-            assertThat(ex.getMessage(), endsWith("Vertex id could not be 
resolved from mergeE: 100"));
+            assertThat(ex.getMessage(), endsWith("Vertex does not exist for 
mergeE: 100"));
         }
         assertEquals(0, IteratorUtils.count(g.E()));
     }
diff --git 
a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/test/features/map/MergeEdge.feature
 
b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/test/features/map/MergeEdge.feature
index ae30e00f9f..b55bbce417 100644
--- 
a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/test/features/map/MergeEdge.feature
+++ 
b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/test/features/map/MergeEdge.feature
@@ -328,7 +328,7 @@ Feature: Step - mergeE()
       g.mergeE(xx1)
       """
     When iterated to list
-    Then the traversal will raise an error with message containing text of 
"Vertex id could not be resolved from mergeE"
+    Then the traversal will raise an error with message containing text of 
"Vertex does not exist for mergeE"
 
   @UserSuppliedVertexIds
   Scenario: 
g_mergeEXlabel_knows_out_marko_in_vadasX_optionXonCreate_created_YX_optionXonMatch_created_NX
@@ -341,7 +341,7 @@ Feature: Step - mergeE()
       g.mergeE(xx1).option(Merge.onCreate,xx2).option(Merge.onMatch,xx3)
       """
     When iterated to list
-    Then the traversal will raise an error with message containing text of 
"Vertex id could not be resolved from mergeE"
+    Then the traversal will raise an error with message containing text of 
"Vertex does not exist for mergeE"
 
   Scenario: 
g_mergeEXlabel_knows_out_marko_in_vadasX_optionXonCreate_created_YX_optionXonMatch_created_NX_exists
     Given the empty graph

Reply via email to