use of com.ncedu.fooddelivery.api.v1.entities.User in project 2021-msk-food-delivery by netcracker-edu.
the class UserServiceTest method unlockUserAlsoUnlocked.
@Test
public void unlockUserAlsoUnlocked() {
User penny = UserUtils.clientPennyTeller(1L);
penny.setLockDate(null);
UserInfoDTO resultDTO = userService.unlockUser(penny);
assertEquals(null, resultDTO.getLockDate());
verify(userRepoMock, never()).save(any(User.class));
}
use of com.ncedu.fooddelivery.api.v1.entities.User in project 2021-msk-food-delivery by netcracker-edu.
the class UserServiceImpl method deleteAvatar.
@Override
public void deleteAvatar(User user) {
UUID avatarId = user.getAvatarId();
if (avatarId == null) {
return;
}
user.setAvatarId(null);
userRepo.save(user);
File avatar = fileService.getFile(avatarId);
if (avatar != null) {
fileService.delete(avatar, user);
}
}
use of com.ncedu.fooddelivery.api.v1.entities.User in project 2021-msk-food-delivery by netcracker-edu.
the class ProfileControllerTest method changeClientName.
@Test
public void changeClientName() {
UserChangeInfoDTO userChangeInfoDTO = new UserChangeInfoDTO();
userChangeInfoDTO.setFullName("Sheldon Lee Cooper");
Long authedUserId = 1L;
when(clientServiceMock.changeClientInfo(authedUserId, userChangeInfoDTO)).thenReturn(true);
User user = new User();
user.setId(authedUserId);
user.setRole(Role.CLIENT);
ResponseEntity<?> resultResponse = profileController.changeUserInfo(userChangeInfoDTO, 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 changePasswordSuccess.
@Test
public void changePasswordSuccess() {
PasswordChangeDTO pwdChangeDTO = new PasswordChangeDTO();
pwdChangeDTO.setOldPassword("password");
pwdChangeDTO.setNewPassword("qwerty123");
pwdChangeDTO.setNewPasswordConfirm("qwerty123");
User user = new User();
user.setId(1L);
when(userServiceMock.changePassword(user, pwdChangeDTO)).thenReturn(true);
ResponseEntity<?> resultResponse = profileController.changeUserPassword(pwdChangeDTO, user);
ResponseEntity<?> perfectResponse = createModifyResponse(true);
verify(userServiceMock, times(1)).changePassword(user, pwdChangeDTO);
assertEquals(perfectResponse, resultResponse);
}
use of com.ncedu.fooddelivery.api.v1.entities.User in project 2021-msk-food-delivery by netcracker-edu.
the class AuthServiceImpl method signIn.
@Override
public JwtResponseDTO signIn(JwtRequestDTO authInfo, String userAgent) {
Authentication auth = authenticate(authInfo.getLogin(), authInfo.getPassword());
// User implements UserDetails
User user = (User) auth.getPrincipal();
userService.setLastSigninFromNow(user);
log.debug("USER: " + user.getUsername() + user.getLastSigninDate());
final String accessToken = jwtUtil.createToken(user);
final String refreshToken = userRefreshTokenService.createRefreshToken(user, userAgent);
return new JwtResponseDTO(accessToken, refreshToken, createUserDTO(user));
}
Aggregations