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

danhaywood pushed a commit to branch CAUSEWAY-3676
in repository https://gitbox.apache.org/repos/asf/causeway.git

commit 99d102d124f074f34619cf2333da60e9aabe9372
Author: danhaywood <[email protected]>
AuthorDate: Wed Jan 24 12:53:15 2024 +0000

    CAUSEWAY-3676: adds tests, in particular for collections
---
 .../graphql/viewer/test/domain/Department.java     |  11 ++
 .../graphql/viewer/test/domain/Departments.java    |   4 +
 .../Domain_IntegTest.find_all_departments._.gql    |   1 -
 ...in_IntegTest.find_all_departments.approved.json |   6 -
 .../Domain_IntegTest.find_department_by_name._.gql |  15 +++
 ...IntegTest.find_department_by_name.approved.json |  13 +++
 ..._IntegTest.find_depthead_and_change_name._.gql} |   9 --
 ...st.find_depthead_and_change_name.approved.json} |   7 +-
 .../Domain_IntegTest.find_depthead_by_name._.gql   |  18 +++
 ...n_IntegTest.find_depthead_by_name.approved.json |  20 ++++
 .../graphql/viewer/test/e2e/Domain_IntegTest.java  |  19 +++-
 .../test/e2e/Schema_IntegTest.schema.approved.json | 123 +++++++++++++++++++++
 ...chema_IntegTest.schema_types_name.approved.json |   4 +
 .../graphql/test/src/test/resources/schema.gql     |  14 +++
 14 files changed, 240 insertions(+), 24 deletions(-)

diff --git 
a/incubator/viewers/graphql/test/src/test/java/org/apache/causeway/viewer/graphql/viewer/test/domain/Department.java
 
b/incubator/viewers/graphql/test/src/test/java/org/apache/causeway/viewer/graphql/viewer/test/domain/Department.java
index d8490bacee..d2a0155e18 100644
--- 
a/incubator/viewers/graphql/test/src/test/java/org/apache/causeway/viewer/graphql/viewer/test/domain/Department.java
+++ 
b/incubator/viewers/graphql/test/src/test/java/org/apache/causeway/viewer/graphql/viewer/test/domain/Department.java
@@ -22,10 +22,12 @@ import javax.persistence.Entity;
 import javax.persistence.GeneratedValue;
 import javax.persistence.Id;
 import javax.persistence.JoinColumn;
+import javax.persistence.OneToMany;
 import javax.persistence.OneToOne;
 import javax.persistence.Table;
 
 import org.apache.causeway.applib.annotation.Bounding;
+import org.apache.causeway.applib.annotation.Collection;
 import org.apache.causeway.applib.annotation.DomainObject;
 import org.apache.causeway.applib.annotation.Nature;
 import org.apache.causeway.applib.annotation.Property;
@@ -35,6 +37,8 @@ import lombok.NoArgsConstructor;
 import lombok.Setter;
 
 import java.util.Comparator;
