Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…o test/#353
  • Loading branch information
LJH098 committed Jul 4, 2024
2 parents bce1e05 + 266f549 commit 0d3c372
Show file tree
Hide file tree
Showing 6 changed files with 110 additions and 67 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import java.time.LocalTime;
import java.util.List;

import com.gaebaljip.exceed.dto.FoodDTO;
import com.gaebaljip.exceed.meal.domain.MealType;

import lombok.Builder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class GetAnalysisController {

private final GetAnalysisUsecase getAnalysisUsecase;

@Operation(summary = "특정 월의 분석 조회", description = "특정 월의 분석을 조회한다.")
@Operation(summary = "월별 식사 정보 분석", description = "월별 식사 정보를 분석한다.")
@GetMapping("/achieve/{date}")
@ApiErrorExceptionsExample(GetAnalysisExceptionDocs.class)
public ApiResponse<ApiResponse.CustomBody<GetAnalysisResponse>> getAnalysis(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,34 +21,10 @@ public class Nutritionist {
private DailyMeal dailyMeal;
private Member member;

public boolean evaluateProteinAchieve() {
return member.measureTargetProtein() - getCurrentProtein() <= 0;
}

public boolean evaluateFatAchieve() {
return member.measureTargetFat() - getCurrentFat() <= 0;
}

public boolean evaluateCarbohydrateAchieve() {
return member.measureTargetCarbohydrate() - getCurrentCarbohydrate() <= 0;
}

public boolean evaluateCalorieAchieve() {
return member.measureTargetCalorie() - getCurrentCalorie() <= 0;
}

private Double getCurrentProtein() {
return dailyMeal.calculateCurrentProtein();
}

private Double getCurrentFat() {
return dailyMeal.calculateCurrentFat();
}

private Double getCurrentCarbohydrate() {
return dailyMeal.calculateCurrentCarbohydrate();
}

private Double getCurrentCalorie() {
return dailyMeal.calculateCurrentCalorie();
}
Expand Down
128 changes: 100 additions & 28 deletions BE/exceed/src/main/resources/db/testData.sql
Original file line number Diff line number Diff line change
@@ -1,11 +1,28 @@

INSERT INTO MEMBER_TB (MEMBER_PK, CREATED_DATE, UPDATED_DATE, MEMBER_ACTIVITY, MEMBER_AGE, MEMBER_ETC, MEMBER_GENDER,
MEMBER_HEIGHT, MEMBER_WEIGHT, MEMBER_TARGET_WEIGHT, MEMBER_EMAIL, MEMBER_PASSWORD, MEMBER_ROLE, MEMBER_CHECKED)
VALUES (1, '2023-12-01 08:00:00', '2023-12-01 08:00:00', 'NOT_ACTIVE', 30, '비고 없음', 1, 175.0, 61.0, 66.0, 'abcd123!@gmail.com',
VALUES (1, '2023-12-01 08:00:00', '2023-12-01 08:00:00', 'NOT_ACTIVE', 30, '비고 없음', 1, 175.0, 70.0, 68.0, 'abcd123!@gmail.com',
'$2a$10$pljAKl0Ad3LnjQyQei.Yz.0Cfcn3Zv/xeBMDwUHDaUrfG8Wm57c56', 'MEMBER', true),
(2, '2023-12-01 08:00:00', '2023-12-01 08:00:00', 'NOT_ACTIVE', 30, '비고 없음', 1, 175.0, 61.0, 66.0, 'abcd234@@gmail.com',
(2, '2023-12-01 08:00:00', '2023-12-01 08:00:00', 'NOT_ACTIVE', 30, '비고 없음', 1, 178.0, 72.0, 69.0, 'abcd234@@gmail.com',
'$2a$10$pljAKl0Ad3LnjQyQei.Yz.2Cfcn3Zv/xeBMDwUHDaUrfG8Wm57c56', 'MEMBER', true),
(3, '2023-12-01 08:00:00', '2023-12-01 08:00:00', 'NOT_ACTIVE', 30, '비고 없음', 1, 165.0, 60.0, 58.0, 'abcd345@@gmail.com',
'$2a$10$pljAKl0Ad3LnjQyQei.Yz.3Cfcn3Zv/xeBMDwUHDaUrfG8Wm57c56', 'MEMBER', true),
(4, '2023-12-01 08:00:00', '2023-12-01 08:00:00', 'NOT_ACTIVE', 30, '비고 없음', 1, 180.0, 75.0, 72.0, 'abcd456@@gmail.com',
'$2a$10$pljAKl0Ad3LnjQyQei.Yz.4Cfcn3Zv/xeBMDwUHDaUrfG8Wm57c56', 'MEMBER', true),
(5, '2023-12-01 08:00:00', '2023-12-01 08:00:00', 'NOT_ACTIVE', 30, '비고 없음', 1, 170.0, 68.0, 65.0, 'abcd567@@gmail.com',
'$2a$10$pljAKl0Ad3LnjQyQei.Yz.5Cfcn3Zv/xeBMDwUHDaUrfG8Wm57c56', 'MEMBER', true),
(6, '2023-12-01 08:00:00', '2023-12-01 08:00:00', 'NOT_ACTIVE', 30, '비고 없음', 1, 177.0, 71.0, 67.0, 'abcd678@@gmail.com',
'$2a$10$pljAKl0Ad3LnjQyQei.Yz.6Cfcn3Zv/xeBMDwUHDaUrfG8Wm57c56', 'MEMBER', true),
(7, '2023-12-01 08:00:00', '2023-12-01 08:00:00', 'NOT_ACTIVE', 30, '비고 없음', 1, 169.0, 69.0, 64.0, 'abcd789@@gmail.com',
'$2a$10$pljAKl0Ad3LnjQyQei.Yz.7Cfcn3Zv/xeBMDwUHDaUrfG8Wm57c56', 'MEMBER', true),
(8, '2023-12-01 08:00:00', '2023-12-01 08:00:00', 'NOT_ACTIVE', 30, '비고 없음', 1, 181.0, 74.0, 70.0, 'abcd890@@gmail.com',
'$2a$10$pljAKl0Ad3LnjQyQei.Yz.8Cfcn3Zv/xeBMDwUHDaUrfG8Wm57c56', 'MEMBER', true),
(9, '2023-12-01 08:00:00', '2023-12-01 08:00:00', 'NOT_ACTIVE', 30, '비고 없음', 1, 168.0, 65.0, 62.0, 'abcd901@@gmail.com',
'$2a$10$pljAKl0Ad3LnjQyQei.Yz.9Cfcn3Zv/xeBMDwUHDaUrfG8Wm57c56', 'MEMBER', true),
(10, '2023-12-01 08:00:00', '2023-12-01 08:00:00', 'NOT_ACTIVE', 30, '비고 없음', 1, 172.0, 66.0, 63.0, 'abcd012@@gmail.com',
'$2a$10$pljAKl0Ad3LnjQyQei.Yz.0Cfcn3Zv/xeBMDwUHDaUrfG8Wm57c56', 'MEMBER', true);


INSERT INTO HISTORY_TB(HISTORY_PK, CREATED_DATE, UPDATED_DATE, HISTORY_ACTIVITY,HISTORY_AGE,HISTORY_GENDER,HISTORY_HEIGHT, HISTORY_WEIGHT, MEMBER_FK)

VALUES(1, '2023-11-20 08:00:00', '2023-11-20 08:00:00', 'NOT_ACTIVE', 30, 1, 175.0, 65.8, 1);
Expand Down Expand Up @@ -103,19 +120,46 @@ VALUES
(28, TIMESTAMPADD(DAY, -19, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -19, CURRENT_TIMESTAMP), 'LUNCH', 1),
(29, TIMESTAMPADD(DAY, -18, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -18, CURRENT_TIMESTAMP), 'BREAKFAST', 1),
(30, TIMESTAMPADD(DAY, -18, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -18, CURRENT_TIMESTAMP), 'LUNCH', 1),
(31, TIMESTAMPADD(DAY, -4, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -4, CURRENT_TIMESTAMP), 'LUNCH', 1),
(32, TIMESTAMPADD(DAY, -4, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -4, CURRENT_TIMESTAMP), 'DINNER', 1),
(33, TIMESTAMPADD(DAY, -3, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -3, CURRENT_TIMESTAMP), 'SNACK', 1),
(34, TIMESTAMPADD(DAY, -3, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -3, CURRENT_TIMESTAMP), 'LUNCH', 1),
(35, TIMESTAMPADD(DAY, -3, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -3, CURRENT_TIMESTAMP), 'DINNER', 1),
(36, TIMESTAMPADD(DAY, -2, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -2, CURRENT_TIMESTAMP), 'BREAKFAST', 1),
(37, TIMESTAMPADD(DAY, -2, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -2, CURRENT_TIMESTAMP), 'SNACK', 1),
(38, TIMESTAMPADD(DAY, -2, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -2, CURRENT_TIMESTAMP), 'DINNER', 1),
(39, TIMESTAMPADD(DAY, -1, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -1, CURRENT_TIMESTAMP), 'BREAKFAST', 1),
(40, TIMESTAMPADD(DAY, -1, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -1, CURRENT_TIMESTAMP), 'LUNCH', 1),
(41, TIMESTAMPADD(DAY, -1, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -1, CURRENT_TIMESTAMP), 'DINNER', 1),
(42, TIMESTAMPADD(DAY, 0, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, 0, CURRENT_TIMESTAMP), 'BREAKFAST', 1),
(43, TIMESTAMPADD(DAY, 0, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, 0, CURRENT_TIMESTAMP), 'LUNCH', 1);
(31, TIMESTAMPADD(DAY, -17, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -17, CURRENT_TIMESTAMP), 'BREAKFAST', 1),
(32, TIMESTAMPADD(DAY, -17, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -17, CURRENT_TIMESTAMP), 'LUNCH', 1),
(33, TIMESTAMPADD(DAY, -16, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -16, CURRENT_TIMESTAMP), 'BREAKFAST', 1),
(34, TIMESTAMPADD(DAY, -16, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -16, CURRENT_TIMESTAMP), 'LUNCH', 1),
(35, TIMESTAMPADD(DAY, -15, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -15, CURRENT_TIMESTAMP), 'BREAKFAST', 1),
(36, TIMESTAMPADD(DAY, -15, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -15, CURRENT_TIMESTAMP), 'LUNCH', 1),
(37, TIMESTAMPADD(DAY, -14, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -14, CURRENT_TIMESTAMP), 'BREAKFAST', 1),
(38, TIMESTAMPADD(DAY, -14, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -14, CURRENT_TIMESTAMP), 'LUNCH', 1),
(39, TIMESTAMPADD(DAY, -13, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -13, CURRENT_TIMESTAMP), 'BREAKFAST', 1),
(40, TIMESTAMPADD(DAY, -13, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -13, CURRENT_TIMESTAMP), 'LUNCH', 1),
(41, TIMESTAMPADD(DAY, -12, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -12, CURRENT_TIMESTAMP), 'BREAKFAST', 1),
(42, TIMESTAMPADD(DAY, -12, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -12, CURRENT_TIMESTAMP), 'LUNCH', 1),
(43, TIMESTAMPADD(DAY, -11, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -11, CURRENT_TIMESTAMP), 'BREAKFAST', 1),
(44, TIMESTAMPADD(DAY, -11, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -11, CURRENT_TIMESTAMP), 'LUNCH', 1),
(45, TIMESTAMPADD(DAY, -10, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -10, CURRENT_TIMESTAMP), 'BREAKFAST', 1),
(46, TIMESTAMPADD(DAY, -10, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -10, CURRENT_TIMESTAMP), 'LUNCH', 1),
(47, TIMESTAMPADD(DAY, -9, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -9, CURRENT_TIMESTAMP), 'BREAKFAST', 1),
(48, TIMESTAMPADD(DAY, -9, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -9, CURRENT_TIMESTAMP), 'LUNCH', 1),
(49, TIMESTAMPADD(DAY, -8, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -8, CURRENT_TIMESTAMP), 'BREAKFAST', 1),
(50, TIMESTAMPADD(DAY, -8, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -8, CURRENT_TIMESTAMP), 'LUNCH', 1),
(51, TIMESTAMPADD(DAY, -7, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -7, CURRENT_TIMESTAMP), 'BREAKFAST', 1),
(52, TIMESTAMPADD(DAY, -7, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -7, CURRENT_TIMESTAMP), 'LUNCH', 1),
(53, TIMESTAMPADD(DAY, -6, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -6, CURRENT_TIMESTAMP), 'BREAKFAST', 1),
(54, TIMESTAMPADD(DAY, -6, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -6, CURRENT_TIMESTAMP), 'LUNCH', 1),
(55, TIMESTAMPADD(DAY, -5, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -5, CURRENT_TIMESTAMP), 'BREAKFAST', 1),
(56, TIMESTAMPADD(DAY, -5, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -5, CURRENT_TIMESTAMP), 'LUNCH', 1),
(57, TIMESTAMPADD(DAY, -4, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -4, CURRENT_TIMESTAMP), 'LUNCH', 1),
(58, TIMESTAMPADD(DAY, -4, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -4, CURRENT_TIMESTAMP), 'DINNER', 1),
(59, TIMESTAMPADD(DAY, -3, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -3, CURRENT_TIMESTAMP), 'SNACK', 1),
(60, TIMESTAMPADD(DAY, -3, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -3, CURRENT_TIMESTAMP), 'LUNCH', 1),
(61, TIMESTAMPADD(DAY, -3, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -3, CURRENT_TIMESTAMP), 'DINNER', 1),
(62, TIMESTAMPADD(DAY, -2, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -2, CURRENT_TIMESTAMP), 'BREAKFAST', 1),
(63, TIMESTAMPADD(DAY, -2, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -2, CURRENT_TIMESTAMP), 'SNACK', 1),
(64, TIMESTAMPADD(DAY, -2, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -2, CURRENT_TIMESTAMP), 'DINNER', 1),
(65, TIMESTAMPADD(DAY, -1, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -1, CURRENT_TIMESTAMP), 'BREAKFAST', 1),
(66, TIMESTAMPADD(DAY, -1, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -1, CURRENT_TIMESTAMP), 'LUNCH', 1),
(67, TIMESTAMPADD(DAY, -1, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -1, CURRENT_TIMESTAMP), 'DINNER', 1),
(68, TIMESTAMPADD(DAY, 0, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, 0, CURRENT_TIMESTAMP), 'BREAKFAST', 1),
(69, TIMESTAMPADD(DAY, 0, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, 0, CURRENT_TIMESTAMP), 'LUNCH', 1);



INSERT INTO MEAL_FOOD_TB (MEAL_FOOD_PK, CREATED_DATE, UPDATED_DATE, FOOD_FK, MEAL_FK, MEAL_FOOD_MULTIPLE, MEAL_FOOD_G)
Expand Down Expand Up @@ -150,16 +194,44 @@ VALUES
(28, TIMESTAMPADD(DAY, -19, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -19, CURRENT_TIMESTAMP), 2, 28, null, 200),
(29, TIMESTAMPADD(DAY, -18, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -18, CURRENT_TIMESTAMP), 3, 29, 1.5, null),
(30, TIMESTAMPADD(DAY, -18, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -18, CURRENT_TIMESTAMP), 4, 30, null, 150),
(31, TIMESTAMPADD(DAY, -4, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -4, CURRENT_TIMESTAMP), 24, 31, 2.1, null),
(32, TIMESTAMPADD(DAY, -4, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -4, CURRENT_TIMESTAMP), 23, 32, null, 110),
(33, TIMESTAMPADD(DAY, -3, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -3, CURRENT_TIMESTAMP), 33, 33, 1.4, null),
(34, TIMESTAMPADD(DAY, -3, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -3, CURRENT_TIMESTAMP), 32, 34, null, 130),
(35, TIMESTAMPADD(DAY, -3, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -3, CURRENT_TIMESTAMP), 3, 35, 1.6, null),
(36, TIMESTAMPADD(DAY, -2, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -2, CURRENT_TIMESTAMP), 42, 36, null, 170),
(37, TIMESTAMPADD(DAY, -2, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -2, CURRENT_TIMESTAMP), 12, 37, 1.8, null),
(38, TIMESTAMPADD(DAY, -2, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -2, CURRENT_TIMESTAMP), 27, 38, null, 120),
(39, TIMESTAMPADD(DAY, -1, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -1, CURRENT_TIMESTAMP), 29, 39, 1.9, null),
(40, TIMESTAMPADD(DAY, -1, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -1, CURRENT_TIMESTAMP), 30, 40, null, 140),
(41, TIMESTAMPADD(DAY, -1, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -1, CURRENT_TIMESTAMP), 42, 41, 1.0, null),
(42, TIMESTAMPADD(DAY, 0, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, 0, CURRENT_TIMESTAMP), 40, 42, null, 180),
(43, TIMESTAMPADD(DAY, 0, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, 0, CURRENT_TIMESTAMP), 23, 43, 2.2, null);
(31, TIMESTAMPADD(DAY, -17, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -17, CURRENT_TIMESTAMP), 5, 31, 2.0, null),
(32, TIMESTAMPADD(DAY, -17, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -17, CURRENT_TIMESTAMP), 6, 32, null, 100),
(33, TIMESTAMPADD(DAY, -16, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -16, CURRENT_TIMESTAMP), 7, 33, 0.5, null),
(34, TIMESTAMPADD(DAY, -16, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -16, CURRENT_TIMESTAMP), 8, 34, null, 250),
(35, TIMESTAMPADD(DAY, -15, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -15, CURRENT_TIMESTAMP), 9, 35, 1.2, null),
(36, TIMESTAMPADD(DAY, -15, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -15, CURRENT_TIMESTAMP), 10, 36, null, 180),
(37, TIMESTAMPADD(DAY, -14, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -14, CURRENT_TIMESTAMP), 11, 37, 1.3, null),
(38, TIMESTAMPADD(DAY, -14, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -14, CURRENT_TIMESTAMP), 12, 38, null, 170),
(39, TIMESTAMPADD(DAY, -13, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -13, CURRENT_TIMESTAMP), 12, 39, 1.1, null),
(40, TIMESTAMPADD(DAY, -13, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -13, CURRENT_TIMESTAMP), 1, 40, null, 210),
(41, TIMESTAMPADD(DAY, -12, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -12, CURRENT_TIMESTAMP), 2, 41, 1.4, null),
(42, TIMESTAMPADD(DAY, -12, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -12, CURRENT_TIMESTAMP), 3, 42, null, 160),
(43, TIMESTAMPADD(DAY, -11, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -11, CURRENT_TIMESTAMP), 4, 43, 1.6, null),
(44, TIMESTAMPADD(DAY, -11, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -11, CURRENT_TIMESTAMP), 5, 44, null, 140),
(45, TIMESTAMPADD(DAY, -10, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -10, CURRENT_TIMESTAMP), 6, 45, 1.8, null),
(46, TIMESTAMPADD(DAY, -10, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -10, CURRENT_TIMESTAMP), 7, 46, null, 120),
(47, TIMESTAMPADD(DAY, -9, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -9, CURRENT_TIMESTAMP), 8, 47, 2.0, null),
(48, TIMESTAMPADD(DAY, -9, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -9, CURRENT_TIMESTAMP), 9, 48, null, 110),
(49, TIMESTAMPADD(DAY, -8, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -8, CURRENT_TIMESTAMP), 10, 49, 0.8, null),
(50, TIMESTAMPADD(DAY, -8, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -8, CURRENT_TIMESTAMP), 11, 50, null, 190),
(51, TIMESTAMPADD(DAY, -7, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -7, CURRENT_TIMESTAMP), 12, 51, 1.7, null),
(52, TIMESTAMPADD(DAY, -7, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -7, CURRENT_TIMESTAMP), 12, 52, null, 130),
(53, TIMESTAMPADD(DAY, -6, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -6, CURRENT_TIMESTAMP), 1, 53, 1.2, null),
(54, TIMESTAMPADD(DAY, -6, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -6, CURRENT_TIMESTAMP), 2, 54, null, 200),
(55, TIMESTAMPADD(DAY, -5, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -5, CURRENT_TIMESTAMP), 3, 55, 1.5, null),
(56, TIMESTAMPADD(DAY, -5, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -5, CURRENT_TIMESTAMP), 4, 56, null, 150),
(57, TIMESTAMPADD(DAY, -4, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -4, CURRENT_TIMESTAMP), 5, 57, 2.0, null),
(58, TIMESTAMPADD(DAY, -4, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -4, CURRENT_TIMESTAMP), 6, 58, null, 100),
(59, TIMESTAMPADD(DAY, -3, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -3, CURRENT_TIMESTAMP), 7, 59, 0.5, null),
(60, TIMESTAMPADD(DAY, -3, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -3, CURRENT_TIMESTAMP), 8, 60, null, 250),
(61, TIMESTAMPADD(DAY, -3, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -3, CURRENT_TIMESTAMP), 9, 61, 1.2, null),
(62, TIMESTAMPADD(DAY, -2, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -2, CURRENT_TIMESTAMP), 10, 62, null, 8),
(63, TIMESTAMPADD(DAY, -2, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -2, CURRENT_TIMESTAMP), 11, 63, 0.3, null),
(64, TIMESTAMPADD(DAY, -2, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -2, CURRENT_TIMESTAMP), 12, 64, null, 7),
(65, TIMESTAMPADD(DAY, -1, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -1, CURRENT_TIMESTAMP), 12, 65, 1.1, null),
(66, TIMESTAMPADD(DAY, -1, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -1, CURRENT_TIMESTAMP), 1, 66, null, 210),
(67, TIMESTAMPADD(DAY, -1, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, -1, CURRENT_TIMESTAMP), 2, 67, 1.4, null),
(68, TIMESTAMPADD(DAY, 0, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, 0, CURRENT_TIMESTAMP), 3, 68, null, 160),
(69, TIMESTAMPADD(DAY, 0, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, 0, CURRENT_TIMESTAMP), 4, 69, 1.6, null),
(70, TIMESTAMPADD(DAY, 0, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, 0, CURRENT_TIMESTAMP), 5, 69, null, 140),
(71, TIMESTAMPADD(DAY, 0, CURRENT_TIMESTAMP), TIMESTAMPADD(DAY, 0, CURRENT_TIMESTAMP), 6, 69, 1.8, null);
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;

import java.time.LocalDate;

import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -113,14 +115,15 @@ void getMeal() throws Exception {
@WithMockUser
void getMealFood() throws Exception {

LocalDate testDate = LocalDate.now().minusDays(5);

given(getPresignedUrlPort.query(any(Long.class), any(Long.class)))
.willReturn("http://test.com/test.jpeg");

// when
String date = "2023-12-04";
ResultActions resultActions =
mockMvc.perform(
RestDocumentationRequestBuilders.get("/v1/meal/" + date)
RestDocumentationRequestBuilders.get("/v1/meal/" + testDate)
.contentType(MediaType.APPLICATION_JSON));

String responseBody = resultActions.andReturn().getResponse().getContentAsString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,17 @@ public class GetAchieveIntegrationTest extends IntegrationTest {
@WithMockUser
void getAchieves() throws Exception {
// given
String year = "2023";
String month = "12";
String day = "04";
String date = year + "-" + month + "-" + day;
LocalDate testDate =
LocalDate.of(
Integer.parseInt(year), Integer.parseInt(month), Integer.parseInt(day));
LocalDate testData = LocalDate.now();

// when
ResultActions resultActions =
mockMvc.perform(
RestDocumentationRequestBuilders.get("/v1/achieve/" + date)
RestDocumentationRequestBuilders.get("/v1/achieve/" + testData)
.contentType(MediaType.APPLICATION_JSON));
// then

String responseBody = resultActions.andReturn().getResponse().getContentAsString();
System.out.println(responseBody);

ApiResponse.CustomBody<GetAnalysisResponse> getAchieveListResponseCustomBody =
om.readValue(
responseBody,
Expand All @@ -53,8 +47,7 @@ void getAchieves() throws Exception {
.toList()
.size();

System.out.println("comparedSize = " + comparedSize);
Assertions.assertThat(comparedSize).isEqualTo(testDate.lengthOfMonth());
Assertions.assertThat(comparedSize).isEqualTo(testData.lengthOfMonth());
resultActions
.andExpect(status().isOk())
.andDo(
Expand Down

0 comments on commit 0d3c372

Please sign in to comment.