diff --git a/src/test/java/com/postgraduate/domain/auth/presentation/AuthControllerTest.java b/src/test/java/com/postgraduate/domain/auth/presentation/AuthControllerTest.java index 249924e7..a6f98ec1 100644 --- a/src/test/java/com/postgraduate/domain/auth/presentation/AuthControllerTest.java +++ b/src/test/java/com/postgraduate/domain/auth/presentation/AuthControllerTest.java @@ -14,6 +14,7 @@ import com.postgraduate.domain.wish.domain.repository.WishRepository; import com.postgraduate.global.config.redis.RedisRepository; import com.postgraduate.global.config.security.jwt.util.JwtUtils; +import com.postgraduate.global.slack.SlackMessage; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -21,6 +22,7 @@ import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.http.MediaType; +import java.io.IOException; import java.util.Optional; import static com.postgraduate.domain.auth.presentation.constant.AuthResponseCode.*; @@ -33,6 +35,7 @@ import static com.postgraduate.domain.user.presentation.constant.UserResponseMessage.NOT_FOUND_USER; import static java.time.LocalDateTime.now; import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.when; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; @@ -53,14 +56,17 @@ class AuthControllerTest extends IntegrationTest { private WishRepository wishRepository; @MockBean RedisRepository redisRepository; + @MockBean + private SlackMessage slackMessage; private User user; private final Long anonymousUserSocialId = 2L; @BeforeEach - void setUp() { + void setUp() throws IOException { user = new User(0L, 1L, "mail", "후배", "011", "profile", 0, USER, true, now(), now(), false); userRepository.save(user); + doNothing().when(slackMessage).sendSlackLog(any()); } @Test diff --git a/src/test/java/com/postgraduate/domain/mentoring/presentation/MentoringControllerTest.java b/src/test/java/com/postgraduate/domain/mentoring/presentation/MentoringControllerTest.java index 55353ab6..35a025e0 100644 --- a/src/test/java/com/postgraduate/domain/mentoring/presentation/MentoringControllerTest.java +++ b/src/test/java/com/postgraduate/domain/mentoring/presentation/MentoringControllerTest.java @@ -22,6 +22,7 @@ import com.postgraduate.domain.user.domain.entity.constant.Role; import com.postgraduate.domain.user.domain.repository.UserRepository; import com.postgraduate.global.config.security.jwt.util.JwtUtils; +import com.postgraduate.global.slack.SlackMessage; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -29,8 +30,10 @@ import org.junit.jupiter.params.provider.EnumSource; import org.junit.jupiter.params.provider.ValueSource; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.http.MediaType; +import java.io.IOException; import java.time.LocalDate; import static com.postgraduate.domain.mentoring.presentation.constant.MentoringResponseCode.*; @@ -39,6 +42,8 @@ import static com.postgraduate.domain.salary.util.SalaryUtil.getSalaryDate; import static com.postgraduate.domain.senior.domain.entity.constant.Status.WAITING; import static java.time.LocalDateTime.now; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.doNothing; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; @@ -60,13 +65,15 @@ class MentoringControllerTest extends IntegrationTest { private SalaryRepository salaryRepository; @Autowired private PaymentRepository paymentRepository; + @MockBean + private SlackMessage slackMessage; private User user; private Senior senior; private String userAccessToken; private String seniorAccessToken; @BeforeEach - void setUp() { + void setUp() throws IOException { user = new User(0L, 1L, "mail", "후배", "011", "profile", 0, Role.USER, true, now(), now(), false); userRepository.save(user); @@ -80,6 +87,8 @@ void setUp() { userAccessToken = jwtUtil.generateAccessToken(user.getUserId(), Role.USER); seniorAccessToken = jwtUtil.generateAccessToken(userOfSenior.getUserId(), Role.SENIOR); + + doNothing().when(slackMessage).sendSlackLog(any()); } @ParameterizedTest diff --git a/src/test/java/com/postgraduate/domain/salary/presentation/SalaryControllerTest.java b/src/test/java/com/postgraduate/domain/salary/presentation/SalaryControllerTest.java index ad39fa27..22b2a292 100644 --- a/src/test/java/com/postgraduate/domain/salary/presentation/SalaryControllerTest.java +++ b/src/test/java/com/postgraduate/domain/salary/presentation/SalaryControllerTest.java @@ -13,15 +13,21 @@ import com.postgraduate.domain.user.domain.entity.constant.Role; import com.postgraduate.domain.user.domain.repository.UserRepository; import com.postgraduate.global.config.security.jwt.util.JwtUtils; +import com.postgraduate.global.slack.SlackMessage; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.mock.mockito.MockBean; + +import java.io.IOException; import static com.postgraduate.domain.salary.presentation.constant.SalaryResponseCode.SALARY_FIND; import static com.postgraduate.domain.salary.presentation.constant.SalaryResponseMessage.GET_SALARY_INFO; import static com.postgraduate.domain.salary.presentation.constant.SalaryResponseMessage.GET_SALARY_LIST_INFO; import static java.time.LocalDateTime.now; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.doNothing; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; @@ -37,11 +43,13 @@ class SalaryControllerTest extends IntegrationTest { private SeniorRepository seniorRepository; @Autowired private SalaryRepository salaryRepository; + @MockBean + private SlackMessage slackMessage; private String token; @BeforeEach - void setUp() { + void setUp() throws IOException { User user = new User(0L, 1L, "mail", "후배", "011", "profile", 0, Role.SENIOR, true, now(), now(), false); userRepository.save(user); @@ -54,6 +62,8 @@ void setUp() { salaryRepository.save(salary); token = jwtUtil.generateAccessToken(user.getUserId(), Role.SENIOR); + + doNothing().when(slackMessage).sendSlackLog(any()); } @Test diff --git a/src/test/java/com/postgraduate/domain/senior/presentation/SeniorControllerTest.java b/src/test/java/com/postgraduate/domain/senior/presentation/SeniorControllerTest.java index 805dd3c8..90aba4f9 100644 --- a/src/test/java/com/postgraduate/domain/senior/presentation/SeniorControllerTest.java +++ b/src/test/java/com/postgraduate/domain/senior/presentation/SeniorControllerTest.java @@ -19,20 +19,25 @@ import com.postgraduate.domain.user.domain.entity.constant.Role; import com.postgraduate.domain.user.domain.repository.UserRepository; import com.postgraduate.global.config.security.jwt.util.JwtUtils; +import com.postgraduate.global.slack.SlackMessage; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.EnumSource; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.http.MediaType; +import java.io.IOException; import java.util.List; import static com.postgraduate.domain.salary.util.SalaryUtil.getSalaryDate; import static com.postgraduate.domain.senior.presentation.constant.SeniorResponseCode.*; import static com.postgraduate.domain.senior.presentation.constant.SeniorResponseMessage.*; import static java.time.LocalDateTime.now; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.doNothing; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; @@ -52,11 +57,13 @@ class SeniorControllerTest extends IntegrationTest { private SalaryRepository salaryRepository; @Autowired private AccountRepository accountRepository; + @MockBean + private SlackMessage slackMessage; private Senior senior; private String token; @BeforeEach - void setUp() { + void setUp() throws IOException { User user = new User(0L, 1L, "mail", "후배", "011", "profile", 0, Role.SENIOR, true, now(), now(), false); userRepository.save(user); @@ -66,6 +73,8 @@ void setUp() { seniorRepository.save(senior); token = jwtUtil.generateAccessToken(user.getUserId(), Role.SENIOR); + + doNothing().when(slackMessage).sendSlackLog(any()); } @Test diff --git a/src/test/java/com/postgraduate/domain/user/presentation/UserControllerTest.java b/src/test/java/com/postgraduate/domain/user/presentation/UserControllerTest.java index 245f3ad4..5424db23 100644 --- a/src/test/java/com/postgraduate/domain/user/presentation/UserControllerTest.java +++ b/src/test/java/com/postgraduate/domain/user/presentation/UserControllerTest.java @@ -8,18 +8,24 @@ import com.postgraduate.domain.user.domain.repository.UserRepository; import com.postgraduate.domain.user.presentation.constant.UserResponseCode; import com.postgraduate.global.config.security.jwt.util.JwtUtils; +import com.postgraduate.global.slack.SlackMessage; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.http.MediaType; +import java.io.IOException; + import static com.postgraduate.domain.user.presentation.constant.UserResponseCode.USER_FIND; import static com.postgraduate.domain.user.presentation.constant.UserResponseCode.USER_UPDATE; import static com.postgraduate.domain.user.presentation.constant.UserResponseMessage.*; import static java.time.LocalDateTime.now; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.doNothing; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.patch; import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; @@ -35,14 +41,18 @@ class UserControllerTest extends IntegrationTest { private JwtUtils jwtUtil; @Autowired private UserRepository userRepository; + @MockBean + private SlackMessage slackMessage; private String token; @BeforeEach - void setUp() { + void setUp() throws IOException { User user = new User(0L, 1L, "mail", "후배", "011", "profile", 0, Role.USER, true, now(), now(), false); userRepository.save(user); token = jwtUtil.generateAccessToken(user.getUserId(), Role.USER); + + doNothing().when(slackMessage).sendSlackLog(any()); } @Test