+import java.util.Set;
+import java.util.TreeSet;
 
 @Entity
 @Table(
@@ -64,6 +68,13 @@ public class Department implements Comparable<Department> {
     @JoinColumn(name = "deptHead_id")
     private DeptHead deptHead;
 
+
+    @Getter @Setter
+    @Collection
+    @OneToMany(mappedBy = "department")
+    private Set<StaffMember> staffMembers = new TreeSet<>();
+
+
     @Override
     public int compareTo(final Department o) {
         return Comparator.comparing(Department::getName).compare(this, o);
diff --git 
a/incubator/viewers/graphql/test/src/test/java/org/apache/causeway/viewer/graphql/viewer/test/domain/Departments.java
 
b/incubator/viewers/graphql/test/src/test/java/org/apache/causeway/viewer/graphql/viewer/test/domain/Departments.java
index 602b94a103..580c779bf4 100644
--- 
a/incubator/viewers/graphql/test/src/test/java/org/apache/causeway/viewer/graphql/viewer/test/domain/Departments.java
+++ 
b/incubator/viewers/graphql/test/src/test/java/org/apache/causeway/viewer/graphql/viewer/test/domain/Departments.java
@@ -59,5 +59,9 @@ public class Departments {
         return departmentRepository.findAll();
     }
 
+    @Action(semantics = SemanticsOf.SAFE)
+    public Department findByName(final String name){
+        return departmentRepository.findByName(name);
+    }
 
 }
diff --git 
a/incubator/viewers/graphql/test/src/test/java/org/apache/causeway/viewer/graphql/viewer/test/e2e/Domain_IntegTest.find_all_departments._.gql
 
b/incubator/viewers/graphql/test/src/test/java/org/apache/causeway/viewer/graphql/viewer/test/e2e/Domain_IntegTest.find_all_departments._.gql
index 1ed457642b..2528d1826c 100644
--- 
a/incubator/viewers/graphql/test/src/test/java/org/apache/causeway/viewer/graphql/viewer/test/e2e/Domain_IntegTest.find_all_departments._.gql
+++ 
b/incubator/viewers/graphql/test/src/test/java/org/apache/causeway/viewer/graphql/viewer/test/e2e/Domain_IntegTest.find_all_departments._.gql
@@ -6,7 +6,6 @@
           get
         }
         _gql_meta {
-          id
           logicalTypeName
           version
         }
diff --git 
a/incubator/viewers/graphql/test/src/test/java/org/apache/causeway/viewer/graphql/viewer/test/e2e/Domain_IntegTest.find_all_departments.approved.json
 
b/incubator/viewers/graphql/test/src/test/java/org/apache/causeway/viewer/graphql/viewer/test/e2e/Domain_IntegTest.find_all_departments.approved.json
index 3067773e3d..0f8e191d91 100644
--- 
a/incubator/viewers/graphql/test/src/test/java/org/apache/causeway/viewer/graphql/viewer/test/e2e/Domain_IntegTest.find_all_departments.approved.json
+++ 
b/incubator/viewers/graphql/test/src/test/java/org/apache/causeway/viewer/graphql/viewer/test/e2e/Domain_IntegTest.find_all_departments.approved.json
@@ -7,7 +7,6 @@
             "get" : "Classics"
           },
           "_gql_meta" : {
-            "id" : "67",
             "logicalTypeName" : "university.dept.Department",
             "version" : null
           }
@@ -16,7 +15,6 @@
             "get" : "Physics"
           },
           "_gql_meta" : {
-            "id" : "68",
             "logicalTypeName" : "university.dept.Department",
             "version" : null
           }
@@ -25,7 +23,6 @@
             "get" : "Textiles"
           },
           "_gql_meta" : {
-            "id" : "69",
             "logicalTypeName" : "university.dept.Department",
             "version" : null
           }
@@ -34,7 +31,6 @@
             "get" : "Pathology"
           },
           "_gql_meta" : {
-            "id" : "70",
             "logicalTypeName" : "university.dept.Department",
             "version" : null
           }
@@ -43,7 +39,6 @@
             "get" : "Mathematics"
           },
           "_gql_meta" : {
-            "id" : "71",
             "logicalTypeName" : "university.dept.Department",
             "version" : null
           }
@@ -52,7 +47,6 @@
             "get" : "Civil Engineering"
           },
           "_gql_meta" : {
-            "id" : "72",
             "logicalTypeName" : "university.dept.Department",
             "version" : null
           }
diff --git 
a/incubator/viewers/graphql/test/src/test/java/org/apache/causeway/viewer/graphql/viewer/test/e2e/Domain_IntegTest.find_department_by_name._.gql
 
b/incubator/viewers/graphql/test/src/test/java/org/apache/causeway/viewer/graphql/viewer/test/e2e/Domain_IntegTest.find_department_by_name._.gql
new file mode 100644
index 0000000000..433a18d013
--- /dev/null
+++ 
b/incubator/viewers/graphql/test/src/test/java/org/apache/causeway/viewer/graphql/viewer/test/e2e/Domain_IntegTest.find_department_by_name._.gql
@@ -0,0 +1,15 @@
+{
+  university_dept_Departments {
+    findByName {
+      invoke(name: "Classics") {
+        staffMembers {
+          get {
+            name {
+              get
+            }
+          }
+        }
+      }
+    }
+  }
+}
diff --git 
a/incubator/viewers/graphql/test/src/test/java/org/apache/causeway/viewer/graphql/viewer/test/e2e/Domain_IntegTest.find_department_by_name.approved.json
 
