Reputation: 41
So I'm struggling with writing a mockito test method for a method having this piece of code
Future<?> future = executor.submit(() -> {
try {
LOGGER.info("create Transport to send mail");
Transport.send(message);
} catch (MessagingException e) {
throw new RuntimeException(e);
}
});
so Ive mocked ExecutorService and Future and tried doing this
when(mockExecutor.submit(any(Runnable.class))).thenReturn(mockFuture);
but seeing this error
error: no suitable method found for thenReturn(Future<CAP#1>)
when(mockExecutor.submit(any(Runnable.class))).thenReturn(mockFuture);
^
method OngoingStubbing.thenReturn(Future<CAP#2>) is not applicable
(argument mismatch; Future<CAP#1> cannot be converted to Future<CAP#2>)
method OngoingStubbing.thenReturn(Future<CAP#2>,Future<CAP#2>...) is not applicable
(argument mismatch; Future<CAP#1> cannot be converted to Future<CAP#2>)
where CAP#1,CAP#2 are fresh type-variables:
CAP#1 extends Object from capture of ?
CAP#2 extends Object from capture of ?
Upvotes: 0
Views: 38