コード例 #1
0
 @Test
 public void testDeleteOne() throws Exception {
   MvcResult deleteComment =
       mvc.perform(
               delete("/inns/{innId}/comments/{comment}", comment.getInn(), comment.getId())
                   .principal(MockUser.mock()))
           .andExpect(request().asyncStarted())
           .andReturn();
   mvc.perform(asyncDispatch(deleteComment)).andExpect(status().isNoContent());
   assertThat(
       "Object must not exist after deletion",
       repo.findOne(comment.getId()),
       is(nullValue(Comment.class)));
 }
コード例 #2
0
 @Test
 public void testEditComment() throws Exception {
   MvcResult editAction =
       mvc.perform(
               put("/inns/{innId}/comments/{comment}", comment.getInn(), comment.getId())
                   .principal(MockUser.mock())
                   .contentType(MediaType.APPLICATION_JSON)
                   .content(parser.encode(contentBody("The pool is awesome, you should try it!!")))
                   .accept(MediaType.APPLICATION_JSON))
           .andExpect(request().asyncStarted())
           .andExpect(request().asyncResult(instanceOf(ResponseEntity.class)))
           .andReturn();
   mvc.perform(asyncDispatch(editAction))
       .andExpect(status().isOk())
       .andExpect(content().contentType(MediaType.APPLICATION_JSON))
       .andExpect(jsonPath("$.id").isString())
       .andExpect(jsonPath("$.content", is("The pool is awesome, you should try it!!")));
 }