I'm new to Mockito and I was trying to write the unit test for nstead adapters
lets say we have
I have 3 classes and the last one will update a map to me, return it to the middle then return it again to final layer
List<Map<Integer, List<String>> x
Class A {
Public void method1(List<Map<Integer, List<String>> x) {
method2(x)
}
private void method2 (List<Map<Integer, List<String>> x) {
x.add(...)
}
}
Class B {
A a;
Public int methodB(List<Map<Integer, List<String>> x) {
a.method1(x)
return x.length;
}
}
Class C {
B b;
Public void methodC(List<Map<Integer, List<String>> x) {
int size = b.methodB(x)
}
}
Now when I wanted to write a unit test for class C, I did this
Public Class cTest {
List<Map<Integer, List<String>> x;
@InjectMocks
C c;
@Mock
B b;
@Test
Public Void test() {
when(b.methodB(x)).thenReturn(1);
c.methodC(x)
}
}
The thing is when I debug the call for c.methodC(x) in unit test and I check the x it will always be empty
So how can I fill it in that case ?