Browse Source

删除无用的test文件

master
chenfang 2 years ago
parent
commit
e9e960ad09
  1. 171
      win-module-wms/win-module-wms-biz/src/test/java/com/win/module/wms/service/documentSwitch/SwitchServiceImplTest.java

171
win-module-wms/win-module-wms-biz/src/test/java/com/win/module/wms/service/documentSwitch/SwitchServiceImplTest.java

@ -1,171 +0,0 @@
package com.win.module.wms.service.documentSwitch;
import com.win.module.wms.controller.documentSwitch.vo.SwitchCreateReqVO;
import com.win.module.wms.controller.documentSwitch.vo.SwitchExportReqVO;
import com.win.module.wms.controller.documentSwitch.vo.SwitchPageReqVO;
import com.win.module.wms.controller.documentSwitch.vo.SwitchUpdateReqVO;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import javax.annotation.Resource;
import com.win.framework.test.core.ut.BaseDbUnitTest;
import com.win.module.wms.dal.dataobject.documentSwitch.SwitchDO;
import com.win.module.wms.dal.mysql.documentSwitch.SwitchMapper;
import com.win.framework.common.pojo.PageResult;
import org.springframework.context.annotation.Import;
import java.util.*;
import static com.win.module.wms.enums.ErrorCodeConstants.*;
import static com.win.framework.test.core.util.AssertUtils.*;
import static com.win.framework.test.core.util.RandomUtils.*;
import static com.win.framework.common.util.object.ObjectUtils.*;
import static org.junit.jupiter.api.Assertions.*;
/**
* {@link SwitchServiceImpl} 的单元测试类
*
* @author 源码
*/
@Import(SwitchServiceImpl.class)
public class SwitchServiceImplTest extends BaseDbUnitTest {
@Resource
private SwitchServiceImpl switchService;
@Resource
private SwitchMapper switchMapper;
@Test
public void testCreateSwitch_success() {
// 准备参数
SwitchCreateReqVO reqVO = randomPojo(SwitchCreateReqVO.class);
// 调用
Long switchId = switchService.createSwitch(reqVO);
// 断言
assertNotNull(switchId);
// 校验记录的属性是否正确
SwitchDO switch = switchMapper.selectById(switchId);
assertPojoEquals(reqVO, switch);
}
@Test
public void testUpdateSwitch_success() {
// mock 数据
SwitchDO dbSwitch = randomPojo(SwitchDO.class);
switchMapper.insert(dbSwitch);// @Sql: 先插入出一条存在的数据
// 准备参数
SwitchUpdateReqVO reqVO = randomPojo(SwitchUpdateReqVO.class, o -> {
o.setId(dbSwitch.getId()); // 设置更新的 ID
});
// 调用
switchService.updateSwitch(reqVO);
// 校验是否更新正确
SwitchDO switch = switchMapper.selectById(reqVO.getId()); // 获取最新的
assertPojoEquals(reqVO, switch);
}
@Test
public void testUpdateSwitch_notExists() {
// 准备参数
SwitchUpdateReqVO reqVO = randomPojo(SwitchUpdateReqVO.class);
// 调用, 并断言异常
assertServiceException(() -> switchService.updateSwitch(reqVO), SWITCH_NOT_EXISTS);
}
@Test
public void testDeleteSwitch_success() {
// mock 数据
SwitchDO dbSwitch = randomPojo(SwitchDO.class);
switchMapper.insert(dbSwitch);// @Sql: 先插入出一条存在的数据
// 准备参数
Long id = dbSwitch.getId();
// 调用
switchService.deleteSwitch(id);
// 校验数据不存在了
assertNull(switchMapper.selectById(id));
}
@Test
public void testDeleteSwitch_notExists() {
// 准备参数
Long id = randomLongId();
// 调用, 并断言异常
assertServiceException(() -> switchService.deleteSwitch(id), SWITCH_NOT_EXISTS);
}
@Test
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
public void testGetSwitchPage() {
// mock 数据
SwitchDO dbSwitch = randomPojo(SwitchDO.class, o -> { // 等会查询到
o.setCode(null);
o.setDescription(null);
o.setEffectiveSetValue(null);
o.setAvailable(null);
});
switchMapper.insert(dbSwitch);
// 测试 code 不匹配
switchMapper.insert(cloneIgnoreId(dbSwitch, o -> o.setCode(null)));
// 测试 description 不匹配
switchMapper.insert(cloneIgnoreId(dbSwitch, o -> o.setDescription(null)));
// 测试 effectiveSetValue 不匹配
switchMapper.insert(cloneIgnoreId(dbSwitch, o -> o.setEffectiveSetValue(null)));
// 测试 available 不匹配
switchMapper.insert(cloneIgnoreId(dbSwitch, o -> o.setAvailable(null)));
// 准备参数
SwitchPageReqVO reqVO = new SwitchPageReqVO();
reqVO.setCode(null);
reqVO.setDescription(null);
reqVO.setEffectiveSetValue(null);
reqVO.setAvailable(null);
// 调用
PageResult<SwitchDO> pageResult = switchService.getSwitchPage(reqVO);
// 断言
assertEquals(1, pageResult.getTotal());
assertEquals(1, pageResult.getList().size());
assertPojoEquals(dbSwitch, pageResult.getList().get(0));
}
@Test
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
public void testGetSwitchList() {
// mock 数据
SwitchDO dbSwitch = randomPojo(SwitchDO.class, o -> { // 等会查询到
o.setCode(null);
o.setDescription(null);
o.setEffectiveSetValue(null);
o.setAvailable(null);
});
switchMapper.insert(dbSwitch);
// 测试 code 不匹配
switchMapper.insert(cloneIgnoreId(dbSwitch, o -> o.setCode(null)));
// 测试 description 不匹配
switchMapper.insert(cloneIgnoreId(dbSwitch, o -> o.setDescription(null)));
// 测试 effectiveSetValue 不匹配
switchMapper.insert(cloneIgnoreId(dbSwitch, o -> o.setEffectiveSetValue(null)));
// 测试 available 不匹配
switchMapper.insert(cloneIgnoreId(dbSwitch, o -> o.setAvailable(null)));
// 准备参数
SwitchExportReqVO reqVO = new SwitchExportReqVO();
reqVO.setCode(null);
reqVO.setDescription(null);
reqVO.setEffectiveSetValue(null);
reqVO.setAvailable(null);
// 调用
List<SwitchDO> list = switchService.getSwitchList(reqVO);
// 断言
assertEquals(1, list.size());
assertPojoEquals(dbSwitch, list.get(0));
}
}
Loading…
Cancel
Save