@SuppressWarnings("unchecked") @Test void testDispatchWithCallback() throws Exception { testSubject.subscribe(Object.class.getName(), commandHandler); CommandCallback<Object, Object> mockCallback = mock(CommandCallback.class); CommandMessage<Object> command = asCommandMessage(new Object()); testSubject.dispatch(command, mockCallback); InOrder inOrder = inOrder(mockCallback, executorService, commandHandler, dispatchInterceptor, handlerInterceptor); inOrder.verify(dispatchInterceptor).handle(isA(CommandMessage.class)); inOrder.verify(executorService).execute(isA(Runnable.class)); inOrder.verify(handlerInterceptor).handle(isA(UnitOfWork.class), isA(InterceptorChain.class)); inOrder.verify(commandHandler).handle(isA(CommandMessage.class)); ArgumentCaptor<CommandMessage<Object>> commandCaptor = ArgumentCaptor.forClass(CommandMessage.class); ArgumentCaptor<CommandResultMessage<Object>> responseCaptor = ArgumentCaptor .forClass(CommandResultMessage.class); inOrder.verify(mockCallback).onResult(commandCaptor.capture(), responseCaptor.capture()); assertEquals(command, commandCaptor.getValue()); assertNull(responseCaptor.getValue().getPayload()); }
@Override protected <C, R> void handle(CommandMessage<C> command, MessageHandler<? super CommandMessage<?>> handler, CommandCallback<? super C, ? super R> callback) { executor.execute(() -> super.handle(command, handler, callback)); }
AsynchronousCommandBus extends SimpleCommandBus { @Override protected <C, R> void handle(CommandMessage<C> command, MessageHandler<? super CommandMessage<?>> handler, CommandCallback<? super C, ? super R> callback) { executor.execute(() -> super.handle(command, handler, callback)); } }
AsynchronousCommandBus extends SimpleCommandBus { @Override protected <C, R> void handle(CommandMessage<C> command, MessageHandler<? super CommandMessage<?>> handler, CommandCallback<? super C, ? super R> callback) { executor.execute(() -> super.handle(command, handler, callback)); } protected  AsynchronousCommandBus(Builder builder); }
AsynchronousCommandBus extends SimpleCommandBus { @Override protected <C, R> void handle(CommandMessage<C> command, MessageHandler<? super CommandMessage<?>> handler, CommandCallback<? super C, ? super R> callback) { executor.execute(() -> super.handle(command, handler, callback)); } protected  AsynchronousCommandBus(Builder builder); static Builder builder(); void shutdown(); }
AsynchronousCommandBus extends SimpleCommandBus { @Override protected <C, R> void handle(CommandMessage<C> command, MessageHandler<? super CommandMessage<?>> handler, CommandCallback<? super C, ? super R> callback) { executor.execute(() -> super.handle(command, handler, callback)); } protected  AsynchronousCommandBus(Builder builder); static Builder builder(); void shutdown();  }