Unit tests do not yet support HQL queries, but we are working on it. But you should not do perseverance tests with mocks. Persistence tests should be performed against the database in an integration test.
I usually move HQL queries to a domain class as static query methods. Thus, they easily mock the unit test of the controller, services, etc., and then I test this method as part of the domain class integration test.
For example, I will have
class User {
String username
String password
...
static List findAllUsersBlahBlah(String foo, boolean bar) {
executeQuery('from User u where ...')
}
}
unit test , unit test - , , , :
def users = [new User(...), new User(...)]
User.metaClass.static.findAllUsersBlahBlah = { String foo, boolean bar -> users }