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

import static org.junit.jupiter.api.Assertions.assertEquals;

import java.util.Calendar;
import java.util.Date;
import java.util.TimeZone;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

@DisplayName("ConsultThreeMonthsWindow")
class ConsultThreeMonthsWindowTest
{
    @Test
    @DisplayName("3 个月自然日边界")
    void threeMonthsAgo()
    {
        Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("Asia/Shanghai"));
        cal.set(2026, Calendar.MAY, 20, 15, 30, 0);
        cal.set(Calendar.MILLISECOND, 0);
        Date ref = cal.getTime();
        Date boundary = ConsultThreeMonthsWindow.calcThreeMonthsAgo(ref);
        Calendar expected = Calendar.getInstance(TimeZone.getTimeZone("Asia/Shanghai"));
        expected.setTime(ref);
        expected.set(Calendar.HOUR_OF_DAY, 0);
        expected.set(Calendar.MINUTE, 0);
        expected.set(Calendar.SECOND, 0);
        expected.set(Calendar.MILLISECOND, 0);
        expected.add(Calendar.MONTH, -3);
        assertEquals(expected.getTime(), boundary);
    }
}
