I am trying to mock the ExecutorService but it is constantly giving compile error. The code that I am trying is the following:
ExecutorService executorService = mock(ExecutorService.class);
Future mockedFuture = mock(Future.class);
List> list = Lists.newArrayList(mockedFuture);
when(executorService.invokeAll(any())).thenReturn(list);
When I compile this, it returns the following error:
error: no suitable method found for thenReturn(List>)
[javac] when(executorService.invokeAll(any())).thenReturn(futureList);
[javac] ^
[javac] method OngoingStubbing.thenReturn(List>) is not applicable
[javac] (argument mismatch; List> cannot be converted to List>)
[javac] method OngoingStubbing.thenReturn(List>,List>...) is not applicable
[javac] (argument mismatch; List> cannot be converted to List>)
any idea?