use of com.ncedu.fooddelivery.api.v1.entities.User in project 2021-msk-food-delivery by netcracker-edu.
the class ProfileControllerTest method changeEmail.
@Test
public void changeEmail() {
EmailChangeDTO emailChangeDTO = new EmailChangeDTO();
emailChangeDTO.setEmail("wolowitz@bigbang.theory");
emailChangeDTO.setPassword("bigBangTheory");
User user = new User();
user.setId(1L);
when(userServiceMock.changeEmail(user, emailChangeDTO)).thenReturn(true);
ResponseEntity<?> resultResponse = profileController.changeUserEmail(emailChangeDTO, user);
ResponseEntity<?> perfectResponse = createModifyResponse(true);
assertEquals(perfectResponse, resultResponse);
}
use of com.ncedu.fooddelivery.api.v1.entities.User in project 2021-msk-food-delivery by netcracker-edu.
the class ProfileControllerTest method getAdminProfile.
@Test
public void getAdminProfile() {
UserInfoDTO userInfoDTO = new UserInfoDTO(1L, "ADMIN", "admin@mail.ru");
when(userServiceMock.getUserDTOById(1L)).thenReturn(userInfoDTO);
User user = new User();
user.setId(1L);
user.setRole(Role.ADMIN);
UserInfoDTO resultUserDTO = profileController.getProfile(user);
assertEquals(userInfoDTO, resultUserDTO);
}
use of com.ncedu.fooddelivery.api.v1.entities.User in project 2021-msk-food-delivery by netcracker-edu.
the class ProfileControllerTest method changePasswordMismatchError.
@Test
public void changePasswordMismatchError() {
PasswordChangeDTO pwdChangeDTO = new PasswordChangeDTO();
pwdChangeDTO.setOldPassword("password");
pwdChangeDTO.setNewPassword("qwerty123");
pwdChangeDTO.setNewPasswordConfirm("INCORRECT");
User user = new User();
user.setId(1L);
when(userServiceMock.changePassword(user, pwdChangeDTO)).thenThrow(new PasswordsMismatchException());
Exception exception = assertThrows(PasswordsMismatchException.class, () -> {
profileController.changeUserPassword(pwdChangeDTO, user);
});
String resultMessage = exception.getMessage();
String perfectMessage = new PasswordsMismatchException().getMessage();
verify(userServiceMock, times(1)).changePassword(user, pwdChangeDTO);
assertEquals(perfectMessage, resultMessage);
}
use of com.ncedu.fooddelivery.api.v1.entities.User in project 2021-msk-food-delivery by netcracker-edu.
the class ClientUtils method createClient.
private static Client createClient(Long userId, String fullName, String email, String phoneNumber) {
User user = new User();
user.setId(userId);
user.setFullName(fullName);
user.setEmail(email);
user.setRole(Role.CLIENT);
Client client = new Client();
client.setPhoneNumber(phoneNumber);
client.setUser(user);
return client;
}
use of com.ncedu.fooddelivery.api.v1.entities.User in project 2021-msk-food-delivery by netcracker-edu.
the class UserServiceTest method lockUserAlsoLocked.
@Test
public void lockUserAlsoLocked() {
User penny = UserUtils.clientPennyTeller(1L);
Timestamp current = new Timestamp(System.currentTimeMillis());
penny.setLockDate(current);
UserInfoDTO resultDTO = userService.lockUser(penny);
assertEquals(current, resultDTO.getLockDate());
verify(userRepoMock, never()).save(any(User.class));
}
Aggregations