use of io.spine.users.TenantId in project core-java by SpineEventEngine.
the class Stand method post.
/**
* Posts the state of an {@link VersionableEntity} to this {@link Stand}.
*
* @param entity the entity which state should be delivered to the {@code Stand}
* @param commandContext the context of the command, which triggered the entity state update.
*/
public void post(final VersionableEntity entity, CommandContext commandContext) {
final TenantId tenantId = commandContext.getActorContext().getTenantId();
final EntityStateEnvelope envelope = EntityStateEnvelope.of(entity, tenantId);
delivery.deliver(envelope);
}
use of io.spine.users.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.getInstance(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 = newTenantUuid();
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 = Tests.newVersionWithNumber(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.users.TenantId in project core-java by SpineEventEngine.
the class ProcessManagerRepositoryShould method testDispatchCommand.
private void testDispatchCommand(Message cmdMsg) throws InvocationTargetException {
final TenantId generatedTenantId = TenantId.newBuilder().setValue(newUuid()).build();
final Command cmd = TestActorRequestFactory.newInstance(ProcessManagerRepositoryShould.class, generatedTenantId).command().create(cmdMsg);
repository.dispatchCommand(CommandEnvelope.of(cmd));
assertTrue(TestProcessManager.processed(cmdMsg));
}
use of io.spine.users.TenantId in project core-java by SpineEventEngine.
the class CommandFactoryShould method set_tenant_ID_in_commands_when_created_with_tenant_ID.
@Test
public void set_tenant_ID_in_commands_when_created_with_tenant_ID() {
final TenantId tenantId = TenantId.newBuilder().setValue(getClass().getSimpleName()).build();
final ActorRequestFactory mtFactory = ActorRequestFactory.newBuilder().setTenantId(tenantId).setActor(getActor()).setZoneOffset(getZoneOffset()).build();
final Command command = mtFactory.command().create(StringValue.getDefaultInstance());
assertEquals(tenantId, command.getContext().getActorContext().getTenantId());
}
Aggregations