lms基线版本提交
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
package org.nl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.nl.system.service.user.ISysUserService;
|
||||
import org.nl.wms.sch.point.service.ISchBasePointService;
|
||||
import org.nl.wms.sch.region.service.ISchBaseRegionService;
|
||||
import org.nl.wms.sch.region.service.dao.SchBaseRegion;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* @Author: lyd
|
||||
* @Description: 单元测试
|
||||
* @Date: 2023/5/15
|
||||
*/
|
||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||
public class ApplicationTest {
|
||||
@Autowired
|
||||
private ISysUserService userService;
|
||||
@Autowired
|
||||
private ISchBaseRegionService regionService;
|
||||
@Autowired
|
||||
private ISchBasePointService pointService;
|
||||
@Test
|
||||
void contextLoads() {
|
||||
System.out.println(userService.list());
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试多数据源情况的事务
|
||||
*/
|
||||
@Test
|
||||
@Transactional
|
||||
void contextLoads1() {
|
||||
SchBaseRegion region = new SchBaseRegion();
|
||||
region.setRegion_code("ee");
|
||||
region.setRegion_name("sss");
|
||||
region.setCreate_id("1");
|
||||
region.setCreate_name("sss");
|
||||
region.setCreate_time(DateUtil.now());
|
||||
regionService.save(region);
|
||||
int n = 1 / 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package org.nl.enums;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.nl.wms.sch.task_manage.enums.GroupBindMaterialStatusEnum;
|
||||
import org.nl.wms.sch.task_manage.enums.TaskDirectionEnum;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
/**
|
||||
* @Author: lyd
|
||||
* @Description:
|
||||
* @Date: 2023/5/25
|
||||
*/
|
||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||
public class GetEnumOnSqlTest {
|
||||
@Test
|
||||
public void TaskDirectionEnum() {
|
||||
TaskDirectionEnum[] values = TaskDirectionEnum.values();
|
||||
for (TaskDirectionEnum value : values) {
|
||||
System.out.println(value.getValue() + ", " + value.getLabel());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void GroupBindMaterialStatusEnum() {
|
||||
GroupBindMaterialStatusEnum[] values = GroupBindMaterialStatusEnum.values();
|
||||
for (GroupBindMaterialStatusEnum value : values) {
|
||||
System.out.println(value.getValue() + ", " + value.getLabel());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,179 @@
|
||||
package org.nl.task;
|
||||
|
||||
import cn.hutool.crypto.SecureUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.nl.config.MapOf;
|
||||
import org.nl.wms.sch.task_manage.task.tasks.mapper.TestMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: lyd
|
||||
* @Description: 单元测试
|
||||
* @Date: 2023/5/19
|
||||
*/
|
||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||
public class MapperTest {
|
||||
@Autowired
|
||||
private TestMapper testMapper;
|
||||
|
||||
/**
|
||||
* 无参查询
|
||||
* 返回类型: List<HashMap<String, Object>> 等同于JSONArray
|
||||
* 定义resultMap
|
||||
*/
|
||||
@Test
|
||||
void testMapper() {
|
||||
List<HashMap<String, Object>> all = testMapper.getAll();
|
||||
System.out.println(all);
|
||||
}
|
||||
|
||||
/**
|
||||
* 无参查询
|
||||
* 返回类型: JSONObject
|
||||
* 定义resultMap
|
||||
*/
|
||||
@Test
|
||||
void testMapper2() {
|
||||
JSONObject all2 = testMapper.getAll2();
|
||||
System.out.println(all2);
|
||||
}
|
||||
|
||||
/**
|
||||
* 无参查询
|
||||
* 返回类型: List<JSONObject> 等同JSONArray
|
||||
* 定义resultMap
|
||||
*/
|
||||
@Test
|
||||
void testMapper3() {
|
||||
List<JSONObject> all3 = testMapper.getAll3();
|
||||
System.out.println(all3);
|
||||
}
|
||||
|
||||
/**
|
||||
* 无参查询
|
||||
* 返回类型: JSONArray
|
||||
* 每条记录类型: JSONObject
|
||||
* 定义resultMap
|
||||
*/
|
||||
@Test
|
||||
void testMapper4() {
|
||||
JSONArray all4 = testMapper.getAll4();
|
||||
System.out.println(all4);
|
||||
}
|
||||
|
||||
/**
|
||||
* 无参查询
|
||||
* 返回类型: JSONArray
|
||||
* 每条记录类型: HashMap
|
||||
* 定义resultMap
|
||||
*/
|
||||
@Test
|
||||
void testMapper5() {
|
||||
JSONArray all5 = testMapper.getAll5();
|
||||
System.out.println(all5);
|
||||
}
|
||||
|
||||
/**
|
||||
* 无参查询
|
||||
* 返回类型: HashMap
|
||||
*/
|
||||
@Test
|
||||
void testMapper6() {
|
||||
HashMap<String, Object> all6 = testMapper.getAll6();
|
||||
System.out.println("结果集:" + all6);
|
||||
}
|
||||
|
||||
/**
|
||||
* 无参查询
|
||||
* 返回类型: JSONObject
|
||||
*/
|
||||
@Test
|
||||
void testMapper7() {
|
||||
JSONObject all7 = testMapper.getAll7();
|
||||
System.out.println("结果集:" + all7);
|
||||
}
|
||||
|
||||
/**
|
||||
* 无参查询
|
||||
* 返回类型: JSONArray
|
||||
* 每条记录类型: JSONObject
|
||||
*/
|
||||
@Test
|
||||
void testMapper8() {
|
||||
JSONArray all8 = testMapper.getAll8();
|
||||
System.out.println("结果集:" + all8);
|
||||
}
|
||||
|
||||
/**
|
||||
* 无参查询
|
||||
* 返回类型: JSONArray
|
||||
* 每条记录类型: HashMap
|
||||
*/
|
||||
@Test
|
||||
void testMapper9() {
|
||||
JSONArray all9 = testMapper.getAll9();
|
||||
System.out.println("结果集:" + all9);
|
||||
}
|
||||
|
||||
/**
|
||||
* 含参查询
|
||||
* 返回类型: JSONObject
|
||||
* 传参类型: HashMap
|
||||
*/
|
||||
@Test
|
||||
void testMapper10() {
|
||||
JSONObject all10 = testMapper.getAll10(MapOf.of("pointCode", "HNJ01"));
|
||||
System.out.println("结果集:" + all10);
|
||||
}
|
||||
|
||||
/**
|
||||
* 含参查询
|
||||
* 返回类型: JSONObject
|
||||
* 传参类型: JSONObject
|
||||
*/
|
||||
@Test
|
||||
void testMapper11() {
|
||||
//
|
||||
JSONObject json=new JSONObject();
|
||||
// json.put("pointCode","HNJ01");
|
||||
JSONArray all11 = testMapper.getAll11(json);
|
||||
System.out.println("结果集:" + all11);
|
||||
}
|
||||
|
||||
/**
|
||||
* mybatis - for的写法 - 使用于IN查询
|
||||
*/
|
||||
@Test
|
||||
void testMapper12() {
|
||||
List<String> list = Arrays.asList("HNJ01", "KLHJ02");
|
||||
// List<String> list = new ArrayList<>();
|
||||
JSONArray all12 = testMapper.getAll12(list);
|
||||
System.out.println("结果集:" + all12);
|
||||
}
|
||||
|
||||
@Test
|
||||
void test1() {
|
||||
for (int i = 0; i < 2; i++) {
|
||||
System.out.println(SecureUtil.md5("123456"));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用第二数据源
|
||||
*/
|
||||
@Test
|
||||
@Transactional
|
||||
void testMapper13() {
|
||||
JSONObject all13 = testMapper.getAll13();
|
||||
System.out.println("结果集:" + all13);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user