use of io.spine.client.ActorRequestFactory in project core-java by SpineEventEngine.
the class ActorRequestFactoryShould method create_instance_by_user.
@Test
public void create_instance_by_user() {
final int currentOffset = ZoneOffsets.getDefault().getAmountSeconds();
final ActorRequestFactory aFactory = builder().setActor(actor).build();
assertEquals(actor, aFactory.getActor());
assertEquals(currentOffset, aFactory.getZoneOffset().getAmountSeconds());
}
use of io.spine.client.ActorRequestFactory in project core-java by SpineEventEngine.
the class AbstractCommandRouter method commandFactory.
/**
* Creates a {@code CommandFactory} using the {@linkplain io.spine.users.UserId actor},
* {@linkplain io.spine.users.TenantId tenant ID} and {@linkplain io.spine.time.ZoneOffset
* zone offset} from the given command context.
*/
private static CommandFactory commandFactory(CommandContext sourceContext) {
final ActorContext actorContext = sourceContext.getActorContext();
final ActorRequestFactory factory = ActorRequestFactory.newBuilder().setActor(actorContext.getActor()).setTenantId(actorContext.getTenantId()).setZoneOffset(actorContext.getZoneOffset()).build();
return factory.command();
}
use of io.spine.client.ActorRequestFactory 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 = newTenantUuid();
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.client.ActorRequestFactory 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.client.ActorRequestFactory in project core-java by SpineEventEngine.
the class TypeUrlShould method obtain_type_of_command.
@Test
public void obtain_type_of_command() {
final ActorRequestFactory factory = TestActorRequestFactory.newInstance(TypeUrlShould.class);
final StringValue message = Wrapper.forString(newUuid());
final Command command = factory.command().create(message);
final TypeUrl typeUrl = TypeUrl.ofCommand(command);
assertIsStringValueUrl(typeUrl);
}
Aggregations