-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
114 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
...orm-hibernate5/src/test/groovy/grails/gorm/tests/HibernateEntityTraitGeneratedSpec.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package grails.gorm.tests | ||
|
||
import grails.gorm.transactions.Rollback | ||
import groovy.transform.Generated | ||
import org.grails.orm.hibernate.HibernateDatastore | ||
import org.springframework.transaction.PlatformTransactionManager | ||
import spock.lang.AutoCleanup | ||
import spock.lang.IgnoreIf | ||
import spock.lang.Shared | ||
import spock.lang.Specification | ||
|
||
@Rollback | ||
class HibernateEntityTraitGeneratedSpec extends Specification { | ||
|
||
@Shared @AutoCleanup HibernateDatastore datastore = new HibernateDatastore(Club) | ||
|
||
void "test that all HibernateEntity trait methods are marked as Generated"() { | ||
// Unfortunately static methods have to check directly one by one | ||
expect: | ||
Club.getMethod('findAllWithSql', CharSequence).isAnnotationPresent(Generated) | ||
Club.getMethod('findWithSql', CharSequence).isAnnotationPresent(Generated) | ||
Club.getMethod('findAllWithSql', CharSequence, Map).isAnnotationPresent(Generated) | ||
Club.getMethod('findWithSql', CharSequence, Map).isAnnotationPresent(Generated) | ||
} | ||
|
||
} |
54 changes: 54 additions & 0 deletions
54
...5/src/test/groovy/grails/gorm/tests/validation/EmbeddedWithValidationExceptionSpec.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package grails.gorm.tests.validation | ||
|
||
import grails.gorm.annotation.Entity | ||
import grails.gorm.transactions.Rollback | ||
import grails.validation.ValidationException | ||
import org.grails.orm.hibernate.HibernateDatastore | ||
import spock.lang.AutoCleanup | ||
import spock.lang.Issue | ||
import spock.lang.Shared | ||
import spock.lang.Specification | ||
|
||
class EmbeddedWithValidationExceptionSpec extends Specification { | ||
@Shared @AutoCleanup HibernateDatastore hibernateDatastore = new HibernateDatastore(DomainWithEmbedded) | ||
|
||
@Rollback | ||
@Issue("https://github.com/grails/gorm-hibernate5/issues/110") | ||
void "test validation exception with embedded in domain"() { | ||
when: | ||
new DomainWithEmbedded( | ||
foo: 'not valid', | ||
myEmbedded: new MyEmbedded( | ||
a: 1, | ||
b: 'foo' | ||
) | ||
).save(failOnError: true) | ||
|
||
then: | ||
thrown(ValidationException) | ||
} | ||
} | ||
|
||
@Entity | ||
class DomainWithEmbedded { | ||
MyEmbedded myEmbedded | ||
String foo | ||
|
||
static embedded = ['myEmbedded'] | ||
|
||
static constraints = { | ||
foo(validator: { val, self -> | ||
return 'not.valid.foo' | ||
}) | ||
} | ||
} | ||
|
||
class MyEmbedded { | ||
Integer a | ||
String b | ||
|
||
static constraints = { | ||
a(nullable: true) | ||
b(nullalbe: true) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters