Search in sources :

Example 1 with CmdCreateProject

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

the class CommandTestUtil method checkRecord.

static void checkRecord(CommandRecord record, Command cmd, CommandStatus statusExpected) {
    final CommandContext context = cmd.getContext();
    final CommandId commandId = cmd.getId();
    final CmdCreateProject message = unpack(cmd.getMessage());
    assertEquals(cmd.getMessage(), record.getCommand().getMessage());
    assertTrue(record.getTimestamp().getSeconds() > 0);
    assertEquals(message.getClass().getSimpleName(), record.getCommandType());
    assertEquals(commandId, record.getCommandId());
    assertEquals(statusExpected, record.getStatus().getCode());
    assertEquals(context, record.getCommand().getContext());
    switch(statusExpected) {
        case RECEIVED:
        case OK:
        case SCHEDULED:
            assertTrue(isDefault(record.getStatus().getError()));
            assertTrue(isDefault(record.getStatus().getRejection()));
            break;
        case ERROR:
            assertTrue(isNotDefault(record.getStatus().getError()));
            break;
        case REJECTED:
            assertTrue(isNotDefault(record.getStatus().getRejection()));
            break;
        case UNDEFINED:
        case UNRECOGNIZED:
            break;
    }
}
Also used : CmdCreateProject(io.spine.test.command.CmdCreateProject) CommandContext(io.spine.core.CommandContext) CommandId(io.spine.core.CommandId)

Example 2 with CmdCreateProject

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

the class CommandStoreShould method givenThrowingHandler.

private <E extends Throwable> Command givenThrowingHandler(E throwable) {
    final CommandHandler handler = new ThrowingCreateProjectHandler(throwable);
    commandBus.register(handler);
    final CmdCreateProject msg = createProjectMessage();
    final Command command = requestFactory.command().create(msg);
    return command;
}
Also used : CmdCreateProject(io.spine.test.command.CmdCreateProject) Command(io.spine.core.Command) CommandHandler(io.spine.server.command.CommandHandler)

Aggregations

CmdCreateProject (io.spine.test.command.CmdCreateProject)2 Command (io.spine.core.Command)1 CommandContext (io.spine.core.CommandContext)1 CommandId (io.spine.core.CommandId)1 CommandHandler (io.spine.server.command.CommandHandler)1