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

식품 목록 조회 API 응답 형식 수정 #33

Merged
merged 2 commits into from
Jul 18, 2023
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
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package zipgo.controller.dto;

import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;
import zipgo.domain.PetFood;

public record GetPetFoodsResponse(List<PetFoodResponse> petFoods) {
public record GetPetFoodsResponse(@JsonProperty(value = "foodList") List<PetFoodResponse> petFoods) {

public static GetPetFoodsResponse from(List<PetFood> petFoods) {
List<PetFoodResponse> petFoodResponses = petFoods.stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
import io.restassured.http.ContentType;
import io.restassured.response.ExtractableResponse;
import io.restassured.response.Response;
import java.util.List;
import org.junit.jupiter.api.Test;
import zipgo.controller.dto.GetPetFoodsResponse;
import zipgo.controller.dto.PetFoodResponse;

public class PetFoodAcceptanceTest extends AcceptanceTest {

Expand All @@ -23,6 +25,19 @@ public class PetFoodAcceptanceTest extends AcceptanceTest {
assertThat(data.petFoods()).isNotEmpty();
}

@Test
void petFoods를_foodList로_직렬화한다() {
//given
ExtractableResponse<Response> response = given().contentType(ContentType.JSON)
.when().get("/pet-foods")
.then().extract();

//when
//then
List<PetFoodResponse> foodList = response.jsonPath().getList("foodList", PetFoodResponse.class);
assertThat(foodList).isNotEmpty();
}

@Test
void 키워드가_다이어트인_식품_조회_API() {
ExtractableResponse<Response> response = given().contentType(ContentType.JSON)
Expand Down