|
2 | 2 |
|
3 | 3 | import static com.gaebaljip.exceed.common.util.ApiDocumentUtil.getDocumentRequest;
|
4 | 4 | import static com.gaebaljip.exceed.common.util.ApiDocumentUtil.getDocumentResponse;
|
| 5 | +import static org.junit.jupiter.api.Assertions.assertFalse; |
5 | 6 | import static org.mockito.ArgumentMatchers.any;
|
6 | 7 | import static org.mockito.BDDMockito.given;
|
7 | 8 | import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document;
|
|
25 | 26 | import com.gaebaljip.exceed.common.ApiResponse;
|
26 | 27 | import com.gaebaljip.exceed.common.IntegrationTest;
|
27 | 28 | import com.gaebaljip.exceed.common.WithMockUser;
|
| 29 | +import com.gaebaljip.exceed.dto.AllAnalysisDTO; |
28 | 30 | import com.gaebaljip.exceed.dto.response.GetMealFoodResponse;
|
29 | 31 | import com.gaebaljip.exceed.dto.response.GetMealResponse;
|
30 | 32 |
|
31 | 33 | import lombok.extern.log4j.Log4j2;
|
32 | 34 |
|
33 | 35 | @Log4j2
|
34 |
| -public class SpecificMealIntegrationTest extends IntegrationTest { |
| 36 | +public class GetMealIntegrationTest extends IntegrationTest { |
35 | 37 |
|
36 | 38 | @MockBean private PresignedUrlPort getPresignedUrlPort;
|
37 | 39 |
|
38 | 40 | @Test
|
39 |
| - @DisplayName("오늘 먹은 식사 조회") |
| 41 | + @DisplayName("성공 : 오늘 먹은 식사 조회") |
40 | 42 | @WithMockUser
|
41 |
| - void getMeal() throws Exception { |
| 43 | + void when_getTodayMeal_expected_success() throws Exception { |
42 | 44 | // when
|
43 | 45 | ResultActions resultActions =
|
44 | 46 | mockMvc.perform(
|
@@ -111,9 +113,10 @@ void getMeal() throws Exception {
|
111 | 113 | }
|
112 | 114 |
|
113 | 115 | @Test
|
114 |
| - @DisplayName("특정 날짜 식사 조회") |
| 116 | + @DisplayName("성공 : 특정 날짜 식사 조회" |
| 117 | + + "특정 날짜에 방문하지 않았을 경우 isVisited가 false이고, 달성도 다 false로 나와야 한다.") |
115 | 118 | @WithMockUser
|
116 |
| - void getMealFood() throws Exception { |
| 119 | + void when_getSpecificMeal_expected_success() throws Exception { |
117 | 120 |
|
118 | 121 | LocalDate testData = LocalDate.of(2024, 6, 6);
|
119 | 122 |
|
@@ -143,12 +146,21 @@ void getMealFood() throws Exception {
|
143 | 146 | .getMealResponse()
|
144 | 147 | .targetMealDTO()
|
145 | 148 | .calorie();
|
146 |
| - int size = getMealFoodResponseCustomBody.getResponse().mealRecordDTOS().size(); |
| 149 | + |
| 150 | + AllAnalysisDTO allAnalysisDTO = |
| 151 | + getMealFoodResponseCustomBody.getResponse().allAnalysisDTO(); |
147 | 152 |
|
148 | 153 | // then
|
| 154 | + |
| 155 | + boolean isVisited = allAnalysisDTO.isVisited(); |
| 156 | + if (!isVisited) { |
| 157 | + assertFalse(allAnalysisDTO.isCalorieAchieved(), "CalorieAchieved가 true입니다."); |
| 158 | + assertFalse(allAnalysisDTO.isProteinAchieved(), "ProteinAchieved가 true입니다."); |
| 159 | + assertFalse(allAnalysisDTO.isFatAchieved(), "FatAchieved가 true입니다."); |
| 160 | + assertFalse(allAnalysisDTO.isCarbohydrateAchieved(), "CarbohydrateAchieved가 true입니다."); |
| 161 | + } |
149 | 162 | Assertions.assertThat(maintainCalorie).isGreaterThan(0);
|
150 | 163 | Assertions.assertThat(targetCalorie).isGreaterThan(maintainCalorie);
|
151 |
| - Assertions.assertThat(size).isGreaterThanOrEqualTo(0); |
152 | 164 | resultActions
|
153 | 165 | .andExpect(status().isOk())
|
154 | 166 | .andDo(
|
|
0 commit comments