|
|
@@ -1,11 +1,16 @@
|
|
|
package cn.yunzhixue.ability.center.examsprint.application.report;
|
|
|
|
|
|
import cn.yunzhixue.ability.center.examsprint.contracts.report.AchievementExamSprintReportPayload;
|
|
|
+import cn.yunzhixue.ability.center.examsprint.contracts.report.BusinessInfo;
|
|
|
+import cn.yunzhixue.ability.center.examsprint.contracts.report.BusinessSetting;
|
|
|
+import cn.yunzhixue.ability.center.examsprint.contracts.report.OutlookExamSprintReportPayload;
|
|
|
import cn.yunzhixue.ability.center.examsprint.domain.report.AchievementReportContent;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.fasterxml.jackson.databind.node.ObjectNode;
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
import static org.assertj.core.api.Assertions.assertThat;
|
|
|
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
|
|
|
|
|
@@ -135,6 +140,105 @@ class AchievementReportContentMapperTest {
|
|
|
assertThat(content.businessInfo().address()).isEqualTo("浙江省杭州市");
|
|
|
}
|
|
|
|
|
|
+ /** 覆盖调用方新增 BusinessSetting 场景,当 payload 指定页脚展示联系人开关时,应透传到成果报告领域内容。 */
|
|
|
+ @Test
|
|
|
+ void mapsBusinessSettingToAchievementContent() {
|
|
|
+ ObjectNode payload = pascalPayload();
|
|
|
+ payload.set("BusinessSetting", OBJECT_MAPPER.createObjectNode()
|
|
|
+ .put("ShowContactInFooter", 0));
|
|
|
+
|
|
|
+ AchievementReportContent content = AchievementReportContentMapper.toDomainContent(convert(payload));
|
|
|
+
|
|
|
+ assertThat(content.businessSetting()).isNotNull();
|
|
|
+ assertThat(content.businessSetting().showContactInFooter()).isZero();
|
|
|
+ }
|
|
|
+
|
|
|
+ /** 覆盖源码兼容构造器场景,新增 BusinessSetting 后仍应保留以 BusinessInfo 结尾的构造器。 */
|
|
|
+ @Test
|
|
|
+ void preservesPayloadConstructorEndingWithBusinessInfo() {
|
|
|
+ AchievementExamSprintReportPayload payload = payload();
|
|
|
+ BusinessInfo businessInfo = new BusinessInfo("张三", "138987484", "浙江省杭州市");
|
|
|
+
|
|
|
+ AchievementExamSprintReportPayload compatiblePayload = new AchievementExamSprintReportPayload(
|
|
|
+ payload.studentName(),
|
|
|
+ payload.studentStage(),
|
|
|
+ payload.stageName(),
|
|
|
+ payload.stageVocabulary(),
|
|
|
+ payload.studentVocabulary(),
|
|
|
+ payload.studentVocabularyBefore(),
|
|
|
+ payload.studentUnMastedWordCount(),
|
|
|
+ payload.studentImproveWordCount(),
|
|
|
+ payload.testPaperTitle(),
|
|
|
+ payload.testPaperWordCount(),
|
|
|
+ payload.testPaperBeforUnMastery(),
|
|
|
+ payload.testPaperBeforMastery(),
|
|
|
+ payload.testPaperLatestMastery(),
|
|
|
+ payload.testPaperAfterUnMastery(),
|
|
|
+ payload.testPaperImprovedWords(),
|
|
|
+ payload.testPaperImprovedWordCount(),
|
|
|
+ payload.testPaperImproveRate(),
|
|
|
+ payload.paperMasteryHitRate(),
|
|
|
+ payload.improveStudyEfficiency(),
|
|
|
+ payload.studentInitialVocabMastery(),
|
|
|
+ payload.studentCurrentVocabMastery(),
|
|
|
+ payload.studentVocabMasteryImprovement(),
|
|
|
+ payload.testPaperBeforMasteryRate(),
|
|
|
+ payload.testPaperLatestMasteryRate(),
|
|
|
+ payload.shouldDisplaySigningGuarantee(),
|
|
|
+ payload.signingGuarantee(),
|
|
|
+ businessInfo);
|
|
|
+
|
|
|
+ assertThat(compatiblePayload.businessInfo()).isSameAs(businessInfo);
|
|
|
+ assertThat(compatiblePayload.businessSetting()).isNull();
|
|
|
+ }
|
|
|
+
|
|
|
+ /** 覆盖展望报告源码兼容构造器场景,新增 BusinessSetting 后仍应保留以 BusinessInfo 结尾的构造器。 */
|
|
|
+ @Test
|
|
|
+ void preservesOutlookPayloadConstructorEndingWithBusinessInfo() {
|
|
|
+ BusinessInfo businessInfo = new BusinessInfo("张三", "138987484", "浙江省杭州市");
|
|
|
+
|
|
|
+ OutlookExamSprintReportPayload payload = new OutlookExamSprintReportPayload(
|
|
|
+ "吴泓妤",
|
|
|
+ 3,
|
|
|
+ "高考",
|
|
|
+ 3500,
|
|
|
+ 2347,
|
|
|
+ "高考英语",
|
|
|
+ 1200,
|
|
|
+ List.of(new OutlookExamSprintReportPayload.StudentWordLatest(
|
|
|
+ 1,
|
|
|
+ 2,
|
|
|
+ "number",
|
|
|
+ 3,
|
|
|
+ 0.8,
|
|
|
+ 4,
|
|
|
+ 5,
|
|
|
+ "2026-05-13T11:00:00")),
|
|
|
+ 2347,
|
|
|
+ 1153,
|
|
|
+ 207,
|
|
|
+ List.of(1, 2, 3),
|
|
|
+ "2024真题",
|
|
|
+ 207,
|
|
|
+ 654,
|
|
|
+ 861,
|
|
|
+ false,
|
|
|
+ businessInfo);
|
|
|
+
|
|
|
+ assertThat(payload.businessInfo()).isSameAs(businessInfo);
|
|
|
+ assertThat(payload.businessSetting()).isNull();
|
|
|
+ }
|
|
|
+
|
|
|
+ /** 覆盖 BusinessSetting 向前兼容场景,当 JSON 包含未知字段时,应忽略未知字段并保留 ShowContactInFooter。 */
|
|
|
+ @Test
|
|
|
+ void ignoresUnknownBusinessSettingFields() throws Exception {
|
|
|
+ BusinessSetting businessSetting = OBJECT_MAPPER.readValue(
|
|
|
+ "{\"ShowContactInFooter\":0,\"UnknownField\":\"ignored\"}",
|
|
|
+ BusinessSetting.class);
|
|
|
+
|
|
|
+ assertThat(businessSetting.showContactInFooter()).isZero();
|
|
|
+ }
|
|
|
+
|
|
|
/** 覆盖空 payload 防御场景,当 mapper 收到 null 时,应抛出包含 payload 的 NullPointerException。 */
|
|
|
@Test
|
|
|
void rejectsNullPayload() {
|