borinquenkid commented on code in PR #15568:
URL: https://github.com/apache/grails-core/pull/15568#discussion_r3440093708
##########
grails-data-hibernate5/core/src/test/groovy/grails/gorm/tests/validation/UniqueWithinGroupSpec.groovy:
##########
@@ -19,35 +19,28 @@
package grails.gorm.tests.validation
import grails.gorm.annotation.Entity
+import grails.gorm.tests.HibernateGormDatastoreSpec
import grails.gorm.transactions.Rollback
import groovy.transform.EqualsAndHashCode
-import org.grails.orm.hibernate.HibernateDatastore
-import org.hibernate.SessionFactory
import org.springframework.dao.DuplicateKeyException
-import spock.lang.AutoCleanup
import spock.lang.Issue
-import spock.lang.Shared
-import spock.lang.Specification
/**
* Created by graemerocher on 29/05/2017.
*/
-@Issue('https://github.com/grails/grails-data-hibernate5/issues/36')
-class UniqueWithinGroupSpec extends Specification {
+@Issue('https://github.com/grails/gorm-hibernate5/issues/36')
Review Comment:
Reverted — this file is unchanged from `8.0.x` in the current revision.
##########
grails-data-hibernate5/core/src/test/groovy/grails/gorm/tests/validation/UniqueWithinGroupSpec.groovy:
##########
@@ -19,35 +19,28 @@
package grails.gorm.tests.validation
import grails.gorm.annotation.Entity
+import grails.gorm.tests.HibernateGormDatastoreSpec
import grails.gorm.transactions.Rollback
import groovy.transform.EqualsAndHashCode
-import org.grails.orm.hibernate.HibernateDatastore
-import org.hibernate.SessionFactory
import org.springframework.dao.DuplicateKeyException
-import spock.lang.AutoCleanup
import spock.lang.Issue
-import spock.lang.Shared
-import spock.lang.Specification
/**
* Created by graemerocher on 29/05/2017.
*/
-@Issue('https://github.com/grails/grails-data-hibernate5/issues/36')
-class UniqueWithinGroupSpec extends Specification {
+@Issue('https://github.com/grails/gorm-hibernate5/issues/36')
+class UniqueWithinGroupSpec extends HibernateGormDatastoreSpec {
- @AutoCleanup
- @Shared
- HibernateDatastore hibernateDatastore = new
HibernateDatastore(getClass().getPackage())
-
- @Shared
- SessionFactory sessionFactory = hibernateDatastore.sessionFactory
+ def setupSpec() {
+ manager.registerDomainClasses(Thing)
+ }
@Rollback
void "test insert"() {
when:
Thing thing1 = new Thing(hello: 1, world: 2)
thing1.insert(flush: true)
- sessionFactory.currentSession.flush()
+
Review Comment:
Reverted — this file is unchanged from `8.0.x` in the current revision.
##########
grails-data-hibernate5/core/src/test/groovy/grails/gorm/tests/validation/UniqueWithinGroupSpec.groovy:
##########
@@ -19,35 +19,28 @@
package grails.gorm.tests.validation
import grails.gorm.annotation.Entity
+import grails.gorm.tests.HibernateGormDatastoreSpec
import grails.gorm.transactions.Rollback
import groovy.transform.EqualsAndHashCode
-import org.grails.orm.hibernate.HibernateDatastore
-import org.hibernate.SessionFactory
import org.springframework.dao.DuplicateKeyException
-import spock.lang.AutoCleanup
import spock.lang.Issue
-import spock.lang.Shared
-import spock.lang.Specification
/**
* Created by graemerocher on 29/05/2017.
*/
-@Issue('https://github.com/grails/grails-data-hibernate5/issues/36')
-class UniqueWithinGroupSpec extends Specification {
+@Issue('https://github.com/grails/gorm-hibernate5/issues/36')
Review Comment:
Reverted — this file is unchanged from `8.0.x` in the current revision.
##########
grails-data-hibernate5/core/src/test/groovy/org/apache/grails/data/hibernate5/core/GrailsDataHibernate5TckManager.groovy:
##########
@@ -62,17 +63,20 @@ class GrailsDataHibernate5TckManager extends
GrailsDataTckManager {
@Override
Session createSession() {
- ConfigObject grailsConfig = new ConfigObject()
+ ConfigObject config = new ConfigObject()
+ if (grailsConfig) {
+ config.putAll(grailsConfig)
+ }
+ if (!config.containsKey('dataSource.dbCreate') &&
!config.dataSource.containsKey('dbCreate')) {
+ config.dataSource.dbCreate = "create-drop"
+ }
boolean isTransactional = true
System.setProperty('hibernate5.gorm.suite', "true")
- grailsApplication = new DefaultGrailsApplication(domainClasses, new
GroovyClassLoader(GrailsDataHibernate5TckManager.getClassLoader()))
- if (grailsConfig) {
- grailsApplication.config.putAll(grailsConfig)
- }
+ grailsApplication = new DefaultGrailsApplication(domainClasses as
Class[], new GroovyClassLoader(GrailsDataHibernate5TckManager.getClassLoader()))
Review Comment:
Reverted — this file is unchanged from `8.0.x` in the current revision.
##########
grails-data-hibernate5/core/src/test/groovy/org/grails/datastore/gorm/GormEnhancerCleanupSpec.groovy:
##########
@@ -0,0 +1,85 @@
+/* Copyright (C) 2026 the original author or authors.
+ *
+ * Licensed 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
+
+import grails.gorm.annotation.Entity
+import grails.gorm.tests.HibernateGormDatastoreSpec
+import org.grails.datastore.mapping.core.Datastore
+import spock.lang.Specification
+import java.util.concurrent.ConcurrentHashMap
Review Comment:
Reverted — this file is unchanged from `8.0.x` in the current revision.
##########
grails-data-hibernate5/core/src/test/groovy/org/grails/orm/hibernate/HibernateDatastoreMultiTenancySpec.groovy:
##########
@@ -0,0 +1,101 @@
+/*
+ * 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.orm.hibernate
+
+import grails.gorm.MultiTenant
+import grails.gorm.annotation.Entity
+import grails.gorm.multitenancy.Tenants
+import grails.gorm.tests.HibernateGormDatastoreSpec
+import org.grails.datastore.mapping.core.connections.ConnectionSource
+import org.grails.datastore.mapping.multitenancy.MultiTenancySettings
+import
org.grails.datastore.mapping.multitenancy.resolvers.SystemPropertyTenantResolver
+import org.grails.orm.hibernate.cfg.Settings
+import org.hibernate.FlushMode
+import spock.lang.Issue
+
+import javax.sql.DataSource
+
Review Comment:
Reverted — this file is unchanged from `8.0.x` in the current revision.
##########
grails-data-hibernate5/core/src/test/groovy/org/grails/orm/hibernate/HibernateDatastoreMultiTenancySpec.groovy:
##########
@@ -0,0 +1,101 @@
+/*
+ * 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.orm.hibernate
+
+import grails.gorm.MultiTenant
+import grails.gorm.annotation.Entity
+import grails.gorm.multitenancy.Tenants
+import grails.gorm.tests.HibernateGormDatastoreSpec
+import org.grails.datastore.mapping.core.connections.ConnectionSource
+import org.grails.datastore.mapping.multitenancy.MultiTenancySettings
+import
org.grails.datastore.mapping.multitenancy.resolvers.SystemPropertyTenantResolver
+import org.grails.orm.hibernate.cfg.Settings
+import org.hibernate.FlushMode
+import spock.lang.Issue
+
+import javax.sql.DataSource
+
+class HibernateDatastoreMultiTenancySpec extends HibernateGormDatastoreSpec {
+
+ def setupSpec() {
+ manager.grailsConfig = [
+ 'dataSource.url' :
"jdbc:h2:mem:grailsDB-multi;LOCK_TIMEOUT=10000",
+ 'dataSource.dbCreate' : 'create-drop',
+ 'hibernate.flush.mode' : 'COMMIT',
+ 'grails.gorm.multiTenancy.mode':
MultiTenancySettings.MultiTenancyMode.DISCRIMINATOR,
+ 'grails.gorm.multiTenancy.tenantResolver': new
SystemPropertyTenantResolver()
+ ]
+ manager.registerDomainClasses(MultiTenantBook)
+ }
+
+ void "test discriminator multi-tenancy filter"() {
+ given:
+ System.setProperty(SystemPropertyTenantResolver.PROPERTY_NAME,
"tenant1")
+
+ when:
+ def result = datastore.withSession {
+ new MultiTenantBook(title: "Book 1").save()
+ MultiTenantBook.list()
+ }
+
+ then:
+ result.size() == 1
+ result[0].tenantId == "tenant1"
+
+ when:
+ System.setProperty(SystemPropertyTenantResolver.PROPERTY_NAME,
"tenant2")
+ result = datastore.withSession {
+ new MultiTenantBook(title: "Book 2").save()
+ MultiTenantBook.list()
+ }
+
+ then:
+ result.size() == 1
+ result[0].tenantId == "tenant2"
+
+ cleanup:
+ System.clearProperty(SystemPropertyTenantResolver.PROPERTY_NAME)
Review Comment:
Reverted — this file is unchanged from `8.0.x` in the current revision.
##########
grails-data-hibernate5/core/src/test/groovy/grails/gorm/tests/HibernateValidationSpec.groovy:
##########
@@ -22,6 +22,9 @@ import org.apache.grails.data.testing.tck.domains.ChildEntity
import
org.apache.grails.data.testing.tck.domains.ClassWithListArgBeforeValidate
import org.apache.grails.data.testing.tck.domains.ClassWithNoArgBeforeValidate
import
org.apache.grails.data.testing.tck.domains.ClassWithOverloadedBeforeValidate
+import org.apache.grails.data.testing.tck.domains.Location
+import org.apache.grails.data.testing.tck.domains.Person
+import org.apache.grails.data.testing.tck.domains.Pet
Review Comment:
Reverted — this file is unchanged from `8.0.x` in the current revision.
##########
grails-data-hibernate5/core/src/test/groovy/grails/gorm/tests/dirtychecking/HibernateUpdateFromListenerSpec.groovy:
##########
@@ -85,6 +85,9 @@ class HibernateUpdateFromListenerSpec extends Specification {
if (event.entityObject instanceof Person) {
Person person = (Person) event.entityObject
person.occupation = person.occupation + " listener"
+ if (event.getEntityAccess() != null) {
+ event.getEntityAccess().setProperty("occupation",
person.occupation)
+ }
Review Comment:
Reverted — this file is unchanged from `8.0.x` in the current revision.
##########
grails-data-hibernate5/core/src/test/groovy/grails/gorm/tests/dirtychecking/PropertyFieldSpec.groovy:
##########
@@ -33,7 +33,7 @@ class PropertyFieldSpec extends Specification {
@Shared @AutoCleanup HibernateDatastore hibernateDatastore = new
HibernateDatastore(getClass().getPackage())
@Rollback
- @Issue('https://github.com/apache/grails-data-mapping/issues/934')
+ @Issue('https://github.com/grails/grails-data-mapping/issues/934')
Review Comment:
Reverted — this file is unchanged from `8.0.x` in the current revision.
--
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]