Reputation: 9027
I am using ExecutorCompletionService and below method calls from that
Future<List<Student>> studentDetails = taskCompletionService.take();
Lis<Student> details =studentDetails.get()
Now am writing Junit and Mockito and I want to mock above two calls. How can I achieve that?
Upvotes: 1
Views: 729
Reputation: 21417
If you simply want to stub for the take
method of a mocked taskCompletionService
then you could do something like this:
List<Student> studentDetails = Arrays.asList(fakeStudentDetail);
when(taskCompletionService.take())
.thenReturn(CompletableFuture.completedFuture(studentDetails));
Upvotes: 1