cmvr-wms/ruoyi-admin/src/test/java/com/ruoyi/system/NoticeHistoryTest.java
lixiaolong 89c962223a feat(warehouse): 优化采购报价权限控制和文件管理功能
- 实现基于角色的采购报价权限检查,仅超级管理员和采购经理角色可查看报价
- 替换原有的仓库采购管理权限检查为新的报价权限函数
- 在采购单据组件中更新报价字段显示权限逻辑
- 集成文件管理功能,支持文档附件上传下载
- 添加移动端应用更新提示和发布功能
- 增强采购历史更正服务的安全访问控制
- 重构报价访问工具类以支持细粒度字段过滤
- 添加单元测试验证新的权限控制逻辑
2026-10-29 09:58:51 +08:00

29 lines
1.7 KiB
Java

package com.ruoyi.system;
import com.ruoyi.system.domain.SysNotice;
import com.ruoyi.system.mapper.SysNoticeReadMapper;
import com.ruoyi.system.service.impl.SysNoticeReadServiceImpl;
import org.junit.jupiter.api.Test;
import org.springframework.test.util.ReflectionTestUtils;
import java.util.ArrayList;
import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.*;
class NoticeHistoryTest {
@Test void historyIsBoundedAndUsesLookaheadWithoutLosingCursor() {
var mapper=mock(SysNoticeReadMapper.class);var service=new SysNoticeReadServiceImpl();
ReflectionTestUtils.setField(service,"noticeReadMapper",mapper);
var rows=new ArrayList<SysNotice>();for(long i=100;i>=50;i--){var row=new SysNotice();row.setNoticeId(i);rows.add(row);}
when(mapper.selectPublishedPage(2L,110L,"公告",true,51)).thenReturn(rows);
var page=service.publishedPage(2L,110L," 公告 ",true,10000);
assertEquals(50,((java.util.List<?>)page.get("items")).size());assertEquals(true,page.get("hasMore"));assertEquals(51L,page.get("nextCursor"));
verify(mapper).selectPublishedPage(2L,110L,"公告",true,51);verifyNoMoreInteractions(mapper);
}
@Test void rejectsAnonymousAndInvalidCursorBeforeQuery() {
var mapper=mock(SysNoticeReadMapper.class);var service=new SysNoticeReadServiceImpl();ReflectionTestUtils.setField(service,"noticeReadMapper",mapper);
assertThrows(RuntimeException.class,()->service.publishedPage(null,null,"",false,20));
assertThrows(RuntimeException.class,()->service.publishedPage(2L,-1L,"",false,20));
assertThrows(RuntimeException.class,()->service.publishedPage(2L,null,"x".repeat(101),false,20));verifyNoInteractions(mapper);
}
}