Skip to content

Commit

Permalink
test: controller integration test 환경 통일
Browse files Browse the repository at this point in the history
  • Loading branch information
redcarrot1 committed Jun 28, 2024
1 parent 5b91216 commit 1e211f4
Show file tree
Hide file tree
Showing 15 changed files with 86 additions and 99 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.playkuround.playkuroundserver;

import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@AutoConfigureMockMvc
@SpringBootTest(properties = "spring.profiles.active=test")
@EntityScan(basePackages = {"com.playkuround.playkuroundserver.domain"})
public @interface IntegrationControllerTest {
}

Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.playkuround.playkuroundserver.domain.adventure.api;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.playkuround.playkuroundserver.IntegrationControllerTest;
import com.playkuround.playkuroundserver.domain.adventure.api.request.AdventureSaveRequest;
import com.playkuround.playkuroundserver.domain.adventure.dao.AdventureRepository;
import com.playkuround.playkuroundserver.domain.adventure.domain.Adventure;
Expand All @@ -17,8 +18,6 @@
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.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.http.MediaType;
import org.springframework.test.context.jdbc.Sql;
Expand All @@ -32,8 +31,7 @@
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;

@AutoConfigureMockMvc
@SpringBootTest(properties = "spring.profiles.active=test")
@IntegrationControllerTest
@Sql(scripts = {"/data-mysql.sql"}, executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD)
class AdventureApiTest {

Expand Down Expand Up @@ -62,10 +60,10 @@ class AdventureApiTest {

@AfterEach
void clean() {
badgeRepository.deleteAll();
adventureRepository.deleteAll();
landmarkRepository.deleteAll();
userRepository.deleteAll();
badgeRepository.deleteAllInBatch();
adventureRepository.deleteAllInBatch();
landmarkRepository.deleteAllInBatch();
userRepository.deleteAllInBatch();
redisTemplate.delete(redisSetKey);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.playkuround.playkuroundserver.domain.appversion.api;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.playkuround.playkuroundserver.IntegrationControllerTest;
import com.playkuround.playkuroundserver.domain.appversion.api.request.UpdateAppVersionRequest;
import com.playkuround.playkuroundserver.domain.appversion.dao.AppVersionRepository;
import com.playkuround.playkuroundserver.domain.appversion.domain.AppVersion;
Expand All @@ -14,8 +15,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.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.MediaType;
import org.springframework.test.web.servlet.MockMvc;

Expand All @@ -27,8 +26,7 @@
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;

@AutoConfigureMockMvc
@SpringBootTest(properties = "spring.profiles.active=test")
@IntegrationControllerTest
class AppVersionApiTest {

@Autowired
Expand All @@ -45,8 +43,8 @@ class AppVersionApiTest {

@AfterEach
void afterEach() {
appVersionRepository.deleteAll();
userRepository.deleteAll();
appVersionRepository.deleteAllInBatch();
userRepository.deleteAllInBatch();
}

@Nested
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.fasterxml.jackson.databind.ObjectMapper;
import com.jayway.jsonpath.JsonPath;
import com.playkuround.playkuroundserver.IntegrationControllerTest;
import com.playkuround.playkuroundserver.domain.attendance.api.request.AttendanceRegisterRequest;
import com.playkuround.playkuroundserver.domain.attendance.application.AttendanceRegisterService;
import com.playkuround.playkuroundserver.domain.attendance.dao.AttendanceRepository;
Expand All @@ -20,8 +21,6 @@
import org.junit.jupiter.api.Test;
import org.mockito.MockitoAnnotations;
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.boot.test.mock.mockito.MockBean;
import org.springframework.boot.test.mock.mockito.SpyBean;
import org.springframework.data.auditing.AuditingHandler;
Expand All @@ -46,8 +45,7 @@
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;

@AutoConfigureMockMvc
@SpringBootTest(properties = "spring.profiles.active=test")
@IntegrationControllerTest
class AttendanceApiTest {

@Autowired
Expand All @@ -65,15 +63,16 @@ class AttendanceApiTest {
@Autowired
private AttendanceRepository attendanceRepository;

private final String redisSetKey = "ranking";
@Autowired
private RedisTemplate<String, String> redisTemplate;

private final String redisSetKey = "ranking";

@AfterEach
void clean() {
attendanceRepository.deleteAll();
badgeRepository.deleteAll();
userRepository.deleteAll();
attendanceRepository.deleteAllInBatch();
badgeRepository.deleteAllInBatch();
userRepository.deleteAllInBatch();
redisTemplate.delete(redisSetKey);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.fasterxml.jackson.databind.ObjectMapper;
import com.jayway.jsonpath.JsonPath;
import com.playkuround.playkuroundserver.IntegrationControllerTest;
import com.playkuround.playkuroundserver.domain.auth.email.api.request.AuthEmailSendRequest;
import com.playkuround.playkuroundserver.domain.auth.email.dao.AuthEmailRepository;
import com.playkuround.playkuroundserver.domain.auth.email.domain.AuthEmail;
Expand All @@ -15,8 +16,6 @@
import org.junit.jupiter.params.provider.NullAndEmptySource;
import org.junit.jupiter.params.provider.ValueSource;
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.boot.test.mock.mockito.MockBean;
import org.springframework.http.MediaType;
import org.springframework.test.web.servlet.MockMvc;
Expand All @@ -35,8 +34,7 @@
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;

@AutoConfigureMockMvc
@SpringBootTest(properties = "spring.profiles.active=test")
@IntegrationControllerTest
class AuthEmailSendApiTest {

@Autowired
Expand All @@ -56,8 +54,8 @@ class AuthEmailSendApiTest {

@AfterEach
void clean() {
authEmailRepository.deleteAll();
userRepository.deleteAll();
authEmailRepository.deleteAllInBatch();
userRepository.deleteAllInBatch();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.playkuround.playkuroundserver.domain.auth.email.api;

import com.jayway.jsonpath.JsonPath;
import com.playkuround.playkuroundserver.IntegrationControllerTest;
import com.playkuround.playkuroundserver.domain.auth.email.dao.AuthEmailRepository;
import com.playkuround.playkuroundserver.domain.auth.email.domain.AuthEmail;
import com.playkuround.playkuroundserver.domain.auth.token.dao.AuthVerifyTokenRepository;
Expand All @@ -16,8 +17,6 @@
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.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.MvcResult;

Expand All @@ -30,8 +29,7 @@
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;

@AutoConfigureMockMvc
@SpringBootTest(properties = "spring.profiles.active=test")
@IntegrationControllerTest
class AuthEmailVerifyApiTest {

@Autowired
Expand All @@ -51,10 +49,10 @@ class AuthEmailVerifyApiTest {

@AfterEach
void clean() {
authEmailRepository.deleteAll();
refreshTokenRepository.deleteAll();
authVerifyTokenRepository.deleteAll();
userRepository.deleteAll();
authEmailRepository.deleteAllInBatch();
refreshTokenRepository.deleteAllInBatch();
authVerifyTokenRepository.deleteAllInBatch();
userRepository.deleteAllInBatch();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.playkuround.playkuroundserver.domain.badge.api;

import com.playkuround.playkuroundserver.IntegrationControllerTest;
import com.playkuround.playkuroundserver.domain.badge.dao.BadgeRepository;
import com.playkuround.playkuroundserver.domain.badge.domain.Badge;
import com.playkuround.playkuroundserver.domain.badge.domain.BadgeType;
Expand All @@ -11,11 +12,6 @@
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.FilterType;
import org.springframework.test.web.servlet.MockMvc;

import java.util.List;
Expand All @@ -28,13 +24,7 @@
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;

@AutoConfigureMockMvc
@SpringBootTest(properties = "spring.profiles.active=test")
@ComponentScan(basePackages = {"com.playkuround.playkuroundserver.domain"},
excludeFilters = {
@ComponentScan.Filter(type = FilterType.REGEX, pattern = "com.playkuround.playkuroundserver.learning.*")
})
@EntityScan(basePackages = {"com.playkuround.playkuroundserver.domain"})
@IntegrationControllerTest
class BadgeApiTest {

@Autowired
Expand All @@ -48,8 +38,8 @@ class BadgeApiTest {

@AfterEach
void clean() {
badgeRepository.deleteAll();
userRepository.deleteAll();
badgeRepository.deleteAllInBatch();
userRepository.deleteAllInBatch();
}

@Nested
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.playkuround.playkuroundserver.domain.fakedoor.api;

import com.playkuround.playkuroundserver.IntegrationControllerTest;
import com.playkuround.playkuroundserver.domain.fakedoor.dao.FakeDoorRepository;
import com.playkuround.playkuroundserver.domain.fakedoor.domain.FakeDoor;
import com.playkuround.playkuroundserver.domain.user.dao.UserRepository;
Expand All @@ -8,8 +9,6 @@
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.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.web.servlet.MockMvc;

import java.util.List;
Expand All @@ -18,8 +17,7 @@
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;

@AutoConfigureMockMvc
@SpringBootTest(properties = "spring.profiles.active=test")
@IntegrationControllerTest
class FakeDoorApiTest {

@Autowired
Expand All @@ -33,8 +31,8 @@ class FakeDoorApiTest {

@AfterEach
void clean() {
fakeDoorRepository.deleteAll();
userRepository.deleteAll();
fakeDoorRepository.deleteAllInBatch();
userRepository.deleteAllInBatch();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.playkuround.playkuroundserver.domain.landmark.api;

import com.playkuround.playkuroundserver.IntegrationControllerTest;
import com.playkuround.playkuroundserver.domain.landmark.dao.LandmarkRepository;
import com.playkuround.playkuroundserver.domain.landmark.domain.Landmark;
import com.playkuround.playkuroundserver.domain.landmark.domain.LandmarkType;
Expand All @@ -11,8 +12,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.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.transaction.annotation.Transactional;

Expand All @@ -21,8 +20,7 @@
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;

@AutoConfigureMockMvc
@SpringBootTest(properties = "spring.profiles.active=test")
@IntegrationControllerTest
class LandmarkApiTest {

@Autowired
Expand All @@ -36,7 +34,7 @@ class LandmarkApiTest {

@AfterEach
void clear() {
userRepository.deleteAll();
userRepository.deleteAllInBatch();
}

@Nested
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.playkuround.playkuroundserver.domain.score.api;

import com.playkuround.playkuroundserver.IntegrationControllerTest;
import com.playkuround.playkuroundserver.TestUtil;
import com.playkuround.playkuroundserver.domain.adventure.dao.AdventureRepository;
import com.playkuround.playkuroundserver.domain.adventure.domain.Adventure;
Expand All @@ -15,8 +16,6 @@
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.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.MvcResult;

Expand All @@ -28,8 +27,7 @@
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;

@AutoConfigureMockMvc
@SpringBootTest(properties = "spring.profiles.active=test")
@IntegrationControllerTest
class LandmarkScoreRankApiTest {

@Autowired
Expand All @@ -46,8 +44,8 @@ class LandmarkScoreRankApiTest {

@AfterEach
void clean() {
adventureRepository.deleteAll();
userRepository.deleteAll();
adventureRepository.deleteAllInBatch();
userRepository.deleteAllInBatch();
}

@Test
Expand Down
Loading

0 comments on commit 1e211f4

Please sign in to comment.