As I noticed in the answers of another question there are a few problems when testing finder methods in GORM.
I want to get all objects from Something
and have support for sorting and pagination, so I wrote this:
SomethingListVO findAllSomethings(int offset = 0, int limit = 50) {
def somethingCount = Something.count()
def somethings = Something.findAll([max: limit,
offset:offset,
sort: "number",
order: "asc"])
return new SomethingListVO(somethingCount,somethings)
}
This can't work because if you want to add something like pagination or sorting you need to have a query. But if you add a query like SELECT * FROM Something
your test will fail.
Is there any way to test this method (with pagination/sorting)?
This approach seems to provide more features but it won't work with my grails installation.