use of com.laurentiuspilca.ssc6.entities.User in project 2021-msk-food-delivery by netcracker-edu.
the class UserServiceTest method getUserByIdSuccess.
@Test
public void getUserByIdSuccess() {
Long userId = 1L;
User sheldonCooper = UserUtils.adminSheldonCooper(userId);
when(userRepoMock.findById(userId)).thenReturn(Optional.of(sheldonCooper));
User result = userService.getUserById(userId);
assertEquals(sheldonCooper, result);
verify(userRepoMock, times(1)).findById(userId);
}
use of com.laurentiuspilca.ssc6.entities.User in project 2021-msk-food-delivery by netcracker-edu.
the class UserServiceTest method unlockUserSuccess.
@Test
public void unlockUserSuccess() {
User penny = UserUtils.clientPennyTeller(1L);
Timestamp current = new Timestamp(System.currentTimeMillis());
penny.setLockDate(current);
UserInfoDTO resultDTO = userService.unlockUser(penny);
assertEquals(null, resultDTO.getLockDate());
verify(userRepoMock, times(1)).save(any(User.class));
}
use of com.laurentiuspilca.ssc6.entities.User in project 2021-msk-food-delivery by netcracker-edu.
the class UserServiceTest method getUserDTOByIdSuccess.
@Test
public void getUserDTOByIdSuccess() {
Long userId = 1L;
User sheldonCooper = UserUtils.adminSheldonCooper(userId);
when(userRepoMock.findById(userId)).thenReturn(Optional.of(sheldonCooper));
UserInfoDTO resultDTO = userService.getUserDTOById(userId);
UserInfoDTO perfectDTO = UserUtils.createUserDTO(sheldonCooper);
assertEquals(perfectDTO, resultDTO);
verify(userRepoMock, times(1)).findById(userId);
}
use of com.laurentiuspilca.ssc6.entities.User in project 2021-msk-food-delivery by netcracker-edu.
the class UserServiceTest method changePasswordSuccess.
@Test
public void changePasswordSuccess() {
Long userId = 1L;
User rajesh = UserUtils.clientRajeshKoothrappali(userId);
String oldPass = "password";
String newPass = "koothrappali";
PasswordChangeDTO passwordDTO = new PasswordChangeDTO();
passwordDTO.setNewPassword(newPass);
passwordDTO.setNewPasswordConfirm(newPass);
passwordDTO.setOldPassword(oldPass);
when(userRepoMock.save(any(User.class))).thenAnswer(invocation -> invocation.getArguments()[0]);
boolean result = userService.changePassword(rajesh, passwordDTO);
assertTrue(result);
verify(userRepoMock, times(1)).save(any(User.class));
}
use of com.laurentiuspilca.ssc6.entities.User in project 2021-msk-food-delivery by netcracker-edu.
the class UserServiceImpl method deleteUserById.
@Override
public boolean deleteUserById(Long id) {
User userForDelete = getUserById(id);
userRepo.delete(userForDelete);
return true;
}
Aggregations