I am new to fixtures in grails and have bumped into this problem in my code. I am trying to use fixtures to build an instance of the following domain objects:
class Tree {
static constraints = {
relationships(
validator: { relationships, tree->
relationships &&
!(relationships.isEmpty()) &&
relationships.every { it.validate()
}
)
}
static hasMany = [
relationships: Branch
]
}
class Branch {
Tree tree
static constraints = {}
}
I have tried these implementations, all of which result in a validation error:
fixture {
Build {
//oak(Tree)
//oakBranch(Branch){ tree = oak }
//oakBranch(Branch){ tree = ref("oak") }
//oak(Tree)
//oak(Tree){ relationships = [ ref("oakBranch") ] }
//oakBranch(Branch)
}
}
All implementations return the same error: "on field of 'relationships': rejected value [null]". Any help will be much appreciated, thanks.