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

borinquenkid pushed a commit to branch merge-hibernate6
in repository https://gitbox.apache.org/repos/asf/grails-core.git

commit 06da8228a4c74e6b0ce47e851eabc3f63997dca2
Author: Walter Duque de Estrada <wbdu...@mac.com>
AuthorDate: Tue Aug 19 12:40:38 2025 -0500

    moved tests to working setup
---
 .../groovy/grails/gorm/specs/SqlQuerySpec.groovy   | 149 -------------------
 .../hibernate/HibernateGormStaticApiSpec.groovy    | 162 +++++++++++++++------
 2 files changed, 114 insertions(+), 197 deletions(-)

diff --git 
a/grails-data-hibernate6/core/src/test/groovy/grails/gorm/specs/SqlQuerySpec.groovy
 
b/grails-data-hibernate6/core/src/test/groovy/grails/gorm/specs/SqlQuerySpec.groovy
deleted file mode 100644
index 37df8bd1aa..0000000000
--- 
a/grails-data-hibernate6/core/src/test/groovy/grails/gorm/specs/SqlQuerySpec.groovy
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- *  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 grails.gorm.specs
-
-import grails.gorm.specs.entities.Club
-import grails.gorm.transactions.Rollback
-import org.grails.orm.hibernate.HibernateDatastore
-import org.springframework.transaction.PlatformTransactionManager
-import spock.lang.AutoCleanup
-import spock.lang.Shared
-import spock.lang.Specification
-
-/**
- * Created by graemerocher on 17/11/16.
- */
-@Rollback
-class SqlQuerySpec extends Specification {
-
-    @Shared @AutoCleanup HibernateDatastore datastore = new 
HibernateDatastore(Club)
-    @Shared PlatformTransactionManager transactionManager = 
datastore.getTransactionManager()
-
-    void "test simple query returns a single result"() {
-        given:
-        setupTestData()
-
-        when:"Some test data is saved"
-        String name = "Arsenal"
-        Club c = Club.findWithSql("select * from club c where c.name = $name")
-
-        then:"The results are correct"
-        c != null
-        c.name == name
-
-    }
-
-    void "test simple sql query"() {
-
-        given:
-        setupTestData()
-
-        when:"Some test data is saved"
-        List<Club> results = Club.findAllWithSql("select * from club c order 
by c.name")
-
-        then:"The results are correct"
-        results.size() == 3
-        results[0] instanceof Club
-        results[0].name == 'Arsenal'
-    }
-
-    void "test sql query with gstring parameters"() {
-        given:
-        setupTestData()
-
-        when:"Some test data is saved"
-        String p = "%l%"
-        List<Club> results = Club.findAllWithSql("select * from club c where 
c.name like $p order by c.name")
-
-        then:"The results are correct"
-        results.size() == 2
-        results[0] instanceof Club
-        results[0].name == 'Arsenal'
-    }
-
-    void "test escape HQL in findAll with gstring"() {
-        given:
-        setupTestData()
-
-        when:"A query is used that embeds a GString with a value that should 
be encoded for the query to succeed"
-        String p = "%l%"
-        List<Club> results = Club.findAll("from Club c where c.name like $p 
order by c.name")
-
-        then:"The results are correct"
-        results.size() == 2
-        results[0] instanceof Club
-        results[0].name == 'Arsenal'
-
-        when:"A query that passes arguments is used"
-        results = Club.findAll("from Club c where c.name like $p and c.name 
like :test order by c.name", [test:'%e%'])
-
-        then:"The results are correct"
-        results.size() == 2
-        results[0] instanceof Club
-        results[0].name == 'Arsenal'
-    }
-
-    void "test escape HQL in executeQuery with gstring"() {
-        given:
-        setupTestData()
-
-        when:"A query is used that embeds a GString with a value that should 
be encoded for the query to succeed"
-        String p = "%l%"
-        List<Club> results = Club.executeQuery("from Club c where c.name like 
$p order by c.name")
-
-        then:"The results are correct"
-        results.size() == 2
-        results[0] instanceof Club
-        results[0].name == 'Arsenal'
-
-        when:"A query that passes arguments is used"
-        results = Club.executeQuery("from Club c where c.name like $p and 
c.name like :test order by c.name", [test:'%e%'])
-
-        then:"The results are correct"
-        results.size() == 2
-        results[0] instanceof Club
-        results[0].name == 'Arsenal'
-    }
-
-    void "test escape HQL in find with gstring"() {
-        given:
-        setupTestData()
-
-        when:"A query is used that embeds a GString with a value that should 
be encoded for the query to succeed"
-        String p = "%chester%"
-        Club c = Club.find("from Club c where c.name like $p order by c.name")
-
-        then:"The results are correct"
-        c != null
-        c.name == 'Manchester United'
-
-        when:"A query that passes arguments is used"
-        c = Club.find("from Club c where c.name like $p and c.name like :test 
order by c.name", [test:'%e%'])
-
-        then:"The results are correct"
-        c != null
-        c.name == 'Manchester United'
-    }
-
-    protected void setupTestData() {
-        new Club(name: "Barcelona").save()
-        new Club(name: "Arsenal").save()
-        new Club(name: "Manchester United").save(flush: true)
-    }
-}
diff --git 
a/grails-data-hibernate6/core/src/test/groovy/org/grails/orm/hibernate/HibernateGormStaticApiSpec.groovy
 
b/grails-data-hibernate6/core/src/test/groovy/org/grails/orm/hibernate/HibernateGormStaticApiSpec.groovy
index 0e5c68ede6..89621d8e40 100644
--- 
a/grails-data-hibernate6/core/src/test/groovy/org/grails/orm/hibernate/HibernateGormStaticApiSpec.groovy
+++ 
b/grails-data-hibernate6/core/src/test/groovy/org/grails/orm/hibernate/HibernateGormStaticApiSpec.groovy
@@ -4,6 +4,7 @@ import grails.gorm.DetachedCriteria
 import grails.gorm.MultiTenant
 import grails.gorm.specs.HibernateGormDatastoreSpec
 import grails.gorm.annotation.Entity
+import grails.gorm.specs.entities.Club
 import groovy.transform.EqualsAndHashCode
 import org.grails.datastore.mapping.core.Session
 import org.grails.datastore.mapping.query.Query
@@ -16,7 +17,7 @@ import spock.lang.Issue
 class HibernateGormStaticApiSpec extends HibernateGormDatastoreSpec {
 
     void setupSpec() {
-        manager.addAllDomainClasses([HibernateGormStaticApiEntity])
+        manager.addAllDomainClasses([HibernateGormStaticApiEntity,Club])
     }
 
     void "Test that get returns the correct instance"() {
@@ -437,6 +438,118 @@ class HibernateGormStaticApiSpec extends 
HibernateGormDatastoreSpec {
         updated == 1
         instance.name == 'updated'
     }
+
+    void "test simple query returns a single result"() {
+        given:
+        setupTestData()
+
+        when:"Some test data is saved"
+        String name = "Arsenal"
+        Club c = Club.findWithSql("select * from club c where c.name = $name")
+
+        then:"The results are correct"
+        c != null
+        c.name == name
+
+    }
+
+    void "test simple sql query"() {
+
+        given:
+        setupTestData()
+
+        when:"Some test data is saved"
+        List<Club> results = Club.findAllWithSql("select * from club c order 
by c.name")
+
+        then:"The results are correct"
+        results.size() == 3
+        results[0] instanceof Club
+        results[0].name == 'Arsenal'
+    }
+
+    void "test sql query with gstring parameters"() {
+        given:
+        setupTestData()
+
+        when:"Some test data is saved"
+        String p = "%l%"
+        List<Club> results = Club.findAllWithSql("select * from club c where 
c.name like $p order by c.name")
+
+        then:"The results are correct"
+        results.size() == 2
+        results[0] instanceof Club
+        results[0].name == 'Arsenal'
+    }
+
+    void "test escape HQL in findAll with gstring"() {
+        given:
+        setupTestData()
+
+        when:"A query is used that embeds a GString with a value that should 
be encoded for the query to succeed"
+        String p = "%l%"
+        List<Club> results = Club.findAll("from Club c where c.name like $p 
order by c.name")
+
+        then:"The results are correct"
+        results.size() == 2
+        results[0] instanceof Club
+        results[0].name == 'Arsenal'
+
+        when:"A query that passes arguments is used"
+        results = Club.findAll("from Club c where c.name like $p and c.name 
like :test order by c.name", [test:'%e%'])
+
+        then:"The results are correct"
+        results.size() == 2
+        results[0] instanceof Club
+        results[0].name == 'Arsenal'
+    }
+
+    void "test escape HQL in executeQuery with gstring"() {
+        given:
+        setupTestData()
+
+        when:"A query is used that embeds a GString with a value that should 
be encoded for the query to succeed"
+        String p = "%l%"
+        List<Club> results = Club.executeQuery("from Club c where c.name like 
$p order by c.name")
+
+        then:"The results are correct"
+        results.size() == 2
+        results[0] instanceof Club
+        results[0].name == 'Arsenal'
+
+        when:"A query that passes arguments is used"
+        results = Club.executeQuery("from Club c where c.name like $p and 
c.name like :test order by c.name", [test:'%e%'])
+
+        then:"The results are correct"
+        results.size() == 2
+        results[0] instanceof Club
+        results[0].name == 'Arsenal'
+    }
+
+    void "test escape HQL in find with gstring"() {
+        given:
+        setupTestData()
+
+        when:"A query is used that embeds a GString with a value that should 
be encoded for the query to succeed"
+        String p = "%chester%"
+        Club c = Club.find("from Club c where c.name like $p order by c.name")
+
+        then:"The results are correct"
+        c != null
+        c.name == 'Manchester United'
+
+        when:"A query that passes arguments is used"
+        c = Club.find("from Club c where c.name like $p and c.name like :test 
order by c.name", [test:'%e%'])
+
+        then:"The results are correct"
+        c != null
+        c.name == 'Manchester United'
+    }
+
+    protected void setupTestData() {
+        new Club(name: "Barcelona").save()
+        new Club(name: "Arsenal").save()
+        new Club(name: "Manchester United").save(flush: true)
+    }
 }
 
 @Entity
@@ -444,50 +557,3 @@ class HibernateGormStaticApiEntity {
     String name
 }
 
-//@EqualsAndHashCode
-//@Entity
-//class Author implements MultiTenant<Author> {
-//    Integer tenantId
-//    String name
-//    static hasMany = [books: ApiSpecBook]
-//
-//    boolean validate(List fields) {
-//        true
-//    }
-//
-//    Serializable getAssociationId(String associationName) {
-//        null
-//    }
-//
-//    Object propertyMissing(String name) {
-//        throw new MissingPropertyException(name, getClass())
-//    }
-//
-//    Object getPersistentValue(String name) {
-//        null
-//    }
-//}
-//
-//@EqualsAndHashCode
-//@Entity
-//class ApiSpecBook implements MultiTenant<ApiSpecBook> {
-//    Integer tenantId
-//    String title
-//    static belongsTo = [author: Author]
-//
-//    boolean validate(List fields) {
-//        true
-//    }
-//
-//    Serializable getAssociationId(String associationName) {
-//        null
-//    }
-//
-//    Object propertyMissing(String name) {
-//        throw new MissingPropertyException(name, getClass())
-//    }
-//
-//    Object getPersistentValue(String name) {
-//        null
-//    }
-//}
\ No newline at end of file

Reply via email to