I was writing integration tests in Grails 3.3 with multiple Asynchronous GORM calls when I realized I could not get access to values stored in the database. I wrote the following test to understand what is happening.
void "test something"() {
given:
def instance = new ExampleDomain(aStringField: "testval").save(flush:true)
when:
def promise = ExampleDomain.async.task {
ExampleDomain.get(instance.id).aStringField
}
then:
promise.get() == "testval"
}
My domain class
class ExampleDomain implements AsyncEntity<ExampleDomain> {
String aStringField
static constraints = {}
}
build.gradle configuration
compile "org.grails:grails-datastore-gorm-async:6.1.6.RELEASE"
Any idea what is going wrong? I'm expecting to have access to the datastore during the execution of the async call.