Search in sources :

Example 1 with AggTaskId

use of io.spine.test.aggregate.task.AggTaskId in project core-java by SpineEventEngine.

the class TaskAggregate method handle.

@Assign
AggTaskAssigned handle(AggAssignTask command) {
    final AggTaskId id = command.getTaskId();
    final UserId newAssignee = command.getAssignee();
    final UserId previousAssignee = getState().getAssignee();
    final AggTaskAssigned event = taskAssigned(id, previousAssignee, newAssignee);
    return event;
}
Also used : 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 2 with AggTaskId

use of io.spine.test.aggregate.task.AggTaskId in project core-java by SpineEventEngine.

the class TaskAggregate method handle.

@Assign
AggTaskAssigned handle(AggReassignTask command) throws AggCannotReassignUnassignedTask {
    final AggTaskId id = command.getTaskId();
    final UserId newAssignee = command.getAssignee();
    final UserId previousAssignee = getState().getAssignee();
    if (previousAssignee.equals(EMPTY_USER_ID)) {
        throw new AggCannotReassignUnassignedTask(id, previousAssignee);
    }
    final AggTaskAssigned event = taskAssigned(id, previousAssignee, newAssignee);
    return event;
}
Also used : UserId(io.spine.core.UserId) AggTaskAssigned(io.spine.test.aggregate.event.AggTaskAssigned) AggCannotReassignUnassignedTask(io.spine.test.aggregate.rejection.AggCannotReassignUnassignedTask) AggTaskId(io.spine.test.aggregate.task.AggTaskId) Assign(io.spine.server.command.Assign)

Example 3 with AggTaskId

use of io.spine.test.aggregate.task.AggTaskId in project core-java by SpineEventEngine.

the class TaskAggregate method on.

@React
Pair<AggUserNotified, Optional<AggUserNotified>> on(AggTaskAssigned event) {
    final AggTaskId taskId = event.getTaskId();
    final UserId previousAssignee = event.getPreviousAssignee();
    final AggUserNotified previousAssigneeNotified = userNotifiedOrNull(taskId, previousAssignee);
    final UserId newAssignee = event.getNewAssignee();
    final AggUserNotified newAssigneeNotified = userNotified(taskId, newAssignee);
    return Pair.withNullable(newAssigneeNotified, previousAssigneeNotified);
}
Also used : UserId(io.spine.core.UserId) AggUserNotified(io.spine.test.aggregate.event.AggUserNotified) AggTaskId(io.spine.test.aggregate.task.AggTaskId) React(io.spine.core.React)

Example 4 with AggTaskId

use of io.spine.test.aggregate.task.AggTaskId 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)4 AggTaskId (io.spine.test.aggregate.task.AggTaskId)4 Assign (io.spine.server.command.Assign)3 AggTaskAssigned (io.spine.test.aggregate.event.AggTaskAssigned)3 React (io.spine.core.React)1 AggTaskCreated (io.spine.test.aggregate.event.AggTaskCreated)1 AggUserNotified (io.spine.test.aggregate.event.AggUserNotified)1 AggCannotReassignUnassignedTask (io.spine.test.aggregate.rejection.AggCannotReassignUnassignedTask)1