use of io.spine.core.Rejection in project core-java by SpineEventEngine.
the class IntegrationBusShould method not_dispatch_rejections_to_domestic_subscribers_if_they_requested_external.
@Test
public void not_dispatch_rejections_to_domestic_subscribers_if_they_requested_external() {
final InMemoryTransportFactory transportFactory = InMemoryTransportFactory.newInstance();
final BoundedContext sourceContext = contextWithExtEntitySubscribers(transportFactory);
final ProjectRejectionsExtSubscriber standaloneSubscriber = new ProjectRejectionsExtSubscriber();
final RejectionBus rejectionBus = sourceContext.getRejectionBus();
rejectionBus.register(standaloneSubscriber);
assertNull(ProjectRejectionsExtSubscriber.getExternalRejection());
assertNull(ProjectWizard.getExternalRejection());
assertNull(ProjectCountAggregate.getExternalRejection());
final Rejection rejection = cannotStartArchivedProject();
rejectionBus.post(rejection);
assertNull(ProjectRejectionsExtSubscriber.getExternalRejection());
assertNull(ProjectWizard.getExternalRejection());
assertNull(ProjectCountAggregate.getExternalRejection());
}
use of io.spine.core.Rejection in project core-java by SpineEventEngine.
the class IntegrationBusTestEnv method cannotStartArchivedProject.
// used to create a rejection
@SuppressWarnings("ThrowableNotThrown")
public static Rejection cannotStartArchivedProject() {
final ProjectId projectId = projectId();
final ItgStartProject cmdMessage = ItgStartProject.newBuilder().setProjectId(projectId).build();
final Command startProjectCmd = toCommand(cmdMessage);
final io.spine.test.integration.rejection.ItgCannotStartArchivedProject throwable = new io.spine.test.integration.rejection.ItgCannotStartArchivedProject(projectId);
throwable.initProducer(AnyPacker.pack(projectId));
final Rejection rejection = toRejection(throwable, startProjectCmd);
return rejection;
}
use of io.spine.core.Rejection in project core-java by SpineEventEngine.
the class PmMessageDeliveryShould method postpone_rejections_dispatched_to_reactor_method.
@Test
public void postpone_rejections_dispatched_to_reactor_method() {
assertNull(ReactingProjectWizard.getEventReceived());
final Rejection rejection = cannotStartProject();
boundedContext.getRejectionBus().post(rejection);
assertNull(ReactingProjectWizard.getRejectionReceived());
final RejectionEnvelope expectedEnvelope = RejectionEnvelope.of(rejection);
final PostponingRejectionDelivery delivery = repository.getRejectionEndpointDelivery();
final Map<ProjectId, RejectionEnvelope> postponedRejections = delivery.getPostponedRejections();
assertTrue(postponedRejections.size() == 1 && postponedRejections.containsValue(expectedEnvelope));
final ProjectId projectId = postponedRejections.keySet().iterator().next();
delivery.deliverNow(projectId, postponedRejections.get(projectId));
final PmCannotStartArchivedProject deliveredRejectionMsg = ReactingProjectWizard.getRejectionReceived();
assertNotNull(deliveredRejectionMsg);
assertEquals(getMessage(rejection), deliveredRejectionMsg);
}
use of io.spine.core.Rejection in project core-java by SpineEventEngine.
the class ProcessManagerRepositoryShould method dispatch_rejection.
@Test
public void dispatch_rejection() {
final CommandEnvelope ce = requestFactory.generateEnvelope();
final EntityAlreadyArchived rejectionMessage = EntityAlreadyArchived.newBuilder().setEntityId(Identifier.pack(newUuid())).build();
final Rejection rejection = createRejection(rejectionMessage, ce.getCommand());
final ProjectId id = ProcessManagerRepositoryTestEnv.GivenCommandMessage.ID;
final Rejection.Builder builder = rejection.toBuilder().setContext(rejection.getContext().toBuilder().setProducerId(Identifier.pack(id)));
final RejectionEnvelope re = RejectionEnvelope.of(builder.build());
final Set<?> delivered = repository().dispatchRejection(re);
assertTrue(delivered.contains(id));
assertTrue(TestProcessManager.processed(rejectionMessage));
}
use of io.spine.core.Rejection in project core-java by SpineEventEngine.
the class ProcessManagerShould method entityAlreadyArchived.
private static RejectionEnvelope entityAlreadyArchived(Class<? extends Message> commandMessageCls) {
final Any id = Identifier.pack(ProcessManagerShould.class.getName());
final EntityAlreadyArchived rejectionMessage = EntityAlreadyArchived.newBuilder().setEntityId(id).build();
final Command command = ACommand.withMessage(Sample.messageOfType(commandMessageCls));
final Rejection rejection = Rejections.createRejection(rejectionMessage, command);
return RejectionEnvelope.of(rejection);
}
Aggregations