grails - How can I unit test a controller using altered default date binding? -
how can simulate behavior of grails.databinding.dateformats in controller spock test?
in config.groovy, added these settings:
grails.databinding.dateformats = [ 'yyyy-mm-dd\'t\'hh:mm:ss.sssx', 'yyyy-mm-dd\'t\'hh:mm:ssx', ] what have unit test framework bind date properties using 1 of specified formats?
my controller looks like:
class mycontroller { static responseformats = ['json'] def get() { mycommand command = binddata(new mycommand(), params) command.validate() if (command.haserrors()) { ... } else { //...do stuff command object } } @validateable class mycommand { long resourceid date startdate date enddate static constraints = { resourceid nullable: false startdate nullable: false enddate nullable: false } } } when run application, code works normally; however, when binddata() called in unit test, 'resourceid' property on command object populated, while date properties not.
Comments
Post a Comment