0

I use mockito 3 as follow:

Mockito.when(webServiceTemplate.marshalSendAndReceive(Mockito.anyString(),
                ArgumentMatchers.<JAXBElement<TypeA>>any()))
                .thenReturn(responseA);
Mockito.when(webServiceTemplate.marshalSendAndReceive(Mockito.anyString(),
                ArgumentMatchers.<JAXBElement<TypeB>>any()))
                .thenReturn(responseB);

The problem is that mockito returns always the responseB. Where is the problem?

user2520969
  • 1,389
  • 6
  • 20
  • 30

1 Answers1

1

I see that you are mocking the same method marshalSendAndReceive in both cases.

It appears therefore that the response is always responseB, because the code that is returning responseB is invoked last.

Is the method overloaded using different types of parameters, or do TypeA and TypeB share the same parent class?

Petar Bivolarski
  • 1,599
  • 10
  • 19