CommentResource { @POST public Comment createComment(@Auth AccessToken token, @Valid Comment comment){ comment.setCreationTime(DateTime.now()); comment.setUpdateTime(DateTime.now()); Long id = commentDao.createComment(comment); comment.setId(id); return comment; } CommentResource(CommentDAO commentDao); @GET @Path("/{id}") Comment commentById(@PathParam("id") Long id); @POST Comment createComment(@Auth AccessToken token, @Valid Comment comment); @POST @Path("/update") Response updateComment(@Auth AccessToken token, @Valid Comment comment); @POST @Path("/{id}/delete") Response deleteComment(@Auth AccessToken token, @PathParam("id") Long id);  }
@Test public void testCreateComment() throws Exception { Response res = rule.getJerseyTest() .target("/comment") .request(MediaType.APPLICATION_JSON_TYPE) .header("Authorization", "Bearer test") .post(Entity.json(comment)); @SuppressWarnings("rawtypes") LinkedHashMap read = mapper.readValue(res.readEntity(String.class), LinkedHashMap.class); assertThat(res.getStatusInfo().getStatusCode()).isEqualTo(200); assertThat(read.get("id")).isEqualTo(1); verify(commentDao).createComment(any()); }