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.BizConsultSession;
import com.ruoyi.web.modules.diagnosis.domain.VetConsultSendBody;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

@DisplayName("VetConsultValidation")
class VetConsultValidationTest
{
    @Test
    @DisplayName("搜索条件全空")
    void searchEmpty()
    {
        BizConsultSession q = new BizConsultSession();
        assertThrows(ServiceException.class, () -> VetConsultValidation.validateListQuery(q, true));
    }

    @Test
    @DisplayName("发送文本与媒体校验")
    void sendBody()
    {
        VetConsultSendBody empty = new VetConsultSendBody();
        empty.setMsgType(ConsultSessionRules.MSG_TYPE_TEXT);
        assertThrows(ServiceException.class, () -> VetConsultValidation.validateSendBody(empty));
        VetConsultSendBody img = new VetConsultSendBody();
        img.setMsgType(ConsultSessionRules.MSG_TYPE_IMAGE);
        img.setContent("http://host/a.jpg");
        assertDoesNotThrow(() -> VetConsultValidation.validateSendBody(img));
        VetConsultSendBody bad = new VetConsultSendBody();
        bad.setMsgType(ConsultSessionRules.MSG_TYPE_IMAGE);
        bad.setContent("http://host/a.exe");
        assertThrows(ServiceException.class, () -> VetConsultValidation.validateSendBody(bad));
    }
}
