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());
}
}
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());
}
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());
}
Aggregations