Search in sources :

Example 1 with Stand

use of io.spine.server.stand.Stand in project core-java by SpineEventEngine.

the class QueryServiceShould method dispatch_queries_to_proper_bounded_context.

@Test
public void dispatch_queries_to_proper_bounded_context() {
    final Query query = Given.AQuery.readAllProjects();
    final Stand stand = projectsContext.getStand();
    service.read(query, responseObserver);
    checkOkResponse(responseObserver);
    verify(stand).execute(query, responseObserver);
    verify(customersContext.getStand(), never()).execute(query, responseObserver);
}
Also used : Stand(io.spine.server.stand.Stand) Query(io.spine.client.Query) Test(org.junit.Test)

Example 2 with Stand

use of io.spine.server.stand.Stand in project core-java by SpineEventEngine.

the class QueryService method read.

@SuppressWarnings("MethodDoesntCallSuperMethod")
// as we override default implementation with `unimplemented` status.
@Override
public void read(Query query, StreamObserver<QueryResponse> responseObserver) {
    log().debug("Incoming query: {}", query);
    final TypeUrl type = Queries.typeOf(query);
    final BoundedContext boundedContext = typeToContextMap.get(type);
    final Stand stand = boundedContext.getStand();
    try {
        stand.execute(query, responseObserver);
    } catch (@SuppressWarnings("OverlyBroadCatchBlock") Exception e) {
        log().error("Error processing query", e);
        responseObserver.onError(e);
    }
}
Also used : Stand(io.spine.server.stand.Stand) TypeUrl(io.spine.type.TypeUrl)

Example 3 with Stand

use of io.spine.server.stand.Stand in project core-java by SpineEventEngine.

the class SubscriptionService method cancel.

@Override
public void cancel(Subscription subscription, StreamObserver<Response> responseObserver) {
    log().debug("Incoming cancel request for the subscription topic: {}", subscription);
    final BoundedContext boundedContext = selectBoundedContext(subscription);
    try {
        final Stand stand = boundedContext.getStand();
        stand.cancel(subscription, responseObserver);
    } catch (@SuppressWarnings("OverlyBroadCatchBlock") Exception e) {
        log().error("Error processing cancel subscription request", e);
        responseObserver.onError(e);
    }
}
Also used : Stand(io.spine.server.stand.Stand)

Example 4 with Stand

use of io.spine.server.stand.Stand in project core-java by SpineEventEngine.

the class SubscriptionService method subscribe.

@Override
public void subscribe(Topic topic, StreamObserver<Subscription> responseObserver) {
    log().debug("Creating the subscription to a topic: {}", topic);
    try {
        final Target target = topic.getTarget();
        final BoundedContext boundedContext = selectBoundedContext(target);
        final Stand stand = boundedContext.getStand();
        stand.subscribe(topic, responseObserver);
    } catch (@SuppressWarnings("OverlyBroadCatchBlock") Exception e) {
        log().error("Error processing subscription request", e);
        responseObserver.onError(e);
    }
}
Also used : Stand(io.spine.server.stand.Stand) Target(io.spine.client.Target)

Example 5 with Stand

use of io.spine.server.stand.Stand in project core-java by SpineEventEngine.

the class SubscriptionServiceShould method setupBoundedContextWithProjectAggregateRepo.

private static BoundedContext setupBoundedContextWithProjectAggregateRepo() {
    final BoundedContext boundedContext = BoundedContext.newBuilder().setStand(Stand.newBuilder()).build();
    final Stand stand = boundedContext.getStand();
    stand.registerTypeSupplier(new Given.ProjectAggregateRepository());
    return boundedContext;
}
Also used : Stand(io.spine.server.stand.Stand)

Aggregations

Stand (io.spine.server.stand.Stand)7 Test (org.junit.Test)2 EntityStateUpdate (io.spine.client.EntityStateUpdate)1 Query (io.spine.client.Query)1 SubscriptionUpdate (io.spine.client.SubscriptionUpdate)1 Target (io.spine.client.Target)1 BoundedContext (io.spine.server.BoundedContext)1 AnotherProjectAggregateRepository (io.spine.server.bc.given.BoundedContextTestEnv.AnotherProjectAggregateRepository)1 ProjectAggregateRepository (io.spine.server.bc.given.BoundedContextTestEnv.ProjectAggregateRepository)1 ProjectReportRepository (io.spine.server.bc.given.BoundedContextTestEnv.ProjectReportRepository)1 SecretProjectRepository (io.spine.server.bc.given.BoundedContextTestEnv.SecretProjectRepository)1 Repository (io.spine.server.entity.Repository)1 TypeUrl (io.spine.type.TypeUrl)1