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

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

import com.ruoyi.common.exception.ServiceException;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

@DisplayName("MedicalResourceBatchIds")
class MedicalResourceBatchIdsTest
{
    @Test
    @DisplayName("解析逗号分隔 ID")
    void parse()
    {
        assertArrayEquals(new Long[] { 1L, 2L, 3L }, MedicalResourceBatchIds.parse("1,2,3"));
        assertArrayEquals(new Long[] { 1L, 2L }, MedicalResourceBatchIds.parse(" 1 , 2 "));
        assertEquals(0, MedicalResourceBatchIds.parse("").length);
        assertEquals(0, MedicalResourceBatchIds.parse(null).length);
    }

    @Test
    @DisplayName("非法 ID 抛错")
    void parseInvalid()
    {
        assertThrows(ServiceException.class, () -> MedicalResourceBatchIds.parse("1,abc"));
    }
}
