diff --git a/backend/sportsmatch/src/test/java/com/sportsmatch/services/UserServiceImpTest.java b/backend/sportsmatch/src/test/java/com/sportsmatch/services/UserServiceImpTest.java index 81f8f0ec..15ac364c 100644 --- a/backend/sportsmatch/src/test/java/com/sportsmatch/services/UserServiceImpTest.java +++ b/backend/sportsmatch/src/test/java/com/sportsmatch/services/UserServiceImpTest.java @@ -9,29 +9,44 @@ import com.sportsmatch.dtos.UserDTO; import com.sportsmatch.dtos.UserInfoDTO; import com.sportsmatch.mappers.SportMapper; +import com.sportsmatch.mappers.UserMapper; import com.sportsmatch.models.*; +import com.sportsmatch.repositories.SportRepository; import com.sportsmatch.repositories.UserRepository; import java.time.LocalDate; import java.time.format.DateTimeFormatter; import java.util.*; +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.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.security.core.Authentication; import org.springframework.security.core.context.SecurityContext; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.core.userdetails.UserDetails; +import org.springframework.security.crypto.password.PasswordEncoder; @ExtendWith(MockitoExtension.class) class UserServiceImpTest extends BaseTest { @Mock private UserRepository userRepository; + @Mock private SportRepository sportRepository; @Mock private SportMapper sportMapper; @Mock private SecurityContext securityContext; @Mock private RankService rankService; - @InjectMocks private UserServiceImp userServiceImp; + @Mock private PasswordEncoder passwordEncoder; + private UserServiceImp userServiceImp; + + @BeforeEach + void initialize(){ + userServiceImp = new UserServiceImp(userRepository, sportMapper, sportRepository, + new UserMapper(passwordEncoder, sportMapper),rankService); + } @Test void updateUserInfo() {