use of entities.User in project 2021-msk-food-delivery by netcracker-edu.
the class UserServiceImpl method changeFullName.
@Override
public boolean changeFullName(Long id, String newFullName) {
User user = getUserById(id);
if (newFullName != null) {
user.setFullName(newFullName);
userRepo.save(user);
return true;
}
return false;
}
use of entities.User in project 2021-msk-food-delivery by netcracker-edu.
the class ProfileControllerTest method changeAdminName.
@Test
public void changeAdminName() {
UserChangeInfoDTO userChangeInfoDTO = new UserChangeInfoDTO();
userChangeInfoDTO.setFullName("Howard Joel Wolowitz");
Long authedUserId = 1L;
when(userServiceMock.changeFullName(authedUserId, userChangeInfoDTO.getFullName())).thenReturn(true);
User user = new User();
user.setId(authedUserId);
user.setRole(Role.ADMIN);
ResponseEntity<?> resultResponse = profileController.changeUserInfo(userChangeInfoDTO, user);
ResponseEntity<?> perfectResponse = createModifyResponse(true);
assertEquals(perfectResponse, resultResponse);
}
use of entities.User in project 2021-msk-food-delivery by netcracker-edu.
the class ProfileControllerTest method changeEmailWithBadValues.
@Test
public void changeEmailWithBadValues() {
EmailChangeDTO emailChangeDTO = new EmailChangeDTO();
emailChangeDTO.setEmail("wolowitz.bigbang");
emailChangeDTO.setPassword("small");
User user = new User();
user.setId(1L);
when(userServiceMock.changeEmail(user, emailChangeDTO)).thenReturn(false);
ResponseEntity<?> resultResponse = profileController.changeUserEmail(emailChangeDTO, user);
ResponseEntity<?> perfectResponse = createModifyResponse(false);
assertEquals(perfectResponse, resultResponse);
}
use of entities.User in project 2021-msk-food-delivery by netcracker-edu.
the class ProfileControllerTest method getClientProfile.
@Test
public void getClientProfile() {
ClientInfoDTO clientInfoDTO = new ClientInfoDTO(1L, "CLIENT", "client@mail.ru");
when(clientServiceMock.getClientDTOById(1L)).thenReturn(clientInfoDTO);
User user = new User();
user.setId(1L);
user.setRole(Role.CLIENT);
UserInfoDTO resultClientDTO = profileController.getProfile(user);
assertEquals(clientInfoDTO, resultClientDTO);
}
use of entities.User in project 2021-msk-food-delivery by netcracker-edu.
the class ProfileControllerTest method getModeratorProfile.
@Test
public void getModeratorProfile() {
ModeratorInfoDTO moderatorInfoDTO = new ModeratorInfoDTO(1L, "MODERATOR", "moderator@mail.ru");
when(moderatorServiceMock.getModeratorDTOById(1L)).thenReturn(moderatorInfoDTO);
User user = new User();
user.setId(1L);
user.setRole(Role.MODERATOR);
UserInfoDTO resultModeratorDTO = profileController.getProfile(user);
assertEquals(moderatorInfoDTO, resultModeratorDTO);
}
Aggregations