Search in sources :

Example 26 with CommandEnvelope

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

the class AggregateCommandEndpointShould method assertDispatches.

/*
     * Utility methods.
     ****************************/
private void assertDispatches(Command cmd) {
    final CommandEnvelope envelope = CommandEnvelope.of(cmd);
    repository.dispatch(envelope);
    ProjectAggregate.assertHandled(cmd);
}
Also used : CommandEnvelope(io.spine.core.CommandEnvelope)

Example 27 with CommandEnvelope

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

the class AggregateRepositoryShould method not_pass_command_rejection_to_onError.

@Test
public void not_pass_command_rejection_to_onError() {
    final FailingAggregateRepository repository = new FailingAggregateRepository();
    boundedContext.register(repository);
    final TestActorRequestFactory requestFactory = TestActorRequestFactory.newInstance(getClass());
    // Passing negative long value to `FailingAggregate` should cause a rejection.
    final CommandEnvelope ce = CommandEnvelope.of(requestFactory.createCommand(UInt64Value.newBuilder().setValue(-100_000_000L).build()));
    boundedContext.getCommandBus().post(ce.getCommand(), StreamObservers.<Ack>noOpObserver());
    assertFalse(repository.isErrorLogged());
}
Also used : TestActorRequestFactory(io.spine.client.TestActorRequestFactory) FailingAggregateRepository(io.spine.server.aggregate.given.AggregateRepositoryTestEnv.FailingAggregateRepository) CommandEnvelope(io.spine.core.CommandEnvelope) Test(org.junit.Test)

Example 28 with CommandEnvelope

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

the class ProcessManagerShould method throw_exception_if_dispatch_unknown_command.

@Test(expected = IllegalStateException.class)
public void throw_exception_if_dispatch_unknown_command() {
    final Int32Value unknownCommand = Int32Value.getDefaultInstance();
    final CommandEnvelope envelope = CommandEnvelope.of(requestFactory.createCommand(unknownCommand));
    processManager.dispatchCommand(envelope);
}
Also used : Int32Value(com.google.protobuf.Int32Value) CommandEnvelope(io.spine.core.CommandEnvelope) TenantAwareTest(io.spine.server.tenant.TenantAwareTest) Test(org.junit.Test)

Example 29 with CommandEnvelope

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

the class PmCommandEndpoint method getTargets.

@Override
protected I getTargets() {
    final CommandEnvelope envelope = envelope();
    final I id = repository().getCommandRouting().apply(envelope.getMessage(), envelope.getCommandContext());
    return id;
}
Also used : CommandEnvelope(io.spine.core.CommandEnvelope)

Example 30 with CommandEnvelope

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

the class TestActorRequestFactory method generateEnvelope.

/**
 * Generates a command and wraps it into envelope.
 */
public CommandEnvelope generateEnvelope() {
    final Command command = generateCommand();
    final CommandEnvelope result = CommandEnvelope.of(command);
    return result;
}
Also used : Command(io.spine.core.Command) CommandEnvelope(io.spine.core.CommandEnvelope)

Aggregations

CommandEnvelope (io.spine.core.CommandEnvelope)40 Test (org.junit.Test)25 Command (io.spine.core.Command)11 Message (com.google.protobuf.Message)7 Error (io.spine.base.Error)5 TestActorRequestFactory (io.spine.client.TestActorRequestFactory)4 StringValue (com.google.protobuf.StringValue)3 CommandValidationError (io.spine.core.CommandValidationError)3 Event (io.spine.core.Event)3 BoundedContext (io.spine.server.BoundedContext)3 TenantAwareTest (io.spine.server.tenant.TenantAwareTest)3 CommandId (io.spine.core.CommandId)2 Commands.getMessage (io.spine.core.Commands.getMessage)2 TypeConverter.toMessage (io.spine.protobuf.TypeConverter.toMessage)2 CommandBus (io.spine.server.commandbus.CommandBus)2 HandlerMethodFailedException (io.spine.server.model.HandlerMethodFailedException)2 AggCreateProject (io.spine.test.aggregate.command.AggCreateProject)2 ProjectId (io.spine.test.procman.ProjectId)2 TypeName (io.spine.type.TypeName)2 Set (java.util.Set)2