Ejemplo n.º 1
0
  @Test
  public void testCreate() throws Exception {
    UserMeal created = getCreated();
    ResultActions action =
        mockMvc.perform(
            post(REST_URL)
                .contentType(MediaType.APPLICATION_JSON)
                .content(JsonUtil.writeValue(created))
                .with(userHttpBasic(ADMIN)));

    UserMeal returned = MATCHER.fromJsonAction(action);
    created.setId(returned.getId());

    MATCHER.assertEquals(created, returned);
    MATCHER.assertCollectionEquals(
        Arrays.asList(ADMIN_MEAL2, created, ADMIN_MEAL), service.getAll(ADMIN_ID));
  }
Ejemplo n.º 2
0
 @Test
 public void testGet() throws Exception {
   mockMvc
       .perform(get(REST_URL + ADMIN_MEAL_ID).with(userHttpBasic(ADMIN)))
       .andExpect(status().isOk())
       .andDo(print())
       .andExpect(content().contentType(MediaType.APPLICATION_JSON))
       .andExpect(MATCHER.contentMatcher(ADMIN_MEAL));
 }
Ejemplo n.º 3
0
 @Test
 public void testDelete() throws Exception {
   mockMvc
       .perform(
           delete(REST_URL + MEAL1_ID)
               .contentType(MediaType.APPLICATION_JSON)
               .with(userHttpBasic(USER)))
       .andExpect(status().isOk());
   MATCHER.assertCollectionEquals(
       Arrays.asList(MEAL6, MEAL5, MEAL4, MEAL3, MEAL2), service.getAll(START_SEQ));
 }