Skip to content

Commit

Permalink
refactor: FoodControllerWebMvcTest 픽스처 이용
Browse files Browse the repository at this point in the history
- FoodControllerWebMvcTest에 fixture 이용되도록 수정
  • Loading branch information
devholic22 committed Oct 6, 2024
1 parent 8d15d63 commit 29fd830
Showing 1 changed file with 2 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 29fd830

Please sign in to comment.