From 757f351156c6e0afad04409df1ef8afab3972430 Mon Sep 17 00:00:00 2001 From: hseong3243 Date: Tue, 27 Aug 2024 20:04:12 +0900 Subject: [PATCH 1/4] =?UTF-8?q?test:=20=ED=91=9C=ED=98=84=20=EA=B3=84?= =?UTF-8?q?=EC=B8=B5=20=EB=8B=A8=EC=9C=84=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20?= =?UTF-8?q?=EB=B9=88=20=EA=B5=AC=EC=84=B1=20=ED=86=B5=EC=9D=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 컨텍스트 캐싱 기능을 활용하기 위해 빈 구성을 통일함. --- .../member/controller/AuthControllerTest.java | 13 +--- .../controller/MemberControllerTest.java | 17 +---- .../AdminPerformanceControllerTest.java | 14 +--- .../UserPerformanceControllerTest.java | 16 ++--- .../controller/AdminSeatControllerTest.java | 20 ++---- .../seat/controller/SeatControllerTest.java | 16 ++--- .../controller/TicketControllerTest.java | 26 +++---- .../waitingsystem/WaitingControllerTest.java | 3 - .../controller/AdminZoneControllerTest.java | 17 ++--- .../controller/UserZoneControllerTest.java | 27 +++---- .../LoginMemberArgumentResolverTest.java | 22 +----- .../ticketing/support/BaseControllerTest.java | 70 ++++++++++++++++--- .../support/controller/DocsController.java | 35 ++++++++++ .../{ => controller}/DocumentationTest.java | 44 +----------- .../controller/ResolverTestController.java | 16 +++++ 15 files changed, 161 insertions(+), 195 deletions(-) create mode 100644 src/test/java/com/thirdparty/ticketing/support/controller/DocsController.java rename src/test/java/com/thirdparty/ticketing/support/{ => controller}/DocumentationTest.java (67%) create mode 100644 src/test/java/com/thirdparty/ticketing/support/controller/ResolverTestController.java diff --git a/src/test/java/com/thirdparty/ticketing/domain/member/controller/AuthControllerTest.java b/src/test/java/com/thirdparty/ticketing/domain/member/controller/AuthControllerTest.java index a0c7cb03..8103f2b3 100644 --- a/src/test/java/com/thirdparty/ticketing/domain/member/controller/AuthControllerTest.java +++ b/src/test/java/com/thirdparty/ticketing/domain/member/controller/AuthControllerTest.java @@ -8,24 +8,17 @@ import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; +import com.thirdparty.ticketing.domain.member.dto.request.LoginRequest; +import com.thirdparty.ticketing.domain.member.dto.response.LoginResponse; +import com.thirdparty.ticketing.support.BaseControllerTest; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; -import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.http.MediaType; import org.springframework.restdocs.payload.JsonFieldType; import org.springframework.test.web.servlet.ResultActions; -import com.thirdparty.ticketing.domain.member.dto.request.LoginRequest; -import com.thirdparty.ticketing.domain.member.dto.response.LoginResponse; -import com.thirdparty.ticketing.domain.member.service.AuthService; -import com.thirdparty.ticketing.support.BaseControllerTest; - -@WebMvcTest(controllers = AuthController.class) class AuthControllerTest extends BaseControllerTest { - @MockBean private AuthService authService; - @Test @DisplayName("로그인 API 호출 시") void login() throws Exception { diff --git a/src/test/java/com/thirdparty/ticketing/domain/member/controller/MemberControllerTest.java b/src/test/java/com/thirdparty/ticketing/domain/member/controller/MemberControllerTest.java index 4948f15a..7d0d4300 100644 --- a/src/test/java/com/thirdparty/ticketing/domain/member/controller/MemberControllerTest.java +++ b/src/test/java/com/thirdparty/ticketing/domain/member/controller/MemberControllerTest.java @@ -8,28 +8,17 @@ import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; +import com.thirdparty.ticketing.domain.member.dto.request.MemberCreationRequest; +import com.thirdparty.ticketing.domain.member.dto.response.CreateMemberResponse; +import com.thirdparty.ticketing.support.BaseControllerTest; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; -import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.http.MediaType; import org.springframework.restdocs.payload.JsonFieldType; import org.springframework.test.web.servlet.ResultActions; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.thirdparty.ticketing.domain.member.dto.request.MemberCreationRequest; -import com.thirdparty.ticketing.domain.member.dto.response.CreateMemberResponse; -import com.thirdparty.ticketing.domain.member.service.MemberService; -import com.thirdparty.ticketing.support.BaseControllerTest; - -@WebMvcTest(controllers = MemberController.class) class MemberControllerTest extends BaseControllerTest { - @Autowired private ObjectMapper objectMapper; - - @MockBean private MemberService memberService; - @Test @DisplayName("회원 생성 API 호출") void createMember() throws Exception { diff --git a/src/test/java/com/thirdparty/ticketing/domain/performance/controller/AdminPerformanceControllerTest.java b/src/test/java/com/thirdparty/ticketing/domain/performance/controller/AdminPerformanceControllerTest.java index 073d0c68..c95eff83 100644 --- a/src/test/java/com/thirdparty/ticketing/domain/performance/controller/AdminPerformanceControllerTest.java +++ b/src/test/java/com/thirdparty/ticketing/domain/performance/controller/AdminPerformanceControllerTest.java @@ -7,26 +7,18 @@ import static org.springframework.restdocs.payload.PayloadDocumentation.requestFields; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.thirdparty.ticketing.domain.performance.dto.request.PerformanceCreationRequest; +import com.thirdparty.ticketing.support.BaseControllerTest; import java.time.ZonedDateTime; - import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; -import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.http.MediaType; import org.springframework.restdocs.payload.JsonFieldType; import org.springframework.test.web.servlet.ResultActions; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.thirdparty.ticketing.domain.performance.dto.request.PerformanceCreationRequest; -import com.thirdparty.ticketing.domain.performance.service.AdminPerformanceService; -import com.thirdparty.ticketing.support.BaseControllerTest; - -@WebMvcTest(AdminPerformanceController.class) class AdminPerformanceControllerTest extends BaseControllerTest { - @MockBean private AdminPerformanceService adminPerformanceService; - @Test @DisplayName("POST /api/performances") void createPerformance() throws Exception { diff --git a/src/test/java/com/thirdparty/ticketing/domain/performance/controller/UserPerformanceControllerTest.java b/src/test/java/com/thirdparty/ticketing/domain/performance/controller/UserPerformanceControllerTest.java index 80daccdc..a85182d2 100644 --- a/src/test/java/com/thirdparty/ticketing/domain/performance/controller/UserPerformanceControllerTest.java +++ b/src/test/java/com/thirdparty/ticketing/domain/performance/controller/UserPerformanceControllerTest.java @@ -1,31 +1,23 @@ package com.thirdparty.ticketing.domain.performance.controller; -import static org.mockito.BDDMockito.*; +import static org.mockito.BDDMockito.given; import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get; import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath; import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; +import com.thirdparty.ticketing.domain.ItemResult; +import com.thirdparty.ticketing.domain.performance.dto.PerformanceElement; +import com.thirdparty.ticketing.support.BaseControllerTest; import java.time.ZonedDateTime; import java.util.List; - import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; -import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.restdocs.payload.JsonFieldType; import org.springframework.test.web.servlet.ResultActions; -import com.thirdparty.ticketing.domain.ItemResult; -import com.thirdparty.ticketing.domain.performance.dto.PerformanceElement; -import com.thirdparty.ticketing.domain.performance.service.UserPerformanceService; -import com.thirdparty.ticketing.support.BaseControllerTest; - -@WebMvcTest(UserPerformanceController.class) class UserPerformanceControllerTest extends BaseControllerTest { - @MockBean private UserPerformanceService userPerformanceService; - @Test @DisplayName("GET /api/performances") void getPerformances() throws Exception { diff --git a/src/test/java/com/thirdparty/ticketing/domain/seat/controller/AdminSeatControllerTest.java b/src/test/java/com/thirdparty/ticketing/domain/seat/controller/AdminSeatControllerTest.java index 93ee6553..5b0a7829 100644 --- a/src/test/java/com/thirdparty/ticketing/domain/seat/controller/AdminSeatControllerTest.java +++ b/src/test/java/com/thirdparty/ticketing/domain/seat/controller/AdminSeatControllerTest.java @@ -9,29 +9,21 @@ import static org.springframework.restdocs.request.RequestDocumentation.pathParameters; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; -import java.util.List; - -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.http.MediaType; -import org.springframework.restdocs.payload.JsonFieldType; -import org.springframework.test.web.servlet.ResultActions; - import com.fasterxml.jackson.core.JsonProcessingException; import com.thirdparty.ticketing.domain.seat.dto.request.SeatCreationElement; import com.thirdparty.ticketing.domain.seat.dto.request.SeatCreationRequest; import com.thirdparty.ticketing.domain.seat.dto.request.SeatGradeCreationElement; import com.thirdparty.ticketing.domain.seat.dto.request.SeatGradeCreationRequest; -import com.thirdparty.ticketing.domain.seat.service.AdminSeatService; import com.thirdparty.ticketing.support.BaseControllerTest; +import java.util.List; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.springframework.http.MediaType; +import org.springframework.restdocs.payload.JsonFieldType; +import org.springframework.test.web.servlet.ResultActions; -@WebMvcTest(AdminSeatController.class) public class AdminSeatControllerTest extends BaseControllerTest { - @MockBean private AdminSeatService adminSeatService; - @Test @DisplayName("관리자 좌석 생성 API") void createSeats() throws Exception { diff --git a/src/test/java/com/thirdparty/ticketing/domain/seat/controller/SeatControllerTest.java b/src/test/java/com/thirdparty/ticketing/domain/seat/controller/SeatControllerTest.java index fe264c74..f25c3fd9 100644 --- a/src/test/java/com/thirdparty/ticketing/domain/seat/controller/SeatControllerTest.java +++ b/src/test/java/com/thirdparty/ticketing/domain/seat/controller/SeatControllerTest.java @@ -11,28 +11,20 @@ import static org.springframework.restdocs.request.RequestDocumentation.pathParameters; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; +import com.thirdparty.ticketing.domain.ItemResult; +import com.thirdparty.ticketing.domain.seat.dto.response.SeatElement; +import com.thirdparty.ticketing.domain.seat.dto.response.SeatGradeElement; +import com.thirdparty.ticketing.support.BaseControllerTest; import java.util.List; - import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; -import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.restdocs.payload.JsonFieldType; import org.springframework.test.web.servlet.ResultActions; -import com.thirdparty.ticketing.domain.ItemResult; -import com.thirdparty.ticketing.domain.seat.dto.response.SeatElement; -import com.thirdparty.ticketing.domain.seat.dto.response.SeatGradeElement; -import com.thirdparty.ticketing.domain.seat.service.SeatService; -import com.thirdparty.ticketing.support.BaseControllerTest; - -@WebMvcTest(SeatController.class) public class SeatControllerTest extends BaseControllerTest { public static final String PERFORMANCE_ID = "performanceId"; - @MockBean private SeatService seatService; - @Test @DisplayName("구역의 좌석 목록을 조회한다.") void getSeats() throws Exception { diff --git a/src/test/java/com/thirdparty/ticketing/domain/ticket/controller/TicketControllerTest.java b/src/test/java/com/thirdparty/ticketing/domain/ticket/controller/TicketControllerTest.java index 7a98b9ee..ee48b69b 100644 --- a/src/test/java/com/thirdparty/ticketing/domain/ticket/controller/TicketControllerTest.java +++ b/src/test/java/com/thirdparty/ticketing/domain/ticket/controller/TicketControllerTest.java @@ -11,18 +11,6 @@ import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; -import java.time.ZonedDateTime; -import java.util.List; -import java.util.UUID; - -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.http.MediaType; -import org.springframework.restdocs.payload.JsonFieldType; -import org.springframework.test.web.servlet.ResultActions; - import com.thirdparty.ticketing.domain.ItemResult; import com.thirdparty.ticketing.domain.performance.dto.PerformanceElement; import com.thirdparty.ticketing.domain.seat.dto.response.SeatGradeElement; @@ -30,17 +18,19 @@ import com.thirdparty.ticketing.domain.ticket.dto.request.TicketPaymentRequest; import com.thirdparty.ticketing.domain.ticket.dto.response.TicketElement; import com.thirdparty.ticketing.domain.ticket.dto.response.TicketSeatDetail; -import com.thirdparty.ticketing.domain.ticket.service.ReservationService; -import com.thirdparty.ticketing.domain.ticket.service.TicketService; import com.thirdparty.ticketing.support.BaseControllerTest; +import java.time.ZonedDateTime; +import java.util.List; +import java.util.UUID; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.springframework.http.MediaType; +import org.springframework.restdocs.payload.JsonFieldType; +import org.springframework.test.web.servlet.ResultActions; -@WebMvcTest(controllers = TicketController.class) class TicketControllerTest extends BaseControllerTest { public static final String PERFORMANCE_ID = "performanceId"; - @MockBean private TicketService ticketService; - - @MockBean private ReservationService reservationService; @Test @DisplayName("티켓 조회 API 호출 시") diff --git a/src/test/java/com/thirdparty/ticketing/domain/waitingsystem/WaitingControllerTest.java b/src/test/java/com/thirdparty/ticketing/domain/waitingsystem/WaitingControllerTest.java index f5eae046..78c12505 100644 --- a/src/test/java/com/thirdparty/ticketing/domain/waitingsystem/WaitingControllerTest.java +++ b/src/test/java/com/thirdparty/ticketing/domain/waitingsystem/WaitingControllerTest.java @@ -21,13 +21,10 @@ import com.thirdparty.ticketing.support.BaseControllerTest; -@WebMvcTest(controllers = WaitingController.class) class WaitingControllerTest extends BaseControllerTest { public static final String PERFORMANCE_ID = "performanceId"; - @MockBean private WaitingSystem waitingSystem; - @Test @DisplayName("남은 대기 순번 조회 API 호출 시") void getRemainingCount() throws Exception { diff --git a/src/test/java/com/thirdparty/ticketing/domain/zone/controller/AdminZoneControllerTest.java b/src/test/java/com/thirdparty/ticketing/domain/zone/controller/AdminZoneControllerTest.java index 25f5ed12..2f2a689f 100644 --- a/src/test/java/com/thirdparty/ticketing/domain/zone/controller/AdminZoneControllerTest.java +++ b/src/test/java/com/thirdparty/ticketing/domain/zone/controller/AdminZoneControllerTest.java @@ -9,28 +9,19 @@ import static org.springframework.restdocs.request.RequestDocumentation.pathParameters; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.thirdparty.ticketing.domain.zone.dto.ZoneCreationElement; +import com.thirdparty.ticketing.domain.zone.dto.ZoneCreationRequest; +import com.thirdparty.ticketing.support.BaseControllerTest; import java.util.List; - import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; -import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.http.MediaType; import org.springframework.restdocs.payload.JsonFieldType; import org.springframework.test.web.servlet.ResultActions; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.thirdparty.ticketing.domain.zone.contoller.AdminZoneController; -import com.thirdparty.ticketing.domain.zone.dto.ZoneCreationElement; -import com.thirdparty.ticketing.domain.zone.dto.ZoneCreationRequest; -import com.thirdparty.ticketing.domain.zone.service.AdminZoneService; -import com.thirdparty.ticketing.support.BaseControllerTest; - -@WebMvcTest(AdminZoneController.class) public class AdminZoneControllerTest extends BaseControllerTest { - @MockBean private AdminZoneService adminZoneService; - @Test @DisplayName("POST /api/performances/{performanceId}/zones") void createZones() throws Exception { diff --git a/src/test/java/com/thirdparty/ticketing/domain/zone/controller/UserZoneControllerTest.java b/src/test/java/com/thirdparty/ticketing/domain/zone/controller/UserZoneControllerTest.java index 5ecfa071..0ccc9339 100644 --- a/src/test/java/com/thirdparty/ticketing/domain/zone/controller/UserZoneControllerTest.java +++ b/src/test/java/com/thirdparty/ticketing/domain/zone/controller/UserZoneControllerTest.java @@ -1,32 +1,25 @@ package com.thirdparty.ticketing.domain.zone.controller; -import static org.mockito.BDDMockito.*; +import static org.mockito.BDDMockito.given; import static org.springframework.restdocs.headers.HeaderDocumentation.headerWithName; import static org.springframework.restdocs.headers.HeaderDocumentation.requestHeaders; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*; -import static org.springframework.restdocs.payload.PayloadDocumentation.*; -import static org.springframework.restdocs.request.RequestDocumentation.*; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; +import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get; +import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath; +import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields; +import static org.springframework.restdocs.request.RequestDocumentation.parameterWithName; +import static org.springframework.restdocs.request.RequestDocumentation.pathParameters; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; +import com.thirdparty.ticketing.domain.ItemResult; +import com.thirdparty.ticketing.domain.zone.dto.ZoneElement; +import com.thirdparty.ticketing.support.BaseControllerTest; import java.util.List; - import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; -import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.test.web.servlet.ResultActions; -import com.thirdparty.ticketing.domain.ItemResult; -import com.thirdparty.ticketing.domain.zone.contoller.UserZoneController; -import com.thirdparty.ticketing.domain.zone.dto.ZoneElement; -import com.thirdparty.ticketing.domain.zone.service.UserZoneService; -import com.thirdparty.ticketing.support.BaseControllerTest; - -@WebMvcTest(UserZoneController.class) class UserZoneControllerTest extends BaseControllerTest { - @MockBean private UserZoneService userZoneService; - @Test @DisplayName("GET /api/performances/{performanceId}/zones") void getZones() throws Exception { diff --git a/src/test/java/com/thirdparty/ticketing/global/security/LoginMemberArgumentResolverTest.java b/src/test/java/com/thirdparty/ticketing/global/security/LoginMemberArgumentResolverTest.java index ac8d9bea..2485d265 100644 --- a/src/test/java/com/thirdparty/ticketing/global/security/LoginMemberArgumentResolverTest.java +++ b/src/test/java/com/thirdparty/ticketing/global/security/LoginMemberArgumentResolverTest.java @@ -3,35 +3,19 @@ import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; +import com.thirdparty.ticketing.domain.member.Member; +import com.thirdparty.ticketing.domain.member.MemberRole; +import com.thirdparty.ticketing.support.BaseControllerTest; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; import org.springframework.test.web.servlet.ResultActions; import org.springframework.test.web.servlet.result.MockMvcResultMatchers; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; -import com.thirdparty.ticketing.domain.common.LoginMember; -import com.thirdparty.ticketing.domain.member.Member; -import com.thirdparty.ticketing.domain.member.MemberRole; -import com.thirdparty.ticketing.global.security.LoginMemberArgumentResolverTest.ResolverTestController; -import com.thirdparty.ticketing.support.BaseControllerTest; - -@WebMvcTest(controllers = ResolverTestController.class) class LoginMemberArgumentResolverTest extends BaseControllerTest { - @RestController - @RequestMapping("/api/test/resolver") - public static class ResolverTestController { - @GetMapping - public String resolve(@LoginMember String email) { - return email; - } - } @Nested @DisplayName("핸들러 메서드 파라미터에 @LoginMember가 포함되어 있으면") diff --git a/src/test/java/com/thirdparty/ticketing/support/BaseControllerTest.java b/src/test/java/com/thirdparty/ticketing/support/BaseControllerTest.java index 1556d426..4365ca5a 100644 --- a/src/test/java/com/thirdparty/ticketing/support/BaseControllerTest.java +++ b/src/test/java/com/thirdparty/ticketing/support/BaseControllerTest.java @@ -6,10 +6,32 @@ import static org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers.springSecurity; import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.thirdparty.ticketing.domain.member.Member; +import com.thirdparty.ticketing.domain.member.MemberRole; +import com.thirdparty.ticketing.domain.member.service.AuthService; +import com.thirdparty.ticketing.domain.member.service.JwtProvider; +import com.thirdparty.ticketing.domain.member.service.MemberService; +import com.thirdparty.ticketing.domain.performance.service.AdminPerformanceService; +import com.thirdparty.ticketing.domain.performance.service.UserPerformanceService; +import com.thirdparty.ticketing.domain.seat.service.AdminSeatService; +import com.thirdparty.ticketing.domain.seat.service.SeatService; +import com.thirdparty.ticketing.domain.ticket.service.ReservationService; +import com.thirdparty.ticketing.domain.ticket.service.TicketService; +import com.thirdparty.ticketing.domain.waitingsystem.WaitingSystem; +import com.thirdparty.ticketing.domain.zone.service.AdminZoneService; +import com.thirdparty.ticketing.domain.zone.service.UserZoneService; +import com.thirdparty.ticketing.global.config.SecurityConfig; +import com.thirdparty.ticketing.global.config.WebConfig; +import com.thirdparty.ticketing.support.BaseControllerTest.RestDocsConfig; +import com.thirdparty.ticketing.support.controller.DocsController; +import com.thirdparty.ticketing.support.controller.ResolverTestController; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; import org.springframework.boot.test.context.TestConfiguration; +import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Import; import org.springframework.restdocs.RestDocumentationContextProvider; @@ -21,15 +43,8 @@ import org.springframework.web.context.WebApplicationContext; import org.springframework.web.filter.CharacterEncodingFilter; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.thirdparty.ticketing.domain.member.Member; -import com.thirdparty.ticketing.domain.member.MemberRole; -import com.thirdparty.ticketing.domain.member.service.JwtProvider; -import com.thirdparty.ticketing.global.config.SecurityConfig; -import com.thirdparty.ticketing.global.config.WebConfig; -import com.thirdparty.ticketing.support.BaseControllerTest.RestDocsConfig; - -@Import({RestDocsConfig.class, SecurityConfig.class, WebConfig.class}) +@WebMvcTest +@Import({RestDocsConfig.class, SecurityConfig.class, WebConfig.class, DocsController.class, ResolverTestController.class}) @ExtendWith(RestDocumentationExtension.class) public abstract class BaseControllerTest { @@ -39,14 +54,47 @@ public abstract class BaseControllerTest { @Autowired protected ObjectMapper objectMapper; + @Autowired protected RestDocumentationResultHandler restDocs; + + @MockBean + protected MemberService memberService; + + @MockBean + protected TicketService ticketService; + + @MockBean + protected AdminPerformanceService adminPerformanceService; + + @MockBean + protected UserPerformanceService userPerformanceService; + + @MockBean + protected AdminSeatService adminSeatService; + + @MockBean + protected SeatService seatService; + + @MockBean + protected AdminZoneService adminZoneService; + + @MockBean + protected UserZoneService userZoneService; + + @MockBean + protected ReservationService reservationService; + + @MockBean + protected AuthService authService; + + @MockBean + protected WaitingSystem waitingSystem; + protected String adminBearerToken; protected String userBearerToken; protected MockMvc mockMvc; - @Autowired protected RestDocumentationResultHandler restDocs; - @TestConfiguration public static class RestDocsConfig { diff --git a/src/test/java/com/thirdparty/ticketing/support/controller/DocsController.java b/src/test/java/com/thirdparty/ticketing/support/controller/DocsController.java new file mode 100644 index 00000000..8f83e231 --- /dev/null +++ b/src/test/java/com/thirdparty/ticketing/support/controller/DocsController.java @@ -0,0 +1,35 @@ +package com.thirdparty.ticketing.support.controller; + +import java.util.HashMap; +import java.util.Map; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("/test/docs") +public class DocsController { + + public record HelloRequest(String name) {} + + @GetMapping("/hello") + public ResponseEntity> hello(@RequestParam("name") String name) { + Map map = new HashMap<>(); + map.put("hello", name); + return ResponseEntity.ok(map); + } + + @PostMapping("/hello/{test}") + public ResponseEntity> hello2( + @PathVariable("test") Long testVariable, @RequestBody HelloRequest request) { + Map map = new HashMap<>(); + map.put("hello", request.name); + map.put("pathVariable", testVariable.toString()); + return ResponseEntity.ok(map); + } +} \ No newline at end of file diff --git a/src/test/java/com/thirdparty/ticketing/support/DocumentationTest.java b/src/test/java/com/thirdparty/ticketing/support/controller/DocumentationTest.java similarity index 67% rename from src/test/java/com/thirdparty/ticketing/support/DocumentationTest.java rename to src/test/java/com/thirdparty/ticketing/support/controller/DocumentationTest.java index 1441adc8..dcbcb1b7 100644 --- a/src/test/java/com/thirdparty/ticketing/support/DocumentationTest.java +++ b/src/test/java/com/thirdparty/ticketing/support/controller/DocumentationTest.java @@ -1,4 +1,4 @@ -package com.thirdparty.ticketing.support; +package com.thirdparty.ticketing.support.controller; import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get; import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.post; @@ -10,55 +10,17 @@ import static org.springframework.restdocs.request.RequestDocumentation.queryParameters; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; -import java.util.HashMap; -import java.util.Map; - +import com.thirdparty.ticketing.support.BaseControllerTest; +import com.thirdparty.ticketing.support.controller.DocsController.HelloRequest; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; -import org.springframework.context.annotation.Import; import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; import org.springframework.restdocs.payload.JsonFieldType; import org.springframework.test.web.servlet.ResultActions; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import com.thirdparty.ticketing.support.DocumentationTest.DocsController; -@WebMvcTest(controllers = DocumentationTest.class) -@Import(DocsController.class) @DisplayName("API 문서 테스트 코드 작성 시") public class DocumentationTest extends BaseControllerTest { - public record HelloRequest(String name) {} - - @RestController - @RequestMapping("/test/docs") - public static class DocsController { - - @GetMapping("/hello") - public ResponseEntity> hello(@RequestParam("name") String name) { - Map map = new HashMap<>(); - map.put("hello", name); - return ResponseEntity.ok(map); - } - - @PostMapping("/hello/{test}") - public ResponseEntity> hello2( - @PathVariable("test") Long testVariable, @RequestBody HelloRequest request) { - Map map = new HashMap<>(); - map.put("hello", request.name); - map.put("pathVariable", testVariable.toString()); - return ResponseEntity.ok(map); - } - } - @Test @DisplayName("GET 요청을 다음과 같이 문서화 할 수 있다.") public void getDocs() throws Exception { diff --git a/src/test/java/com/thirdparty/ticketing/support/controller/ResolverTestController.java b/src/test/java/com/thirdparty/ticketing/support/controller/ResolverTestController.java new file mode 100644 index 00000000..b801c95a --- /dev/null +++ b/src/test/java/com/thirdparty/ticketing/support/controller/ResolverTestController.java @@ -0,0 +1,16 @@ +package com.thirdparty.ticketing.support.controller; + +import com.thirdparty.ticketing.domain.common.LoginMember; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("/api/test/resolver") +public class ResolverTestController { + + @GetMapping + public String resolve(@LoginMember String email) { + return email; + } +} \ No newline at end of file From 40a96b68410e345a955a2ef9ab6b5b872ee54ab3 Mon Sep 17 00:00:00 2001 From: hseong3243 Date: Tue, 27 Aug 2024 20:25:24 +0900 Subject: [PATCH 2/4] =?UTF-8?q?test:=20=ED=86=B5=ED=95=A9=20=ED=85=8C?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=20=EB=B9=88=20=EA=B5=AC=EC=84=B1=20=ED=86=B5?= =?UTF-8?q?=EC=9D=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 애플리케이션 컨텍스트 캐싱을 활용하기 위해 통합 테스트 빈 구성을 통일함. --- .../ticket/service/CacheReservationTest.java | 4 +- .../service/PersistenceReservationTest.java | 14 ++---- .../waitingsystem/WaitingAspectTest.java | 38 ++++----------- .../waitingsystem/WaitingSystemTest.java | 4 +- .../config/ProductionRedisConfigTest.java | 8 ++-- .../WaitingEventListenerTest.java | 4 +- .../memory/MemoryDebounceAspectTest.java | 4 +- .../redis/DebounceAspectTest.java | 46 ++---------------- .../running/RedisRunningCounterTest.java | 4 +- .../running/RedisRunningManagerTest.java | 4 +- .../redis/running/RedisRunningRoomTest.java | 10 ++-- .../waiting/RedisWaitingCounterTest.java | 8 +--- .../redis/waiting/RedisWaitingLineTest.java | 14 ++---- .../waiting/RedisWaitingManagerTest.java | 4 +- .../redis/waiting/RedisWaitingRoomTest.java | 4 +- .../support/BaseIntegrationTest.java | 25 ++++++++++ .../support/integration/AspectTestConfig.java | 47 +++++++++++++++++++ 17 files changed, 118 insertions(+), 124 deletions(-) create mode 100644 src/test/java/com/thirdparty/ticketing/support/BaseIntegrationTest.java create mode 100644 src/test/java/com/thirdparty/ticketing/support/integration/AspectTestConfig.java diff --git a/src/test/java/com/thirdparty/ticketing/domain/ticket/service/CacheReservationTest.java b/src/test/java/com/thirdparty/ticketing/domain/ticket/service/CacheReservationTest.java index 188f8d21..03328d49 100644 --- a/src/test/java/com/thirdparty/ticketing/domain/ticket/service/CacheReservationTest.java +++ b/src/test/java/com/thirdparty/ticketing/domain/ticket/service/CacheReservationTest.java @@ -2,6 +2,7 @@ import static org.assertj.core.api.AssertionsForClassTypes.assertThat; +import com.thirdparty.ticketing.support.BaseIntegrationTest; import java.time.ZonedDateTime; import java.util.List; import java.util.concurrent.CountDownLatch; @@ -35,8 +36,7 @@ import com.thirdparty.ticketing.domain.zone.repository.ZoneRepository; import com.thirdparty.ticketing.support.TestContainerStarter; -@SpringBootTest -public class CacheReservationTest extends TestContainerStarter { +public class CacheReservationTest extends BaseIntegrationTest { @Autowired private SeatRepository seatRepository; diff --git a/src/test/java/com/thirdparty/ticketing/domain/ticket/service/PersistenceReservationTest.java b/src/test/java/com/thirdparty/ticketing/domain/ticket/service/PersistenceReservationTest.java index 91bfb73b..9d4ed65b 100644 --- a/src/test/java/com/thirdparty/ticketing/domain/ticket/service/PersistenceReservationTest.java +++ b/src/test/java/com/thirdparty/ticketing/domain/ticket/service/PersistenceReservationTest.java @@ -2,6 +2,10 @@ import static org.assertj.core.api.AssertionsForClassTypes.assertThat; +import com.thirdparty.ticketing.domain.common.TicketingException; +import com.thirdparty.ticketing.domain.ticket.dto.request.SeatSelectionRequest; +import com.thirdparty.ticketing.domain.ticket.dto.request.TicketPaymentRequest; +import com.thirdparty.ticketing.support.BaseIntegrationTest; import java.util.List; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutorService; @@ -9,7 +13,6 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.IntStream; - import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; @@ -17,7 +20,6 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.boot.test.context.SpringBootTest; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; import org.springframework.security.core.Authentication; import org.springframework.security.core.context.SecurityContext; @@ -26,13 +28,7 @@ import org.springframework.test.context.jdbc.SqlConfig; import org.springframework.transaction.annotation.Transactional; -import com.thirdparty.ticketing.domain.common.TicketingException; -import com.thirdparty.ticketing.domain.ticket.dto.request.SeatSelectionRequest; -import com.thirdparty.ticketing.domain.ticket.dto.request.TicketPaymentRequest; -import com.thirdparty.ticketing.support.TestContainerStarter; - -@SpringBootTest -public class PersistenceReservationTest extends TestContainerStarter { +public class PersistenceReservationTest extends BaseIntegrationTest { private static final Logger log = LoggerFactory.getLogger(PersistenceReservationTest.class); @Autowired diff --git a/src/test/java/com/thirdparty/ticketing/domain/waitingsystem/WaitingAspectTest.java b/src/test/java/com/thirdparty/ticketing/domain/waitingsystem/WaitingAspectTest.java index ae837c86..f48fe0fd 100644 --- a/src/test/java/com/thirdparty/ticketing/domain/waitingsystem/WaitingAspectTest.java +++ b/src/test/java/com/thirdparty/ticketing/domain/waitingsystem/WaitingAspectTest.java @@ -4,37 +4,25 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; +import com.thirdparty.ticketing.domain.member.Member; +import com.thirdparty.ticketing.domain.member.MemberRole; +import com.thirdparty.ticketing.domain.member.service.JwtProvider; +import com.thirdparty.ticketing.domain.waitingsystem.waiting.WaitingMember; +import com.thirdparty.ticketing.global.waitingsystem.redis.running.RedisRunningRoom; +import com.thirdparty.ticketing.global.waitingsystem.redis.waiting.RedisWaitingLine; +import com.thirdparty.ticketing.support.BaseIntegrationTest; import java.time.ZonedDateTime; import java.util.Set; - import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.context.annotation.Import; import org.springframework.data.redis.core.StringRedisTemplate; -import org.springframework.http.ResponseEntity; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.ResultActions; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -import com.thirdparty.ticketing.domain.member.Member; -import com.thirdparty.ticketing.domain.member.MemberRole; -import com.thirdparty.ticketing.domain.member.service.JwtProvider; -import com.thirdparty.ticketing.domain.waitingsystem.WaitingAspectTest.TestController; -import com.thirdparty.ticketing.domain.waitingsystem.waiting.WaitingMember; -import com.thirdparty.ticketing.global.waitingsystem.redis.running.RedisRunningRoom; -import com.thirdparty.ticketing.global.waitingsystem.redis.waiting.RedisWaitingLine; -import com.thirdparty.ticketing.support.TestContainerStarter; -@SpringBootTest -@AutoConfigureMockMvc -@Import(TestController.class) -class WaitingAspectTest extends TestContainerStarter { +class WaitingAspectTest extends BaseIntegrationTest { private static final String AUTHORIZATION_HEADER = "Authorization"; @@ -48,16 +36,6 @@ class WaitingAspectTest extends TestContainerStarter { @Autowired private RedisWaitingLine waitingLine; - @RestController - static class TestController { - - @Waiting - @GetMapping("/api/waiting/test") - public ResponseEntity test() { - return ResponseEntity.ok("test"); - } - } - @BeforeEach void setUp() { redisTemplate.getConnectionFactory().getConnection().commands().flushAll(); diff --git a/src/test/java/com/thirdparty/ticketing/domain/waitingsystem/WaitingSystemTest.java b/src/test/java/com/thirdparty/ticketing/domain/waitingsystem/WaitingSystemTest.java index 3154ca3c..080a9a59 100644 --- a/src/test/java/com/thirdparty/ticketing/domain/waitingsystem/WaitingSystemTest.java +++ b/src/test/java/com/thirdparty/ticketing/domain/waitingsystem/WaitingSystemTest.java @@ -4,6 +4,7 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.assertj.core.api.Assertions.catchException; +import com.thirdparty.ticketing.support.BaseIntegrationTest; import java.time.ZonedDateTime; import java.util.Set; @@ -29,8 +30,7 @@ import com.thirdparty.ticketing.support.SpyEventPublisher; import com.thirdparty.ticketing.support.TestContainerStarter; -@SpringBootTest -class WaitingSystemTest extends TestContainerStarter { +class WaitingSystemTest extends BaseIntegrationTest { private WaitingSystem waitingSystem; diff --git a/src/test/java/com/thirdparty/ticketing/global/config/ProductionRedisConfigTest.java b/src/test/java/com/thirdparty/ticketing/global/config/ProductionRedisConfigTest.java index 9d0dcb81..0747d7d6 100644 --- a/src/test/java/com/thirdparty/ticketing/global/config/ProductionRedisConfigTest.java +++ b/src/test/java/com/thirdparty/ticketing/global/config/ProductionRedisConfigTest.java @@ -2,16 +2,14 @@ import static org.assertj.core.api.Assertions.assertThat; +import com.thirdparty.ticketing.support.BaseIntegrationTest; +import com.thirdparty.ticketing.support.TestContainerStarter; import org.junit.jupiter.api.Test; import org.redisson.api.RedissonClient; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; import org.springframework.data.redis.core.StringRedisTemplate; -import com.thirdparty.ticketing.support.TestContainerStarter; - -@SpringBootTest -class ProductionRedisConfigTest extends TestContainerStarter { +class ProductionRedisConfigTest extends BaseIntegrationTest { @Autowired private RedissonClient redissonClient; diff --git a/src/test/java/com/thirdparty/ticketing/global/waitingsystem/WaitingEventListenerTest.java b/src/test/java/com/thirdparty/ticketing/global/waitingsystem/WaitingEventListenerTest.java index 8365fe19..40ac0d69 100644 --- a/src/test/java/com/thirdparty/ticketing/global/waitingsystem/WaitingEventListenerTest.java +++ b/src/test/java/com/thirdparty/ticketing/global/waitingsystem/WaitingEventListenerTest.java @@ -2,6 +2,7 @@ import static org.assertj.core.api.Assertions.assertThat; +import com.thirdparty.ticketing.support.BaseIntegrationTest; import java.util.Set; import org.junit.jupiter.api.BeforeEach; @@ -17,8 +18,7 @@ import com.thirdparty.ticketing.domain.waitingsystem.WaitingSystem; import com.thirdparty.ticketing.support.TestContainerStarter; -@SpringBootTest -class WaitingEventListenerTest extends TestContainerStarter { +class WaitingEventListenerTest extends BaseIntegrationTest { @Autowired private WaitingSystem waitingSystem; diff --git a/src/test/java/com/thirdparty/ticketing/global/waitingsystem/memory/MemoryDebounceAspectTest.java b/src/test/java/com/thirdparty/ticketing/global/waitingsystem/memory/MemoryDebounceAspectTest.java index 8ce9c66f..5bb522a1 100644 --- a/src/test/java/com/thirdparty/ticketing/global/waitingsystem/memory/MemoryDebounceAspectTest.java +++ b/src/test/java/com/thirdparty/ticketing/global/waitingsystem/memory/MemoryDebounceAspectTest.java @@ -2,13 +2,13 @@ import static org.assertj.core.api.Assertions.assertThat; +import com.thirdparty.ticketing.domain.waitingsystem.Debounce; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; - import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.DisplayName; @@ -22,8 +22,6 @@ import org.springframework.context.annotation.Import; import org.springframework.test.context.junit.jupiter.SpringExtension; -import com.thirdparty.ticketing.domain.waitingsystem.Debounce; - @ExtendWith(SpringExtension.class) @Import(MemoryDebounceAspectTest.MemoryDebounceAopConfig.class) class MemoryDebounceAspectTest { diff --git a/src/test/java/com/thirdparty/ticketing/global/waitingsystem/redis/DebounceAspectTest.java b/src/test/java/com/thirdparty/ticketing/global/waitingsystem/redis/DebounceAspectTest.java index 71142e34..6fc6f78e 100644 --- a/src/test/java/com/thirdparty/ticketing/global/waitingsystem/redis/DebounceAspectTest.java +++ b/src/test/java/com/thirdparty/ticketing/global/waitingsystem/redis/DebounceAspectTest.java @@ -2,56 +2,20 @@ import static org.assertj.core.api.Assertions.assertThat; +import com.thirdparty.ticketing.support.BaseIntegrationTest; +import com.thirdparty.ticketing.support.integration.AspectTestConfig.DebounceTarget; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; -import java.util.concurrent.atomic.AtomicInteger; - import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.context.TestConfiguration; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Import; - -import com.thirdparty.ticketing.domain.waitingsystem.Debounce; -import com.thirdparty.ticketing.global.waitingsystem.redis.DebounceAspectTest.TestConfig; -import com.thirdparty.ticketing.support.TestContainerStarter; - -@SpringBootTest -@Import(TestConfig.class) -class DebounceAspectTest extends TestContainerStarter { - - @Autowired private DebounceTarget debounceTarget; - - @TestConfiguration - static class TestConfig { - - @Bean - public DebounceTarget debounceTarget() { - return new DebounceTarget(); - } - } - static class DebounceTarget { +class DebounceAspectTest extends BaseIntegrationTest { - private final AtomicInteger counter; - - public DebounceTarget() { - counter = new AtomicInteger(0); - } - - @Debounce - public void increment() { - counter.incrementAndGet(); - } - - public int get() { - return counter.get(); - } - } + @Autowired + private DebounceTarget debounceTarget; @Nested @DisplayName("디바운스 aop 적용 시") diff --git a/src/test/java/com/thirdparty/ticketing/global/waitingsystem/redis/running/RedisRunningCounterTest.java b/src/test/java/com/thirdparty/ticketing/global/waitingsystem/redis/running/RedisRunningCounterTest.java index 9be775ab..34de9c66 100644 --- a/src/test/java/com/thirdparty/ticketing/global/waitingsystem/redis/running/RedisRunningCounterTest.java +++ b/src/test/java/com/thirdparty/ticketing/global/waitingsystem/redis/running/RedisRunningCounterTest.java @@ -2,6 +2,7 @@ import static org.assertj.core.api.Assertions.assertThat; +import com.thirdparty.ticketing.support.BaseIntegrationTest; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; @@ -19,8 +20,7 @@ import com.thirdparty.ticketing.support.TestContainerStarter; -@SpringBootTest -class RedisRunningCounterTest extends TestContainerStarter { +class RedisRunningCounterTest extends BaseIntegrationTest { @Autowired private RedisRunningCounter runningCounter; diff --git a/src/test/java/com/thirdparty/ticketing/global/waitingsystem/redis/running/RedisRunningManagerTest.java b/src/test/java/com/thirdparty/ticketing/global/waitingsystem/redis/running/RedisRunningManagerTest.java index 469268eb..31cb1af1 100644 --- a/src/test/java/com/thirdparty/ticketing/global/waitingsystem/redis/running/RedisRunningManagerTest.java +++ b/src/test/java/com/thirdparty/ticketing/global/waitingsystem/redis/running/RedisRunningManagerTest.java @@ -2,6 +2,7 @@ import static org.assertj.core.api.Assertions.assertThat; +import com.thirdparty.ticketing.support.BaseIntegrationTest; import java.time.ZonedDateTime; import java.util.HashSet; import java.util.Set; @@ -19,8 +20,7 @@ import com.thirdparty.ticketing.domain.waitingsystem.waiting.WaitingMember; import com.thirdparty.ticketing.support.TestContainerStarter; -@SpringBootTest -class RedisRunningManagerTest extends TestContainerStarter { +class RedisRunningManagerTest extends BaseIntegrationTest { @Autowired private RedisRunningManager runningManager; diff --git a/src/test/java/com/thirdparty/ticketing/global/waitingsystem/redis/running/RedisRunningRoomTest.java b/src/test/java/com/thirdparty/ticketing/global/waitingsystem/redis/running/RedisRunningRoomTest.java index 7f81a964..3f8c26b9 100644 --- a/src/test/java/com/thirdparty/ticketing/global/waitingsystem/redis/running/RedisRunningRoomTest.java +++ b/src/test/java/com/thirdparty/ticketing/global/waitingsystem/redis/running/RedisRunningRoomTest.java @@ -2,11 +2,12 @@ import static org.assertj.core.api.Assertions.assertThat; +import com.thirdparty.ticketing.domain.waitingsystem.waiting.WaitingMember; +import com.thirdparty.ticketing.support.BaseIntegrationTest; import java.time.ZonedDateTime; import java.util.HashSet; import java.util.List; import java.util.Set; - import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Nested; @@ -14,15 +15,10 @@ import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.CsvSource; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.data.redis.core.ZSetOperations; -import com.thirdparty.ticketing.domain.waitingsystem.waiting.WaitingMember; -import com.thirdparty.ticketing.support.TestContainerStarter; - -@SpringBootTest -class RedisRunningRoomTest extends TestContainerStarter { +class RedisRunningRoomTest extends BaseIntegrationTest { @Autowired private RedisRunningRoom runningRoom; diff --git a/src/test/java/com/thirdparty/ticketing/global/waitingsystem/redis/waiting/RedisWaitingCounterTest.java b/src/test/java/com/thirdparty/ticketing/global/waitingsystem/redis/waiting/RedisWaitingCounterTest.java index 57a5a2a4..4a45805b 100644 --- a/src/test/java/com/thirdparty/ticketing/global/waitingsystem/redis/waiting/RedisWaitingCounterTest.java +++ b/src/test/java/com/thirdparty/ticketing/global/waitingsystem/redis/waiting/RedisWaitingCounterTest.java @@ -2,22 +2,18 @@ import static org.assertj.core.api.Assertions.assertThat; +import com.thirdparty.ticketing.support.BaseIntegrationTest; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; - import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; import org.springframework.data.redis.core.StringRedisTemplate; -import com.thirdparty.ticketing.support.TestContainerStarter; - -@SpringBootTest -class RedisWaitingCounterTest extends TestContainerStarter { +class RedisWaitingCounterTest extends BaseIntegrationTest { @Autowired private RedisWaitingCounter waitingCounter; diff --git a/src/test/java/com/thirdparty/ticketing/global/waitingsystem/redis/waiting/RedisWaitingLineTest.java b/src/test/java/com/thirdparty/ticketing/global/waitingsystem/redis/waiting/RedisWaitingLineTest.java index f3fcae14..ffa0ed53 100644 --- a/src/test/java/com/thirdparty/ticketing/global/waitingsystem/redis/waiting/RedisWaitingLineTest.java +++ b/src/test/java/com/thirdparty/ticketing/global/waitingsystem/redis/waiting/RedisWaitingLineTest.java @@ -2,27 +2,23 @@ import static org.assertj.core.api.Assertions.assertThat; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.thirdparty.ticketing.domain.waitingsystem.waiting.WaitingMember; +import com.thirdparty.ticketing.support.BaseIntegrationTest; import java.time.ZonedDateTime; import java.util.ArrayList; import java.util.List; import java.util.Set; - import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.data.redis.core.ZSetOperations; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.thirdparty.ticketing.domain.waitingsystem.waiting.WaitingMember; -import com.thirdparty.ticketing.support.TestContainerStarter; - -@SpringBootTest -class RedisWaitingLineTest extends TestContainerStarter { +class RedisWaitingLineTest extends BaseIntegrationTest { private static final String WAITING_LINE_KEY = "waiting_line:"; diff --git a/src/test/java/com/thirdparty/ticketing/global/waitingsystem/redis/waiting/RedisWaitingManagerTest.java b/src/test/java/com/thirdparty/ticketing/global/waitingsystem/redis/waiting/RedisWaitingManagerTest.java index 9a181569..328805a0 100644 --- a/src/test/java/com/thirdparty/ticketing/global/waitingsystem/redis/waiting/RedisWaitingManagerTest.java +++ b/src/test/java/com/thirdparty/ticketing/global/waitingsystem/redis/waiting/RedisWaitingManagerTest.java @@ -3,6 +3,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.catchException; +import com.thirdparty.ticketing.support.BaseIntegrationTest; import java.util.Optional; import java.util.Set; import java.util.concurrent.CountDownLatch; @@ -27,8 +28,7 @@ import com.thirdparty.ticketing.global.waitingsystem.ObjectMapperUtils; import com.thirdparty.ticketing.support.TestContainerStarter; -@SpringBootTest -class RedisWaitingManagerTest extends TestContainerStarter { +class RedisWaitingManagerTest extends BaseIntegrationTest { @Autowired private RedisWaitingManager waitingManager; diff --git a/src/test/java/com/thirdparty/ticketing/global/waitingsystem/redis/waiting/RedisWaitingRoomTest.java b/src/test/java/com/thirdparty/ticketing/global/waitingsystem/redis/waiting/RedisWaitingRoomTest.java index ca49ad42..7bfdc0c5 100644 --- a/src/test/java/com/thirdparty/ticketing/global/waitingsystem/redis/waiting/RedisWaitingRoomTest.java +++ b/src/test/java/com/thirdparty/ticketing/global/waitingsystem/redis/waiting/RedisWaitingRoomTest.java @@ -3,6 +3,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.catchException; +import com.thirdparty.ticketing.support.BaseIntegrationTest; import java.time.ZonedDateTime; import java.util.Optional; import java.util.Set; @@ -21,8 +22,7 @@ import com.thirdparty.ticketing.global.waitingsystem.ObjectMapperUtils; import com.thirdparty.ticketing.support.TestContainerStarter; -@SpringBootTest -class RedisWaitingRoomTest extends TestContainerStarter { +class RedisWaitingRoomTest extends BaseIntegrationTest { @Autowired private RedisWaitingRoom waitingRoom; diff --git a/src/test/java/com/thirdparty/ticketing/support/BaseIntegrationTest.java b/src/test/java/com/thirdparty/ticketing/support/BaseIntegrationTest.java new file mode 100644 index 00000000..ebfe9c34 --- /dev/null +++ b/src/test/java/com/thirdparty/ticketing/support/BaseIntegrationTest.java @@ -0,0 +1,25 @@ +package com.thirdparty.ticketing.support; + +import com.thirdparty.ticketing.support.integration.AspectTestConfig; +import com.thirdparty.ticketing.support.integration.AspectTestConfig.DebounceTarget; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.context.TestConfiguration; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Import; + + +@SpringBootTest +@AutoConfigureMockMvc +@Import(AspectTestConfig.class) +public class BaseIntegrationTest extends TestContainerStarter { + + @TestConfiguration + static class TestConfig { + + @Bean + public DebounceTarget debounceTarget() { + return new DebounceTarget(); + } + } +} diff --git a/src/test/java/com/thirdparty/ticketing/support/integration/AspectTestConfig.java b/src/test/java/com/thirdparty/ticketing/support/integration/AspectTestConfig.java new file mode 100644 index 00000000..266d2458 --- /dev/null +++ b/src/test/java/com/thirdparty/ticketing/support/integration/AspectTestConfig.java @@ -0,0 +1,47 @@ +package com.thirdparty.ticketing.support.integration; + +import com.thirdparty.ticketing.domain.waitingsystem.Debounce; +import com.thirdparty.ticketing.domain.waitingsystem.Waiting; +import java.util.concurrent.atomic.AtomicInteger; +import org.springframework.boot.test.context.TestConfiguration; +import org.springframework.context.annotation.Bean; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@TestConfiguration +public class AspectTestConfig { + + @Bean + public DebounceTarget debounceTarget() { + return new DebounceTarget(); + } + + public static class DebounceTarget { + + private final AtomicInteger counter; + + public DebounceTarget() { + counter = new AtomicInteger(0); + } + + @Debounce + public void increment() { + counter.incrementAndGet(); + } + + public int get() { + return counter.get(); + } + } + + @RestController + static class TestController { + + @Waiting + @GetMapping("/api/waiting/test") + public ResponseEntity test() { + return ResponseEntity.ok("test"); + } + } +} \ No newline at end of file From c363ba8d05c1a5f59e7f5569547c78371a80a9ac Mon Sep 17 00:00:00 2001 From: hseong3243 Date: Tue, 27 Aug 2024 20:25:59 +0900 Subject: [PATCH 3/4] =?UTF-8?q?setting:=20=EC=84=9C=EB=B8=8C=20=EB=AA=A8?= =?UTF-8?q?=EB=93=88=20=EC=97=85=EB=8D=B0=EC=9D=B4=ED=8A=B8=20=EB=B0=98?= =?UTF-8?q?=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend-config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend-config b/backend-config index bc25ed78..75091bff 160000 --- a/backend-config +++ b/backend-config @@ -1 +1 @@ -Subproject commit bc25ed78260321496eebbcab42412d3b47cadffa +Subproject commit 75091bffbad5c49f25e78b07af93182640c7ea43 From d09219530238928bd3bf61edbab6896c7ac62533 Mon Sep 17 00:00:00 2001 From: hseong3243 Date: Tue, 27 Aug 2024 20:34:37 +0900 Subject: [PATCH 4/4] =?UTF-8?q?refactor:=20=EC=BD=94=EB=93=9C=20=ED=8F=AC?= =?UTF-8?q?=EB=A7=B7=20=EC=A0=95=EB=A0=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../member/controller/AuthControllerTest.java | 7 +- .../controller/MemberControllerTest.java | 7 +- .../AdminPerformanceControllerTest.java | 8 +- .../UserPerformanceControllerTest.java | 8 +- .../controller/AdminSeatControllerTest.java | 14 ++-- .../seat/controller/SeatControllerTest.java | 10 ++- .../controller/TicketControllerTest.java | 18 +++-- .../ticket/service/CacheReservationTest.java | 4 +- .../service/PersistenceReservationTest.java | 10 ++- .../waitingsystem/WaitingAspectTest.java | 16 ++-- .../waitingsystem/WaitingControllerTest.java | 2 - .../waitingsystem/WaitingSystemTest.java | 4 +- .../controller/AdminZoneControllerTest.java | 10 ++- .../controller/UserZoneControllerTest.java | 8 +- .../config/ProductionRedisConfigTest.java | 4 +- .../LoginMemberArgumentResolverTest.java | 9 +-- .../WaitingEventListenerTest.java | 4 +- .../memory/MemoryDebounceAspectTest.java | 4 +- .../redis/DebounceAspectTest.java | 9 ++- .../running/RedisRunningCounterTest.java | 4 +- .../running/RedisRunningManagerTest.java | 4 +- .../redis/running/RedisRunningRoomTest.java | 6 +- .../waiting/RedisWaitingCounterTest.java | 4 +- .../redis/waiting/RedisWaitingLineTest.java | 10 ++- .../waiting/RedisWaitingManagerTest.java | 4 +- .../redis/waiting/RedisWaitingRoomTest.java | 4 +- .../ticketing/support/BaseControllerTest.java | 74 +++++++++---------- .../support/BaseIntegrationTest.java | 4 +- .../support/controller/DocsController.java | 3 +- .../support/controller/DocumentationTest.java | 5 +- .../controller/ResolverTestController.java | 5 +- .../support/integration/AspectTestConfig.java | 8 +- 32 files changed, 152 insertions(+), 139 deletions(-) diff --git a/src/test/java/com/thirdparty/ticketing/domain/member/controller/AuthControllerTest.java b/src/test/java/com/thirdparty/ticketing/domain/member/controller/AuthControllerTest.java index 8103f2b3..96c190b3 100644 --- a/src/test/java/com/thirdparty/ticketing/domain/member/controller/AuthControllerTest.java +++ b/src/test/java/com/thirdparty/ticketing/domain/member/controller/AuthControllerTest.java @@ -8,15 +8,16 @@ import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; -import com.thirdparty.ticketing.domain.member.dto.request.LoginRequest; -import com.thirdparty.ticketing.domain.member.dto.response.LoginResponse; -import com.thirdparty.ticketing.support.BaseControllerTest; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.springframework.http.MediaType; import org.springframework.restdocs.payload.JsonFieldType; import org.springframework.test.web.servlet.ResultActions; +import com.thirdparty.ticketing.domain.member.dto.request.LoginRequest; +import com.thirdparty.ticketing.domain.member.dto.response.LoginResponse; +import com.thirdparty.ticketing.support.BaseControllerTest; + class AuthControllerTest extends BaseControllerTest { @Test diff --git a/src/test/java/com/thirdparty/ticketing/domain/member/controller/MemberControllerTest.java b/src/test/java/com/thirdparty/ticketing/domain/member/controller/MemberControllerTest.java index 7d0d4300..6f88d05a 100644 --- a/src/test/java/com/thirdparty/ticketing/domain/member/controller/MemberControllerTest.java +++ b/src/test/java/com/thirdparty/ticketing/domain/member/controller/MemberControllerTest.java @@ -8,15 +8,16 @@ import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; -import com.thirdparty.ticketing.domain.member.dto.request.MemberCreationRequest; -import com.thirdparty.ticketing.domain.member.dto.response.CreateMemberResponse; -import com.thirdparty.ticketing.support.BaseControllerTest; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.springframework.http.MediaType; import org.springframework.restdocs.payload.JsonFieldType; import org.springframework.test.web.servlet.ResultActions; +import com.thirdparty.ticketing.domain.member.dto.request.MemberCreationRequest; +import com.thirdparty.ticketing.domain.member.dto.response.CreateMemberResponse; +import com.thirdparty.ticketing.support.BaseControllerTest; + class MemberControllerTest extends BaseControllerTest { @Test diff --git a/src/test/java/com/thirdparty/ticketing/domain/performance/controller/AdminPerformanceControllerTest.java b/src/test/java/com/thirdparty/ticketing/domain/performance/controller/AdminPerformanceControllerTest.java index c95eff83..544c010e 100644 --- a/src/test/java/com/thirdparty/ticketing/domain/performance/controller/AdminPerformanceControllerTest.java +++ b/src/test/java/com/thirdparty/ticketing/domain/performance/controller/AdminPerformanceControllerTest.java @@ -7,16 +7,18 @@ import static org.springframework.restdocs.payload.PayloadDocumentation.requestFields; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.thirdparty.ticketing.domain.performance.dto.request.PerformanceCreationRequest; -import com.thirdparty.ticketing.support.BaseControllerTest; import java.time.ZonedDateTime; + import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.springframework.http.MediaType; import org.springframework.restdocs.payload.JsonFieldType; import org.springframework.test.web.servlet.ResultActions; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.thirdparty.ticketing.domain.performance.dto.request.PerformanceCreationRequest; +import com.thirdparty.ticketing.support.BaseControllerTest; + class AdminPerformanceControllerTest extends BaseControllerTest { @Test diff --git a/src/test/java/com/thirdparty/ticketing/domain/performance/controller/UserPerformanceControllerTest.java b/src/test/java/com/thirdparty/ticketing/domain/performance/controller/UserPerformanceControllerTest.java index a85182d2..4258eb82 100644 --- a/src/test/java/com/thirdparty/ticketing/domain/performance/controller/UserPerformanceControllerTest.java +++ b/src/test/java/com/thirdparty/ticketing/domain/performance/controller/UserPerformanceControllerTest.java @@ -6,16 +6,18 @@ import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; -import com.thirdparty.ticketing.domain.ItemResult; -import com.thirdparty.ticketing.domain.performance.dto.PerformanceElement; -import com.thirdparty.ticketing.support.BaseControllerTest; import java.time.ZonedDateTime; import java.util.List; + import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.springframework.restdocs.payload.JsonFieldType; import org.springframework.test.web.servlet.ResultActions; +import com.thirdparty.ticketing.domain.ItemResult; +import com.thirdparty.ticketing.domain.performance.dto.PerformanceElement; +import com.thirdparty.ticketing.support.BaseControllerTest; + class UserPerformanceControllerTest extends BaseControllerTest { @Test diff --git a/src/test/java/com/thirdparty/ticketing/domain/seat/controller/AdminSeatControllerTest.java b/src/test/java/com/thirdparty/ticketing/domain/seat/controller/AdminSeatControllerTest.java index 5b0a7829..31bcea47 100644 --- a/src/test/java/com/thirdparty/ticketing/domain/seat/controller/AdminSeatControllerTest.java +++ b/src/test/java/com/thirdparty/ticketing/domain/seat/controller/AdminSeatControllerTest.java @@ -9,19 +9,21 @@ import static org.springframework.restdocs.request.RequestDocumentation.pathParameters; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.thirdparty.ticketing.domain.seat.dto.request.SeatCreationElement; -import com.thirdparty.ticketing.domain.seat.dto.request.SeatCreationRequest; -import com.thirdparty.ticketing.domain.seat.dto.request.SeatGradeCreationElement; -import com.thirdparty.ticketing.domain.seat.dto.request.SeatGradeCreationRequest; -import com.thirdparty.ticketing.support.BaseControllerTest; import java.util.List; + import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.springframework.http.MediaType; import org.springframework.restdocs.payload.JsonFieldType; import org.springframework.test.web.servlet.ResultActions; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.thirdparty.ticketing.domain.seat.dto.request.SeatCreationElement; +import com.thirdparty.ticketing.domain.seat.dto.request.SeatCreationRequest; +import com.thirdparty.ticketing.domain.seat.dto.request.SeatGradeCreationElement; +import com.thirdparty.ticketing.domain.seat.dto.request.SeatGradeCreationRequest; +import com.thirdparty.ticketing.support.BaseControllerTest; + public class AdminSeatControllerTest extends BaseControllerTest { @Test diff --git a/src/test/java/com/thirdparty/ticketing/domain/seat/controller/SeatControllerTest.java b/src/test/java/com/thirdparty/ticketing/domain/seat/controller/SeatControllerTest.java index f25c3fd9..9754fbce 100644 --- a/src/test/java/com/thirdparty/ticketing/domain/seat/controller/SeatControllerTest.java +++ b/src/test/java/com/thirdparty/ticketing/domain/seat/controller/SeatControllerTest.java @@ -11,16 +11,18 @@ import static org.springframework.restdocs.request.RequestDocumentation.pathParameters; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; -import com.thirdparty.ticketing.domain.ItemResult; -import com.thirdparty.ticketing.domain.seat.dto.response.SeatElement; -import com.thirdparty.ticketing.domain.seat.dto.response.SeatGradeElement; -import com.thirdparty.ticketing.support.BaseControllerTest; import java.util.List; + import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.springframework.restdocs.payload.JsonFieldType; import org.springframework.test.web.servlet.ResultActions; +import com.thirdparty.ticketing.domain.ItemResult; +import com.thirdparty.ticketing.domain.seat.dto.response.SeatElement; +import com.thirdparty.ticketing.domain.seat.dto.response.SeatGradeElement; +import com.thirdparty.ticketing.support.BaseControllerTest; + public class SeatControllerTest extends BaseControllerTest { public static final String PERFORMANCE_ID = "performanceId"; diff --git a/src/test/java/com/thirdparty/ticketing/domain/ticket/controller/TicketControllerTest.java b/src/test/java/com/thirdparty/ticketing/domain/ticket/controller/TicketControllerTest.java index ee48b69b..59d61f2f 100644 --- a/src/test/java/com/thirdparty/ticketing/domain/ticket/controller/TicketControllerTest.java +++ b/src/test/java/com/thirdparty/ticketing/domain/ticket/controller/TicketControllerTest.java @@ -11,23 +11,25 @@ import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; -import com.thirdparty.ticketing.domain.ItemResult; -import com.thirdparty.ticketing.domain.performance.dto.PerformanceElement; -import com.thirdparty.ticketing.domain.seat.dto.response.SeatGradeElement; -import com.thirdparty.ticketing.domain.ticket.dto.request.SeatSelectionRequest; -import com.thirdparty.ticketing.domain.ticket.dto.request.TicketPaymentRequest; -import com.thirdparty.ticketing.domain.ticket.dto.response.TicketElement; -import com.thirdparty.ticketing.domain.ticket.dto.response.TicketSeatDetail; -import com.thirdparty.ticketing.support.BaseControllerTest; import java.time.ZonedDateTime; import java.util.List; import java.util.UUID; + import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.springframework.http.MediaType; import org.springframework.restdocs.payload.JsonFieldType; import org.springframework.test.web.servlet.ResultActions; +import com.thirdparty.ticketing.domain.ItemResult; +import com.thirdparty.ticketing.domain.performance.dto.PerformanceElement; +import com.thirdparty.ticketing.domain.seat.dto.response.SeatGradeElement; +import com.thirdparty.ticketing.domain.ticket.dto.request.SeatSelectionRequest; +import com.thirdparty.ticketing.domain.ticket.dto.request.TicketPaymentRequest; +import com.thirdparty.ticketing.domain.ticket.dto.response.TicketElement; +import com.thirdparty.ticketing.domain.ticket.dto.response.TicketSeatDetail; +import com.thirdparty.ticketing.support.BaseControllerTest; + class TicketControllerTest extends BaseControllerTest { public static final String PERFORMANCE_ID = "performanceId"; diff --git a/src/test/java/com/thirdparty/ticketing/domain/ticket/service/CacheReservationTest.java b/src/test/java/com/thirdparty/ticketing/domain/ticket/service/CacheReservationTest.java index 03328d49..9525f4eb 100644 --- a/src/test/java/com/thirdparty/ticketing/domain/ticket/service/CacheReservationTest.java +++ b/src/test/java/com/thirdparty/ticketing/domain/ticket/service/CacheReservationTest.java @@ -2,7 +2,6 @@ import static org.assertj.core.api.AssertionsForClassTypes.assertThat; -import com.thirdparty.ticketing.support.BaseIntegrationTest; import java.time.ZonedDateTime; import java.util.List; import java.util.concurrent.CountDownLatch; @@ -17,7 +16,6 @@ import org.redisson.api.RedissonClient; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.boot.test.context.SpringBootTest; import com.thirdparty.ticketing.domain.common.LettuceRepository; import com.thirdparty.ticketing.domain.common.TicketingException; @@ -34,7 +32,7 @@ import com.thirdparty.ticketing.domain.ticket.dto.request.SeatSelectionRequest; import com.thirdparty.ticketing.domain.zone.Zone; import com.thirdparty.ticketing.domain.zone.repository.ZoneRepository; -import com.thirdparty.ticketing.support.TestContainerStarter; +import com.thirdparty.ticketing.support.BaseIntegrationTest; public class CacheReservationTest extends BaseIntegrationTest { diff --git a/src/test/java/com/thirdparty/ticketing/domain/ticket/service/PersistenceReservationTest.java b/src/test/java/com/thirdparty/ticketing/domain/ticket/service/PersistenceReservationTest.java index 9d4ed65b..0734901a 100644 --- a/src/test/java/com/thirdparty/ticketing/domain/ticket/service/PersistenceReservationTest.java +++ b/src/test/java/com/thirdparty/ticketing/domain/ticket/service/PersistenceReservationTest.java @@ -2,10 +2,6 @@ import static org.assertj.core.api.AssertionsForClassTypes.assertThat; -import com.thirdparty.ticketing.domain.common.TicketingException; -import com.thirdparty.ticketing.domain.ticket.dto.request.SeatSelectionRequest; -import com.thirdparty.ticketing.domain.ticket.dto.request.TicketPaymentRequest; -import com.thirdparty.ticketing.support.BaseIntegrationTest; import java.util.List; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutorService; @@ -13,6 +9,7 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.IntStream; + import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; @@ -28,6 +25,11 @@ import org.springframework.test.context.jdbc.SqlConfig; import org.springframework.transaction.annotation.Transactional; +import com.thirdparty.ticketing.domain.common.TicketingException; +import com.thirdparty.ticketing.domain.ticket.dto.request.SeatSelectionRequest; +import com.thirdparty.ticketing.domain.ticket.dto.request.TicketPaymentRequest; +import com.thirdparty.ticketing.support.BaseIntegrationTest; + public class PersistenceReservationTest extends BaseIntegrationTest { private static final Logger log = LoggerFactory.getLogger(PersistenceReservationTest.class); diff --git a/src/test/java/com/thirdparty/ticketing/domain/waitingsystem/WaitingAspectTest.java b/src/test/java/com/thirdparty/ticketing/domain/waitingsystem/WaitingAspectTest.java index f48fe0fd..38cc0611 100644 --- a/src/test/java/com/thirdparty/ticketing/domain/waitingsystem/WaitingAspectTest.java +++ b/src/test/java/com/thirdparty/ticketing/domain/waitingsystem/WaitingAspectTest.java @@ -4,15 +4,9 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; -import com.thirdparty.ticketing.domain.member.Member; -import com.thirdparty.ticketing.domain.member.MemberRole; -import com.thirdparty.ticketing.domain.member.service.JwtProvider; -import com.thirdparty.ticketing.domain.waitingsystem.waiting.WaitingMember; -import com.thirdparty.ticketing.global.waitingsystem.redis.running.RedisRunningRoom; -import com.thirdparty.ticketing.global.waitingsystem.redis.waiting.RedisWaitingLine; -import com.thirdparty.ticketing.support.BaseIntegrationTest; import java.time.ZonedDateTime; import java.util.Set; + import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Nested; @@ -22,6 +16,14 @@ import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.ResultActions; +import com.thirdparty.ticketing.domain.member.Member; +import com.thirdparty.ticketing.domain.member.MemberRole; +import com.thirdparty.ticketing.domain.member.service.JwtProvider; +import com.thirdparty.ticketing.domain.waitingsystem.waiting.WaitingMember; +import com.thirdparty.ticketing.global.waitingsystem.redis.running.RedisRunningRoom; +import com.thirdparty.ticketing.global.waitingsystem.redis.waiting.RedisWaitingLine; +import com.thirdparty.ticketing.support.BaseIntegrationTest; + class WaitingAspectTest extends BaseIntegrationTest { private static final String AUTHORIZATION_HEADER = "Authorization"; diff --git a/src/test/java/com/thirdparty/ticketing/domain/waitingsystem/WaitingControllerTest.java b/src/test/java/com/thirdparty/ticketing/domain/waitingsystem/WaitingControllerTest.java index 78c12505..d25188ff 100644 --- a/src/test/java/com/thirdparty/ticketing/domain/waitingsystem/WaitingControllerTest.java +++ b/src/test/java/com/thirdparty/ticketing/domain/waitingsystem/WaitingControllerTest.java @@ -14,8 +14,6 @@ import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; -import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.restdocs.payload.JsonFieldType; import org.springframework.test.web.servlet.ResultActions; diff --git a/src/test/java/com/thirdparty/ticketing/domain/waitingsystem/WaitingSystemTest.java b/src/test/java/com/thirdparty/ticketing/domain/waitingsystem/WaitingSystemTest.java index 080a9a59..7bc4a6e7 100644 --- a/src/test/java/com/thirdparty/ticketing/domain/waitingsystem/WaitingSystemTest.java +++ b/src/test/java/com/thirdparty/ticketing/domain/waitingsystem/WaitingSystemTest.java @@ -4,7 +4,6 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.assertj.core.api.Assertions.catchException; -import com.thirdparty.ticketing.support.BaseIntegrationTest; import java.time.ZonedDateTime; import java.util.Set; @@ -15,7 +14,6 @@ import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.CsvSource; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; import org.springframework.data.redis.core.HashOperations; import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.data.redis.core.ValueOperations; @@ -27,8 +25,8 @@ import com.thirdparty.ticketing.domain.waitingsystem.running.RunningManager; import com.thirdparty.ticketing.domain.waitingsystem.waiting.WaitingManager; import com.thirdparty.ticketing.domain.waitingsystem.waiting.WaitingMember; +import com.thirdparty.ticketing.support.BaseIntegrationTest; import com.thirdparty.ticketing.support.SpyEventPublisher; -import com.thirdparty.ticketing.support.TestContainerStarter; class WaitingSystemTest extends BaseIntegrationTest { diff --git a/src/test/java/com/thirdparty/ticketing/domain/zone/controller/AdminZoneControllerTest.java b/src/test/java/com/thirdparty/ticketing/domain/zone/controller/AdminZoneControllerTest.java index 2f2a689f..3d3b3215 100644 --- a/src/test/java/com/thirdparty/ticketing/domain/zone/controller/AdminZoneControllerTest.java +++ b/src/test/java/com/thirdparty/ticketing/domain/zone/controller/AdminZoneControllerTest.java @@ -9,17 +9,19 @@ import static org.springframework.restdocs.request.RequestDocumentation.pathParameters; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.thirdparty.ticketing.domain.zone.dto.ZoneCreationElement; -import com.thirdparty.ticketing.domain.zone.dto.ZoneCreationRequest; -import com.thirdparty.ticketing.support.BaseControllerTest; import java.util.List; + import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.springframework.http.MediaType; import org.springframework.restdocs.payload.JsonFieldType; import org.springframework.test.web.servlet.ResultActions; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.thirdparty.ticketing.domain.zone.dto.ZoneCreationElement; +import com.thirdparty.ticketing.domain.zone.dto.ZoneCreationRequest; +import com.thirdparty.ticketing.support.BaseControllerTest; + public class AdminZoneControllerTest extends BaseControllerTest { @Test diff --git a/src/test/java/com/thirdparty/ticketing/domain/zone/controller/UserZoneControllerTest.java b/src/test/java/com/thirdparty/ticketing/domain/zone/controller/UserZoneControllerTest.java index 0ccc9339..a184b621 100644 --- a/src/test/java/com/thirdparty/ticketing/domain/zone/controller/UserZoneControllerTest.java +++ b/src/test/java/com/thirdparty/ticketing/domain/zone/controller/UserZoneControllerTest.java @@ -10,14 +10,16 @@ import static org.springframework.restdocs.request.RequestDocumentation.pathParameters; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; -import com.thirdparty.ticketing.domain.ItemResult; -import com.thirdparty.ticketing.domain.zone.dto.ZoneElement; -import com.thirdparty.ticketing.support.BaseControllerTest; import java.util.List; + import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.springframework.test.web.servlet.ResultActions; +import com.thirdparty.ticketing.domain.ItemResult; +import com.thirdparty.ticketing.domain.zone.dto.ZoneElement; +import com.thirdparty.ticketing.support.BaseControllerTest; + class UserZoneControllerTest extends BaseControllerTest { @Test diff --git a/src/test/java/com/thirdparty/ticketing/global/config/ProductionRedisConfigTest.java b/src/test/java/com/thirdparty/ticketing/global/config/ProductionRedisConfigTest.java index 0747d7d6..ae1e3e87 100644 --- a/src/test/java/com/thirdparty/ticketing/global/config/ProductionRedisConfigTest.java +++ b/src/test/java/com/thirdparty/ticketing/global/config/ProductionRedisConfigTest.java @@ -2,13 +2,13 @@ import static org.assertj.core.api.Assertions.assertThat; -import com.thirdparty.ticketing.support.BaseIntegrationTest; -import com.thirdparty.ticketing.support.TestContainerStarter; import org.junit.jupiter.api.Test; import org.redisson.api.RedissonClient; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.core.StringRedisTemplate; +import com.thirdparty.ticketing.support.BaseIntegrationTest; + class ProductionRedisConfigTest extends BaseIntegrationTest { @Autowired private RedissonClient redissonClient; diff --git a/src/test/java/com/thirdparty/ticketing/global/security/LoginMemberArgumentResolverTest.java b/src/test/java/com/thirdparty/ticketing/global/security/LoginMemberArgumentResolverTest.java index 2485d265..65dac40d 100644 --- a/src/test/java/com/thirdparty/ticketing/global/security/LoginMemberArgumentResolverTest.java +++ b/src/test/java/com/thirdparty/ticketing/global/security/LoginMemberArgumentResolverTest.java @@ -3,9 +3,6 @@ import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; -import com.thirdparty.ticketing.domain.member.Member; -import com.thirdparty.ticketing.domain.member.MemberRole; -import com.thirdparty.ticketing.support.BaseControllerTest; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Nested; @@ -13,9 +10,11 @@ import org.springframework.test.web.servlet.ResultActions; import org.springframework.test.web.servlet.result.MockMvcResultMatchers; -class LoginMemberArgumentResolverTest extends BaseControllerTest { - +import com.thirdparty.ticketing.domain.member.Member; +import com.thirdparty.ticketing.domain.member.MemberRole; +import com.thirdparty.ticketing.support.BaseControllerTest; +class LoginMemberArgumentResolverTest extends BaseControllerTest { @Nested @DisplayName("핸들러 메서드 파라미터에 @LoginMember가 포함되어 있으면") diff --git a/src/test/java/com/thirdparty/ticketing/global/waitingsystem/WaitingEventListenerTest.java b/src/test/java/com/thirdparty/ticketing/global/waitingsystem/WaitingEventListenerTest.java index 40ac0d69..b994cd76 100644 --- a/src/test/java/com/thirdparty/ticketing/global/waitingsystem/WaitingEventListenerTest.java +++ b/src/test/java/com/thirdparty/ticketing/global/waitingsystem/WaitingEventListenerTest.java @@ -2,7 +2,6 @@ import static org.assertj.core.api.Assertions.assertThat; -import com.thirdparty.ticketing.support.BaseIntegrationTest; import java.util.Set; import org.junit.jupiter.api.BeforeEach; @@ -10,13 +9,12 @@ import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.data.redis.core.ZSetOperations; import com.thirdparty.ticketing.domain.common.EventPublisher; import com.thirdparty.ticketing.domain.waitingsystem.WaitingSystem; -import com.thirdparty.ticketing.support.TestContainerStarter; +import com.thirdparty.ticketing.support.BaseIntegrationTest; class WaitingEventListenerTest extends BaseIntegrationTest { diff --git a/src/test/java/com/thirdparty/ticketing/global/waitingsystem/memory/MemoryDebounceAspectTest.java b/src/test/java/com/thirdparty/ticketing/global/waitingsystem/memory/MemoryDebounceAspectTest.java index 5bb522a1..8ce9c66f 100644 --- a/src/test/java/com/thirdparty/ticketing/global/waitingsystem/memory/MemoryDebounceAspectTest.java +++ b/src/test/java/com/thirdparty/ticketing/global/waitingsystem/memory/MemoryDebounceAspectTest.java @@ -2,13 +2,13 @@ import static org.assertj.core.api.Assertions.assertThat; -import com.thirdparty.ticketing.domain.waitingsystem.Debounce; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; + import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.DisplayName; @@ -22,6 +22,8 @@ import org.springframework.context.annotation.Import; import org.springframework.test.context.junit.jupiter.SpringExtension; +import com.thirdparty.ticketing.domain.waitingsystem.Debounce; + @ExtendWith(SpringExtension.class) @Import(MemoryDebounceAspectTest.MemoryDebounceAopConfig.class) class MemoryDebounceAspectTest { diff --git a/src/test/java/com/thirdparty/ticketing/global/waitingsystem/redis/DebounceAspectTest.java b/src/test/java/com/thirdparty/ticketing/global/waitingsystem/redis/DebounceAspectTest.java index 6fc6f78e..02a1c176 100644 --- a/src/test/java/com/thirdparty/ticketing/global/waitingsystem/redis/DebounceAspectTest.java +++ b/src/test/java/com/thirdparty/ticketing/global/waitingsystem/redis/DebounceAspectTest.java @@ -2,20 +2,21 @@ import static org.assertj.core.api.Assertions.assertThat; -import com.thirdparty.ticketing.support.BaseIntegrationTest; -import com.thirdparty.ticketing.support.integration.AspectTestConfig.DebounceTarget; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; + import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; +import com.thirdparty.ticketing.support.BaseIntegrationTest; +import com.thirdparty.ticketing.support.integration.AspectTestConfig.DebounceTarget; + class DebounceAspectTest extends BaseIntegrationTest { - @Autowired - private DebounceTarget debounceTarget; + @Autowired private DebounceTarget debounceTarget; @Nested @DisplayName("디바운스 aop 적용 시") diff --git a/src/test/java/com/thirdparty/ticketing/global/waitingsystem/redis/running/RedisRunningCounterTest.java b/src/test/java/com/thirdparty/ticketing/global/waitingsystem/redis/running/RedisRunningCounterTest.java index 34de9c66..ce6ad88d 100644 --- a/src/test/java/com/thirdparty/ticketing/global/waitingsystem/redis/running/RedisRunningCounterTest.java +++ b/src/test/java/com/thirdparty/ticketing/global/waitingsystem/redis/running/RedisRunningCounterTest.java @@ -2,7 +2,6 @@ import static org.assertj.core.api.Assertions.assertThat; -import com.thirdparty.ticketing.support.BaseIntegrationTest; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; @@ -14,11 +13,10 @@ import org.junit.jupiter.api.RepeatedTest; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.data.redis.core.ValueOperations; -import com.thirdparty.ticketing.support.TestContainerStarter; +import com.thirdparty.ticketing.support.BaseIntegrationTest; class RedisRunningCounterTest extends BaseIntegrationTest { diff --git a/src/test/java/com/thirdparty/ticketing/global/waitingsystem/redis/running/RedisRunningManagerTest.java b/src/test/java/com/thirdparty/ticketing/global/waitingsystem/redis/running/RedisRunningManagerTest.java index 31cb1af1..52724c1a 100644 --- a/src/test/java/com/thirdparty/ticketing/global/waitingsystem/redis/running/RedisRunningManagerTest.java +++ b/src/test/java/com/thirdparty/ticketing/global/waitingsystem/redis/running/RedisRunningManagerTest.java @@ -2,7 +2,6 @@ import static org.assertj.core.api.Assertions.assertThat; -import com.thirdparty.ticketing.support.BaseIntegrationTest; import java.time.ZonedDateTime; import java.util.HashSet; import java.util.Set; @@ -12,13 +11,12 @@ import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.data.redis.core.ValueOperations; import org.springframework.data.redis.core.ZSetOperations; import com.thirdparty.ticketing.domain.waitingsystem.waiting.WaitingMember; -import com.thirdparty.ticketing.support.TestContainerStarter; +import com.thirdparty.ticketing.support.BaseIntegrationTest; class RedisRunningManagerTest extends BaseIntegrationTest { diff --git a/src/test/java/com/thirdparty/ticketing/global/waitingsystem/redis/running/RedisRunningRoomTest.java b/src/test/java/com/thirdparty/ticketing/global/waitingsystem/redis/running/RedisRunningRoomTest.java index 3f8c26b9..74c664bd 100644 --- a/src/test/java/com/thirdparty/ticketing/global/waitingsystem/redis/running/RedisRunningRoomTest.java +++ b/src/test/java/com/thirdparty/ticketing/global/waitingsystem/redis/running/RedisRunningRoomTest.java @@ -2,12 +2,11 @@ import static org.assertj.core.api.Assertions.assertThat; -import com.thirdparty.ticketing.domain.waitingsystem.waiting.WaitingMember; -import com.thirdparty.ticketing.support.BaseIntegrationTest; import java.time.ZonedDateTime; import java.util.HashSet; import java.util.List; import java.util.Set; + import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Nested; @@ -18,6 +17,9 @@ import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.data.redis.core.ZSetOperations; +import com.thirdparty.ticketing.domain.waitingsystem.waiting.WaitingMember; +import com.thirdparty.ticketing.support.BaseIntegrationTest; + class RedisRunningRoomTest extends BaseIntegrationTest { @Autowired private RedisRunningRoom runningRoom; diff --git a/src/test/java/com/thirdparty/ticketing/global/waitingsystem/redis/waiting/RedisWaitingCounterTest.java b/src/test/java/com/thirdparty/ticketing/global/waitingsystem/redis/waiting/RedisWaitingCounterTest.java index 4a45805b..b4e2cf5b 100644 --- a/src/test/java/com/thirdparty/ticketing/global/waitingsystem/redis/waiting/RedisWaitingCounterTest.java +++ b/src/test/java/com/thirdparty/ticketing/global/waitingsystem/redis/waiting/RedisWaitingCounterTest.java @@ -2,10 +2,10 @@ import static org.assertj.core.api.Assertions.assertThat; -import com.thirdparty.ticketing.support.BaseIntegrationTest; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; + import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Nested; @@ -13,6 +13,8 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.core.StringRedisTemplate; +import com.thirdparty.ticketing.support.BaseIntegrationTest; + class RedisWaitingCounterTest extends BaseIntegrationTest { @Autowired private RedisWaitingCounter waitingCounter; diff --git a/src/test/java/com/thirdparty/ticketing/global/waitingsystem/redis/waiting/RedisWaitingLineTest.java b/src/test/java/com/thirdparty/ticketing/global/waitingsystem/redis/waiting/RedisWaitingLineTest.java index ffa0ed53..3feb1fa8 100644 --- a/src/test/java/com/thirdparty/ticketing/global/waitingsystem/redis/waiting/RedisWaitingLineTest.java +++ b/src/test/java/com/thirdparty/ticketing/global/waitingsystem/redis/waiting/RedisWaitingLineTest.java @@ -2,14 +2,11 @@ import static org.assertj.core.api.Assertions.assertThat; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.thirdparty.ticketing.domain.waitingsystem.waiting.WaitingMember; -import com.thirdparty.ticketing.support.BaseIntegrationTest; import java.time.ZonedDateTime; import java.util.ArrayList; import java.util.List; import java.util.Set; + import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Nested; @@ -18,6 +15,11 @@ import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.data.redis.core.ZSetOperations; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.thirdparty.ticketing.domain.waitingsystem.waiting.WaitingMember; +import com.thirdparty.ticketing.support.BaseIntegrationTest; + class RedisWaitingLineTest extends BaseIntegrationTest { private static final String WAITING_LINE_KEY = "waiting_line:"; diff --git a/src/test/java/com/thirdparty/ticketing/global/waitingsystem/redis/waiting/RedisWaitingManagerTest.java b/src/test/java/com/thirdparty/ticketing/global/waitingsystem/redis/waiting/RedisWaitingManagerTest.java index 328805a0..f353ab34 100644 --- a/src/test/java/com/thirdparty/ticketing/global/waitingsystem/redis/waiting/RedisWaitingManagerTest.java +++ b/src/test/java/com/thirdparty/ticketing/global/waitingsystem/redis/waiting/RedisWaitingManagerTest.java @@ -3,7 +3,6 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.catchException; -import com.thirdparty.ticketing.support.BaseIntegrationTest; import java.util.Optional; import java.util.Set; import java.util.concurrent.CountDownLatch; @@ -15,7 +14,6 @@ import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; import org.springframework.data.redis.core.HashOperations; import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.data.redis.core.ZSetOperations; @@ -26,7 +24,7 @@ import com.thirdparty.ticketing.domain.common.TicketingException; import com.thirdparty.ticketing.domain.waitingsystem.waiting.WaitingMember; import com.thirdparty.ticketing.global.waitingsystem.ObjectMapperUtils; -import com.thirdparty.ticketing.support.TestContainerStarter; +import com.thirdparty.ticketing.support.BaseIntegrationTest; class RedisWaitingManagerTest extends BaseIntegrationTest { diff --git a/src/test/java/com/thirdparty/ticketing/global/waitingsystem/redis/waiting/RedisWaitingRoomTest.java b/src/test/java/com/thirdparty/ticketing/global/waitingsystem/redis/waiting/RedisWaitingRoomTest.java index 7bfdc0c5..7674f027 100644 --- a/src/test/java/com/thirdparty/ticketing/global/waitingsystem/redis/waiting/RedisWaitingRoomTest.java +++ b/src/test/java/com/thirdparty/ticketing/global/waitingsystem/redis/waiting/RedisWaitingRoomTest.java @@ -3,7 +3,6 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.catchException; -import com.thirdparty.ticketing.support.BaseIntegrationTest; import java.time.ZonedDateTime; import java.util.Optional; import java.util.Set; @@ -13,14 +12,13 @@ import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; import org.springframework.data.redis.core.HashOperations; import org.springframework.data.redis.core.StringRedisTemplate; import com.fasterxml.jackson.databind.ObjectMapper; import com.thirdparty.ticketing.domain.waitingsystem.waiting.WaitingMember; import com.thirdparty.ticketing.global.waitingsystem.ObjectMapperUtils; -import com.thirdparty.ticketing.support.TestContainerStarter; +import com.thirdparty.ticketing.support.BaseIntegrationTest; class RedisWaitingRoomTest extends BaseIntegrationTest { diff --git a/src/test/java/com/thirdparty/ticketing/support/BaseControllerTest.java b/src/test/java/com/thirdparty/ticketing/support/BaseControllerTest.java index 4365ca5a..f4c50aff 100644 --- a/src/test/java/com/thirdparty/ticketing/support/BaseControllerTest.java +++ b/src/test/java/com/thirdparty/ticketing/support/BaseControllerTest.java @@ -6,6 +6,23 @@ import static org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers.springSecurity; import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; +import org.springframework.boot.test.context.TestConfiguration; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Import; +import org.springframework.restdocs.RestDocumentationContextProvider; +import org.springframework.restdocs.RestDocumentationExtension; +import org.springframework.restdocs.mockmvc.MockMvcRestDocumentation; +import org.springframework.restdocs.mockmvc.RestDocumentationResultHandler; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.setup.MockMvcBuilders; +import org.springframework.web.context.WebApplicationContext; +import org.springframework.web.filter.CharacterEncodingFilter; + import com.fasterxml.jackson.databind.ObjectMapper; import com.thirdparty.ticketing.domain.member.Member; import com.thirdparty.ticketing.domain.member.MemberRole; @@ -26,25 +43,15 @@ import com.thirdparty.ticketing.support.BaseControllerTest.RestDocsConfig; import com.thirdparty.ticketing.support.controller.DocsController; import com.thirdparty.ticketing.support.controller.ResolverTestController; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.extension.ExtendWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; -import org.springframework.boot.test.context.TestConfiguration; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Import; -import org.springframework.restdocs.RestDocumentationContextProvider; -import org.springframework.restdocs.RestDocumentationExtension; -import org.springframework.restdocs.mockmvc.MockMvcRestDocumentation; -import org.springframework.restdocs.mockmvc.RestDocumentationResultHandler; -import org.springframework.test.web.servlet.MockMvc; -import org.springframework.test.web.servlet.setup.MockMvcBuilders; -import org.springframework.web.context.WebApplicationContext; -import org.springframework.web.filter.CharacterEncodingFilter; @WebMvcTest -@Import({RestDocsConfig.class, SecurityConfig.class, WebConfig.class, DocsController.class, ResolverTestController.class}) +@Import({ + RestDocsConfig.class, + SecurityConfig.class, + WebConfig.class, + DocsController.class, + ResolverTestController.class +}) @ExtendWith(RestDocumentationExtension.class) public abstract class BaseControllerTest { @@ -56,38 +63,27 @@ public abstract class BaseControllerTest { @Autowired protected RestDocumentationResultHandler restDocs; - @MockBean - protected MemberService memberService; + @MockBean protected MemberService memberService; - @MockBean - protected TicketService ticketService; + @MockBean protected TicketService ticketService; - @MockBean - protected AdminPerformanceService adminPerformanceService; + @MockBean protected AdminPerformanceService adminPerformanceService; - @MockBean - protected UserPerformanceService userPerformanceService; + @MockBean protected UserPerformanceService userPerformanceService; - @MockBean - protected AdminSeatService adminSeatService; + @MockBean protected AdminSeatService adminSeatService; - @MockBean - protected SeatService seatService; + @MockBean protected SeatService seatService; - @MockBean - protected AdminZoneService adminZoneService; + @MockBean protected AdminZoneService adminZoneService; - @MockBean - protected UserZoneService userZoneService; + @MockBean protected UserZoneService userZoneService; - @MockBean - protected ReservationService reservationService; + @MockBean protected ReservationService reservationService; - @MockBean - protected AuthService authService; + @MockBean protected AuthService authService; - @MockBean - protected WaitingSystem waitingSystem; + @MockBean protected WaitingSystem waitingSystem; protected String adminBearerToken; diff --git a/src/test/java/com/thirdparty/ticketing/support/BaseIntegrationTest.java b/src/test/java/com/thirdparty/ticketing/support/BaseIntegrationTest.java index ebfe9c34..2f9d113a 100644 --- a/src/test/java/com/thirdparty/ticketing/support/BaseIntegrationTest.java +++ b/src/test/java/com/thirdparty/ticketing/support/BaseIntegrationTest.java @@ -1,13 +1,13 @@ package com.thirdparty.ticketing.support; -import com.thirdparty.ticketing.support.integration.AspectTestConfig; -import com.thirdparty.ticketing.support.integration.AspectTestConfig.DebounceTarget; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.TestConfiguration; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Import; +import com.thirdparty.ticketing.support.integration.AspectTestConfig; +import com.thirdparty.ticketing.support.integration.AspectTestConfig.DebounceTarget; @SpringBootTest @AutoConfigureMockMvc diff --git a/src/test/java/com/thirdparty/ticketing/support/controller/DocsController.java b/src/test/java/com/thirdparty/ticketing/support/controller/DocsController.java index 8f83e231..dcd3ebf7 100644 --- a/src/test/java/com/thirdparty/ticketing/support/controller/DocsController.java +++ b/src/test/java/com/thirdparty/ticketing/support/controller/DocsController.java @@ -2,6 +2,7 @@ import java.util.HashMap; import java.util.Map; + import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; @@ -32,4 +33,4 @@ public ResponseEntity> hello2( map.put("pathVariable", testVariable.toString()); return ResponseEntity.ok(map); } -} \ No newline at end of file +} diff --git a/src/test/java/com/thirdparty/ticketing/support/controller/DocumentationTest.java b/src/test/java/com/thirdparty/ticketing/support/controller/DocumentationTest.java index dcbcb1b7..9c1f0c37 100644 --- a/src/test/java/com/thirdparty/ticketing/support/controller/DocumentationTest.java +++ b/src/test/java/com/thirdparty/ticketing/support/controller/DocumentationTest.java @@ -10,14 +10,15 @@ import static org.springframework.restdocs.request.RequestDocumentation.queryParameters; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; -import com.thirdparty.ticketing.support.BaseControllerTest; -import com.thirdparty.ticketing.support.controller.DocsController.HelloRequest; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.springframework.http.MediaType; import org.springframework.restdocs.payload.JsonFieldType; import org.springframework.test.web.servlet.ResultActions; +import com.thirdparty.ticketing.support.BaseControllerTest; +import com.thirdparty.ticketing.support.controller.DocsController.HelloRequest; + @DisplayName("API 문서 테스트 코드 작성 시") public class DocumentationTest extends BaseControllerTest { diff --git a/src/test/java/com/thirdparty/ticketing/support/controller/ResolverTestController.java b/src/test/java/com/thirdparty/ticketing/support/controller/ResolverTestController.java index b801c95a..dc6da464 100644 --- a/src/test/java/com/thirdparty/ticketing/support/controller/ResolverTestController.java +++ b/src/test/java/com/thirdparty/ticketing/support/controller/ResolverTestController.java @@ -1,10 +1,11 @@ package com.thirdparty.ticketing.support.controller; -import com.thirdparty.ticketing.domain.common.LoginMember; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import com.thirdparty.ticketing.domain.common.LoginMember; + @RestController @RequestMapping("/api/test/resolver") public class ResolverTestController { @@ -13,4 +14,4 @@ public class ResolverTestController { public String resolve(@LoginMember String email) { return email; } -} \ No newline at end of file +} diff --git a/src/test/java/com/thirdparty/ticketing/support/integration/AspectTestConfig.java b/src/test/java/com/thirdparty/ticketing/support/integration/AspectTestConfig.java index 266d2458..dc62c197 100644 --- a/src/test/java/com/thirdparty/ticketing/support/integration/AspectTestConfig.java +++ b/src/test/java/com/thirdparty/ticketing/support/integration/AspectTestConfig.java @@ -1,14 +1,16 @@ package com.thirdparty.ticketing.support.integration; -import com.thirdparty.ticketing.domain.waitingsystem.Debounce; -import com.thirdparty.ticketing.domain.waitingsystem.Waiting; import java.util.concurrent.atomic.AtomicInteger; + import org.springframework.boot.test.context.TestConfiguration; import org.springframework.context.annotation.Bean; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; +import com.thirdparty.ticketing.domain.waitingsystem.Debounce; +import com.thirdparty.ticketing.domain.waitingsystem.Waiting; + @TestConfiguration public class AspectTestConfig { @@ -44,4 +46,4 @@ public ResponseEntity test() { return ResponseEntity.ok("test"); } } -} \ No newline at end of file +}