use of io.spine.core.TenantId in project core-java by SpineEventEngine.
the class TenantRepositoryShould method clear_cache.
@Test
public void clear_cache() {
final TenantId tenantId = newUuid();
repository.keep(tenantId);
repository.clearCache();
assertFalse(repository.unCache(tenantId));
}
use of io.spine.core.TenantId in project core-java by SpineEventEngine.
the class TenantRepositoryShould method un_cache_values.
@Test
public void un_cache_values() {
final TenantId tenantId = newUuid();
repository.keep(tenantId);
assertTrue(repository.unCache(tenantId));
assertFalse(repository.unCache(tenantId));
}
use of io.spine.core.TenantId in project core-java by SpineEventEngine.
the class MultiTenantStandShould method not_allow_reading_aggregate_records_for_another_tenant.
@Test
public void not_allow_reading_aggregate_records_for_another_tenant() {
final Stand stand = doCheckReadingCustomersById(15);
final TenantId anotherTenant = newUuid();
final ActorRequestFactory requestFactory = createRequestFactory(anotherTenant);
final Query readAllCustomers = requestFactory.query().all(Customer.class);
final MemoizeQueryResponseObserver responseObserver = new MemoizeQueryResponseObserver();
stand.execute(readAllCustomers, responseObserver);
final QueryResponse response = responseObserver.getResponseHandled();
assertTrue(Responses.isOk(response.getResponse()));
assertEquals(0, response.getMessagesCount());
}
use of io.spine.core.TenantId in project core-java by SpineEventEngine.
the class MultiTenantStandShould method not_trigger_updates_of_aggregate_records_for_another_tenant_subscriptions.
@Test
public void not_trigger_updates_of_aggregate_records_for_another_tenant_subscriptions() {
final StandStorage standStorage = InMemoryStorageFactory.newInstance(newName(getClass().getSimpleName()), isMultitenant()).createStandStorage();
final Stand stand = prepareStandWithAggregateRepo(standStorage);
// --- Default Tenant
final ActorRequestFactory requestFactory = getRequestFactory();
final MemoizeEntityUpdateCallback defaultTenantCallback = subscribeToAllOf(stand, requestFactory, Customer.class);
// --- Another Tenant
final TenantId anotherTenant = newUuid();
final ActorRequestFactory anotherFactory = createRequestFactory(anotherTenant);
final MemoizeEntityUpdateCallback anotherCallback = subscribeToAllOf(stand, anotherFactory, Customer.class);
// Trigger updates in Default Tenant.
final Map.Entry<CustomerId, Customer> sampleData = fillSampleCustomers(1).entrySet().iterator().next();
final CustomerId customerId = sampleData.getKey();
final Customer customer = sampleData.getValue();
final Version stateVersion = GivenVersion.withNumber(1);
stand.update(asEnvelope(customerId, customer, stateVersion));
final Any packedState = AnyPacker.pack(customer);
// Verify that Default Tenant callback has got the update.
assertEquals(packedState, defaultTenantCallback.getNewEntityState());
// And Another Tenant callback has not been called.
assertEquals(null, anotherCallback.getNewEntityState());
}
use of io.spine.core.TenantId in project core-java by SpineEventEngine.
the class EntityMessageEndpoint method handle.
/**
* Handles the message processing.
*
* @return the result of the message processing
*/
public final R handle() {
final TenantId tenantId = envelope().getTenantId();
final TenantAwareFunction0<R> operation = new Operation(tenantId);
final R result = operation.execute();
return result;
}
Aggregations