From 29fd830414fa2c05d2179be7c79088bec1167171 Mon Sep 17 00:00:00 2001 From: devholic22 Date: Sun, 6 Oct 2024 22:51:40 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20FoodControllerWebMvcTest=20?= =?UTF-8?q?=ED=94=BD=EC=8A=A4=EC=B2=98=20=EC=9D=B4=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - FoodControllerWebMvcTest에 fixture 이용되도록 수정 --- .../food/ui/FoodControllerWebMvcTest.java | 24 ++----------------- 1 file changed, 2 insertions(+), 22 deletions(-) diff --git a/src/test/java/com/flab/eattofit/food/ui/FoodControllerWebMvcTest.java b/src/test/java/com/flab/eattofit/food/ui/FoodControllerWebMvcTest.java index 5f6caa6..c4bb765 100644 --- a/src/test/java/com/flab/eattofit/food/ui/FoodControllerWebMvcTest.java +++ b/src/test/java/com/flab/eattofit/food/ui/FoodControllerWebMvcTest.java @@ -13,7 +13,7 @@ import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; import org.springframework.test.web.servlet.MockMvc; -import java.math.BigDecimal; +import static com.flab.eattofit.food.fixture.FoodCreateRequestFixture.음식_생성_요청_햄버거; import static com.flab.eattofit.food.fixture.FoodFixture.음식_생성_응답_id있음; import static com.flab.eattofit.food.fixture.FoodSearchResponseFixture.음식_응답_비빔밥; import static com.flab.eattofit.helper.RestDocsHelper.customDocument; @@ -52,27 +52,7 @@ class FoodControllerWebMvcTest extends MockBeanInjection { @Test void 음식을_생성한다() throws Exception { // given - String name = "햄버거"; - BigDecimal servingSize = BigDecimal.valueOf(150.0); - String unit = "g"; - BigDecimal kcal = BigDecimal.valueOf(430.0); - BigDecimal carbohydrate = BigDecimal.valueOf(36.0); - BigDecimal protein = BigDecimal.valueOf(25.0); - BigDecimal fat = BigDecimal.valueOf(21.0); - BigDecimal sodium = BigDecimal.valueOf(636.0); - String url = "burger.jpg"; - - FoodCreateRequest request = new FoodCreateRequest( - name, - servingSize, - unit, - kcal, - carbohydrate, - protein, - fat, - sodium, - url - ); + FoodCreateRequest request = 음식_생성_요청_햄버거(); Long memberId = 1L; Food food = 음식_생성_응답_id있음(request, memberId); when(foodService.createFood(any(), any())).thenReturn(food);