Search in sources :

Example 6 with TestActorRequestFactory

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

the class EventsShould method setUp.

@Before
public void setUp() {
    final TestActorRequestFactory requestFactory = TestActorRequestFactory.newInstance(getClass());
    final CommandEnvelope cmd = requestFactory.generateEnvelope();
    final StringValue producerId = toMessage(getClass().getSimpleName());
    EventFactory eventFactory = EventFactory.on(cmd, Identifier.pack(producerId));
    event = eventFactory.createEvent(Time.getCurrentTime(), Tests.<Version>nullRef());
    context = event.getContext();
}
Also used : TestActorRequestFactory(io.spine.client.TestActorRequestFactory) EventFactory(io.spine.server.event.EventFactory) StringValue(com.google.protobuf.StringValue) Before(org.junit.Before)

Example 7 with TestActorRequestFactory

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

the class CommandRoutingShould method apply_custom_route.

@Test
public void apply_custom_route() {
    final TestActorRequestFactory factory = TestActorRequestFactory.newInstance(getClass());
    // Have custom route.
    commandRouting.route(StringValue.class, customRoute);
    final CommandEnvelope command = factory.generateEnvelope();
    final long id = commandRouting.apply(command.getMessage(), command.getCommandContext());
    assertEquals(CUSTOM_ANSWER, id);
}
Also used : TestActorRequestFactory(io.spine.client.TestActorRequestFactory) CommandEnvelope(io.spine.core.CommandEnvelope) Test(org.junit.Test)

Example 8 with TestActorRequestFactory

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

the class CommandRoutingShould method apply_default_route.

@Test
public void apply_default_route() {
    final TestActorRequestFactory factory = TestActorRequestFactory.newInstance(getClass());
    // Replace the default route since we have custom command message.
    commandRouting.replaceDefault(customDefault).route(StringValue.class, customRoute);
    final CommandEnvelope command = CommandEnvelope.of(factory.createCommand(Time.getCurrentTime()));
    final long id = commandRouting.apply(command.getMessage(), command.getCommandContext());
    assertEquals(DEFAULT_ANSWER, id);
}
Also used : TestActorRequestFactory(io.spine.client.TestActorRequestFactory) CommandEnvelope(io.spine.core.CommandEnvelope) Test(org.junit.Test)

Example 9 with TestActorRequestFactory

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

the class ProcessManagerDispatcherShould method pass_null_tolerance_check.

@Test
public void pass_null_tolerance_check() {
    TestActorRequestFactory requestFactory = TestActorRequestFactory.newInstance(getClass());
    TestEventFactory eventFactory = TestEventFactory.newInstance(getClass());
    final Command command = requestFactory.generateCommand();
    new NullPointerTester().setDefault(CommandEnvelope.class, CommandEnvelope.of(command)).setDefault(EventEnvelope.class, EventEnvelope.of(eventFactory.createEvent(newUuidValue()))).setDefault(RejectionEnvelope.class, RejectionEnvelope.of(createRejection(newUuidValue(), command))).setDefault(ProcessManager.class, mock(ProcessManager.class)).testAllPublicStaticMethods(ProcessManagerDispatcher.class);
}
Also used : TestActorRequestFactory(io.spine.client.TestActorRequestFactory) EventEnvelope(io.spine.core.EventEnvelope) TestEventFactory(io.spine.server.command.TestEventFactory) Command(io.spine.core.Command) NullPointerTester(com.google.common.testing.NullPointerTester) Test(org.junit.Test)

Aggregations

TestActorRequestFactory (io.spine.client.TestActorRequestFactory)9 Test (org.junit.Test)7 Command (io.spine.core.Command)4 CommandEnvelope (io.spine.core.CommandEnvelope)4 StringValue (com.google.protobuf.StringValue)2 Error (io.spine.base.Error)2 NullPointerTester (com.google.common.testing.NullPointerTester)1 UInt32Value (com.google.protobuf.UInt32Value)1 StringChange (io.spine.change.StringChange)1 Ack (io.spine.core.Ack)1 CommandValidationError (io.spine.core.CommandValidationError)1 EventEnvelope (io.spine.core.EventEnvelope)1 Status (io.spine.core.Status)1 TenantId (io.spine.core.TenantId)1 FailingAggregateRepository (io.spine.server.aggregate.given.AggregateRepositoryTestEnv.FailingAggregateRepository)1 TestEventFactory (io.spine.server.command.TestEventFactory)1 CommandRecord (io.spine.server.commandbus.CommandRecord)1 EventFactory (io.spine.server.event.EventFactory)1 TenantAwareTest (io.spine.server.tenant.TenantAwareTest)1 ProjectId (io.spine.test.rejection.ProjectId)1