Search in sources :

Example 11 with RejectionEnvelope

use of io.spine.core.RejectionEnvelope in project core-java by SpineEventEngine.

the class ProcessManagerShould method dispatch_rejection_by_rejection_and_command_message.

@Test
public void dispatch_rejection_by_rejection_and_command_message() {
    final RejectionEnvelope rejection = entityAlreadyArchived(PmAddTask.class);
    dispatch(processManager, rejection);
    assertEquals(AnyPacker.pack(rejection.getCommandMessage()), processManager.getState());
}
Also used : RejectionEnvelope(io.spine.core.RejectionEnvelope) TenantAwareTest(io.spine.server.tenant.TenantAwareTest) Test(org.junit.Test)

Example 12 with RejectionEnvelope

use of io.spine.core.RejectionEnvelope in project core-java by SpineEventEngine.

the class ProcessManagerShould method dispatch_rejection_by_rejection_message_only.

@Test
public void dispatch_rejection_by_rejection_message_only() {
    final RejectionEnvelope rejection = entityAlreadyArchived(StringValue.class);
    dispatch(processManager, rejection);
    assertEquals(rejection.getOuterObject().getMessage(), processManager.getState());
}
Also used : RejectionEnvelope(io.spine.core.RejectionEnvelope) TenantAwareTest(io.spine.server.tenant.TenantAwareTest) Test(org.junit.Test)

Example 13 with RejectionEnvelope

use of io.spine.core.RejectionEnvelope in project core-java by SpineEventEngine.

the class RejectionBusShould method pick_proper_consumer_by_consumer_id_when_delivering_to_delegates_of_same_rejection.

@Test
public void pick_proper_consumer_by_consumer_id_when_delivering_to_delegates_of_same_rejection() {
    final InvalidProjectNameDelegate first = new InvalidProjectNameDelegate();
    final AnotherInvalidProjectNameDelegate second = new AnotherInvalidProjectNameDelegate();
    final DelegatingRejectionDispatcher<String> firstDispatcher = DelegatingRejectionDispatcher.of(first);
    final DelegatingRejectionDispatcher<String> secondDispatcher = DelegatingRejectionDispatcher.of(second);
    rejectionBusWithPostponedExecution.register(firstDispatcher);
    rejectionBusWithPostponedExecution.register(secondDispatcher);
    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(firstDispatcher));
    assertTrue(first.isDispatchCalled());
    verify(delegateDispatcherExecutor).execute(any(Runnable.class));
    assertFalse(second.isDispatchCalled());
}
Also used : AnotherInvalidProjectNameDelegate(io.spine.server.rejection.given.AnotherInvalidProjectNameDelegate) Given.missingOwnerRejection(io.spine.server.rejection.given.Given.missingOwnerRejection) Rejection(io.spine.core.Rejection) Given.invalidProjectNameRejection(io.spine.server.rejection.given.Given.invalidProjectNameRejection) InvalidProjectNameDelegate(io.spine.server.rejection.given.InvalidProjectNameDelegate) AnotherInvalidProjectNameDelegate(io.spine.server.rejection.given.AnotherInvalidProjectNameDelegate) RejectionEnvelope(io.spine.core.RejectionEnvelope) Test(org.junit.Test)

Example 14 with RejectionEnvelope

use of io.spine.core.RejectionEnvelope in project core-java by SpineEventEngine.

the class PostponedDispatcherRejectionDelivery method isPostponed.

public boolean isPostponed(Rejection rejection, RejectionDispatcher<?> dispatcher) {
    final RejectionEnvelope envelope = RejectionEnvelope.of(rejection);
    final Class<? extends RejectionDispatcher> actualClass = postponedExecutions.get(envelope);
    final boolean rejectionPostponed = actualClass != null;
    final boolean dispatcherMatches = rejectionPostponed && dispatcher.getClass().equals(actualClass);
    return dispatcherMatches;
}
Also used : RejectionEnvelope(io.spine.core.RejectionEnvelope)

Aggregations

RejectionEnvelope (io.spine.core.RejectionEnvelope)14 Test (org.junit.Test)11 Rejection (io.spine.core.Rejection)8 Given.invalidProjectNameRejection (io.spine.server.rejection.given.Given.invalidProjectNameRejection)3 Given.missingOwnerRejection (io.spine.server.rejection.given.Given.missingOwnerRejection)3 Command (io.spine.core.Command)2 TenantAwareTest (io.spine.server.tenant.TenantAwareTest)2 ProjectId (io.spine.test.procman.ProjectId)2 Message (com.google.protobuf.Message)1 ActorContext (io.spine.core.ActorContext)1 CommandEnvelope (io.spine.core.CommandEnvelope)1 Rejections.createRejection (io.spine.core.Rejections.createRejection)1 PostponingRejectionDelivery (io.spine.server.aggregate.given.AggregateMessageDeliveryTestEnv.PostponingRejectionDelivery)1 EntityAlreadyArchived (io.spine.server.entity.rejection.StandardRejections.EntityAlreadyArchived)1 PostponingRejectionDelivery (io.spine.server.procman.given.PmMessageDeliveryTestEnv.PostponingRejectionDelivery)1 AnotherInvalidProjectNameDelegate (io.spine.server.rejection.given.AnotherInvalidProjectNameDelegate)1 BareDispatcher (io.spine.server.rejection.given.BareDispatcher)1 InvalidProjectNameDelegate (io.spine.server.rejection.given.InvalidProjectNameDelegate)1 ProjectId (io.spine.test.aggregate.ProjectId)1 AggCannotStartArchivedProject (io.spine.test.aggregate.rejection.Rejections.AggCannotStartArchivedProject)1