DocumentResource { @POST @Path("/bulk") public Response saveDocuments(@PathParam("table") final String table, @Valid final List<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("/" + table)).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 testSaveDocuments() throws Exception { List<Document> documents = new ArrayList<Document>(); String id1 = UUID.randomUUID().toString(); Document document1 = new Document(id1, System.currentTimeMillis(), factory.objectNode().put("D", "data")); String id2 = UUID.randomUUID().toString(); Document document2 = new Document(id2, System.currentTimeMillis(), factory.objectNode().put("D", "data")); documents.add(document1); documents.add(document2); client().resource(String.format("/v1/document/%s/bulk", TestUtils.TEST_TABLE_NAME)).type(MediaType.APPLICATION_JSON_TYPE).post(documents); compare(document1, queryStore.get(TestUtils.TEST_TABLE_NAME, id1)); compare(document2, queryStore.get(TestUtils.TEST_TABLE_NAME, id2)); }