Search in sources :

Example 6 with RejectionContext

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

the class EventsTestEnv method rejectionContext.

public static RejectionContext rejectionContext(TenantId id) {
    final Command command = Command.newBuilder().setContext(commandContext(id)).build();
    final RejectionContext result = RejectionContext.newBuilder().setCommand(command).build();
    return result;
}
Also used : Command(io.spine.core.Command) RejectionContext(io.spine.core.RejectionContext)

Example 7 with RejectionContext

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

the class RejectionBusAdapter method markExternal.

@Override
ExternalMessageEnvelope markExternal(ExternalMessage externalMsg) {
    final Any packedEvent = externalMsg.getOriginalMessage();
    final Rejection rejection = AnyPacker.unpack(packedEvent);
    final Rejection.Builder rejectionBuilder = rejection.toBuilder();
    final RejectionContext modifiedContext = rejectionBuilder.getContext().toBuilder().setExternal(true).build();
    final Rejection marked = rejectionBuilder.setContext(modifiedContext).build();
    final ExternalMessage result = ExternalMessages.of(marked, externalMsg.getBoundedContextName());
    return ExternalMessageEnvelope.of(result, Rejections.getMessage(rejection));
}
Also used : Rejection(io.spine.core.Rejection) RejectionContext(io.spine.core.RejectionContext) Any(com.google.protobuf.Any)

Aggregations

RejectionContext (io.spine.core.RejectionContext)7 Test (org.junit.Test)5 CommandContext (io.spine.core.CommandContext)2 Event (io.spine.core.Event)2 Rejection (io.spine.core.Rejection)2 InvalidProjectName (io.spine.test.reflect.ReflectRejections.InvalidProjectName)2 RjUpdateProjectName (io.spine.test.rejection.command.RjUpdateProjectName)2 Any (com.google.protobuf.Any)1 Command (io.spine.core.Command)1 Enrichment (io.spine.core.Enrichment)1 EventContext (io.spine.core.EventContext)1 Given.invalidProjectNameRejection (io.spine.server.rejection.given.Given.invalidProjectNameRejection)1 RejectionEnrichmentConsumer (io.spine.server.rejection.given.RejectionEnrichmentConsumer)1 RValidThreeParams (io.spine.server.rejection.given.RejectionReactorMethodTestEnv.RValidThreeParams)1 ValidThreeParams (io.spine.server.rejection.given.RejectionSubscriberMethodTestEnv.ValidThreeParams)1 ProjectRejections (io.spine.test.rejection.ProjectRejections)1