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

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

import java.util.Arrays;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import com.ruoyi.web.modules.architecture.domain.AppMedicationIncompatibilityGroupRow;

@DisplayName("AppMedicationIncompatibilityDisplaySupport")
class AppMedicationIncompatibilityDisplaySupportTest
{
    @Test
    @DisplayName("多配伍组带结果")
    void multipleGroups()
    {
        AppMedicationIncompatibilityGroupRow g1 = group("链霉素,庆大霉素", "禁止合用");
        AppMedicationIncompatibilityGroupRow g2 = group("维生素C", "降低疗效");
        assertEquals("链霉素,庆大霉素（禁止合用）；维生素C（降低疗效）",
                AppMedicationIncompatibilityDisplaySupport.formatGroupsForDisplay(Arrays.asList(g1, g2)));
    }

    @Test
    @DisplayName("单组无配伍结果")
    void singleGroupWithoutResult()
    {
        assertEquals("链霉素,磺胺",
                AppMedicationIncompatibilityDisplaySupport.formatGroupsForDisplay(
                        Arrays.asList(group("链霉素,磺胺", null))));
    }

    @Test
    @DisplayName("空列表")
    void empty()
    {
        assertNull(AppMedicationIncompatibilityDisplaySupport.formatGroupsForDisplay(null));
    }

    private static AppMedicationIncompatibilityGroupRow group(String companions, String result)
    {
        AppMedicationIncompatibilityGroupRow row = new AppMedicationIncompatibilityGroupRow();
        row.setCompanionsCsv(companions);
        row.setCompatResult(result);
        return row;
    }
}
