I'm not 100% sure whether I'm asking the right question, but my scenario is I got something like this:
class A {
public List<String> methodA(input) {
B b = new B();
TreeMap<> treemap = b.methodB(input);
// do something with treemap
}
}
class B {
public TreeMap<> methodB(input) {
// do something
return treemap;
}
}
Now, I want to test methodA, and want to try mock methodB with Mockito. Tried when().thenReturn(), but didn't work. Since there are others consuming class A, I don't want to do a refactor. Do anyone know how can I do this?