I tried the approach with powermockito but it wasn't working for me.
The point is that Roo promotes DDD. So I have been writing some nice business methods and have added them to the appropriate classes. I should be able to unit-test these easily. Note unit test != integration test.
Obviously one could say that I can modify the signature of SalesOrder.createSalesOrder to accept a Product object, which would probably get me out of the woods for this particular issue. Still I have the feeling that at some point I will *have* to invoke a static finder which I will have to mock...
Some of these methods have to lookup other data, in my case a SalesOrder.createSalesOrder(String productId, Integer quantity) has to look up a product using the Roo-provided static Product.findProduct(long id).
This a huge pain to mock, even PowerMock is telling me that it cannot find the stub for this method, maybe this is caused by the intensive use of aspectj?
Maybe I am missing some DDD concept here (I have been stuck in service/repository land for years).
Hoping somebody will share their thoughts...
Hans Westerbeek
Software Engineer