Search in sources :

Example 1 with ValidThreeParams

use of io.spine.server.rejection.given.RejectionSubscriberMethodTestEnv.ValidThreeParams in project core-java by SpineEventEngine.

the class RejectionSubscriberMethodShould method consider_subscriber_with_both_messages_and_context_params_valid.

@Test
public void consider_subscriber_with_both_messages_and_context_params_valid() {
    final Method subscriber = new ValidThreeParams().getMethod();
    assertIsRejectionSubscriber(subscriber, true);
}
Also used : ValidThreeParams(io.spine.server.rejection.given.RejectionSubscriberMethodTestEnv.ValidThreeParams) Method(java.lang.reflect.Method) Test(org.junit.Test)

Example 2 with ValidThreeParams

use of io.spine.server.rejection.given.RejectionSubscriberMethodTestEnv.ValidThreeParams 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)

Aggregations

ValidThreeParams (io.spine.server.rejection.given.RejectionSubscriberMethodTestEnv.ValidThreeParams)2 Test (org.junit.Test)2 CommandContext (io.spine.core.CommandContext)1 RejectionContext (io.spine.core.RejectionContext)1 InvalidProjectName (io.spine.test.reflect.ReflectRejections.InvalidProjectName)1 RjUpdateProjectName (io.spine.test.rejection.command.RjUpdateProjectName)1 Method (java.lang.reflect.Method)1