QueryResource { @POST @Consumes(APPLICATION_JSON) @Produces(APPLICATION_JSON) public List<QueryResult> query(List<Query> queries) { long queryId = queryCounter.incrementAndGet(); List<QueryResult> results = queries.stream().flatMap(q -> { LOG.info( "Processing query #{} with sql = \"{}\" and parameters = [{}]", queryId, q.getSql(), q.getParameters().stream().map(Parameter::toString).collect(Collectors.joining(", ")) ); return queryProcessor.process(q).stream(); }).collect(Collectors.toList()); String queryStatus = results.stream() .map(QueryResource::getQueryStatus) .collect(Collectors.joining("; ")); LOG.debug("Query #{} results = [{}]", queryId, queryStatus); LOG.trace("Query #{} results raw data = {}", results); return results; } @Autowired  QueryResource(QueryProcessor queryProcessor); @POST @Consumes(APPLICATION_JSON) @Produces(APPLICATION_JSON) List<QueryResult> query(List<Query> queries);  }
@Test public void testExecuteQuery() throws Exception { Query query = new Query(); query.setSql(sql); List<Query> queries = new ArrayList<>(); queries.add(query); Response<Collection<QueryResult>> response = getApi().query(queries).execute(); assertThat(response.isSuccessful(), is(true)); List<QueryResult> queryResults = new ArrayList<>(response.body()); assertThat(queryResults, hasSize(1)); QueryResult queryResult = queryResults.get(0); assertThat(queryResult.getStatus(), equalTo(QueryStatus.SUCCESS)); assertThat(queryResult.getCount(), equalTo(1)); assertThat(queryResult.getData().getRows(), hasSize(1)); }