@SuppressWarnings({"unchecked"}) @Test void testSendWithCallbackCommandIsRetried() { doAnswer(invocation -> { ((CommandCallback<Object, Object>) invocation.getArguments()[1]) .onResult((CommandMessage<Object>) invocation.getArguments()[0], asCommandResultMessage(new RuntimeException(new RuntimeException()))); return null; }).when(mockCommandBus).dispatch(isA(CommandMessage.class), isA(CommandCallback.class)); when(mockRetryScheduler.scheduleRetry(isA(CommandMessage.class), isA(RuntimeException.class), isA(List.class), isA(Runnable.class))) .thenAnswer(new RescheduleCommand()) .thenReturn(false); final AtomicReference<CommandResultMessage> actualResult = new AtomicReference<>(); testSubject.send("Command", (CommandCallback<Object, Object>) (commandMessage, commandResultMessage) -> actualResult .set(commandResultMessage)); verify(mockCommandMessageTransformer).handle(isA(CommandMessage.class)); ArgumentCaptor<List> captor = ArgumentCaptor.forClass(List.class); verify(mockRetryScheduler, times(2)).scheduleRetry(isA(CommandMessage.class), isA(RuntimeException.class), captor.capture(), isA(Runnable.class)); verify(mockCommandBus, times(2)).dispatch(isA(CommandMessage.class), isA(CommandCallback.class)); assertTrue(actualResult.get().isExceptional()); assertTrue(actualResult.get().exceptionResult() instanceof RuntimeException); assertEquals(1, captor.getAllValues().get(0).size()); assertEquals(2, captor.getValue().size()); assertEquals(2, ((Class<? extends Throwable>[]) captor.getValue().get(0)).length); }
@Override public <C, R> void send(C command, CommandCallback<? super C, ? super R> callback) { super.send(command, callback); }
DefaultCommandGateway extends AbstractCommandGateway implements CommandGateway { @Override public <C, R> void send(C command, CommandCallback<? super C, ? super R> callback) { super.send(command, callback); } }
DefaultCommandGateway extends AbstractCommandGateway implements CommandGateway { @Override public <C, R> void send(C command, CommandCallback<? super C, ? super R> callback) { super.send(command, callback); } protected  DefaultCommandGateway(Builder builder); }
DefaultCommandGateway extends AbstractCommandGateway implements CommandGateway { @Override public <C, R> void send(C command, CommandCallback<? super C, ? super R> callback) { super.send(command, callback); } protected  DefaultCommandGateway(Builder builder); static Builder builder(); @Override void send(C command, CommandCallback<? super C, ? super R> callback); @Override @SuppressWarnings("unchecked") R sendAndWait(Object command); @Override @SuppressWarnings("unchecked") R sendAndWait(Object command, long timeout, TimeUnit unit); @Override CompletableFuture<R> send(Object command); @Override Registration registerDispatchInterceptor(
            MessageDispatchInterceptor<? super CommandMessage<?>> dispatchInterceptor); }
DefaultCommandGateway extends AbstractCommandGateway implements CommandGateway { @Override public <C, R> void send(C command, CommandCallback<? super C, ? super R> callback) { super.send(command, callback); } protected  DefaultCommandGateway(Builder builder); static Builder builder(); @Override void send(C command, CommandCallback<? super C, ? super R> callback); @Override @SuppressWarnings("unchecked") R sendAndWait(Object command); @Override @SuppressWarnings("unchecked") R sendAndWait(Object command, long timeout, TimeUnit unit); @Override CompletableFuture<R> send(Object command); @Override Registration registerDispatchInterceptor(
            MessageDispatchInterceptor<? super CommandMessage<?>> dispatchInterceptor);  }