I am trying to mock DAO objects used in a Spring application. I can easily create mock or stub objects and inject them into my service. However, in all cases an object is passed in as an argument and an object is returned as an argument on the method calls in the mock object. I was trying to find a mocking framework that handles this situation. Here is my code with EasyMock. The problem is the Unit object passed to the method on the mock object is created in the service and can not be passed in. When easymock does the compare for the expect, its comparing two different Unit objects with the same values which results in not equal and a failure.
I also tried to handle this in Groovy, which didn't work. I know I can create my own Mock objects for each DAO to handle this. It just seems like a mocking framework should handle this scenario, so I don't have to create the objects. Any ideas on how I should handle this.