diff --git a/src/test/java/com/lk/paopao/service/AuthServiceTest.java b/src/test/java/com/lk/paopao/service/AuthServiceTest.java index 7fc6f52..81670d9 100644 --- a/src/test/java/com/lk/paopao/service/AuthServiceTest.java +++ b/src/test/java/com/lk/paopao/service/AuthServiceTest.java @@ -8,6 +8,7 @@ import com.lk.paopao.security.JwtUtils; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; import org.springframework.security.authentication.AuthenticationManager; @@ -37,17 +38,14 @@ class AuthServiceTest { @Mock private JwtUtils mockJwtUtils; + @InjectMocks private AuthService authServiceUnderTest; String TOKEN = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1aWQiOjEwMDA2NiwidXNlcm5hbWUiOiJ4eXoiLCJpc3MiOiI4ZGNlMGM3NjcyMWFkODFiYzQxMjRhMDhjMTBkNDk3MSIsImV4cCI6MTcxNzYzODgxMn0.TdAMHh4n7SQVipXK-_zRsk5jhCVpoZI4jnlUIR7iO-I"; @BeforeEach void setUp() { - authServiceUnderTest = new AuthService(); + ReflectionTestUtils.setField(authServiceUnderTest, "DEFAULT_HEAD_ICON", "avatar"); - authServiceUnderTest.userRepository = mockUserRepository; - authServiceUnderTest.authenticationManager = mockAuthenticationManager; - authServiceUnderTest.encoder = mockEncoder; - authServiceUnderTest.jwtUtils = mockJwtUtils; }