From 0710879d79015c2946496c1bdd3289a71f268201 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=90=8D=E5=96=9C?= Date: Wed, 6 Nov 2024 15:29:27 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E5=AE=8C=E6=88=90=E5=BA=93=E6=88=BF?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ktg-admin/src/test/WmWarehouseUnitTest.java | 77 +++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 ktg-admin/src/test/WmWarehouseUnitTest.java diff --git a/ktg-admin/src/test/WmWarehouseUnitTest.java b/ktg-admin/src/test/WmWarehouseUnitTest.java new file mode 100644 index 0000000..cd0d935 --- /dev/null +++ b/ktg-admin/src/test/WmWarehouseUnitTest.java @@ -0,0 +1,77 @@ +import com.alibaba.fastjson.JSON; +import com.ktg.RuoYiApplication; +import com.ktg.mes.wm.controller.WmWarehouseController; +import com.ktg.mes.wm.domain.WmWarehouse; +import com.ktg.mes.wm.service.IWmWarehouseService; +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 WmWarehouseUnitTest { + @Autowired + private WmWarehouseController wmWarehouseController = null; + + @Autowired + private IWmWarehouseService wmWarehouseService; + + @Test + public void add() { + WmWarehouse wmWarehouse = new WmWarehouse(); + wmWarehouse.setWarehouseCode("WH999"); + wmWarehouse.setWarehouseName("测试库房999"); + wmWarehouse.setCharge("张三丰"); + wmWarehouse.setRemark("这是一个测试库房999"); + wmWarehouse.setAttr1("7"); + wmWarehouse.setAttr2("刀柄入库"); + wmWarehouse.setAttr3(1L); + wmWarehouseService.insertWmWarehouse(wmWarehouse); + System.out.println("add:" + wmWarehouse.getWarehouseId()); // 222 + } + + @Test + public void list() { + List list = wmWarehouseService.selectWmWarehouseList(new WmWarehouse()); + System.out.println("list:" + JSON.toJSONString(list)); + } + +// @Test TODO E +// public void getTreeList() { +// List list = wmWarehouseService.getTreeList(); +// System.out.println("getTreeList:" + JSON.toJSONString(list)); +// } + + @Test + public void getInfo() { + System.out.println("getInfo:" + JSON.toJSONString(wmWarehouseService.selectWmWarehouseByWarehouseId(222L))); + } + + @Test + public void edit() { + WmWarehouse wmWarehouse = new WmWarehouse(); + wmWarehouse.setWarehouseId(222L); + wmWarehouse.setWarehouseCode("WH999EDIT"); + wmWarehouse.setWarehouseName("测试库房999EDIT"); + wmWarehouse.setCharge("张三丰"); + wmWarehouse.setFrozenFlag("N"); + wmWarehouse.setRemark("这是一个测试库房999EDIT"); + wmWarehouse.setAttr1("7"); + wmWarehouse.setAttr2("刀柄入库"); + wmWarehouse.setAttr3(1L); + wmWarehouse.setAttr4(0L); + int count = wmWarehouseService.updateWmWarehouse(wmWarehouse); + System.out.println("edit:" + count); + } + + @Test + public void remove() { + Long[] ids = {222L}; + int count = wmWarehouseService.deleteWmWarehouseByWarehouseIds(ids); + System.out.println("remove:" + count); + } +} From 682bc52c778ece69c48c7619ea4177ecde69d41a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=90=8D=E5=96=9C?= Date: Wed, 6 Nov 2024 15:30:59 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E5=B1=8F=E8=94=BD=E4=B8=8D=E9=9C=80?= =?UTF-8?q?=E8=A6=81=E7=9A=84=E6=B3=A8=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ktg-admin/src/test/WmWarehouseUnitTest.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/ktg-admin/src/test/WmWarehouseUnitTest.java b/ktg-admin/src/test/WmWarehouseUnitTest.java index cd0d935..b0c8588 100644 --- a/ktg-admin/src/test/WmWarehouseUnitTest.java +++ b/ktg-admin/src/test/WmWarehouseUnitTest.java @@ -1,6 +1,5 @@ import com.alibaba.fastjson.JSON; import com.ktg.RuoYiApplication; -import com.ktg.mes.wm.controller.WmWarehouseController; import com.ktg.mes.wm.domain.WmWarehouse; import com.ktg.mes.wm.service.IWmWarehouseService; import org.junit.Test; @@ -14,9 +13,6 @@ import java.util.List; @RunWith(SpringRunner.class) @SpringBootTest(classes = RuoYiApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) public class WmWarehouseUnitTest { - @Autowired - private WmWarehouseController wmWarehouseController = null; - @Autowired private IWmWarehouseService wmWarehouseService; From b82c30fc2765f18290f1bcca7f93caaa2ee937f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=90=8D=E5=96=9C?= Date: Wed, 6 Nov 2024 16:06:12 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E7=BC=96=E5=86=99=E5=BA=93=E5=8C=BA?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=8D=95=E5=85=83=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/test/WmStorageLocationUnitTest.java | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 ktg-admin/src/test/WmStorageLocationUnitTest.java diff --git a/ktg-admin/src/test/WmStorageLocationUnitTest.java b/ktg-admin/src/test/WmStorageLocationUnitTest.java new file mode 100644 index 0000000..767efc9 --- /dev/null +++ b/ktg-admin/src/test/WmStorageLocationUnitTest.java @@ -0,0 +1,62 @@ +import com.alibaba.fastjson.JSON; +import com.ktg.RuoYiApplication; +import com.ktg.mes.wm.domain.WmStorageLocation; +import com.ktg.mes.wm.service.IWmStorageLocationService; +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 WmStorageLocationUnitTest { + @Autowired + private IWmStorageLocationService wmStorageLocationService; + + @Test + public void add() { + WmStorageLocation wmStorageLocation = new WmStorageLocation(); + wmStorageLocation.setLocationCode("L061"); + wmStorageLocation.setLocationName("测试库区001"); + wmStorageLocation.setWarehouseId(210L); + wmStorageLocation.setRemark("则是一个测试库区"); + wmStorageLocation.setLocationName("原料仓"); + wmStorageLocationService.insertWmStorageLocation(wmStorageLocation); + System.out.println("add:" + wmStorageLocation.getLocationId()); // 227 + } + + @Test + public void list() { + List list = wmStorageLocationService.selectWmStorageLocationList(new WmStorageLocation()); + System.out.println("list:" + JSON.toJSONString(list)); + } + + @Test + public void getInfo() { + System.out.println("getInfo:" + JSON.toJSONString(wmStorageLocationService.selectWmStorageLocationByLocationId(227L))); + } + + @Test + public void edit() { + WmStorageLocation wmStorageLocation = new WmStorageLocation(); + wmStorageLocation.setRemark("这是一个测试库区"); + wmStorageLocation.setLocationId(227L); + wmStorageLocation.setLocationCode("L061"); + wmStorageLocation.setLocationName("原料仓"); + wmStorageLocation.setWarehouseId(210L); + wmStorageLocation.setAreaFlag("N"); + wmStorageLocation.setFrozenFlag("N"); + int count = wmStorageLocationService.updateWmStorageLocation(wmStorageLocation); + System.out.println("edit:" + count); + } + + @Test + public void remove() { + Long[] ids = {227L}; + int count = wmStorageLocationService.deleteWmStorageLocationByLocationIds(ids); + System.out.println("remove:" + count); + } +} From 7fc5556b570de33774589843da0319fc072ef2a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=90=8D=E5=96=9C?= Date: Wed, 6 Nov 2024 16:17:26 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E7=BC=96=E5=86=99=E5=87=BA=E5=85=A5?= =?UTF-8?q?=E5=BA=93=E7=B1=BB=E5=9E=8B=E5=8D=95=E5=85=83=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/test/WmStorageLocationUnitTest.java | 3 + ktg-admin/src/test/WmWarehouseUnitTest.java | 3 + .../src/test/WmsBusinessTypeUnitTest.java | 62 +++++++++++++++++++ 3 files changed, 68 insertions(+) create mode 100644 ktg-admin/src/test/WmsBusinessTypeUnitTest.java diff --git a/ktg-admin/src/test/WmStorageLocationUnitTest.java b/ktg-admin/src/test/WmStorageLocationUnitTest.java index 767efc9..9f13d83 100644 --- a/ktg-admin/src/test/WmStorageLocationUnitTest.java +++ b/ktg-admin/src/test/WmStorageLocationUnitTest.java @@ -10,6 +10,9 @@ 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 WmStorageLocationUnitTest { diff --git a/ktg-admin/src/test/WmWarehouseUnitTest.java b/ktg-admin/src/test/WmWarehouseUnitTest.java index b0c8588..3a0dbe5 100644 --- a/ktg-admin/src/test/WmWarehouseUnitTest.java +++ b/ktg-admin/src/test/WmWarehouseUnitTest.java @@ -10,6 +10,9 @@ 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 WmWarehouseUnitTest { diff --git a/ktg-admin/src/test/WmsBusinessTypeUnitTest.java b/ktg-admin/src/test/WmsBusinessTypeUnitTest.java new file mode 100644 index 0000000..24690a3 --- /dev/null +++ b/ktg-admin/src/test/WmsBusinessTypeUnitTest.java @@ -0,0 +1,62 @@ +import com.alibaba.fastjson.JSON; +import com.ktg.RuoYiApplication; +import com.ktg.mes.md.domain.WmsBusinessType; +import com.ktg.mes.md.service.IWmsBusinessTypeService; +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 WmsBusinessTypeUnitTest { + @Autowired + private IWmsBusinessTypeService wmsBusinessTypeService; + + @Test + public void add() { + WmsBusinessType wmsBusinessType = new WmsBusinessType(); + wmsBusinessType.setCode("TYPE_UNIT_TEST_01"); + wmsBusinessType.setName("出库单元测试数据01"); + wmsBusinessType.setFlag("2"); + wmsBusinessType.setRemark("出库单元测试数据01"); + wmsBusinessTypeService.insertWmsBusinessType(wmsBusinessType); + System.out.println("add:" + wmsBusinessType.getTypeId()); // 14 + } + + @Test + public void list() { + List list = wmsBusinessTypeService.selectWmsBusinessTypeList(new WmsBusinessType()); + System.out.println("list:" + JSON.toJSONString(list)); + } + + @Test + public void getInfo() { + System.out.println("getInfo:" + JSON.toJSONString(wmsBusinessTypeService.selectWmsBusinessTypeByTypeId("14"))); + } + + @Test + public void edit() { + WmsBusinessType wmsBusinessType = new WmsBusinessType(); + wmsBusinessType.setTypeId("14"); + wmsBusinessType.setCode("TYPE_UNIT_TEST_02"); + wmsBusinessType.setName("出库单元测试数据02"); + wmsBusinessType.setFlag("2"); + wmsBusinessType.setRemark("出库单元测试数据02"); + int count = wmsBusinessTypeService.updateWmsBusinessType(wmsBusinessType); + System.out.println("edit:" + count); + } + + @Test + public void remove() { + String[] ids = {"14"}; + int count = wmsBusinessTypeService.deleteWmsBusinessTypeByTypeIds(ids); + System.out.println("remove:" + count); + } +} From a73a6e96a6c8445adb6be1295140a23a0ba0d97a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=90=8D=E5=96=9C?= Date: Wed, 6 Nov 2024 17:09:24 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E7=BC=96=E5=86=99=E7=BB=84=E7=BB=87?= =?UTF-8?q?=E6=9C=BA=E6=9E=84=E5=8D=95=E5=85=83=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ktg-admin/src/test/SysDeptUnitTest.java | 97 +++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 ktg-admin/src/test/SysDeptUnitTest.java diff --git a/ktg-admin/src/test/SysDeptUnitTest.java b/ktg-admin/src/test/SysDeptUnitTest.java new file mode 100644 index 0000000..07fe224 --- /dev/null +++ b/ktg-admin/src/test/SysDeptUnitTest.java @@ -0,0 +1,97 @@ +import com.alibaba.fastjson.JSON; +import com.ktg.RuoYiApplication; +import com.ktg.common.core.domain.AjaxResult; +import com.ktg.common.core.domain.entity.SysDept; +import com.ktg.common.utils.StringUtils; +import com.ktg.system.service.ISysDeptService; +import org.apache.commons.lang3.ArrayUtils; +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.Iterator; +import java.util.List; + +/** + * 组织机构 + */ +@RunWith(SpringRunner.class) +@SpringBootTest(classes = RuoYiApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +public class SysDeptUnitTest { + @Autowired + private ISysDeptService deptService; + + @Test + public void add() { + SysDept sysDept = new SysDept(); + sysDept.setParentId(100L); + sysDept.setDeptName("单元测试机构01"); + sysDept.setDeptCode("UNIT_DEP_001"); + sysDept.setDeptType(4); + sysDept.setOrderNum("1"); + sysDept.setStatus("0"); + deptService.insertDept(sysDept); + System.out.println("add:" + sysDept.getDeptId()); // 119 + } + + @Test + public void list() { + List list = deptService.selectDeptList(new SysDept()); + System.out.println("list:" + JSON.toJSONString(list)); + } + + @Test + public void getInfo() { + System.out.println("getInfo:" + JSON.toJSONString(deptService.selectDeptById(119L))); + } + + @Test + public void edit() { + SysDept sysDept = new SysDept(); + sysDept.setDeptId(119L); + sysDept.setParentId(100L); + sysDept.setAncestors("0,100"); + sysDept.setDeptName("单元测试机构02"); + sysDept.setDeptCode("UNIT_DEP_002"); + sysDept.setDeptType(4); + sysDept.setOrderNum("1"); + int count = deptService.updateDept(sysDept); + System.out.println("edit:" + count); + } + + @Test + public void remove() { + int count = deptService.deleteDeptById(119L); + System.out.println("remove:" + count); + } + + @Test + public void excludeChild() { + List depts = deptService.selectDeptList(new SysDept()); + Iterator it = depts.iterator(); + while (it.hasNext()) { + SysDept d = it.next(); + if (d.getDeptId().intValue() == 100 + || ArrayUtils.contains(StringUtils.split(d.getAncestors(), ","), 100 + "")) { + it.remove(); + } + } + System.out.println("excludeChild:" + JSON.toJSONString(depts)); + } + + @Test + public void treeselect() { + List depts = deptService.selectDeptList(new SysDept()); + System.out.println("treeselect:" + JSON.toJSONString(depts)); + } + + @Test + public void roleDeptTreeselect() { + List depts = deptService.selectDeptList(new SysDept()); + AjaxResult ajax = AjaxResult.success(); + ajax.put("checkedKeys", deptService.selectDeptListByRoleId(100L)); + System.out.println("roleDeptTreeselect:" + JSON.toJSONString(depts)); + } +} From 39ebdece85d6b5213f7187232f1597aceae0428b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=90=8D=E5=96=9C?= Date: Wed, 6 Nov 2024 17:35:15 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E7=BC=96=E5=86=99=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=8D=95=E5=85=83=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ktg-admin/src/test/SysUserUnitTest.java | 106 ++++++++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 ktg-admin/src/test/SysUserUnitTest.java diff --git a/ktg-admin/src/test/SysUserUnitTest.java b/ktg-admin/src/test/SysUserUnitTest.java new file mode 100644 index 0000000..bc32b7d --- /dev/null +++ b/ktg-admin/src/test/SysUserUnitTest.java @@ -0,0 +1,106 @@ +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.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.HashMap; +import java.util.List; +import java.util.stream.Collectors; + +/** + * 用户管理 + */ +@RunWith(SpringRunner.class) +@SpringBootTest(classes = RuoYiApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +public class SysUserUnitTest { + @Autowired + private ISysUserService userService; + + @Autowired + private ISysRoleService roleService; + + @Test + public void add() { + SysUser sysUser = new SysUser(); + sysUser.setDeptId(118L); + sysUser.setUserName("unittest02"); + sysUser.setNickName("单元测试用户02"); + sysUser.setPassword("123456"); + sysUser.setStatus("0"); + sysUser.setRoleIds(new Long[]{105L}); + userService.insertUser(sysUser); + System.out.println("add:" + sysUser.getUserId()); // 117 + } + + @Test + public void list() { + List list = userService.selectUserList(new SysUser()); + System.out.println("list:" + JSON.toJSONString(list)); + } + + @Test + public void getInfo() { + System.out.println("getInfo:" + JSON.toJSONString(userService.selectUserById(117L))); + } + + @Test + public void edit() { + SysUser sysUser = new SysUser(); + sysUser.setUserId(117L); + sysUser.setUserName("unittest02"); + sysUser.setNickName("单元测试用户03"); + sysUser.setPassword("123456"); + sysUser.setStatus("0"); + sysUser.setRoleIds(new Long[]{105L}); + int count = userService.updateUser(sysUser); + System.out.println("edit:" + count); + } + + @Test + public void remove() { + Long[] ids = {117L}; + int count = userService.deleteUserByIds(ids); + System.out.println("remove:" + count); + } + + @Test + public void resetPwd() { + SysUser sysUser = new SysUser(); + sysUser.setUserId(117L); + sysUser.setPassword("123456"); + int count = userService.resetPwd(sysUser); + System.out.println("resetPwd:" + count); + } + + @Test + public void changeStatus() { + SysUser sysUser = new SysUser(); + sysUser.setUserId(117L); + sysUser.setStatus("1"); + int count = userService.resetPwd(sysUser); + System.out.println("changeStatus:" + count); + } + + @Test + public void authRole() { + HashMap map = new HashMap<>(); + SysUser user = userService.selectUserById(117L); + List roles = roleService.selectRolesByUserId(117L); + map.put("user", user); + map.put("roles", SysUser.isAdmin(117L) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList())); + System.out.println("authRole:" + JSON.toJSONString(map)); + } + + @Test + public void insertAuthRole() { + userService.insertUserAuth(117L, new Long[]{105L}); + System.out.println("insertAuthRole:OK"); + } +}