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
 @Override
 public UserMeal update(UserMeal meal, int userId) {
   return ExceptionUtil.check(repository.save(meal, userId), meal.getId());
 }