Skip to content

Commit

Permalink
test(#160): 어드민 분석기능 변경에 따른 테스트 수정
Browse files Browse the repository at this point in the history
- 어드민 분석기능이 변경됨에 따라서 테스트를 수정했어요.
  • Loading branch information
cabbage16 committed Oct 18, 2024
1 parent a7a6556 commit 311f917
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class QueryGenderRatioUseCaseTest {

given(formRepository.findByCategory(FormType.Category.REGULAR)).willReturn(formList);
List<FormStatus> round = List.of(FormStatus.FIRST_PASSED, FormStatus.FAILED, FormStatus.PASSED);
GenderRatioRequest request = new GenderRatioRequest(round, FormType.Category.REGULAR);
GenderRatioRequest request = new GenderRatioRequest(round, FormType.Category.REGULAR, "CURRENT");

// when
List<GenderRatioResponse> responseList = queryGenderRatioUseCase.execute(request);
Expand Down Expand Up @@ -79,7 +79,7 @@ class QueryGenderRatioUseCaseTest {
.filter(form -> form.getType().categoryEquals(FormType.Category.SOCIAL_INTEGRATION))
.toList());
List<FormStatus> round = List.of(FormStatus.FIRST_PASSED, FormStatus.FAILED, FormStatus.PASSED);
GenderRatioRequest request = new GenderRatioRequest(round, FormType.Category.SPECIAL);
GenderRatioRequest request = new GenderRatioRequest(round, FormType.Category.SPECIAL, "CURRENT");

// when
List<GenderRatioResponse> responseList = queryGenderRatioUseCase.execute(request);
Expand Down Expand Up @@ -115,7 +115,7 @@ class QueryGenderRatioUseCaseTest {
.filter(form -> form.getType().categoryEquals(FormType.Category.SPECIAL_ADMISSION))
.toList());
List<FormStatus> round = List.of(FormStatus.FIRST_PASSED, FormStatus.FAILED, FormStatus.PASSED);
GenderRatioRequest request = new GenderRatioRequest(round, FormType.Category.SUPERNUMERARY);
GenderRatioRequest request = new GenderRatioRequest(round, FormType.Category.SUPERNUMERARY, "CURRENT");

// when
List<GenderRatioResponse> responseList = queryGenderRatioUseCase.execute(request);
Expand Down Expand Up @@ -143,7 +143,7 @@ class QueryGenderRatioUseCaseTest {

given(formRepository.findByCategory(FormType.Category.REGULAR)).willReturn(formList);
List<FormStatus> round = List.of(FormStatus.FAILED, FormStatus.PASSED);
GenderRatioRequest request = new GenderRatioRequest(round, FormType.Category.REGULAR);
GenderRatioRequest request = new GenderRatioRequest(round, FormType.Category.REGULAR, "CURRENT");

// when
List<GenderRatioResponse> responseList = queryGenderRatioUseCase.execute(request);
Expand Down Expand Up @@ -181,7 +181,7 @@ class QueryGenderRatioUseCaseTest {
.filter(form -> form.getType().categoryEquals(FormType.Category.SOCIAL_INTEGRATION))
.toList());
List<FormStatus> round = List.of(FormStatus.FAILED, FormStatus.PASSED);
GenderRatioRequest request = new GenderRatioRequest(round, FormType.Category.SPECIAL);
GenderRatioRequest request = new GenderRatioRequest(round, FormType.Category.SPECIAL, "CURRENT");

// when
List<GenderRatioResponse> responseList = queryGenderRatioUseCase.execute(request);
Expand Down Expand Up @@ -217,7 +217,7 @@ class QueryGenderRatioUseCaseTest {
.filter(form -> form.getType().categoryEquals(FormType.Category.SPECIAL_ADMISSION))
.toList());
List<FormStatus> round = List.of(FormStatus.FAILED, FormStatus.PASSED);
GenderRatioRequest request = new GenderRatioRequest(round, FormType.Category.SUPERNUMERARY);
GenderRatioRequest request = new GenderRatioRequest(round, FormType.Category.SUPERNUMERARY, "CURRENT");

// when
List<GenderRatioResponse> responseList = queryGenderRatioUseCase.execute(request);
Expand Down Expand Up @@ -245,7 +245,7 @@ class QueryGenderRatioUseCaseTest {

given(formRepository.findByCategory(FormType.Category.REGULAR)).willReturn(formList);
List<FormStatus> round = List.of(FormStatus.PASSED);
GenderRatioRequest request = new GenderRatioRequest(round, FormType.Category.REGULAR);
GenderRatioRequest request = new GenderRatioRequest(round, FormType.Category.REGULAR, "CURRENT");

// when
List<GenderRatioResponse> responseList = queryGenderRatioUseCase.execute(request);
Expand Down Expand Up @@ -283,7 +283,7 @@ class QueryGenderRatioUseCaseTest {
.filter(form -> form.getType().categoryEquals(FormType.Category.SOCIAL_INTEGRATION))
.toList());
List<FormStatus> round = List.of(FormStatus.PASSED);
GenderRatioRequest request = new GenderRatioRequest(round, FormType.Category.SPECIAL);
GenderRatioRequest request = new GenderRatioRequest(round, FormType.Category.SPECIAL, "CURRENT");

// when
List<GenderRatioResponse> responseList = queryGenderRatioUseCase.execute(request);
Expand Down Expand Up @@ -319,7 +319,7 @@ class QueryGenderRatioUseCaseTest {
.filter(form -> form.getType().categoryEquals(FormType.Category.SPECIAL_ADMISSION))
.toList());
List<FormStatus> round = List.of(FormStatus.FIRST_PASSED, FormStatus.FAILED, FormStatus.PASSED);
GenderRatioRequest request = new GenderRatioRequest(round, FormType.Category.SUPERNUMERARY);
GenderRatioRequest request = new GenderRatioRequest(round, FormType.Category.SUPERNUMERARY, "CURRENT");

// when
List<GenderRatioResponse> responseList = queryGenderRatioUseCase.execute(request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class QueryNumberOfApplicantsUseCaseTest {
given(formRepository.findTypeAndCountGroupByType()).willReturn(voList);

// when
List<NumberOfApplicantsResponse> responseList = queryNumberOfApplicantsUseCase.execute();
List<NumberOfApplicantsResponse> responseList = queryNumberOfApplicantsUseCase.execute("CURRENT");

// then
assertEquals(responseList.size(), FormType.values().length);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,21 @@ class AnalysisControllerTest extends RestDocsTestSupport {
User user = UserFixture.createAdminUser();
given(authenticationArgumentResolver.supportsParameter(any(MethodParameter.class))).willReturn(true);
given(authenticationArgumentResolver.resolveArgument(any(), any(), any(), any())).willReturn(user);
given(queryNumberOfApplicantsUseCase.execute()).willReturn(AnalysisFixture.createNumberOfApplicantsResponseList());
given(queryNumberOfApplicantsUseCase.execute(any(String.class))).willReturn(AnalysisFixture.createNumberOfApplicantsResponseList());

mockMvc.perform(get("/analysis/number-of-applicants")
.param("type", "CURRENT")
.header(HttpHeaders.AUTHORIZATION, AuthFixture.createAuthHeader())
.accept(MediaType.APPLICATION_JSON)
.contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
.andDo(restDocs.document(
requestHeaders(
headerWithName(HttpHeaders.AUTHORIZATION).description("Bearer token")
),
queryParameters(
parameterWithName("type")
.description("CURRENT(지원전형) / ORIGINAL(최종 전형)")
)
));
}
Expand All @@ -71,7 +76,7 @@ class AnalysisControllerTest extends RestDocsTestSupport {
),
queryParameters(
parameterWithName("statusList")
.description("조회할 원서 상태 목록(1차 합격자면 FIRST_PASSED, FAILED, PASSED, 2차 전형자면 FAILED, PASSED, 최종 합격자면 PASSED)")
.description("조회할 원서 상태 목록(전체 조회면, RECEIVED, FIRST_PASSED, FAILED, PASSED, 1차 합격자면 FIRST_PASSED, FAILED, PASSED, 2차 전형자면 FAILED, PASSED, 최종 합격자면 PASSED)")
)
));
}
Expand All @@ -97,7 +102,7 @@ class AnalysisControllerTest extends RestDocsTestSupport {
),
queryParameters(
parameterWithName("statusList")
.description("조회할 원서 상태 목록(1차 합격자면 FIRST_PASSED, FAILED, PASSED, 2차 전형자면 FAILED, PASSED, 최종 합격자면 PASSED)")
.description("조회할 원서 상태 목록(전체 조회면, RECEIVED, FIRST_PASSED, FAILED, PASSED, 1차 합격자면 FIRST_PASSED, FAILED, PASSED, 2차 전형자면 FAILED, PASSED, 최종 합격자면 PASSED)")
)
));
}
Expand All @@ -123,7 +128,7 @@ class AnalysisControllerTest extends RestDocsTestSupport {
),
queryParameters(
parameterWithName("statusList")
.description("조회할 원서 상태 목록(1차 합격자면 FIRST_PASSED, FAILED, PASSED, 2차 전형자면 FAILED, PASSED, 최종 합격자면 PASSED)")
.description("조회할 원서 상태 목록(전체 조회면, RECEIVED, FIRST_PASSED, FAILED, PASSED, 1차 합격자면 FIRST_PASSED, FAILED, PASSED, 2차 전형자면 FAILED, PASSED, 최종 합격자면 PASSED)")
)
));
}
Expand All @@ -136,6 +141,7 @@ class AnalysisControllerTest extends RestDocsTestSupport {
MultiValueMap<String, String> multiValueMap = new LinkedMultiValueMap<>();
multiValueMap.put("statusList", List.of("FIRST_PASSED", "FAILED", "PASSED"));
multiValueMap.add("mainCategory", "REGULAR");
multiValueMap.add("type", "CURRENT");
given(queryGenderRatioUseCase.execute(any(GenderRatioRequest.class))).willReturn(AnalysisFixture.createGenderRatioResponse(
FormType.Category.valueOf(Objects.requireNonNull(multiValueMap.get("mainCategory")).get(0))
));
Expand All @@ -154,9 +160,11 @@ class AnalysisControllerTest extends RestDocsTestSupport {
),
queryParameters(
parameterWithName("statusList")
.description("조회할 원서 상태 목록(1차 합격자면 FIRST_PASSED, FAILED, PASSED, 2차 전형자면 FAILED, PASSED, 최종 합격자면 PASSED)"),
.description("조회할 원서 상태 목록(전체 조회면, RECEIVED, FIRST_PASSED, FAILED, PASSED, 1차 합격자면 FIRST_PASSED, FAILED, PASSED, 2차 전형자면 FAILED, PASSED, 최종 합격자면 PASSED)"),
parameterWithName("mainCategory")
.description("메인 카테고리(FormType.Category 참고)")
.description("메인 카테고리(FormType.Category 참고)"),
parameterWithName("type")
.description("CURRENT(지원전형) / ORIGINAL(최종 전형)")
)
));
}
Expand Down Expand Up @@ -186,7 +194,7 @@ class AnalysisControllerTest extends RestDocsTestSupport {
),
queryParameters(
parameterWithName("statusList")
.description("조회할 원서 상태 목록(1차 합격자면 FIRST_PASSED, FAILED, PASSED, 2차 전형자면 FAILED, PASSED, 최종 합격자면 PASSED)"),
.description("조회할 원서 상태 목록(전체 조회면, RECEIVED, FIRST_PASSED, FAILED, PASSED, 1차 합격자면 FIRST_PASSED, FAILED, PASSED, 2차 전형자면 FAILED, PASSED, 최종 합격자면 PASSED)"),
parameterWithName("isBusan")
.description("부산 지역 학교 검색 여부(true면 부산, false면 부산 외 다른 모든 타지역)"),
parameterWithName("gu")
Expand Down Expand Up @@ -220,7 +228,7 @@ class AnalysisControllerTest extends RestDocsTestSupport {
),
queryParameters(
parameterWithName("statusList")
.description("조회할 원서 상태 목록(1차 합격자면 FIRST_PASSED, FAILED, PASSED, 2차 전형자면 FAILED, PASSED, 최종 합격자면 PASSED)"),
.description("조회할 원서 상태 목록(전체 조회면, RECEIVED, FIRST_PASSED, FAILED, PASSED, 1차 합격자면 FIRST_PASSED, FAILED, PASSED, 2차 전형자면 FAILED, PASSED, 최종 합격자면 PASSED)"),
parameterWithName("isBusan")
.description("부산 지역 학교 검색 여부(true면 부산, false면 부산 외 다른 모든 타지역)"),
parameterWithName("gu")
Expand Down Expand Up @@ -254,7 +262,7 @@ class AnalysisControllerTest extends RestDocsTestSupport {
),
queryParameters(
parameterWithName("statusList")
.description("조회할 원서 상태 목록(1차 합격자면 FIRST_PASSED, FAILED, PASSED, 2차 전형자면 FAILED, PASSED, 최종 합격자면 PASSED)"),
.description("조회할 원서 상태 목록(전체 조회면, RECEIVED, FIRST_PASSED, FAILED, PASSED, 1차 합격자면 FIRST_PASSED, FAILED, PASSED, 2차 전형자면 FAILED, PASSED, 최종 합격자면 PASSED)"),
parameterWithName("isBusan")
.description("부산 지역 학교 검색 여부(true면 부산, false면 부산 외 다른 모든 타지역)"),
parameterWithName("gu")
Expand Down

0 comments on commit 311f917

Please sign in to comment.