b/incubator/viewers/graphql/test/src/test/java/org/apache/causeway/viewer/graphql/viewer/test/e2e/Domain_IntegTest.find_department_by_name.approved.json
new file mode 100644
index 0000000000..60867f87b8
--- /dev/null
+++ 
b/incubator/viewers/graphql/test/src/test/java/org/apache/causeway/viewer/graphql/viewer/test/e2e/Domain_IntegTest.find_department_by_name.approved.json
@@ -0,0 +1,13 @@
+{
+  "data" : {
+    "university_dept_Departments" : {
+      "findByName" : {
+        "invoke" : {
+          "staffMembers" : {
+            "get" : [ ]
+          }
+        }
+      }
+    }
+  }
+}
\ No newline at end of file
diff --git 
a/incubator/viewers/graphql/test/src/test/java/org/apache/causeway/viewer/graphql/viewer/test/e2e/Domain_IntegTest.find_department_and_change_name._.gql
 
b/incubator/viewers/graphql/test/src/test/java/org/apache/causeway/viewer/graphql/viewer/test/e2e/Domain_IntegTest.find_depthead_and_change_name._.gql
similarity index 58%
rename from 
incubator/viewers/graphql/test/src/test/java/org/apache/causeway/viewer/graphql/viewer/test/e2e/Domain_IntegTest.find_department_and_change_name._.gql
rename to 
incubator/viewers/graphql/test/src/test/java/org/apache/causeway/viewer/graphql/viewer/test/e2e/Domain_IntegTest.find_depthead_and_change_name._.gql
index 9638c9484c..b2984ffc87 100644
--- 
a/incubator/viewers/graphql/test/src/test/java/org/apache/causeway/viewer/graphql/viewer/test/e2e/Domain_IntegTest.find_department_and_change_name._.gql
+++ 
b/incubator/viewers/graphql/test/src/test/java/org/apache/causeway/viewer/graphql/viewer/test/e2e/Domain_IntegTest.find_depthead_and_change_name._.gql
@@ -7,15 +7,6 @@
             invoke(newName: "bar") {
               name {
                 get
-                hidden
-                disabled
-              }
-              department {
-                get {
-                  name {
-                    get
-                  }
-                }
               }
             }
           }
diff --git 
a/incubator/viewers/graphql/test/src/test/java/org/apache/causeway/viewer/graphql/viewer/test/e2e/Domain_IntegTest.find_department_and_change_name.approved.json
 
b/incubator/viewers/graphql/test/src/test/java/org/apache/causeway/viewer/graphql/viewer/test/e2e/Domain_IntegTest.find_depthead_and_change_name.approved.json
similarity index 55%
rename from 
incubator/viewers/graphql/test/src/test/java/org/apache/causeway/viewer/graphql/viewer/test/e2e/Domain_IntegTest.find_department_and_change_name.approved.json
rename to 
incubator/viewers/graphql/test/src/test/java/org/apache/causeway/viewer/graphql/viewer/test/e2e/Domain_IntegTest.find_depthead_and_change_name.approved.json
index 0226001cf9..791198eb5a 100644
--- 
a/incubator/viewers/graphql/test/src/test/java/org/apache/causeway/viewer/graphql/viewer/test/e2e/Domain_IntegTest.find_department_and_change_name.approved.json
+++ 
b/incubator/viewers/graphql/test/src/test/java/org/apache/causeway/viewer/graphql/viewer/test/e2e/Domain_IntegTest.find_depthead_and_change_name.approved.json
@@ -7,12 +7,7 @@
             "changeName" : {
               "invoke" : {
                 "name" : {
-                  "get" : "bar",
-                  "hidden" : false,
-                  "disabled" : "Disabled via @DomainObject annotation, reason 
not given."
-                },
-                "department" : {
-                  "get" : null
+                  "get" : "bar"
                 }
               }
             }
diff --git 
a/incubator/viewers/graphql/test/src/test/java/org/apache/causeway/viewer/graphql/viewer/test/e2e/Domain_IntegTest.find_depthead_by_name._.gql
 
