@Test void testCommandHandlerSubscribesToCommands() { verify(commandBus).subscribe(eq(CreateCommand.class.getName()), any(MessageHandler.class)); verify(commandBus).subscribe(eq(UpdateCommandWithAnnotatedMethod.class.getName()), any(MessageHandler.class)); }
public Registration subscribe(CommandBus commandBus) { List<Registration> subscriptions = supportedCommandNames() .stream() .map(supportedCommand -> commandBus.subscribe(supportedCommand, this)) .filter(Objects::nonNull).collect(Collectors.toList()); return () -> subscriptions.stream().map(Registration::cancel).reduce(Boolean::logicalOr).orElse(false); }
AggregateAnnotationCommandHandler implements CommandMessageHandler { public Registration subscribe(CommandBus commandBus) { List<Registration> subscriptions = supportedCommandNames() .stream() .map(supportedCommand -> commandBus.subscribe(supportedCommand, this)) .filter(Objects::nonNull).collect(Collectors.toList()); return () -> subscriptions.stream().map(Registration::cancel).reduce(Boolean::logicalOr).orElse(false); } }
AggregateAnnotationCommandHandler implements CommandMessageHandler { public Registration subscribe(CommandBus commandBus) { List<Registration> subscriptions = supportedCommandNames() .stream() .map(supportedCommand -> commandBus.subscribe(supportedCommand, this)) .filter(Objects::nonNull).collect(Collectors.toList()); return () -> subscriptions.stream().map(Registration::cancel).reduce(Boolean::logicalOr).orElse(false); } protected  AggregateAnnotationCommandHandler(Builder<T> builder); }
AggregateAnnotationCommandHandler implements CommandMessageHandler { public Registration subscribe(CommandBus commandBus) { List<Registration> subscriptions = supportedCommandNames() .stream() .map(supportedCommand -> commandBus.subscribe(supportedCommand, this)) .filter(Objects::nonNull).collect(Collectors.toList()); return () -> subscriptions.stream().map(Registration::cancel).reduce(Boolean::logicalOr).orElse(false); } protected  AggregateAnnotationCommandHandler(Builder<T> builder); static Builder<T> builder(); Registration subscribe(CommandBus commandBus); @Override Object handle(CommandMessage<?> commandMessage); @Override boolean canHandle(CommandMessage<?> message); @Override Set<String> supportedCommandNames(); }
AggregateAnnotationCommandHandler implements CommandMessageHandler { public Registration subscribe(CommandBus commandBus) { List<Registration> subscriptions = supportedCommandNames() .stream() .map(supportedCommand -> commandBus.subscribe(supportedCommand, this)) .filter(Objects::nonNull).collect(Collectors.toList()); return () -> subscriptions.stream().map(Registration::cancel).reduce(Boolean::logicalOr).orElse(false); } protected  AggregateAnnotationCommandHandler(Builder<T> builder); static Builder<T> builder(); Registration subscribe(CommandBus commandBus); @Override Object handle(CommandMessage<?> commandMessage); @Override boolean canHandle(CommandMessage<?> message); @Override Set<String> supportedCommandNames();  }