grails.gorm.tests.QueryByAssociationSpec.groovy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of grace-datastore-gorm-tck Show documentation
Show all versions of grace-datastore-gorm-tck Show documentation
Grace Data : Grace Datastore Gorm Tck
package grails.gorm.tests
/**
* Abstract base test for query associations. Subclasses should do the necessary setup to configure GORM
*/
class QueryByAssociationSpec extends GormDatastoreSpec {
void "Test query entity by single-ended association"() {
given:
def age = 40
["Bob", "Fred", "Barney", "Frank"].each { new TestEntity(name:it, age: age++, child:new ChildEntity(name:"$it Child")).save() }
when:
def child = ChildEntity.findByName("Barney Child")
then:
child != null
child.id != null
when:
def t = TestEntity.findByChild(child)
then:
t != null
"Barney" == t.name
}
}