File tree Expand file tree Collapse file tree
src/test/java/br/com/developers/login/service/impl Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -108,4 +108,23 @@ void shouldReturnIllegalRoleException(RegisterDTO registerData) {
108108 assertTrue (exception instanceof IllegalRoleException );
109109 assertEquals ("Fail! -> Cause: teste is Role invalid." , exception .getMessage ());
110110 }
111+
112+ @ ParameterizedTest
113+ @ ArgumentsSource (RegisterDTOProviderTests .class )
114+ void shouldUpdateUser (RegisterDTO registerData ) {
115+ BDDMockito .given (this .userRepository .findByEmail (registerData .getEmail ().toLowerCase ()))
116+ .willReturn (Optional .of (this .user ));
117+ BDDMockito .given (this .roleRepository .findByName (RoleName .ROLE_ADMIN ))
118+ .willReturn (Optional .of (this .role ));
119+ BDDMockito .given (this .userRepository .save (this .user )).willReturn (this .user );
120+
121+ User user = this .service .updateUser (registerData );
122+
123+ assertEquals (registerData .getName (), user .getFirstName ());
124+ assertEquals (registerData .getLastName (), user .getLastName ());
125+ assertEquals (registerData .getEmail ().toLowerCase (), user .getEmail ());
126+
127+ verify (this .userRepository , times (1 )).findByEmail (anyString ());
128+ verify (this .roleRepository , times (1 )).findByName (any ());
129+ }
111130}
You can’t perform that action at this time.
0 commit comments