Skip to content

GPMONGODB-48: beforeInsert event not working when using @Mixin(DatastoreUnitTestMixin)  #455

@graemerocher

Description

@graemerocher

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}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions