Roo uses static methods on entities as follows:
- findTheEntity(Identifier id):TheEntity
- findTheEntityEntries(int first, int maxResults):List<TheEntity>
Spring has always adopted a strong test focus. It is important this is also reflected by Roo.
Because the above are static methods, they are difficult to mock and therefore test using conventional mocking techniques.
Roo should offer some facility to dynamically implement mock-based stubs of these methods during tests. This should only happen on demand, so as to not interfere with the normal Roo implementations of the methods. Using AspectJ offers us the flexibility of using an around advice to replace the Roo implementation of the method as required. If the control flow included a newly-defined annotation to activate this dynamic mocking behavior, we would have a flexible solution that doesn't interfere with normal Roo provision of the methods.
(Logged by Ben Alex on behalf of Rod Johnson, who has provided the code for this new feature)