I am trying to test a service class, which internally makes use of a Spring AMQP connection object. This connection object is injected by Spring. However, I don\'t want my
Use one, or more, ArgumentCaptors.
It is unclear what your types are here, but anyway. Let's suppose you have a mock which has a method doSomething() taking a Foo as an argument, then you do this:
final ArgumentCaptor captor = ArgumentCaptor.forClass(Foo.class);
verify(mock).doSomething(captor.capture());
final Foo argument = captor.getValue();
// Test the argument
Also, it looks like your method returns void and you don't want it to do anything. Just write this:
doNothing().when(theMock).doSomething(any());