From fe92a067378feb3c0dd3bd925f6f881ac5de5b55 Mon Sep 17 00:00:00 2001 From: 0x000000EF Date: Wed, 6 May 2026 12:08:03 +0900 Subject: [PATCH 01/12] refactor(QueryAllFormUseCase.java): overload execute method for pagination support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit AdminFormController.java에서 getFormList의 패이지네이션 지원을 위해 기존 execute를 오버로드한 새 함수를 만듦. --- .../maru/application/form/QueryAllFormUseCase.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/main/java/com/bamdoliro/maru/application/form/QueryAllFormUseCase.java b/src/main/java/com/bamdoliro/maru/application/form/QueryAllFormUseCase.java index a1ab6727..2bdc4311 100644 --- a/src/main/java/com/bamdoliro/maru/application/form/QueryAllFormUseCase.java +++ b/src/main/java/com/bamdoliro/maru/application/form/QueryAllFormUseCase.java @@ -12,6 +12,7 @@ import java.util.Comparator; import java.util.List; import java.util.Objects; +import java.util.stream.Collectors; @RequiredArgsConstructor @UseCase @@ -41,4 +42,16 @@ public List execute(FormStatus status, FormType type, String .map(FormSimpleResponse::new) .toList(); } + + // 하위 호환성을 유지해야하므로 execute 함수를 오버로드 + public List execute(FormStatus status, FormType type, String sort, int page, int size) { + List allForms = this.execute(status, type, sort); + + int skip = (page - 1) * size; + + return allForms.stream() + .skip(skip) + .limit(size) + .collect(Collectors.toList()); + } } \ No newline at end of file From 8f6d12a3bf9c2061edfbfd83c3c0d9f52df19034 Mon Sep 17 00:00:00 2001 From: 0x000000EF Date: Wed, 6 May 2026 12:14:34 +0900 Subject: [PATCH 02/12] refactor(AdminFormController.java): add pagination support to form query MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 명확히 하위 호환성을 준수하도록하였고 페이지네이션 파라미터가 부분적이더라도 기본값으로 처리되도록 하였습니다. --- .../presentation/form/AdminFormController.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/bamdoliro/maru/presentation/form/AdminFormController.java b/src/main/java/com/bamdoliro/maru/presentation/form/AdminFormController.java index c94acc88..d8c4df1b 100644 --- a/src/main/java/com/bamdoliro/maru/presentation/form/AdminFormController.java +++ b/src/main/java/com/bamdoliro/maru/presentation/form/AdminFormController.java @@ -91,10 +91,24 @@ public ListCommonResponse getFormList( @AuthenticationPrincipal(authority = Authority.ADMIN) User user, @RequestParam(name = "status", required = false) FormStatus status, @RequestParam(name = "type", required = false) FormType type, - @RequestParam(name = "sort", required = false) String sort + @RequestParam(name = "sort", required = false) String sort, + + // page와 size는 하위 호환성을 위해 required = false로 설정 + @RequestParam(name = "page", required = false) Integer page, + @RequestParam(name = "size", required = false) Integer size ) { + // 하위 호환성 유지를 위해 page와 size가 없는 경우 전체 조회를 수행 + if (page == null && size == null) { + return ListCommonResponse.ok( + queryAllFormUseCase.execute(status, type, sort) + ); + } + // page와 size가 둘중하나라 있는 경우 페이징 조회를 수행 + int pageNumber = (page != null) ? page : 1; + int pageSize = (size != null) ? size : 10; + return ListCommonResponse.ok( - queryAllFormUseCase.execute(status, type, sort) + queryAllFormUseCase.execute(status, type, sort, pageNumber, pageSize) ); } From a93adfc7683320dcfa0d224dab14e548847c8129 Mon Sep 17 00:00:00 2001 From: 0x000000EF Date: Wed, 6 May 2026 12:23:13 +0900 Subject: [PATCH 03/12] test(#389): add test for partial form retrieval with pagination MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 전체, 일부 모두 성공적으로 작동함을 확인하였습니다. --- .../form/AdminFormControllerTest.java | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/src/test/java/com/bamdoliro/maru/presentation/form/AdminFormControllerTest.java b/src/test/java/com/bamdoliro/maru/presentation/form/AdminFormControllerTest.java index 6770107a..959a7892 100644 --- a/src/test/java/com/bamdoliro/maru/presentation/form/AdminFormControllerTest.java +++ b/src/test/java/com/bamdoliro/maru/presentation/form/AdminFormControllerTest.java @@ -247,6 +247,45 @@ class AdminFormControllerTest extends RestDocsTestSupport { verify(queryAllFormUseCase, times(1)).execute(FormStatus.SUBMITTED, FormType.REGULAR, null); } + @Test + void 원서를_일부만_조회한다() throws Exception { + User user = UserFixture.createAdminUser(); + + given(authenticationArgumentResolver.supportsParameter(any(MethodParameter.class))).willReturn(true); + given(authenticationArgumentResolver.resolveArgument(any(), any(), any(), any())).willReturn(user); + + given(queryAllFormUseCase.execute(FormStatus.SUBMITTED, FormType.REGULAR, null, 1, 2)).willReturn(List.of( + FormFixture.createFormSimpleResponse(FormStatus.SUBMITTED), + FormFixture.createFormSimpleResponse(FormStatus.SUBMITTED) + )); + + mockMvc.perform(get("/admin/forms") + .param("status", FormStatus.SUBMITTED.name()) + .param("type", FormType.REGULAR.name()) + .param("page", "1") + .param("size", "2") + .cookie(AuthFixture.createAuthCookie()) + .accept(MediaType.APPLICATION_JSON) + ) + .andExpect(status().isOk()) + .andDo(restDocs.document( + requestCookies( + cookieWithName("accessToken") + .description("이것은.액세스.토큰") + ), + queryParameters( + parameterWithName("status").description("<>").optional(), + parameterWithName("type").description("<>").optional(), + parameterWithName("sort").description("정렬 기준").optional(), + parameterWithName("page").description("조회할 페이지 번호 (size, page둘다 null인 경우 전체 조회, size가 null 아니라면 1)").optional(), + parameterWithName("size").description("페이지당 데이터 개수 (size, page둘다 null인 경우 전체 조회, page가 null 아니라면 10)").optional() + ) + )); + + // 오버로딩된 페이징 메서드가 정확히 호출되었는지 검증합니다. + verify(queryAllFormUseCase, times(1)).execute(FormStatus.SUBMITTED, FormType.REGULAR, null, 1, 2); + } + @Test void 수험표_전체를_발급받는다() throws Exception { User user = UserFixture.createAdminUser(); From 844ac9f667c77600b528cdc720887f25e1fab7c5 Mon Sep 17 00:00:00 2001 From: 0x000000EF Date: Wed, 6 May 2026 15:38:38 +0900 Subject: [PATCH 04/12] test(#389): add test for partial form retrieval with pagination MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 전체, 일부 모두 성공적으로 작동함을 확인하였습니다. --- .../form/AdminFormControllerTest.java | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/test/java/com/bamdoliro/maru/presentation/form/AdminFormControllerTest.java b/src/test/java/com/bamdoliro/maru/presentation/form/AdminFormControllerTest.java index 959a7892..6635541b 100644 --- a/src/test/java/com/bamdoliro/maru/presentation/form/AdminFormControllerTest.java +++ b/src/test/java/com/bamdoliro/maru/presentation/form/AdminFormControllerTest.java @@ -9,6 +9,8 @@ import com.bamdoliro.maru.domain.user.domain.User; import com.bamdoliro.maru.presentation.form.dto.request.PassOrFailFormListRequest; import com.bamdoliro.maru.presentation.form.dto.request.PassOrFailFormRequest; +import com.bamdoliro.maru.presentation.form.dto.response.FormSimpleResponse; +import com.bamdoliro.maru.presentation.form.dto.response.PageResult; import com.bamdoliro.maru.shared.fixture.AuthFixture; import com.bamdoliro.maru.shared.fixture.FormFixture; import com.bamdoliro.maru.shared.fixture.UserFixture; @@ -27,10 +29,13 @@ import static org.mockito.BDDMockito.*; import static org.springframework.restdocs.cookies.CookieDocumentation.cookieWithName; import static org.springframework.restdocs.cookies.CookieDocumentation.requestCookies; +import static org.springframework.restdocs.headers.HeaderDocumentation.headerWithName; +import static org.springframework.restdocs.headers.HeaderDocumentation.responseHeaders; import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*; import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath; import static org.springframework.restdocs.payload.PayloadDocumentation.requestFields; import static org.springframework.restdocs.request.RequestDocumentation.*; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.header; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; class AdminFormControllerTest extends RestDocsTestSupport { @@ -254,10 +259,15 @@ class AdminFormControllerTest extends RestDocsTestSupport { given(authenticationArgumentResolver.supportsParameter(any(MethodParameter.class))).willReturn(true); given(authenticationArgumentResolver.resolveArgument(any(), any(), any(), any())).willReturn(user); - given(queryAllFormUseCase.execute(FormStatus.SUBMITTED, FormType.REGULAR, null, 1, 2)).willReturn(List.of( - FormFixture.createFormSimpleResponse(FormStatus.SUBMITTED), - FormFixture.createFormSimpleResponse(FormStatus.SUBMITTED) - )); + given(queryAllFormUseCase.execute(FormStatus.SUBMITTED, FormType.REGULAR, null, 1, 2)) + .willReturn(new PageResult<>( + List.of( + FormFixture.createFormSimpleResponse(FormStatus.SUBMITTED), + FormFixture.createFormSimpleResponse(FormStatus.SUBMITTED) + ), + 5L, + 3L + )); mockMvc.perform(get("/admin/forms") .param("status", FormStatus.SUBMITTED.name()) @@ -268,7 +278,13 @@ class AdminFormControllerTest extends RestDocsTestSupport { .accept(MediaType.APPLICATION_JSON) ) .andExpect(status().isOk()) + .andExpect(header().exists("X-Total-Count")) + .andExpect(header().exists("X-Total-Pages")) .andDo(restDocs.document( + responseHeaders( + headerWithName("X-Total-Count").description("필터링된 전체 원서의 개수"), + headerWithName("X-Total-Pages").description("전체 페이지 수") + ), requestCookies( cookieWithName("accessToken") .description("이것은.액세스.토큰") From 14a69321f54190a4e1e161a764b92d231adb2929 Mon Sep 17 00:00:00 2001 From: 0x000000EF Date: Wed, 6 May 2026 15:45:56 +0900 Subject: [PATCH 05/12] test(#389): add test for partial form retrieval with pagination --- .../form/QueryAllFormUseCaseTest.java | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/test/java/com/bamdoliro/maru/application/form/QueryAllFormUseCaseTest.java b/src/test/java/com/bamdoliro/maru/application/form/QueryAllFormUseCaseTest.java index a1d38bd8..2c96a086 100644 --- a/src/test/java/com/bamdoliro/maru/application/form/QueryAllFormUseCaseTest.java +++ b/src/test/java/com/bamdoliro/maru/application/form/QueryAllFormUseCaseTest.java @@ -4,6 +4,7 @@ import com.bamdoliro.maru.domain.form.domain.type.FormType; import com.bamdoliro.maru.infrastructure.persistence.form.FormRepository; import com.bamdoliro.maru.presentation.form.dto.response.FormSimpleResponse; +import com.bamdoliro.maru.presentation.form.dto.response.PageResult; import com.bamdoliro.maru.shared.fixture.FormFixture; import com.bamdoliro.maru.shared.util.RandomUtil; import org.junit.jupiter.api.Test; @@ -53,6 +54,31 @@ class QueryAllFormUseCaseTest { verify(formRepository, times(1)).findByStatus(null); } + @Test + void 일부_원서만_조회한다() { + // given + List
formList = List.of( + FormFixture.createForm(FormType.REGULAR), + FormFixture.createForm(FormType.SPECIAL_ADMISSION), + FormFixture.createForm(FormType.MEISTER_TALENT), + FormFixture.createForm(FormType.MULTI_CHILDREN) + ); + + formList.forEach(form -> form.assignExaminationNumber(1001L)); + + given(formRepository.findByStatus(null)).willReturn(formList); + + // when + PageResult returnedFormList = queryAllFormUseCase.execute(null, null,null, 1, 2); + + // then + assertEquals(2, returnedFormList.getTotalPages()); + assertEquals(2, returnedFormList.getData().size()); + assertEquals(FormType.REGULAR, returnedFormList.getData().get(0).getType()); + + verify(formRepository, times(1)).findByStatus(null); + } + @Test void 특별전형_원서만_조회한다() { // given From 9b27f9703eb370b4a46cc60cb204f5d67f26d8cd Mon Sep 17 00:00:00 2001 From: 0x000000EF Date: Wed, 6 May 2026 15:46:08 +0900 Subject: [PATCH 06/12] refactor(PageResult.java): create PageResult class for pagination response --- .../presentation/form/dto/response/PageResult.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 src/main/java/com/bamdoliro/maru/presentation/form/dto/response/PageResult.java diff --git a/src/main/java/com/bamdoliro/maru/presentation/form/dto/response/PageResult.java b/src/main/java/com/bamdoliro/maru/presentation/form/dto/response/PageResult.java new file mode 100644 index 00000000..b9095f6f --- /dev/null +++ b/src/main/java/com/bamdoliro/maru/presentation/form/dto/response/PageResult.java @@ -0,0 +1,14 @@ +package com.bamdoliro.maru.presentation.form.dto.response; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.List; + +@Getter +@AllArgsConstructor +public class PageResult { + List data; + long totalCount; + long totalPages; +} From fddabd360c61de160bb519e2377507d403344c81 Mon Sep 17 00:00:00 2001 From: 0x000000EF Date: Wed, 6 May 2026 15:47:29 +0900 Subject: [PATCH 07/12] refactor(AdminFormController.java): update getFormList method to return paginated response MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit DTO의 일관성을 유지하기 위해 DTO를 수정하는 대신 헤더로써 메타데이터를 반환토록 하였습니다. --- .../form/AdminFormController.java | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/bamdoliro/maru/presentation/form/AdminFormController.java b/src/main/java/com/bamdoliro/maru/presentation/form/AdminFormController.java index d8c4df1b..5215c973 100644 --- a/src/main/java/com/bamdoliro/maru/presentation/form/AdminFormController.java +++ b/src/main/java/com/bamdoliro/maru/presentation/form/AdminFormController.java @@ -8,6 +8,7 @@ import com.bamdoliro.maru.presentation.form.dto.response.AdmissionAndPledgeUrlResponse; import com.bamdoliro.maru.presentation.form.dto.response.FormSimpleResponse; import com.bamdoliro.maru.presentation.form.dto.response.FormUrlResponse; +import com.bamdoliro.maru.presentation.form.dto.response.PageResult; import com.bamdoliro.maru.shared.auth.AuthenticationPrincipal; import com.bamdoliro.maru.shared.auth.Authority; import com.bamdoliro.maru.shared.response.CommonResponse; @@ -87,29 +88,29 @@ public ListCommonResponse getSubmittedFormList( } @GetMapping - public ListCommonResponse getFormList( + public ResponseEntity> getFormList( @AuthenticationPrincipal(authority = Authority.ADMIN) User user, @RequestParam(name = "status", required = false) FormStatus status, @RequestParam(name = "type", required = false) FormType type, @RequestParam(name = "sort", required = false) String sort, - - // page와 size는 하위 호환성을 위해 required = false로 설정 @RequestParam(name = "page", required = false) Integer page, @RequestParam(name = "size", required = false) Integer size ) { - // 하위 호환성 유지를 위해 page와 size가 없는 경우 전체 조회를 수행 if (page == null && size == null) { - return ListCommonResponse.ok( - queryAllFormUseCase.execute(status, type, sort) + return ResponseEntity.ok( + ListCommonResponse.ok(queryAllFormUseCase.execute(status, type, sort)) ); } - // page와 size가 둘중하나라 있는 경우 페이징 조회를 수행 + int pageNumber = (page != null) ? page : 1; int pageSize = (size != null) ? size : 10; - return ListCommonResponse.ok( - queryAllFormUseCase.execute(status, type, sort, pageNumber, pageSize) - ); + PageResult result = queryAllFormUseCase.execute(status, type, sort, pageNumber, pageSize); + + return ResponseEntity.ok() + .header("X-Total-Count", String.valueOf(result.getTotalCount())) + .header("X-Total-Pages", String.valueOf(result.getTotalPages())) + .body(ListCommonResponse.ok(result.getData())); } @GetMapping("/admission-tickets") From e64dbf0331f2bc43f282e8730639a0828e4405a9 Mon Sep 17 00:00:00 2001 From: 0x000000EF Date: Wed, 6 May 2026 15:47:52 +0900 Subject: [PATCH 08/12] refactor(QueryAllFormUseCase.java): update execute method to return paginated results --- .../maru/application/form/QueryAllFormUseCase.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/bamdoliro/maru/application/form/QueryAllFormUseCase.java b/src/main/java/com/bamdoliro/maru/application/form/QueryAllFormUseCase.java index 2bdc4311..7c18ca8f 100644 --- a/src/main/java/com/bamdoliro/maru/application/form/QueryAllFormUseCase.java +++ b/src/main/java/com/bamdoliro/maru/application/form/QueryAllFormUseCase.java @@ -5,6 +5,7 @@ import com.bamdoliro.maru.domain.form.domain.type.FormType; import com.bamdoliro.maru.infrastructure.persistence.form.FormRepository; import com.bamdoliro.maru.presentation.form.dto.response.FormSimpleResponse; +import com.bamdoliro.maru.presentation.form.dto.response.PageResult; import com.bamdoliro.maru.shared.annotation.UseCase; import lombok.RequiredArgsConstructor; @@ -44,14 +45,18 @@ public List execute(FormStatus status, FormType type, String } // 하위 호환성을 유지해야하므로 execute 함수를 오버로드 - public List execute(FormStatus status, FormType type, String sort, int page, int size) { + public PageResult execute(FormStatus status, FormType type, String sort, int page, int size) { List allForms = this.execute(status, type, sort); - int skip = (page - 1) * size; + long totalCount = allForms.size(); + long totalPages = (long) Math.ceil((double) totalCount / size); - return allForms.stream() + int skip = (page - 1) * size; + List pagedData = allForms.stream() .skip(skip) .limit(size) - .collect(Collectors.toList()); + .toList(); + + return new PageResult<>(pagedData, totalCount, totalPages); } } \ No newline at end of file From 8ee1047a01681a690d22e4f3dad2a97b83beacb5 Mon Sep 17 00:00:00 2001 From: 0x000000EF Date: Sun, 10 May 2026 04:25:18 +0900 Subject: [PATCH 09/12] refactor(AdminFormController.java): update getFormList method to return PageResult for pagination --- .../presentation/form/AdminFormController.java | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/bamdoliro/maru/presentation/form/AdminFormController.java b/src/main/java/com/bamdoliro/maru/presentation/form/AdminFormController.java index 5215c973..d4535570 100644 --- a/src/main/java/com/bamdoliro/maru/presentation/form/AdminFormController.java +++ b/src/main/java/com/bamdoliro/maru/presentation/form/AdminFormController.java @@ -88,7 +88,7 @@ public ListCommonResponse getSubmittedFormList( } @GetMapping - public ResponseEntity> getFormList( + public ResponseEntity getFormList( @AuthenticationPrincipal(authority = Authority.ADMIN) User user, @RequestParam(name = "status", required = false) FormStatus status, @RequestParam(name = "type", required = false) FormType type, @@ -96,21 +96,10 @@ public ResponseEntity> getFormList( @RequestParam(name = "page", required = false) Integer page, @RequestParam(name = "size", required = false) Integer size ) { - if (page == null && size == null) { - return ResponseEntity.ok( - ListCommonResponse.ok(queryAllFormUseCase.execute(status, type, sort)) - ); - } - - int pageNumber = (page != null) ? page : 1; - int pageSize = (size != null) ? size : 10; - - PageResult result = queryAllFormUseCase.execute(status, type, sort, pageNumber, pageSize); + PageResult result = queryAllFormUseCase.execute(status, type, sort, page, size); return ResponseEntity.ok() - .header("X-Total-Count", String.valueOf(result.getTotalCount())) - .header("X-Total-Pages", String.valueOf(result.getTotalPages())) - .body(ListCommonResponse.ok(result.getData())); + .body(result); } @GetMapping("/admission-tickets") From c1c3bf95e5e7a212eb96fa5d651b3b89ec534355 Mon Sep 17 00:00:00 2001 From: 0x000000EF Date: Sun, 10 May 2026 04:25:30 +0900 Subject: [PATCH 10/12] refactor(QueryAllFormUseCase.java): enhance execute method for pagination support and update tests --- .../application/form/QueryAllFormUseCase.java | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/bamdoliro/maru/application/form/QueryAllFormUseCase.java b/src/main/java/com/bamdoliro/maru/application/form/QueryAllFormUseCase.java index 7c18ca8f..d4a2a8e0 100644 --- a/src/main/java/com/bamdoliro/maru/application/form/QueryAllFormUseCase.java +++ b/src/main/java/com/bamdoliro/maru/application/form/QueryAllFormUseCase.java @@ -13,7 +13,6 @@ import java.util.Comparator; import java.util.List; import java.util.Objects; -import java.util.stream.Collectors; @RequiredArgsConstructor @UseCase @@ -44,17 +43,23 @@ public List execute(FormStatus status, FormType type, String .toList(); } - // 하위 호환성을 유지해야하므로 execute 함수를 오버로드 - public PageResult execute(FormStatus status, FormType type, String sort, int page, int size) { + public PageResult execute(FormStatus status, FormType type, String sort, Integer page, Integer size) { List allForms = this.execute(status, type, sort); - long totalCount = allForms.size(); - long totalPages = (long) Math.ceil((double) totalCount / size); - int skip = (page - 1) * size; + if (page == null && size == null) { + return new PageResult<>(allForms, totalCount, 1); + } + + int validPage = (page != null) ? page : 1; + int validSize = (size != null) ? size : 10; + + long totalPages = (long) Math.ceil((double) totalCount / validSize); + int skip = (validPage - 1) * validSize; + List pagedData = allForms.stream() .skip(skip) - .limit(size) + .limit(validSize) .toList(); return new PageResult<>(pagedData, totalCount, totalPages); From 40177ab06710662eb2ae51411bd949d3850fd662 Mon Sep 17 00:00:00 2001 From: 0x000000EF Date: Sun, 10 May 2026 04:25:43 +0900 Subject: [PATCH 11/12] test(AdminFormControllerTest.java): update tests to validate pagination in form retrieval --- .../form/AdminFormControllerTest.java | 71 +++++++++---------- 1 file changed, 34 insertions(+), 37 deletions(-) diff --git a/src/test/java/com/bamdoliro/maru/presentation/form/AdminFormControllerTest.java b/src/test/java/com/bamdoliro/maru/presentation/form/AdminFormControllerTest.java index 6635541b..df18d874 100644 --- a/src/test/java/com/bamdoliro/maru/presentation/form/AdminFormControllerTest.java +++ b/src/test/java/com/bamdoliro/maru/presentation/form/AdminFormControllerTest.java @@ -32,11 +32,9 @@ import static org.springframework.restdocs.headers.HeaderDocumentation.headerWithName; import static org.springframework.restdocs.headers.HeaderDocumentation.responseHeaders; import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*; -import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath; -import static org.springframework.restdocs.payload.PayloadDocumentation.requestFields; +import static org.springframework.restdocs.payload.PayloadDocumentation.*; import static org.springframework.restdocs.request.RequestDocumentation.*; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.header; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; class AdminFormControllerTest extends RestDocsTestSupport { @@ -222,13 +220,16 @@ class AdminFormControllerTest extends RestDocsTestSupport { given(authenticationArgumentResolver.supportsParameter(any(MethodParameter.class))).willReturn(true); given(authenticationArgumentResolver.resolveArgument(any(), any(), any(), any())).willReturn(user); - given(queryAllFormUseCase.execute(FormStatus.SUBMITTED, FormType.REGULAR, null)).willReturn(List.of( - FormFixture.createFormSimpleResponse(FormStatus.SUBMITTED), - FormFixture.createFormSimpleResponse(FormStatus.SUBMITTED), - FormFixture.createFormSimpleResponse(FormStatus.SUBMITTED), - FormFixture.createFormSimpleResponse(FormStatus.SUBMITTED), - FormFixture.createFormSimpleResponse(FormStatus.SUBMITTED) - )); + + given(queryAllFormUseCase.execute(FormStatus.SUBMITTED, FormType.REGULAR, null, 1, 2)) + .willReturn(new PageResult<>( + List.of( + FormFixture.createFormSimpleResponse(FormStatus.SUBMITTED), + FormFixture.createFormSimpleResponse(FormStatus.SUBMITTED) + ), + 5L, + 3L + )); mockMvc.perform(get("/admin/forms") .param("status", FormStatus.SUBMITTED.name()) @@ -237,21 +238,23 @@ class AdminFormControllerTest extends RestDocsTestSupport { .accept(MediaType.APPLICATION_JSON) ) .andExpect(status().isOk()) + .andExpect(jsonPath("$.data").isArray()) + .andExpect(jsonPath("$.data.length()").value(2)) .andDo(restDocs.document( requestCookies( - cookieWithName("accessToken") - .description("이것은.액세스.토큰") + cookieWithName("accessToken").description("이것은.액세스.토큰") ), queryParameters( - parameterWithName("status").description("<>").optional(), - parameterWithName("type").description("<>").optional(), - parameterWithName("sort").description("정렬 기준").optional() + parameterWithName("status").description("<<원서 상태 (null인 경우 전체 조회)>>").optional(), + parameterWithName("type").description("<<원서 카테고리 (null인 경우 전체 조회)>>").optional(), + parameterWithName("sort").description("정렬 기준").optional(), + parameterWithName("page").description("조회할 페이지 번호 (size, page둘다 null인 경우 전체 조회, size가 null 아니라면 1)").optional(), + parameterWithName("size").description("페이지당 데이터 개수 (size, page둘다 null인 경우 전체 조회, page가 null 아니라면 10)").optional() ) )); - verify(queryAllFormUseCase, times(1)).execute(FormStatus.SUBMITTED, FormType.REGULAR, null); + verify(queryAllFormUseCase, times(1)).execute(FormStatus.SUBMITTED, FormType.REGULAR, null, 1, 2); } - @Test void 원서를_일부만_조회한다() throws Exception { User user = UserFixture.createAdminUser(); @@ -260,14 +263,14 @@ class AdminFormControllerTest extends RestDocsTestSupport { given(authenticationArgumentResolver.resolveArgument(any(), any(), any(), any())).willReturn(user); given(queryAllFormUseCase.execute(FormStatus.SUBMITTED, FormType.REGULAR, null, 1, 2)) - .willReturn(new PageResult<>( - List.of( - FormFixture.createFormSimpleResponse(FormStatus.SUBMITTED), - FormFixture.createFormSimpleResponse(FormStatus.SUBMITTED) - ), - 5L, - 3L - )); + .willReturn(new PageResult<>( + List.of( + FormFixture.createFormSimpleResponse(FormStatus.SUBMITTED), + FormFixture.createFormSimpleResponse(FormStatus.SUBMITTED) + ), + 5L, + 3L + )); mockMvc.perform(get("/admin/forms") .param("status", FormStatus.SUBMITTED.name()) @@ -278,27 +281,21 @@ class AdminFormControllerTest extends RestDocsTestSupport { .accept(MediaType.APPLICATION_JSON) ) .andExpect(status().isOk()) - .andExpect(header().exists("X-Total-Count")) - .andExpect(header().exists("X-Total-Pages")) + .andExpect(jsonPath("$.data").isArray()) + .andExpect(jsonPath("$.data.length()").value(2)) .andDo(restDocs.document( - responseHeaders( - headerWithName("X-Total-Count").description("필터링된 전체 원서의 개수"), - headerWithName("X-Total-Pages").description("전체 페이지 수") - ), requestCookies( - cookieWithName("accessToken") - .description("이것은.액세스.토큰") + cookieWithName("accessToken").description("이것은.액세스.토큰") ), queryParameters( - parameterWithName("status").description("<>").optional(), - parameterWithName("type").description("<>").optional(), + parameterWithName("status").description("<<원서 상태 (null인 경우 전체 조회)>>").optional(), + parameterWithName("type").description("<<원서 카테고리 (null인 경우 전체 조회)>>").optional(), parameterWithName("sort").description("정렬 기준").optional(), parameterWithName("page").description("조회할 페이지 번호 (size, page둘다 null인 경우 전체 조회, size가 null 아니라면 1)").optional(), parameterWithName("size").description("페이지당 데이터 개수 (size, page둘다 null인 경우 전체 조회, page가 null 아니라면 10)").optional() ) )); - // 오버로딩된 페이징 메서드가 정확히 호출되었는지 검증합니다. verify(queryAllFormUseCase, times(1)).execute(FormStatus.SUBMITTED, FormType.REGULAR, null, 1, 2); } From 0ca4e3e6432c1c92148368c5aeef6379d74d8bc9 Mon Sep 17 00:00:00 2001 From: 0x000000EF Date: Sun, 10 May 2026 04:26:44 +0900 Subject: [PATCH 12/12] refactor(AdminFormControllerTest.java): remove unused imports for cleaner test code --- .../maru/presentation/form/AdminFormControllerTest.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/test/java/com/bamdoliro/maru/presentation/form/AdminFormControllerTest.java b/src/test/java/com/bamdoliro/maru/presentation/form/AdminFormControllerTest.java index df18d874..46aa2fea 100644 --- a/src/test/java/com/bamdoliro/maru/presentation/form/AdminFormControllerTest.java +++ b/src/test/java/com/bamdoliro/maru/presentation/form/AdminFormControllerTest.java @@ -9,7 +9,6 @@ import com.bamdoliro.maru.domain.user.domain.User; import com.bamdoliro.maru.presentation.form.dto.request.PassOrFailFormListRequest; import com.bamdoliro.maru.presentation.form.dto.request.PassOrFailFormRequest; -import com.bamdoliro.maru.presentation.form.dto.response.FormSimpleResponse; import com.bamdoliro.maru.presentation.form.dto.response.PageResult; import com.bamdoliro.maru.shared.fixture.AuthFixture; import com.bamdoliro.maru.shared.fixture.FormFixture; @@ -29,8 +28,6 @@ import static org.mockito.BDDMockito.*; import static org.springframework.restdocs.cookies.CookieDocumentation.cookieWithName; import static org.springframework.restdocs.cookies.CookieDocumentation.requestCookies; -import static org.springframework.restdocs.headers.HeaderDocumentation.headerWithName; -import static org.springframework.restdocs.headers.HeaderDocumentation.responseHeaders; import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*; import static org.springframework.restdocs.payload.PayloadDocumentation.*; import static org.springframework.restdocs.request.RequestDocumentation.*;