use of io.spine.core.ActorContext in project core-java by SpineEventEngine.
the class RejectionEnvelopeShould method obtain_actor_context.
@Test
public void obtain_actor_context() {
final RejectionEnvelope rejection = toEnvelope(outerObject());
final ActorContext actorContext = rejection.getActorContext();
/* Since we're using `TestActorRequestFactory` initialized with the class of this test suite
the actor ID should be the suite class name.
*/
assertEquals(getClass().getName(), actorContext.getActor().getValue());
}
use of io.spine.core.ActorContext in project core-java by SpineEventEngine.
the class GivenCommandContext method withActorAndTime.
/**
* Creates a new {@link CommandContext} instance based upon given actor and creation date.
*
* @return a new {@code CommandContext} instance
*/
public static CommandContext withActorAndTime(UserId actor, Timestamp when) {
final TenantId tenantId = GivenTenantId.newUuid();
final ActorContext.Builder actorContext = ActorContext.newBuilder().setActor(actor).setTimestamp(when).setZoneOffset(UTC).setTenantId(tenantId);
final CommandContext.Builder builder = CommandContext.newBuilder().setActorContext(actorContext);
return builder.build();
}
use of io.spine.core.ActorContext in project core-java by SpineEventEngine.
the class GivenCommandContextShould method create_with_random_actor.
@Test
public void create_with_random_actor() {
final CommandContext first = GivenCommandContext.withRandomActor();
final CommandContext second = GivenCommandContext.withRandomActor();
checkValid(first);
checkValid(second);
final ActorContext firstActorContext = first.getActorContext();
final ActorContext secondActorContext = second.getActorContext();
assertNotEquals(firstActorContext.getActor(), secondActorContext.getActor());
}
use of io.spine.core.ActorContext in project core-java by SpineEventEngine.
the class AbstractCommandRouter method commandFactory.
/**
* Creates a {@code CommandFactory} using the {@linkplain io.spine.core.UserId actor},
* {@linkplain io.spine.core.TenantId tenant ID} and {@linkplain io.spine.time.ZoneOffset
* zone offset} from the given command context.
*/
private static CommandFactory commandFactory(CommandContext sourceContext) {
final ActorContext actorContext = sourceContext.getActorContext();
final ActorRequestFactory factory = ActorRequestFactory.newBuilder().setActor(actorContext.getActor()).setTenantId(actorContext.getTenantId()).setZoneOffset(actorContext.getZoneOffset()).build();
return factory.command();
}
use of io.spine.core.ActorContext in project core-java by SpineEventEngine.
the class ActorRequestFactoryShould method verifyContext.
void verifyContext(ActorContext actualContext) {
final ActorContext expectedContext = actorContext();
assertEquals(expectedContext.getTenantId(), actualContext.getTenantId());
assertEquals(expectedContext.getActor(), actualContext.getActor());
assertEquals(expectedContext.getLanguage(), actualContext.getLanguage());
assertEquals(expectedContext.getZoneOffset(), actualContext.getZoneOffset());
// It's impossible to get the same creation time for the `expected` value,
// so checking that the `actual` value is not later than `expected`.
assertTrue(actualContext.getTimestamp().equals(expectedContext.getTimestamp()) || isLaterThan(expectedContext.getTimestamp(), actualContext.getTimestamp()));
}
Aggregations