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<A> mockedFuture = mock(Future.class);
List<Future<A>> 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<Future<A>>)
[javac] when(executorService.invokeAll(any())).thenReturn(futureList);
[javac] ^
[javac] method OngoingStubbing.thenReturn(List<Future<Object>>) is not applicable
[javac] (argument mismatch; List<Future<A>> cannot be converted to List<Future<Object>>)
[javac] method OngoingStubbing.thenReturn(List<Future<Object>>,List<Future<Object>>...) is not applicable
[javac] (argument mismatch; List<Future<A>> cannot be converted to List<Future<Object>>)
any idea?