|
|
@@ -704,6 +704,24 @@ class ExamSprintReportApplicationServiceTest {
|
|
|
assertCreateOutlookReportSyncRejectsInvalidPayload(OBJECT_MAPPER.nullNode());
|
|
|
}
|
|
|
|
|
|
+ /** 覆盖展望报告新增必填字段场景,当 StudentVocabulary 缺失时,应在保存前校验失败。 */
|
|
|
+ @Test
|
|
|
+ void createOutlookReportSyncRejectsMissingStudentVocabularyBeforeSaving() throws Exception {
|
|
|
+ ObjectNode invalidPayload = callerVocabularyPayload();
|
|
|
+ invalidPayload.remove("StudentVocabulary");
|
|
|
+
|
|
|
+ assertCreateOutlookReportSyncRejectsInvalidPayload(invalidPayload, "StudentVocabulary", "studentVocabulary");
|
|
|
+ }
|
|
|
+
|
|
|
+ /** 覆盖展望报告新增必填字段类型场景,当 StudentVocabulary 不是整数时,应在保存前校验失败。 */
|
|
|
+ @Test
|
|
|
+ void createOutlookReportSyncRejectsNonIntegralStudentVocabularyBeforeSaving() throws Exception {
|
|
|
+ ObjectNode invalidPayload = callerVocabularyPayload();
|
|
|
+ invalidPayload.put("StudentVocabulary", "7");
|
|
|
+
|
|
|
+ assertCreateOutlookReportSyncRejectsInvalidPayload(invalidPayload, "StudentVocabulary", "studentVocabulary");
|
|
|
+ }
|
|
|
+
|
|
|
/** 覆盖同步展望报告渲染失败场景,当 pipeline 生成失败时,应抛出下载不可用并保留失败报告。 */
|
|
|
@Test
|
|
|
void createOutlookReportSyncThrowsDownloadUnavailableAndKeepsFailedReportWhenGenerationFails() {
|
|
|
@@ -1153,6 +1171,7 @@ class ExamSprintReportApplicationServiceTest {
|
|
|
"StudentStage": 2,
|
|
|
"StageName": "初中",
|
|
|
"StageVocabulary": 10,
|
|
|
+ "StudentVocabulary": 4,
|
|
|
"StageExaminName": "中考",
|
|
|
"StageImportant": 3,
|
|
|
"StudentWordsLatest": [
|
|
|
@@ -1347,6 +1366,13 @@ class ExamSprintReportApplicationServiceTest {
|
|
|
}
|
|
|
|
|
|
private void assertCreateOutlookReportSyncRejectsInvalidPayload(JsonNode payload) {
|
|
|
+ assertCreateOutlookReportSyncRejectsInvalidPayload(payload, null, null);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void assertCreateOutlookReportSyncRejectsInvalidPayload(
|
|
|
+ JsonNode payload,
|
|
|
+ String expectedMessageField,
|
|
|
+ String forbiddenMessageField) {
|
|
|
TestRepository repository = new TestRepository();
|
|
|
boolean[] dispatched = {false};
|
|
|
DefaultExamSprintReportApplicationService service = service(
|
|
|
@@ -1354,9 +1380,15 @@ class ExamSprintReportApplicationServiceTest {
|
|
|
reportId -> dispatched[0] = true,
|
|
|
new TestStorage());
|
|
|
|
|
|
- assertThatThrownBy(() -> service.createOutlookReportSync(payload))
|
|
|
- .isInstanceOf(BusinessException.class)
|
|
|
- .extracting(exception -> ((BusinessException) exception).getErrorCode())
|
|
|
+ var throwableAssert = assertThatThrownBy(() -> service.createOutlookReportSync(payload))
|
|
|
+ .isInstanceOf(BusinessException.class);
|
|
|
+ if (expectedMessageField != null) {
|
|
|
+ throwableAssert.hasMessageContaining(expectedMessageField);
|
|
|
+ }
|
|
|
+ if (forbiddenMessageField != null) {
|
|
|
+ throwableAssert.hasMessageNotContaining(forbiddenMessageField);
|
|
|
+ }
|
|
|
+ throwableAssert.extracting(exception -> ((BusinessException) exception).getErrorCode())
|
|
|
.isEqualTo(ErrorCode.VALIDATION_ERROR);
|
|
|
|
|
|
assertThat(repository.storage).isEmpty();
|