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

import cn.yunzhixue.ability.center.examsprint.contracts.report.ExamSprintReportType;
import cn.yunzhixue.ability.center.examsprint.domain.report.ReportGenerationStatus;
import cn.yunzhixue.ability.center.examsprint.domain.report.ReportType;
import org.junit.jupiter.api.Test;

import static org.assertj.core.api.Assertions.assertThat;

class ExamSprintReportContractMapperTest {

    @Test
    void mapsEveryDomainGenerationStatusToContractStatusWithTheSamePublicName() {
        for (ReportGenerationStatus domainStatus : ReportGenerationStatus.values()) {
            assertThat(ExamSprintReportContractMapper.toContractStatus(domainStatus).name())
                    .isEqualTo(domainStatus.name());
        }
    }

    @Test
    void mapsNullGenerationStatusToNull() {
        assertThat(ExamSprintReportContractMapper.toContractStatus(null)).isNull();
    }

    @Test
    void mapsKnownDomainReportTypesToExplicitContractReportTypes() {
        assertThat(ExamSprintReportContractMapper.toContractReportType(ReportType.OUTLOOK))
                .isEqualTo(ExamSprintReportType.OUTLOOK);
        assertThat(ExamSprintReportContractMapper.toContractReportType(ReportType.ACHIEVEMENT))
                .isEqualTo(ExamSprintReportType.ACHIEVEMENT);
    }

    @Test
    void mapsKnownContractReportTypesToExplicitDomainReportTypes() {
        assertThat(ExamSprintReportContractMapper.toDomainReportType(ExamSprintReportType.OUTLOOK))
                .isEqualTo(ReportType.OUTLOOK);
        assertThat(ExamSprintReportContractMapper.toDomainReportType(ExamSprintReportType.ACHIEVEMENT))
                .isEqualTo(ReportType.ACHIEVEMENT);
    }

    @Test
    void mapsEveryDomainReportTypeToContractReportTypeWithTheSamePublicName() {
        for (ReportType domainReportType : ReportType.values()) {
            assertThat(ExamSprintReportContractMapper.toContractReportType(domainReportType).name())
                    .isEqualTo(domainReportType.name());
        }
    }

    @Test
    void mapsEveryContractReportTypeToDomainReportTypeWithTheSamePublicName() {
        for (ExamSprintReportType contractReportType : ExamSprintReportType.values()) {
            assertThat(ExamSprintReportContractMapper.toDomainReportType(contractReportType).name())
                    .isEqualTo(contractReportType.name());
        }
    }

    @Test
    void mapsNullReportTypeToNullInBothDirections() {
        assertThat(ExamSprintReportContractMapper.toContractReportType(null)).isNull();
        assertThat(ExamSprintReportContractMapper.toDomainReportType(null)).isNull();
    }
}
