From 6a6f2739ffba6326d0b6160b9db7a92517abbb4b Mon Sep 17 00:00:00 2001 From: tiki <78459713+yh20studio@users.noreply.github.com> Date: Tue, 2 Aug 2022 11:36:15 +0900 Subject: [PATCH] =?UTF-8?q?[BE]=20=ED=8E=98=EC=9D=B4=EC=A7=80=20=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C=20=EC=8B=9C=20=EC=A4=91=EB=B3=B5=EB=90=98=EB=8A=94=20?= =?UTF-8?q?=EC=95=84=EC=9D=B4=ED=85=9C=20=EC=A1=B0=ED=9A=8C=EB=90=98?= =?UTF-8?q?=EB=8A=94=20=EC=9D=B4=EC=8A=88=20=ED=94=BC=EB=93=9C=EB=B0=B1=20?= =?UTF-8?q?=EB=B0=98=EC=98=81=EC=99=84=EB=A3=8C=20(#332)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit test: 제품을 조회할 때, 정렬 조건으로 id에 대한 역순을 적용하더라도, 정렬이 되는지 확인하는 test 추가 Co-authored-by: hamcheeseburger Co-authored-by: yangdongjue5510 Co-authored-by: hamcheeseburger Co-authored-by: yangdongjue5510 --- .../f12/acceptance/ProductAcceptanceTest.java | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/backend/src/test/java/com/woowacourse/f12/acceptance/ProductAcceptanceTest.java b/backend/src/test/java/com/woowacourse/f12/acceptance/ProductAcceptanceTest.java index 77815607..9588945e 100644 --- a/backend/src/test/java/com/woowacourse/f12/acceptance/ProductAcceptanceTest.java +++ b/backend/src/test/java/com/woowacourse/f12/acceptance/ProductAcceptanceTest.java @@ -127,7 +127,7 @@ class ProductAcceptanceTest extends AcceptanceTest { } @Test - void 리뷰_갯수가_같은_상태에서_제품_목록을_리뷰가_많은_순서로_페이징하여_조회하면_id_역순으로_조회된다() { + void 리뷰_개수가_같은_상태에서_제품_목록을_리뷰가_많은_순서로_페이징하여_조회하면_id_역순으로_조회된다() { // given Product product1 = 제품을_저장한다(KEYBOARD_1.생성()); Product product2 = 제품을_저장한다(KEYBOARD_2.생성()); @@ -149,6 +149,27 @@ class ProductAcceptanceTest extends AcceptanceTest { ); } + @Test + void 정렬_조건으로_id_역순으로_페이징하여_조회하면_id_역순으로_조회된다() { + // given + Product product1 = 제품을_저장한다(KEYBOARD_1.생성()); + Product product2 = 제품을_저장한다(KEYBOARD_2.생성()); + Product product3 = 제품을_저장한다(MOUSE_1.생성()); + + // when + ExtractableResponse response = GET_요청을_보낸다( + "/api/v1/products?page=0&size=3&sort=id,desc"); + + // then + assertAll( + () -> assertThat(response.statusCode()).isEqualTo(HttpStatus.OK.value()), + () -> assertThat(response.as(ProductPageResponse.class).getItems()) + .extracting("id") + .containsExactly(product3.getId(), product2.getId(), product1.getId()), + () -> assertThat(response.as(ProductPageResponse.class).isHasNext()).isFalse() + ); + } + @Test void 키보드_목록을_평점_높은_순서로_페이징하여_조회한다() { // given