@Test void testOnResultUnwrapsExecutionResult() throws InterruptedException { Thread t = new Thread(() -> { resultFromParallelThread = testSubject.getResult(); }); t.start(); testSubject.completeExceptionally(new MockException("Mocking an exception")); t.join(); assertTrue(resultFromParallelThread instanceof ResultMessage); assertTrue(((ResultMessage) resultFromParallelThread).exceptionResult() instanceof MockException); }
public CommandResultMessage<? extends R> getResult() { try { return get(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); return new GenericCommandResultMessage<>((R) null); } catch (ExecutionException e) { return asCommandResultMessage(e.getCause()); } catch (Exception e) { return asCommandResultMessage(e); } }
FutureCallback extends CompletableFuture<CommandResultMessage<? extends R>> implements CommandCallback<C, R> { public CommandResultMessage<? extends R> getResult() { try { return get(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); return new GenericCommandResultMessage<>((R) null); } catch (ExecutionException e) { return asCommandResultMessage(e.getCause()); } catch (Exception e) { return asCommandResultMessage(e); } } }
FutureCallback extends CompletableFuture<CommandResultMessage<? extends R>> implements CommandCallback<C, R> { public CommandResultMessage<? extends R> getResult() { try { return get(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); return new GenericCommandResultMessage<>((R) null); } catch (ExecutionException e) { return asCommandResultMessage(e.getCause()); } catch (Exception e) { return asCommandResultMessage(e); } }  }
FutureCallback extends CompletableFuture<CommandResultMessage<? extends R>> implements CommandCallback<C, R> { public CommandResultMessage<? extends R> getResult() { try { return get(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); return new GenericCommandResultMessage<>((R) null); } catch (ExecutionException e) { return asCommandResultMessage(e.getCause()); } catch (Exception e) { return asCommandResultMessage(e); } }  @Override void onResult(CommandMessage<? extends C> commandMessage,
                         CommandResultMessage<? extends R> commandResultMessage); CommandResultMessage<? extends R> getResult(); CommandResultMessage<? extends R> getResult(long timeout, TimeUnit unit); boolean awaitCompletion(long timeout, TimeUnit unit); }
FutureCallback extends CompletableFuture<CommandResultMessage<? extends R>> implements CommandCallback<C, R> { public CommandResultMessage<? extends R> getResult() { try { return get(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); return new GenericCommandResultMessage<>((R) null); } catch (ExecutionException e) { return asCommandResultMessage(e.getCause()); } catch (Exception e) { return asCommandResultMessage(e); } }  @Override void onResult(CommandMessage<? extends C> commandMessage,
                         CommandResultMessage<? extends R> commandResultMessage); CommandResultMessage<? extends R> getResult(); CommandResultMessage<? extends R> getResult(long timeout, TimeUnit unit); boolean awaitCompletion(long timeout, TimeUnit unit);  }