Search in sources :

Example 1 with QueryResponse

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

the class QueryServiceShould method checkFailureResponse.

private static void checkFailureResponse(TestQueryResponseObserver responseObserver) {
    final QueryResponse responseHandled = responseObserver.getResponseHandled();
    assertNull(responseHandled);
    assertFalse(responseObserver.isCompleted());
    assertNotNull(responseObserver.getThrowable());
}
Also used : QueryResponse(io.spine.client.QueryResponse)

Example 2 with QueryResponse

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

the class QueryServiceShould method checkOkResponse.

private static void checkOkResponse(MemoizingObserver<QueryResponse> responseObserver) {
    final QueryResponse responseHandled = responseObserver.firstResponse();
    assertNotNull(responseHandled);
    assertEquals(Responses.ok(), responseHandled.getResponse());
    assertTrue(responseObserver.isCompleted());
    assertNull(responseObserver.getError());
}
Also used : QueryResponse(io.spine.client.QueryResponse)

Example 3 with QueryResponse

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

the class StandShould method checkAndGetMessageList.

private static List<Any> checkAndGetMessageList(MemoizeQueryResponseObserver responseObserver) {
    assertTrue("Query has not completed successfully", responseObserver.isCompleted);
    assertNull("Throwable has been caught upon query execution", responseObserver.throwable);
    final QueryResponse response = responseObserver.responseHandled;
    assertEquals("Query response is not OK", Responses.ok(), response.getResponse());
    assertNotNull("Query response must not be null", response);
    final List<Any> messageList = response.getMessagesList();
    assertNotNull("Query response has null message list", messageList);
    return messageList;
}
Also used : QueryResponse(io.spine.client.QueryResponse) Any(com.google.protobuf.Any)

Example 4 with QueryResponse

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

the class QueryServiceShould method checkOkResponse.

private static void checkOkResponse(TestQueryResponseObserver responseObserver) {
    final QueryResponse responseHandled = responseObserver.getResponseHandled();
    assertNotNull(responseHandled);
    assertEquals(Responses.ok(), responseHandled.getResponse());
    assertTrue(responseObserver.isCompleted());
    assertNull(responseObserver.getThrowable());
}
Also used : QueryResponse(io.spine.client.QueryResponse)

Example 5 with QueryResponse

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

the class Stand method execute.

/**
 * Reads a particular set of items from the read-side of the application and
 * feed the result into an instance.
 *
 * <p>{@link Query} defines the query target and the expected detail level for response.
 *
 * <p>The query results are fed to an instance
 * of {@link StreamObserver}&lt;{@link QueryResponse}&gt;.
 *
 * @param query            an instance of query
 * @param responseObserver an observer to feed the query results to.
 */
public void execute(final Query query, final StreamObserver<QueryResponse> responseObserver) {
    queryValidator.validate(query, responseObserver);
    final TypeUrl type = Queries.typeOf(query);
    final QueryProcessor queryProcessor = processorFor(type);
    final QueryOperation op = new QueryOperation(query) {

        @Override
        public void run() {
            final ImmutableCollection<Any> readResult = queryProcessor.process(query());
            final QueryResponse response = QueryResponse.newBuilder().addAllMessages(readResult).setResponse(Responses.ok()).build();
            responseObserver.onNext(response);
            responseObserver.onCompleted();
        }
    };
    op.execute();
}
Also used : QueryResponse(io.spine.client.QueryResponse) TypeUrl(io.spine.type.TypeUrl) TypeConverter.toAny(io.spine.protobuf.TypeConverter.toAny) Any(com.google.protobuf.Any) QueryOperation(io.spine.server.tenant.QueryOperation)

Aggregations

QueryResponse (io.spine.client.QueryResponse)10 Any (com.google.protobuf.Any)6 Query (io.spine.client.Query)4 Customer (io.spine.test.commandservice.customer.Customer)4 Version (io.spine.core.Version)3 GivenVersion (io.spine.core.given.GivenVersion)3 Test (org.junit.Test)3 TenantAwareTest (io.spine.server.tenant.TenantAwareTest)2 Sets.newHashSet (com.google.common.collect.Sets.newHashSet)1 Descriptors (com.google.protobuf.Descriptors)1 FieldMask (com.google.protobuf.FieldMask)1 ActorRequestFactory (io.spine.client.ActorRequestFactory)1 TenantId (io.spine.core.TenantId)1 TypeConverter.toAny (io.spine.protobuf.TypeConverter.toAny)1 QueryOperation (io.spine.server.tenant.QueryOperation)1 CustomerId (io.spine.test.commandservice.customer.CustomerId)1 TypeUrl (io.spine.type.TypeUrl)1 HashSet (java.util.HashSet)1