From 3565319b24a78fefa323d5a5e37614c87f2fef1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=90=8D=E5=96=9C?= Date: Thu, 7 Nov 2024 10:31:50 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BC=96=E5=86=99=E8=A7=92=E8=89=B2=E5=8D=95?= =?UTF-8?q?=E5=85=83=E6=B5=8B=E8=AF=95=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ktg-admin/src/test/SysRoleUnitTest.java | 122 ++++++++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 ktg-admin/src/test/SysRoleUnitTest.java diff --git a/ktg-admin/src/test/SysRoleUnitTest.java b/ktg-admin/src/test/SysRoleUnitTest.java new file mode 100644 index 0000000..c1958dd --- /dev/null +++ b/ktg-admin/src/test/SysRoleUnitTest.java @@ -0,0 +1,122 @@ +import com.alibaba.fastjson.JSON; +import com.ktg.RuoYiApplication; +import com.ktg.common.core.domain.entity.SysRole; +import com.ktg.common.core.domain.entity.SysUser; +import com.ktg.system.domain.SysUserRole; +import com.ktg.system.service.ISysRoleService; +import com.ktg.system.service.ISysUserService; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +import java.util.List; + +/** + * 角色管理 + */ +@RunWith(SpringRunner.class) +@SpringBootTest(classes = RuoYiApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +public class SysRoleUnitTest { + @Autowired + private ISysRoleService roleService; + + @Autowired + private ISysUserService userService; + + @Test + public void add() { + SysRole sysRole = new SysRole(); + sysRole.setRoleName("测试角色112"); + sysRole.setRoleKey("TEST_ROLE_112"); + sysRole.setRoleSort("0"); + sysRole.setStatus("0"); + sysRole.setMenuIds(new Long[]{2394L}); + sysRole.setMenuCheckStrictly(true); + sysRole.setDeptCheckStrictly(true); + roleService.insertRole(sysRole); + System.out.println("add:" + sysRole.getRoleId()); // 108 + } + + @Test + public void list() { + List list = roleService.selectRoleList(new SysRole()); + System.out.println("list:" + JSON.toJSONString(list)); + } + + @Test + public void getInfo() { + System.out.println("getInfo:" + JSON.toJSONString(roleService.selectRoleById(108L))); + } + + @Test + public void edit() { + SysRole sysRole = new SysRole(); + sysRole.setRoleId(108L); + sysRole.setRoleName("测试角色111"); + sysRole.setRoleKey("TEST_ROLE_111"); + sysRole.setRoleSort("0"); + sysRole.setStatus("0"); + sysRole.setMenuIds(new Long[]{2394L}); + sysRole.setMenuCheckStrictly(true); + sysRole.setDeptCheckStrictly(true); + int count = roleService.updateRole(sysRole); + System.out.println("edit:" + count); + } + + @Test + public void remove() { + Long[] ids = {108L}; + int count = roleService.deleteRoleByIds(ids); + System.out.println("remove:" + count); + } + + @Test + public void changeStatus() { + SysRole sysRole = new SysRole(); + sysRole.setRoleId(108L); + sysRole.setStatus("0"); + int count = roleService.updateRoleStatus(sysRole); + System.out.println("changeStatus:" + count); + } + + @Test + public void optionselect() { + List list = roleService.selectRoleAll(); + System.out.println("optionselect:" + JSON.toJSONString(list)); + } + + @Test + public void allocatedList() { + List list = userService.selectAllocatedList(new SysUser()); + System.out.println("allocatedList:" + JSON.toJSONString(list)); + } + + @Test + public void unallocatedList() { + List list = userService.selectUnallocatedList(new SysUser()); + System.out.println("unallocatedList:" + JSON.toJSONString(list)); + } + + @Test + public void cancelAuthUser() { + SysUserRole sysUserRole = new SysUserRole(); + sysUserRole.setUserId(117L); + sysUserRole.setRoleId(104L); + int count = roleService.deleteAuthUser(sysUserRole); + System.out.println("cancelAuthUser:" + count); + } + + @Test + public void cancelAuthUserAll() { + int count = roleService.deleteAuthUsers(104L, new Long[]{116L, 117L}); + System.out.println("cancelAuthUserAll:" + count); + } + + @Test + public void selectAuthUserAll() { + int count = roleService.insertAuthUsers(104L, new Long[]{116L, 117L}); + System.out.println("selectAuthUserAll:" + count); + } +}