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

ahuber pushed a commit to branch 3855-spring.boot.3.5
in repository https://gitbox.apache.org/repos/asf/causeway.git


The following commit(s) were added to refs/heads/3855-spring.boot.3.5 by this 
push:
     new 03bf41e896f CAUSEWAY-3855: approval test fixes (GraphQL)
03bf41e896f is described below

commit 03bf41e896fd03b2e8e568ab8c84c456505a1503
Author: Andi Huber <[email protected]>
AuthorDate: Fri May 23 07:48:32 2025 +0200

    CAUSEWAY-3855: approval test fixes (GraphQL)
---
 ...pthead_and_change_name_invoke_invalid.approved.json |  4 ++--
 ...t.each.staff_member_name_edit_invalid.approved.json |  4 ++--
 viewers/graphql/test/src/test/resources/schema.gql     | 13 ++++++++++++-
 .../CausewayViewerGraphqlIntegTestAbstract.java        | 18 ++++++++++++------
 4 files changed, 28 insertions(+), 11 deletions(-)

diff --git 
a/viewers/graphql/test/src/test/java/org/apache/causeway/viewer/graphql/viewer/test/e2e/univ/depthead/DeptHead_IntegTest.each.find_depthead_and_change_name_invoke_invalid.approved.json
 
b/viewers/graphql/test/src/test/java/org/apache/causeway/viewer/graphql/viewer/test/e2e/univ/depthead/DeptHead_IntegTest.each.find_depthead_and_change_name_invoke_invalid.approved.json
index 426f06b6b8e..cae2aefb52e 100644
--- 
a/viewers/graphql/test/src/test/java/org/apache/causeway/viewer/graphql/viewer/test/e2e/univ/depthead/DeptHead_IntegTest.each.find_depthead_and_change_name_invoke_invalid.approved.json
+++ 
b/viewers/graphql/test/src/test/java/org/apache/causeway/viewer/graphql/viewer/test/e2e/univ/depthead/DeptHead_IntegTest.each.find_depthead_and_change_name_invoke_invalid.approved.json
@@ -2,8 +2,8 @@
   "errors" : [ {
     "message" : "Exception while fetching data 
(/rich/university_dept_DeptHeads/findHeadByName/invoke/results/changeName/invokeIdempotent/results)
 : Name cannot contain '!' character",
     "locations" : [ {
-      "line" : 9,
-      "column" : 17
+      "column" : 17,
+      "line" : 9
     } ],
     "path" : [ "rich", "university_dept_DeptHeads", "findHeadByName", 
"invoke", "results", "changeName", "invokeIdempotent", "results" ],
     "extensions" : {
diff --git 
a/viewers/graphql/test/src/test/java/org/apache/causeway/viewer/graphql/viewer/test/e2e/univ/staff/Staff_IntegTest.each.staff_member_name_edit_invalid.approved.json
 
b/viewers/graphql/test/src/test/java/org/apache/causeway/viewer/graphql/viewer/test/e2e/univ/staff/Staff_IntegTest.each.staff_member_name_edit_invalid.approved.json
index c2f246ab1f1..7fd746451ac 100644
--- 
a/viewers/graphql/test/src/test/java/org/apache/causeway/viewer/graphql/viewer/test/e2e/univ/staff/Staff_IntegTest.each.staff_member_name_edit_invalid.approved.json
+++ 
b/viewers/graphql/test/src/test/java/org/apache/causeway/viewer/graphql/viewer/test/e2e/univ/staff/Staff_IntegTest.each.staff_member_name_edit_invalid.approved.json
@@ -2,8 +2,8 @@
   "errors" : [ {
     "message" : "Exception while fetching data 
(/rich/university_dept_Staff/findStaffMemberByName/invoke/results/name/set) : 
Name cannot contain '!' character",
     "locations" : [ {
-      "line" : 8,
-      "column" : 15
+      "column" : 15,
+      "line" : 8
     } ],
     "path" : [ "rich", "university_dept_Staff", "findStaffMemberByName", 
"invoke", "results", "name", "set" ],
     "extensions" : {
diff --git a/viewers/graphql/test/src/test/resources/schema.gql 
b/viewers/graphql/test/src/test/resources/schema.gql
index bab842d8270..827f8fd7075 100644
--- a/viewers/graphql/test/src/test/resources/schema.gql
+++ b/viewers/graphql/test/src/test/resources/schema.gql
@@ -3,12 +3,23 @@ schema {
   mutation: Mutation
 }
 
+"This directive allows results to be deferred during execution"
+directive @defer(
+    "Deferred behaviour is controlled by this argument"
+    if: Boolean! = true,
+    "A unique label that represents the fragment being deferred"
+    label: String
+  ) on FRAGMENT_SPREAD | INLINE_FRAGMENT
+
 "Marks the field, argument, input field or enum value as deprecated"
 directive @deprecated(
     "The reason for the deprecation"
-    reason: String = "No longer supported"
+    reason: String! = "No longer supported"
   ) on FIELD_DEFINITION | ARGUMENT_DEFINITION | ENUM_VALUE | 
INPUT_FIELD_DEFINITION
 
+"This directive disables error propagation when a non nullable field returns 
null for the given operation."
+directive @experimental_disableErrorPropagation on QUERY | MUTATION | 
SUBSCRIPTION
+
 "Directs the executor to include this field or fragment only when the `if` 
argument is true"
 directive @include(
     "Included when true."
diff --git 
a/viewers/graphql/testsupport/src/main/java/org/apache/causeway/viewer/graphql/viewer/testsupport/CausewayViewerGraphqlIntegTestAbstract.java
 
b/viewers/graphql/testsupport/src/main/java/org/apache/causeway/viewer/graphql/viewer/testsupport/CausewayViewerGraphqlIntegTestAbstract.java
index 4f4ce063d22..06b6c902e4c 100644
--- 
a/viewers/graphql/testsupport/src/main/java/org/apache/causeway/viewer/graphql/viewer/testsupport/CausewayViewerGraphqlIntegTestAbstract.java
+++ 
b/viewers/graphql/testsupport/src/main/java/org/apache/causeway/viewer/graphql/viewer/testsupport/CausewayViewerGraphqlIntegTestAbstract.java
@@ -37,7 +37,9 @@
 import jakarta.inject.Inject;
 
 import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.MapperFeature;
 import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.json.JsonMapper;
 
 import org.approvaltests.Approvals;
 import org.approvaltests.core.Options;
@@ -180,8 +182,6 @@ void init(final TestInfo testInfo) {
      */
     protected TestInfo testInfo;
 
-    private ObjectMapper objectMapper = new ObjectMapper();
-
     protected HttpGraphQlTester graphQlTester() {
         WebTestClient client =
                 WebTestClient.bindToServer()
@@ -192,10 +192,10 @@ protected HttpGraphQlTester graphQlTester() {
 
     /**
      * Builds an HTTP request based on the current {@link TestInfo}, with 
suffix <code>.submit.gql</code>,
-     * and unmarshalls the response as a string
+     * and unmarshalls the response as a string.
+     * (throws an exception if an error occurs during the submission)
      *
      * @return the response body as a string
-     * @throws Exception if an error occurs during the submission
      */
     protected String submit() {
         return submit(Collections.emptyMap());
@@ -245,7 +245,7 @@ protected HttpRequest buildRequest(final String 
resourceName, final Map<String,
         var uri = URI.create(String.format("http://0.0.0.0:%d/graphql";, port));
 
         var gqlBody = new GqlBody(resourceContent);
-        var gqlBodyStr = objectMapper.writeValueAsString(gqlBody);
+        var gqlBodyStr = new ObjectMapper().writeValueAsString(gqlBody);
         var bodyPublisher = HttpRequest.BodyPublishers.ofString(gqlBodyStr);
 
         return HttpRequest.newBuilder().
@@ -306,7 +306,13 @@ public Options jsonOptions(@Nullable Options options, 
final BookmarkOptions book
         }
         return options.withScrubber(s -> {
                     try {
-                        String prettyJson = 
objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(objectMapper.readTree(s));
+                        var objectMapper = JsonMapper.builder()
+                            
.configure(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY, true)
+                            .build();
+
+                        String prettyJson = objectMapper
+                            .writerWithDefaultPrettyPrinter()
+                            .writeValueAsString(objectMapper.readTree(s));
                         if (bookmarkOptions == BookmarkOptions.SCRUB) {
                             prettyJson = prettyJson.replaceAll(":\\d+/", 
":NNN/");
                         }

Reply via email to