@Test @DisplayName("not trigger subscription callbacks in case of another type criterion mismatch") void notTriggerOnTypeMismatch() { CustomerAggregateRepository repository = new CustomerAggregateRepository(); StandTestProjectionRepository projectionRepository = new StandTestProjectionRepository(); Stand stand = createStand(repository, projectionRepository); Target allProjects = Targets.allOf(Project.class); MemoizeSubscriptionCallback callback = subscribeWithCallback(stand, allProjects); Customer customer = fillSampleCustomers(1) .iterator() .next(); CustomerId customerId = customer.getId(); int version = 1; CustomerAggregate entity = aggregateOfClass(CustomerAggregate.class) .withId(customerId) .withState(customer) .withVersion(version) .build(); stand.post(entity, repository.lifecycleOf(customerId)); assertEquals(0, callback.countAcceptedUpdates()); }
@VisibleForTesting void post(Entity<?, ?> entity, EntityLifecycle lifecycle) { Any id = Identifier.pack(entity.id()); Any state = AnyPacker.pack(entity.state()); EntityRecord record = EntityRecord .newBuilder() .setEntityId(id) .setState(state) .vBuild(); EntityRecordChange change = EntityRecordChange .newBuilder() .setNewValue(record) .vBuild(); MessageId origin = Identity.byString("Stand-received-entity-update"); lifecycle.onStateChanged(change, ImmutableSet.of(origin), Origin.getDefaultInstance()); }
Stand implements AutoCloseable { @VisibleForTesting void post(Entity<?, ?> entity, EntityLifecycle lifecycle) { Any id = Identifier.pack(entity.id()); Any state = AnyPacker.pack(entity.state()); EntityRecord record = EntityRecord .newBuilder() .setEntityId(id) .setState(state) .vBuild(); EntityRecordChange change = EntityRecordChange .newBuilder() .setNewValue(record) .vBuild(); MessageId origin = Identity.byString("Stand-received-entity-update"); lifecycle.onStateChanged(change, ImmutableSet.of(origin), Origin.getDefaultInstance()); } }
Stand implements AutoCloseable { @VisibleForTesting void post(Entity<?, ?> entity, EntityLifecycle lifecycle) { Any id = Identifier.pack(entity.id()); Any state = AnyPacker.pack(entity.state()); EntityRecord record = EntityRecord .newBuilder() .setEntityId(id) .setState(state) .vBuild(); EntityRecordChange change = EntityRecordChange .newBuilder() .setNewValue(record) .vBuild(); MessageId origin = Identity.byString("Stand-received-entity-update"); lifecycle.onStateChanged(change, ImmutableSet.of(origin), Origin.getDefaultInstance()); } private  Stand(Builder builder); }
Stand implements AutoCloseable { @VisibleForTesting void post(Entity<?, ?> entity, EntityLifecycle lifecycle) { Any id = Identifier.pack(entity.id()); Any state = AnyPacker.pack(entity.state()); EntityRecord record = EntityRecord .newBuilder() .setEntityId(id) .setState(state) .vBuild(); EntityRecordChange change = EntityRecordChange .newBuilder() .setNewValue(record) .vBuild(); MessageId origin = Identity.byString("Stand-received-entity-update"); lifecycle.onStateChanged(change, ImmutableSet.of(origin), Origin.getDefaultInstance()); } private  Stand(Builder builder); static Builder newBuilder(); @Internal @VisibleForTesting boolean isMultitenant(); void subscribe(Topic topic, StreamObserver<Subscription> responseObserver); void subscribe(Subscription subscription); void activate(Subscription subscription,
                         SubscriptionCallback callback,
                         StreamObserver<Response> responseObserver); void cancel(Subscription subscription, StreamObserver<Response> responseObserver); Listener<EventEnvelope> eventListener(); ImmutableSet<TypeUrl> exposedTypes(); ImmutableSet<TypeUrl> exposedEventTypes(); ImmutableSet<TypeUrl> exposedAggregateTypes(); void execute(Query query, StreamObserver<QueryResponse> responseObserver); void registerTypeSupplier(Repository<?, ?> repository); @Override void close(); }
Stand implements AutoCloseable { @VisibleForTesting void post(Entity<?, ?> entity, EntityLifecycle lifecycle) { Any id = Identifier.pack(entity.id()); Any state = AnyPacker.pack(entity.state()); EntityRecord record = EntityRecord .newBuilder() .setEntityId(id) .setState(state) .vBuild(); EntityRecordChange change = EntityRecordChange .newBuilder() .setNewValue(record) .vBuild(); MessageId origin = Identity.byString("Stand-received-entity-update"); lifecycle.onStateChanged(change, ImmutableSet.of(origin), Origin.getDefaultInstance()); } private  Stand(Builder builder); static Builder newBuilder(); @Internal @VisibleForTesting boolean isMultitenant(); void subscribe(Topic topic, StreamObserver<Subscription> responseObserver); void subscribe(Subscription subscription); void activate(Subscription subscription,
                         SubscriptionCallback callback,
                         StreamObserver<Response> responseObserver); void cancel(Subscription subscription, StreamObserver<Response> responseObserver); Listener<EventEnvelope> eventListener(); ImmutableSet<TypeUrl> exposedTypes(); ImmutableSet<TypeUrl> exposedEventTypes(); ImmutableSet<TypeUrl> exposedAggregateTypes(); void execute(Query query, StreamObserver<QueryResponse> responseObserver); void registerTypeSupplier(Repository<?, ?> repository); @Override void close();  }