jamesfredley commented on code in PR #15435:
URL: https://github.com/apache/grails-core/pull/15435#discussion_r2847118066


##########
grails-datamapping-core/src/test/groovy/org/grails/datastore/gorm/GormEnhancerAllQualifiersSpec.groovy:
##########
@@ -102,6 +102,38 @@ class GormEnhancerAllQualifiersSpec extends Specification {
         qualifiers == ['secondary']
     }
 
+    void "registerEntity adds static api under default and secondary for 
non-default datasource"() {
+        given: "a non-MultiTenant entity with datasource 'secondary'"
+        def enhancer = createEnhancer()
+        def entity = mockEntity(NonMultiTenantSecondaryEntity, ['secondary'])
+        def staticApis = GormEnhancer.@STATIC_APIS
+        staticApis.get(ConnectionSource.DEFAULT).remove(entity.name)
+        staticApis.get('secondary').remove(entity.name)
+
+        when: "registering the entity"
+        enhancer.registerEntity(entity)
+
+        then: "static api is available under DEFAULT and secondary qualifiers"
+        staticApis.get(ConnectionSource.DEFAULT).containsKey(entity.name)
+        staticApis.get('secondary').containsKey(entity.name)

Review Comment:
   These are unit tests for `GormEnhancer.registerEntity()` internals using 
mock/stub entities that are not real GORM-enhanced domain classes. 
`findStaticApi()` won't work here since the entities lack full GORM 
enhancement. Kept `@STATIC_APIS` access for assertions but removed the 
destructive `.remove()` calls to make the tests parallel-safe.



##########
grails-datamapping-core/src/test/groovy/org/grails/datastore/gorm/GormEnhancerAllQualifiersSpec.groovy:
##########
@@ -159,6 +191,20 @@ class GormEnhancerAllQualifiersSpec extends Specification {
         qualifiers == [ConnectionSource.DEFAULT]
     }
 
+    void "registerEntity adds static api under default for default 
datasource"() {
+        given: "a non-MultiTenant entity on the default datasource"
+        def enhancer = createEnhancer()
+        def entity = mockEntity(NonMultiTenantDefaultEntity, 
[ConnectionSource.DEFAULT])
+        def staticApis = GormEnhancer.@STATIC_APIS
+        staticApis.get(ConnectionSource.DEFAULT).remove(entity.name)
+
+        when: "registering the entity"
+        enhancer.registerEntity(entity)
+
+        then: "static api is available under DEFAULT qualifier"
+        staticApis.get(ConnectionSource.DEFAULT).containsKey(entity.name)

Review Comment:
   Same as above - these are unit tests for `GormEnhancer` internals with mock 
entities. `findStaticApi()` requires full GORM enhancement which these stubs 
don't have. Kept `@STATIC_APIS` for assertions, removed the `.remove()` calls 
for parallel-test safety.



-- 
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