If I understand correctly, this test is a test foe methodname()
. And you would like to test that, given a source, the correct MyClass paremeter is created by the mapper, and passed to serviceBeingMocked.doSomething()
.
So in fact, your unit test for methodname()
actually tests the mapper.map()
method. That's wrong. You should write a unit test for mapper.map()
to test that. Once you've ensured that mapper.map()
works as expected, you can test methodname()
by mocking the mapper.map()
method, and verify that the result of this mocked method is passed to the mocked service (although this test wouldn't add much value).
To be complete, if you really want to go your way and check the value passed to serviceBeingMocked()
, then you should use a capture.