Search in sources :

Example 1 with RefProjectCreated

use of io.spine.test.reflect.event.RefProjectCreated in project core-java by SpineEventEngine.

the class EventSubscriberMethodShould method invoke_subscriber_method.

@Test
public void invoke_subscriber_method() throws InvocationTargetException {
    final ValidTwoParams subscriberObject;
    subscriberObject = spy(new ValidTwoParams());
    final EventSubscriberMethod subscriber = EventSubscriberMethod.from(subscriberObject.getMethod());
    final RefProjectCreated msg = Given.EventMessage.projectCreated();
    subscriber.invoke(subscriberObject, msg, EventContext.getDefaultInstance());
    verify(subscriberObject, times(1)).handle(msg, EventContext.getDefaultInstance());
}
Also used : RefProjectCreated(io.spine.test.reflect.event.RefProjectCreated) ValidTwoParams(io.spine.server.event.given.EventSubscriberMethodTestEnv.ValidTwoParams) Test(org.junit.Test)

Example 2 with RefProjectCreated

use of io.spine.test.reflect.event.RefProjectCreated in project core-java by SpineEventEngine.

the class EventApplierMethodShould method invoke_applier_method.

@Test
public void invoke_applier_method() throws InvocationTargetException {
    final ValidApplier applierObject = new ValidApplier();
    final EventApplierMethod applier = EventApplierMethod.from(applierObject.getMethod());
    final RefProjectCreated event = Sample.messageOfType(RefProjectCreated.class);
    applier.invoke(applierObject, event);
    assertEquals(event, applierObject.eventApplied);
}
Also used : RefProjectCreated(io.spine.test.reflect.event.RefProjectCreated) Test(org.junit.Test)

Example 3 with RefProjectCreated

use of io.spine.test.reflect.event.RefProjectCreated in project core-java by SpineEventEngine.

the class CommandHandlerMethodShould method invoke_handler_method_and_return_message_list.

@Test
public void invoke_handler_method_and_return_message_list() {
    final ValidHandlerOneParamReturnsList handlerObject = spy(new ValidHandlerOneParamReturnsList());
    final CommandHandlerMethod handler = from(handlerObject.getHandler());
    final RefCreateProject cmd = createProject();
    final List<? extends Message> events = handler.invoke(handlerObject, cmd, emptyContext);
    verify(handlerObject, times(1)).handleTest(cmd);
    assertEquals(1, events.size());
    final RefProjectCreated event = (RefProjectCreated) events.get(0);
    assertEquals(cmd.getProjectId(), event.getProjectId());
}
Also used : RefProjectCreated(io.spine.test.reflect.event.RefProjectCreated) RefCreateProject(io.spine.test.reflect.command.RefCreateProject) ValidHandlerOneParamReturnsList(io.spine.server.command.given.CommandHandlerMethodTestEnv.ValidHandlerOneParamReturnsList) Test(org.junit.Test)

Example 4 with RefProjectCreated

use of io.spine.test.reflect.event.RefProjectCreated in project core-java by SpineEventEngine.

the class CommandHandlerMethodShould method invoke_handler_method_which_returns_one_message.

@Test
public void invoke_handler_method_which_returns_one_message() {
    final ValidHandlerTwoParams handlerObject = spy(new ValidHandlerTwoParams());
    final CommandHandlerMethod handler = from(handlerObject.getHandler());
    final RefCreateProject cmd = createProject();
    final List<? extends Message> events = handler.invoke(handlerObject, cmd, emptyContext);
    verify(handlerObject, times(1)).handleTest(cmd, emptyContext);
    assertEquals(1, events.size());
    final RefProjectCreated event = (RefProjectCreated) events.get(0);
    assertEquals(cmd.getProjectId(), event.getProjectId());
}
Also used : RefProjectCreated(io.spine.test.reflect.event.RefProjectCreated) RefCreateProject(io.spine.test.reflect.command.RefCreateProject) ValidHandlerTwoParams(io.spine.server.command.given.CommandHandlerMethodTestEnv.ValidHandlerTwoParams) Test(org.junit.Test)

Aggregations

RefProjectCreated (io.spine.test.reflect.event.RefProjectCreated)4 Test (org.junit.Test)4 RefCreateProject (io.spine.test.reflect.command.RefCreateProject)2 ValidHandlerOneParamReturnsList (io.spine.server.command.given.CommandHandlerMethodTestEnv.ValidHandlerOneParamReturnsList)1 ValidHandlerTwoParams (io.spine.server.command.given.CommandHandlerMethodTestEnv.ValidHandlerTwoParams)1 ValidTwoParams (io.spine.server.event.given.EventSubscriberMethodTestEnv.ValidTwoParams)1