QueryResource { @GET @Produces(MediaType.APPLICATION_JSON) public Response getAllQueries(@QueryParam("state") String state, @QueryParam("startTime") long startTime, @QueryParam("endTime") long endTime) { if (LOG.isDebugEnabled()) { LOG.debug("Client sent a get all queries request."); } Response response = null; try { initializeContext(); JerseyResourceDelegateContextKey<String> stateKey = JerseyResourceDelegateContextKey.valueOf(stateKeyName, String.class); if (state != null && !state.isEmpty()) { context.put(stateKey, state); } JerseyResourceDelegateContextKey<Long> startTimeKey = JerseyResourceDelegateContextKey.valueOf(startTimeKeyName, Long.class); if (startTime > 0) { context.put(startTimeKey, startTime); } JerseyResourceDelegateContextKey<Long> endTimeKey = JerseyResourceDelegateContextKey.valueOf(endTimeKeyName, Long.class); if (endTime > 0) { context.put(endTimeKey, endTime); } response = JerseyResourceDelegateUtil.runJerseyResourceDelegate( new GetAllQueriesDelegate(), application, context, LOG); } catch (Throwable e) { LOG.error(e.getMessage(), e); response = ResourcesUtil.createExceptionResponse(null, e.getMessage()); } return response; }  @GET @Produces(MediaType.APPLICATION_JSON) Response getAllQueries(@QueryParam("state") String state,
      @QueryParam("startTime") long startTime,
      @QueryParam("endTime") long endTime); @POST @Consumes(MediaType.APPLICATION_JSON) Response submitQuery(@HeaderParam(tajoSessionIdHeaderName) String sessionId,
      SubmitQueryRequest request); @GET @Path("{queryId}") @Produces(MediaType.APPLICATION_JSON) Response getQuery(@PathParam("queryId") String queryId, @QueryParam("print") String printType); @DELETE @Path("{queryId}") Response terminateQuery(@PathParam("queryId") String queryId); @Path("/{queryId}/result") QueryResultResource getQueryResult(@PathParam("queryId") String queryId);  }
@Test public void testGetAllQueries() throws Exception { String sessionId = generateNewSessionAndGetId(); SubmitQueryRequest queryRequest = createNewQueryRequest("select * from lineitem"); Response response = restClient.target(queriesURI) .request().header(tajoSessionIdHeaderName, sessionId) .post(Entity.entity(queryRequest, MediaType.APPLICATION_JSON)); assertNotNull(response); assertEquals(Status.CREATED.getStatusCode(), response.getStatus()); String locationHeader = response.getHeaderString("Location"); assertTrue(locationHeader != null && !locationHeader.isEmpty()); String queryId = locationHeader.lastIndexOf('/') >= 0? locationHeader.substring(locationHeader.lastIndexOf('/')+1):null; assertTrue(queryId != null && !queryId.isEmpty()); Map<String, List<StringMap>> queriesMap = restClient.target(queriesURI) .request().get(new GenericType<Map<String, List<StringMap>>>(Map.class)); assertNotNull(queriesMap); List<StringMap> queryInfoList = queriesMap.get("queries"); assertNotNull(queryInfoList); boolean assertQueryIdFound = false; for (StringMap queryInfo: queryInfoList) { if (queryId.equals(queryInfo.get("queryIdStr"))) { assertQueryIdFound = true; } } assertTrue(assertQueryIdFound); }