Compare commits

...

2 Commits

Author SHA1 Message Date
9eec90ef98 Merge remote-tracking branch 'origin/master' 2025-05-14 14:26:59 +09:00
bd06fc047d 练习 2025-05-14 14:24:33 +09:00

View File

@ -15,6 +15,8 @@ import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.security.crypto.password.PasswordEncoder;
import static org.mockito.Mockito.when;
@SpringBootTest
@ExtendWith(MockitoExtension.class)
public class UserServiceTest {
@ -50,7 +52,13 @@ public class UserServiceTest {
}
@Test
void testRegisterNewUser () throws Exception{
void testRegisterNewUser_normal () throws Exception{
when(userRepository.existsByEmail(registrationDto.getEmail())).thenReturn(false);
when(passwordEncoder.encode(registrationDto.getPassword())).thenReturn(registrationDto.getPassword());
when(userRepository.save(userEntity)).thenAnswer(invocation -> invocation.getArgument(0));
}