jdaugherty commented on code in PR #16143:
URL: https://github.com/apache/grails-core/pull/16143#discussion_r4146438901


##########
grails-datamapping-core/src/main/groovy/org/grails/datastore/gorm/query/criteria/AbstractDetachedCriteria.groovy:
##########
@@ -216,7 +216,7 @@ abstract class AbstractDetachedCriteria<T> implements 
Criteria, Cloneable {
             }
         }
         if (junctions)  {
-            junctions[-1].add(criterion)
+            junctions.getLast().add(criterion)

Review Comment:
   Resolved: `args[-1]` is back in the rebased branch (the `getLast()` change 
was dropped).



##########
grails-datamapping-rx/src/test/groovy/org/grails/gorm/rx/api/DetachedCriteriaQuerySpec.groovy:
##########
@@ -0,0 +1,295 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    https://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package org.grails.gorm.rx.api
+
+import grails.gorm.rx.DetachedCriteria
+import jakarta.persistence.criteria.JoinType
+import org.grails.datastore.mapping.core.connections.ConnectionSource
+import org.grails.datastore.mapping.model.MappingContext
+import org.grails.datastore.mapping.model.PersistentEntity
+import org.grails.datastore.mapping.query.Query
+import org.grails.datastore.mapping.query.api.QueryArgumentsAware
+import org.grails.datastore.rx.internal.RxDatastoreClientImplementor
+import org.grails.datastore.rx.query.RxQuery
+import org.springframework.core.convert.ConversionService
+import rx.Observable
+import rx.Subscriber
+import spock.lang.Specification
+
+/**
+ * Exercises the reactive query-execution methods on {@link DetachedCriteria} 
(rx) - the ones
+ * that go through {@code prepareQuery} and {@link 
RxGormEnhancer#findStaticApi}. This requires
+ * a fake entity registered with {@link RxGormEnhancer}, since those static 
lookups can't be
+ * intercepted from outside the {@code CompileStatic} call site with 
metaclass-based mocking.
+ * Package-local so the test can call the {@code protected static}
+ * {@code RxGormEnhancer.registerEntityWithConnectionSource} directly rather 
than driving the
+ * full {@code registerEntity} multi-tenancy/connection-source resolution 
machinery.
+ */
+class DetachedCriteriaQuerySpec extends Specification {
+
+    Query mockQuery
+    RxDatastoreClientImplementor datastoreClient
+
+    void setup() {
+        def queryEntity = Mock(PersistentEntity) {
+            getMappingContext() >> Mock(MappingContext) {
+                getConversionService() >> Mock(ConversionService)
+            }
+        }
+        mockQuery = Mock(Query, additionalInterfaces: [RxQuery, 
QueryArgumentsAware]) {
+            getEntity() >> queryEntity
+        }
+        datastoreClient = Mock(RxDatastoreClientImplementor) {
+            createQuery(QueryTestEntity, _ as Map) >> mockQuery
+        }
+        def persistentEntity = Mock(PersistentEntity) {
+            getJavaClass() >> QueryTestEntity
+            getName() >> QueryTestEntity.name
+        }
+        def staticApi = Mock(RxGormStaticApi) {
+            getDatastoreClient() >> datastoreClient
+        }
+        datastoreClient.createStaticApi(persistentEntity, 
ConnectionSource.DEFAULT) >> staticApi
+        datastoreClient.createInstanceApi(persistentEntity, 
ConnectionSource.DEFAULT) >> Mock(RxGormInstanceApi)
+        datastoreClient.createValidationApi(persistentEntity, 
ConnectionSource.DEFAULT) >> Mock(RxGormValidationApi)
+        RxGormEnhancer.registerEntityWithConnectionSource(persistentEntity, 
ConnectionSource.DEFAULT, ConnectionSource.DEFAULT, datastoreClient)

Review Comment:
   Resolved: `DetachedCriteriaQuerySpec` is gone and the only new coverage, the 
custom `JoinType` passthrough, now lives in the existing 
`grails.gorm.rx.DetachedCriteriaSpec`.



##########
grails-datamapping-core/src/test/groovy/org/grails/datastore/gorm/query/criteria/AbstractDetachedCriteriaSpec.groovy:
##########
@@ -0,0 +1,1167 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    https://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package org.grails.datastore.gorm.query.criteria
+
+import grails.gorm.DetachedCriteria
+
+import jakarta.persistence.FetchType
+import jakarta.persistence.criteria.JoinType
+
+import org.grails.datastore.gorm.finders.FinderMethod
+import org.grails.datastore.mapping.model.PersistentEntity
+import org.grails.datastore.mapping.model.PersistentProperty
+import org.grails.datastore.mapping.model.types.Association
+import org.grails.datastore.mapping.query.Query
+import org.grails.datastore.mapping.query.api.QueryableCriteria
+import spock.lang.Specification
+
+/**
+ * Exercises {@link AbstractDetachedCriteria} through its concrete subclass 
{@link DetachedCriteria}.
+ */
+class AbstractDetachedCriteriaSpec extends Specification {
+
+    void "eq adds an Equals criterion"() {
+        given:
+        def criteria = new DetachedCriteria(TestEntity)

Review Comment:
   Resolved: `TestEntity` now has its own file in this package, and the 
features that need a real GORM entity use dedicated `@Entity` fixtures declared 
in this spec.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to