3131class UserServiceImpl implements UserService {
3232
3333 private static final String ROLE_NOT_FOUND = "Fail! -> Cause: %s Role not found in database." ;
34- private static final String USER_NOT_FOUND = "Fail! -> Cause: User not found with email [%s]" ;
34+ private static final String USER_NOT_FOUND = "Fail! -> Cause: User not found with %s [%s]" ;
3535
3636 private UserRepository userRepository ;
3737 private RoleRepository roleRepository ;
@@ -68,9 +68,10 @@ private Set<Role> getAllRoles(RegisterDTO registerData) {
6868 }
6969
7070
71- public User updateUser (RegisterDTO registerData ) {
72- User user = this .userRepository .findByEmail (registerData .getEmail ().toLowerCase ()).orElseThrow (
73- () -> new UserNotFoundException (String .format (USER_NOT_FOUND , registerData .getEmail ())));
71+ public User update (RegisterDTO registerData ) {
72+ User user = this .userRepository .findByEmail (registerData .getEmail ().toLowerCase ())
73+ .orElseThrow (() -> new UserNotFoundException (
74+ String .format (USER_NOT_FOUND , "email" , registerData .getEmail ())));
7475 user .setFirstName (registerData .getName ());
7576 user .setLastName (registerData .getLastName ());
7677 user .setPassword (registerData .getPassword ());
@@ -79,8 +80,9 @@ public User updateUser(RegisterDTO registerData) {
7980 }
8081
8182 public void delete (LoginDTO loginDTO ) {
82- User user = this .userRepository .findByEmail (loginDTO .getEmail ().toLowerCase ()).orElseThrow (
83- () -> new UserNotFoundException (String .format (USER_NOT_FOUND , loginDTO .getEmail ())));
83+ User user = this .userRepository .findByEmail (loginDTO .getEmail ().toLowerCase ())
84+ .orElseThrow (() -> new UserNotFoundException (
85+ String .format (USER_NOT_FOUND , "email" , loginDTO .getEmail ())));
8486 this .userRepository .delete (user );
8587 }
8688
@@ -95,7 +97,7 @@ public AccessToken authenticateUser(LoginDTO loginDto) {
9597
9698 public UserDTO find (String id ) {
9799 User user = this .userRepository .findById (UUID .fromString (id ))
98- .orElseThrow (() -> new UserNotFoundException (String .format (USER_NOT_FOUND , id )));
100+ .orElseThrow (() -> new UserNotFoundException (String .format (USER_NOT_FOUND , "id" , id )));
99101 return UserDTO .build (user );
100102 }
101103}
0 commit comments