Search in sources :

Example 1 with CreateProject

use of io.spine.test.command.CreateProject 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 CreateProject 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().getFailure()));
            break;
        case ERROR:
            assertTrue(isNotDefault(record.getStatus().getError()));
            break;
        case FAILURE:
            assertTrue(isNotDefault(record.getStatus().getFailure()));
            break;
        case UNDEFINED:
        case UNRECOGNIZED:
            break;
    }
}
Also used : CommandContext(io.spine.base.CommandContext) CommandId(io.spine.base.CommandId) CreateProject(io.spine.test.command.CreateProject)

Example 2 with CreateProject

use of io.spine.test.command.CreateProject 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 CreateProject msg = createProjectMessage();
    final Command command = requestFactory.command().create(msg);
    return command;
}
Also used : Command(io.spine.base.Command) CommandHandler(io.spine.server.command.CommandHandler) CreateProject(io.spine.test.command.CreateProject)

Aggregations

CreateProject (io.spine.test.command.CreateProject)2 Command (io.spine.base.Command)1 CommandContext (io.spine.base.CommandContext)1 CommandId (io.spine.base.CommandId)1 CommandHandler (io.spine.server.command.CommandHandler)1