I have an abstract class B which extend another abstract class A. In abstract class A I have protected method convert. I want to test method foo which invoke method convert from base class which doesn't have implementation. How I can mock method convert if I can't change convert method signature.
abstract class B extends A {
public void foo(Object someObject) {
Object convertedObject = convert(someObject);
//logic for testing
}
}
abstract class A {
protected abstract Object convert(Object some object);
}
I use Mockito.spy() for invoking real methods but convert method is not available for mocking (throught Mockito.when (...).thenReturn (...) because it is protected.
B b = Mockito.spy(B.class);
Give me idea how I can test method foo.