package cn.yunzhixue.ability.center.examsprint.application.report;

import cn.yunzhixue.ability.center.examsprint.contracts.report.AchievementExamSprintReportPayload;
import cn.yunzhixue.ability.center.examsprint.domain.report.AchievementReportContent;
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;

class AchievementReportContentMapperTest {

    @Test
    void mapsEveryRendererUsedAchievementFieldToDomainContent() {
        AchievementReportContent content = AchievementReportContentMapper.toDomainContent(payload());

        assertThat(content.studentName()).isEqualTo("吴泓妤");
        assertThat(content.reportTitle()).isEqualTo("高考英语临考突击学习成果报告");
        assertThat(content.summaryMetrics().vocabularyGrowthText()).isEqualTo("+19");
        assertThat(content.vocabularyComparison().beforeValue()).isEqualTo(2328.0);
        assertThat(content.vocabularyComparison().afterText()).isEqualTo("2347");
        assertThat(content.paperKnownWordsComparison().growthText()).isEqualTo("+4");
        assertThat(content.examUnknownWordsHitStatus().hitWords())
                .containsExactly("number", "bear", "popular", "importance");
    }

    @Test
    void rejectsNullPayload() {
        assertThatThrownBy(() -> AchievementReportContentMapper.toDomainContent(null))
                .isInstanceOf(NullPointerException.class)
                .hasMessageContaining("payload");
    }

    private AchievementExamSprintReportPayload payload() {
        return new AchievementExamSprintReportPayload(
                "吴泓妤",
                "高考英语临考突击学习成果报告",
                "2024真题 · 两周专项训练 · 真实提分效果",
                "恭喜完成两周考前突击专项训练",
                "基于2024英语真题试卷 · 真实学习效果分析",
                new AchievementExamSprintReportPayload.SummaryMetrics("+19", "+4", "0.0193", "0.48"),
                new AchievementExamSprintReportPayload.Comparison(2328.0, 2347.0, "2328", "2347", "+19"),
                new AchievementExamSprintReportPayload.Comparison(650.0, 654.0, "650", "654", "+4"),
                new AchievementExamSprintReportPayload.ExamUnknownWordsHitStatus(
                        "0.0193",
                        "0.48",
                        "207",
                        "203",
                        "4",
                        List.of("number", "bear", "popular", "importance")));
    }
}
