use of io.spine.core.UserId 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;
}
use of io.spine.core.UserId 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);
}
use of io.spine.core.UserId 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);
}
use of io.spine.core.UserId in project core-java by SpineEventEngine.
the class GivenCommandContextShould method create_with_actor_and_time.
@Test
public void create_with_actor_and_time() {
final UserId actorId = newUuid();
final Timestamp when = add(getCurrentTime(), fromMinutes(42));
final CommandContext context = GivenCommandContext.withActorAndTime(actorId, when);
checkValid(context);
final ActorContext actualActorContext = context.getActorContext();
assertEquals(actorId, actualActorContext.getActor());
assertEquals(when, actualActorContext.getTimestamp());
}
Aggregations