use of io.spine.core.UserId in project core-java by SpineEventEngine.
the class TaskAggregate method taskAssignedOrNull.
/**
* Creates a new {@link AggTaskAssigned} event message with provided values. If the
* {@linkplain UserId assignee} is a default empty instance returns {@code null}.
*/
@Nullable
private static AggTaskAssigned taskAssignedOrNull(AggTaskId id, UserId assignee) {
final UserId emptyUserId = UserId.getDefaultInstance();
if (assignee.equals(emptyUserId)) {
return null;
}
final AggTaskAssigned event = AggTaskAssigned.newBuilder().setTaskId(id).setNewAssignee(assignee).build();
return event;
}
use of io.spine.core.UserId 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;
}
use of io.spine.core.UserId in project core-java by SpineEventEngine.
the class GivenCommandContext method withRandomActor.
/**
* Creates a new {@link CommandContext} instance with a randomly
* generated {@linkplain UserId actor} and current timestamp as a creation date.
*
* @return a new {@code CommandContext} instance
*/
public static CommandContext withRandomActor() {
final UserId userId = GivenUserId.newUuid();
final Timestamp now = getCurrentTime();
return withActorAndTime(userId, now);
}
use of io.spine.core.UserId in project core-java by SpineEventEngine.
the class GivenUserIdShould method create_UserId_by_string.
@Test
public void create_UserId_by_string() {
final String testIdString = "12345";
final UserId userId = of(testIdString);
final UserId expected = UserId.newBuilder().setValue(testIdString).build();
assertEquals(expected, userId);
}
use of io.spine.core.UserId in project core-java by SpineEventEngine.
the class CommandFactoryShould method create_command_context.
@Test
public void create_command_context() {
final TenantId tenantId = GivenTenantId.newUuid();
final UserId userId = GivenUserId.newUuid();
final ZoneOffset zoneOffset = ZoneOffsets.ofHours(-3);
final int targetVersion = 100500;
final CommandContext commandContext = CommandFactory.createContext(tenantId, userId, zoneOffset, targetVersion);
final ActorContext actorContext = commandContext.getActorContext();
assertEquals(tenantId, actorContext.getTenantId());
assertEquals(userId, actorContext.getActor());
assertEquals(zoneOffset, actorContext.getZoneOffset());
assertEquals(targetVersion, commandContext.getTargetVersion());
}
Aggregations