Search in sources :

Example 1 with AggTaskCreated

use of io.spine.test.aggregate.event.AggTaskCreated 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)

Aggregations

UserId (io.spine.core.UserId)1 Assign (io.spine.server.command.Assign)1 AggTaskAssigned (io.spine.test.aggregate.event.AggTaskAssigned)1 AggTaskCreated (io.spine.test.aggregate.event.AggTaskCreated)1 AggTaskId (io.spine.test.aggregate.task.AggTaskId)1