Search in sources :

Example 1 with RefCreateProject

use of io.spine.test.reflect.command.RefCreateProject in project core-java by SpineEventEngine.

the class CommandHandlerMethodShould method set_producer_ID_if_entity.

@Test
public void set_producer_ID_if_entity() {
    final RefCreateProject commandMessage = createProject();
    final Aggregate<ProjectId, ?, ?> entity = new RejectingAggregate(commandMessage.getProjectId());
    final CommandEnvelope cmd = requestFactory.createEnvelope(commandMessage);
    try {
        AggregateMessageDispatcher.dispatchCommand(entity, cmd);
    } catch (HandlerMethodFailedException e) {
        assertCauseAndId(e, entity.getId());
    }
}
Also used : RefCreateProject(io.spine.test.reflect.command.RefCreateProject) HandlerMethodFailedException(io.spine.server.model.HandlerMethodFailedException) RejectingAggregate(io.spine.server.command.given.CommandHandlerMethodTestEnv.RejectingAggregate) ProjectId(io.spine.test.reflect.ProjectId) CommandEnvelope(io.spine.core.CommandEnvelope) Test(org.junit.Test)

Example 2 with RefCreateProject

use of io.spine.test.reflect.command.RefCreateProject 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 3 with RefCreateProject

use of io.spine.test.reflect.command.RefCreateProject 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

RefCreateProject (io.spine.test.reflect.command.RefCreateProject)3 Test (org.junit.Test)3 RefProjectCreated (io.spine.test.reflect.event.RefProjectCreated)2 CommandEnvelope (io.spine.core.CommandEnvelope)1 RejectingAggregate (io.spine.server.command.given.CommandHandlerMethodTestEnv.RejectingAggregate)1 ValidHandlerOneParamReturnsList (io.spine.server.command.given.CommandHandlerMethodTestEnv.ValidHandlerOneParamReturnsList)1 ValidHandlerTwoParams (io.spine.server.command.given.CommandHandlerMethodTestEnv.ValidHandlerTwoParams)1 HandlerMethodFailedException (io.spine.server.model.HandlerMethodFailedException)1 ProjectId (io.spine.test.reflect.ProjectId)1