package com.njcn.rdms.module.system.service.notice;

import com.njcn.rdms.framework.test.core.ut.BaseMockitoUnitTest;
import com.njcn.rdms.module.system.dal.dataobject.notice.NoticeDO;
import com.njcn.rdms.module.system.dal.mysql.notice.NoticeMapper;
import org.junit.jupiter.api.Test;
import org.mockito.InjectMocks;
import org.mockito.Mock;

import java.util.List;

import static java.util.Collections.singletonList;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.when;

/**
 * {@link NoticeServiceImpl} 的单元测试 —— 工作台最近公告查询。
 */
class NoticeServiceImplTest extends BaseMockitoUnitTest {

    @InjectMocks
    private NoticeServiceImpl noticeService;

    @Mock
    private NoticeMapper noticeMapper;

    @Test
    void testGetRecentNotices_delegatesToMapper() {
        NoticeDO notice = new NoticeDO();
        notice.setId(100L);
        when(noticeMapper.selectRecentList(3, 2)).thenReturn(singletonList(notice));

        List<NoticeDO> result = noticeService.getRecentNotices(3, 2);

        assertEquals(1, result.size());
        assertEquals(100L, result.get(0).getId());
    }
}
