Search in sources :

Example 16 with Customer

use of io.spine.test.commandservice.customer.Customer in project core-java by SpineEventEngine.

the class StandShould method getDuplicateCostumerStreamObserver.

private static MemoizeQueryResponseObserver getDuplicateCostumerStreamObserver() {
    return new MemoizeQueryResponseObserver() {

        @Override
        public void onNext(QueryResponse value) {
            super.onNext(value);
            final List<Any> messages = value.getMessagesList();
            assertFalse(messages.isEmpty());
            final Customer customer = unpack(messages.get(0));
            final Customer sampleCustomer = getSampleCustomer();
            assertEquals(sampleCustomer.getName(), customer.getName());
            assertEquals(sampleCustomer.getNicknamesList(), customer.getNicknamesList());
            assertTrue(customer.hasId());
        }
    };
}
Also used : Customer(io.spine.test.commandservice.customer.Customer) QueryResponse(io.spine.client.QueryResponse) Any(com.google.protobuf.Any)

Example 17 with Customer

use of io.spine.test.commandservice.customer.Customer in project core-java by SpineEventEngine.

the class StandShould method trigger_subscription_callback_upon_update_of_aggregate.

@Test
public void trigger_subscription_callback_upon_update_of_aggregate() {
    final Stand stand = prepareStandWithAggregateRepo(mock(StandStorage.class));
    final Topic allCustomers = requestFactory.topic().allOf(Customer.class);
    final MemoizeEntityUpdateCallback memoizeCallback = new MemoizeEntityUpdateCallback();
    subscribeAndActivate(stand, allCustomers, memoizeCallback);
    assertNull(memoizeCallback.newEntityState);
    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);
    assertEquals(packedState, memoizeCallback.newEntityState);
}
Also used : Customer(io.spine.test.commandservice.customer.Customer) GivenVersion(io.spine.core.given.GivenVersion) Version(io.spine.core.Version) CustomerId(io.spine.test.commandservice.customer.CustomerId) Topic(io.spine.client.Topic) Map(java.util.Map) Maps.newHashMap(com.google.common.collect.Maps.newHashMap) Any(com.google.protobuf.Any) Test(org.junit.Test) TenantAwareTest(io.spine.server.tenant.TenantAwareTest)

Aggregations

Customer (io.spine.test.commandservice.customer.Customer)17 Version (io.spine.core.Version)13 GivenVersion (io.spine.core.given.GivenVersion)13 CustomerId (io.spine.test.commandservice.customer.CustomerId)13 Any (com.google.protobuf.Any)11 Test (org.junit.Test)10 TenantAwareTest (io.spine.server.tenant.TenantAwareTest)9 Query (io.spine.client.Query)6 Map (java.util.Map)6 Maps.newHashMap (com.google.common.collect.Maps.newHashMap)5 QueryResponse (io.spine.client.QueryResponse)4 EntityStateUpdate (io.spine.client.EntityStateUpdate)3 Topic (io.spine.client.Topic)3 FieldMask (com.google.protobuf.FieldMask)2 Target (io.spine.client.Target)2 BoundedContext (io.spine.server.BoundedContext)2 EntityRecord (io.spine.server.entity.EntityRecord)2 TypeUrl (io.spine.type.TypeUrl)2 ImmutableList (com.google.common.collect.ImmutableList)1 Sets.newHashSet (com.google.common.collect.Sets.newHashSet)1