Original Reporter: mjhugo
Environment: macosx, java 1.6, grails 1.3.5, grails-datastore-gorm-test 1.0.0.M2
Version: Not Specified
Migrated From: http://jira.grails.org/browse/GPMONGODB-48
Sample grails project attached. When using the @mixin(DatastoreUnitTestMixin) and working in a Grails Unit test, the beforeInsert method is not called on a domain class. Work around can be seen in the second test method below (manually add the entity interceptor)
{code}
void testBeforeInsert() {
def b = new Book(name:'lower')
b.save(flush:true, failOnError:true)
assertEquals b.name.toUpperCase(), b.upperName
}
void testBeforeInsert_manuallySetEventInterceptor() {
// this test passes with this line:
getDatastore().addEntityInterceptor(new DomainEventInterceptor())
def b = new Book(name:'lower')
b.save(flush:true, failOnError:true)
assertEquals b.name.toUpperCase(), b.upperName
}
{code}