@Test
@DisplayName("Success scenario for Card Replace for Lost")
void testcardReplaceLostSuccess() throws Exception {
final CardReplaceRqst cardReplaceRqst = mockCardReplaceRequest("Lost");
when(cardBlockService.sendBlockRequest(cardReplaceRqst)).thenReturn(new ResponseEntity<>(any(), HttpStatus.OK));
when(cardReplaceService.replaceCard(ArgumentMatchers.eq(cardReplaceRqst), any(CardType.class)))
.thenReturn(mockCardReplaceResponse());
mockMvc
.perform(MockMvcRequestBuilders.post(REPLACE_REQUEST_URL).contentType(MediaType.APPLICATION_JSON_VALUE)
.content(TestUtils.toJson(cardReplaceRqst)).characterEncoding("utf-8"))
.andExpect(MockMvcResultMatchers.status().isOk()).andExpect(jsonPath("$.successCode").value("Success"));
}
When I run this code, I get the below error.
org.mockito.exceptions.misusing.InvalidUseOfMatchersException:
Invalid use of argument matchers! 2 matchers expected, 3 recorded:
Any suggestions?
p.s. I had to add ArgumentMatcher.eq() because of a sonar rule "Add an "eq()" argument matcher on this parameter."