コード例 #1
0
  @Test
  public void testCreateWithErrors() throws Exception {
    MvcResult result =
        mvc.perform(
                post(BASE_URI, ObjectId.get().toHexString())
                    .principal(MockUser.mock())
                    .contentType(MediaType.APPLICATION_JSON)
                    .content(parser.encode(new CommentBody())))
            .andReturn();

    mvc.perform(asyncDispatch(result)).andExpect(status().isBadRequest());
  }
コード例 #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!!")));
 }
コード例 #3
0
 @Test
 public void testCreateComment() throws Exception {
   MvcResult action =
       mvc.perform(
               post(BASE_URI, ObjectId.get().toHexString())
                   .principal(MockUser.mock())
                   .contentType(MediaType.APPLICATION_JSON)
                   .accept(MediaType.APPLICATION_JSON)
                   .content(parser.encode(contentBody("#foos"))))
           .andExpect(request().asyncStarted())
           .andExpect(request().asyncResult(instanceOf(ResponseEntity.class)))
           .andReturn();
   mvc.perform(asyncDispatch(action))
       .andExpect(status().isCreated())
       .andExpect(content().contentType(MediaType.APPLICATION_JSON))
       .andExpect(jsonPath("$.id").isString())
       .andExpect(jsonPath("$.inn").isString())
       .andExpect(jsonPath("$.content", is("#foos")))
       .andExpect(jsonPath("$.author", is(1)));
 }