package com.ruoyi.web.modules.news.service;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.when;
import java.util.Collections;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import com.ruoyi.web.modules.news.AgriculturalCourseTestSamples;
import com.ruoyi.web.modules.news.domain.AgriculturalCourseQuery;
import com.ruoyi.web.modules.news.mapper.AgriculturalCourseMapper;
import com.ruoyi.web.modules.news.service.impl.AgriculturalCourseServiceImpl;

@ExtendWith(MockitoExtension.class)
@DisplayName("农技课堂 Service")
class AgriculturalCourseServiceImplTest
{
    @Mock
    private AgriculturalCourseMapper agriculturalCourseMapper;

    @InjectMocks
    private AgriculturalCourseServiceImpl agriculturalCourseService;

    @Test
    @DisplayName("按 type 查询并映射列表项")
    void selectList_mapsVo()
    {
        when(agriculturalCourseMapper.selectAgriculturalCourseList(any(AgriculturalCourseQuery.class)))
                .thenReturn(Collections.singletonList(AgriculturalCourseTestSamples.sampleVideoRow()));
        assertEquals(1, agriculturalCourseService.selectAgriculturalCourseList(
                AgriculturalCourseTestSamples.listQueryVideo()).size());
    }

    @Test
    @DisplayName("无数据返回空列表")
    void selectList_empty()
    {
        when(agriculturalCourseMapper.selectAgriculturalCourseList(any(AgriculturalCourseQuery.class)))
                .thenReturn(Collections.emptyList());
        assertTrue(agriculturalCourseService.selectAgriculturalCourseList(
                AgriculturalCourseTestSamples.listQueryVideo()).isEmpty());
    }
}
