Is it possible to create PagedResultList instance or Mock?
For Background: Currently I´m writing Controller Unit tests. If it is necessary I stubbing Service function calls. But some of this functions have PagedResultList
as return type. So i have to inject a PagedResultList
instance or null
.
In some cases I need an instance because the controller do something like this:
testFunction(){
def result = sampleService.doSomething()
if (result.empty) {
variable = "it´s empty"
}
render variable
}
My Test looking like this:
void "sample Test"(){
given:
controller.sampleService = Mock(SampleService)
PagedResultList emptyPagedResultList = ?????
when:
controller.testFunction()
then:
1 * controller.sampleService.doSomething() >> emptyPagedResultList
response.text == "it´s empty"
}
Someone can help me to replace the ?????
with a pice of code to fix this issue?
Thanks in advance.