Skip to content

Commit ae3435c

Browse files
committed
test/#368 : 식사 분석하는 API 통합 테스트 수정
1 parent c5ff22d commit ae3435c

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

BE/exceed/src/test/java/com/gaebaljip/exceed/integration/meal/SpecificMealIntegrationTest.java renamed to BE/exceed/src/test/java/com/gaebaljip/exceed/integration/meal/GetMealIntegrationTest.java

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import static com.gaebaljip.exceed.common.util.ApiDocumentUtil.getDocumentRequest;
44
import static com.gaebaljip.exceed.common.util.ApiDocumentUtil.getDocumentResponse;
5+
import static org.junit.jupiter.api.Assertions.assertFalse;
56
import static org.mockito.ArgumentMatchers.any;
67
import static org.mockito.BDDMockito.given;
78
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document;
@@ -25,20 +26,21 @@
2526
import com.gaebaljip.exceed.common.ApiResponse;
2627
import com.gaebaljip.exceed.common.IntegrationTest;
2728
import com.gaebaljip.exceed.common.WithMockUser;
29+
import com.gaebaljip.exceed.dto.AllAnalysisDTO;
2830
import com.gaebaljip.exceed.dto.response.GetMealFoodResponse;
2931
import com.gaebaljip.exceed.dto.response.GetMealResponse;
3032

3133
import lombok.extern.log4j.Log4j2;
3234

3335
@Log4j2
34-
public class SpecificMealIntegrationTest extends IntegrationTest {
36+
public class GetMealIntegrationTest extends IntegrationTest {
3537

3638
@MockBean private PresignedUrlPort getPresignedUrlPort;
3739

3840
@Test
39-
@DisplayName("오늘 먹은 식사 조회")
41+
@DisplayName("성공 : 오늘 먹은 식사 조회")
4042
@WithMockUser
41-
void getMeal() throws Exception {
43+
void when_getTodayMeal_expected_success() throws Exception {
4244
// when
4345
ResultActions resultActions =
4446
mockMvc.perform(
@@ -111,9 +113,10 @@ void getMeal() throws Exception {
111113
}
112114

113115
@Test
114-
@DisplayName("특정 날짜 식사 조회")
116+
@DisplayName("성공 : 특정 날짜 식사 조회"
117+
+ "특정 날짜에 방문하지 않았을 경우 isVisited가 false이고, 달성도 다 false로 나와야 한다.")
115118
@WithMockUser
116-
void getMealFood() throws Exception {
119+
void when_getSpecificMeal_expected_success() throws Exception {
117120

118121
LocalDate testData = LocalDate.of(2024, 6, 6);
119122

@@ -143,12 +146,21 @@ void getMealFood() throws Exception {
143146
.getMealResponse()
144147
.targetMealDTO()
145148
.calorie();
146-
int size = getMealFoodResponseCustomBody.getResponse().mealRecordDTOS().size();
149+
150+
AllAnalysisDTO allAnalysisDTO =
151+
getMealFoodResponseCustomBody.getResponse().allAnalysisDTO();
147152

148153
// 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+
}
149162
Assertions.assertThat(maintainCalorie).isGreaterThan(0);
150163
Assertions.assertThat(targetCalorie).isGreaterThan(maintainCalorie);
151-
Assertions.assertThat(size).isGreaterThanOrEqualTo(0);
152164
resultActions
153165
.andExpect(status().isOk())
154166
.andDo(

0 commit comments

Comments
 (0)