Search in sources :

Example 1 with RjUpdateProjectName

use of io.spine.test.rejection.command.RjUpdateProjectName in project core-java by SpineEventEngine.

the class RejectionReactorMethodShould method invoke_reactor_method.

@Test
public void invoke_reactor_method() throws InvocationTargetException {
    final RValidThreeParams reactorObject = new RValidThreeParams();
    final RejectionReactorMethod reactor = new RejectionReactorMethod(reactorObject.getMethod());
    final InvalidProjectName rejectionMessage = Given.RejectionMessage.invalidProjectName();
    final RejectionContext.Builder builder = RejectionContext.newBuilder();
    final CommandContext commandContext = CommandContext.newBuilder().setTargetVersion(3040).build();
    final RjUpdateProjectName commandMessage = RjUpdateProjectName.getDefaultInstance();
    builder.setCommand(Command.newBuilder().setMessage(pack(commandMessage)).setContext(commandContext));
    final RejectionContext rejectionContext = builder.build();
    reactor.invoke(reactorObject, rejectionMessage, rejectionContext);
    assertEquals(rejectionMessage, reactorObject.getLastRejectionMessage());
    assertEquals(commandMessage, reactorObject.getLastCommandMessage());
    assertEquals(commandContext, reactorObject.getLastCommandContext());
}
Also used : CommandContext(io.spine.core.CommandContext) InvalidProjectName(io.spine.test.reflect.ReflectRejections.InvalidProjectName) RejectionContext(io.spine.core.RejectionContext) RjUpdateProjectName(io.spine.test.rejection.command.RjUpdateProjectName) RValidThreeParams(io.spine.server.rejection.given.RejectionReactorMethodTestEnv.RValidThreeParams) Test(org.junit.Test)

Example 2 with RjUpdateProjectName

use of io.spine.test.rejection.command.RjUpdateProjectName in project core-java by SpineEventEngine.

the class RejectionSubscriberMethodShould method invoke_subscriber_method.

@Test
public void invoke_subscriber_method() throws InvocationTargetException {
    final ValidThreeParams subscriberObject = new ValidThreeParams();
    final RejectionSubscriberMethod method = new RejectionSubscriberMethod(subscriberObject.getMethod());
    final InvalidProjectName rejectionMessage = Given.RejectionMessage.invalidProjectName();
    final RejectionContext.Builder builder = RejectionContext.newBuilder();
    final CommandContext commandContext = CommandContext.newBuilder().setTargetVersion(1020).build();
    final RjUpdateProjectName commandMessage = RjUpdateProjectName.getDefaultInstance();
    builder.setCommand(Command.newBuilder().setMessage(pack(commandMessage)).setContext(commandContext));
    final RejectionContext rejectionContext = builder.build();
    method.invoke(subscriberObject, rejectionMessage, rejectionContext);
    assertEquals(rejectionMessage, subscriberObject.getLastRejectionMessage());
    assertEquals(commandMessage, subscriberObject.getLastCommandMessage());
    assertEquals(commandContext, subscriberObject.getLastCommandContext());
}
Also used : CommandContext(io.spine.core.CommandContext) ValidThreeParams(io.spine.server.rejection.given.RejectionSubscriberMethodTestEnv.ValidThreeParams) InvalidProjectName(io.spine.test.reflect.ReflectRejections.InvalidProjectName) RejectionContext(io.spine.core.RejectionContext) RjUpdateProjectName(io.spine.test.rejection.command.RjUpdateProjectName) Test(org.junit.Test)

Example 3 with RjUpdateProjectName

use of io.spine.test.rejection.command.RjUpdateProjectName in project core-java by SpineEventEngine.

the class Given method invalidProjectNameRejection.

public static Rejection invalidProjectNameRejection() {
    final ProjectId projectId = newProjectId();
    final ProjectRejections.InvalidProjectName invalidProjectName = ProjectRejections.InvalidProjectName.newBuilder().setProjectId(projectId).build();
    final StringChange nameChange = StringChange.newBuilder().setNewValue("Too short").build();
    final RjUpdateProjectName updateProjectName = RjUpdateProjectNameVBuilder.newBuilder().setId(projectId).setNameUpdate(nameChange).build();
    final TenantId generatedTenantId = TenantId.newBuilder().setValue(newUuid()).build();
    final TestActorRequestFactory factory = TestActorRequestFactory.newInstance(RejectionBusShould.class, generatedTenantId);
    final Command command = factory.createCommand(updateProjectName);
    return Rejections.createRejection(invalidProjectName, command);
}
Also used : TestActorRequestFactory(io.spine.client.TestActorRequestFactory) TenantId(io.spine.core.TenantId) Command(io.spine.core.Command) ProjectRejections(io.spine.test.rejection.ProjectRejections) ProjectId(io.spine.test.rejection.ProjectId) RjUpdateProjectName(io.spine.test.rejection.command.RjUpdateProjectName) StringChange(io.spine.change.StringChange)

Aggregations

RjUpdateProjectName (io.spine.test.rejection.command.RjUpdateProjectName)3 CommandContext (io.spine.core.CommandContext)2 RejectionContext (io.spine.core.RejectionContext)2 InvalidProjectName (io.spine.test.reflect.ReflectRejections.InvalidProjectName)2 Test (org.junit.Test)2 StringChange (io.spine.change.StringChange)1 TestActorRequestFactory (io.spine.client.TestActorRequestFactory)1 Command (io.spine.core.Command)1 TenantId (io.spine.core.TenantId)1 RValidThreeParams (io.spine.server.rejection.given.RejectionReactorMethodTestEnv.RValidThreeParams)1 ValidThreeParams (io.spine.server.rejection.given.RejectionSubscriberMethodTestEnv.ValidThreeParams)1 ProjectId (io.spine.test.rejection.ProjectId)1 ProjectRejections (io.spine.test.rejection.ProjectRejections)1