use of com.laurentiuspilca.ssc6.entities.User in project 2021-msk-food-delivery by netcracker-edu.
the class UserServiceTest method setLastSigninSuccess.
@Test
public void setLastSigninSuccess() {
User howard = UserUtils.courierHowardWolowitz(1L);
Timestamp current = new Timestamp(System.currentTimeMillis());
howard.setLastSigninDate(current);
when(userRepoMock.save(any(User.class))).thenAnswer(invocation -> invocation.getArguments()[0]);
userService.setLastSigninFromNow(howard);
assertTrue(current.before(howard.getLastSigninDate()));
verify(userRepoMock, times(1)).save(any());
}
use of com.laurentiuspilca.ssc6.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.laurentiuspilca.ssc6.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.laurentiuspilca.ssc6.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.laurentiuspilca.ssc6.entities.User in project 2021-msk-food-delivery by netcracker-edu.
the class UserServiceImpl method getAllAdmins.
public List<UserInfoDTO> getAllAdmins() {
Role adminRole = Role.ADMIN;
List<User> admins = userRepo.findByRole(adminRole);
List<UserInfoDTO> adminsDTO = new ArrayList<>();
for (User admin : admins) {
adminsDTO.add(createUserDTO(admin));
}
return adminsDTO;
}
Aggregations