0

I am using Easy mock.

  1. I call a method of my actual class from my Test class.
  2. Inside that method I create an object called 'A' on the fly with child objects.
  3. I pass that object 'A' to a remote service and a output returns.

I don't want to asset that returned output. (That is already taken care of)

I want assert and make sure that, my object created successfully and weather it contains the relevant child objects? Can I access this object from my Test Class before or after it get passed to remote service.

Is this possible.

Thank you very much :)

nilan59
  • 1,006
  • 9
  • 24

1 Answers1

2

Yes, it's possible. Mock the remote service, and use a capture when mocking the remote call. The get the actual value passed as argument from the capture, and check that it contains everything expected.

Something like the following (not tested):

Capture<A> capture = EasyMock.newCapture();
expect(mockRemoteService.someMethod(capture)).andReturn(whatever);
...

A a = capture.getValue();
// now check that a is OK.
JB Nizet
  • 678,734
  • 91
  • 1,224
  • 1,255