testing - Grails: How to mock a domain field validator? -
is there way mock domain field validator?
currently, code in domain class looking this:
isprimary(validator: { boolean value, person obj -> ....... }
and need mock function.
i tried use like:
person.metaclass.static.isprimary.validator = { boolean value, person obj -> ....... }
and didn't work, suggestions how solve issue ?
here example:
class person { boolean isprimary static constraints = { isprimary validator: isprimaryvalidator //or qualified validator //isprimary validator: person.isprimaryvalidator } static isprimaryvalidator = { boolean value, person obj -> //some validation } } //in test person.metaclass.'static'.isprimaryvalidator = { boolean value, person obj -> //do else }
Comments
Post a Comment