use of io.spine.client.Target in project core-java by SpineEventEngine.
the class TopicValidator method isSupported.
@Override
protected Optional<RequestNotSupported<Topic>> isSupported(Topic request) {
final Target target = request.getTarget();
final boolean targetSupported = checkTargetSupported(target);
if (targetSupported) {
return Optional.absent();
}
return Optional.of(missingInRegistry(getTypeOf(target)));
}
use of io.spine.client.Target in project core-java by SpineEventEngine.
the class StandShould method trigger_each_subscription_callback_once_for_multiple_subscriptions.
@SuppressWarnings("MethodWithMultipleLoops")
@Test
public void trigger_each_subscription_callback_once_for_multiple_subscriptions() {
final Stand stand = prepareStandWithAggregateRepo(mock(StandStorage.class));
final Target allCustomers = Targets.allOf(Customer.class);
final Set<MemoizeEntityUpdateCallback> callbacks = newHashSet();
final int totalCallbacks = 100;
for (int callbackIndex = 0; callbackIndex < totalCallbacks; callbackIndex++) {
final MemoizeEntityUpdateCallback callback = subscribeWithCallback(stand, allCustomers);
callbacks.add(callback);
}
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);
for (MemoizeEntityUpdateCallback callback : callbacks) {
assertEquals(packedState, callback.newEntityState);
verify(callback, times(1)).onStateChanged(any(EntityStateUpdate.class));
}
}
use of io.spine.client.Target in project core-java by SpineEventEngine.
the class StandShould method do_not_trigger_subscription_callbacks_in_case_of_another_type_criterion_mismatch.
@Test
public void do_not_trigger_subscription_callbacks_in_case_of_another_type_criterion_mismatch() {
final Stand stand = prepareStandWithAggregateRepo(mock(StandStorage.class));
final Target allProjects = Targets.allOf(Project.class);
final MemoizeEntityUpdateCallback callback = subscribeWithCallback(stand, allProjects);
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));
verify(callback, never()).onStateChanged(any(EntityStateUpdate.class));
}
use of io.spine.client.Target in project core-java by SpineEventEngine.
the class SubscriptionService method selectBoundedContext.
private BoundedContext selectBoundedContext(Subscription subscription) {
final Target target = subscription.getTopic().getTarget();
final BoundedContext context = selectBoundedContext(target);
return context;
}
use of io.spine.client.Target in project core-java by SpineEventEngine.
the class QueryValidator method isSupported.
@Override
protected Optional<RequestNotSupported<Query>> isSupported(Query request) {
final Target target = request.getTarget();
final boolean targetSupported = checkTargetSupported(target);
if (targetSupported) {
return Optional.absent();
}
return Optional.of(missingInRegistry(getTypeOf(target)));
}
Aggregations