GRAILS-1019: Allowing expressions to be used with the 'disabled' attribute for g...
[grails.git] / test / groovy / org / codehaus / groovy / grails / orm / hibernate / ManyToManyAndOneToOneTests.groovy
blob52b827833dd6bf58fce95f80a91830c4698a7042
1 /**
2 * Tests a many-to-many and one-to-one relationship used together
4 * @author Graeme Rocher
5 * @since 1.0
6 *
7 * Created: Oct 12, 2007
8 */
9 package org.codehaus.groovy.grails.orm.hibernate
11 import org.codehaus.groovy.grails.commons.GrailsDomainClass
13 class ManyToManyAndOneToOneTests extends AbstractGrailsHibernateTests {
15 protected void onSetUp() {
16 gcl.parseClass('''
17 class Book {
18 Long version
19 Long id
20 static belongsTo = Author
21 Set authors
23 static hasMany = [authors:Author]
24 static mappedBy = [authors:"books"]
25 String title
27 class Author {
28 Long version
29 Long id
31 Set books
32 static hasMany = [books:Book]
33 static mappedBy = [books:"authors"]
34 String name
35 Book bookOther
37 ''')
40 void testDomain() {
41 GrailsDomainClass bookClass = ga.getDomainClass("Book")
42 GrailsDomainClass authorClass = ga.getDomainClass("Author")
43 assert authorClass
44 assertTrue authorClass.getPropertyByName("bookOther").isOneToOne()
45 assertTrue authorClass.getPropertyByName("books").isManyToMany()
46 assertEquals "authors",authorClass.getPropertyByName("books").otherSide.name
47 assertFalse authorClass.getPropertyByName("bookOther").isBidirectional()
49 assert bookClass
50 assert bookClass.getPropertyByName("authors").isManyToMany()
51 assertEquals "books",bookClass.getPropertyByName("authors").otherSide.name