public List<Object> getDummyData(String testString ) {
final List<String> result1 = utility.getData(testString);
final List<String> result2 = utility.getData(result1.get(0).split(~)[0]);
// Processing of result2 and few more method calls
return someListOfObject;
}
I need to mock the method having above method calls. When I go with below code:
MainApp mock= Mockito.mock(MainApp.class);
List<String> mockList = Mockito.mock(ArrayList.class);
doReturn(mockList).when(mock).getData("str");
I am getting IndexOutOfBoundsException while running the test case at second method call.