@Test @DisplayName("produce RoutingFailed when dispatching unknown command") @MuteLogging void throwOnUnknownCommand() { Command unknownCommand = requestFactory.createCommand(PmDontHandle.getDefaultInstance()); CommandEnvelope command = CommandEnvelope.of(unknownCommand); ProcessManagerRepository<ProjectId, ?, ?> repo = repository(); DiagnosticMonitor monitor = new DiagnosticMonitor(); context.internalAccess() .registerEventDispatcher(monitor); repo.dispatchCommand(command); List<RoutingFailed> failures = monitor.routingFailures(); assertThat(failures).hasSize(1); RoutingFailed failure = failures.get(0); assertThat(failure.getEntityType() .getJavaClassName()) .isEqualTo(repo.entityClass() .getCanonicalName()); assertThat(failure.getError() .getType()) .isEqualTo(IllegalStateException.class.getName()); }
@Override public final void dispatchCommand(CommandEnvelope command) { checkNotNull(command); Optional<I> target = route(command); target.ifPresent(id -> inbox().send(command) .toHandler(id)); }
ProcessManagerRepository extends EventDispatchingRepository<I, P, S> implements CommandDispatcherDelegate, EventProducingRepository { @Override public final void dispatchCommand(CommandEnvelope command) { checkNotNull(command); Optional<I> target = route(command); target.ifPresent(id -> inbox().send(command) .toHandler(id)); } }
ProcessManagerRepository extends EventDispatchingRepository<I, P, S> implements CommandDispatcherDelegate, EventProducingRepository { @Override public final void dispatchCommand(CommandEnvelope command) { checkNotNull(command); Optional<I> target = route(command); target.ifPresent(id -> inbox().send(command) .toHandler(id)); } protected  ProcessManagerRepository(); }
ProcessManagerRepository extends EventDispatchingRepository<I, P, S> implements CommandDispatcherDelegate, EventProducingRepository { @Override public final void dispatchCommand(CommandEnvelope command) { checkNotNull(command); Optional<I> target = route(command); target.ifPresent(id -> inbox().send(command) .toHandler(id)); } protected  ProcessManagerRepository(); @Override @OverridingMethodsMustInvokeSuper void registerWith(BoundedContext context); @Override final EventBus eventBus(); @Override final ImmutableSet<EventClass> messageClasses(); @Override final ImmutableSet<EventClass> domesticEventClasses(); @Override final ImmutableSet<EventClass> externalEventClasses(); @Override final ImmutableSet<CommandClass> commandClasses(); @Override ImmutableSet<EventClass> outgoingEvents(); @Override final void dispatchCommand(CommandEnvelope command); @OverridingMethodsMustInvokeSuper @Override P create(I id); @Override final void store(P entity); @OverridingMethodsMustInvokeSuper @Override void close(); }
ProcessManagerRepository extends EventDispatchingRepository<I, P, S> implements CommandDispatcherDelegate, EventProducingRepository { @Override public final void dispatchCommand(CommandEnvelope command) { checkNotNull(command); Optional<I> target = route(command); target.ifPresent(id -> inbox().send(command) .toHandler(id)); } protected  ProcessManagerRepository(); @Override @OverridingMethodsMustInvokeSuper void registerWith(BoundedContext context); @Override final EventBus eventBus(); @Override final ImmutableSet<EventClass> messageClasses(); @Override final ImmutableSet<EventClass> domesticEventClasses(); @Override final ImmutableSet<EventClass> externalEventClasses(); @Override final ImmutableSet<CommandClass> commandClasses(); @Override ImmutableSet<EventClass> outgoingEvents(); @Override final void dispatchCommand(CommandEnvelope command); @OverridingMethodsMustInvokeSuper @Override P create(I id); @Override final void store(P entity); @OverridingMethodsMustInvokeSuper @Override void close();  }