@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)); }
public UserMeal create(UserMeal meal) { meal.setId(null); int userId = LoggedUser.id(); LOG.info("create {} for User {}", meal, userId); return service.save(meal, userId); }
@Override public UserMeal update(UserMeal meal, int userId) { return ExceptionUtil.check(repository.save(meal, userId), meal.getId()); }
public void update(UserMeal meal, int id) { meal.setId(id); int userId = LoggedUser.id(); LOG.info("update {} for User {}", meal, userId); service.update(meal, userId); }