use of io.spine.core.Rejection in project core-java by SpineEventEngine.
the class RejectionBusShould method call_subscriber_by_rejection_and_command_message_when_rejection_posted.
@Test
public void call_subscriber_by_rejection_and_command_message_when_rejection_posted() {
final MultipleRejectionSubscriber subscriber = new MultipleRejectionSubscriber();
rejectionBus.register(subscriber);
final Class<RjStartProject> commandMessageCls = RjStartProject.class;
final Rejection rejection = cannotModifyDeletedEntity(commandMessageCls);
rejectionBus.post(rejection);
assertEquals(1, subscriber.numberOfSubscriberCalls());
assertEquals(commandMessageCls, subscriber.commandMessageClass());
}
use of io.spine.core.Rejection in project core-java by SpineEventEngine.
the class RejectionBusShould method checkRejection.
private void checkRejection(VerifiableSubscriber subscriber) {
final Rejection rejection = missingOwnerRejection();
rejectionBus.register(subscriber);
rejectionBus.post(rejection);
assertTrue(subscriber.isMethodCalled());
subscriber.verifyGot(rejection);
}
use of io.spine.core.Rejection in project core-java by SpineEventEngine.
the class SingleTenantCommandBusShould method propagate_rejections_to_rejection_bus.
@Test
public void propagate_rejections_to_rejection_bus() {
final FaultyHandler faultyHandler = new FaultyHandler(eventBus);
commandBus.register(faultyHandler);
final Command addTaskCommand = clearTenantId(addTask());
final MemoizingObserver<Ack> observer = memoizingObserver();
commandBus.post(addTaskCommand, observer);
final InvalidProjectName throwable = faultyHandler.getThrowable();
final Rejection expectedRejection = toRejection(throwable, addTaskCommand);
final Ack ack = observer.firstResponse();
final Rejection actualRejection = ack.getStatus().getRejection();
assertTrue(isNotDefault(actualRejection));
assertEquals(unpack(expectedRejection.getMessage()), unpack(actualRejection.getMessage()));
}
use of io.spine.core.Rejection in project core-java by SpineEventEngine.
the class RejectionEnvelopeShould method outerObject.
@Override
protected Rejection outerObject() {
final Message commandMessage = Int32Value.getDefaultInstance();
final Command command = requestFactory.command().create(commandMessage);
final Message rejectionMessage = CannotPerformBusinessOperation.newBuilder().setOperationId(newUuid()).build();
final Rejection rejection = Rejections.createRejection(rejectionMessage, command);
return rejection;
}
use of io.spine.core.Rejection 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());
}
Aggregations