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

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 AchievementReportContentTest {

    @Test
    void reportsAchievementTypeAndCopiesHitWords() {
        List<String> hitWords = new java.util.ArrayList<>(List.of("number", "bear"));
        AchievementReportContent content = sampleContent(hitWords);

        hitWords.add("mutated");

        assertThat(content.reportType()).isEqualTo(ReportType.ACHIEVEMENT);
        assertThat(content.examUnknownWordsHitStatus().hitWords())
                .containsExactly("number", "bear");
    }

    @Test
    void rejectsNullRequiredGroups() {
        assertThatThrownBy(() -> new AchievementReportContent(
                null,
                "title",
                "subtitle",
                "completion title",
                "completion subtitle",
                null,
                comparison(),
                comparison(),
                stageVocabularySummary(),
                testPaperVocabularySummary(),
                hitStatus(List.of("number"))))
                .isInstanceOf(NullPointerException.class)
                .hasMessageContaining("summaryMetrics");
    }

    private AchievementReportContent sampleContent(List<String> hitWords) {
        return new AchievementReportContent(
                "吴泓妤",
                "高考英语临考突击学习成果报告",
                "2024真题 · 两周专项训练 · 真实提分效果",
                "恭喜完成两周考前突击专项训练",
                "基于2024英语真题试卷 · 真实学习效果分析",
                new AchievementReportContent.SummaryMetrics("+19", "+4", "0.0193", "0.48"),
                comparison(),
                comparison(),
                stageVocabularySummary(),
                testPaperVocabularySummary(),
                hitStatus(hitWords));
    }

    private AchievementReportContent.Comparison comparison() {
        return new AchievementReportContent.Comparison(2328.0, 2347.0, "2328", "2347", "+19");
    }

    private AchievementReportContent.StageVocabularySummary stageVocabularySummary() {
        return new AchievementReportContent.StageVocabularySummary("高考", "3500", "66.51", "67.06", "+0.55");
    }

    private AchievementReportContent.TestPaperVocabularySummary testPaperVocabularySummary() {
        return new AchievementReportContent.TestPaperVocabularySummary("2024真题", "861", "207", "203", "75.49", "75.96", "+0.62");
    }

    private AchievementReportContent.ExamUnknownWordsHitStatus hitStatus(List<String> hitWords) {
        return new AchievementReportContent.ExamUnknownWordsHitStatus(
                "0.0193",
                "0.48",
                "207",
                "203",
                "4",
                hitWords);
    }
}
