I have a Cucumber test class where I also want to do some mocking in. I want to mock a service call that's happening in one of my actual classes. I set up in my Cucumber config class as such:
public class TestConfig {
@Autowired @MockBean private RestService restService;
}
And in the Cucumber test class:
public class TestClass {
private RestService restService;
public TestClass(@Autowired(required = false) RestService restService) {
this.restService = restService;
}
}
So when the mocking occurs, I want to capture the arguments being passed into the mock method call within restService, as such:
when(restService.someCall(anyLong())).thenAnswer( (Answer) invocation -> {
Object[] args = invocation.getArguments();
}
Yet, the arguments that are being picked up (args) for these mock calls are always "0L", which I suspect is some kind of default parameter passed in as arguments for Mockito interceptors, since I try to pick it up by calling getArguments on invocation as well as using ArgumentCapture, both of which return the argument as "0L".