use of ru.javawebinar.topjava.model.User in project topjava10 by JavaWebinar.
the class AbstractUserServiceTest method testUpdate.
@Test
public void testUpdate() throws Exception {
User updated = new User(USER);
updated.setName("UpdatedName");
updated.setCaloriesPerDay(330);
updated.setRoles(Collections.singletonList(Role.ROLE_ADMIN));
service.update(updated);
MATCHER.assertEquals(updated, service.get(USER_ID));
}
use of ru.javawebinar.topjava.model.User in project topjava10 by JavaWebinar.
the class AbstractJpaUserServiceTest method testValidation.
@Test
public void testValidation() throws Exception {
validateRootCause(() -> service.save(new User(null, " ", "invalid@yandex.ru", "password", 2000, Role.ROLE_USER)), ConstraintViolationException.class);
validateRootCause(() -> service.save(new User(null, "User", " ", "password", 2000, Role.ROLE_USER)), ConstraintViolationException.class);
validateRootCause(() -> service.save(new User(null, "User", "invalid@yandex.ru", " ", 2000, Role.ROLE_USER)), ConstraintViolationException.class);
validateRootCause(() -> service.save(new User(null, "User", "invalid@yandex.ru", "password", 9, true, new Date(), Collections.emptySet())), ConstraintViolationException.class);
validateRootCause(() -> service.save(new User(null, "User", "invalid@yandex.ru", "password", 10001, true, new Date(), Collections.emptySet())), ConstraintViolationException.class);
}
use of ru.javawebinar.topjava.model.User in project topjava10 by JavaWebinar.
the class ProfileRestControllerTest method testUpdate.
@Test
public void testUpdate() throws Exception {
UserTo updatedTo = new UserTo(null, "newName", "newemail@ya.ru", "newPassword", 1500);
mockMvc.perform(put(REST_URL).contentType(MediaType.APPLICATION_JSON).with(userHttpBasic(USER)).content(JsonUtil.writeValue(updatedTo))).andDo(print()).andExpect(status().isOk());
MATCHER.assertEquals(UserUtil.updateFromTo(new User(USER), updatedTo), userService.getByEmail("newemail@ya.ru"));
}
Aggregations