I have a Grails 2.2.4 project, and I'm trying to write a unit test for a method that queries over lastUpdated
, like so:
Tile.createCriteria().list {
lt('lastUpdated', new Date() - 1)
}
This method works fine in real life, but fails in my unit tests because I can't create any test data with lastUpdated
other than now
. Setting myTile.lastUpdated
explicitly doesn't work, since that's an update and thus triggers the auto-timestamping. Turning off auto timestamping requires the eventTriggeringInterceptor
, which doesn't seem to be available in unit tests. Mocking the default Date
constructor to return other values was also no help. Direct SQL updates are not available in unit tests at all.
Is this possible in unit tests at all, or do I have to write an integration test?