Search in sources :

Example 1 with TestActorRequestFactory

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

the class CommandServiceShould method return_error_if_command_is_unsupported.

@Test
public void return_error_if_command_is_unsupported() {
    final TestActorRequestFactory factory = TestActorRequestFactory.newInstance(getClass());
    final Command unsupportedCmd = factory.createCommand(StringValue.getDefaultInstance());
    service.post(unsupportedCmd, responseObserver);
    final Throwable exception = responseObserver.getThrowable().getCause();
    assertEquals(UnsupportedCommandException.class, exception.getClass());
}
Also used : TestActorRequestFactory(io.spine.test.TestActorRequestFactory) Command(io.spine.base.Command) Test(org.junit.Test)

Example 2 with TestActorRequestFactory

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

the class FailureBusShould method invalidProjectNameFailure.

private static Failure invalidProjectNameFailure() {
    final ProjectId projectId = ProjectId.newBuilder().setId(newUuid()).build();
    final ProjectFailures.InvalidProjectName invalidProjectName = ProjectFailures.InvalidProjectName.newBuilder().setProjectId(projectId).build();
    final StringChange nameChange = StringChange.newBuilder().setNewValue("Too short").build();
    final UpdateProjectName updateProjectName = UpdateProjectName.newBuilder().setId(projectId).setNameUpdate(nameChange).build();
    final TenantId generatedTenantId = TenantId.newBuilder().setValue(newUuid()).build();
    final TestActorRequestFactory factory = TestActorRequestFactory.newInstance(FailureBusShould.class, generatedTenantId);
    final Command command = factory.createCommand(updateProjectName);
    return Failures.createFailure(invalidProjectName, command);
}
Also used : TestActorRequestFactory(io.spine.test.TestActorRequestFactory) TenantId(io.spine.users.TenantId) Command(io.spine.base.Command) UpdateProjectName(io.spine.test.failure.command.UpdateProjectName) ProjectId(io.spine.test.failure.ProjectId) ProjectFailures(io.spine.test.failure.ProjectFailures) StringChange(io.spine.change.StringChange)

Example 3 with TestActorRequestFactory

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

the class EventsShould method setUp.

@Before
public void setUp() {
    final TestActorRequestFactory requestFactory = TestActorRequestFactory.newInstance(getClass());
    final Command cmd = requestFactory.command().create(Time.getCurrentTime());
    final StringValue producerId = Wrapper.forString(getClass().getSimpleName());
    EventFactory eventFactory = EventFactory.newBuilder().setCommandId(Commands.generateId()).setProducerId(producerId).setCommandContext(cmd.getContext()).build();
    event = eventFactory.createEvent(Time.getCurrentTime(), Tests.<Version>nullRef());
    context = event.getContext();
}
Also used : TestActorRequestFactory(io.spine.test.TestActorRequestFactory) Version(io.spine.base.Version) TestEventFactory(io.spine.test.TestEventFactory) EventFactory(io.spine.server.command.EventFactory) StringValue(com.google.protobuf.StringValue) Before(org.junit.Before)

Example 4 with TestActorRequestFactory

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

the class FailureThrowableShould method setUp.

@Before
public void setUp() {
    final TestActorRequestFactory requestFactory = TestActorRequestFactory.newInstance(FailureThrowable.class);
    this.command = requestFactory.command().create(newUuidValue());
}
Also used : TestActorRequestFactory(io.spine.test.TestActorRequestFactory) Before(org.junit.Before)

Aggregations

TestActorRequestFactory (io.spine.test.TestActorRequestFactory)4 Command (io.spine.base.Command)2 Before (org.junit.Before)2 StringValue (com.google.protobuf.StringValue)1 Version (io.spine.base.Version)1 StringChange (io.spine.change.StringChange)1 EventFactory (io.spine.server.command.EventFactory)1 TestEventFactory (io.spine.test.TestEventFactory)1 ProjectFailures (io.spine.test.failure.ProjectFailures)1 ProjectId (io.spine.test.failure.ProjectId)1 UpdateProjectName (io.spine.test.failure.command.UpdateProjectName)1 TenantId (io.spine.users.TenantId)1 Test (org.junit.Test)1