Search in sources :

Example 6 with Assign

use of io.spine.server.command.Assign in project core-java by SpineEventEngine.

the class TaskAggregate method handle.

/**
 * A command handler that returns a pair with an optional second element.
 *
 * <p>{@link AggTaskAssigned} is present when the command contains an
 * {@linkplain AggCreateTask#getAssignee() assignee}.
 */
@Assign
Pair<AggTaskCreated, Optional<AggTaskAssigned>> handle(AggCreateTask command) {
    final AggTaskId id = command.getTaskId();
    final AggTaskCreated createdEvent = taskCreated(id);
    final UserId assignee = command.getAssignee();
    final AggTaskAssigned assignedEvent = taskAssignedOrNull(id, assignee);
    return Pair.withNullable(createdEvent, assignedEvent);
}
Also used : AggTaskCreated(io.spine.test.aggregate.event.AggTaskCreated) UserId(io.spine.core.UserId) AggTaskAssigned(io.spine.test.aggregate.event.AggTaskAssigned) AggTaskId(io.spine.test.aggregate.task.AggTaskId) Assign(io.spine.server.command.Assign)

Example 7 with Assign

use of io.spine.server.command.Assign in project core-java by SpineEventEngine.

the class TestAggregate method handle.

@Assign
AggTaskAdded handle(AggAddTask cmd, CommandContext ctx) {
    isAddTaskCommandHandled = true;
    final AggTaskAdded event = taskAdded(cmd.getProjectId());
    return event.toBuilder().setTask(cmd.getTask()).build();
}
Also used : AggTaskAdded(io.spine.test.aggregate.event.AggTaskAdded) Assign(io.spine.server.command.Assign)

Aggregations

Assign (io.spine.server.command.Assign)7 UserId (io.spine.core.UserId)3 AggTaskAssigned (io.spine.test.aggregate.event.AggTaskAssigned)3 AggTaskId (io.spine.test.aggregate.task.AggTaskId)3 Message (com.google.protobuf.Message)1 AggProjectCancelled (io.spine.test.aggregate.event.AggProjectCancelled)1 AggProjectCreated (io.spine.test.aggregate.event.AggProjectCreated)1 AggProjectPaused (io.spine.test.aggregate.event.AggProjectPaused)1 AggProjectStarted (io.spine.test.aggregate.event.AggProjectStarted)1 AggTaskAdded (io.spine.test.aggregate.event.AggTaskAdded)1 AggTaskCreated (io.spine.test.aggregate.event.AggTaskCreated)1 AggCannotReassignUnassignedTask (io.spine.test.aggregate.rejection.AggCannotReassignUnassignedTask)1