Skip to content

Commit

Permalink
refactor: 테스트 실행시간 최적화 (#204)
Browse files Browse the repository at this point in the history
  • Loading branch information
5uhwann authored Nov 21, 2023
1 parent 631873f commit a0ec713
Show file tree
Hide file tree
Showing 31 changed files with 124 additions and 156 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
@WebAdapter
@RequestMapping("/api/v1/graduation")
@RequiredArgsConstructor
class CalculateGraduationController {
public class CalculateGraduationController {

private final CalculateGraduationUseCase calculateGraduationUseCase;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
@RequiredArgsConstructor
@RequestMapping("/api/v1/lectures")
@Validated
class SearchLectureController {
public class SearchLectureController {

private final SearchLectureUseCase searchLectureUseCase;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@

import com.plzgraduate.myongjigraduatebe.core.meta.LoginUser;
import com.plzgraduate.myongjigraduatebe.core.meta.WebAdapter;
import com.plzgraduate.myongjigraduatebe.parsing.application.port.in.ParsingTextCommand;
import com.plzgraduate.myongjigraduatebe.parsing.application.port.in.ParsingTextHistoryUseCase;
import com.plzgraduate.myongjigraduatebe.parsing.application.port.in.ParsingTextUseCase;
import com.plzgraduate.myongjigraduatebe.parsing.application.port.in.ParsingTextCommand;

import lombok.RequiredArgsConstructor;

@WebAdapter
@RequestMapping("/api/v1/parsing-text")
@RequiredArgsConstructor
class ParsingTextController {
public class ParsingTextController {

private final ParsingTextUseCase parsingTextUseCase;
private final ParsingTextHistoryUseCase parsingTextHistoryUseCase;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
@WebAdapter
@RequestMapping("/api/v1/taken-lectures")
@RequiredArgsConstructor
class UpdateTakenLectureController {
public class UpdateTakenLectureController {
private final UpdateTakenLectureUseCase updateTakenLectureUseCase;

@PostMapping("/update")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,12 @@

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 com.plzgraduate.myongjigraduatebe.auth.application.port.in.signin.SignInUseCase;
import com.plzgraduate.myongjigraduatebe.support.WebAdaptorTestSupport;

@WebMvcTest(controllers = SignInController.class)
class SignInControllerTest extends WebAdaptorTestSupport {

@MockBean
private SignInUseCase signInUseCase;

@DisplayName("로그인을 진행한다.")
@Test
void signIn() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@

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 com.plzgraduate.myongjigraduatebe.graduation.application.port.in.CalculateGraduationUseCase;
import com.plzgraduate.myongjigraduatebe.graduation.application.port.in.response.BasicInfoResponse;
import com.plzgraduate.myongjigraduatebe.graduation.application.port.in.response.ChapelResultResponse;
import com.plzgraduate.myongjigraduatebe.graduation.application.port.in.response.DetailGraduationResultResponse;
Expand All @@ -21,12 +18,8 @@
import com.plzgraduate.myongjigraduatebe.support.WebAdaptorTestSupport;
import com.plzgraduate.myongjigraduatebe.support.WithMockAuthenticationUser;

@WebMvcTest(controllers = CalculateGraduationController.class)
class CalculateGraduationControllerTest extends WebAdaptorTestSupport {

@MockBean
private CalculateGraduationUseCase calculateGraduationUseCase;

@WithMockAuthenticationUser
@DisplayName("유저의 졸업 결과를 계산한다.")
@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
package com.plzgraduate.myongjigraduatebe.graduation.adpater.out.persistence;

import static com.plzgraduate.myongjigraduatebe.user.domain.model.College.*;
import static com.plzgraduate.myongjigraduatebe.user.domain.model.College.BUSINESS;

import java.util.List;

import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Import;

import com.plzgraduate.myongjigraduatebe.fixture.UserFixture;
import com.plzgraduate.myongjigraduatebe.graduation.adpater.out.persistence.entity.GraduationRequirementJpaEntity;
import com.plzgraduate.myongjigraduatebe.graduation.domain.model.GraduationRequirement;
import com.plzgraduate.myongjigraduatebe.support.PersistenceTestSupport;
import com.plzgraduate.myongjigraduatebe.user.domain.model.User;

@Import({FindGraduationRequirementPersistenceAdapter.class, GraduationRequirementMapper.class})
class FindGraduationRequirementPersistenceAdapterTest extends PersistenceTestSupport {

private static final int SUB_MAJOR_CREDIT = 10;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Import;

import com.plzgraduate.myongjigraduatebe.graduation.adpater.out.persistence.entity.GraduationRequirementJpaEntity;
import com.plzgraduate.myongjigraduatebe.graduation.domain.model.GraduationRequirement;
import com.plzgraduate.myongjigraduatebe.support.PersistenceTestSupport;

@Import(GraduationRequirementMapper.class)
class GraduationRequirementMapperTest extends PersistenceTestSupport {

@Autowired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,25 @@

import static org.hamcrest.Matchers.hasSize;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.BDDMockito.given;
import static org.mockito.BDDMockito.then;
import static org.mockito.Mockito.times;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import static org.mockito.BDDMockito.given;

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 com.plzgraduate.myongjigraduatebe.lecture.application.port.in.search.LectureResponse;
import com.plzgraduate.myongjigraduatebe.lecture.application.port.in.search.SearchLectureResponse;
import com.plzgraduate.myongjigraduatebe.lecture.application.port.in.search.SearchLectureUseCase;
import com.plzgraduate.myongjigraduatebe.support.WithMockAuthenticationUser;
import com.plzgraduate.myongjigraduatebe.support.WebAdaptorTestSupport;
import com.plzgraduate.myongjigraduatebe.support.WithMockAuthenticationUser;

@WebMvcTest(controllers = SearchLectureController.class)
class SearchLectureControllerTest extends WebAdaptorTestSupport {
@MockBean
private SearchLectureUseCase searchLectureUseCase;

@WithMockAuthenticationUser
@DisplayName("type과 keyword를 통해 과목정보를 검색한다.")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
package com.plzgraduate.myongjigraduatebe.lecture.adapter.out;

import static org.assertj.core.api.Assertions.*;
import static org.assertj.core.api.Assertions.assertThat;

import java.util.List;

import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Import;

import com.plzgraduate.myongjigraduatebe.lecture.adapter.out.persistence.entity.LectureJpaEntity;
import com.plzgraduate.myongjigraduatebe.lecture.adapter.out.persistence.repository.LectureQueryRepository;
import com.plzgraduate.myongjigraduatebe.lecture.adapter.out.persistence.repository.LectureRepository;
import com.plzgraduate.myongjigraduatebe.support.PersistenceTestSupport;

@Import(TestQuerydslConfig.class)
class LectureQueryRepositoryTest extends PersistenceTestSupport {

@Autowired
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package com.plzgraduate.myongjigraduatebe.lecture.adapter.out.persistence;

import static com.plzgraduate.myongjigraduatebe.user.domain.model.College.*;
import static org.assertj.core.api.Assertions.*;
import static com.plzgraduate.myongjigraduatebe.user.domain.model.College.BUSINESS;
import static com.plzgraduate.myongjigraduatebe.user.domain.model.College.ICT;
import static org.assertj.core.api.Assertions.assertThat;

import java.util.List;
import java.util.Set;

import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Import;

import com.plzgraduate.myongjigraduatebe.fixture.UserFixture;
import com.plzgraduate.myongjigraduatebe.lecture.adapter.out.persistence.entity.BasicAcademicalCultureLectureJpaEntity;
Expand All @@ -20,7 +20,6 @@
import com.plzgraduate.myongjigraduatebe.support.PersistenceTestSupport;
import com.plzgraduate.myongjigraduatebe.user.domain.model.User;

@Import({LectureMapper.class, FindBasicAcademicalCulturePersistenceAdapter.class})
class FindBasicAcademicalCulturePersistenceAdapterTest extends PersistenceTestSupport {

@Autowired
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
package com.plzgraduate.myongjigraduatebe.lecture.adapter.out.persistence;

import static com.plzgraduate.myongjigraduatebe.lecture.domain.model.CommonCultureCategory.*;
import static org.assertj.core.api.Assertions.*;
import static com.plzgraduate.myongjigraduatebe.lecture.domain.model.CommonCultureCategory.ENGLISH;
import static org.assertj.core.api.Assertions.assertThat;

import java.util.List;
import java.util.Set;

import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Import;

import com.plzgraduate.myongjigraduatebe.fixture.UserFixture;
import com.plzgraduate.myongjigraduatebe.lecture.adapter.out.persistence.entity.CommonCultureJpaEntity;
Expand All @@ -20,7 +19,6 @@
import com.plzgraduate.myongjigraduatebe.support.PersistenceTestSupport;
import com.plzgraduate.myongjigraduatebe.user.domain.model.User;

@Import({LectureMapper.class, FindCommonCulturePersistenceAdapter.class})
class FindCommonCulturePersistenceAdapterTest extends PersistenceTestSupport {

private static final String ENGLISH1_CODE = "KMA02106";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.plzgraduate.myongjigraduatebe.lecture.adapter.out.persistence;

import static com.plzgraduate.myongjigraduatebe.lecture.domain.model.CoreCultureCategory.*;
import static com.plzgraduate.myongjigraduatebe.lecture.domain.model.CoreCultureCategory.CULTURE_ART;
import static com.plzgraduate.myongjigraduatebe.lecture.domain.model.CoreCultureCategory.SOCIETY_COMMUNITY;
import static org.assertj.core.api.Assertions.assertThat;

import java.util.List;
Expand All @@ -9,7 +10,6 @@
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Import;

import com.plzgraduate.myongjigraduatebe.fixture.UserFixture;
import com.plzgraduate.myongjigraduatebe.lecture.adapter.out.persistence.entity.CoreCultureJpaEntity;
Expand All @@ -20,7 +20,6 @@
import com.plzgraduate.myongjigraduatebe.support.PersistenceTestSupport;
import com.plzgraduate.myongjigraduatebe.user.domain.model.User;

@Import({LectureMapper.class, FindCoreCulturePersistenceAdapter.class})
class FindCoreCulturePersistenceAdapterTest extends PersistenceTestSupport {

@Autowired
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
package com.plzgraduate.myongjigraduatebe.lecture.adapter.out.persistence;

import static org.assertj.core.api.Assertions.*;
import static org.assertj.core.api.Assertions.assertThat;

import java.util.List;
import java.util.Set;

import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Import;

import com.plzgraduate.myongjigraduatebe.fixture.UserFixture;
import com.plzgraduate.myongjigraduatebe.lecture.adapter.out.persistence.entity.LectureJpaEntity;
Expand All @@ -19,7 +18,6 @@
import com.plzgraduate.myongjigraduatebe.support.PersistenceTestSupport;
import com.plzgraduate.myongjigraduatebe.user.domain.model.User;

@Import({LectureMapper.class, FindMajorPersistenceAdapter.class})
class FindMajorPersistenceAdapterTest extends PersistenceTestSupport {

@Autowired
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package com.plzgraduate.myongjigraduatebe.lecture.adapter.out.persistence;

import static com.plzgraduate.myongjigraduatebe.lecture.domain.model.CommonCultureCategory.*;
import static com.plzgraduate.myongjigraduatebe.lecture.domain.model.CoreCultureCategory.*;
import static org.assertj.core.api.Assertions.*;
import static com.plzgraduate.myongjigraduatebe.lecture.domain.model.CommonCultureCategory.CAREER;
import static com.plzgraduate.myongjigraduatebe.lecture.domain.model.CoreCultureCategory.CULTURE_ART;
import static org.assertj.core.api.Assertions.assertThat;

import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Import;

import com.plzgraduate.myongjigraduatebe.lecture.adapter.out.persistence.entity.BasicAcademicalCultureLectureJpaEntity;
import com.plzgraduate.myongjigraduatebe.lecture.adapter.out.persistence.entity.CommonCultureJpaEntity;
Expand All @@ -20,7 +19,6 @@
import com.plzgraduate.myongjigraduatebe.lecture.domain.model.MajorLecture;
import com.plzgraduate.myongjigraduatebe.support.PersistenceTestSupport;

@Import(LectureMapper.class)
class LectureMapperTest extends PersistenceTestSupport {

@Autowired
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.plzgraduate.myongjigraduatebe.lecture.adapter.out.persistence;

import static org.assertj.core.api.Assertions.*;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.tuple;

import java.util.ArrayList;
import java.util.List;
Expand All @@ -9,16 +10,13 @@
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Import;

import com.plzgraduate.myongjigraduatebe.lecture.adapter.out.TestQuerydslConfig;
import com.plzgraduate.myongjigraduatebe.lecture.adapter.out.persistence.entity.LectureJpaEntity;
import com.plzgraduate.myongjigraduatebe.lecture.adapter.out.persistence.repository.LectureQueryRepository;
import com.plzgraduate.myongjigraduatebe.lecture.adapter.out.persistence.repository.LectureRepository;
import com.plzgraduate.myongjigraduatebe.lecture.domain.model.Lecture;
import com.plzgraduate.myongjigraduatebe.support.PersistenceTestSupport;

@Import({LectureMapper.class, LecturePersistenceAdaptor.class, TestQuerydslConfig.class})
class LecturePersistenceAdaptorTest extends PersistenceTestSupport {

@Autowired
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.plzgraduate.myongjigraduatebe.parsing.adaptor.in.web;

import static org.mockito.BDDMockito.*;
import static org.mockito.BDDMockito.any;
import static org.mockito.BDDMockito.doThrow;
import static org.mockito.BDDMockito.then;
import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.csrf;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
Expand All @@ -9,27 +11,16 @@

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.test.web.servlet.ResultActions;

import com.plzgraduate.myongjigraduatebe.core.exception.InvalidPdfException;
import com.plzgraduate.myongjigraduatebe.parsing.application.port.in.ParsingTextCommand;
import com.plzgraduate.myongjigraduatebe.parsing.application.port.in.ParsingTextHistoryUseCase;
import com.plzgraduate.myongjigraduatebe.parsing.application.port.in.ParsingTextUseCase;
import com.plzgraduate.myongjigraduatebe.support.WithMockAuthenticationUser;
import com.plzgraduate.myongjigraduatebe.support.WebAdaptorTestSupport;
import com.plzgraduate.myongjigraduatebe.support.WithMockAuthenticationUser;

@WebMvcTest(controllers = ParsingTextController.class)
class ParsingTextControllerTest extends WebAdaptorTestSupport {

@MockBean
private ParsingTextUseCase parsingTextUseCase;

@MockBean
private ParsingTextHistoryUseCase parsingTextHistoryUseCase;

@WithMockAuthenticationUser
@DisplayName("파싱 텍스트를 등록한다.")
@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package com.plzgraduate.myongjigraduatebe.parsing.adaptor.out.persistence;

import static org.assertj.core.api.Assertions.*;
import static org.assertj.core.api.Assertions.assertThat;

import java.util.Optional;

import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Import;
import org.springframework.transaction.annotation.Transactional;

import com.plzgraduate.myongjigraduatebe.fixture.UserFixture;
Expand All @@ -18,7 +17,6 @@
import com.plzgraduate.myongjigraduatebe.user.adaptor.out.persistence.UserRepository;
import com.plzgraduate.myongjigraduatebe.user.domain.model.User;

@Import({ParsingTextHistoryAdaptor.class, ParsingTextHistoryMapper.class})
class ParsingTextHistoryAdaptorTest extends PersistenceTestSupport {

@Autowired
Expand Down
Loading

0 comments on commit a0ec713

Please sign in to comment.