b/incubator/viewers/graphql/test/src/test/java/org/apache/causeway/viewer/graphql/viewer/test/e2e/Domain_IntegTest.find_depthead_by_name._.gql
new file mode 100644
index 0000000000..05d52e441f
--- /dev/null
+++ 
b/incubator/viewers/graphql/test/src/test/java/org/apache/causeway/viewer/graphql/viewer/test/e2e/Domain_IntegTest.find_depthead_by_name._.gql
@@ -0,0 +1,18 @@
+{
+  university_dept_DeptHeads {
+    findHeadByName {
+      invoke(name: "Dr. Barney Jones") {
+        name {
+          get
+        }
+        department {
+          get {
+            name {
+              get
+            }
+          }
+        }
+      }
+    }
+  }
+}
diff --git 
a/incubator/viewers/graphql/test/src/test/java/org/apache/causeway/viewer/graphql/viewer/test/e2e/Domain_IntegTest.find_depthead_by_name.approved.json
 
b/incubator/viewers/graphql/test/src/test/java/org/apache/causeway/viewer/graphql/viewer/test/e2e/Domain_IntegTest.find_depthead_by_name.approved.json
new file mode 100644
index 0000000000..7a74179c65
--- /dev/null
+++ 
b/incubator/viewers/graphql/test/src/test/java/org/apache/causeway/viewer/graphql/viewer/test/e2e/Domain_IntegTest.find_depthead_by_name.approved.json
@@ -0,0 +1,20 @@
+{
+  "data" : {
+    "university_dept_DeptHeads" : {
+      "findHeadByName" : {
+        "invoke" : {
+          "name" : {
+            "get" : "Dr. Barney Jones"
+          },
+          "department" : {
+            "get" : {
+              "name" : {
+                "get" : "Classics"
+              }
+            }
+          }
+        }
+      }
+    }
+  }
+}
\ No newline at end of file
diff --git 
a/incubator/viewers/graphql/test/src/test/java/org/apache/causeway/viewer/graphql/viewer/test/e2e/Domain_IntegTest.java
 
b/incubator/viewers/graphql/test/src/test/java/org/apache/causeway/viewer/graphql/viewer/test/e2e/Domain_IntegTest.java
index 8ca42fc373..9bc1c0af68 100644
--- 
a/incubator/viewers/graphql/test/src/test/java/org/apache/causeway/viewer/graphql/viewer/test/e2e/Domain_IntegTest.java
+++ 
b/incubator/viewers/graphql/test/src/test/java/org/apache/causeway/viewer/graphql/viewer/test/e2e/Domain_IntegTest.java
@@ -43,7 +43,6 @@ import 
org.apache.causeway.viewer.graphql.viewer.test.domain.Department;
 import 
org.apache.causeway.viewer.graphql.viewer.test.domain.DepartmentRepository;
 import org.apache.causeway.viewer.graphql.viewer.test.domain.DeptHead;
 import 
org.apache.causeway.viewer.graphql.viewer.test.domain.DeptHeadRepository;
-import org.apache.causeway.viewer.graphql.viewer.test.domain.Departments;
 
 import static 
org.apache.causeway.commons.internal.assertions._Assert.assertEquals;
 import static 
org.apache.causeway.commons.internal.assertions._Assert.assertTrue;
@@ -117,6 +116,22 @@ public class Domain_IntegTest extends 
CausewayViewerGraphqlTestModuleIntegTestAb
         Approvals.verify(submit(), jsonOptions());
     }
 
