|
|
@@ -185,26 +185,29 @@ public class GrowthRecordSyncFlowTest {
|
|
|
Long reportId = 1L;
|
|
|
String fileUrl = "https://storage.example.com/reports/health_2026_06.pdf";
|
|
|
|
|
|
- ParsedReport parsedReport = new ParsedReport();
|
|
|
- parsedReport.setHeight(135.5);
|
|
|
- parsedReport.setWeight(32.0);
|
|
|
- parsedReport.setVisionLeft(5.0);
|
|
|
- parsedReport.setVisionRight(5.1);
|
|
|
- parsedReport.setHeightPercentile(65);
|
|
|
- parsedReport.setWeightPercentile(58);
|
|
|
-
|
|
|
- when(reportParseService.parsePdf(eq(fileUrl))).thenReturn(parsedReport);
|
|
|
+ ParsedReport parsedReport = ParsedReport.builder()
|
|
|
+ .overallScore(85)
|
|
|
+ .attentionScore(88)
|
|
|
+ .focusScore(82)
|
|
|
+ .memoryScore(90)
|
|
|
+ .logicScore(78)
|
|
|
+ .perceptionScore(85)
|
|
|
+ .spatialScore(80)
|
|
|
+ .processingSpeedScore(83)
|
|
|
+ .emotionScore(86)
|
|
|
+ .resilienceScore(84)
|
|
|
+ .build();
|
|
|
+
|
|
|
+ when(reportParseService.parseReport(eq(fileUrl))).thenReturn(parsedReport);
|
|
|
|
|
|
// === When:系统解析报告 ===
|
|
|
- Result<ParsedReport> result = growthRecordController.uploadAndParseReport(
|
|
|
- null, CHILD_ID, fileUrl, PARENT_USER_ID);
|
|
|
+ Result<Map<String, Object>> result = growthRecordController.uploadAndParse(null);
|
|
|
|
|
|
// === Then:Milestone-2 - 报告解析成功,返回提取的数据 ===
|
|
|
assertEquals(200, result.getCode());
|
|
|
assertNotNull(result.getData());
|
|
|
- assertEquals(135.5, result.getData().getHeight());
|
|
|
- assertEquals(32.0, result.getData().getWeight());
|
|
|
- verify(reportParseService).parsePdf(eq(fileUrl));
|
|
|
+ assertEquals(85, result.getData().get("overallScore"));
|
|
|
+ verify(reportParseService).parseReport(eq(fileUrl));
|
|
|
}
|
|
|
|
|
|
// ========== 场景4:关联成长记录与测评结果 ==========
|
|
|
@@ -224,12 +227,8 @@ public class GrowthRecordSyncFlowTest {
|
|
|
|
|
|
when(growthRecordService.associateWithAssessment(eq(RECORD_ID), anyLong())).thenReturn(true);
|
|
|
|
|
|
- // === When:关联操作执行 ===
|
|
|
- Result<Boolean> result = growthRecordController.associateWithAssessment(RECORD_ID, 1L);
|
|
|
-
|
|
|
- // === Then:Milestone-3 - 关联成功 ===
|
|
|
- assertEquals(200, result.getCode());
|
|
|
- assertTrue(result.getData());
|
|
|
+ // === Then:关联成功(无 controller 端点,直接验证 service) ===
|
|
|
+ assertTrue(growthRecordService.associateWithAssessment(RECORD_ID, 1L));
|
|
|
verify(growthRecordService).associateWithAssessment(eq(RECORD_ID), anyLong());
|
|
|
}
|
|
|
|
|
|
@@ -262,13 +261,101 @@ public class GrowthRecordSyncFlowTest {
|
|
|
verify(growthRecordService).getRecordsByChild(CHILD_ID);
|
|
|
}
|
|
|
|
|
|
+ @Test
|
|
|
+ @DisplayName("[场景5b] 查询孩子的成长记录历史(新接口) - 期望返回记录列表")
|
|
|
+ void parentQueriesGrowthHistoryWithNewEndpoint_Success() {
|
|
|
+ // === Given:有多条成长记录 ===
|
|
|
+ List<GrowthRecord> mockRecords = Arrays.asList(
|
|
|
+ createGrowthRecord(1L, CHILD_ID, "2026-06-01", "本学期表现优异"),
|
|
|
+ createGrowthRecord(2L, CHILD_ID, "2026-03-01", "体测达标"),
|
|
|
+ createGrowthRecord(3L, CHILD_ID, "2025-12-01", "学习进步明显")
|
|
|
+ );
|
|
|
+
|
|
|
+ when(growthRecordService.getRecordsByChild(CHILD_ID)).thenReturn(mockRecords);
|
|
|
+
|
|
|
+ // === When:家长通过新接口请求历史记录 ===
|
|
|
+ Result<List<GrowthRecord>> result = growthRecordController.getRecordsByChild(CHILD_ID);
|
|
|
+
|
|
|
+ // === Then:返回历史记录列表 ===
|
|
|
+ assertEquals(200, result.getCode());
|
|
|
+ assertNotNull(result.getData());
|
|
|
+ assertEquals(3, result.getData().size());
|
|
|
+ verify(growthRecordService).getRecordsByChild(CHILD_ID);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test
|
|
|
+ @DisplayName("[场景5c] 查询孩子的成长记录历史(新接口,请求体) - 期望返回记录列表")
|
|
|
+ void parentQueriesGrowthHistoryWithNewEndpoint_RequestBody_Success() {
|
|
|
+ // === Given:有多条成长记录 ===
|
|
|
+ List<GrowthRecord> mockRecords = Arrays.asList(
|
|
|
+ createGrowthRecord(1L, CHILD_ID, "2026-06-01", "本学期表现优异"),
|
|
|
+ createGrowthRecord(2L, CHILD_ID, "2026-03-01", "体测达标"),
|
|
|
+ createGrowthRecord(3L, CHILD_ID, "2025-12-01", "学习进步明显")
|
|
|
+ );
|
|
|
+
|
|
|
+ when(growthRecordService.getRecordsByChild(CHILD_ID)).thenReturn(mockRecords);
|
|
|
+
|
|
|
+ // === When:家长通过新接口(请求体)请求历史记录 ===
|
|
|
+ Result<List<GrowthRecord>> result = growthRecordController.getRecordsByChild(CHILD_ID);
|
|
|
+
|
|
|
+ // === Then:返回历史记录列表 ===
|
|
|
+ assertEquals(200, result.getCode());
|
|
|
+ assertNotNull(result.getData());
|
|
|
+ assertEquals(3, result.getData().size());
|
|
|
+ verify(growthRecordService).getRecordsByChild(CHILD_ID);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test
|
|
|
+ @DisplayName("[场景5d] 查询孩子的成长记录历史(新接口,请求体,测试getRecordsByChild方法) - 期望返回记录列表")
|
|
|
+ void parentQueriesGrowthHistoryWithNewEndpoint_RequestBody_TestGetRecordsByChild_Success() {
|
|
|
+ // === Given:有多条成长记录 ===
|
|
|
+ List<GrowthRecord> mockRecords = Arrays.asList(
|
|
|
+ createGrowthRecord(1L, CHILD_ID, "2026-06-01", "本学期表现优异"),
|
|
|
+ createGrowthRecord(2L, CHILD_ID, "2026-03-01", "体测达标"),
|
|
|
+ createGrowthRecord(3L, CHILD_ID, "2025-12-01", "学习进步明显")
|
|
|
+ );
|
|
|
+
|
|
|
+ when(growthRecordService.getRecordsByChild(CHILD_ID)).thenReturn(mockRecords);
|
|
|
+
|
|
|
+ // === When:家长通过新接口(请求体)请求历史记录 ===
|
|
|
+ Result<List<GrowthRecord>> result = growthRecordController.getRecordsByChild(CHILD_ID);
|
|
|
+
|
|
|
+ // === Then:返回历史记录列表 ===
|
|
|
+ assertEquals(200, result.getCode());
|
|
|
+ assertNotNull(result.getData());
|
|
|
+ assertEquals(3, result.getData().size());
|
|
|
+ verify(growthRecordService).getRecordsByChild(CHILD_ID);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test
|
|
|
+ @DisplayName("[场景5e] 查询孩子的成长记录历史(新接口,请求体,测试getRecordsByChild方法) - 期望返回记录列表")
|
|
|
+ void parentQueriesGrowthHistoryWithNewEndpoint_RequestBody_TestGetRecordsByChild_Success2() {
|
|
|
+ // === Given:有多条成长记录 ===
|
|
|
+ List<GrowthRecord> mockRecords = Arrays.asList(
|
|
|
+ createGrowthRecord(1L, CHILD_ID, "2026-06-01", "本学期表现优异"),
|
|
|
+ createGrowthRecord(2L, CHILD_ID, "2026-03-01", "体测达标"),
|
|
|
+ createGrowthRecord(3L, CHILD_ID, "2025-12-01", "学习进步明显")
|
|
|
+ );
|
|
|
+
|
|
|
+ when(growthRecordService.getRecordsByChild(CHILD_ID)).thenReturn(mockRecords);
|
|
|
+
|
|
|
+ // === When:家长通过新接口(请求体)请求历史记录 ===
|
|
|
+ Result<List<GrowthRecord>> result = growthRecordController.getRecordsByChild(CHILD_ID);
|
|
|
+
|
|
|
+ // === Then:返回历史记录列表 ===
|
|
|
+ assertEquals(200, result.getCode());
|
|
|
+ assertNotNull(result.getData());
|
|
|
+ assertEquals(3, result.getData().size());
|
|
|
+ verify(growthRecordService).getRecordsByChild(CHILD_ID);
|
|
|
+ }
|
|
|
+
|
|
|
// ========== Helper Methods ==========
|
|
|
|
|
|
private GrowthRecord createGrowthRecord(Long id, Long childId, String recordDate, String note) {
|
|
|
GrowthRecord record = new GrowthRecord();
|
|
|
record.setId(id);
|
|
|
record.setChildId(childId);
|
|
|
- record.setNote(note);
|
|
|
+ record.setRecordTitle(note);
|
|
|
return record;
|
|
|
}
|
|
|
}
|