@Test void testHandlerDispatching_WithCustomCommandName() throws Exception { Object actualReturnValue = testSubject.handle(new GenericCommandMessage<>(new GenericMessage<>(1L), "almostLong")); assertEquals(1L, actualReturnValue); assertEquals(0, mockTarget.voidHandlerInvoked); assertEquals(0, mockTarget.returningHandlerInvoked); assertEquals(1, mockTarget.almostDuplicateReturningHandlerInvoked); }
@Override public Object handle(CommandMessage<?> command) throws Exception { return model.getHandlers().stream() .filter(h -> h.canHandle(command)).findFirst() .orElseThrow(() -> new NoHandlerForCommandException(format("No handler available to handle command [%s]", command.getCommandName()))) .handle(command, target); }
AnnotationCommandHandlerAdapter implements CommandMessageHandler { @Override public Object handle(CommandMessage<?> command) throws Exception { return model.getHandlers().stream() .filter(h -> h.canHandle(command)).findFirst() .orElseThrow(() -> new NoHandlerForCommandException(format("No handler available to handle command [%s]", command.getCommandName()))) .handle(command, target); } }
AnnotationCommandHandlerAdapter implements CommandMessageHandler { @Override public Object handle(CommandMessage<?> command) throws Exception { return model.getHandlers().stream() .filter(h -> h.canHandle(command)).findFirst() .orElseThrow(() -> new NoHandlerForCommandException(format("No handler available to handle command [%s]", command.getCommandName()))) .handle(command, target); } AnnotationCommandHandlerAdapter(T annotatedCommandHandler);  AnnotationCommandHandlerAdapter(T annotatedCommandHandler,
                                           ParameterResolverFactory parameterResolverFactory); @SuppressWarnings("unchecked")  AnnotationCommandHandlerAdapter(T annotatedCommandHandler,
                                           ParameterResolverFactory parameterResolverFactory,
                                           HandlerDefinition handlerDefinition); }
AnnotationCommandHandlerAdapter implements CommandMessageHandler { @Override public Object handle(CommandMessage<?> command) throws Exception { return model.getHandlers().stream() .filter(h -> h.canHandle(command)).findFirst() .orElseThrow(() -> new NoHandlerForCommandException(format("No handler available to handle command [%s]", command.getCommandName()))) .handle(command, target); } AnnotationCommandHandlerAdapter(T annotatedCommandHandler);  AnnotationCommandHandlerAdapter(T annotatedCommandHandler,
                                           ParameterResolverFactory parameterResolverFactory); @SuppressWarnings("unchecked")  AnnotationCommandHandlerAdapter(T annotatedCommandHandler,
                                           ParameterResolverFactory parameterResolverFactory,
                                           HandlerDefinition handlerDefinition); Registration subscribe(CommandBus commandBus); @Override Object handle(CommandMessage<?> command); @Override boolean canHandle(CommandMessage<?> message); @Override Set<String> supportedCommandNames(); }
AnnotationCommandHandlerAdapter implements CommandMessageHandler { @Override public Object handle(CommandMessage<?> command) throws Exception { return model.getHandlers().stream() .filter(h -> h.canHandle(command)).findFirst() .orElseThrow(() -> new NoHandlerForCommandException(format("No handler available to handle command [%s]", command.getCommandName()))) .handle(command, target); } AnnotationCommandHandlerAdapter(T annotatedCommandHandler);  AnnotationCommandHandlerAdapter(T annotatedCommandHandler,
                                           ParameterResolverFactory parameterResolverFactory); @SuppressWarnings("unchecked")  AnnotationCommandHandlerAdapter(T annotatedCommandHandler,
                                           ParameterResolverFactory parameterResolverFactory,
                                           HandlerDefinition handlerDefinition); Registration subscribe(CommandBus commandBus); @Override Object handle(CommandMessage<?> command); @Override boolean canHandle(CommandMessage<?> message); @Override Set<String> supportedCommandNames();  }