Home > Net >  createdCriteria - Mock only list method
createdCriteria - Mock only list method

Time:02-10

I use Grails 2.5.6 . I've mocked the list method of createCriteria like this

def myCriteria = new Expando();
myCriteria.list = {Object params=null, Closure  cls -> myObjectReturn}         
MyDomainClass.metaClass.static.createCriteria = {myCriteria}

The problem is that by doing this I am forced to mock the get method too, otherwise it will return null. What I need is not to mock the get method and use the real one from the code. I've tried something like this, but it doesn't work

myCriteria.get = {Closure  cls -> callRealMethod()} 

It is possible?

CodePudding user response:

  •  Tags:  
  • Related