+    @Test
+    @UseReporter(DiffReporter.class)
+    void find_department_by_name() throws Exception {
+
+        // when, then
+        Approvals.verify(submit(), jsonOptions());
+    }
+
+    @Test
+    @UseReporter(DiffReporter.class)
+    void find_depthead_by_name() throws Exception {
+
+        // when, then
+        Approvals.verify(submit(), jsonOptions());
+    }
+
     @Test
     @UseReporter(DiffReporter.class)
     void create_department() throws Exception {
@@ -182,7 +197,7 @@ public class Domain_IntegTest extends 
CausewayViewerGraphqlTestModuleIntegTestAb
 
     @Test
     @UseReporter(DiffReporter.class)
-    void find_department_and_change_name() throws Exception {
+    void find_depthead_and_change_name() throws Exception {
 
         // given
         transactionService.callTransactional(
diff --git 
a/incubator/viewers/graphql/test/src/test/java/org/apache/causeway/viewer/graphql/viewer/test/e2e/Schema_IntegTest.schema.approved.json
 
b/incubator/viewers/graphql/test/src/test/java/org/apache/causeway/viewer/graphql/viewer/test/e2e/Schema_IntegTest.schema.approved.json
index b11babc82b..b8815b5763 100644
--- 
a/incubator/viewers/graphql/test/src/test/java/org/apache/causeway/viewer/graphql/viewer/test/e2e/Schema_IntegTest.schema.approved.json
+++ 
b/incubator/viewers/graphql/test/src/test/java/org/apache/causeway/viewer/graphql/viewer/test/e2e/Schema_IntegTest.schema.approved.json
@@ -13965,6 +13965,17 @@
           },
           "isDeprecated" : false,
           "deprecationReason" : null
+        }, {
+          "name" : "staffMembers",
+          "description" : null,
+          "args" : [ ],
+          "type" : {
+            "kind" : "OBJECT",
+            "name" : "university_dept_Department__staffMembers__collection",
+            "ofType" : null
+          },
+          "isDeprecated" : false,
+          "deprecationReason" : null
         } ],
         "inputFields" : null,
         "interfaces" : [ ],
@@ -14130,6 +14141,52 @@
         "interfaces" : [ ],
         "enumValues" : null,
         "possibleTypes" : null
+      }, {
+        "kind" : "OBJECT",
+        "name" : "university_dept_Department__staffMembers__collection",
+        "description" : null,
+        "fields" : [ {
+          "name" : "hidden",
+          "description" : null,
+          "args" : [ ],
+          "type" : {
+            "kind" : "SCALAR",
+            "name" : "Boolean",
+            "ofType" : null
+          },
+          "isDeprecated" : false,
+          "deprecationReason" : null
+        }, {
+          "name" : "disabled",
+          "description" : null,
+          "args" : [ ],
+          "type" : {
+            "kind" : "SCALAR",
+            "name" : "String",
+            "ofType" : null
+          },
+          "isDeprecated" : false,
+          "deprecationReason" : null
+        }, {
+          "name" : "get",
+          "description" : null,
+          "args" : [ ],
+          "type" : {
+            "kind" : "LIST",
+            "name" : null,
+            "ofType" : {
+              "kind" : "OBJECT",
+              "name" : "university_dept_StaffMember",
+              "ofType" : null
+            }
+          },
+          "isDeprecated" : false,
+          "deprecationReason" : null
+        } ],
+        "inputFields" : null,
+        "interfaces" : [ ],
+        "enumValues" : null,
+        "possibleTypes" : null
       }, {
         "kind" : "OBJECT",
         "name" : "university_dept_Departments",
@@ -14145,6 +14202,17 @@
           },
           "isDeprecated" : false,
           "deprecationReason" : null
