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);
}
use of io.spine.core.Rejection in project core-java by SpineEventEngine.
the class RejectionBusShould method not_enrich_rejection_messages.
// as the RejectionBus instances do not support enrichment yet.
@Test
public void not_enrich_rejection_messages() {
final Rejection original = invalidProjectNameRejection();
final RejectionEnvelope enriched = rejectionBus.enrich(RejectionEnvelope.of(original));
assertEquals(original, enriched.getOuterObject());
}
use of io.spine.core.Rejection in project core-java by SpineEventEngine.
the class RejectionBusShould method deliver_postponed_rejection_to_dispatcher_using_configured_executor.
@Test
public void deliver_postponed_rejection_to_dispatcher_using_configured_executor() {
final BareDispatcher dispatcher = new BareDispatcher();
rejectionBusWithPostponedExecution.register(dispatcher);
final Rejection rejection = invalidProjectNameRejection();
rejectionBusWithPostponedExecution.post(rejection);
final Set<RejectionEnvelope> postponedRejections = postponedDelivery.getPostponedRejections();
final RejectionEnvelope postponedRejection = postponedRejections.iterator().next();
verify(delegateDispatcherExecutor, never()).execute(any(Runnable.class));
postponedDelivery.deliverNow(postponedRejection, Consumers.idOf(dispatcher));
assertTrue(dispatcher.isDispatchCalled());
verify(delegateDispatcherExecutor).execute(any(Runnable.class));
}
Aggregations