use of io.spine.core.TenantId in project core-java by SpineEventEngine.
the class MultiTenantStandShould method setUp.
@Override
@Before
public void setUp() {
super.setUp();
final TenantId tenantId = newUuid();
setCurrentTenant(tenantId);
setMultitenant(true);
setRequestFactory(createRequestFactory(tenantId));
}
use of io.spine.core.TenantId in project core-java by SpineEventEngine.
the class CurrentTenantShould method clear_set_value.
@Test
public void clear_set_value() {
final TenantId value = nameOf(getClass());
CurrentTenant.set(value);
CurrentTenant.clear();
assertFalse(CurrentTenant.get().isPresent());
}
use of io.spine.core.TenantId in project core-java by SpineEventEngine.
the class TenantAwareOperationShould method create_instance_for_non_command_execution_context.
@Test
public void create_instance_for_non_command_execution_context() {
final TenantId tenant = newUuid();
CurrentTenant.set(tenant);
final TenantAwareOperation op = createOperation();
assertEquals(tenant, op.tenantId());
op.execute();
assertEquals(tenant, getTenantFromRun(op));
}
use of io.spine.core.TenantId 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.TenantId in project core-java by SpineEventEngine.
the class CommandStoreShould method set_command_status_to_rejection_when_handler_throws_rejection.
@Test
public void set_command_status_to_rejection_when_handler_throws_rejection() {
ModelTests.clearModel();
final TestRejection rejection = new TestRejection();
final Command command = givenThrowingHandler(rejection);
final CommandId commandId = command.getId();
final Message commandMessage = getMessage(command);
commandBus.post(command, observer);
// Check that the logging was called.
verify(log).rejectedWith(eq(rejection), eq(commandMessage), eq(commandId));
// Check that the status has the correct code,
// and the rejection matches the thrown rejection.
final TenantId tenantId = command.getContext().getActorContext().getTenantId();
final ProcessingStatus status = getStatus(commandId, tenantId);
assertEquals(CommandStatus.REJECTED, status.getCode());
assertEquals(toRejection(rejection, command).getMessage(), status.getRejection().getMessage());
}
Aggregations