diff --git a/src/main/java/ac/knu/likeknu/controller/dto/main/MainMenuResponse.java b/src/main/java/ac/knu/likeknu/controller/dto/main/MainMenuResponse.java index e36b082..593abb1 100644 --- a/src/main/java/ac/knu/likeknu/controller/dto/main/MainMenuResponse.java +++ b/src/main/java/ac/knu/likeknu/controller/dto/main/MainMenuResponse.java @@ -2,7 +2,7 @@ import ac.knu.likeknu.controller.dto.menu.MenuListDto; import ac.knu.likeknu.domain.Cafeteria; -import ac.knu.likeknu.domain.value.CafeteriaName; +import ac.knu.likeknu.domain.value.MealType; import lombok.Builder; import lombok.Getter; @@ -14,12 +14,14 @@ public class MainMenuResponse { private final String cafeteriaId; private final String cafeteriaName; + private final String mealType; private final List menus; @Builder - public MainMenuResponse(String cafeteriaId, String cafeteriaName, List menus) { + public MainMenuResponse(String cafeteriaId, String cafeteriaName, String mealType, List menus) { this.cafeteriaId = cafeteriaId; this.cafeteriaName = cafeteriaName; + this.mealType = mealType; this.menus = menus; } @@ -35,6 +37,7 @@ public static MainMenuResponse of(Cafeteria cafeteria, String menu) { return MainMenuResponse.builder() .cafeteriaId(cafeteria.getId()) .cafeteriaName(cafeteria.getCafeteriaName().getCafeteriaName()) + .mealType(MealType.now().getMealTypeKr()) .menus(menuList) .build(); } @@ -43,6 +46,7 @@ public static MainMenuResponse empty(Cafeteria cafeteria) { return MainMenuResponse.builder() .cafeteriaId(cafeteria.getId()) .cafeteriaName(cafeteria.getCafeteriaName().getCafeteriaName()) + .mealType(MealType.now().getMealTypeKr()) .menus(new ArrayList<>()) .build(); } diff --git a/src/main/java/ac/knu/likeknu/domain/value/MealType.java b/src/main/java/ac/knu/likeknu/domain/value/MealType.java index aafceb0..c0824c5 100644 --- a/src/main/java/ac/knu/likeknu/domain/value/MealType.java +++ b/src/main/java/ac/knu/likeknu/domain/value/MealType.java @@ -11,8 +11,8 @@ public enum MealType { BREAKFAST("아침", 9), LUNCH("점심", 14), DINNER("저녁", 19), - NIGHT("", 21), - DAWN("", 0); + NIGHT("밤", 21), + DAWN("새벽", 2); private final String mealTypeKr; private final int hour; @@ -27,7 +27,7 @@ public static MealType now() { return Stream.of(MealType.values()) .filter((MealType m) -> m.getHour() > hour) - .findAny() - .orElse(DAWN); + .findFirst() + .orElse(NIGHT); } } diff --git a/src/test/java/ac/knu/likeknu/controller/MainControllerTest.java b/src/test/java/ac/knu/likeknu/controller/MainControllerTest.java index 88ec7d6..cb36426 100644 --- a/src/test/java/ac/knu/likeknu/controller/MainControllerTest.java +++ b/src/test/java/ac/knu/likeknu/controller/MainControllerTest.java @@ -29,9 +29,7 @@ import static org.mockito.Mockito.when; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; @Slf4j @DisplayName("메인 컨트롤러 테스트") @@ -144,10 +142,10 @@ void getMenuResponsesAndSuccess() throws Exception { new MenuListDto(2, "testMenu2") ); - MainMenuResponse menuResponse1 = new MainMenuResponse("cafeteriaId1", "학생식당", menus); - MainMenuResponse menuResponse2 = new MainMenuResponse("cafeteriaId2", "생활관식당", menus); - MainMenuResponse menuResponse3 = new MainMenuResponse("cafeteriaId2", "생활관식당", menus); - MainMenuResponse menuResponse4 = new MainMenuResponse("cafeteriaId3", "직원식당", menus); + MainMenuResponse menuResponse1 = new MainMenuResponse("cafeteriaId1", "학생식당", "아침", menus); + MainMenuResponse menuResponse2 = new MainMenuResponse("cafeteriaId2", "생활관식당", "점심", menus); + MainMenuResponse menuResponse3 = new MainMenuResponse("cafeteriaId2", "생활관식당", "저녁", menus); + MainMenuResponse menuResponse4 = new MainMenuResponse("cafeteriaId3", "직원식당", "아침", menus); List menuResponses1 = new ArrayList<>(List.of(menuResponse1, menuResponse2, menuResponse4)); List menuResponses2 = new ArrayList<>(List.of(menuResponse1, menuResponse3, menuResponse4));