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