I have my code like below
public process() {
extract();
...
}
private Obj extract() {
Constructor const = new Constructor();
Obj object = const.getOBJMethod("12345","c:/file/a.zip",null);
return object;
}
I am testing the method process using mockito. and in my test class I have written code as
Constructor mocckConst = mock(Constructor.class);
Obj mockObject = mock(Obj.class);
when(mocckConst .getOBJMethod("12345","c:/file/a.zip",null).thenReturn(mockObject);
But while execution of testcase when extract method is called it is going to the real implementation of getOBJMethod().
Constructor class has another inner class. Does that cause any problem? Can anybody tell me what is going wrong here and the solution.
I would like to improvise my process method.
public process(String base) {
if("abc".equals(base)) {
---
}
else if("def".equals(base) {
extract();
---
}
}
This way extract() is called only when basis is def. and I don't want to pass constructor object to process() method then are there any solutions?