use of org.summerb.microservices.users.api.exceptions.UserNotFoundException in project summerb by skarpushin.
the class UserServiceImpl method getUserByUuid.
@Override
public User getUserByUuid(String userUuid) throws UserNotFoundException {
Assert.hasText(userUuid, "userUuid must be provided");
User foundUser;
try {
foundUser = userDao.findUserByUuid(userUuid);
} catch (Throwable t) {
String msg = String.format("Failed to find user '%s'", userUuid);
throw new UserServiceUnexpectedException(msg, t);
}
if (foundUser == null) {
throw new UserNotFoundException(userUuid);
}
return foundUser;
}
use of org.summerb.microservices.users.api.exceptions.UserNotFoundException in project summerb by skarpushin.
the class UserServiceImpl method updateUser.
@Override
@Transactional(rollbackFor = Throwable.class)
public void updateUser(User user) throws FieldValidationException, UserNotFoundException {
Preconditions.checkArgument(user != null, "User reference required");
Preconditions.checkArgument(StringUtils.hasText(user.getUuid()), "User uuid must be provided");
validateUser(user);
boolean isUpdatedSuccessfully;
try {
isUpdatedSuccessfully = userDao.updateUser(user);
eventBus.post(EntityChangedEvent.updated(user));
} catch (DuplicateKeyException dke) {
throw new FieldValidationException(new DuplicateUserValidationError(User.FN_EMAIL));
} catch (Throwable t) {
String msg = String.format("Failed to update user '%s'", user.getUuid());
throw new UserServiceUnexpectedException(msg, t);
}
if (!isUpdatedSuccessfully) {
throw new UserNotFoundException(user.getUuid());
}
}
use of org.summerb.microservices.users.api.exceptions.UserNotFoundException in project summerb by skarpushin.
the class UserCachedTest method testDeleteUser_expectUserNotFoundException.
// (expected=UserNotFoundException.class)
@Test
public void testDeleteUser_expectUserNotFoundException() throws Exception {
User userToCreate = UserFactory.createNewUserTemplate();
userToCreate = userService.createUser(userToCreate);
userService.getUserByUuid(userToCreate.getUuid());
userService.deleteUserByUuid(userToCreate.getUuid());
try {
userService.getUserByUuid(userToCreate.getUuid());
fail();
} catch (UserNotFoundException e) {
}
}
use of org.summerb.microservices.users.api.exceptions.UserNotFoundException in project summerb by skarpushin.
the class UserDaoImplTest method testDeleteUser_expectUserWillNotBeFoundAfterDeletition.
@Test
public void testDeleteUser_expectUserWillNotBeFoundAfterDeletition() throws Exception {
User userToCreate = UserFactory.createNewUserTemplate();
userToCreate = userService.createUser(userToCreate);
userService.deleteUserByUuid(userToCreate.getUuid());
try {
userService.getUserByEmail(userToCreate.getEmail());
fail();
} catch (UserNotFoundException e) {
// it's expected
}
}
Aggregations