DocumentResource { @POST @Consumes(MediaType.APPLICATION_JSON) @Timed @ApiOperation("Save Document") public Response saveDocument(@PathParam("table") String table, @Valid final Document document) { String tableName = tableTranslator.getTable(table, document); if(tableName != null) { queryStore.save(tableName, document); } if(tableName != null && !table.equals(tableName)) { queryStore.save(table, document); } return Response.created(URI.create("/" + document.getId())) .build(); } @Inject  DocumentResource(QueryStore queryStore, TableTranslator tableTranslator); @POST @Consumes(MediaType.APPLICATION_JSON) @Timed @ApiOperation("Save Document") Response saveDocument(@PathParam("table") String table, @Valid final Document document); @POST @Path("/bulk") @Consumes(MediaType.APPLICATION_JSON) @Timed @ApiOperation("Save list of documents") Response saveDocuments(@PathParam("table") String table, @Valid final List<Document> documents); @GET @Path("/{id}") @Timed @ApiOperation("Get Document") Response getDocument(@PathParam("table") final String table, @PathParam("id") @NotNull final String id); @GET @Timed @ApiOperation("Get Documents") Response getDocuments(@PathParam("table") final String table, @QueryParam("id") @NotNull final List<String> ids);  }
@Test public void testSaveDocument() throws Exception { String id = UUID.randomUUID() .toString(); Document document = new Document(id, System.currentTimeMillis(), getMapper().getNodeFactory() .objectNode() .put("hello", "world")); Entity<Document> documentEntity = Entity.json(document); resources.client() .target("/v1/document/" + TestUtils.TEST_TABLE_NAME) .request() .post(documentEntity); getElasticsearchConnection().refresh(ElasticsearchUtils.getIndices(TestUtils.TEST_TABLE_NAME)); Document response = getQueryStore().get(TestUtils.TEST_TABLE_NAME, id); compare(document, response); }