Search in sources :

Example 1 with EntityAlreadyArchived

use of io.spine.server.entity.rejection.StandardRejections.EntityAlreadyArchived 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));
}
Also used : Rejections.createRejection(io.spine.core.Rejections.createRejection) Rejection(io.spine.core.Rejection) ProjectId(io.spine.test.procman.ProjectId) CommandEnvelope(io.spine.core.CommandEnvelope) PmThrowEntityAlreadyArchived(io.spine.test.procman.command.PmThrowEntityAlreadyArchived) EntityAlreadyArchived(io.spine.server.entity.rejection.StandardRejections.EntityAlreadyArchived) RejectionEnvelope(io.spine.core.RejectionEnvelope) Test(org.junit.Test)

Example 2 with EntityAlreadyArchived

use of io.spine.server.entity.rejection.StandardRejections.EntityAlreadyArchived 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);
}
Also used : Rejection(io.spine.core.Rejection) Command(io.spine.core.Command) ACommand(io.spine.server.commandbus.Given.ACommand) EntityAlreadyArchived(io.spine.server.entity.rejection.StandardRejections.EntityAlreadyArchived) Any(com.google.protobuf.Any)

Example 3 with EntityAlreadyArchived

use of io.spine.server.entity.rejection.StandardRejections.EntityAlreadyArchived in project core-java by SpineEventEngine.

the class RejectionRoutingShould method apply_custom_route.

@Test
public void apply_custom_route() {
    rejectionRouting.route(EntityAlreadyArchived.class, customRoute);
    final EntityAlreadyArchived rejection = EntityAlreadyArchived.newBuilder().setEntityId(thisTestAsEntity()).build();
    final Set<String> ids = rejectionRouting.apply(rejection, RejectionContext.getDefaultInstance());
    assertEquals(CUSTOM_ROUTE, ids);
}
Also used : EntityAlreadyArchived(io.spine.server.entity.rejection.StandardRejections.EntityAlreadyArchived) Test(org.junit.Test)

Aggregations

EntityAlreadyArchived (io.spine.server.entity.rejection.StandardRejections.EntityAlreadyArchived)3 Rejection (io.spine.core.Rejection)2 Test (org.junit.Test)2 Any (com.google.protobuf.Any)1 Command (io.spine.core.Command)1 CommandEnvelope (io.spine.core.CommandEnvelope)1 RejectionEnvelope (io.spine.core.RejectionEnvelope)1 Rejections.createRejection (io.spine.core.Rejections.createRejection)1 ACommand (io.spine.server.commandbus.Given.ACommand)1 ProjectId (io.spine.test.procman.ProjectId)1 PmThrowEntityAlreadyArchived (io.spine.test.procman.command.PmThrowEntityAlreadyArchived)1