Problem: I can not verify or capture an argument passed to a private method of my System under Test.
For example:
public class FooManagedBean{
public void persistFooEntity(){
Response response = new Response();
response.addResponse(checkFirstConstrain);
response.addResponse(checkSecondConstrain(response));
if(response.hasNoErros){
persistFoo();
}enter code here
}
private Response checkFirstConstrain(){
Response response = new Response();
if(//checking Constrain){
return //Response with Error
}
return //Response without Error
}
private Response checkSecondConstrain(Response response){
//some Code
}
}
First I tried to use Mockito.verify() to check the passed Response of the method checkSecondConstrain, which throws an Error, because you can only use it the Mock Instances. Second I tried it with ArgumentCaptor in order to capture the passed Response. But here we get the same Problem because to capture the passed argument you must use Mockito.verify().
Question: Is there a way to capture or verify an argument which is passed to a private method of the System under Test? I want the state of the variable while being passed to the method.
Another Question: Is it possible to verify if a method of the System under Test is invoked or rather is never invoked?
Note: FooManagedBean is the System Under Test.
System: Java 8, Mockito 1.9.5