DocumentResource { @POST public Response saveDocument(@PathParam("table") final String table, @Valid final Document document) { try { queryStore.save(table, document); } catch (QueryStoreException ex) { logger.error("Save error : ", ex); switch (ex.getErrorCode()) { case NO_SUCH_TABLE: case INVALID_REQUEST: return Response.status(Response.Status.BAD_REQUEST) .entity(Collections.singletonMap("error", ex.getErrorCode())) .build(); case DOCUMENT_SAVE_ERROR: default: return Response.serverError() .entity(Collections.singletonMap("error", ex.getErrorCode())) .build(); } } return Response.created(URI.create("/" + document.getId())).build(); } DocumentResource(QueryStore queryStore); @POST Response saveDocument(@PathParam("table") final String table, @Valid final Document document); @POST @Path("/bulk") Response saveDocuments(@PathParam("table") final String table, @Valid final List<Document> document); @GET @Path("/{id}") Response getDocument(@PathParam("table") final String table, @PathParam("id") @NotNull final String id); @GET 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(), factory.objectNode().put("hello", "world")); client().resource("/v1/document/" + TestUtils.TEST_TABLE_NAME).type(MediaType.APPLICATION_JSON_TYPE).post(document); Document response = queryStore.get(TestUtils.TEST_TABLE_NAME, id); compare(document, response); }