Search in sources :

Example 6 with RejectionEnvelope

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

the class RejectionEnvelopeShould method obtain_actor_context.

@Test
public void obtain_actor_context() {
    final RejectionEnvelope rejection = toEnvelope(outerObject());
    final ActorContext actorContext = rejection.getActorContext();
    /* Since we're using `TestActorRequestFactory` initialized with the class of this test suite
           the actor ID should be the suite class name.
         */
    assertEquals(getClass().getName(), actorContext.getActor().getValue());
}
Also used : RejectionEnvelope(io.spine.core.RejectionEnvelope) ActorContext(io.spine.core.ActorContext) Test(org.junit.Test)

Example 7 with RejectionEnvelope

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

the class RejectionEnvelopeShould method obtain_command_message.

@Test
public void obtain_command_message() {
    final Rejection rejection = outerObject();
    final Command command = rejection.getContext().getCommand();
    final Message commandMessage = AnyPacker.unpack(command.getMessage());
    final RejectionEnvelope envelope = toEnvelope(rejection);
    assertEquals(commandMessage, envelope.getCommandMessage());
}
Also used : Rejection(io.spine.core.Rejection) Message(com.google.protobuf.Message) Command(io.spine.core.Command) RejectionEnvelope(io.spine.core.RejectionEnvelope) Test(org.junit.Test)

Example 8 with RejectionEnvelope

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

the class RejectionEnvelopeShould method obtain_command_context.

@Test
public void obtain_command_context() {
    final Rejection rejection = outerObject();
    final Command command = rejection.getContext().getCommand();
    final RejectionEnvelope envelope = toEnvelope(rejection);
    assertEquals(command.getContext(), envelope.getCommandContext());
}
Also used : Rejection(io.spine.core.Rejection) Command(io.spine.core.Command) RejectionEnvelope(io.spine.core.RejectionEnvelope) Test(org.junit.Test)

Example 9 with RejectionEnvelope

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

the class AggregateMessageDeliveryShould method postpone_rejections_dispatched_to_reactor_method.

@Test
public void postpone_rejections_dispatched_to_reactor_method() {
    assertNull(ReactingProject.getEventReceived());
    final Rejection rejection = cannotStartProject();
    boundedContext.getRejectionBus().post(rejection);
    assertNull(ReactingProject.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 AggCannotStartArchivedProject deliveredRejectionMsg = ReactingProject.getRejectionReceived();
    assertNotNull(deliveredRejectionMsg);
    assertEquals(getMessage(rejection), deliveredRejectionMsg);
}
Also used : Rejection(io.spine.core.Rejection) AggCannotStartArchivedProject(io.spine.test.aggregate.rejection.Rejections.AggCannotStartArchivedProject) ProjectId(io.spine.test.aggregate.ProjectId) PostponingRejectionDelivery(io.spine.server.aggregate.given.AggregateMessageDeliveryTestEnv.PostponingRejectionDelivery) RejectionEnvelope(io.spine.core.RejectionEnvelope) Test(org.junit.Test)

Example 10 with RejectionEnvelope

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

the class PmRejectionEndpoint method getTargets.

@Override
protected Set<I> getTargets() {
    final RejectionEnvelope envelope = envelope();
    final Set<I> ids = repository().getRejectionRouting().apply(envelope.getMessage(), envelope.getMessageContext());
    return ids;
}
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