I have a simple filter and its unit test case as in the link(Unit Testing Filters) and it working fine.
Now I have added Hibernate Filter plugin in the application. And in a domain I have a parametric hibernate filter:
class Author {
Book book
static hibernateFilters = {
bookFilter(condition: ':bookId = book_id', types: 'long')
}
}
due to some reason I have enabled this hibernate filter in grails filter:
class CancellingFilters {
def filters = {
all(controller:"simple", action:"list") {
before = {
Author.enableHibernateFilter('bookFilter').setParameter('bookId', session.bookId)
redirect(controller:"book")
return false
}
}
}
}
this works fine while run-app. But my test of CancellingFilters failing with following error:
| groovy.lang.MissingMethodException: No signature of method: com.mkb.Author.enableHibernateFilter() is applicable for argument types: (java.lang.String) values: [bookFilter]
at org.grails.datastore.gorm.GormStaticApi.methodMissing(GormStaticApi.groovy:91)
at org.grails.datastore.gorm.internal.StaticMethodInvokingClosure.call(StaticMethodInvokingClosure.groovy:32)
at mkb.CancellingFilters.closure1_closure2_closure3(CancellingFilters.groovy:5)
at grails.test.mixin.web.FiltersUnitTestMixin.withFilters(FiltersUnitTestMixin.groovy:119)
I have no idea how can I fix this issue. I tried with metaClass but no luck.
How can I fix this error to pass the test case? Is this possible to test this filter? Please suggest.
Aucun commentaire:
Enregistrer un commentaire