Search in sources :

Example 1 with AggCannotReassignUnassignedTask

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

Aggregations

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