Using spock I need to mock the calls to EntityManager/Query. The line of code I'm trying to mock is:
entityManager.createNativeQuery("nativeQuery").setParameter(1, param1).getResultList()
The mock of entityManager.createNativeQuery returns a null Query object. That then causes a failure because you can't call a method on a null object. And I consequently I can't mock the return of a result set list.
I've tried breaking the statement down into separate ones and accompanying mocks, but that hasn't worked either because I still end up with a null Query.
I don't know if I've got tunnelvision on this right now, or if this can't be mocked - at least with Spock.
All help appreciated!