GRAILS-1019: Allowing expressions to be used with the 'disabled' attribute for g...
[grails.git] / test / groovy / org / codehaus / groovy / grails / orm / hibernate / ValidationFailureTests.groovy
blob2414cdab5faf2222f33901de8898adf7964d7532
1 package org.codehaus.groovy.grails.orm.hibernate;
4 import org.hibernate.FlushMode;
6 class ValidationFailureTests extends AbstractGrailsHibernateTests {
8 void onSetUp() {
9 gcl.parseClass(
10 """
11 class ValidationFailureBook {
12 Long id
13 Long version
14 String title
16 class ValidationFailureAuthor {
17 Long id
18 Long version
19 String name
20 Set books
21 static hasMany = [books: ValidationFailureBook]
22 static constraints = {
23 name(size:8..16)
26 """
31 void testValidationFailure() {
32 def authorClass = ga.getDomainClass("ValidationFailureAuthor")
33 def bookClass = ga.getDomainClass("ValidationFailureBook")
35 def a = authorClass.newInstance()
36 a.name = "123456789"
38 def b1 = bookClass.newInstance()
39 b1.title = "foo"
40 a.addToBooks(b1)
41 def b2 = bookClass.newInstance()
42 b2.title = "bar"
43 a.addToBooks(b2)
45 a.save(true)
47 assert session.contains(a)
48 session.flush()
50 session.evict(a)
51 session.evict(b1)
52 session.evict(b2)
53 a = null
54 b1 = null
55 b2 = null
57 a = authorClass.clazz.get(1)
59 // now invalidate a
60 a.name = "bad"
61 a.save()
63 assertTrue FlushMode.isManualFlushMode(session.getFlushMode())
67 void onTearDown() {