Search in sources :

Example 6 with ActorRequestFactory

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.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());
}
Also used : TenantId(io.spine.core.TenantId) Customer(io.spine.test.commandservice.customer.Customer) GivenVersion(io.spine.core.given.GivenVersion) Version(io.spine.core.Version) ActorRequestFactory(io.spine.client.ActorRequestFactory) CustomerId(io.spine.test.commandservice.customer.CustomerId) Map(java.util.Map) Any(com.google.protobuf.Any) Test(org.junit.Test)

Example 7 with ActorRequestFactory

use of io.spine.client.ActorRequestFactory in project core-java by SpineEventEngine.

the class CommandsShould method obtain_type_url_of_command.

@Test
public void obtain_type_url_of_command() {
    final ActorRequestFactory factory = TestActorRequestFactory.newInstance(CommandsShould.class);
    final StringValue message = toMessage(Identifier.newUuid());
    final Command command = factory.command().create(message);
    final TypeUrl typeUrl = CommandEnvelope.of(command).getTypeName().toUrl();
    assertEquals(TypeUrl.of(StringValue.class), typeUrl);
}
Also used : ActorRequestFactory(io.spine.client.ActorRequestFactory) TestActorRequestFactory(io.spine.client.TestActorRequestFactory) TypeUrl(io.spine.type.TypeUrl) StringValue(com.google.protobuf.StringValue) Test(org.junit.Test)

Aggregations

ActorRequestFactory (io.spine.client.ActorRequestFactory)7 Test (org.junit.Test)6 StringValue (com.google.protobuf.StringValue)2 TenantId (io.spine.core.TenantId)2 Any (com.google.protobuf.Any)1 Command (io.spine.base.Command)1 Query (io.spine.client.Query)1 QueryResponse (io.spine.client.QueryResponse)1 TestActorRequestFactory (io.spine.client.TestActorRequestFactory)1 ActorContext (io.spine.core.ActorContext)1 Version (io.spine.core.Version)1 GivenVersion (io.spine.core.given.GivenVersion)1 TestActorRequestFactory (io.spine.test.TestActorRequestFactory)1 Customer (io.spine.test.commandservice.customer.Customer)1 CustomerId (io.spine.test.commandservice.customer.CustomerId)1 TypeUrl (io.spine.type.TypeUrl)1 TypeUrl.composeTypeUrl (io.spine.type.TypeUrl.composeTypeUrl)1 Map (java.util.Map)1