|
|
@@ -85,6 +85,7 @@ public class FoodRecommendServiceTest {
|
|
|
public void recalculateForUser_noSuitability_deletesIndices() {
|
|
|
HealthReport report = mockReport(1L, 1L);
|
|
|
when(healthReportService.getLatestReport(1L)).thenReturn(report);
|
|
|
+ when(foodService.listByReportId(1L)).thenReturn(Collections.emptyList());
|
|
|
when(reportFoodSuitabilityMapper.selectList(any())).thenReturn(Collections.emptyList());
|
|
|
|
|
|
service.recalculateForUser(1L);
|
|
|
@@ -97,6 +98,7 @@ public class FoodRecommendServiceTest {
|
|
|
HealthReport report = mockReport(1L, 1L);
|
|
|
ReportFoodSuitability suit = mockSuit(1L, 100L, "食材A", 85);
|
|
|
when(healthReportService.getLatestReport(1L)).thenReturn(report);
|
|
|
+ when(foodService.listByReportId(1L)).thenReturn(Collections.emptyList());
|
|
|
when(reportFoodSuitabilityMapper.selectList(any())).thenReturn(Collections.singletonList(suit));
|
|
|
when(foodRecommendIndexMapper.selectList(any())).thenReturn(Collections.emptyList());
|
|
|
|
|
|
@@ -117,6 +119,7 @@ public class FoodRecommendServiceTest {
|
|
|
ReportFoodSuitability suit = mockSuit(1L, 100L, "食材A", 90);
|
|
|
FoodRecommendIndex existing = mockIndex(1L, 100L, "食材A", 70);
|
|
|
when(healthReportService.getLatestReport(1L)).thenReturn(report);
|
|
|
+ when(foodService.listByReportId(1L)).thenReturn(Collections.emptyList());
|
|
|
when(reportFoodSuitabilityMapper.selectList(any())).thenReturn(Collections.singletonList(suit));
|
|
|
when(foodRecommendIndexMapper.selectList(any())).thenReturn(Collections.singletonList(existing));
|
|
|
|
|
|
@@ -138,6 +141,7 @@ public class FoodRecommendServiceTest {
|
|
|
ReportFoodSuitability suit = mockSuit(1L, 100L, "食材A", 80);
|
|
|
FoodRecommendIndex existing = mockIndex(1L, 100L, "食材A", 80);
|
|
|
when(healthReportService.getLatestReport(1L)).thenReturn(report);
|
|
|
+ when(foodService.listByReportId(1L)).thenReturn(Collections.emptyList());
|
|
|
when(reportFoodSuitabilityMapper.selectList(any())).thenReturn(Collections.singletonList(suit));
|
|
|
when(foodRecommendIndexMapper.selectList(any())).thenReturn(Collections.singletonList(existing));
|
|
|
|
|
|
@@ -152,6 +156,7 @@ public class FoodRecommendServiceTest {
|
|
|
FoodRecommendIndex existing = mockIndex(1L, 100L, "食材A", 80);
|
|
|
FoodRecommendIndex existing2 = mockIndex(1L, 200L, "食材B", 75);
|
|
|
when(healthReportService.getLatestReport(1L)).thenReturn(report);
|
|
|
+ when(foodService.listByReportId(1L)).thenReturn(Collections.emptyList());
|
|
|
// 新报告只含食材C,existing A/B 被移除
|
|
|
ReportFoodSuitability newSuit = mockSuit(1L, 300L, "食材C", 70);
|
|
|
when(reportFoodSuitabilityMapper.selectList(any())).thenReturn(Collections.singletonList(newSuit));
|