Reputation: 3717
Seems that PagedResultList is changed in grails 2.2.4 which is causing some issues in unit test.
The constructor is changed from
PagedResultList(list())
to
PagedResultList(GrailsHibernateTemplate template, Criteria crit)
Upvotes: 1
Views: 661
Reputation: 23
If only care about return values, attach totalCount
to ArrayList
.
def list = [domainObj1, domainObj2]
list.metaClass.getTotalCount {
2
}
Upvotes: 2
Reputation: 356
How about something like this...
def mockC = mockFor(org.hibernate.Criteria)
mockC.demand.list { return []} //PagedResultList constructor calls this
def pagedList = new PagedResultList(null, mockC.createMock()){
{
//Using a static block to set private variables
//since we can't call a constructor here!
list = yourList
totalCount = yourList.size()
}
}
Upvotes: 3