+        }, {
+          "name" : "findByName",
+          "description" : null,
+          "args" : [ ],
+          "type" : {
+            "kind" : "OBJECT",
+            "name" : "university_dept_Departments__findByName__action",
+            "ofType" : null
+          },
+          "isDeprecated" : false,
+          "deprecationReason" : null
         }, {
           "name" : "_gql_mutations",
           "description" : null,
@@ -14271,6 +14339,61 @@
         "interfaces" : [ ],
         "enumValues" : null,
         "possibleTypes" : null
+      }, {
+        "kind" : "OBJECT",
+        "name" : "university_dept_Departments__findByName__action",
+        "description" : null,
+        "fields" : [ {
+          "name" : "hidden",
+          "description" : null,
+          "args" : [ ],
+          "type" : {
+            "kind" : "SCALAR",
+            "name" : "Boolean",
+            "ofType" : null
+          },
+          "isDeprecated" : false,
+          "deprecationReason" : null
+        }, {
+          "name" : "disabled",
+          "description" : null,
+          "args" : [ ],
+          "type" : {
+            "kind" : "SCALAR",
+            "name" : "String",
+            "ofType" : null
+          },
+          "isDeprecated" : false,
+          "deprecationReason" : null
+        }, {
+          "name" : "invoke",
+          "description" : null,
+          "args" : [ {
+            "name" : "name",
+            "description" : null,
+            "type" : {
+              "kind" : "NON_NULL",
+              "name" : null,
+              "ofType" : {
+                "kind" : "SCALAR",
+                "name" : "String",
+                "ofType" : null
+              }
+            },
+            "defaultValue" : null
+          } ],
+          "type" : {
+            "kind" : "OBJECT",
+            "name" : "university_dept_Department",
+            "ofType" : null
+          },
+          "isDeprecated" : false,
+          "deprecationReason" : null
+        } ],
+        "inputFields" : null,
+        "interfaces" : [ ],
+        "enumValues" : null,
+        "possibleTypes" : null
       }, {
         "kind" : "OBJECT",
         "name" : "university_dept_Departments__gql_mutations",
diff --git 
a/incubator/viewers/graphql/test/src/test/java/org/apache/causeway/viewer/graphql/viewer/test/e2e/Schema_IntegTest.schema_types_name.approved.json
 
b/incubator/viewers/graphql/test/src/test/java/org/apache/causeway/viewer/graphql/viewer/test/e2e/Schema_IntegTest.schema_types_name.approved.json
index cd0f9b72c8..7b105f1437 100644
--- 
a/incubator/viewers/graphql/test/src/test/java/org/apache/causeway/viewer/graphql/viewer/test/e2e/Schema_IntegTest.schema_types_name.approved.json
+++ 
b/incubator/viewers/graphql/test/src/test/java/org/apache/causeway/viewer/graphql/viewer/test/e2e/Schema_IntegTest.schema_types_name.approved.json
@@ -645,12 +645,16 @@
         "name" : "university_dept_Department__gql_meta"
       }, {
         "name" : "university_dept_Department__name__property"
+      }, {
+        "name" : "university_dept_Department__staffMembers__collection"
       }, {
         "name" : "university_dept_Departments"
       }, {
         "name" : "university_dept_Departments__createDepartment__action"
       }, {
         "name" : "university_dept_Departments__findAllDepartments__action"
+      }, {
+        "name" : "university_dept_Departments__findByName__action"
       }, {
         "name" : "university_dept_Departments__gql_mutations"
       }, {
diff --git a/incubator/viewers/graphql/test/src/test/resources/schema.gql 
b/incubator/viewers/graphql/test/src/test/resources/schema.gql
index 1eb3309ced..dba7b9c464 100644
--- a/incubator/viewers/graphql/test/src/test/resources/schema.gql
+++ b/incubator/viewers/graphql/test/src/test/resources/schema.gql
@@ -1611,6 +1611,7 @@ type university_dept_Department {
   _gql_meta: university_dept_Department__gql_meta
   deptHead: university_dept_Department__deptHead__property
   name: university_dept_Department__name__property
+  staffMembers: university_dept_Department__staffMembers__collection
 }
 
 type university_dept_Department__deptHead__property {
@@ -1631,9 +1632,16 @@ type university_dept_Department__name__property {
   hidden: Boolean
 }
 
+type university_dept_Department__staffMembers__collection {
+  disabled: String
+  get: [university_dept_StaffMember]
+  hidden: Boolean
+}
+
 type university_dept_Departments {
   _gql_mutations: university_dept_Departments__gql_mutations
   findAllDepartments: university_dept_Departments__findAllDepartments__action
+  findByName: university_dept_Departments__findByName__action
 }
 
 type university_dept_Departments__createDepartment__action {
@@ -1648,6 +1656,12 @@ type 
university_dept_Departments__findAllDepartments__action {
   invoke: [university_dept_Department]
 }
 
+type university_dept_Departments__findByName__action {
+  disabled: String
+  hidden: Boolean
+  invoke(name: String!): university_dept_Department
+}
+
 type university_dept_Departments__gql_mutations {
   createDepartment: university_dept_Departments__createDepartment__action
 }

Reply via email to