use of io.spine.core.Rejection in project core-java by SpineEventEngine.
the class IntegrationBusShould method dispatch_rejections_from_one_BC_to_external_subscribers_of_another_BC.
@Test
public void dispatch_rejections_from_one_BC_to_external_subscribers_of_another_BC() {
final InMemoryTransportFactory transportFactory = InMemoryTransportFactory.newInstance();
final BoundedContext sourceContext = contextWithTransport(transportFactory);
contextWithExternalSubscribers(transportFactory);
assertNull(ProjectRejectionsExtSubscriber.getExternalRejection());
assertNull(ProjectCountAggregate.getExternalRejection());
assertNull(ProjectWizard.getExternalRejection());
final Rejection rejection = cannotStartArchivedProject();
sourceContext.getRejectionBus().post(rejection);
final Message rejectionMessage = AnyPacker.unpack(rejection.getMessage());
assertEquals(rejectionMessage, ProjectRejectionsExtSubscriber.getExternalRejection());
assertEquals(rejectionMessage, ProjectCountAggregate.getExternalRejection());
assertEquals(rejectionMessage, ProjectWizard.getExternalRejection());
}
use of io.spine.core.Rejection in project core-java by SpineEventEngine.
the class PmMessageDeliveryTestEnv method cannotStartProject.
public static Rejection cannotStartProject() {
final ProjectId projectId = projectId();
final PmStartProject cmdMessage = PmStartProject.newBuilder().setProjectId(projectId).build();
final Command command = createCommand(cmdMessage);
final Rejection result = toRejection(throwableWith(projectId), command);
return result;
}
use of io.spine.core.Rejection in project core-java by SpineEventEngine.
the class DelegatingRejectionDispatcherShould method setUp.
@Before
public void setUp() {
delegate = new EmptyRejectionDispatcherDelegate();
delegatingDispatcher = DelegatingRejectionDispatcher.of(delegate);
final Command command = requestFactory.generateCommand();
final Message rejectionMessage = EntityAlreadyDeleted.newBuilder().setEntityId(Identifier.pack(getClass().getName())).build();
final Rejection rejection = Rejections.createRejection(rejectionMessage, command);
rejectionEnvelope = RejectionEnvelope.of(rejection);
}
use of io.spine.core.Rejection in project core-java by SpineEventEngine.
the class RejectionBusShould method call_subscriber_when_rejection_posted.
@Test
public void call_subscriber_when_rejection_posted() {
final InvalidProjectNameSubscriber subscriber = new InvalidProjectNameSubscriber();
final Rejection rejection = invalidProjectNameRejection();
rejectionBus.register(subscriber);
rejectionBus.post(rejection);
final Rejection handled = subscriber.getRejectionHandled();
// Compare the content without command ID, which is different in the remembered
assertEquals(rejection.getMessage(), handled.getMessage());
assertEquals(rejection.getContext().getCommand().getMessage(), handled.getContext().getCommand().getMessage());
assertEquals(rejection.getContext().getCommand().getContext(), handled.getContext().getCommand().getContext());
}
use of io.spine.core.Rejection in project core-java by SpineEventEngine.
the class RejectionBusShould method not_call_dispatchers_if_dispatcher_rejection_execution_postponed.
@Test
public void not_call_dispatchers_if_dispatcher_rejection_execution_postponed() {
final BareDispatcher dispatcher = new BareDispatcher();
rejectionBusWithPostponedExecution.register(dispatcher);
final Rejection rejection = invalidProjectNameRejection();
rejectionBusWithPostponedExecution.post(rejection);
assertFalse(dispatcher.isDispatchCalled());
final boolean rejectionPostponed = postponedDelivery.isPostponed(rejection, dispatcher);
assertTrue(rejectionPostponed);
}
Aggregations