QueryInfo queryInfo = client.execute(prepareGet().setUri(location).build(), createJsonResponseHandler(jsonCodec(QueryInfo.class)));
TaskInfo taskInfo = queryInfo.getOutputStage().getTasks().get(0);
URI outputLocation = uriFor("/v1/task/" + taskInfo.getTaskId() + "/results/out");
long sequenceId = 0;
PagesResponse response = client.execute(
prepareGet().setUri(uriBuilderFrom(outputLocation).appendPath(String.valueOf(sequenceId)).build()).build(),
new PageResponseHandler(createTestingBlockEncodingManager()));
List<Page> pages = response.getPages();
assertEquals(countPositions(pages), 220);
assertQueryStatus(location, QueryState.RUNNING);
sequenceId += pages.size();
response = client.execute(
prepareGet().setUri(uriBuilderFrom(outputLocation).appendPath(String.valueOf(sequenceId)).build()).build(),
new PageResponseHandler(createTestingBlockEncodingManager()));
pages = response.getPages();
assertEquals(countPositions(pages), 44 + 48);
sequenceId += pages.size();
response = client.execute(
prepareGet().setUri(uriBuilderFrom(outputLocation).appendPath(String.valueOf(sequenceId)).build()).build(),
new PageResponseHandler(createTestingBlockEncodingManager()));
pages = response.getPages();
assertEquals(countPositions(pages), 0);
assertQueryStatus(location, QueryState.FINISHED);
// cancel the query