From 35708db1a73fe4ac9e847e4bfd23317d4ac8c413 Mon Sep 17 00:00:00 2001 From: lowgiant Date: Sun, 13 Feb 2022 21:47:09 +0900 Subject: [PATCH 1/2] test: Get Buyer Paging [#325] --- .../buyer/controller/BuyerControllerTest.java | 97 +++++++++++++++---- 1 file changed, 78 insertions(+), 19 deletions(-) diff --git a/spring/src/test/java/com/bancow/bancowback/domain/sub/buyer/controller/BuyerControllerTest.java b/spring/src/test/java/com/bancow/bancowback/domain/sub/buyer/controller/BuyerControllerTest.java index 123a482f..7056aac0 100644 --- a/spring/src/test/java/com/bancow/bancowback/domain/sub/buyer/controller/BuyerControllerTest.java +++ b/spring/src/test/java/com/bancow/bancowback/domain/sub/buyer/controller/BuyerControllerTest.java @@ -47,33 +47,92 @@ void getBuyerDistribute() throws Exception { @Test @Transactional - void editBuyer() throws Exception { + void getBuyerPaging() throws Exception { Manager adminManager = adminManagerLogin(); Token tokenAdmin = tokenRepository.findByManager(adminManager).get(); mockMvc.perform( - patch("/api/buyer/edit") - .contentType(MediaType.APPLICATION_JSON) + get("/api/buyer") + .param("page", "0") .header("TOKEN", tokenAdmin.getToken()) - .content(readJson("/json/buyer/update.json")) ) - .andExpect(status().isOk()) - .andDo(restDocs.document( - requestHeaders( - headerWithName("TOKEN").description("해당 로그인 유저의 토큰값") - ), - requestFields( - fieldWithPath("id").description("번호"), - fieldWithPath("status").description("공개여부 값") - ), - responseFields( - fieldWithPath("data").description("결과 데이터"), - fieldWithPath("data.result").description("인증 성공 여부"), - fieldWithPath("data.message").description("response 메시지"), - fieldWithPath("status").description("HTTP Status") + .andDo( + restDocs.document( + requestHeaders( + headerWithName("TOKEN").description("해당 로그인 유저의 토큰값") + ), + requestParameters( + parameterWithName("page").description("페이징 처리를 위한 페이지 값 (0부터 시작)") + ), + responseFields( + fieldWithPath("data").description("결과 데이터"), + fieldWithPath("data.content").description("정보"), + fieldWithPath("data.content[0].id").description("id (pk)"), + fieldWithPath("data.content[0].title").description("제목"), + fieldWithPath("data.content[0].buyer_name").description("구매자이름"), + fieldWithPath("data.content[0].user_name").description("관리자 이름"), + fieldWithPath("data.content[0].farm_name").description("농장이름"), + fieldWithPath("data.content[0].status").description("배포 상태 값"), + fieldWithPath("data.content[0].create_date").description("생성된 시간"), + fieldWithPath("data.pageable").description("Pageable 설명"), + fieldWithPath("data.pageable.sort").description("페이지 정렬 설명"), + fieldWithPath("data.pageable.sort.empty").description("비어있는 지 여부"), + fieldWithPath("data.pageable.sort.unsorted").description("비정렬 여부"), + fieldWithPath("data.pageable.sort.sorted").description("정렬 여부"), + fieldWithPath("data.pageable.offset").description("Skip할 데이터 양"), + fieldWithPath("data.pageable.pageNumber").description("페이지 번호"), + fieldWithPath("data.pageable.pageSize").description("페이지 크기"), + fieldWithPath("data.pageable.paged").description("페이지 수를 매긴 여부"), + fieldWithPath("data.pageable.unpaged").description("페이지 수를 매기지 않은 여부"), + fieldWithPath("data.totalPages").description("총 페이지"), + fieldWithPath("data.totalElements").description("모든 데이터 개수"), + fieldWithPath("data.last").description("마지막 페이지 여부"), + fieldWithPath("data.size").description("한 페이지에서 보여줄 데이터의 개수"), + fieldWithPath("data.numberOfElements").description("모든 데이터 개수"), + fieldWithPath("data.number").description("페이지 번호"), + fieldWithPath("data.sort").description("data 정렬 설명"), + fieldWithPath("data.sort.empty").description("비어있는 지 여부"), + fieldWithPath("data.sort.unsorted").description("비정렬 여부"), + fieldWithPath("data.sort.sorted").description("정렬 여부"), + fieldWithPath("data.first").description("첫번째 페이지 여부"), + fieldWithPath("data.empty").description("비어있는 지 여부"), + fieldWithPath("status").description("HTTP Status") + ) ) - )); + ); + } + @Test + @Transactional + void editBuyer() throws Exception { + Manager adminManager = adminManagerLogin(); + Token tokenAdmin = tokenRepository.findByManager(adminManager).get(); + + mockMvc.perform( + patch("/api/buyer/edit") + .contentType(MediaType.APPLICATION_JSON) + .header("TOKEN", tokenAdmin.getToken()) + .content(readJson("/json/buyer/update.json")) + ) + + .andExpect(status().isOk()) + .andDo(restDocs.document( + requestHeaders( + headerWithName("TOKEN").description("해당 로그인 유저의 토큰값") + ), + requestFields( + fieldWithPath("id").description("번호"), + fieldWithPath("status").description("공개여부 값") + ), + responseFields( + fieldWithPath("data").description("결과 데이터"), + fieldWithPath("data.result").description("인증 성공 여부"), + fieldWithPath("data.message").description("response 메시지"), + fieldWithPath("status").description("HTTP Status") + ) + ) + ); + } @Test From 03b649cee519e9dd11feb2ac4e2dea00cafb0be2 Mon Sep 17 00:00:00 2001 From: lowgiant Date: Sun, 13 Feb 2022 21:47:24 +0900 Subject: [PATCH 2/2] docs: Get Buyer Paging [#325] --- spring/src/docs/asciidoc/index.adoc | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/spring/src/docs/asciidoc/index.adoc b/spring/src/docs/asciidoc/index.adoc index a7e723b7..4823b6c4 100644 --- a/spring/src/docs/asciidoc/index.adoc +++ b/spring/src/docs/asciidoc/index.adoc @@ -1291,6 +1291,25 @@ include::{snippets}/buyer-controller-test/get-buyer-distribute/response-body.ado ==== Response Fields include::{snippets}/buyer-controller-test/get-buyer-distribute/response-fields.adoc[] +[[구매자-페이징]] +=== 구매자 5개씩 가져오기 +==== Curl Request +include::{snippets}/buyer-controller-test/get-buyer-paging/curl-request.adoc[] +==== Http Request +include::{snippets}/buyer-controller-test/get-buyer-paging/http-request.adoc[] +==== Http Response +include::{snippets}/buyer-controller-test/get-buyer-paging/http-response.adoc[] +==== Httpie Request +include::{snippets}/buyer-controller-test/get-buyer-paging/httpie-request.adoc[] +==== Request Header +include::{snippets}/buyer-controller-test/get-buyer-paging/request-headers.adoc[] +==== Request Parameters +include::{snippets}/buyer-controller-test/get-buyer-paging/request-parameters.adoc[] +==== Response Body +include::{snippets}/buyer-controller-test/get-buyer-paging/response-body.adoc[] +==== Response Fields +include::{snippets}/buyer-controller-test/get-buyer-paging/response-fields.adoc[] + [[구매자-수정]] === 구매자 배포 유무만 수정 ==== Curl Request