use of com.laurentiuspilca.springsecurityc2.entities.User in project 2021-msk-food-delivery by netcracker-edu.
the class UserServiceTest method changeFullNameBad.
@Test
public void changeFullNameBad() {
Long userId = 1L;
User leonard = UserUtils.moderatorLeonardHofstadter(userId);
when(userRepoMock.findById(userId)).thenReturn(Optional.of(leonard));
boolean result = userService.changeFullName(userId, null);
assertFalse(result);
verify(userRepoMock, times(1)).findById(userId);
verify(userRepoMock, never()).save(leonard);
}
use of com.laurentiuspilca.springsecurityc2.entities.User in project 2021-msk-food-delivery by netcracker-edu.
the class UserServiceTest method lockUserSuccess.
@Test
public void lockUserSuccess() {
User penny = UserUtils.clientPennyTeller(1L);
when(userRepoMock.save(any(User.class))).thenAnswer(invocation -> invocation.getArguments()[0]);
UserInfoDTO resultDTO = userService.lockUser(penny);
assertTrue(resultDTO.getLockDate() != null);
verify(userRepoMock, times(1)).save(any(User.class));
}
use of com.laurentiuspilca.springsecurityc2.entities.User in project 2021-msk-food-delivery by netcracker-edu.
the class UserServiceTest method changeEmailPasswordMismatch.
@Test
public void changeEmailPasswordMismatch() {
Long userId = 1L;
User howard = UserUtils.courierHowardWolowitz(userId);
String newEmail = "happy-howard@bigbang.theory";
when(userRepoMock.findByEmail(newEmail)).thenReturn(null);
String password = "wrong-password";
EmailChangeDTO changeDTO = new EmailChangeDTO();
changeDTO.setEmail(newEmail);
changeDTO.setPassword(password);
assertThrows(PasswordsMismatchException.class, () -> {
userService.changeEmail(howard, changeDTO);
});
verify(userRepoMock, times(1)).findByEmail(newEmail);
verify(userRepoMock, never()).save(any(User.class));
}
use of com.laurentiuspilca.springsecurityc2.entities.User in project 2021-msk-food-delivery by netcracker-edu.
the class ClientServiceImpl method changeClientInfo.
@Override
public boolean changeClientInfo(Long id, UserChangeInfoDTO newUserInfo) {
Client client = getClientById(id);
String newFullName = newUserInfo.getFullName();
if (newFullName != null) {
User user = client.getUser();
user.setFullName(newFullName);
client.setUser(user);
}
String newPhoneNumber = newUserInfo.getPhoneNumber();
if (newPhoneNumber != null) {
Client clientWithNewNumber = clientRepo.findByPhoneNumber(newPhoneNumber);
if (clientWithNewNumber != null) {
throw new AlreadyExistsException(newPhoneNumber);
}
client.setPhoneNumber(newPhoneNumber);
}
clientRepo.save(client);
return true;
}
use of com.laurentiuspilca.springsecurityc2.entities.User in project tapestry-5 by apache.
the class CachedForm method onSuccess.
@CommitAfter
void onSuccess() {
User user = new User();
user.setFirstName(name);
session.save(user);
}
Aggregations