use of io.spine.core.TenantId in project core-java by SpineEventEngine.
the class DuplicateCommandShould method be_acknowledged_on_client_when_posted_to_an_aggregate.
@Test
public void be_acknowledged_on_client_when_posted_to_an_aggregate() {
final TenantId tenantId = newTenantId();
final Command command = command(createProject(), tenantId);
client.post(command);
final Ack ack = client.post(command);
final Status status = ack.getStatus();
final Error error = status.getError();
final String errorType = error.getType();
final String expectedErrorType = DuplicateCommandException.class.getCanonicalName();
assertEquals(expectedErrorType, errorType);
}
use of io.spine.core.TenantId in project core-java by SpineEventEngine.
the class CurrentTenantShould method keep_set_value.
// we check isPresent() in assertion
@SuppressWarnings("OptionalGetWithoutIsPresent")
@Test
public void keep_set_value() {
final TenantId expected = nameOf(getClass());
CurrentTenant.set(expected);
final Optional<TenantId> currentTenant = CurrentTenant.get();
assertTrue(currentTenant.isPresent());
assertEquals(expected, currentTenant.get());
}
use of io.spine.core.TenantId in project core-java by SpineEventEngine.
the class TenantAwareOperationShould method clear_current_tenant_on_restore_if_no_tenant_was_set.
@Test
public void clear_current_tenant_on_restore_if_no_tenant_was_set() {
// Make sure there's not current tenant.
CurrentTenant.clear();
// Create new operation.
final TenantId newTenant = newUuid();
final TenantAwareOperation op = createOperation(newTenant);
// Check that the construction did not set the tenant.
assertFalse(CurrentTenant.get().isPresent());
op.execute();
// Check that the execution was on the correct tenant.
assertEquals(newTenant, getTenantFromRun(op));
// Check that the execution cleared the current tenant.
assertFalse(CurrentTenant.get().isPresent());
}
use of io.spine.core.TenantId in project core-java by SpineEventEngine.
the class TenantAwareOperationShould method remember_and_restore_current_tenant.
@Test
public void remember_and_restore_current_tenant() {
final TenantId previousTenant = newUuid();
CurrentTenant.set(previousTenant);
final TenantId newTenant = newUuid();
final TenantAwareOperation op = createOperation(newTenant);
// Check that the construction of the operation does not change the current tenant.
assertEquals(previousTenant, CurrentTenant.get().get());
op.execute();
// Check that we got right value inside run().
assertEquals(newTenant, getTenantFromRun(op));
// Check that the current tenant is restored.
assertEquals(previousTenant, CurrentTenant.get().get());
}
use of io.spine.core.TenantId in project core-java by SpineEventEngine.
the class TenantRepositoryShould method cache_passed_value.
@Test
public void cache_passed_value() {
final TenantId tenantId = newUuid();
repository.keep(tenantId);
repository.keep(tenantId);
verify(repository, times(1)).find(tenantId);
}
Aggregations