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());
}
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());
}
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;
}
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());
}
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}<{@link QueryResponse}>.
*
* @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();
}
Aggregations