AsyncResource { @POST @Timed @ApiOperation("getResponsePost") public Response getResponsePost(final AsyncDataToken dataToken) { return Response.ok(getData(dataToken)) .build(); } @Inject  AsyncResource(CacheManager cacheManager); @GET @Path("/{action}/{id}") @Timed @ApiOperation("getResponse") Response getResponse(@PathParam("action") final String action, @NotNull @PathParam("id") final String id); @POST @Timed @ApiOperation("getResponsePost") Response getResponsePost(final AsyncDataToken dataToken);  }
@Test public void testGetResponsePost() throws Exception { GroupRequest groupRequest = new GroupRequest(); groupRequest.setTable(TestUtils.TEST_TABLE_NAME); groupRequest.setNesting(Arrays.asList("os", "device", "version")); Map<String, Object> expectedResponse = new LinkedHashMap<String, Object>(); final Map<String, Object> nexusResponse = new LinkedHashMap<String, Object>() {{ put("1", 2); put("2", 2); put("3", 1); }}; final Map<String, Object> galaxyResponse = new LinkedHashMap<String, Object>() {{ put("2", 1); put("3", 1); }}; expectedResponse.put("android", new LinkedHashMap<String, Object>() {{ put("nexus", nexusResponse); put("galaxy", galaxyResponse); }}); final Map<String, Object> nexusResponse2 = new LinkedHashMap<String, Object>() {{ put("2", 1); }}; final Map<String, Object> iPadResponse = new LinkedHashMap<String, Object>() {{ put("2", 2); }}; final Map<String, Object> iPhoneResponse = new LinkedHashMap<String, Object>() {{ put("1", 1); }}; expectedResponse.put("ios", new LinkedHashMap<String, Object>() {{ put("nexus", nexusResponse2); put("ipad", iPadResponse); put("iphone", iPhoneResponse); }}); AsyncDataToken dataToken = getQueryExecutor().executeAsync(groupRequest); await().pollDelay(5000, TimeUnit.MILLISECONDS).until(() -> true); Entity<AsyncDataToken> asyncDataTokenEntity = Entity.json(dataToken); GroupResponse response = resources.client() .target("/v1/async") .request() .post(asyncDataTokenEntity, GroupResponse.class); assertEquals(expectedResponse, response.getResult()); }