package com.ruoyi.web.modules.diagnosis.support;

import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertThrows;

import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.web.modules.diagnosis.domain.BizServiceAppointment;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

@DisplayName("OrgAppointmentValidation")
class OrgAppointmentValidationTest
{
    @Test
    @DisplayName("预约日期区间")
    void dateRange()
    {
        BizServiceAppointment q = new BizServiceAppointment();
        q.setStartDate("2026-05-20");
        q.setEndDate("2026-05-10");
        assertThrows(ServiceException.class, () -> OrgAppointmentValidation.validateListQuery(q));
        q.setEndDate("2026-05-20");
        assertDoesNotThrow(() -> OrgAppointmentValidation.validateListQuery(q));
    }

    @Test
    @DisplayName("状态筛选仅三态")
    void statusFilter()
    {
        BizServiceAppointment q = new BizServiceAppointment();
        assertDoesNotThrow(() -> OrgAppointmentValidation.validateListQuery(q));
        q.setStatus(ServiceAppointmentRules.STATUS_BOOKED);
        assertDoesNotThrow(() -> OrgAppointmentValidation.validateListQuery(q));
        q.setStatus(ServiceAppointmentRules.STATUS_PENDING);
        assertThrows(ServiceException.class, () -> OrgAppointmentValidation.validateListQuery(q));
        q.setStatus(1);
        assertThrows(ServiceException.class, () -> OrgAppointmentValidation.validateListQuery(q));
    }
}
