You are right, this exception is thrown because the stubbing setup does not match the objects that were passed during test execution.
The .toString()
represents this inside the Stacktrace:
[email protected]__, "603b408b-4eb2-4d01-ab90-d30277874415"
[email protected]__, "603b408b-4eb2-4d01-ab90-d30277874415"
The id
argument does match, but not the instance of your MockHttpServletRequest
.
You can solve this by a more open stub setup, that does not check on equality of the MockHttpServletRequest
when(this.service.validateDeletingProcessBoard(any(MockHttpServletRequest.class),eq(id))).thenReturn(object);
Make sure to use org.mockito.ArgumentMatchers
for both any()
and eq()
.
CLICK HERE to find out more related problems solutions.