Search in sources :

Example 11 with TenantId

use of io.spine.users.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 = newTenantUuid();
    CurrentTenant.set(tenant);
    final TenantAwareOperation op = createOperation();
    assertEquals(tenant, op.tenantId());
    op.execute();
    assertEquals(tenant, getTenantFromRun(op));
}
Also used : TenantId(io.spine.users.TenantId) TenantAwareOperation(io.spine.server.tenant.TenantAwareOperation) Test(org.junit.Test)

Example 12 with TenantId

use of io.spine.users.TenantId in project core-java by SpineEventEngine.

the class TenantRepositoryShould method cache_passed_value.

@Test
public void cache_passed_value() {
    final TenantId tenantId = newTenantUuid();
    repository.keep(tenantId);
    repository.keep(tenantId);
    verify(repository, times(1)).find(tenantId);
}
Also used : TenantId(io.spine.users.TenantId) Test(org.junit.Test)

Example 13 with TenantId

use of io.spine.users.TenantId in project core-java by SpineEventEngine.

the class TenantRepositoryShould method clear_cache.

@Test
public void clear_cache() {
    final TenantId tenantId = newTenantUuid();
    repository.keep(tenantId);
    repository.clearCache();
    assertFalse(repository.unCache(tenantId));
}
Also used : TenantId(io.spine.users.TenantId) Test(org.junit.Test)

Example 14 with TenantId

use of io.spine.users.TenantId in project core-java by SpineEventEngine.

the class TenantRepositoryShould method un_cache_values.

@Test
public void un_cache_values() {
    final TenantId tenantId = newTenantUuid();
    repository.keep(tenantId);
    assertTrue(repository.unCache(tenantId));
    assertFalse(repository.unCache(tenantId));
}
Also used : TenantId(io.spine.users.TenantId) Test(org.junit.Test)

Example 15 with TenantId

use of io.spine.users.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 = newTenantId(getClass());
    CurrentTenant.set(expected);
    final Optional<TenantId> currentTenant = CurrentTenant.get();
    assertTrue(currentTenant.isPresent());
    assertEquals(expected, currentTenant.get());
}
Also used : TenantId(io.spine.users.TenantId) Tests.newTenantId(io.spine.test.Tests.newTenantId) Test(org.junit.Test)

Aggregations

TenantId (io.spine.users.TenantId)24 Test (org.junit.Test)14 Command (io.spine.base.Command)6 TenantAwareOperation (io.spine.server.tenant.TenantAwareOperation)4 CommandId (io.spine.base.CommandId)3 ActorRequestFactory (io.spine.client.ActorRequestFactory)2 Subscription (io.spine.client.Subscription)2 Tests.newTenantId (io.spine.test.Tests.newTenantId)2 Nullable (javax.annotation.Nullable)2 Any (com.google.protobuf.Any)1 Message (com.google.protobuf.Message)1 ActorContext (io.spine.base.ActorContext)1 CommandContext (io.spine.base.CommandContext)1 Commands.getMessage (io.spine.base.Commands.getMessage)1 Version (io.spine.base.Version)1 StringChange (io.spine.change.StringChange)1 Query (io.spine.client.Query)1 QueryResponse (io.spine.client.QueryResponse)1 CommandMessage.createProjectMessage (io.spine.server.commandbus.Given.CommandMessage.createProjectMessage)1 EntityStateEnvelope (io.spine.server.entity.EntityStateEnvelope)1