diff --git a/src/test/java/com/daedan/festabook/FestabookApplicationTests.java b/src/test/java/com/daedan/festabook/FestabookApplicationTests.java index 3449f7b..cc31320 100644 --- a/src/test/java/com/daedan/festabook/FestabookApplicationTests.java +++ b/src/test/java/com/daedan/festabook/FestabookApplicationTests.java @@ -1,13 +1,11 @@ package com.daedan.festabook; +import com.daedan.festabook.support.AcceptanceTestSupport; import org.junit.jupiter.api.Test; -import org.springframework.boot.test.context.SpringBootTest; -@SpringBootTest -class FestabookApplicationTests { - - @Test - void contextLoads() { - } +class FestabookApplicationTests extends AcceptanceTestSupport { + @Test + void contextLoads() { + } } diff --git a/src/test/java/com/daedan/festabook/announcement/controller/AnnouncementControllerTest.java b/src/test/java/com/daedan/festabook/announcement/controller/AnnouncementControllerTest.java index 51621f1..071e0a9 100644 --- a/src/test/java/com/daedan/festabook/announcement/controller/AnnouncementControllerTest.java +++ b/src/test/java/com/daedan/festabook/announcement/controller/AnnouncementControllerTest.java @@ -26,29 +26,20 @@ import com.daedan.festabook.global.lock.ConcurrencyTestHelper; import com.daedan.festabook.global.security.JwtTestHelper; import com.daedan.festabook.global.security.role.RoleType; -import com.daedan.festabook.notification.infrastructure.FcmNotificationManager; +import com.daedan.festabook.support.AcceptanceTestSupport; import io.restassured.RestAssured; import io.restassured.http.ContentType; import io.restassured.http.Header; import java.util.List; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.DisplayNameGeneration; -import org.junit.jupiter.api.DisplayNameGenerator; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.CsvSource; import org.junit.jupiter.params.provider.EnumSource; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.boot.test.web.server.LocalServerPort; import org.springframework.http.HttpStatus; -import org.springframework.test.context.bean.override.mockito.MockitoBean; -@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) -@DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class) -class AnnouncementControllerTest { +class AnnouncementControllerTest extends AcceptanceTestSupport { private static final String FESTIVAL_HEADER_NAME = "festival"; @@ -61,17 +52,6 @@ class AnnouncementControllerTest { @Autowired private JwtTestHelper jwtTestHelper; - @MockitoBean - private FcmNotificationManager fcmNotificationManager; - - @LocalServerPort - private int port; - - @BeforeEach - void setUp() { - RestAssured.port = port; - } - @Nested class createAnnouncement { @@ -443,7 +423,7 @@ class sendAnnouncementNotification { Announcement announcement = AnnouncementFixture.create(festival); announcementJpaRepository.save(announcement); - willDoNothing().given(fcmNotificationManager) + willDoNothing().given(festivalNotificationManager) .sendToFestivalTopic(any(), any()); // when & then @@ -455,7 +435,7 @@ class sendAnnouncementNotification { .then() .statusCode(HttpStatus.OK.value()); - then(fcmNotificationManager).should() + then(festivalNotificationManager).should() .sendToFestivalTopic(any(), any()); } } diff --git a/src/test/java/com/daedan/festabook/council/controller/CouncilControllerTest.java b/src/test/java/com/daedan/festabook/council/controller/CouncilControllerTest.java index 441b9f8..52e18dd 100644 --- a/src/test/java/com/daedan/festabook/council/controller/CouncilControllerTest.java +++ b/src/test/java/com/daedan/festabook/council/controller/CouncilControllerTest.java @@ -16,25 +16,18 @@ import com.daedan.festabook.festival.infrastructure.FestivalJpaRepository; import com.daedan.festabook.global.security.JwtTestHelper; import com.daedan.festabook.global.security.role.RoleType; +import com.daedan.festabook.support.AcceptanceTestSupport; import io.restassured.RestAssured; import io.restassured.http.ContentType; import io.restassured.http.Header; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.DisplayNameGeneration; -import org.junit.jupiter.api.DisplayNameGenerator; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.EnumSource; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.boot.test.web.server.LocalServerPort; import org.springframework.http.HttpStatus; -@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) -@DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class) -class CouncilControllerTest { +class CouncilControllerTest extends AcceptanceTestSupport { @Autowired private FestivalJpaRepository festivalJpaRepository; @@ -42,14 +35,6 @@ class CouncilControllerTest { @Autowired private JwtTestHelper jwtTestHelper; - @LocalServerPort - private int port; - - @BeforeEach - void setUp() { - RestAssured.port = port; - } - @Nested class createCouncil { diff --git a/src/test/java/com/daedan/festabook/device/controller/DeviceControllerTest.java b/src/test/java/com/daedan/festabook/device/controller/DeviceControllerTest.java index 89667b6..ee03147 100644 --- a/src/test/java/com/daedan/festabook/device/controller/DeviceControllerTest.java +++ b/src/test/java/com/daedan/festabook/device/controller/DeviceControllerTest.java @@ -10,34 +10,19 @@ import com.daedan.festabook.device.dto.DeviceUpdateRequest; import com.daedan.festabook.device.dto.DeviceUpdateRequestFixture; import com.daedan.festabook.device.infrastructure.DeviceJpaRepository; +import com.daedan.festabook.support.AcceptanceTestSupport; import io.restassured.RestAssured; import io.restassured.http.ContentType; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.DisplayNameGeneration; -import org.junit.jupiter.api.DisplayNameGenerator; 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.SpringBootTest.WebEnvironment; -import org.springframework.boot.test.web.server.LocalServerPort; import org.springframework.http.HttpStatus; -@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) -@DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class) -class DeviceControllerTest { +class DeviceControllerTest extends AcceptanceTestSupport { @Autowired private DeviceJpaRepository deviceJpaRepository; - @LocalServerPort - private int port; - - @BeforeEach - void setUp() { - RestAssured.port = port; - } - @Nested class registerDevice { diff --git a/src/test/java/com/daedan/festabook/event/controller/EventControllerTest.java b/src/test/java/com/daedan/festabook/event/controller/EventControllerTest.java index 72b9f0e..a027730 100644 --- a/src/test/java/com/daedan/festabook/event/controller/EventControllerTest.java +++ b/src/test/java/com/daedan/festabook/event/controller/EventControllerTest.java @@ -22,6 +22,7 @@ import com.daedan.festabook.festival.infrastructure.FestivalJpaRepository; import com.daedan.festabook.global.security.JwtTestHelper; import com.daedan.festabook.global.security.role.RoleType; +import com.daedan.festabook.support.AcceptanceTestSupport; import io.restassured.RestAssured; import io.restassured.http.ContentType; import io.restassured.http.Header; @@ -31,24 +32,15 @@ import java.time.LocalTime; import java.time.ZoneId; import java.util.List; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.DisplayNameGeneration; -import org.junit.jupiter.api.DisplayNameGenerator; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.CsvSource; import org.junit.jupiter.params.provider.EnumSource; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.boot.test.web.server.LocalServerPort; import org.springframework.http.HttpStatus; -import org.springframework.test.context.bean.override.mockito.MockitoBean; -@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) -@DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class) -class EventControllerTest { +class EventControllerTest extends AcceptanceTestSupport { @Autowired private EventDateJpaRepository eventDateJpaRepository; @@ -62,17 +54,6 @@ class EventControllerTest { @Autowired private JwtTestHelper jwtTestHelper; - @MockitoBean - private Clock clock; - - @LocalServerPort - private int port; - - @BeforeEach - void setUp() { - RestAssured.port = port; - } - @Nested class createEvent { diff --git a/src/test/java/com/daedan/festabook/event/controller/EventDateControllerTest.java b/src/test/java/com/daedan/festabook/event/controller/EventDateControllerTest.java index fec6fd2..18a524e 100644 --- a/src/test/java/com/daedan/festabook/event/controller/EventDateControllerTest.java +++ b/src/test/java/com/daedan/festabook/event/controller/EventDateControllerTest.java @@ -21,29 +21,20 @@ import com.daedan.festabook.festival.infrastructure.FestivalJpaRepository; import com.daedan.festabook.global.security.JwtTestHelper; import com.daedan.festabook.global.security.role.RoleType; +import com.daedan.festabook.support.AcceptanceTestSupport; import io.restassured.RestAssured; import io.restassured.http.ContentType; import io.restassured.http.Header; -import java.time.Clock; import java.time.LocalDate; import java.util.List; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.DisplayNameGeneration; -import org.junit.jupiter.api.DisplayNameGenerator; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.EnumSource; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.boot.test.web.server.LocalServerPort; import org.springframework.http.HttpStatus; -import org.springframework.test.context.bean.override.mockito.MockitoBean; -@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) -@DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class) -class EventDateControllerTest { +class EventDateControllerTest extends AcceptanceTestSupport { private static final String FESTIVAL_HEADER_NAME = "festival"; @@ -59,17 +50,6 @@ class EventDateControllerTest { @Autowired private JwtTestHelper jwtTestHelper; - @MockitoBean - private Clock clock; - - @LocalServerPort - private int port; - - @BeforeEach - void setUp() { - RestAssured.port = port; - } - @Nested class createEventDate { diff --git a/src/test/java/com/daedan/festabook/festival/controller/AndroidFestivalNotificationSubscriptionControllerTest.java b/src/test/java/com/daedan/festabook/festival/controller/AndroidFestivalNotificationSubscriptionControllerTest.java index bc4359c..771d1fd 100644 --- a/src/test/java/com/daedan/festabook/festival/controller/AndroidFestivalNotificationSubscriptionControllerTest.java +++ b/src/test/java/com/daedan/festabook/festival/controller/AndroidFestivalNotificationSubscriptionControllerTest.java @@ -16,24 +16,15 @@ import com.daedan.festabook.festival.dto.FestivalNotificationRequestFixture; import com.daedan.festabook.festival.infrastructure.FestivalJpaRepository; import com.daedan.festabook.festival.infrastructure.FestivalNotificationJpaRepository; -import com.daedan.festabook.notification.infrastructure.FcmNotificationManager; +import com.daedan.festabook.support.AcceptanceTestSupport; import io.restassured.RestAssured; import io.restassured.http.ContentType; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.DisplayNameGeneration; -import org.junit.jupiter.api.DisplayNameGenerator; 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.SpringBootTest.WebEnvironment; -import org.springframework.boot.test.web.server.LocalServerPort; import org.springframework.http.HttpStatus; -import org.springframework.test.context.bean.override.mockito.MockitoBean; -@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) -@DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class) -class AndroidFestivalNotificationSubscriptionControllerTest { +class AndroidFestivalNotificationSubscriptionControllerTest extends AcceptanceTestSupport { @Autowired private FestivalJpaRepository festivalJpaRepository; @@ -44,17 +35,6 @@ class AndroidFestivalNotificationSubscriptionControllerTest { @Autowired private FestivalNotificationJpaRepository festivalNotificationJpaRepository; - @MockitoBean - private FcmNotificationManager fcmNotificationManager; - - @LocalServerPort - private int port; - - @BeforeEach - void setUp() { - RestAssured.port = port; - } - @Nested class subscribeAndroidFestivalNotification { @@ -83,7 +63,7 @@ class subscribeAndroidFestivalNotification { .body("size()", equalTo(expectedFieldSize)) .body("festivalNotificationId", notNullValue()); - then(fcmNotificationManager).should() + then(festivalNotificationManager).should() .subscribeAndroidFestivalTopic(any(), any()); } @@ -113,7 +93,7 @@ class subscribeAndroidFestivalNotification { .statusCode(HttpStatus.CONFLICT.value()) .body("message", equalTo("FestivalNotification 데이터베이스에 이미 존재합니다.")); - then(fcmNotificationManager).shouldHaveNoInteractions(); + then(festivalNotificationManager).shouldHaveNoInteractions(); } @Test @@ -136,7 +116,7 @@ class subscribeAndroidFestivalNotification { .statusCode(HttpStatus.BAD_REQUEST.value()) .body("message", equalTo("존재하지 않는 디바이스입니다.")); - then(fcmNotificationManager).shouldHaveNoInteractions(); + then(festivalNotificationManager).shouldHaveNoInteractions(); } @Test @@ -160,7 +140,7 @@ class subscribeAndroidFestivalNotification { .statusCode(HttpStatus.BAD_REQUEST.value()) .body("message", equalTo("존재하지 않는 축제입니다.")); - then(fcmNotificationManager).shouldHaveNoInteractions(); + then(festivalNotificationManager).shouldHaveNoInteractions(); } } } diff --git a/src/test/java/com/daedan/festabook/festival/controller/FestivalControllerTest.java b/src/test/java/com/daedan/festabook/festival/controller/FestivalControllerTest.java index f58abb0..cfc9dbd 100644 --- a/src/test/java/com/daedan/festabook/festival/controller/FestivalControllerTest.java +++ b/src/test/java/com/daedan/festabook/festival/controller/FestivalControllerTest.java @@ -23,6 +23,7 @@ import com.daedan.festabook.festival.infrastructure.FestivalJpaRepository; import com.daedan.festabook.global.security.JwtTestHelper; import com.daedan.festabook.global.security.role.RoleType; +import com.daedan.festabook.support.AcceptanceTestSupport; import io.restassured.RestAssured; import io.restassured.config.JsonConfig; import io.restassured.config.RestAssuredConfig; @@ -33,23 +34,15 @@ import java.util.List; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.DisplayNameGeneration; -import org.junit.jupiter.api.DisplayNameGenerator; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.CsvSource; import org.junit.jupiter.params.provider.EnumSource; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.boot.test.web.server.LocalServerPort; import org.springframework.http.HttpStatus; -@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) -@DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class) -class FestivalControllerTest { +class FestivalControllerTest extends AcceptanceTestSupport { private static final String FESTIVAL_HEADER_NAME = "festival"; @@ -62,9 +55,6 @@ class FestivalControllerTest { @Autowired private JwtTestHelper jwtTestHelper; - @LocalServerPort - private int port; - @BeforeAll static void beforeAll() { RestAssured.config = RestAssured.config() @@ -77,11 +67,6 @@ static void afterAll() { RestAssured.config = RestAssuredConfig.config(); } - @BeforeEach - void setUp() { - RestAssured.port = port; - } - @Nested class createFestival { diff --git a/src/test/java/com/daedan/festabook/festival/controller/FestivalNotificationSubscriptionControllerTest.java b/src/test/java/com/daedan/festabook/festival/controller/FestivalNotificationSubscriptionControllerTest.java index 75eb673..84a8b53 100644 --- a/src/test/java/com/daedan/festabook/festival/controller/FestivalNotificationSubscriptionControllerTest.java +++ b/src/test/java/com/daedan/festabook/festival/controller/FestivalNotificationSubscriptionControllerTest.java @@ -18,25 +18,16 @@ import com.daedan.festabook.festival.dto.FestivalNotificationRequestFixture; import com.daedan.festabook.festival.infrastructure.FestivalJpaRepository; import com.daedan.festabook.festival.infrastructure.FestivalNotificationJpaRepository; -import com.daedan.festabook.notification.infrastructure.FcmNotificationManager; +import com.daedan.festabook.support.AcceptanceTestSupport; import io.restassured.RestAssured; import io.restassured.http.ContentType; import java.util.List; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.DisplayNameGeneration; -import org.junit.jupiter.api.DisplayNameGenerator; 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.SpringBootTest.WebEnvironment; -import org.springframework.boot.test.web.server.LocalServerPort; import org.springframework.http.HttpStatus; -import org.springframework.test.context.bean.override.mockito.MockitoBean; -@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) -@DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class) -class FestivalNotificationSubscriptionControllerTest { +class FestivalNotificationSubscriptionControllerTest extends AcceptanceTestSupport { @Autowired private FestivalJpaRepository festivalJpaRepository; @@ -47,17 +38,6 @@ class FestivalNotificationSubscriptionControllerTest { @Autowired private FestivalNotificationJpaRepository festivalNotificationJpaRepository; - @MockitoBean - private FcmNotificationManager fcmNotificationManager; - - @LocalServerPort - private int port; - - @BeforeEach - void setUp() { - RestAssured.port = port; - } - @Nested class subscribeFestivalNotification { @@ -86,7 +66,7 @@ class subscribeFestivalNotification { .body("size()", equalTo(expectedFieldSize)) .body("festivalNotificationId", notNullValue()); - then(fcmNotificationManager).should() + then(festivalNotificationManager).should() .subscribeFestivalTopic(any(), any()); } @@ -116,7 +96,7 @@ class subscribeFestivalNotification { .statusCode(HttpStatus.CREATED.value()) .body("festivalNotificationId", notNullValue()); - then(fcmNotificationManager).should() + then(festivalNotificationManager).should() .subscribeFestivalTopic(festival.getId(), device.getFcmToken()); } @@ -146,7 +126,7 @@ class subscribeFestivalNotification { .statusCode(HttpStatus.CONFLICT.value()) .body("message", equalTo("FestivalNotification 데이터베이스에 이미 존재합니다.")); - then(fcmNotificationManager).shouldHaveNoInteractions(); + then(festivalNotificationManager).shouldHaveNoInteractions(); } @Test @@ -169,7 +149,7 @@ class subscribeFestivalNotification { .statusCode(HttpStatus.BAD_REQUEST.value()) .body("message", equalTo("존재하지 않는 디바이스입니다.")); - then(fcmNotificationManager).shouldHaveNoInteractions(); + then(festivalNotificationManager).shouldHaveNoInteractions(); } @Test @@ -193,7 +173,7 @@ class subscribeFestivalNotification { .statusCode(HttpStatus.BAD_REQUEST.value()) .body("message", equalTo("존재하지 않는 축제입니다.")); - then(fcmNotificationManager).shouldHaveNoInteractions(); + then(festivalNotificationManager).shouldHaveNoInteractions(); } } @@ -269,7 +249,7 @@ class unsubscribeFestivalNotification { boolean exists = festivalNotificationJpaRepository.existsById(festivalNotification.getId()); assertThat(exists).isFalse(); - then(fcmNotificationManager).should() + then(festivalNotificationManager).should() .unsubscribeFestivalTopic(any(), any()); } @@ -301,7 +281,7 @@ class unsubscribeFestivalNotification { boolean exists = festivalNotificationJpaRepository.existsById(second.getId()); assertThat(exists).isFalse(); - then(fcmNotificationManager).should() + then(festivalNotificationManager).should() .unsubscribeFestivalTopic(any(), any()); } @@ -320,7 +300,7 @@ class unsubscribeFestivalNotification { .then() .statusCode(HttpStatus.NO_CONTENT.value()); - then(fcmNotificationManager).shouldHaveNoInteractions(); + then(festivalNotificationManager).shouldHaveNoInteractions(); } } } diff --git a/src/test/java/com/daedan/festabook/festival/controller/IosFestivalNotificationSubscriptionControllerTest.java b/src/test/java/com/daedan/festabook/festival/controller/IosFestivalNotificationSubscriptionControllerTest.java index 6105313..642af0f 100644 --- a/src/test/java/com/daedan/festabook/festival/controller/IosFestivalNotificationSubscriptionControllerTest.java +++ b/src/test/java/com/daedan/festabook/festival/controller/IosFestivalNotificationSubscriptionControllerTest.java @@ -16,24 +16,15 @@ import com.daedan.festabook.festival.dto.FestivalNotificationRequestFixture; import com.daedan.festabook.festival.infrastructure.FestivalJpaRepository; import com.daedan.festabook.festival.infrastructure.FestivalNotificationJpaRepository; -import com.daedan.festabook.notification.infrastructure.FcmNotificationManager; +import com.daedan.festabook.support.AcceptanceTestSupport; import io.restassured.RestAssured; import io.restassured.http.ContentType; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.DisplayNameGeneration; -import org.junit.jupiter.api.DisplayNameGenerator; 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.SpringBootTest.WebEnvironment; -import org.springframework.boot.test.web.server.LocalServerPort; import org.springframework.http.HttpStatus; -import org.springframework.test.context.bean.override.mockito.MockitoBean; -@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) -@DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class) -class IosFestivalNotificationSubscriptionControllerTest { +class IosFestivalNotificationSubscriptionControllerTest extends AcceptanceTestSupport { @Autowired private FestivalJpaRepository festivalJpaRepository; @@ -44,17 +35,6 @@ class IosFestivalNotificationSubscriptionControllerTest { @Autowired private FestivalNotificationJpaRepository festivalNotificationJpaRepository; - @MockitoBean - private FcmNotificationManager fcmNotificationManager; - - @LocalServerPort - private int port; - - @BeforeEach - void setUp() { - RestAssured.port = port; - } - @Nested class subscribeIosFestivalNotification { @@ -83,7 +63,7 @@ class subscribeIosFestivalNotification { .body("size()", equalTo(expectedFieldSize)) .body("festivalNotificationId", notNullValue()); - then(fcmNotificationManager).should() + then(festivalNotificationManager).should() .subscribeIosFestivalTopic(any(), any()); } @@ -113,7 +93,7 @@ class subscribeIosFestivalNotification { .statusCode(HttpStatus.CONFLICT.value()) .body("message", equalTo("FestivalNotification 데이터베이스에 이미 존재합니다.")); - then(fcmNotificationManager).shouldHaveNoInteractions(); + then(festivalNotificationManager).shouldHaveNoInteractions(); } @Test @@ -136,7 +116,7 @@ class subscribeIosFestivalNotification { .statusCode(HttpStatus.BAD_REQUEST.value()) .body("message", equalTo("존재하지 않는 디바이스입니다.")); - then(fcmNotificationManager).shouldHaveNoInteractions(); + then(festivalNotificationManager).shouldHaveNoInteractions(); } @Test @@ -160,7 +140,7 @@ class subscribeIosFestivalNotification { .statusCode(HttpStatus.BAD_REQUEST.value()) .body("message", equalTo("존재하지 않는 축제입니다.")); - then(fcmNotificationManager).shouldHaveNoInteractions(); + then(festivalNotificationManager).shouldHaveNoInteractions(); } } } diff --git a/src/test/java/com/daedan/festabook/festival/service/FestivalNotificationConcurrencyTest.java b/src/test/java/com/daedan/festabook/festival/service/FestivalNotificationConcurrencyTest.java index 51d54af..668a1d7 100644 --- a/src/test/java/com/daedan/festabook/festival/service/FestivalNotificationConcurrencyTest.java +++ b/src/test/java/com/daedan/festabook/festival/service/FestivalNotificationConcurrencyTest.java @@ -7,31 +7,22 @@ import com.daedan.festabook.device.infrastructure.DeviceJpaRepository; import com.daedan.festabook.festival.domain.Festival; import com.daedan.festabook.festival.domain.FestivalFixture; -import com.daedan.festabook.festival.domain.FestivalNotificationManager; import com.daedan.festabook.festival.dto.FestivalNotificationRequest; import com.daedan.festabook.festival.dto.FestivalNotificationRequestFixture; import com.daedan.festabook.festival.infrastructure.FestivalJpaRepository; import com.daedan.festabook.festival.infrastructure.FestivalNotificationJpaRepository; import com.daedan.festabook.global.lock.ConcurrencyTestHelper; +import com.daedan.festabook.support.AcceptanceTestSupport; import io.restassured.RestAssured; import io.restassured.http.ContentType; import io.restassured.response.Response; import java.util.concurrent.atomic.AtomicInteger; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.DisplayNameGeneration; -import org.junit.jupiter.api.DisplayNameGenerator; 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.SpringBootTest.WebEnvironment; -import org.springframework.boot.test.web.server.LocalServerPort; import org.springframework.http.HttpStatus; -import org.springframework.test.context.bean.override.mockito.MockitoBean; -@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) -@DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class) -class FestivalNotificationConcurrencyTest { +class FestivalNotificationConcurrencyTest extends AcceptanceTestSupport { @Autowired private FestivalJpaRepository festivalJpaRepository; @@ -42,17 +33,6 @@ class FestivalNotificationConcurrencyTest { @Autowired private FestivalNotificationJpaRepository festivalNotificationJpaRepository; - @MockitoBean - private FestivalNotificationManager festivalNotificationManager; - - @LocalServerPort - private int port; - - @BeforeEach - void setUp() { - RestAssured.port = port; - } - @Nested class subscribeFestivalNotification { diff --git a/src/test/java/com/daedan/festabook/global/argumentresolver/FestivalIdArgumentResolverTest.java b/src/test/java/com/daedan/festabook/global/argumentresolver/FestivalIdArgumentResolverTest.java index 5e0d22b..deda558 100644 --- a/src/test/java/com/daedan/festabook/global/argumentresolver/FestivalIdArgumentResolverTest.java +++ b/src/test/java/com/daedan/festabook/global/argumentresolver/FestivalIdArgumentResolverTest.java @@ -6,41 +6,23 @@ import com.daedan.festabook.festival.domain.Festival; import com.daedan.festabook.festival.domain.FestivalFixture; import com.daedan.festabook.festival.infrastructure.FestivalJpaRepository; -import com.daedan.festabook.global.config.TestSecurityConfig; +import com.daedan.festabook.support.AcceptanceTestSupport; import io.restassured.RestAssured; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.DisplayNameGeneration; -import org.junit.jupiter.api.DisplayNameGenerator; 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.SpringBootTest.WebEnvironment; -import org.springframework.boot.test.web.server.LocalServerPort; -import org.springframework.context.annotation.Import; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.RestController; -@Import(TestSecurityConfig.class) -@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) -@DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class) -class FestivalIdArgumentResolverTest { +class FestivalIdArgumentResolverTest extends AcceptanceTestSupport { private static final String FESTIVAL_HEADER_NAME = "festival"; @Autowired private FestivalJpaRepository festivalJpaRepository; - @LocalServerPort - private int port; - - @BeforeEach - void setUp() { - RestAssured.port = port; - } - @Nested class resolveArgument { diff --git a/src/test/java/com/daedan/festabook/global/config/WebMvcConfigTest.java b/src/test/java/com/daedan/festabook/global/config/WebMvcConfigTest.java index f671bd8..796cef6 100644 --- a/src/test/java/com/daedan/festabook/global/config/WebMvcConfigTest.java +++ b/src/test/java/com/daedan/festabook/global/config/WebMvcConfigTest.java @@ -6,39 +6,23 @@ import com.daedan.festabook.festival.domain.FestivalFixture; import com.daedan.festabook.festival.infrastructure.FestivalJpaRepository; import com.daedan.festabook.global.argumentresolver.FestivalId; +import com.daedan.festabook.support.AcceptanceTestSupport; import io.restassured.RestAssured; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.DisplayNameGeneration; -import org.junit.jupiter.api.DisplayNameGenerator; 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.web.server.LocalServerPort; -import org.springframework.context.annotation.Import; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.RestController; -@Import(TestSecurityConfig.class) -@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) -@DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class) -class WebMvcConfigTest { +class WebMvcConfigTest extends AcceptanceTestSupport { private static final String FESTIVAL_HEADER_NAME = "festival"; @Autowired private FestivalJpaRepository festivalJpaRepository; - @LocalServerPort - private int port; - - @BeforeEach - void setUp() { - RestAssured.port = port; - } - @Nested class addArgumentResolvers { diff --git a/src/test/java/com/daedan/festabook/global/exception/GlobalExceptionHandlerTest.java b/src/test/java/com/daedan/festabook/global/exception/GlobalExceptionHandlerTest.java index a0e3754..a218481 100644 --- a/src/test/java/com/daedan/festabook/global/exception/GlobalExceptionHandlerTest.java +++ b/src/test/java/com/daedan/festabook/global/exception/GlobalExceptionHandlerTest.java @@ -8,24 +8,18 @@ import ch.qos.logback.classic.Logger; import ch.qos.logback.classic.spi.ILoggingEvent; import ch.qos.logback.core.read.ListAppender; -import com.daedan.festabook.global.config.TestSecurityConfig; +import com.daedan.festabook.support.AcceptanceTestSupport; import io.restassured.RestAssured; import java.sql.SQLException; import java.util.stream.Stream; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.DisplayNameGeneration; -import org.junit.jupiter.api.DisplayNameGenerator; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.boot.test.web.server.LocalServerPort; -import org.springframework.context.annotation.Import; import org.springframework.dao.DataAccessException; import org.springframework.dao.DataAccessResourceFailureException; import org.springframework.dao.DataIntegrityViolationException; @@ -38,10 +32,7 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -@Import(TestSecurityConfig.class) -@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) -@DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class) -class GlobalExceptionHandlerTest { +class GlobalExceptionHandlerTest extends AcceptanceTestSupport { private static final String MESSAGE_PARAM_NAME = "message"; private static final String STATUS_CODE_PARAM_NAME = "status-code"; @@ -49,14 +40,6 @@ class GlobalExceptionHandlerTest { @Autowired private ExceptionController exceptionController; - @LocalServerPort - private int port; - - @BeforeEach - void setUp() { - RestAssured.port = port; - } - @Nested class handleDatabaseException { diff --git a/src/test/java/com/daedan/festabook/global/security/config/SecurityConfigTest.java b/src/test/java/com/daedan/festabook/global/security/config/SecurityConfigTest.java index b619366..3d4e2c9 100644 --- a/src/test/java/com/daedan/festabook/global/security/config/SecurityConfigTest.java +++ b/src/test/java/com/daedan/festabook/global/security/config/SecurityConfigTest.java @@ -8,17 +8,11 @@ import com.daedan.festabook.festival.domain.Festival; import com.daedan.festabook.festival.domain.FestivalFixture; import com.daedan.festabook.festival.infrastructure.FestivalJpaRepository; -import com.daedan.festabook.global.config.TestSecurityConfig; +import com.daedan.festabook.support.AcceptanceTestSupport; import io.restassured.RestAssured; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.DisplayNameGeneration; -import org.junit.jupiter.api.DisplayNameGenerator; 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.web.server.LocalServerPort; -import org.springframework.context.annotation.Import; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; @@ -28,10 +22,7 @@ import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.RestController; -@Import({TestSecurityConfig.class, SecurityConfig.class}) -@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) -@DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class) -class SecurityConfigTest { +class SecurityConfigTest extends AcceptanceTestSupport { private static final String ORIGIN_LOCALHOST = "http://localhost:5173"; private static final String ORIGIN_LOCALHOST_IP = "http://127.0.0.1:5173"; @@ -39,14 +30,6 @@ class SecurityConfigTest { @Autowired private FestivalJpaRepository festivalJpaRepository; - @LocalServerPort - int port; - - @BeforeEach - void setUp() { - RestAssured.port = port; - } - @Nested class CORS_검증 { diff --git a/src/test/java/com/daedan/festabook/lineup/controller/LineupControllerTest.java b/src/test/java/com/daedan/festabook/lineup/controller/LineupControllerTest.java index 0288113..553d1d5 100644 --- a/src/test/java/com/daedan/festabook/lineup/controller/LineupControllerTest.java +++ b/src/test/java/com/daedan/festabook/lineup/controller/LineupControllerTest.java @@ -16,27 +16,20 @@ import com.daedan.festabook.lineup.dto.LineupUpdateRequest; import com.daedan.festabook.lineup.dto.LineupUpdateRequestFixture; import com.daedan.festabook.lineup.infrastructure.LineupJpaRepository; +import com.daedan.festabook.support.AcceptanceTestSupport; import io.restassured.RestAssured; import io.restassured.http.ContentType; import io.restassured.http.Header; import java.time.LocalDateTime; import java.util.List; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.DisplayNameGeneration; -import org.junit.jupiter.api.DisplayNameGenerator; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.EnumSource; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.boot.test.web.server.LocalServerPort; import org.springframework.http.HttpStatus; -@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) -@DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class) -class LineupControllerTest { +class LineupControllerTest extends AcceptanceTestSupport { private static final String FESTIVAL_HEADER_NAME = "festival"; @@ -49,14 +42,6 @@ class LineupControllerTest { @Autowired private JwtTestHelper jwtTestHelper; - @LocalServerPort - private int port; - - @BeforeEach - void setUp() { - RestAssured.port = port; - } - @Nested class addLineup { diff --git a/src/test/java/com/daedan/festabook/lostitem/controller/LostItemControllerTest.java b/src/test/java/com/daedan/festabook/lostitem/controller/LostItemControllerTest.java index d2d7c2e..d4a1382 100644 --- a/src/test/java/com/daedan/festabook/lostitem/controller/LostItemControllerTest.java +++ b/src/test/java/com/daedan/festabook/lostitem/controller/LostItemControllerTest.java @@ -19,26 +19,20 @@ import com.daedan.festabook.lostitem.dto.LostItemStatusUpdateRequest; import com.daedan.festabook.lostitem.dto.LostItemStatusUpdateRequestFixture; import com.daedan.festabook.lostitem.infrastructure.LostItemJpaRepository; +import com.daedan.festabook.support.AcceptanceTestSupport; import io.restassured.RestAssured; import io.restassured.http.ContentType; import io.restassured.http.Header; import java.util.List; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.DisplayNameGeneration; -import org.junit.jupiter.api.DisplayNameGenerator; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.CsvSource; import org.junit.jupiter.params.provider.EnumSource; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.web.server.LocalServerPort; import org.springframework.http.HttpStatus; -@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) -@DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class) -class LostItemControllerTest { +class LostItemControllerTest extends AcceptanceTestSupport { private static final String FESTIVAL_HEADER_NAME = "festival"; @@ -51,14 +45,6 @@ class LostItemControllerTest { @Autowired private JwtTestHelper jwtTestHelper; - @LocalServerPort - private int port; - - @BeforeEach - void setUp() { - RestAssured.port = port; - } - @Nested class createLostItem { diff --git a/src/test/java/com/daedan/festabook/place/controller/PlaceAnnouncementControllerTest.java b/src/test/java/com/daedan/festabook/place/controller/PlaceAnnouncementControllerTest.java index 5fa6fc1..558e470 100644 --- a/src/test/java/com/daedan/festabook/place/controller/PlaceAnnouncementControllerTest.java +++ b/src/test/java/com/daedan/festabook/place/controller/PlaceAnnouncementControllerTest.java @@ -20,26 +20,19 @@ import com.daedan.festabook.place.dto.PlaceAnnouncementUpdateRequestFixture; import com.daedan.festabook.place.infrastructure.PlaceAnnouncementJpaRepository; import com.daedan.festabook.place.infrastructure.PlaceJpaRepository; +import com.daedan.festabook.support.AcceptanceTestSupport; import io.restassured.RestAssured; import io.restassured.http.ContentType; import io.restassured.http.Header; import java.util.List; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.DisplayNameGeneration; -import org.junit.jupiter.api.DisplayNameGenerator; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.EnumSource; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.boot.test.web.server.LocalServerPort; import org.springframework.http.HttpStatus; -@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) -@DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class) -class PlaceAnnouncementControllerTest { +class PlaceAnnouncementControllerTest extends AcceptanceTestSupport { @Autowired private FestivalJpaRepository festivalJpaRepository; @@ -53,14 +46,6 @@ class PlaceAnnouncementControllerTest { @Autowired private JwtTestHelper jwtTestHelper; - @LocalServerPort - private int port; - - @BeforeEach - void setUp() { - RestAssured.port = port; - } - @Nested class createPlaceAnnouncement { diff --git a/src/test/java/com/daedan/festabook/place/controller/PlaceControllerTest.java b/src/test/java/com/daedan/festabook/place/controller/PlaceControllerTest.java index 17b54db..1e05147 100644 --- a/src/test/java/com/daedan/festabook/place/controller/PlaceControllerTest.java +++ b/src/test/java/com/daedan/festabook/place/controller/PlaceControllerTest.java @@ -15,7 +15,6 @@ import com.daedan.festabook.festival.domain.Festival; import com.daedan.festabook.festival.domain.FestivalFixture; import com.daedan.festabook.festival.infrastructure.FestivalJpaRepository; -import com.daedan.festabook.global.infrastructure.ShuffleManager; import com.daedan.festabook.global.security.JwtTestHelper; import com.daedan.festabook.global.security.role.RoleType; import com.daedan.festabook.place.domain.Place; @@ -40,6 +39,7 @@ import com.daedan.festabook.place.infrastructure.PlaceFavoriteJpaRepository; import com.daedan.festabook.place.infrastructure.PlaceImageJpaRepository; import com.daedan.festabook.place.infrastructure.PlaceJpaRepository; +import com.daedan.festabook.support.AcceptanceTestSupport; import com.daedan.festabook.timetag.domain.PlaceTimeTag; import com.daedan.festabook.timetag.domain.PlaceTimeTagFixture; import com.daedan.festabook.timetag.domain.TimeTag; @@ -51,23 +51,14 @@ import io.restassured.http.Header; import java.time.LocalTime; import java.util.List; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.DisplayNameGeneration; -import org.junit.jupiter.api.DisplayNameGenerator; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.EnumSource; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.boot.test.web.server.LocalServerPort; import org.springframework.http.HttpStatus; -import org.springframework.test.context.bean.override.mockito.MockitoBean; -@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) -@DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class) -class PlaceControllerTest { +class PlaceControllerTest extends AcceptanceTestSupport { private static final String FESTIVAL_HEADER_NAME = "festival"; @@ -98,17 +89,6 @@ class PlaceControllerTest { @Autowired private JwtTestHelper jwtTestHelper; - @MockitoBean - private ShuffleManager shuffleManager; - - @LocalServerPort - private int port; - - @BeforeEach - void setUp() { - RestAssured.port = port; - } - @Nested class createPlace { diff --git a/src/test/java/com/daedan/festabook/place/controller/PlaceFavoriteControllerTest.java b/src/test/java/com/daedan/festabook/place/controller/PlaceFavoriteControllerTest.java index 822960c..b7db09f 100644 --- a/src/test/java/com/daedan/festabook/place/controller/PlaceFavoriteControllerTest.java +++ b/src/test/java/com/daedan/festabook/place/controller/PlaceFavoriteControllerTest.java @@ -18,22 +18,15 @@ import com.daedan.festabook.place.dto.PlaceFavoriteRequestFixture; import com.daedan.festabook.place.infrastructure.PlaceFavoriteJpaRepository; import com.daedan.festabook.place.infrastructure.PlaceJpaRepository; +import com.daedan.festabook.support.AcceptanceTestSupport; import io.restassured.RestAssured; import io.restassured.http.ContentType; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.DisplayNameGeneration; -import org.junit.jupiter.api.DisplayNameGenerator; 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.SpringBootTest.WebEnvironment; -import org.springframework.boot.test.web.server.LocalServerPort; import org.springframework.http.HttpStatus; -@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) -@DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class) -class PlaceFavoriteControllerTest { +class PlaceFavoriteControllerTest extends AcceptanceTestSupport { @Autowired private FestivalJpaRepository festivalJpaRepository; @@ -47,14 +40,6 @@ class PlaceFavoriteControllerTest { @Autowired private PlaceFavoriteJpaRepository placeFavoriteJpaRepository; - @LocalServerPort - private int port; - - @BeforeEach - void setUp() { - RestAssured.port = port; - } - @Nested class addPlaceFavorite { diff --git a/src/test/java/com/daedan/festabook/place/controller/PlaceGeographyControllerTest.java b/src/test/java/com/daedan/festabook/place/controller/PlaceGeographyControllerTest.java index 6c05202..b57ba4e 100644 --- a/src/test/java/com/daedan/festabook/place/controller/PlaceGeographyControllerTest.java +++ b/src/test/java/com/daedan/festabook/place/controller/PlaceGeographyControllerTest.java @@ -15,6 +15,7 @@ import com.daedan.festabook.place.dto.PlaceCoordinateRequest; import com.daedan.festabook.place.dto.PlaceCoordinateRequestFixture; import com.daedan.festabook.place.infrastructure.PlaceJpaRepository; +import com.daedan.festabook.support.AcceptanceTestSupport; import com.daedan.festabook.timetag.domain.PlaceTimeTag; import com.daedan.festabook.timetag.domain.PlaceTimeTagFixture; import com.daedan.festabook.timetag.domain.TimeTag; @@ -30,22 +31,14 @@ import java.util.List; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.DisplayNameGeneration; -import org.junit.jupiter.api.DisplayNameGenerator; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.EnumSource; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.boot.test.web.server.LocalServerPort; import org.springframework.http.HttpStatus; -@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) -@DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class) -class PlaceGeographyControllerTest { +class PlaceGeographyControllerTest extends AcceptanceTestSupport { private static final String FESTIVAL_HEADER_NAME = "festival"; @@ -64,9 +57,6 @@ class PlaceGeographyControllerTest { @Autowired private PlaceTimeTagJpaRepository placeTimeTagJpaRepository; - @LocalServerPort - private int port; - @BeforeAll static void beforeAll() { RestAssured.config = RestAssured.config() @@ -79,11 +69,6 @@ static void afterAll() { RestAssured.config = RestAssuredConfig.config(); } - @BeforeEach - void setUp() { - RestAssured.port = port; - } - @Nested class getAllPlaceGeographyByFestivalId { diff --git a/src/test/java/com/daedan/festabook/place/controller/PlaceImageControllerTest.java b/src/test/java/com/daedan/festabook/place/controller/PlaceImageControllerTest.java index 403560e..a95a4d1 100644 --- a/src/test/java/com/daedan/festabook/place/controller/PlaceImageControllerTest.java +++ b/src/test/java/com/daedan/festabook/place/controller/PlaceImageControllerTest.java @@ -20,25 +20,18 @@ import com.daedan.festabook.place.dto.PlaceImageSequenceUpdateRequestFixture; import com.daedan.festabook.place.infrastructure.PlaceImageJpaRepository; import com.daedan.festabook.place.infrastructure.PlaceJpaRepository; +import com.daedan.festabook.support.AcceptanceTestSupport; import io.restassured.RestAssured; import io.restassured.http.ContentType; import io.restassured.http.Header; import java.util.List; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.DisplayNameGeneration; -import org.junit.jupiter.api.DisplayNameGenerator; import org.junit.jupiter.api.Nested; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.EnumSource; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.boot.test.web.server.LocalServerPort; import org.springframework.http.HttpStatus; -@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) -@DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class) -class PlaceImageControllerTest { +class PlaceImageControllerTest extends AcceptanceTestSupport { @Autowired private FestivalJpaRepository festivalJpaRepository; @@ -52,14 +45,6 @@ class PlaceImageControllerTest { @Autowired private JwtTestHelper jwtTestHelper; - @LocalServerPort - private int port; - - @BeforeEach - void setUp() { - RestAssured.port = port; - } - @Nested class addPlaceImage { diff --git a/src/test/java/com/daedan/festabook/question/controller/QuestionControllerTest.java b/src/test/java/com/daedan/festabook/question/controller/QuestionControllerTest.java index 3c1a5ef..7c519d7 100644 --- a/src/test/java/com/daedan/festabook/question/controller/QuestionControllerTest.java +++ b/src/test/java/com/daedan/festabook/question/controller/QuestionControllerTest.java @@ -16,26 +16,19 @@ import com.daedan.festabook.question.dto.QuestionSequenceUpdateRequest; import com.daedan.festabook.question.dto.QuestionSequenceUpdateRequestFixture; import com.daedan.festabook.question.infrastructure.QuestionJpaRepository; +import com.daedan.festabook.support.AcceptanceTestSupport; import io.restassured.RestAssured; import io.restassured.http.ContentType; import io.restassured.http.Header; import java.util.List; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.DisplayNameGeneration; -import org.junit.jupiter.api.DisplayNameGenerator; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.EnumSource; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.boot.test.web.server.LocalServerPort; import org.springframework.http.HttpStatus; -@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) -@DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class) -class QuestionControllerTest { +class QuestionControllerTest extends AcceptanceTestSupport { private static final String FESTIVAL_HEADER_NAME = "festival"; @@ -48,14 +41,6 @@ class QuestionControllerTest { @Autowired private JwtTestHelper jwtTestHelper; - @LocalServerPort - private int port; - - @BeforeEach - void setup() { - RestAssured.port = port; - } - @Nested class createQuestion { diff --git a/src/test/java/com/daedan/festabook/storage/controller/ImageStoreControllerTest.java b/src/test/java/com/daedan/festabook/storage/controller/ImageStoreControllerTest.java index d7da021..8d1fb82 100644 --- a/src/test/java/com/daedan/festabook/storage/controller/ImageStoreControllerTest.java +++ b/src/test/java/com/daedan/festabook/storage/controller/ImageStoreControllerTest.java @@ -8,24 +8,18 @@ import com.daedan.festabook.festival.infrastructure.FestivalJpaRepository; import com.daedan.festabook.global.security.JwtTestHelper; import com.daedan.festabook.global.security.role.RoleType; +import com.daedan.festabook.support.AcceptanceTestSupport; import io.restassured.RestAssured; import io.restassured.http.Header; import java.io.IOException; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.DisplayNameGeneration; -import org.junit.jupiter.api.DisplayNameGenerator; import org.junit.jupiter.api.Nested; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.EnumSource; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.web.server.LocalServerPort; import org.springframework.http.HttpStatus; import org.springframework.mock.web.MockMultipartFile; -@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) -@DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class) -class ImageStoreControllerTest { +class ImageStoreControllerTest extends AcceptanceTestSupport { @Autowired private FestivalJpaRepository festivalJpaRepository; @@ -33,14 +27,6 @@ class ImageStoreControllerTest { @Autowired private JwtTestHelper jwtTestHelper; - @LocalServerPort - private int port; - - @BeforeEach - void setUp() { - RestAssured.port = port; - } - @Nested class UploadImage { diff --git a/src/test/java/com/daedan/festabook/support/AcceptanceTestSupport.java b/src/test/java/com/daedan/festabook/support/AcceptanceTestSupport.java new file mode 100644 index 0000000..6a7fc8c --- /dev/null +++ b/src/test/java/com/daedan/festabook/support/AcceptanceTestSupport.java @@ -0,0 +1,38 @@ +package com.daedan.festabook.support; + +import com.daedan.festabook.festival.domain.FestivalNotificationManager; +import com.daedan.festabook.global.config.TestSecurityConfig; +import com.daedan.festabook.global.infrastructure.ShuffleManager; +import io.restassured.RestAssured; +import java.time.Clock; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayNameGeneration; +import org.junit.jupiter.api.DisplayNameGenerator; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.boot.test.web.server.LocalServerPort; +import org.springframework.context.annotation.Import; +import org.springframework.test.context.bean.override.mockito.MockitoBean; + +@Import(TestSecurityConfig.class) +@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) +@DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class) +public abstract class AcceptanceTestSupport { + + @MockitoBean + protected Clock clock; + + @MockitoBean + protected FestivalNotificationManager festivalNotificationManager; + + @MockitoBean + protected ShuffleManager shuffleManager; + + @LocalServerPort + private int port; + + @BeforeEach + void setUp() { + RestAssured.port = port; + } +} diff --git a/src/test/java/com/daedan/festabook/timetag/controller/TimeTagControllerTest.java b/src/test/java/com/daedan/festabook/timetag/controller/TimeTagControllerTest.java index 17bc229..2484f3f 100644 --- a/src/test/java/com/daedan/festabook/timetag/controller/TimeTagControllerTest.java +++ b/src/test/java/com/daedan/festabook/timetag/controller/TimeTagControllerTest.java @@ -10,6 +10,7 @@ import com.daedan.festabook.festival.infrastructure.FestivalJpaRepository; import com.daedan.festabook.global.security.JwtTestHelper; import com.daedan.festabook.global.security.role.RoleType; +import com.daedan.festabook.support.AcceptanceTestSupport; import com.daedan.festabook.timetag.domain.TimeTag; import com.daedan.festabook.timetag.domain.TimeTagFixture; import com.daedan.festabook.timetag.dto.TimeTagCreateRequest; @@ -20,22 +21,14 @@ import io.restassured.RestAssured; import io.restassured.http.ContentType; import io.restassured.http.Header; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.DisplayNameGeneration; -import org.junit.jupiter.api.DisplayNameGenerator; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.EnumSource; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.boot.test.web.server.LocalServerPort; import org.springframework.http.HttpStatus; -@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) -@DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class) -class TimeTagControllerTest { +class TimeTagControllerTest extends AcceptanceTestSupport { private static final String FESTIVAL_HEADER_NAME = "festival"; @@ -48,14 +41,6 @@ class TimeTagControllerTest { @Autowired private JwtTestHelper jwtTestHelper; - @LocalServerPort - private int port; - - @BeforeEach - void setup() { - RestAssured.port = port; - } - @Nested class createTimeTag {