### Question:
CommandService implements AxonServerClientService { public void dispatch(byte[] command, StreamObserver<SerializedCommandResponse> responseObserver) { SerializedCommand request = new SerializedCommand(command); String clientId = request.wrapped().getClientId(); if (logger.isTraceEnabled()) { logger.trace("{}: Received command: {}", clientId, request.wrapped().getName()); } try { commandDispatcher.dispatch(contextProvider.getContext(), request, commandResponse -> safeReply(clientId, commandResponse, responseObserver), false); } catch (Exception ex) { logger.warn("Dispatching failed with unexpected error", ex); responseObserver.onError(GrpcExceptionBuilder.build(ex)); } } CommandService(Topology topology,
                          CommandDispatcher commandDispatcher,
                          ContextProvider contextProvider,
                          ClientIdRegistry clientIdRegistry,
                          ApplicationEventPublisher eventPublisher,
                          @Qualifier("commandInstructionAckSource")
                                  InstructionAckSource<SerializedCommandProviderInbound> instructionAckSource); @PreDestroy void cleanup(); Set<GrpcFlowControlledDispatcherListener> listeners(); @Override final ServerServiceDefinition bindService(); StreamObserver<CommandProviderOutbound> openStream(
            StreamObserver<SerializedCommandProviderInbound> responseObserver); void dispatch(byte[] command, StreamObserver<SerializedCommandResponse> responseObserver); void completeStream(String clientId, ClientStreamIdentification clientStreamIdentification);  }### Answer:
@Test public void dispatch() { doAnswer(invocationOnMock -> { Consumer<SerializedCommandResponse> responseConsumer= (Consumer<SerializedCommandResponse>) invocationOnMock.getArguments()[2]; responseConsumer.accept(new SerializedCommandResponse(CommandResponse.newBuilder().build())); return null; }).when(commandDispatcher).dispatch(any(), any(), any(), anyBoolean()); FakeStreamObserver<SerializedCommandResponse> responseObserver = new FakeStreamObserver<>(); testSubject.dispatch(Command.newBuilder().build().toByteArray(), responseObserver); assertEquals(1, responseObserver.values().size()); }