Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TEST] Get Buyer Paging #326

Merged
merged 2 commits into from
Feb 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions spring/src/docs/asciidoc/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down