forked from sfms3.0/sfms3.0
14 changed files with 0 additions and 3428 deletions
@ -1,316 +0,0 @@ |
|||
package com.win.module.wms.service.businesstype; |
|||
|
|||
import com.win.module.wms.controller.businesstype.vo.BusinesstypeCreateReqVO; |
|||
import com.win.module.wms.controller.businesstype.vo.BusinesstypeExportReqVO; |
|||
import com.win.module.wms.controller.businesstype.vo.BusinesstypePageReqVO; |
|||
import com.win.module.wms.controller.businesstype.vo.BusinesstypeUpdateReqVO; |
|||
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.businesstype.BusinesstypeDO; |
|||
import com.win.module.wms.dal.mysql.businesstype.BusinesstypeMapper; |
|||
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.date.LocalDateTimeUtils.*; |
|||
import static com.win.framework.common.util.object.ObjectUtils.*; |
|||
import static org.junit.jupiter.api.Assertions.*; |
|||
|
|||
/** |
|||
* {@link BusinesstypeServiceImpl} 的单元测试类 |
|||
* |
|||
* @author 超级管理员 |
|||
*/ |
|||
@Import(BusinesstypeServiceImpl.class) |
|||
public class BusinesstypeServiceImplTest extends BaseDbUnitTest { |
|||
|
|||
@Resource |
|||
private BusinesstypeServiceImpl businesstypeService; |
|||
|
|||
@Resource |
|||
private BusinesstypeMapper businesstypeMapper; |
|||
|
|||
@Test |
|||
public void testCreateBusinesstype_success() { |
|||
// 准备参数
|
|||
BusinesstypeCreateReqVO reqVO = randomPojo(BusinesstypeCreateReqVO.class); |
|||
|
|||
// 调用
|
|||
Long businesstypeId = businesstypeService.createBusinesstype(reqVO); |
|||
// 断言
|
|||
assertNotNull(businesstypeId); |
|||
// 校验记录的属性是否正确
|
|||
BusinesstypeDO businesstype = businesstypeMapper.selectById(businesstypeId); |
|||
assertPojoEquals(reqVO, businesstype); |
|||
} |
|||
|
|||
@Test |
|||
public void testUpdateBusinesstype_success() { |
|||
// mock 数据
|
|||
BusinesstypeDO dbBusinesstype = randomPojo(BusinesstypeDO.class); |
|||
businesstypeMapper.insert(dbBusinesstype);// @Sql: 先插入出一条存在的数据
|
|||
// 准备参数
|
|||
BusinesstypeUpdateReqVO reqVO = randomPojo(BusinesstypeUpdateReqVO.class, o -> { |
|||
o.setId(dbBusinesstype.getId()); // 设置更新的 ID
|
|||
}); |
|||
|
|||
// 调用
|
|||
businesstypeService.updateBusinesstype(reqVO); |
|||
// 校验是否更新正确
|
|||
BusinesstypeDO businesstype = businesstypeMapper.selectById(reqVO.getId()); // 获取最新的
|
|||
assertPojoEquals(reqVO, businesstype); |
|||
} |
|||
|
|||
@Test |
|||
public void testUpdateBusinesstype_notExists() { |
|||
// 准备参数
|
|||
BusinesstypeUpdateReqVO reqVO = randomPojo(BusinesstypeUpdateReqVO.class); |
|||
|
|||
// 调用, 并断言异常
|
|||
assertServiceException(() -> businesstypeService.updateBusinesstype(reqVO), BUSINESSTYPE_NOT_EXISTS); |
|||
} |
|||
|
|||
@Test |
|||
public void testDeleteBusinesstype_success() { |
|||
// mock 数据
|
|||
BusinesstypeDO dbBusinesstype = randomPojo(BusinesstypeDO.class); |
|||
businesstypeMapper.insert(dbBusinesstype);// @Sql: 先插入出一条存在的数据
|
|||
// 准备参数
|
|||
Long id = dbBusinesstype.getId(); |
|||
|
|||
// 调用
|
|||
businesstypeService.deleteBusinesstype(id); |
|||
// 校验数据不存在了
|
|||
assertNull(businesstypeMapper.selectById(id)); |
|||
} |
|||
|
|||
@Test |
|||
public void testDeleteBusinesstype_notExists() { |
|||
// 准备参数
|
|||
Long id = randomLongId(); |
|||
|
|||
// 调用, 并断言异常
|
|||
assertServiceException(() -> businesstypeService.deleteBusinesstype(id), BUSINESSTYPE_NOT_EXISTS); |
|||
} |
|||
|
|||
@Test |
|||
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
|
|||
public void testGetBusinesstypePage() { |
|||
// mock 数据
|
|||
BusinesstypeDO dbBusinesstype = randomPojo(BusinesstypeDO.class, o -> { // 等会查询到
|
|||
o.setCode(null); |
|||
o.setName(null); |
|||
o.setDescription(null); |
|||
o.setItemTypes(null); |
|||
o.setItemStatuses(null); |
|||
o.setOutLocationTypes(null); |
|||
o.setInLocationTypes(null); |
|||
o.setOutAreaCodes(null); |
|||
o.setInAreaCodes(null); |
|||
o.setOutInventoryStatuses(null); |
|||
o.setInInventoryStatuses(null); |
|||
o.setOutTransactionType(null); |
|||
o.setInTransactionType(null); |
|||
o.setOnTheWayArea(null); |
|||
o.setActiveTime(null); |
|||
o.setExpireTime(null); |
|||
o.setRemark(null); |
|||
o.setCreateTime(null); |
|||
o.setCreator(null); |
|||
o.setUseOnTheWay(null); |
|||
o.setAvailable(null); |
|||
o.setIsSoftDeleted(null); |
|||
}); |
|||
businesstypeMapper.insert(dbBusinesstype); |
|||
// 测试 code 不匹配
|
|||
businesstypeMapper.insert(cloneIgnoreId(dbBusinesstype, o -> o.setCode(null))); |
|||
// 测试 name 不匹配
|
|||
businesstypeMapper.insert(cloneIgnoreId(dbBusinesstype, o -> o.setName(null))); |
|||
// 测试 description 不匹配
|
|||
businesstypeMapper.insert(cloneIgnoreId(dbBusinesstype, o -> o.setDescription(null))); |
|||
// 测试 itemTypes 不匹配
|
|||
businesstypeMapper.insert(cloneIgnoreId(dbBusinesstype, o -> o.setItemTypes(null))); |
|||
// 测试 itemStatuses 不匹配
|
|||
businesstypeMapper.insert(cloneIgnoreId(dbBusinesstype, o -> o.setItemStatuses(null))); |
|||
// 测试 outLocationTypes 不匹配
|
|||
businesstypeMapper.insert(cloneIgnoreId(dbBusinesstype, o -> o.setOutLocationTypes(null))); |
|||
// 测试 inLocationTypes 不匹配
|
|||
businesstypeMapper.insert(cloneIgnoreId(dbBusinesstype, o -> o.setInLocationTypes(null))); |
|||
// 测试 outAreaCodes 不匹配
|
|||
businesstypeMapper.insert(cloneIgnoreId(dbBusinesstype, o -> o.setOutAreaCodes(null))); |
|||
// 测试 inAreaCodes 不匹配
|
|||
businesstypeMapper.insert(cloneIgnoreId(dbBusinesstype, o -> o.setInAreaCodes(null))); |
|||
// 测试 outInventoryStatuses 不匹配
|
|||
businesstypeMapper.insert(cloneIgnoreId(dbBusinesstype, o -> o.setOutInventoryStatuses(null))); |
|||
// 测试 inInventoryStatuses 不匹配
|
|||
businesstypeMapper.insert(cloneIgnoreId(dbBusinesstype, o -> o.setInInventoryStatuses(null))); |
|||
// 测试 outTransactionType 不匹配
|
|||
businesstypeMapper.insert(cloneIgnoreId(dbBusinesstype, o -> o.setOutTransactionType(null))); |
|||
// 测试 inTransactionType 不匹配
|
|||
businesstypeMapper.insert(cloneIgnoreId(dbBusinesstype, o -> o.setInTransactionType(null))); |
|||
// 测试 onTheWayArea 不匹配
|
|||
businesstypeMapper.insert(cloneIgnoreId(dbBusinesstype, o -> o.setOnTheWayArea(null))); |
|||
// 测试 activeTime 不匹配
|
|||
businesstypeMapper.insert(cloneIgnoreId(dbBusinesstype, o -> o.setActiveTime(null))); |
|||
// 测试 expireTime 不匹配
|
|||
businesstypeMapper.insert(cloneIgnoreId(dbBusinesstype, o -> o.setExpireTime(null))); |
|||
// 测试 remark 不匹配
|
|||
businesstypeMapper.insert(cloneIgnoreId(dbBusinesstype, o -> o.setRemark(null))); |
|||
// 测试 createTime 不匹配
|
|||
businesstypeMapper.insert(cloneIgnoreId(dbBusinesstype, o -> o.setCreateTime(null))); |
|||
// 测试 creator 不匹配
|
|||
businesstypeMapper.insert(cloneIgnoreId(dbBusinesstype, o -> o.setCreator(null))); |
|||
// 测试 useOnTheWay 不匹配
|
|||
businesstypeMapper.insert(cloneIgnoreId(dbBusinesstype, o -> o.setUseOnTheWay(null))); |
|||
// 测试 available 不匹配
|
|||
businesstypeMapper.insert(cloneIgnoreId(dbBusinesstype, o -> o.setAvailable(null))); |
|||
// 测试 isSoftDeleted 不匹配
|
|||
businesstypeMapper.insert(cloneIgnoreId(dbBusinesstype, o -> o.setIsSoftDeleted(null))); |
|||
// 准备参数
|
|||
BusinesstypePageReqVO reqVO = new BusinesstypePageReqVO(); |
|||
reqVO.setCode(null); |
|||
reqVO.setName(null); |
|||
reqVO.setDescription(null); |
|||
reqVO.setItemTypes(null); |
|||
reqVO.setItemStatuses(null); |
|||
reqVO.setOutLocationTypes(null); |
|||
reqVO.setInLocationTypes(null); |
|||
reqVO.setOutAreaCodes(null); |
|||
reqVO.setInAreaCodes(null); |
|||
reqVO.setOutInventoryStatuses(null); |
|||
reqVO.setInInventoryStatuses(null); |
|||
reqVO.setOutTransactionType(null); |
|||
reqVO.setInTransactionType(null); |
|||
reqVO.setOnTheWayArea(null); |
|||
reqVO.setActiveTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); |
|||
reqVO.setExpireTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); |
|||
reqVO.setRemark(null); |
|||
reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); |
|||
reqVO.setCreator(null); |
|||
reqVO.setUseOnTheWay(null); |
|||
reqVO.setAvailable(null); |
|||
reqVO.setIsSoftDeleted(null); |
|||
|
|||
// 调用
|
|||
PageResult<BusinesstypeDO> pageResult = businesstypeService.getBusinesstypePage(reqVO); |
|||
// 断言
|
|||
assertEquals(1, pageResult.getTotal()); |
|||
assertEquals(1, pageResult.getList().size()); |
|||
assertPojoEquals(dbBusinesstype, pageResult.getList().get(0)); |
|||
} |
|||
|
|||
@Test |
|||
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
|
|||
public void testGetBusinesstypeList() { |
|||
// mock 数据
|
|||
BusinesstypeDO dbBusinesstype = randomPojo(BusinesstypeDO.class, o -> { // 等会查询到
|
|||
o.setCode(null); |
|||
o.setName(null); |
|||
o.setDescription(null); |
|||
o.setItemTypes(null); |
|||
o.setItemStatuses(null); |
|||
o.setOutLocationTypes(null); |
|||
o.setInLocationTypes(null); |
|||
o.setOutAreaCodes(null); |
|||
o.setInAreaCodes(null); |
|||
o.setOutInventoryStatuses(null); |
|||
o.setInInventoryStatuses(null); |
|||
o.setOutTransactionType(null); |
|||
o.setInTransactionType(null); |
|||
o.setOnTheWayArea(null); |
|||
o.setActiveTime(null); |
|||
o.setExpireTime(null); |
|||
o.setRemark(null); |
|||
o.setCreateTime(null); |
|||
o.setCreator(null); |
|||
o.setUseOnTheWay(null); |
|||
o.setAvailable(null); |
|||
o.setIsSoftDeleted(null); |
|||
}); |
|||
businesstypeMapper.insert(dbBusinesstype); |
|||
// 测试 code 不匹配
|
|||
businesstypeMapper.insert(cloneIgnoreId(dbBusinesstype, o -> o.setCode(null))); |
|||
// 测试 name 不匹配
|
|||
businesstypeMapper.insert(cloneIgnoreId(dbBusinesstype, o -> o.setName(null))); |
|||
// 测试 description 不匹配
|
|||
businesstypeMapper.insert(cloneIgnoreId(dbBusinesstype, o -> o.setDescription(null))); |
|||
// 测试 itemTypes 不匹配
|
|||
businesstypeMapper.insert(cloneIgnoreId(dbBusinesstype, o -> o.setItemTypes(null))); |
|||
// 测试 itemStatuses 不匹配
|
|||
businesstypeMapper.insert(cloneIgnoreId(dbBusinesstype, o -> o.setItemStatuses(null))); |
|||
// 测试 outLocationTypes 不匹配
|
|||
businesstypeMapper.insert(cloneIgnoreId(dbBusinesstype, o -> o.setOutLocationTypes(null))); |
|||
// 测试 inLocationTypes 不匹配
|
|||
businesstypeMapper.insert(cloneIgnoreId(dbBusinesstype, o -> o.setInLocationTypes(null))); |
|||
// 测试 outAreaCodes 不匹配
|
|||
businesstypeMapper.insert(cloneIgnoreId(dbBusinesstype, o -> o.setOutAreaCodes(null))); |
|||
// 测试 inAreaCodes 不匹配
|
|||
businesstypeMapper.insert(cloneIgnoreId(dbBusinesstype, o -> o.setInAreaCodes(null))); |
|||
// 测试 outInventoryStatuses 不匹配
|
|||
businesstypeMapper.insert(cloneIgnoreId(dbBusinesstype, o -> o.setOutInventoryStatuses(null))); |
|||
// 测试 inInventoryStatuses 不匹配
|
|||
businesstypeMapper.insert(cloneIgnoreId(dbBusinesstype, o -> o.setInInventoryStatuses(null))); |
|||
// 测试 outTransactionType 不匹配
|
|||
businesstypeMapper.insert(cloneIgnoreId(dbBusinesstype, o -> o.setOutTransactionType(null))); |
|||
// 测试 inTransactionType 不匹配
|
|||
businesstypeMapper.insert(cloneIgnoreId(dbBusinesstype, o -> o.setInTransactionType(null))); |
|||
// 测试 onTheWayArea 不匹配
|
|||
businesstypeMapper.insert(cloneIgnoreId(dbBusinesstype, o -> o.setOnTheWayArea(null))); |
|||
// 测试 activeTime 不匹配
|
|||
businesstypeMapper.insert(cloneIgnoreId(dbBusinesstype, o -> o.setActiveTime(null))); |
|||
// 测试 expireTime 不匹配
|
|||
businesstypeMapper.insert(cloneIgnoreId(dbBusinesstype, o -> o.setExpireTime(null))); |
|||
// 测试 remark 不匹配
|
|||
businesstypeMapper.insert(cloneIgnoreId(dbBusinesstype, o -> o.setRemark(null))); |
|||
// 测试 createTime 不匹配
|
|||
businesstypeMapper.insert(cloneIgnoreId(dbBusinesstype, o -> o.setCreateTime(null))); |
|||
// 测试 creator 不匹配
|
|||
businesstypeMapper.insert(cloneIgnoreId(dbBusinesstype, o -> o.setCreator(null))); |
|||
// 测试 useOnTheWay 不匹配
|
|||
businesstypeMapper.insert(cloneIgnoreId(dbBusinesstype, o -> o.setUseOnTheWay(null))); |
|||
// 测试 available 不匹配
|
|||
businesstypeMapper.insert(cloneIgnoreId(dbBusinesstype, o -> o.setAvailable(null))); |
|||
// 测试 isSoftDeleted 不匹配
|
|||
businesstypeMapper.insert(cloneIgnoreId(dbBusinesstype, o -> o.setIsSoftDeleted(null))); |
|||
// 准备参数
|
|||
BusinesstypeExportReqVO reqVO = new BusinesstypeExportReqVO(); |
|||
reqVO.setCode(null); |
|||
reqVO.setName(null); |
|||
reqVO.setDescription(null); |
|||
reqVO.setItemTypes(null); |
|||
reqVO.setItemStatuses(null); |
|||
reqVO.setOutLocationTypes(null); |
|||
reqVO.setInLocationTypes(null); |
|||
reqVO.setOutAreaCodes(null); |
|||
reqVO.setInAreaCodes(null); |
|||
reqVO.setOutInventoryStatuses(null); |
|||
reqVO.setInInventoryStatuses(null); |
|||
reqVO.setOutTransactionType(null); |
|||
reqVO.setInTransactionType(null); |
|||
reqVO.setOnTheWayArea(null); |
|||
reqVO.setActiveTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); |
|||
reqVO.setExpireTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); |
|||
reqVO.setRemark(null); |
|||
reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); |
|||
reqVO.setCreator(null); |
|||
reqVO.setUseOnTheWay(null); |
|||
reqVO.setAvailable(null); |
|||
reqVO.setIsSoftDeleted(null); |
|||
|
|||
// 调用
|
|||
List<BusinesstypeDO> list = businesstypeService.getBusinesstypeList(reqVO); |
|||
// 断言
|
|||
assertEquals(1, list.size()); |
|||
assertPojoEquals(dbBusinesstype, list.get(0)); |
|||
} |
|||
|
|||
} |
@ -1,300 +0,0 @@ |
|||
package com.win.module.wms.service.carrier; |
|||
|
|||
import com.win.module.wms.controller.carrier.vo.CarrierCreateReqVO; |
|||
import com.win.module.wms.controller.carrier.vo.CarrierExportReqVO; |
|||
import com.win.module.wms.controller.carrier.vo.CarrierPageReqVO; |
|||
import com.win.module.wms.controller.carrier.vo.CarrierUpdateReqVO; |
|||
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.carrier.CarrierDO; |
|||
import com.win.module.wms.dal.mysql.carrier.CarrierMapper; |
|||
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.date.LocalDateTimeUtils.*; |
|||
import static com.win.framework.common.util.object.ObjectUtils.*; |
|||
import static org.junit.jupiter.api.Assertions.*; |
|||
|
|||
/** |
|||
* {@link CarrierServiceImpl} 的单元测试类 |
|||
* |
|||
* @author 超级管理员 |
|||
*/ |
|||
@Import(CarrierServiceImpl.class) |
|||
public class CarrierServiceImplTest extends BaseDbUnitTest { |
|||
|
|||
@Resource |
|||
private CarrierServiceImpl carrierService; |
|||
|
|||
@Resource |
|||
private CarrierMapper carrierMapper; |
|||
|
|||
@Test |
|||
public void testCreateCarrier_success() { |
|||
// 准备参数
|
|||
CarrierCreateReqVO reqVO = randomPojo(CarrierCreateReqVO.class); |
|||
|
|||
// 调用
|
|||
Long carrierId = carrierService.createCarrier(reqVO); |
|||
// 断言
|
|||
assertNotNull(carrierId); |
|||
// 校验记录的属性是否正确
|
|||
CarrierDO carrier = carrierMapper.selectById(carrierId); |
|||
assertPojoEquals(reqVO, carrier); |
|||
} |
|||
|
|||
@Test |
|||
public void testUpdateCarrier_success() { |
|||
// mock 数据
|
|||
CarrierDO dbCarrier = randomPojo(CarrierDO.class); |
|||
carrierMapper.insert(dbCarrier);// @Sql: 先插入出一条存在的数据
|
|||
// 准备参数
|
|||
CarrierUpdateReqVO reqVO = randomPojo(CarrierUpdateReqVO.class, o -> { |
|||
o.setId(dbCarrier.getId()); // 设置更新的 ID
|
|||
}); |
|||
|
|||
// 调用
|
|||
carrierService.updateCarrier(reqVO); |
|||
// 校验是否更新正确
|
|||
CarrierDO carrier = carrierMapper.selectById(reqVO.getId()); // 获取最新的
|
|||
assertPojoEquals(reqVO, carrier); |
|||
} |
|||
|
|||
@Test |
|||
public void testUpdateCarrier_notExists() { |
|||
// 准备参数
|
|||
CarrierUpdateReqVO reqVO = randomPojo(CarrierUpdateReqVO.class); |
|||
|
|||
// 调用, 并断言异常
|
|||
assertServiceException(() -> carrierService.updateCarrier(reqVO), CARRIER_NOT_EXISTS); |
|||
} |
|||
|
|||
@Test |
|||
public void testDeleteCarrier_success() { |
|||
// mock 数据
|
|||
CarrierDO dbCarrier = randomPojo(CarrierDO.class); |
|||
carrierMapper.insert(dbCarrier);// @Sql: 先插入出一条存在的数据
|
|||
// 准备参数
|
|||
Long id = dbCarrier.getId(); |
|||
|
|||
// 调用
|
|||
carrierService.deleteCarrier(id); |
|||
// 校验数据不存在了
|
|||
assertNull(carrierMapper.selectById(id)); |
|||
} |
|||
|
|||
@Test |
|||
public void testDeleteCarrier_notExists() { |
|||
// 准备参数
|
|||
Long id = randomLongId(); |
|||
|
|||
// 调用, 并断言异常
|
|||
assertServiceException(() -> carrierService.deleteCarrier(id), CARRIER_NOT_EXISTS); |
|||
} |
|||
|
|||
@Test |
|||
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
|
|||
public void testGetCarrierPage() { |
|||
// mock 数据
|
|||
CarrierDO dbCarrier = randomPojo(CarrierDO.class, o -> { // 等会查询到
|
|||
o.setCode(null); |
|||
o.setName(null); |
|||
o.setShortName(null); |
|||
o.setAddress(null); |
|||
o.setCountry(null); |
|||
o.setCity(null); |
|||
o.setPhone(null); |
|||
o.setFax(null); |
|||
o.setPostId(null); |
|||
o.setContacts(null); |
|||
o.setBank(null); |
|||
o.setCurrency(null); |
|||
o.setTaxRate(null); |
|||
o.setType(null); |
|||
o.setActiveTime(null); |
|||
o.setExpireTime(null); |
|||
o.setRemark(null); |
|||
o.setCreateTime(null); |
|||
o.setCreator(null); |
|||
o.setAvailable(null); |
|||
}); |
|||
carrierMapper.insert(dbCarrier); |
|||
// 测试 code 不匹配
|
|||
carrierMapper.insert(cloneIgnoreId(dbCarrier, o -> o.setCode(null))); |
|||
// 测试 name 不匹配
|
|||
carrierMapper.insert(cloneIgnoreId(dbCarrier, o -> o.setName(null))); |
|||
// 测试 shortName 不匹配
|
|||
carrierMapper.insert(cloneIgnoreId(dbCarrier, o -> o.setShortName(null))); |
|||
// 测试 address 不匹配
|
|||
carrierMapper.insert(cloneIgnoreId(dbCarrier, o -> o.setAddress(null))); |
|||
// 测试 country 不匹配
|
|||
carrierMapper.insert(cloneIgnoreId(dbCarrier, o -> o.setCountry(null))); |
|||
// 测试 city 不匹配
|
|||
carrierMapper.insert(cloneIgnoreId(dbCarrier, o -> o.setCity(null))); |
|||
// 测试 phone 不匹配
|
|||
carrierMapper.insert(cloneIgnoreId(dbCarrier, o -> o.setPhone(null))); |
|||
// 测试 fax 不匹配
|
|||
carrierMapper.insert(cloneIgnoreId(dbCarrier, o -> o.setFax(null))); |
|||
// 测试 postId 不匹配
|
|||
carrierMapper.insert(cloneIgnoreId(dbCarrier, o -> o.setPostId(null))); |
|||
// 测试 contacts 不匹配
|
|||
carrierMapper.insert(cloneIgnoreId(dbCarrier, o -> o.setContacts(null))); |
|||
// 测试 bank 不匹配
|
|||
carrierMapper.insert(cloneIgnoreId(dbCarrier, o -> o.setBank(null))); |
|||
// 测试 currency 不匹配
|
|||
carrierMapper.insert(cloneIgnoreId(dbCarrier, o -> o.setCurrency(null))); |
|||
// 测试 taxRate 不匹配
|
|||
carrierMapper.insert(cloneIgnoreId(dbCarrier, o -> o.setTaxRate(null))); |
|||
// 测试 type 不匹配
|
|||
carrierMapper.insert(cloneIgnoreId(dbCarrier, o -> o.setType(null))); |
|||
// 测试 activeTime 不匹配
|
|||
carrierMapper.insert(cloneIgnoreId(dbCarrier, o -> o.setActiveTime(null))); |
|||
// 测试 expireTime 不匹配
|
|||
carrierMapper.insert(cloneIgnoreId(dbCarrier, o -> o.setExpireTime(null))); |
|||
// 测试 remark 不匹配
|
|||
carrierMapper.insert(cloneIgnoreId(dbCarrier, o -> o.setRemark(null))); |
|||
// 测试 createTime 不匹配
|
|||
carrierMapper.insert(cloneIgnoreId(dbCarrier, o -> o.setCreateTime(null))); |
|||
// 测试 creator 不匹配
|
|||
carrierMapper.insert(cloneIgnoreId(dbCarrier, o -> o.setCreator(null))); |
|||
// 测试 available 不匹配
|
|||
carrierMapper.insert(cloneIgnoreId(dbCarrier, o -> o.setAvailable(null))); |
|||
// 准备参数
|
|||
CarrierPageReqVO reqVO = new CarrierPageReqVO(); |
|||
reqVO.setCode(null); |
|||
reqVO.setName(null); |
|||
reqVO.setShortName(null); |
|||
reqVO.setAddress(null); |
|||
reqVO.setCountry(null); |
|||
reqVO.setCity(null); |
|||
reqVO.setPhone(null); |
|||
reqVO.setFax(null); |
|||
reqVO.setPostId(null); |
|||
reqVO.setContacts(null); |
|||
reqVO.setBank(null); |
|||
reqVO.setCurrency(null); |
|||
reqVO.setTaxRate(null); |
|||
reqVO.setType(null); |
|||
reqVO.setActiveTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); |
|||
reqVO.setExpireTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); |
|||
reqVO.setRemark(null); |
|||
reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); |
|||
reqVO.setCreator(null); |
|||
reqVO.setAvailable(null); |
|||
|
|||
// 调用
|
|||
PageResult<CarrierDO> pageResult = carrierService.getCarrierPage(reqVO); |
|||
// 断言
|
|||
assertEquals(1, pageResult.getTotal()); |
|||
assertEquals(1, pageResult.getList().size()); |
|||
assertPojoEquals(dbCarrier, pageResult.getList().get(0)); |
|||
} |
|||
|
|||
@Test |
|||
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
|
|||
public void testGetCarrierList() { |
|||
// mock 数据
|
|||
CarrierDO dbCarrier = randomPojo(CarrierDO.class, o -> { // 等会查询到
|
|||
o.setCode(null); |
|||
o.setName(null); |
|||
o.setShortName(null); |
|||
o.setAddress(null); |
|||
o.setCountry(null); |
|||
o.setCity(null); |
|||
o.setPhone(null); |
|||
o.setFax(null); |
|||
o.setPostId(null); |
|||
o.setContacts(null); |
|||
o.setBank(null); |
|||
o.setCurrency(null); |
|||
o.setTaxRate(null); |
|||
o.setType(null); |
|||
o.setActiveTime(null); |
|||
o.setExpireTime(null); |
|||
o.setRemark(null); |
|||
o.setCreateTime(null); |
|||
o.setCreator(null); |
|||
o.setAvailable(null); |
|||
}); |
|||
carrierMapper.insert(dbCarrier); |
|||
// 测试 code 不匹配
|
|||
carrierMapper.insert(cloneIgnoreId(dbCarrier, o -> o.setCode(null))); |
|||
// 测试 name 不匹配
|
|||
carrierMapper.insert(cloneIgnoreId(dbCarrier, o -> o.setName(null))); |
|||
// 测试 shortName 不匹配
|
|||
carrierMapper.insert(cloneIgnoreId(dbCarrier, o -> o.setShortName(null))); |
|||
// 测试 address 不匹配
|
|||
carrierMapper.insert(cloneIgnoreId(dbCarrier, o -> o.setAddress(null))); |
|||
// 测试 country 不匹配
|
|||
carrierMapper.insert(cloneIgnoreId(dbCarrier, o -> o.setCountry(null))); |
|||
// 测试 city 不匹配
|
|||
carrierMapper.insert(cloneIgnoreId(dbCarrier, o -> o.setCity(null))); |
|||
// 测试 phone 不匹配
|
|||
carrierMapper.insert(cloneIgnoreId(dbCarrier, o -> o.setPhone(null))); |
|||
// 测试 fax 不匹配
|
|||
carrierMapper.insert(cloneIgnoreId(dbCarrier, o -> o.setFax(null))); |
|||
// 测试 postId 不匹配
|
|||
carrierMapper.insert(cloneIgnoreId(dbCarrier, o -> o.setPostId(null))); |
|||
// 测试 contacts 不匹配
|
|||
carrierMapper.insert(cloneIgnoreId(dbCarrier, o -> o.setContacts(null))); |
|||
// 测试 bank 不匹配
|
|||
carrierMapper.insert(cloneIgnoreId(dbCarrier, o -> o.setBank(null))); |
|||
// 测试 currency 不匹配
|
|||
carrierMapper.insert(cloneIgnoreId(dbCarrier, o -> o.setCurrency(null))); |
|||
// 测试 taxRate 不匹配
|
|||
carrierMapper.insert(cloneIgnoreId(dbCarrier, o -> o.setTaxRate(null))); |
|||
// 测试 type 不匹配
|
|||
carrierMapper.insert(cloneIgnoreId(dbCarrier, o -> o.setType(null))); |
|||
// 测试 activeTime 不匹配
|
|||
carrierMapper.insert(cloneIgnoreId(dbCarrier, o -> o.setActiveTime(null))); |
|||
// 测试 expireTime 不匹配
|
|||
carrierMapper.insert(cloneIgnoreId(dbCarrier, o -> o.setExpireTime(null))); |
|||
// 测试 remark 不匹配
|
|||
carrierMapper.insert(cloneIgnoreId(dbCarrier, o -> o.setRemark(null))); |
|||
// 测试 createTime 不匹配
|
|||
carrierMapper.insert(cloneIgnoreId(dbCarrier, o -> o.setCreateTime(null))); |
|||
// 测试 creator 不匹配
|
|||
carrierMapper.insert(cloneIgnoreId(dbCarrier, o -> o.setCreator(null))); |
|||
// 测试 available 不匹配
|
|||
carrierMapper.insert(cloneIgnoreId(dbCarrier, o -> o.setAvailable(null))); |
|||
// 准备参数
|
|||
CarrierExportReqVO reqVO = new CarrierExportReqVO(); |
|||
reqVO.setCode(null); |
|||
reqVO.setName(null); |
|||
reqVO.setShortName(null); |
|||
reqVO.setAddress(null); |
|||
reqVO.setCountry(null); |
|||
reqVO.setCity(null); |
|||
reqVO.setPhone(null); |
|||
reqVO.setFax(null); |
|||
reqVO.setPostId(null); |
|||
reqVO.setContacts(null); |
|||
reqVO.setBank(null); |
|||
reqVO.setCurrency(null); |
|||
reqVO.setTaxRate(null); |
|||
reqVO.setType(null); |
|||
reqVO.setActiveTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); |
|||
reqVO.setExpireTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); |
|||
reqVO.setRemark(null); |
|||
reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); |
|||
reqVO.setCreator(null); |
|||
reqVO.setAvailable(null); |
|||
|
|||
// 调用
|
|||
List<CarrierDO> list = carrierService.getCarrierList(reqVO); |
|||
// 断言
|
|||
assertEquals(1, list.size()); |
|||
assertPojoEquals(dbCarrier, list.get(0)); |
|||
} |
|||
|
|||
} |
@ -1,187 +0,0 @@ |
|||
package com.win.module.wms.service.configuration; |
|||
|
|||
import com.win.module.wms.controller.configuration.vo.ConfigurationCreateReqVO; |
|||
import com.win.module.wms.controller.configuration.vo.ConfigurationExportReqVO; |
|||
import com.win.module.wms.controller.configuration.vo.ConfigurationPageReqVO; |
|||
import com.win.module.wms.controller.configuration.vo.ConfigurationUpdateReqVO; |
|||
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.configuration.ConfigurationDO; |
|||
import com.win.module.wms.dal.mysql.configuration.ConfigurationMapper; |
|||
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 ConfigurationServiceImpl} 的单元测试类 |
|||
* |
|||
* @author 超级管理员 |
|||
*/ |
|||
@Import(ConfigurationServiceImpl.class) |
|||
public class ConfigurationServiceImplTest extends BaseDbUnitTest { |
|||
|
|||
@Resource |
|||
private ConfigurationServiceImpl configurationService; |
|||
|
|||
@Resource |
|||
private ConfigurationMapper configurationMapper; |
|||
|
|||
@Test |
|||
public void testCreateConfiguration_success() { |
|||
// 准备参数
|
|||
ConfigurationCreateReqVO reqVO = randomPojo(ConfigurationCreateReqVO.class); |
|||
|
|||
// 调用
|
|||
Long configurationId = configurationService.createConfiguration(reqVO); |
|||
// 断言
|
|||
assertNotNull(configurationId); |
|||
// 校验记录的属性是否正确
|
|||
ConfigurationDO configuration = configurationMapper.selectById(configurationId); |
|||
assertPojoEquals(reqVO, configuration); |
|||
} |
|||
|
|||
@Test |
|||
public void testUpdateConfiguration_success() { |
|||
// mock 数据
|
|||
ConfigurationDO dbConfiguration = randomPojo(ConfigurationDO.class); |
|||
configurationMapper.insert(dbConfiguration);// @Sql: 先插入出一条存在的数据
|
|||
// 准备参数
|
|||
ConfigurationUpdateReqVO reqVO = randomPojo(ConfigurationUpdateReqVO.class, o -> { |
|||
o.setId(dbConfiguration.getId()); // 设置更新的 ID
|
|||
}); |
|||
|
|||
// 调用
|
|||
configurationService.updateConfiguration(reqVO); |
|||
// 校验是否更新正确
|
|||
ConfigurationDO configuration = configurationMapper.selectById(reqVO.getId()); // 获取最新的
|
|||
assertPojoEquals(reqVO, configuration); |
|||
} |
|||
|
|||
@Test |
|||
public void testUpdateConfiguration_notExists() { |
|||
// 准备参数
|
|||
ConfigurationUpdateReqVO reqVO = randomPojo(ConfigurationUpdateReqVO.class); |
|||
|
|||
// 调用, 并断言异常
|
|||
assertServiceException(() -> configurationService.updateConfiguration(reqVO), CONFIGURATION_NOT_EXISTS); |
|||
} |
|||
|
|||
@Test |
|||
public void testDeleteConfiguration_success() { |
|||
// mock 数据
|
|||
ConfigurationDO dbConfiguration = randomPojo(ConfigurationDO.class); |
|||
configurationMapper.insert(dbConfiguration);// @Sql: 先插入出一条存在的数据
|
|||
// 准备参数
|
|||
Long id = dbConfiguration.getId(); |
|||
|
|||
// 调用
|
|||
configurationService.deleteConfiguration(id); |
|||
// 校验数据不存在了
|
|||
assertNull(configurationMapper.selectById(id)); |
|||
} |
|||
|
|||
@Test |
|||
public void testDeleteConfiguration_notExists() { |
|||
// 准备参数
|
|||
Long id = randomLongId(); |
|||
|
|||
// 调用, 并断言异常
|
|||
assertServiceException(() -> configurationService.deleteConfiguration(id), CONFIGURATION_NOT_EXISTS); |
|||
} |
|||
|
|||
@Test |
|||
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
|
|||
public void testGetConfigurationPage() { |
|||
// mock 数据
|
|||
ConfigurationDO dbConfiguration = randomPojo(ConfigurationDO.class, o -> { // 等会查询到
|
|||
o.setStrategyCode(null); |
|||
o.setRuleCode(null); |
|||
o.setConfigurationCode(null); |
|||
o.setConfigurationValue(null); |
|||
o.setDescription(null); |
|||
o.setGroupCode(null); |
|||
}); |
|||
configurationMapper.insert(dbConfiguration); |
|||
// 测试 strategyCode 不匹配
|
|||
configurationMapper.insert(cloneIgnoreId(dbConfiguration, o -> o.setStrategyCode(null))); |
|||
// 测试 ruleCode 不匹配
|
|||
configurationMapper.insert(cloneIgnoreId(dbConfiguration, o -> o.setRuleCode(null))); |
|||
// 测试 configurationCode 不匹配
|
|||
configurationMapper.insert(cloneIgnoreId(dbConfiguration, o -> o.setConfigurationCode(null))); |
|||
// 测试 configurationValue 不匹配
|
|||
configurationMapper.insert(cloneIgnoreId(dbConfiguration, o -> o.setConfigurationValue(null))); |
|||
// 测试 description 不匹配
|
|||
configurationMapper.insert(cloneIgnoreId(dbConfiguration, o -> o.setDescription(null))); |
|||
// 测试 groupCode 不匹配
|
|||
configurationMapper.insert(cloneIgnoreId(dbConfiguration, o -> o.setGroupCode(null))); |
|||
// 准备参数
|
|||
ConfigurationPageReqVO reqVO = new ConfigurationPageReqVO(); |
|||
reqVO.setStrategyCode(null); |
|||
reqVO.setRuleCode(null); |
|||
reqVO.setConfigurationCode(null); |
|||
reqVO.setConfigurationValue(null); |
|||
reqVO.setDescription(null); |
|||
reqVO.setGroupCode(null); |
|||
|
|||
// 调用
|
|||
PageResult<ConfigurationDO> pageResult = configurationService.getConfigurationPage(reqVO); |
|||
// 断言
|
|||
assertEquals(1, pageResult.getTotal()); |
|||
assertEquals(1, pageResult.getList().size()); |
|||
assertPojoEquals(dbConfiguration, pageResult.getList().get(0)); |
|||
} |
|||
|
|||
@Test |
|||
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
|
|||
public void testGetConfigurationList() { |
|||
// mock 数据
|
|||
ConfigurationDO dbConfiguration = randomPojo(ConfigurationDO.class, o -> { // 等会查询到
|
|||
o.setStrategyCode(null); |
|||
o.setRuleCode(null); |
|||
o.setConfigurationCode(null); |
|||
o.setConfigurationValue(null); |
|||
o.setDescription(null); |
|||
o.setGroupCode(null); |
|||
}); |
|||
configurationMapper.insert(dbConfiguration); |
|||
// 测试 strategyCode 不匹配
|
|||
configurationMapper.insert(cloneIgnoreId(dbConfiguration, o -> o.setStrategyCode(null))); |
|||
// 测试 ruleCode 不匹配
|
|||
configurationMapper.insert(cloneIgnoreId(dbConfiguration, o -> o.setRuleCode(null))); |
|||
// 测试 configurationCode 不匹配
|
|||
configurationMapper.insert(cloneIgnoreId(dbConfiguration, o -> o.setConfigurationCode(null))); |
|||
// 测试 configurationValue 不匹配
|
|||
configurationMapper.insert(cloneIgnoreId(dbConfiguration, o -> o.setConfigurationValue(null))); |
|||
// 测试 description 不匹配
|
|||
configurationMapper.insert(cloneIgnoreId(dbConfiguration, o -> o.setDescription(null))); |
|||
// 测试 groupCode 不匹配
|
|||
configurationMapper.insert(cloneIgnoreId(dbConfiguration, o -> o.setGroupCode(null))); |
|||
// 准备参数
|
|||
ConfigurationExportReqVO reqVO = new ConfigurationExportReqVO(); |
|||
reqVO.setStrategyCode(null); |
|||
reqVO.setRuleCode(null); |
|||
reqVO.setConfigurationCode(null); |
|||
reqVO.setConfigurationValue(null); |
|||
reqVO.setDescription(null); |
|||
reqVO.setGroupCode(null); |
|||
|
|||
// 调用
|
|||
List<ConfigurationDO> list = configurationService.getConfigurationList(reqVO); |
|||
// 断言
|
|||
assertEquals(1, list.size()); |
|||
assertPojoEquals(dbConfiguration, list.get(0)); |
|||
} |
|||
|
|||
} |
@ -1,203 +0,0 @@ |
|||
package com.win.module.wms.service.configurationsetting; |
|||
|
|||
import com.win.module.wms.controller.configurationsetting.vo.ConfigurationsettingCreateReqVO; |
|||
import com.win.module.wms.controller.configurationsetting.vo.ConfigurationsettingExportReqVO; |
|||
import com.win.module.wms.controller.configurationsetting.vo.ConfigurationsettingPageReqVO; |
|||
import com.win.module.wms.controller.configurationsetting.vo.ConfigurationsettingUpdateReqVO; |
|||
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.configurationsetting.ConfigurationsettingDO; |
|||
import com.win.module.wms.dal.mysql.configurationsetting.ConfigurationsettingMapper; |
|||
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 ConfigurationsettingServiceImpl} 的单元测试类 |
|||
* |
|||
* @author 超级管理员 |
|||
*/ |
|||
@Import(ConfigurationsettingServiceImpl.class) |
|||
public class ConfigurationsettingServiceImplTest extends BaseDbUnitTest { |
|||
|
|||
@Resource |
|||
private ConfigurationsettingServiceImpl configurationsettingService; |
|||
|
|||
@Resource |
|||
private ConfigurationsettingMapper configurationsettingMapper; |
|||
|
|||
@Test |
|||
public void testCreateConfigurationsetting_success() { |
|||
// 准备参数
|
|||
ConfigurationsettingCreateReqVO reqVO = randomPojo(ConfigurationsettingCreateReqVO.class); |
|||
|
|||
// 调用
|
|||
Long configurationsettingId = configurationsettingService.createConfigurationsetting(reqVO); |
|||
// 断言
|
|||
assertNotNull(configurationsettingId); |
|||
// 校验记录的属性是否正确
|
|||
ConfigurationsettingDO configurationsetting = configurationsettingMapper.selectById(configurationsettingId); |
|||
assertPojoEquals(reqVO, configurationsetting); |
|||
} |
|||
|
|||
@Test |
|||
public void testUpdateConfigurationsetting_success() { |
|||
// mock 数据
|
|||
ConfigurationsettingDO dbConfigurationsetting = randomPojo(ConfigurationsettingDO.class); |
|||
configurationsettingMapper.insert(dbConfigurationsetting);// @Sql: 先插入出一条存在的数据
|
|||
// 准备参数
|
|||
ConfigurationsettingUpdateReqVO reqVO = randomPojo(ConfigurationsettingUpdateReqVO.class, o -> { |
|||
o.setId(dbConfigurationsetting.getId()); // 设置更新的 ID
|
|||
}); |
|||
|
|||
// 调用
|
|||
configurationsettingService.updateConfigurationsetting(reqVO); |
|||
// 校验是否更新正确
|
|||
ConfigurationsettingDO configurationsetting = configurationsettingMapper.selectById(reqVO.getId()); // 获取最新的
|
|||
assertPojoEquals(reqVO, configurationsetting); |
|||
} |
|||
|
|||
@Test |
|||
public void testUpdateConfigurationsetting_notExists() { |
|||
// 准备参数
|
|||
ConfigurationsettingUpdateReqVO reqVO = randomPojo(ConfigurationsettingUpdateReqVO.class); |
|||
|
|||
// 调用, 并断言异常
|
|||
assertServiceException(() -> configurationsettingService.updateConfigurationsetting(reqVO), CONFIGURATIONSETTING_NOT_EXISTS); |
|||
} |
|||
|
|||
@Test |
|||
public void testDeleteConfigurationsetting_success() { |
|||
// mock 数据
|
|||
ConfigurationsettingDO dbConfigurationsetting = randomPojo(ConfigurationsettingDO.class); |
|||
configurationsettingMapper.insert(dbConfigurationsetting);// @Sql: 先插入出一条存在的数据
|
|||
// 准备参数
|
|||
Long id = dbConfigurationsetting.getId(); |
|||
|
|||
// 调用
|
|||
configurationsettingService.deleteConfigurationsetting(id); |
|||
// 校验数据不存在了
|
|||
assertNull(configurationsettingMapper.selectById(id)); |
|||
} |
|||
|
|||
@Test |
|||
public void testDeleteConfigurationsetting_notExists() { |
|||
// 准备参数
|
|||
Long id = randomLongId(); |
|||
|
|||
// 调用, 并断言异常
|
|||
assertServiceException(() -> configurationsettingService.deleteConfigurationsetting(id), CONFIGURATIONSETTING_NOT_EXISTS); |
|||
} |
|||
|
|||
@Test |
|||
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
|
|||
public void testGetConfigurationsettingPage() { |
|||
// mock 数据
|
|||
ConfigurationsettingDO dbConfigurationsetting = randomPojo(ConfigurationsettingDO.class, o -> { // 等会查询到
|
|||
o.setStrategyType(null); |
|||
o.setConfigurationCode(null); |
|||
o.setConfigurationName(null); |
|||
o.setDataType(null); |
|||
o.setValueScope(null); |
|||
o.setRelatedTo(null); |
|||
o.setDescription(null); |
|||
o.setIsRequired(null); |
|||
}); |
|||
configurationsettingMapper.insert(dbConfigurationsetting); |
|||
// 测试 strategyType 不匹配
|
|||
configurationsettingMapper.insert(cloneIgnoreId(dbConfigurationsetting, o -> o.setStrategyType(null))); |
|||
// 测试 configurationCode 不匹配
|
|||
configurationsettingMapper.insert(cloneIgnoreId(dbConfigurationsetting, o -> o.setConfigurationCode(null))); |
|||
// 测试 configurationName 不匹配
|
|||
configurationsettingMapper.insert(cloneIgnoreId(dbConfigurationsetting, o -> o.setConfigurationName(null))); |
|||
// 测试 dataType 不匹配
|
|||
configurationsettingMapper.insert(cloneIgnoreId(dbConfigurationsetting, o -> o.setDataType(null))); |
|||
// 测试 valueScope 不匹配
|
|||
configurationsettingMapper.insert(cloneIgnoreId(dbConfigurationsetting, o -> o.setValueScope(null))); |
|||
// 测试 relatedTo 不匹配
|
|||
configurationsettingMapper.insert(cloneIgnoreId(dbConfigurationsetting, o -> o.setRelatedTo(null))); |
|||
// 测试 description 不匹配
|
|||
configurationsettingMapper.insert(cloneIgnoreId(dbConfigurationsetting, o -> o.setDescription(null))); |
|||
// 测试 isRequired 不匹配
|
|||
configurationsettingMapper.insert(cloneIgnoreId(dbConfigurationsetting, o -> o.setIsRequired(null))); |
|||
// 准备参数
|
|||
ConfigurationsettingPageReqVO reqVO = new ConfigurationsettingPageReqVO(); |
|||
reqVO.setStrategyType(null); |
|||
reqVO.setConfigurationCode(null); |
|||
reqVO.setConfigurationName(null); |
|||
reqVO.setDataType(null); |
|||
reqVO.setValueScope(null); |
|||
reqVO.setRelatedTo(null); |
|||
reqVO.setDescription(null); |
|||
reqVO.setIsRequired(null); |
|||
|
|||
// 调用
|
|||
PageResult<ConfigurationsettingDO> pageResult = configurationsettingService.getConfigurationsettingPage(reqVO); |
|||
// 断言
|
|||
assertEquals(1, pageResult.getTotal()); |
|||
assertEquals(1, pageResult.getList().size()); |
|||
assertPojoEquals(dbConfigurationsetting, pageResult.getList().get(0)); |
|||
} |
|||
|
|||
@Test |
|||
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
|
|||
public void testGetConfigurationsettingList() { |
|||
// mock 数据
|
|||
ConfigurationsettingDO dbConfigurationsetting = randomPojo(ConfigurationsettingDO.class, o -> { // 等会查询到
|
|||
o.setStrategyType(null); |
|||
o.setConfigurationCode(null); |
|||
o.setConfigurationName(null); |
|||
o.setDataType(null); |
|||
o.setValueScope(null); |
|||
o.setRelatedTo(null); |
|||
o.setDescription(null); |
|||
o.setIsRequired(null); |
|||
}); |
|||
configurationsettingMapper.insert(dbConfigurationsetting); |
|||
// 测试 strategyType 不匹配
|
|||
configurationsettingMapper.insert(cloneIgnoreId(dbConfigurationsetting, o -> o.setStrategyType(null))); |
|||
// 测试 configurationCode 不匹配
|
|||
configurationsettingMapper.insert(cloneIgnoreId(dbConfigurationsetting, o -> o.setConfigurationCode(null))); |
|||
// 测试 configurationName 不匹配
|
|||
configurationsettingMapper.insert(cloneIgnoreId(dbConfigurationsetting, o -> o.setConfigurationName(null))); |
|||
// 测试 dataType 不匹配
|
|||
configurationsettingMapper.insert(cloneIgnoreId(dbConfigurationsetting, o -> o.setDataType(null))); |
|||
// 测试 valueScope 不匹配
|
|||
configurationsettingMapper.insert(cloneIgnoreId(dbConfigurationsetting, o -> o.setValueScope(null))); |
|||
// 测试 relatedTo 不匹配
|
|||
configurationsettingMapper.insert(cloneIgnoreId(dbConfigurationsetting, o -> o.setRelatedTo(null))); |
|||
// 测试 description 不匹配
|
|||
configurationsettingMapper.insert(cloneIgnoreId(dbConfigurationsetting, o -> o.setDescription(null))); |
|||
// 测试 isRequired 不匹配
|
|||
configurationsettingMapper.insert(cloneIgnoreId(dbConfigurationsetting, o -> o.setIsRequired(null))); |
|||
// 准备参数
|
|||
ConfigurationsettingExportReqVO reqVO = new ConfigurationsettingExportReqVO(); |
|||
reqVO.setStrategyType(null); |
|||
reqVO.setConfigurationCode(null); |
|||
reqVO.setConfigurationName(null); |
|||
reqVO.setDataType(null); |
|||
reqVO.setValueScope(null); |
|||
reqVO.setRelatedTo(null); |
|||
reqVO.setDescription(null); |
|||
reqVO.setIsRequired(null); |
|||
|
|||
// 调用
|
|||
List<ConfigurationsettingDO> list = configurationsettingService.getConfigurationsettingList(reqVO); |
|||
// 断言
|
|||
assertEquals(1, list.size()); |
|||
assertPojoEquals(dbConfigurationsetting, list.get(0)); |
|||
} |
|||
|
|||
} |
@ -1,276 +0,0 @@ |
|||
package com.win.module.wms.service.documentsetting; |
|||
|
|||
import com.win.module.wms.controller.documentsetting.vo.DocumentsettingCreateReqVO; |
|||
import com.win.module.wms.controller.documentsetting.vo.DocumentsettingExportReqVO; |
|||
import com.win.module.wms.controller.documentsetting.vo.DocumentsettingPageReqVO; |
|||
import com.win.module.wms.controller.documentsetting.vo.DocumentsettingUpdateReqVO; |
|||
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.documentsetting.DocumentsettingDO; |
|||
import com.win.module.wms.dal.mysql.documentsetting.DocumentsettingMapper; |
|||
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.date.LocalDateTimeUtils.*; |
|||
import static com.win.framework.common.util.object.ObjectUtils.*; |
|||
import static org.junit.jupiter.api.Assertions.*; |
|||
|
|||
/** |
|||
* {@link DocumentsettingServiceImpl} 的单元测试类 |
|||
* |
|||
* @author 超级管理员 |
|||
*/ |
|||
@Import(DocumentsettingServiceImpl.class) |
|||
public class DocumentsettingServiceImplTest extends BaseDbUnitTest { |
|||
|
|||
@Resource |
|||
private DocumentsettingServiceImpl documentsettingService; |
|||
|
|||
@Resource |
|||
private DocumentsettingMapper documentsettingMapper; |
|||
|
|||
@Test |
|||
public void testCreateDocumentsetting_success() { |
|||
// 准备参数
|
|||
DocumentsettingCreateReqVO reqVO = randomPojo(DocumentsettingCreateReqVO.class); |
|||
|
|||
// 调用
|
|||
Long documentsettingId = documentsettingService.createDocumentsetting(reqVO); |
|||
// 断言
|
|||
assertNotNull(documentsettingId); |
|||
// 校验记录的属性是否正确
|
|||
DocumentsettingDO documentsetting = documentsettingMapper.selectById(documentsettingId); |
|||
assertPojoEquals(reqVO, documentsetting); |
|||
} |
|||
|
|||
@Test |
|||
public void testUpdateDocumentsetting_success() { |
|||
// mock 数据
|
|||
DocumentsettingDO dbDocumentsetting = randomPojo(DocumentsettingDO.class); |
|||
documentsettingMapper.insert(dbDocumentsetting);// @Sql: 先插入出一条存在的数据
|
|||
// 准备参数
|
|||
DocumentsettingUpdateReqVO reqVO = randomPojo(DocumentsettingUpdateReqVO.class, o -> { |
|||
o.setId(dbDocumentsetting.getId()); // 设置更新的 ID
|
|||
}); |
|||
|
|||
// 调用
|
|||
documentsettingService.updateDocumentsetting(reqVO); |
|||
// 校验是否更新正确
|
|||
DocumentsettingDO documentsetting = documentsettingMapper.selectById(reqVO.getId()); // 获取最新的
|
|||
assertPojoEquals(reqVO, documentsetting); |
|||
} |
|||
|
|||
@Test |
|||
public void testUpdateDocumentsetting_notExists() { |
|||
// 准备参数
|
|||
DocumentsettingUpdateReqVO reqVO = randomPojo(DocumentsettingUpdateReqVO.class); |
|||
|
|||
// 调用, 并断言异常
|
|||
assertServiceException(() -> documentsettingService.updateDocumentsetting(reqVO), DOCUMENTSETTING_NOT_EXISTS); |
|||
} |
|||
|
|||
@Test |
|||
public void testDeleteDocumentsetting_success() { |
|||
// mock 数据
|
|||
DocumentsettingDO dbDocumentsetting = randomPojo(DocumentsettingDO.class); |
|||
documentsettingMapper.insert(dbDocumentsetting);// @Sql: 先插入出一条存在的数据
|
|||
// 准备参数
|
|||
Long id = dbDocumentsetting.getId(); |
|||
|
|||
// 调用
|
|||
documentsettingService.deleteDocumentsetting(id); |
|||
// 校验数据不存在了
|
|||
assertNull(documentsettingMapper.selectById(id)); |
|||
} |
|||
|
|||
@Test |
|||
public void testDeleteDocumentsetting_notExists() { |
|||
// 准备参数
|
|||
Long id = randomLongId(); |
|||
|
|||
// 调用, 并断言异常
|
|||
assertServiceException(() -> documentsettingService.deleteDocumentsetting(id), DOCUMENTSETTING_NOT_EXISTS); |
|||
} |
|||
|
|||
@Test |
|||
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
|
|||
public void testGetDocumentsettingPage() { |
|||
// mock 数据
|
|||
DocumentsettingDO dbDocumentsetting = randomPojo(DocumentsettingDO.class, o -> { // 等会查询到
|
|||
o.setCode(null); |
|||
o.setName(null); |
|||
o.setDescription(null); |
|||
o.setType(null); |
|||
o.setBusinessType(null); |
|||
o.setNumberPrefix(null); |
|||
o.setDateFormat(null); |
|||
o.setSerialLength(null); |
|||
o.setSeparatorStr(null); |
|||
o.setResetPeriod(null); |
|||
o.setActiveTime(null); |
|||
o.setExpireTime(null); |
|||
o.setRemark(null); |
|||
o.setCreateTime(null); |
|||
o.setCreator(null); |
|||
o.setAvailable(null); |
|||
o.setIsSoftDeleted(null); |
|||
}); |
|||
documentsettingMapper.insert(dbDocumentsetting); |
|||
// 测试 code 不匹配
|
|||
documentsettingMapper.insert(cloneIgnoreId(dbDocumentsetting, o -> o.setCode(null))); |
|||
// 测试 name 不匹配
|
|||
documentsettingMapper.insert(cloneIgnoreId(dbDocumentsetting, o -> o.setName(null))); |
|||
// 测试 description 不匹配
|
|||
documentsettingMapper.insert(cloneIgnoreId(dbDocumentsetting, o -> o.setDescription(null))); |
|||
// 测试 type 不匹配
|
|||
documentsettingMapper.insert(cloneIgnoreId(dbDocumentsetting, o -> o.setType(null))); |
|||
// 测试 businessType 不匹配
|
|||
documentsettingMapper.insert(cloneIgnoreId(dbDocumentsetting, o -> o.setBusinessType(null))); |
|||
// 测试 numberPrefix 不匹配
|
|||
documentsettingMapper.insert(cloneIgnoreId(dbDocumentsetting, o -> o.setNumberPrefix(null))); |
|||
// 测试 dateFormat 不匹配
|
|||
documentsettingMapper.insert(cloneIgnoreId(dbDocumentsetting, o -> o.setDateFormat(null))); |
|||
// 测试 serialLength 不匹配
|
|||
documentsettingMapper.insert(cloneIgnoreId(dbDocumentsetting, o -> o.setSerialLength(null))); |
|||
// 测试 separatorStr 不匹配
|
|||
documentsettingMapper.insert(cloneIgnoreId(dbDocumentsetting, o -> o.setSeparatorStr(null))); |
|||
// 测试 resetPeriod 不匹配
|
|||
documentsettingMapper.insert(cloneIgnoreId(dbDocumentsetting, o -> o.setResetPeriod(null))); |
|||
// 测试 activeTime 不匹配
|
|||
documentsettingMapper.insert(cloneIgnoreId(dbDocumentsetting, o -> o.setActiveTime(null))); |
|||
// 测试 expireTime 不匹配
|
|||
documentsettingMapper.insert(cloneIgnoreId(dbDocumentsetting, o -> o.setExpireTime(null))); |
|||
// 测试 remark 不匹配
|
|||
documentsettingMapper.insert(cloneIgnoreId(dbDocumentsetting, o -> o.setRemark(null))); |
|||
// 测试 createTime 不匹配
|
|||
documentsettingMapper.insert(cloneIgnoreId(dbDocumentsetting, o -> o.setCreateTime(null))); |
|||
// 测试 creator 不匹配
|
|||
documentsettingMapper.insert(cloneIgnoreId(dbDocumentsetting, o -> o.setCreator(null))); |
|||
// 测试 available 不匹配
|
|||
documentsettingMapper.insert(cloneIgnoreId(dbDocumentsetting, o -> o.setAvailable(null))); |
|||
// 测试 isSoftDeleted 不匹配
|
|||
documentsettingMapper.insert(cloneIgnoreId(dbDocumentsetting, o -> o.setIsSoftDeleted(null))); |
|||
// 准备参数
|
|||
DocumentsettingPageReqVO reqVO = new DocumentsettingPageReqVO(); |
|||
reqVO.setCode(null); |
|||
reqVO.setName(null); |
|||
reqVO.setDescription(null); |
|||
reqVO.setType(null); |
|||
reqVO.setBusinessType(null); |
|||
reqVO.setNumberPrefix(null); |
|||
reqVO.setDateFormat(null); |
|||
reqVO.setSerialLength(null); |
|||
reqVO.setSeparatorStr(null); |
|||
reqVO.setResetPeriod(null); |
|||
reqVO.setActiveTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); |
|||
reqVO.setExpireTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); |
|||
reqVO.setRemark(null); |
|||
reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); |
|||
reqVO.setCreator(null); |
|||
reqVO.setAvailable(null); |
|||
reqVO.setIsSoftDeleted(null); |
|||
|
|||
// 调用
|
|||
PageResult<DocumentsettingDO> pageResult = documentsettingService.getDocumentsettingPage(reqVO); |
|||
// 断言
|
|||
assertEquals(1, pageResult.getTotal()); |
|||
assertEquals(1, pageResult.getList().size()); |
|||
assertPojoEquals(dbDocumentsetting, pageResult.getList().get(0)); |
|||
} |
|||
|
|||
@Test |
|||
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
|
|||
public void testGetDocumentsettingList() { |
|||
// mock 数据
|
|||
DocumentsettingDO dbDocumentsetting = randomPojo(DocumentsettingDO.class, o -> { // 等会查询到
|
|||
o.setCode(null); |
|||
o.setName(null); |
|||
o.setDescription(null); |
|||
o.setType(null); |
|||
o.setBusinessType(null); |
|||
o.setNumberPrefix(null); |
|||
o.setDateFormat(null); |
|||
o.setSerialLength(null); |
|||
o.setSeparatorStr(null); |
|||
o.setResetPeriod(null); |
|||
o.setActiveTime(null); |
|||
o.setExpireTime(null); |
|||
o.setRemark(null); |
|||
o.setCreateTime(null); |
|||
o.setCreator(null); |
|||
o.setAvailable(null); |
|||
o.setIsSoftDeleted(null); |
|||
}); |
|||
documentsettingMapper.insert(dbDocumentsetting); |
|||
// 测试 code 不匹配
|
|||
documentsettingMapper.insert(cloneIgnoreId(dbDocumentsetting, o -> o.setCode(null))); |
|||
// 测试 name 不匹配
|
|||
documentsettingMapper.insert(cloneIgnoreId(dbDocumentsetting, o -> o.setName(null))); |
|||
// 测试 description 不匹配
|
|||
documentsettingMapper.insert(cloneIgnoreId(dbDocumentsetting, o -> o.setDescription(null))); |
|||
// 测试 type 不匹配
|
|||
documentsettingMapper.insert(cloneIgnoreId(dbDocumentsetting, o -> o.setType(null))); |
|||
// 测试 businessType 不匹配
|
|||
documentsettingMapper.insert(cloneIgnoreId(dbDocumentsetting, o -> o.setBusinessType(null))); |
|||
// 测试 numberPrefix 不匹配
|
|||
documentsettingMapper.insert(cloneIgnoreId(dbDocumentsetting, o -> o.setNumberPrefix(null))); |
|||
// 测试 dateFormat 不匹配
|
|||
documentsettingMapper.insert(cloneIgnoreId(dbDocumentsetting, o -> o.setDateFormat(null))); |
|||
// 测试 serialLength 不匹配
|
|||
documentsettingMapper.insert(cloneIgnoreId(dbDocumentsetting, o -> o.setSerialLength(null))); |
|||
// 测试 separatorStr 不匹配
|
|||
documentsettingMapper.insert(cloneIgnoreId(dbDocumentsetting, o -> o.setSeparatorStr(null))); |
|||
// 测试 resetPeriod 不匹配
|
|||
documentsettingMapper.insert(cloneIgnoreId(dbDocumentsetting, o -> o.setResetPeriod(null))); |
|||
// 测试 activeTime 不匹配
|
|||
documentsettingMapper.insert(cloneIgnoreId(dbDocumentsetting, o -> o.setActiveTime(null))); |
|||
// 测试 expireTime 不匹配
|
|||
documentsettingMapper.insert(cloneIgnoreId(dbDocumentsetting, o -> o.setExpireTime(null))); |
|||
// 测试 remark 不匹配
|
|||
documentsettingMapper.insert(cloneIgnoreId(dbDocumentsetting, o -> o.setRemark(null))); |
|||
// 测试 createTime 不匹配
|
|||
documentsettingMapper.insert(cloneIgnoreId(dbDocumentsetting, o -> o.setCreateTime(null))); |
|||
// 测试 creator 不匹配
|
|||
documentsettingMapper.insert(cloneIgnoreId(dbDocumentsetting, o -> o.setCreator(null))); |
|||
// 测试 available 不匹配
|
|||
documentsettingMapper.insert(cloneIgnoreId(dbDocumentsetting, o -> o.setAvailable(null))); |
|||
// 测试 isSoftDeleted 不匹配
|
|||
documentsettingMapper.insert(cloneIgnoreId(dbDocumentsetting, o -> o.setIsSoftDeleted(null))); |
|||
// 准备参数
|
|||
DocumentsettingExportReqVO reqVO = new DocumentsettingExportReqVO(); |
|||
reqVO.setCode(null); |
|||
reqVO.setName(null); |
|||
reqVO.setDescription(null); |
|||
reqVO.setType(null); |
|||
reqVO.setBusinessType(null); |
|||
reqVO.setNumberPrefix(null); |
|||
reqVO.setDateFormat(null); |
|||
reqVO.setSerialLength(null); |
|||
reqVO.setSeparatorStr(null); |
|||
reqVO.setResetPeriod(null); |
|||
reqVO.setActiveTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); |
|||
reqVO.setExpireTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); |
|||
reqVO.setRemark(null); |
|||
reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); |
|||
reqVO.setCreator(null); |
|||
reqVO.setAvailable(null); |
|||
reqVO.setIsSoftDeleted(null); |
|||
|
|||
// 调用
|
|||
List<DocumentsettingDO> list = documentsettingService.getDocumentsettingList(reqVO); |
|||
// 断言
|
|||
assertEquals(1, list.size()); |
|||
assertPojoEquals(dbDocumentsetting, list.get(0)); |
|||
} |
|||
|
|||
} |
@ -1,292 +0,0 @@ |
|||
package com.win.module.wms.service.jobsetting; |
|||
|
|||
import com.win.module.wms.controller.jobsetting.vo.JobsettingCreateReqVO; |
|||
import com.win.module.wms.controller.jobsetting.vo.JobsettingExportReqVO; |
|||
import com.win.module.wms.controller.jobsetting.vo.JobsettingPageReqVO; |
|||
import com.win.module.wms.controller.jobsetting.vo.JobsettingUpdateReqVO; |
|||
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.jobsetting.JobsettingDO; |
|||
import com.win.module.wms.dal.mysql.jobsetting.JobsettingMapper; |
|||
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.date.LocalDateTimeUtils.*; |
|||
import static com.win.framework.common.util.object.ObjectUtils.*; |
|||
import static org.junit.jupiter.api.Assertions.*; |
|||
|
|||
/** |
|||
* {@link JobsettingServiceImpl} 的单元测试类 |
|||
* |
|||
* @author 超级管理员 |
|||
*/ |
|||
@Import(JobsettingServiceImpl.class) |
|||
public class JobsettingServiceImplTest extends BaseDbUnitTest { |
|||
|
|||
@Resource |
|||
private JobsettingServiceImpl jobsettingService; |
|||
|
|||
@Resource |
|||
private JobsettingMapper jobsettingMapper; |
|||
|
|||
@Test |
|||
public void testCreateJobsetting_success() { |
|||
// 准备参数
|
|||
JobsettingCreateReqVO reqVO = randomPojo(JobsettingCreateReqVO.class); |
|||
|
|||
// 调用
|
|||
Long jobsettingId = jobsettingService.createJobsetting(reqVO); |
|||
// 断言
|
|||
assertNotNull(jobsettingId); |
|||
// 校验记录的属性是否正确
|
|||
JobsettingDO jobsetting = jobsettingMapper.selectById(jobsettingId); |
|||
assertPojoEquals(reqVO, jobsetting); |
|||
} |
|||
|
|||
@Test |
|||
public void testUpdateJobsetting_success() { |
|||
// mock 数据
|
|||
JobsettingDO dbJobsetting = randomPojo(JobsettingDO.class); |
|||
jobsettingMapper.insert(dbJobsetting);// @Sql: 先插入出一条存在的数据
|
|||
// 准备参数
|
|||
JobsettingUpdateReqVO reqVO = randomPojo(JobsettingUpdateReqVO.class, o -> { |
|||
o.setId(dbJobsetting.getId()); // 设置更新的 ID
|
|||
}); |
|||
|
|||
// 调用
|
|||
jobsettingService.updateJobsetting(reqVO); |
|||
// 校验是否更新正确
|
|||
JobsettingDO jobsetting = jobsettingMapper.selectById(reqVO.getId()); // 获取最新的
|
|||
assertPojoEquals(reqVO, jobsetting); |
|||
} |
|||
|
|||
@Test |
|||
public void testUpdateJobsetting_notExists() { |
|||
// 准备参数
|
|||
JobsettingUpdateReqVO reqVO = randomPojo(JobsettingUpdateReqVO.class); |
|||
|
|||
// 调用, 并断言异常
|
|||
assertServiceException(() -> jobsettingService.updateJobsetting(reqVO), JOBSETTING_NOT_EXISTS); |
|||
} |
|||
|
|||
@Test |
|||
public void testDeleteJobsetting_success() { |
|||
// mock 数据
|
|||
JobsettingDO dbJobsetting = randomPojo(JobsettingDO.class); |
|||
jobsettingMapper.insert(dbJobsetting);// @Sql: 先插入出一条存在的数据
|
|||
// 准备参数
|
|||
Long id = dbJobsetting.getId(); |
|||
|
|||
// 调用
|
|||
jobsettingService.deleteJobsetting(id); |
|||
// 校验数据不存在了
|
|||
assertNull(jobsettingMapper.selectById(id)); |
|||
} |
|||
|
|||
@Test |
|||
public void testDeleteJobsetting_notExists() { |
|||
// 准备参数
|
|||
Long id = randomLongId(); |
|||
|
|||
// 调用, 并断言异常
|
|||
assertServiceException(() -> jobsettingService.deleteJobsetting(id), JOBSETTING_NOT_EXISTS); |
|||
} |
|||
|
|||
@Test |
|||
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
|
|||
public void testGetJobsettingPage() { |
|||
// mock 数据
|
|||
JobsettingDO dbJobsetting = randomPojo(JobsettingDO.class, o -> { // 等会查询到
|
|||
o.setCode(null); |
|||
o.setValidMinutes(null); |
|||
o.setActiveTime(null); |
|||
o.setExpire-time(null); |
|||
o.setRemark(null); |
|||
o.setCreateTime(null); |
|||
o.setCreator(null); |
|||
o.setAutoComplete(null); |
|||
o.setAllowModifyLocation(null); |
|||
o.setAllowModifyQty(null); |
|||
o.setAllowBiggerQty(null); |
|||
o.setAllowSmallerQty(null); |
|||
o.setAllowModifyInventoryStatus(null); |
|||
o.setAllowContinuousScanning(null); |
|||
o.setAllowPartialComplete(null); |
|||
o.setAllowModifyBach(null); |
|||
o.setAllowModifyPackingNumber(null); |
|||
o.setAvailable(null); |
|||
o.setIsSoftDeleted(null); |
|||
}); |
|||
jobsettingMapper.insert(dbJobsetting); |
|||
// 测试 code 不匹配
|
|||
jobsettingMapper.insert(cloneIgnoreId(dbJobsetting, o -> o.setCode(null))); |
|||
// 测试 validMinutes 不匹配
|
|||
jobsettingMapper.insert(cloneIgnoreId(dbJobsetting, o -> o.setValidMinutes(null))); |
|||
// 测试 activeTime 不匹配
|
|||
jobsettingMapper.insert(cloneIgnoreId(dbJobsetting, o -> o.setActiveTime(null))); |
|||
// 测试 expire-time 不匹配
|
|||
jobsettingMapper.insert(cloneIgnoreId(dbJobsetting, o -> o.setExpire-time(null))); |
|||
// 测试 remark 不匹配
|
|||
jobsettingMapper.insert(cloneIgnoreId(dbJobsetting, o -> o.setRemark(null))); |
|||
// 测试 createTime 不匹配
|
|||
jobsettingMapper.insert(cloneIgnoreId(dbJobsetting, o -> o.setCreateTime(null))); |
|||
// 测试 creator 不匹配
|
|||
jobsettingMapper.insert(cloneIgnoreId(dbJobsetting, o -> o.setCreator(null))); |
|||
// 测试 autoComplete 不匹配
|
|||
jobsettingMapper.insert(cloneIgnoreId(dbJobsetting, o -> o.setAutoComplete(null))); |
|||
// 测试 allowModifyLocation 不匹配
|
|||
jobsettingMapper.insert(cloneIgnoreId(dbJobsetting, o -> o.setAllowModifyLocation(null))); |
|||
// 测试 allowModifyQty 不匹配
|
|||
jobsettingMapper.insert(cloneIgnoreId(dbJobsetting, o -> o.setAllowModifyQty(null))); |
|||
// 测试 allowBiggerQty 不匹配
|
|||
jobsettingMapper.insert(cloneIgnoreId(dbJobsetting, o -> o.setAllowBiggerQty(null))); |
|||
// 测试 allowSmallerQty 不匹配
|
|||
jobsettingMapper.insert(cloneIgnoreId(dbJobsetting, o -> o.setAllowSmallerQty(null))); |
|||
// 测试 allowModifyInventoryStatus 不匹配
|
|||
jobsettingMapper.insert(cloneIgnoreId(dbJobsetting, o -> o.setAllowModifyInventoryStatus(null))); |
|||
// 测试 allowContinuousScanning 不匹配
|
|||
jobsettingMapper.insert(cloneIgnoreId(dbJobsetting, o -> o.setAllowContinuousScanning(null))); |
|||
// 测试 allowPartialComplete 不匹配
|
|||
jobsettingMapper.insert(cloneIgnoreId(dbJobsetting, o -> o.setAllowPartialComplete(null))); |
|||
// 测试 allowModifyBach 不匹配
|
|||
jobsettingMapper.insert(cloneIgnoreId(dbJobsetting, o -> o.setAllowModifyBach(null))); |
|||
// 测试 allowModifyPackingNumber 不匹配
|
|||
jobsettingMapper.insert(cloneIgnoreId(dbJobsetting, o -> o.setAllowModifyPackingNumber(null))); |
|||
// 测试 available 不匹配
|
|||
jobsettingMapper.insert(cloneIgnoreId(dbJobsetting, o -> o.setAvailable(null))); |
|||
// 测试 isSoftDeleted 不匹配
|
|||
jobsettingMapper.insert(cloneIgnoreId(dbJobsetting, o -> o.setIsSoftDeleted(null))); |
|||
// 准备参数
|
|||
JobsettingPageReqVO reqVO = new JobsettingPageReqVO(); |
|||
reqVO.setCode(null); |
|||
reqVO.setValidMinutes(null); |
|||
reqVO.setActiveTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); |
|||
reqVO.setExpire-time(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); |
|||
reqVO.setRemark(null); |
|||
reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); |
|||
reqVO.setCreator(null); |
|||
reqVO.setAutoComplete(null); |
|||
reqVO.setAllowModifyLocation(null); |
|||
reqVO.setAllowModifyQty(null); |
|||
reqVO.setAllowBiggerQty(null); |
|||
reqVO.setAllowSmallerQty(null); |
|||
reqVO.setAllowModifyInventoryStatus(null); |
|||
reqVO.setAllowContinuousScanning(null); |
|||
reqVO.setAllowPartialComplete(null); |
|||
reqVO.setAllowModifyBach(null); |
|||
reqVO.setAllowModifyPackingNumber(null); |
|||
reqVO.setAvailable(null); |
|||
reqVO.setIsSoftDeleted(null); |
|||
|
|||
// 调用
|
|||
PageResult<JobsettingDO> pageResult = jobsettingService.getJobsettingPage(reqVO); |
|||
// 断言
|
|||
assertEquals(1, pageResult.getTotal()); |
|||
assertEquals(1, pageResult.getList().size()); |
|||
assertPojoEquals(dbJobsetting, pageResult.getList().get(0)); |
|||
} |
|||
|
|||
@Test |
|||
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
|
|||
public void testGetJobsettingList() { |
|||
// mock 数据
|
|||
JobsettingDO dbJobsetting = randomPojo(JobsettingDO.class, o -> { // 等会查询到
|
|||
o.setCode(null); |
|||
o.setValidMinutes(null); |
|||
o.setActiveTime(null); |
|||
o.setExpire-time(null); |
|||
o.setRemark(null); |
|||
o.setCreateTime(null); |
|||
o.setCreator(null); |
|||
o.setAutoComplete(null); |
|||
o.setAllowModifyLocation(null); |
|||
o.setAllowModifyQty(null); |
|||
o.setAllowBiggerQty(null); |
|||
o.setAllowSmallerQty(null); |
|||
o.setAllowModifyInventoryStatus(null); |
|||
o.setAllowContinuousScanning(null); |
|||
o.setAllowPartialComplete(null); |
|||
o.setAllowModifyBach(null); |
|||
o.setAllowModifyPackingNumber(null); |
|||
o.setAvailable(null); |
|||
o.setIsSoftDeleted(null); |
|||
}); |
|||
jobsettingMapper.insert(dbJobsetting); |
|||
// 测试 code 不匹配
|
|||
jobsettingMapper.insert(cloneIgnoreId(dbJobsetting, o -> o.setCode(null))); |
|||
// 测试 validMinutes 不匹配
|
|||
jobsettingMapper.insert(cloneIgnoreId(dbJobsetting, o -> o.setValidMinutes(null))); |
|||
// 测试 activeTime 不匹配
|
|||
jobsettingMapper.insert(cloneIgnoreId(dbJobsetting, o -> o.setActiveTime(null))); |
|||
// 测试 expire-time 不匹配
|
|||
jobsettingMapper.insert(cloneIgnoreId(dbJobsetting, o -> o.setExpire-time(null))); |
|||
// 测试 remark 不匹配
|
|||
jobsettingMapper.insert(cloneIgnoreId(dbJobsetting, o -> o.setRemark(null))); |
|||
// 测试 createTime 不匹配
|
|||
jobsettingMapper.insert(cloneIgnoreId(dbJobsetting, o -> o.setCreateTime(null))); |
|||
// 测试 creator 不匹配
|
|||
jobsettingMapper.insert(cloneIgnoreId(dbJobsetting, o -> o.setCreator(null))); |
|||
// 测试 autoComplete 不匹配
|
|||
jobsettingMapper.insert(cloneIgnoreId(dbJobsetting, o -> o.setAutoComplete(null))); |
|||
// 测试 allowModifyLocation 不匹配
|
|||
jobsettingMapper.insert(cloneIgnoreId(dbJobsetting, o -> o.setAllowModifyLocation(null))); |
|||
// 测试 allowModifyQty 不匹配
|
|||
jobsettingMapper.insert(cloneIgnoreId(dbJobsetting, o -> o.setAllowModifyQty(null))); |
|||
// 测试 allowBiggerQty 不匹配
|
|||
jobsettingMapper.insert(cloneIgnoreId(dbJobsetting, o -> o.setAllowBiggerQty(null))); |
|||
// 测试 allowSmallerQty 不匹配
|
|||
jobsettingMapper.insert(cloneIgnoreId(dbJobsetting, o -> o.setAllowSmallerQty(null))); |
|||
// 测试 allowModifyInventoryStatus 不匹配
|
|||
jobsettingMapper.insert(cloneIgnoreId(dbJobsetting, o -> o.setAllowModifyInventoryStatus(null))); |
|||
// 测试 allowContinuousScanning 不匹配
|
|||
jobsettingMapper.insert(cloneIgnoreId(dbJobsetting, o -> o.setAllowContinuousScanning(null))); |
|||
// 测试 allowPartialComplete 不匹配
|
|||
jobsettingMapper.insert(cloneIgnoreId(dbJobsetting, o -> o.setAllowPartialComplete(null))); |
|||
// 测试 allowModifyBach 不匹配
|
|||
jobsettingMapper.insert(cloneIgnoreId(dbJobsetting, o -> o.setAllowModifyBach(null))); |
|||
// 测试 allowModifyPackingNumber 不匹配
|
|||
jobsettingMapper.insert(cloneIgnoreId(dbJobsetting, o -> o.setAllowModifyPackingNumber(null))); |
|||
// 测试 available 不匹配
|
|||
jobsettingMapper.insert(cloneIgnoreId(dbJobsetting, o -> o.setAvailable(null))); |
|||
// 测试 isSoftDeleted 不匹配
|
|||
jobsettingMapper.insert(cloneIgnoreId(dbJobsetting, o -> o.setIsSoftDeleted(null))); |
|||
// 准备参数
|
|||
JobsettingExportReqVO reqVO = new JobsettingExportReqVO(); |
|||
reqVO.setCode(null); |
|||
reqVO.setValidMinutes(null); |
|||
reqVO.setActiveTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); |
|||
reqVO.setExpire-time(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); |
|||
reqVO.setRemark(null); |
|||
reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); |
|||
reqVO.setCreator(null); |
|||
reqVO.setAutoComplete(null); |
|||
reqVO.setAllowModifyLocation(null); |
|||
reqVO.setAllowModifyQty(null); |
|||
reqVO.setAllowBiggerQty(null); |
|||
reqVO.setAllowSmallerQty(null); |
|||
reqVO.setAllowModifyInventoryStatus(null); |
|||
reqVO.setAllowContinuousScanning(null); |
|||
reqVO.setAllowPartialComplete(null); |
|||
reqVO.setAllowModifyBach(null); |
|||
reqVO.setAllowModifyPackingNumber(null); |
|||
reqVO.setAvailable(null); |
|||
reqVO.setIsSoftDeleted(null); |
|||
|
|||
// 调用
|
|||
List<JobsettingDO> list = jobsettingService.getJobsettingList(reqVO); |
|||
// 断言
|
|||
assertEquals(1, list.size()); |
|||
assertPojoEquals(dbJobsetting, list.get(0)); |
|||
} |
|||
|
|||
} |
@ -1,300 +0,0 @@ |
|||
package com.win.module.wms.service.owner; |
|||
|
|||
import com.win.module.wms.controller.owner.vo.OwnerCreateReqVO; |
|||
import com.win.module.wms.controller.owner.vo.OwnerExportReqVO; |
|||
import com.win.module.wms.controller.owner.vo.OwnerPageReqVO; |
|||
import com.win.module.wms.controller.owner.vo.OwnerUpdateReqVO; |
|||
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.owner.OwnerDO; |
|||
import com.win.module.wms.dal.mysql.owner.OwnerMapper; |
|||
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.date.LocalDateTimeUtils.*; |
|||
import static com.win.framework.common.util.object.ObjectUtils.*; |
|||
import static org.junit.jupiter.api.Assertions.*; |
|||
|
|||
/** |
|||
* {@link OwnerServiceImpl} 的单元测试类 |
|||
* |
|||
* @author 超级管理员 |
|||
*/ |
|||
@Import(OwnerServiceImpl.class) |
|||
public class OwnerServiceImplTest extends BaseDbUnitTest { |
|||
|
|||
@Resource |
|||
private OwnerServiceImpl ownerService; |
|||
|
|||
@Resource |
|||
private OwnerMapper ownerMapper; |
|||
|
|||
@Test |
|||
public void testCreateOwner_success() { |
|||
// 准备参数
|
|||
OwnerCreateReqVO reqVO = randomPojo(OwnerCreateReqVO.class); |
|||
|
|||
// 调用
|
|||
Long ownerId = ownerService.createOwner(reqVO); |
|||
// 断言
|
|||
assertNotNull(ownerId); |
|||
// 校验记录的属性是否正确
|
|||
OwnerDO owner = ownerMapper.selectById(ownerId); |
|||
assertPojoEquals(reqVO, owner); |
|||
} |
|||
|
|||
@Test |
|||
public void testUpdateOwner_success() { |
|||
// mock 数据
|
|||
OwnerDO dbOwner = randomPojo(OwnerDO.class); |
|||
ownerMapper.insert(dbOwner);// @Sql: 先插入出一条存在的数据
|
|||
// 准备参数
|
|||
OwnerUpdateReqVO reqVO = randomPojo(OwnerUpdateReqVO.class, o -> { |
|||
o.setId(dbOwner.getId()); // 设置更新的 ID
|
|||
}); |
|||
|
|||
// 调用
|
|||
ownerService.updateOwner(reqVO); |
|||
// 校验是否更新正确
|
|||
OwnerDO owner = ownerMapper.selectById(reqVO.getId()); // 获取最新的
|
|||
assertPojoEquals(reqVO, owner); |
|||
} |
|||
|
|||
@Test |
|||
public void testUpdateOwner_notExists() { |
|||
// 准备参数
|
|||
OwnerUpdateReqVO reqVO = randomPojo(OwnerUpdateReqVO.class); |
|||
|
|||
// 调用, 并断言异常
|
|||
assertServiceException(() -> ownerService.updateOwner(reqVO), OWNER_NOT_EXISTS); |
|||
} |
|||
|
|||
@Test |
|||
public void testDeleteOwner_success() { |
|||
// mock 数据
|
|||
OwnerDO dbOwner = randomPojo(OwnerDO.class); |
|||
ownerMapper.insert(dbOwner);// @Sql: 先插入出一条存在的数据
|
|||
// 准备参数
|
|||
Long id = dbOwner.getId(); |
|||
|
|||
// 调用
|
|||
ownerService.deleteOwner(id); |
|||
// 校验数据不存在了
|
|||
assertNull(ownerMapper.selectById(id)); |
|||
} |
|||
|
|||
@Test |
|||
public void testDeleteOwner_notExists() { |
|||
// 准备参数
|
|||
Long id = randomLongId(); |
|||
|
|||
// 调用, 并断言异常
|
|||
assertServiceException(() -> ownerService.deleteOwner(id), OWNER_NOT_EXISTS); |
|||
} |
|||
|
|||
@Test |
|||
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
|
|||
public void testGetOwnerPage() { |
|||
// mock 数据
|
|||
OwnerDO dbOwner = randomPojo(OwnerDO.class, o -> { // 等会查询到
|
|||
o.setCode(null); |
|||
o.setName(null); |
|||
o.setShortName(null); |
|||
o.setAddress(null); |
|||
o.setCountry(null); |
|||
o.setCity(null); |
|||
o.setPhone(null); |
|||
o.setFax(null); |
|||
o.setPostId(null); |
|||
o.setContacts(null); |
|||
o.setBank(null); |
|||
o.setCurrency(null); |
|||
o.setTaxRate(null); |
|||
o.setType(null); |
|||
o.setActiveTime(null); |
|||
o.setExpireTime(null); |
|||
o.setRemark(null); |
|||
o.setCreateTime(null); |
|||
o.setCreator(null); |
|||
o.setAvailable(null); |
|||
}); |
|||
ownerMapper.insert(dbOwner); |
|||
// 测试 code 不匹配
|
|||
ownerMapper.insert(cloneIgnoreId(dbOwner, o -> o.setCode(null))); |
|||
// 测试 name 不匹配
|
|||
ownerMapper.insert(cloneIgnoreId(dbOwner, o -> o.setName(null))); |
|||
// 测试 shortName 不匹配
|
|||
ownerMapper.insert(cloneIgnoreId(dbOwner, o -> o.setShortName(null))); |
|||
// 测试 address 不匹配
|
|||
ownerMapper.insert(cloneIgnoreId(dbOwner, o -> o.setAddress(null))); |
|||
// 测试 country 不匹配
|
|||
ownerMapper.insert(cloneIgnoreId(dbOwner, o -> o.setCountry(null))); |
|||
// 测试 city 不匹配
|
|||
ownerMapper.insert(cloneIgnoreId(dbOwner, o -> o.setCity(null))); |
|||
// 测试 phone 不匹配
|
|||
ownerMapper.insert(cloneIgnoreId(dbOwner, o -> o.setPhone(null))); |
|||
// 测试 fax 不匹配
|
|||
ownerMapper.insert(cloneIgnoreId(dbOwner, o -> o.setFax(null))); |
|||
// 测试 postId 不匹配
|
|||
ownerMapper.insert(cloneIgnoreId(dbOwner, o -> o.setPostId(null))); |
|||
// 测试 contacts 不匹配
|
|||
ownerMapper.insert(cloneIgnoreId(dbOwner, o -> o.setContacts(null))); |
|||
// 测试 bank 不匹配
|
|||
ownerMapper.insert(cloneIgnoreId(dbOwner, o -> o.setBank(null))); |
|||
// 测试 currency 不匹配
|
|||
ownerMapper.insert(cloneIgnoreId(dbOwner, o -> o.setCurrency(null))); |
|||
// 测试 taxRate 不匹配
|
|||
ownerMapper.insert(cloneIgnoreId(dbOwner, o -> o.setTaxRate(null))); |
|||
// 测试 type 不匹配
|
|||
ownerMapper.insert(cloneIgnoreId(dbOwner, o -> o.setType(null))); |
|||
// 测试 activeTime 不匹配
|
|||
ownerMapper.insert(cloneIgnoreId(dbOwner, o -> o.setActiveTime(null))); |
|||
// 测试 expireTime 不匹配
|
|||
ownerMapper.insert(cloneIgnoreId(dbOwner, o -> o.setExpireTime(null))); |
|||
// 测试 remark 不匹配
|
|||
ownerMapper.insert(cloneIgnoreId(dbOwner, o -> o.setRemark(null))); |
|||
// 测试 createTime 不匹配
|
|||
ownerMapper.insert(cloneIgnoreId(dbOwner, o -> o.setCreateTime(null))); |
|||
// 测试 creator 不匹配
|
|||
ownerMapper.insert(cloneIgnoreId(dbOwner, o -> o.setCreator(null))); |
|||
// 测试 available 不匹配
|
|||
ownerMapper.insert(cloneIgnoreId(dbOwner, o -> o.setAvailable(null))); |
|||
// 准备参数
|
|||
OwnerPageReqVO reqVO = new OwnerPageReqVO(); |
|||
reqVO.setCode(null); |
|||
reqVO.setName(null); |
|||
reqVO.setShortName(null); |
|||
reqVO.setAddress(null); |
|||
reqVO.setCountry(null); |
|||
reqVO.setCity(null); |
|||
reqVO.setPhone(null); |
|||
reqVO.setFax(null); |
|||
reqVO.setPostId(null); |
|||
reqVO.setContacts(null); |
|||
reqVO.setBank(null); |
|||
reqVO.setCurrency(null); |
|||
reqVO.setTaxRate(null); |
|||
reqVO.setType(null); |
|||
reqVO.setActiveTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); |
|||
reqVO.setExpireTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); |
|||
reqVO.setRemark(null); |
|||
reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); |
|||
reqVO.setCreator(null); |
|||
reqVO.setAvailable(null); |
|||
|
|||
// 调用
|
|||
PageResult<OwnerDO> pageResult = ownerService.getOwnerPage(reqVO); |
|||
// 断言
|
|||
assertEquals(1, pageResult.getTotal()); |
|||
assertEquals(1, pageResult.getList().size()); |
|||
assertPojoEquals(dbOwner, pageResult.getList().get(0)); |
|||
} |
|||
|
|||
@Test |
|||
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
|
|||
public void testGetOwnerList() { |
|||
// mock 数据
|
|||
OwnerDO dbOwner = randomPojo(OwnerDO.class, o -> { // 等会查询到
|
|||
o.setCode(null); |
|||
o.setName(null); |
|||
o.setShortName(null); |
|||
o.setAddress(null); |
|||
o.setCountry(null); |
|||
o.setCity(null); |
|||
o.setPhone(null); |
|||
o.setFax(null); |
|||
o.setPostId(null); |
|||
o.setContacts(null); |
|||
o.setBank(null); |
|||
o.setCurrency(null); |
|||
o.setTaxRate(null); |
|||
o.setType(null); |
|||
o.setActiveTime(null); |
|||
o.setExpireTime(null); |
|||
o.setRemark(null); |
|||
o.setCreateTime(null); |
|||
o.setCreator(null); |
|||
o.setAvailable(null); |
|||
}); |
|||
ownerMapper.insert(dbOwner); |
|||
// 测试 code 不匹配
|
|||
ownerMapper.insert(cloneIgnoreId(dbOwner, o -> o.setCode(null))); |
|||
// 测试 name 不匹配
|
|||
ownerMapper.insert(cloneIgnoreId(dbOwner, o -> o.setName(null))); |
|||
// 测试 shortName 不匹配
|
|||
ownerMapper.insert(cloneIgnoreId(dbOwner, o -> o.setShortName(null))); |
|||
// 测试 address 不匹配
|
|||
ownerMapper.insert(cloneIgnoreId(dbOwner, o -> o.setAddress(null))); |
|||
// 测试 country 不匹配
|
|||
ownerMapper.insert(cloneIgnoreId(dbOwner, o -> o.setCountry(null))); |
|||
// 测试 city 不匹配
|
|||
ownerMapper.insert(cloneIgnoreId(dbOwner, o -> o.setCity(null))); |
|||
// 测试 phone 不匹配
|
|||
ownerMapper.insert(cloneIgnoreId(dbOwner, o -> o.setPhone(null))); |
|||
// 测试 fax 不匹配
|
|||
ownerMapper.insert(cloneIgnoreId(dbOwner, o -> o.setFax(null))); |
|||
// 测试 postId 不匹配
|
|||
ownerMapper.insert(cloneIgnoreId(dbOwner, o -> o.setPostId(null))); |
|||
// 测试 contacts 不匹配
|
|||
ownerMapper.insert(cloneIgnoreId(dbOwner, o -> o.setContacts(null))); |
|||
// 测试 bank 不匹配
|
|||
ownerMapper.insert(cloneIgnoreId(dbOwner, o -> o.setBank(null))); |
|||
// 测试 currency 不匹配
|
|||
ownerMapper.insert(cloneIgnoreId(dbOwner, o -> o.setCurrency(null))); |
|||
// 测试 taxRate 不匹配
|
|||
ownerMapper.insert(cloneIgnoreId(dbOwner, o -> o.setTaxRate(null))); |
|||
// 测试 type 不匹配
|
|||
ownerMapper.insert(cloneIgnoreId(dbOwner, o -> o.setType(null))); |
|||
// 测试 activeTime 不匹配
|
|||
ownerMapper.insert(cloneIgnoreId(dbOwner, o -> o.setActiveTime(null))); |
|||
// 测试 expireTime 不匹配
|
|||
ownerMapper.insert(cloneIgnoreId(dbOwner, o -> o.setExpireTime(null))); |
|||
// 测试 remark 不匹配
|
|||
ownerMapper.insert(cloneIgnoreId(dbOwner, o -> o.setRemark(null))); |
|||
// 测试 createTime 不匹配
|
|||
ownerMapper.insert(cloneIgnoreId(dbOwner, o -> o.setCreateTime(null))); |
|||
// 测试 creator 不匹配
|
|||
ownerMapper.insert(cloneIgnoreId(dbOwner, o -> o.setCreator(null))); |
|||
// 测试 available 不匹配
|
|||
ownerMapper.insert(cloneIgnoreId(dbOwner, o -> o.setAvailable(null))); |
|||
// 准备参数
|
|||
OwnerExportReqVO reqVO = new OwnerExportReqVO(); |
|||
reqVO.setCode(null); |
|||
reqVO.setName(null); |
|||
reqVO.setShortName(null); |
|||
reqVO.setAddress(null); |
|||
reqVO.setCountry(null); |
|||
reqVO.setCity(null); |
|||
reqVO.setPhone(null); |
|||
reqVO.setFax(null); |
|||
reqVO.setPostId(null); |
|||
reqVO.setContacts(null); |
|||
reqVO.setBank(null); |
|||
reqVO.setCurrency(null); |
|||
reqVO.setTaxRate(null); |
|||
reqVO.setType(null); |
|||
reqVO.setActiveTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); |
|||
reqVO.setExpireTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); |
|||
reqVO.setRemark(null); |
|||
reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); |
|||
reqVO.setCreator(null); |
|||
reqVO.setAvailable(null); |
|||
|
|||
// 调用
|
|||
List<OwnerDO> list = ownerService.getOwnerList(reqVO); |
|||
// 断言
|
|||
assertEquals(1, list.size()); |
|||
assertPojoEquals(dbOwner, list.get(0)); |
|||
} |
|||
|
|||
} |
@ -1,211 +0,0 @@ |
|||
package com.win.module.wms.service.paramsetting; |
|||
|
|||
import com.win.module.wms.controller.paramsetting.vo.ParamsettingCreateReqVO; |
|||
import com.win.module.wms.controller.paramsetting.vo.ParamsettingExportReqVO; |
|||
import com.win.module.wms.controller.paramsetting.vo.ParamsettingPageReqVO; |
|||
import com.win.module.wms.controller.paramsetting.vo.ParamsettingUpdateReqVO; |
|||
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.paramsetting.ParamsettingDO; |
|||
import com.win.module.wms.dal.mysql.paramsetting.ParamsettingMapper; |
|||
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 ParamsettingServiceImpl} 的单元测试类 |
|||
* |
|||
* @author 超级管理员 |
|||
*/ |
|||
@Import(ParamsettingServiceImpl.class) |
|||
public class ParamsettingServiceImplTest extends BaseDbUnitTest { |
|||
|
|||
@Resource |
|||
private ParamsettingServiceImpl paramsettingService; |
|||
|
|||
@Resource |
|||
private ParamsettingMapper paramsettingMapper; |
|||
|
|||
@Test |
|||
public void testCreateParamsetting_success() { |
|||
// 准备参数
|
|||
ParamsettingCreateReqVO reqVO = randomPojo(ParamsettingCreateReqVO.class); |
|||
|
|||
// 调用
|
|||
Long paramsettingId = paramsettingService.createParamsetting(reqVO); |
|||
// 断言
|
|||
assertNotNull(paramsettingId); |
|||
// 校验记录的属性是否正确
|
|||
ParamsettingDO paramsetting = paramsettingMapper.selectById(paramsettingId); |
|||
assertPojoEquals(reqVO, paramsetting); |
|||
} |
|||
|
|||
@Test |
|||
public void testUpdateParamsetting_success() { |
|||
// mock 数据
|
|||
ParamsettingDO dbParamsetting = randomPojo(ParamsettingDO.class); |
|||
paramsettingMapper.insert(dbParamsetting);// @Sql: 先插入出一条存在的数据
|
|||
// 准备参数
|
|||
ParamsettingUpdateReqVO reqVO = randomPojo(ParamsettingUpdateReqVO.class, o -> { |
|||
o.setId(dbParamsetting.getId()); // 设置更新的 ID
|
|||
}); |
|||
|
|||
// 调用
|
|||
paramsettingService.updateParamsetting(reqVO); |
|||
// 校验是否更新正确
|
|||
ParamsettingDO paramsetting = paramsettingMapper.selectById(reqVO.getId()); // 获取最新的
|
|||
assertPojoEquals(reqVO, paramsetting); |
|||
} |
|||
|
|||
@Test |
|||
public void testUpdateParamsetting_notExists() { |
|||
// 准备参数
|
|||
ParamsettingUpdateReqVO reqVO = randomPojo(ParamsettingUpdateReqVO.class); |
|||
|
|||
// 调用, 并断言异常
|
|||
assertServiceException(() -> paramsettingService.updateParamsetting(reqVO), PARAMSETTING_NOT_EXISTS); |
|||
} |
|||
|
|||
@Test |
|||
public void testDeleteParamsetting_success() { |
|||
// mock 数据
|
|||
ParamsettingDO dbParamsetting = randomPojo(ParamsettingDO.class); |
|||
paramsettingMapper.insert(dbParamsetting);// @Sql: 先插入出一条存在的数据
|
|||
// 准备参数
|
|||
Long id = dbParamsetting.getId(); |
|||
|
|||
// 调用
|
|||
paramsettingService.deleteParamsetting(id); |
|||
// 校验数据不存在了
|
|||
assertNull(paramsettingMapper.selectById(id)); |
|||
} |
|||
|
|||
@Test |
|||
public void testDeleteParamsetting_notExists() { |
|||
// 准备参数
|
|||
Long id = randomLongId(); |
|||
|
|||
// 调用, 并断言异常
|
|||
assertServiceException(() -> paramsettingService.deleteParamsetting(id), PARAMSETTING_NOT_EXISTS); |
|||
} |
|||
|
|||
@Test |
|||
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
|
|||
public void testGetParamsettingPage() { |
|||
// mock 数据
|
|||
ParamsettingDO dbParamsetting = randomPojo(ParamsettingDO.class, o -> { // 等会查询到
|
|||
o.setStrategyType(null); |
|||
o.setParamCode(null); |
|||
o.setParamName(null); |
|||
o.setUsableOpeartors(null); |
|||
o.setDataType(null); |
|||
o.setValueScope(null); |
|||
o.setRelatedTo(null); |
|||
o.setDescription(null); |
|||
o.setIsRequired(null); |
|||
}); |
|||
paramsettingMapper.insert(dbParamsetting); |
|||
// 测试 strategyType 不匹配
|
|||
paramsettingMapper.insert(cloneIgnoreId(dbParamsetting, o -> o.setStrategyType(null))); |
|||
// 测试 paramCode 不匹配
|
|||
paramsettingMapper.insert(cloneIgnoreId(dbParamsetting, o -> o.setParamCode(null))); |
|||
// 测试 paramName 不匹配
|
|||
paramsettingMapper.insert(cloneIgnoreId(dbParamsetting, o -> o.setParamName(null))); |
|||
// 测试 usableOpeartors 不匹配
|
|||
paramsettingMapper.insert(cloneIgnoreId(dbParamsetting, o -> o.setUsableOpeartors(null))); |
|||
// 测试 dataType 不匹配
|
|||
paramsettingMapper.insert(cloneIgnoreId(dbParamsetting, o -> o.setDataType(null))); |
|||
// 测试 valueScope 不匹配
|
|||
paramsettingMapper.insert(cloneIgnoreId(dbParamsetting, o -> o.setValueScope(null))); |
|||
// 测试 relatedTo 不匹配
|
|||
paramsettingMapper.insert(cloneIgnoreId(dbParamsetting, o -> o.setRelatedTo(null))); |
|||
// 测试 description 不匹配
|
|||
paramsettingMapper.insert(cloneIgnoreId(dbParamsetting, o -> o.setDescription(null))); |
|||
// 测试 isRequired 不匹配
|
|||
paramsettingMapper.insert(cloneIgnoreId(dbParamsetting, o -> o.setIsRequired(null))); |
|||
// 准备参数
|
|||
ParamsettingPageReqVO reqVO = new ParamsettingPageReqVO(); |
|||
reqVO.setStrategyType(null); |
|||
reqVO.setParamCode(null); |
|||
reqVO.setParamName(null); |
|||
reqVO.setUsableOpeartors(null); |
|||
reqVO.setDataType(null); |
|||
reqVO.setValueScope(null); |
|||
reqVO.setRelatedTo(null); |
|||
reqVO.setDescription(null); |
|||
reqVO.setIsRequired(null); |
|||
|
|||
// 调用
|
|||
PageResult<ParamsettingDO> pageResult = paramsettingService.getParamsettingPage(reqVO); |
|||
// 断言
|
|||
assertEquals(1, pageResult.getTotal()); |
|||
assertEquals(1, pageResult.getList().size()); |
|||
assertPojoEquals(dbParamsetting, pageResult.getList().get(0)); |
|||
} |
|||
|
|||
@Test |
|||
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
|
|||
public void testGetParamsettingList() { |
|||
// mock 数据
|
|||
ParamsettingDO dbParamsetting = randomPojo(ParamsettingDO.class, o -> { // 等会查询到
|
|||
o.setStrategyType(null); |
|||
o.setParamCode(null); |
|||
o.setParamName(null); |
|||
o.setUsableOpeartors(null); |
|||
o.setDataType(null); |
|||
o.setValueScope(null); |
|||
o.setRelatedTo(null); |
|||
o.setDescription(null); |
|||
o.setIsRequired(null); |
|||
}); |
|||
paramsettingMapper.insert(dbParamsetting); |
|||
// 测试 strategyType 不匹配
|
|||
paramsettingMapper.insert(cloneIgnoreId(dbParamsetting, o -> o.setStrategyType(null))); |
|||
// 测试 paramCode 不匹配
|
|||
paramsettingMapper.insert(cloneIgnoreId(dbParamsetting, o -> o.setParamCode(null))); |
|||
// 测试 paramName 不匹配
|
|||
paramsettingMapper.insert(cloneIgnoreId(dbParamsetting, o -> o.setParamName(null))); |
|||
// 测试 usableOpeartors 不匹配
|
|||
paramsettingMapper.insert(cloneIgnoreId(dbParamsetting, o -> o.setUsableOpeartors(null))); |
|||
// 测试 dataType 不匹配
|
|||
paramsettingMapper.insert(cloneIgnoreId(dbParamsetting, o -> o.setDataType(null))); |
|||
// 测试 valueScope 不匹配
|
|||
paramsettingMapper.insert(cloneIgnoreId(dbParamsetting, o -> o.setValueScope(null))); |
|||
// 测试 relatedTo 不匹配
|
|||
paramsettingMapper.insert(cloneIgnoreId(dbParamsetting, o -> o.setRelatedTo(null))); |
|||
// 测试 description 不匹配
|
|||
paramsettingMapper.insert(cloneIgnoreId(dbParamsetting, o -> o.setDescription(null))); |
|||
// 测试 isRequired 不匹配
|
|||
paramsettingMapper.insert(cloneIgnoreId(dbParamsetting, o -> o.setIsRequired(null))); |
|||
// 准备参数
|
|||
ParamsettingExportReqVO reqVO = new ParamsettingExportReqVO(); |
|||
reqVO.setStrategyType(null); |
|||
reqVO.setParamCode(null); |
|||
reqVO.setParamName(null); |
|||
reqVO.setUsableOpeartors(null); |
|||
reqVO.setDataType(null); |
|||
reqVO.setValueScope(null); |
|||
reqVO.setRelatedTo(null); |
|||
reqVO.setDescription(null); |
|||
reqVO.setIsRequired(null); |
|||
|
|||
// 调用
|
|||
List<ParamsettingDO> list = paramsettingService.getParamsettingList(reqVO); |
|||
// 断言
|
|||
assertEquals(1, list.size()); |
|||
assertPojoEquals(dbParamsetting, list.get(0)); |
|||
} |
|||
|
|||
} |
@ -1,212 +0,0 @@ |
|||
package com.win.module.wms.service.recordsetting; |
|||
|
|||
import com.win.module.wms.controller.recordsetting.vo.RecordsettingCreateReqVO; |
|||
import com.win.module.wms.controller.recordsetting.vo.RecordsettingExportReqVO; |
|||
import com.win.module.wms.controller.recordsetting.vo.RecordsettingPageReqVO; |
|||
import com.win.module.wms.controller.recordsetting.vo.RecordsettingUpdateReqVO; |
|||
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.recordsetting.RecordsettingDO; |
|||
import com.win.module.wms.dal.mysql.recordsetting.RecordsettingMapper; |
|||
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.date.LocalDateTimeUtils.*; |
|||
import static com.win.framework.common.util.object.ObjectUtils.*; |
|||
import static org.junit.jupiter.api.Assertions.*; |
|||
|
|||
/** |
|||
* {@link RecordsettingServiceImpl} 的单元测试类 |
|||
* |
|||
* @author 超级管理员 |
|||
*/ |
|||
@Import(RecordsettingServiceImpl.class) |
|||
public class RecordsettingServiceImplTest extends BaseDbUnitTest { |
|||
|
|||
@Resource |
|||
private RecordsettingServiceImpl recordsettingService; |
|||
|
|||
@Resource |
|||
private RecordsettingMapper recordsettingMapper; |
|||
|
|||
@Test |
|||
public void testCreateRecordsetting_success() { |
|||
// 准备参数
|
|||
RecordsettingCreateReqVO reqVO = randomPojo(RecordsettingCreateReqVO.class); |
|||
|
|||
// 调用
|
|||
Long recordsettingId = recordsettingService.createRecordsetting(reqVO); |
|||
// 断言
|
|||
assertNotNull(recordsettingId); |
|||
// 校验记录的属性是否正确
|
|||
RecordsettingDO recordsetting = recordsettingMapper.selectById(recordsettingId); |
|||
assertPojoEquals(reqVO, recordsetting); |
|||
} |
|||
|
|||
@Test |
|||
public void testUpdateRecordsetting_success() { |
|||
// mock 数据
|
|||
RecordsettingDO dbRecordsetting = randomPojo(RecordsettingDO.class); |
|||
recordsettingMapper.insert(dbRecordsetting);// @Sql: 先插入出一条存在的数据
|
|||
// 准备参数
|
|||
RecordsettingUpdateReqVO reqVO = randomPojo(RecordsettingUpdateReqVO.class, o -> { |
|||
o.setId(dbRecordsetting.getId()); // 设置更新的 ID
|
|||
}); |
|||
|
|||
// 调用
|
|||
recordsettingService.updateRecordsetting(reqVO); |
|||
// 校验是否更新正确
|
|||
RecordsettingDO recordsetting = recordsettingMapper.selectById(reqVO.getId()); // 获取最新的
|
|||
assertPojoEquals(reqVO, recordsetting); |
|||
} |
|||
|
|||
@Test |
|||
public void testUpdateRecordsetting_notExists() { |
|||
// 准备参数
|
|||
RecordsettingUpdateReqVO reqVO = randomPojo(RecordsettingUpdateReqVO.class); |
|||
|
|||
// 调用, 并断言异常
|
|||
assertServiceException(() -> recordsettingService.updateRecordsetting(reqVO), RECORDSETTING_NOT_EXISTS); |
|||
} |
|||
|
|||
@Test |
|||
public void testDeleteRecordsetting_success() { |
|||
// mock 数据
|
|||
RecordsettingDO dbRecordsetting = randomPojo(RecordsettingDO.class); |
|||
recordsettingMapper.insert(dbRecordsetting);// @Sql: 先插入出一条存在的数据
|
|||
// 准备参数
|
|||
Long id = dbRecordsetting.getId(); |
|||
|
|||
// 调用
|
|||
recordsettingService.deleteRecordsetting(id); |
|||
// 校验数据不存在了
|
|||
assertNull(recordsettingMapper.selectById(id)); |
|||
} |
|||
|
|||
@Test |
|||
public void testDeleteRecordsetting_notExists() { |
|||
// 准备参数
|
|||
Long id = randomLongId(); |
|||
|
|||
// 调用, 并断言异常
|
|||
assertServiceException(() -> recordsettingService.deleteRecordsetting(id), RECORDSETTING_NOT_EXISTS); |
|||
} |
|||
|
|||
@Test |
|||
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
|
|||
public void testGetRecordsettingPage() { |
|||
// mock 数据
|
|||
RecordsettingDO dbRecordsetting = randomPojo(RecordsettingDO.class, o -> { // 等会查询到
|
|||
o.setCode(null); |
|||
o.setInterfaceType(null); |
|||
o.setActiveTime(null); |
|||
o.setExpireTime(null); |
|||
o.setRemark(null); |
|||
o.setCreateTime(null); |
|||
o.setCreator(null); |
|||
o.setAvailable(null); |
|||
o.setIsSoftDeleted(null); |
|||
}); |
|||
recordsettingMapper.insert(dbRecordsetting); |
|||
// 测试 code 不匹配
|
|||
recordsettingMapper.insert(cloneIgnoreId(dbRecordsetting, o -> o.setCode(null))); |
|||
// 测试 interfaceType 不匹配
|
|||
recordsettingMapper.insert(cloneIgnoreId(dbRecordsetting, o -> o.setInterfaceType(null))); |
|||
// 测试 activeTime 不匹配
|
|||
recordsettingMapper.insert(cloneIgnoreId(dbRecordsetting, o -> o.setActiveTime(null))); |
|||
// 测试 expireTime 不匹配
|
|||
recordsettingMapper.insert(cloneIgnoreId(dbRecordsetting, o -> o.setExpireTime(null))); |
|||
// 测试 remark 不匹配
|
|||
recordsettingMapper.insert(cloneIgnoreId(dbRecordsetting, o -> o.setRemark(null))); |
|||
// 测试 createTime 不匹配
|
|||
recordsettingMapper.insert(cloneIgnoreId(dbRecordsetting, o -> o.setCreateTime(null))); |
|||
// 测试 creator 不匹配
|
|||
recordsettingMapper.insert(cloneIgnoreId(dbRecordsetting, o -> o.setCreator(null))); |
|||
// 测试 available 不匹配
|
|||
recordsettingMapper.insert(cloneIgnoreId(dbRecordsetting, o -> o.setAvailable(null))); |
|||
// 测试 isSoftDeleted 不匹配
|
|||
recordsettingMapper.insert(cloneIgnoreId(dbRecordsetting, o -> o.setIsSoftDeleted(null))); |
|||
// 准备参数
|
|||
RecordsettingPageReqVO reqVO = new RecordsettingPageReqVO(); |
|||
reqVO.setCode(null); |
|||
reqVO.setInterfaceType(null); |
|||
reqVO.setActiveTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); |
|||
reqVO.setExpireTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); |
|||
reqVO.setRemark(null); |
|||
reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); |
|||
reqVO.setCreator(null); |
|||
reqVO.setAvailable(null); |
|||
reqVO.setIsSoftDeleted(null); |
|||
|
|||
// 调用
|
|||
PageResult<RecordsettingDO> pageResult = recordsettingService.getRecordsettingPage(reqVO); |
|||
// 断言
|
|||
assertEquals(1, pageResult.getTotal()); |
|||
assertEquals(1, pageResult.getList().size()); |
|||
assertPojoEquals(dbRecordsetting, pageResult.getList().get(0)); |
|||
} |
|||
|
|||
@Test |
|||
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
|
|||
public void testGetRecordsettingList() { |
|||
// mock 数据
|
|||
RecordsettingDO dbRecordsetting = randomPojo(RecordsettingDO.class, o -> { // 等会查询到
|
|||
o.setCode(null); |
|||
o.setInterfaceType(null); |
|||
o.setActiveTime(null); |
|||
o.setExpireTime(null); |
|||
o.setRemark(null); |
|||
o.setCreateTime(null); |
|||
o.setCreator(null); |
|||
o.setAvailable(null); |
|||
o.setIsSoftDeleted(null); |
|||
}); |
|||
recordsettingMapper.insert(dbRecordsetting); |
|||
// 测试 code 不匹配
|
|||
recordsettingMapper.insert(cloneIgnoreId(dbRecordsetting, o -> o.setCode(null))); |
|||
// 测试 interfaceType 不匹配
|
|||
recordsettingMapper.insert(cloneIgnoreId(dbRecordsetting, o -> o.setInterfaceType(null))); |
|||
// 测试 activeTime 不匹配
|
|||
recordsettingMapper.insert(cloneIgnoreId(dbRecordsetting, o -> o.setActiveTime(null))); |
|||
// 测试 expireTime 不匹配
|
|||
recordsettingMapper.insert(cloneIgnoreId(dbRecordsetting, o -> o.setExpireTime(null))); |
|||
// 测试 remark 不匹配
|
|||
recordsettingMapper.insert(cloneIgnoreId(dbRecordsetting, o -> o.setRemark(null))); |
|||
// 测试 createTime 不匹配
|
|||
recordsettingMapper.insert(cloneIgnoreId(dbRecordsetting, o -> o.setCreateTime(null))); |
|||
// 测试 creator 不匹配
|
|||
recordsettingMapper.insert(cloneIgnoreId(dbRecordsetting, o -> o.setCreator(null))); |
|||
// 测试 available 不匹配
|
|||
recordsettingMapper.insert(cloneIgnoreId(dbRecordsetting, o -> o.setAvailable(null))); |
|||
// 测试 isSoftDeleted 不匹配
|
|||
recordsettingMapper.insert(cloneIgnoreId(dbRecordsetting, o -> o.setIsSoftDeleted(null))); |
|||
// 准备参数
|
|||
RecordsettingExportReqVO reqVO = new RecordsettingExportReqVO(); |
|||
reqVO.setCode(null); |
|||
reqVO.setInterfaceType(null); |
|||
reqVO.setActiveTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); |
|||
reqVO.setExpireTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); |
|||
reqVO.setRemark(null); |
|||
reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); |
|||
reqVO.setCreator(null); |
|||
reqVO.setAvailable(null); |
|||
reqVO.setIsSoftDeleted(null); |
|||
|
|||
// 调用
|
|||
List<RecordsettingDO> list = recordsettingService.getRecordsettingList(reqVO); |
|||
// 断言
|
|||
assertEquals(1, list.size()); |
|||
assertPojoEquals(dbRecordsetting, list.get(0)); |
|||
} |
|||
|
|||
} |
@ -1,244 +0,0 @@ |
|||
package com.win.module.wms.service.requestsetting; |
|||
|
|||
import com.win.module.wms.controller.requestsetting.vo.RequestsettingCreateReqVO; |
|||
import com.win.module.wms.controller.requestsetting.vo.RequestsettingExportReqVO; |
|||
import com.win.module.wms.controller.requestsetting.vo.RequestsettingPageReqVO; |
|||
import com.win.module.wms.controller.requestsetting.vo.RequestsettingUpdateReqVO; |
|||
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.requestsetting.RequestsettingDO; |
|||
import com.win.module.wms.dal.mysql.requestsetting.RequestsettingMapper; |
|||
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.date.LocalDateTimeUtils.*; |
|||
import static com.win.framework.common.util.object.ObjectUtils.*; |
|||
import static org.junit.jupiter.api.Assertions.*; |
|||
|
|||
/** |
|||
* {@link RequestsettingServiceImpl} 的单元测试类 |
|||
* |
|||
* @author 超级管理员 |
|||
*/ |
|||
@Import(RequestsettingServiceImpl.class) |
|||
public class RequestsettingServiceImplTest extends BaseDbUnitTest { |
|||
|
|||
@Resource |
|||
private RequestsettingServiceImpl requestsettingService; |
|||
|
|||
@Resource |
|||
private RequestsettingMapper requestsettingMapper; |
|||
|
|||
@Test |
|||
public void testCreateRequestsetting_success() { |
|||
// 准备参数
|
|||
RequestsettingCreateReqVO reqVO = randomPojo(RequestsettingCreateReqVO.class); |
|||
|
|||
// 调用
|
|||
Long requestsettingId = requestsettingService.createRequestsetting(reqVO); |
|||
// 断言
|
|||
assertNotNull(requestsettingId); |
|||
// 校验记录的属性是否正确
|
|||
RequestsettingDO requestsetting = requestsettingMapper.selectById(requestsettingId); |
|||
assertPojoEquals(reqVO, requestsetting); |
|||
} |
|||
|
|||
@Test |
|||
public void testUpdateRequestsetting_success() { |
|||
// mock 数据
|
|||
RequestsettingDO dbRequestsetting = randomPojo(RequestsettingDO.class); |
|||
requestsettingMapper.insert(dbRequestsetting);// @Sql: 先插入出一条存在的数据
|
|||
// 准备参数
|
|||
RequestsettingUpdateReqVO reqVO = randomPojo(RequestsettingUpdateReqVO.class, o -> { |
|||
o.setId(dbRequestsetting.getId()); // 设置更新的 ID
|
|||
}); |
|||
|
|||
// 调用
|
|||
requestsettingService.updateRequestsetting(reqVO); |
|||
// 校验是否更新正确
|
|||
RequestsettingDO requestsetting = requestsettingMapper.selectById(reqVO.getId()); // 获取最新的
|
|||
assertPojoEquals(reqVO, requestsetting); |
|||
} |
|||
|
|||
@Test |
|||
public void testUpdateRequestsetting_notExists() { |
|||
// 准备参数
|
|||
RequestsettingUpdateReqVO reqVO = randomPojo(RequestsettingUpdateReqVO.class); |
|||
|
|||
// 调用, 并断言异常
|
|||
assertServiceException(() -> requestsettingService.updateRequestsetting(reqVO), REQUESTSETTING_NOT_EXISTS); |
|||
} |
|||
|
|||
@Test |
|||
public void testDeleteRequestsetting_success() { |
|||
// mock 数据
|
|||
RequestsettingDO dbRequestsetting = randomPojo(RequestsettingDO.class); |
|||
requestsettingMapper.insert(dbRequestsetting);// @Sql: 先插入出一条存在的数据
|
|||
// 准备参数
|
|||
Long id = dbRequestsetting.getId(); |
|||
|
|||
// 调用
|
|||
requestsettingService.deleteRequestsetting(id); |
|||
// 校验数据不存在了
|
|||
assertNull(requestsettingMapper.selectById(id)); |
|||
} |
|||
|
|||
@Test |
|||
public void testDeleteRequestsetting_notExists() { |
|||
// 准备参数
|
|||
Long id = randomLongId(); |
|||
|
|||
// 调用, 并断言异常
|
|||
assertServiceException(() -> requestsettingService.deleteRequestsetting(id), REQUESTSETTING_NOT_EXISTS); |
|||
} |
|||
|
|||
@Test |
|||
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
|
|||
public void testGetRequestsettingPage() { |
|||
// mock 数据
|
|||
RequestsettingDO dbRequestsetting = randomPojo(RequestsettingDO.class, o -> { // 等会查询到
|
|||
o.setCode(null); |
|||
o.setRequestMode(null); |
|||
o.setActiveTime(null); |
|||
o.setExpireTime(null); |
|||
o.setRemark(null); |
|||
o.setCreateTime(null); |
|||
o.setCreator(null); |
|||
o.setAutoCommit(null); |
|||
o.setAutoAgree(null); |
|||
o.setAutoExecute(null); |
|||
o.setDirectCreateRecord(null); |
|||
o.setAvailable(null); |
|||
o.setIsSoftDeleted(null); |
|||
}); |
|||
requestsettingMapper.insert(dbRequestsetting); |
|||
// 测试 code 不匹配
|
|||
requestsettingMapper.insert(cloneIgnoreId(dbRequestsetting, o -> o.setCode(null))); |
|||
// 测试 requestMode 不匹配
|
|||
requestsettingMapper.insert(cloneIgnoreId(dbRequestsetting, o -> o.setRequestMode(null))); |
|||
// 测试 activeTime 不匹配
|
|||
requestsettingMapper.insert(cloneIgnoreId(dbRequestsetting, o -> o.setActiveTime(null))); |
|||
// 测试 expireTime 不匹配
|
|||
requestsettingMapper.insert(cloneIgnoreId(dbRequestsetting, o -> o.setExpireTime(null))); |
|||
// 测试 remark 不匹配
|
|||
requestsettingMapper.insert(cloneIgnoreId(dbRequestsetting, o -> o.setRemark(null))); |
|||
// 测试 createTime 不匹配
|
|||
requestsettingMapper.insert(cloneIgnoreId(dbRequestsetting, o -> o.setCreateTime(null))); |
|||
// 测试 creator 不匹配
|
|||
requestsettingMapper.insert(cloneIgnoreId(dbRequestsetting, o -> o.setCreator(null))); |
|||
// 测试 autoCommit 不匹配
|
|||
requestsettingMapper.insert(cloneIgnoreId(dbRequestsetting, o -> o.setAutoCommit(null))); |
|||
// 测试 autoAgree 不匹配
|
|||
requestsettingMapper.insert(cloneIgnoreId(dbRequestsetting, o -> o.setAutoAgree(null))); |
|||
// 测试 autoExecute 不匹配
|
|||
requestsettingMapper.insert(cloneIgnoreId(dbRequestsetting, o -> o.setAutoExecute(null))); |
|||
// 测试 directCreateRecord 不匹配
|
|||
requestsettingMapper.insert(cloneIgnoreId(dbRequestsetting, o -> o.setDirectCreateRecord(null))); |
|||
// 测试 available 不匹配
|
|||
requestsettingMapper.insert(cloneIgnoreId(dbRequestsetting, o -> o.setAvailable(null))); |
|||
// 测试 isSoftDeleted 不匹配
|
|||
requestsettingMapper.insert(cloneIgnoreId(dbRequestsetting, o -> o.setIsSoftDeleted(null))); |
|||
// 准备参数
|
|||
RequestsettingPageReqVO reqVO = new RequestsettingPageReqVO(); |
|||
reqVO.setCode(null); |
|||
reqVO.setRequestMode(null); |
|||
reqVO.setActiveTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); |
|||
reqVO.setExpireTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); |
|||
reqVO.setRemark(null); |
|||
reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); |
|||
reqVO.setCreator(null); |
|||
reqVO.setAutoCommit(null); |
|||
reqVO.setAutoAgree(null); |
|||
reqVO.setAutoExecute(null); |
|||
reqVO.setDirectCreateRecord(null); |
|||
reqVO.setAvailable(null); |
|||
reqVO.setIsSoftDeleted(null); |
|||
|
|||
// 调用
|
|||
PageResult<RequestsettingDO> pageResult = requestsettingService.getRequestsettingPage(reqVO); |
|||
// 断言
|
|||
assertEquals(1, pageResult.getTotal()); |
|||
assertEquals(1, pageResult.getList().size()); |
|||
assertPojoEquals(dbRequestsetting, pageResult.getList().get(0)); |
|||
} |
|||
|
|||
@Test |
|||
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
|
|||
public void testGetRequestsettingList() { |
|||
// mock 数据
|
|||
RequestsettingDO dbRequestsetting = randomPojo(RequestsettingDO.class, o -> { // 等会查询到
|
|||
o.setCode(null); |
|||
o.setRequestMode(null); |
|||
o.setActiveTime(null); |
|||
o.setExpireTime(null); |
|||
o.setRemark(null); |
|||
o.setCreateTime(null); |
|||
o.setCreator(null); |
|||
o.setAutoCommit(null); |
|||
o.setAutoAgree(null); |
|||
o.setAutoExecute(null); |
|||
o.setDirectCreateRecord(null); |
|||
o.setAvailable(null); |
|||
o.setIsSoftDeleted(null); |
|||
}); |
|||
requestsettingMapper.insert(dbRequestsetting); |
|||
// 测试 code 不匹配
|
|||
requestsettingMapper.insert(cloneIgnoreId(dbRequestsetting, o -> o.setCode(null))); |
|||
// 测试 requestMode 不匹配
|
|||
requestsettingMapper.insert(cloneIgnoreId(dbRequestsetting, o -> o.setRequestMode(null))); |
|||
// 测试 activeTime 不匹配
|
|||
requestsettingMapper.insert(cloneIgnoreId(dbRequestsetting, o -> o.setActiveTime(null))); |
|||
// 测试 expireTime 不匹配
|
|||
requestsettingMapper.insert(cloneIgnoreId(dbRequestsetting, o -> o.setExpireTime(null))); |
|||
// 测试 remark 不匹配
|
|||
requestsettingMapper.insert(cloneIgnoreId(dbRequestsetting, o -> o.setRemark(null))); |
|||
// 测试 createTime 不匹配
|
|||
requestsettingMapper.insert(cloneIgnoreId(dbRequestsetting, o -> o.setCreateTime(null))); |
|||
// 测试 creator 不匹配
|
|||
requestsettingMapper.insert(cloneIgnoreId(dbRequestsetting, o -> o.setCreator(null))); |
|||
// 测试 autoCommit 不匹配
|
|||
requestsettingMapper.insert(cloneIgnoreId(dbRequestsetting, o -> o.setAutoCommit(null))); |
|||
// 测试 autoAgree 不匹配
|
|||
requestsettingMapper.insert(cloneIgnoreId(dbRequestsetting, o -> o.setAutoAgree(null))); |
|||
// 测试 autoExecute 不匹配
|
|||
requestsettingMapper.insert(cloneIgnoreId(dbRequestsetting, o -> o.setAutoExecute(null))); |
|||
// 测试 directCreateRecord 不匹配
|
|||
requestsettingMapper.insert(cloneIgnoreId(dbRequestsetting, o -> o.setDirectCreateRecord(null))); |
|||
// 测试 available 不匹配
|
|||
requestsettingMapper.insert(cloneIgnoreId(dbRequestsetting, o -> o.setAvailable(null))); |
|||
// 测试 isSoftDeleted 不匹配
|
|||
requestsettingMapper.insert(cloneIgnoreId(dbRequestsetting, o -> o.setIsSoftDeleted(null))); |
|||
// 准备参数
|
|||
RequestsettingExportReqVO reqVO = new RequestsettingExportReqVO(); |
|||
reqVO.setCode(null); |
|||
reqVO.setRequestMode(null); |
|||
reqVO.setActiveTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); |
|||
reqVO.setExpireTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); |
|||
reqVO.setRemark(null); |
|||
reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); |
|||
reqVO.setCreator(null); |
|||
reqVO.setAutoCommit(null); |
|||
reqVO.setAutoAgree(null); |
|||
reqVO.setAutoExecute(null); |
|||
reqVO.setDirectCreateRecord(null); |
|||
reqVO.setAvailable(null); |
|||
reqVO.setIsSoftDeleted(null); |
|||
|
|||
// 调用
|
|||
List<RequestsettingDO> list = requestsettingService.getRequestsettingList(reqVO); |
|||
// 断言
|
|||
assertEquals(1, list.size()); |
|||
assertPojoEquals(dbRequestsetting, list.get(0)); |
|||
} |
|||
|
|||
} |
@ -1,195 +0,0 @@ |
|||
package com.win.module.wms.service.rule; |
|||
|
|||
import com.win.module.wms.controller.rule.vo.RuleCreateReqVO; |
|||
import com.win.module.wms.controller.rule.vo.RuleExportReqVO; |
|||
import com.win.module.wms.controller.rule.vo.RulePageReqVO; |
|||
import com.win.module.wms.controller.rule.vo.RuleUpdateReqVO; |
|||
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.rule.RuleDO; |
|||
import com.win.module.wms.dal.mysql.rule.RuleMapper; |
|||
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 RuleServiceImpl} 的单元测试类 |
|||
* |
|||
* @author 超级管理员 |
|||
*/ |
|||
@Import(RuleServiceImpl.class) |
|||
public class RuleServiceImplTest extends BaseDbUnitTest { |
|||
|
|||
@Resource |
|||
private RuleServiceImpl ruleService; |
|||
|
|||
@Resource |
|||
private RuleMapper ruleMapper; |
|||
|
|||
@Test |
|||
public void testCreateRule_success() { |
|||
// 准备参数
|
|||
RuleCreateReqVO reqVO = randomPojo(RuleCreateReqVO.class); |
|||
|
|||
// 调用
|
|||
Long ruleId = ruleService.createRule(reqVO); |
|||
// 断言
|
|||
assertNotNull(ruleId); |
|||
// 校验记录的属性是否正确
|
|||
RuleDO rule = ruleMapper.selectById(ruleId); |
|||
assertPojoEquals(reqVO, rule); |
|||
} |
|||
|
|||
@Test |
|||
public void testUpdateRule_success() { |
|||
// mock 数据
|
|||
RuleDO dbRule = randomPojo(RuleDO.class); |
|||
ruleMapper.insert(dbRule);// @Sql: 先插入出一条存在的数据
|
|||
// 准备参数
|
|||
RuleUpdateReqVO reqVO = randomPojo(RuleUpdateReqVO.class, o -> { |
|||
o.setId(dbRule.getId()); // 设置更新的 ID
|
|||
}); |
|||
|
|||
// 调用
|
|||
ruleService.updateRule(reqVO); |
|||
// 校验是否更新正确
|
|||
RuleDO rule = ruleMapper.selectById(reqVO.getId()); // 获取最新的
|
|||
assertPojoEquals(reqVO, rule); |
|||
} |
|||
|
|||
@Test |
|||
public void testUpdateRule_notExists() { |
|||
// 准备参数
|
|||
RuleUpdateReqVO reqVO = randomPojo(RuleUpdateReqVO.class); |
|||
|
|||
// 调用, 并断言异常
|
|||
assertServiceException(() -> ruleService.updateRule(reqVO), RULE_NOT_EXISTS); |
|||
} |
|||
|
|||
@Test |
|||
public void testDeleteRule_success() { |
|||
// mock 数据
|
|||
RuleDO dbRule = randomPojo(RuleDO.class); |
|||
ruleMapper.insert(dbRule);// @Sql: 先插入出一条存在的数据
|
|||
// 准备参数
|
|||
Long id = dbRule.getId(); |
|||
|
|||
// 调用
|
|||
ruleService.deleteRule(id); |
|||
// 校验数据不存在了
|
|||
assertNull(ruleMapper.selectById(id)); |
|||
} |
|||
|
|||
@Test |
|||
public void testDeleteRule_notExists() { |
|||
// 准备参数
|
|||
Long id = randomLongId(); |
|||
|
|||
// 调用, 并断言异常
|
|||
assertServiceException(() -> ruleService.deleteRule(id), RULE_NOT_EXISTS); |
|||
} |
|||
|
|||
@Test |
|||
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
|
|||
public void testGetRulePage() { |
|||
// mock 数据
|
|||
RuleDO dbRule = randomPojo(RuleDO.class, o -> { // 等会查询到
|
|||
o.setStrategyCode(null); |
|||
o.setPriority(null); |
|||
o.setCode(null); |
|||
o.setName(null); |
|||
o.setDescription(null); |
|||
o.setCondition(null); |
|||
o.setConfiguration(null); |
|||
}); |
|||
ruleMapper.insert(dbRule); |
|||
// 测试 strategyCode 不匹配
|
|||
ruleMapper.insert(cloneIgnoreId(dbRule, o -> o.setStrategyCode(null))); |
|||
// 测试 priority 不匹配
|
|||
ruleMapper.insert(cloneIgnoreId(dbRule, o -> o.setPriority(null))); |
|||
// 测试 code 不匹配
|
|||
ruleMapper.insert(cloneIgnoreId(dbRule, o -> o.setCode(null))); |
|||
// 测试 name 不匹配
|
|||
ruleMapper.insert(cloneIgnoreId(dbRule, o -> o.setName(null))); |
|||
// 测试 description 不匹配
|
|||
ruleMapper.insert(cloneIgnoreId(dbRule, o -> o.setDescription(null))); |
|||
// 测试 condition 不匹配
|
|||
ruleMapper.insert(cloneIgnoreId(dbRule, o -> o.setCondition(null))); |
|||
// 测试 configuration 不匹配
|
|||
ruleMapper.insert(cloneIgnoreId(dbRule, o -> o.setConfiguration(null))); |
|||
// 准备参数
|
|||
RulePageReqVO reqVO = new RulePageReqVO(); |
|||
reqVO.setStrategyCode(null); |
|||
reqVO.setPriority(null); |
|||
reqVO.setCode(null); |
|||
reqVO.setName(null); |
|||
reqVO.setDescription(null); |
|||
reqVO.setCondition(null); |
|||
reqVO.setConfiguration(null); |
|||
|
|||
// 调用
|
|||
PageResult<RuleDO> pageResult = ruleService.getRulePage(reqVO); |
|||
// 断言
|
|||
assertEquals(1, pageResult.getTotal()); |
|||
assertEquals(1, pageResult.getList().size()); |
|||
assertPojoEquals(dbRule, pageResult.getList().get(0)); |
|||
} |
|||
|
|||
@Test |
|||
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
|
|||
public void testGetRuleList() { |
|||
// mock 数据
|
|||
RuleDO dbRule = randomPojo(RuleDO.class, o -> { // 等会查询到
|
|||
o.setStrategyCode(null); |
|||
o.setPriority(null); |
|||
o.setCode(null); |
|||
o.setName(null); |
|||
o.setDescription(null); |
|||
o.setCondition(null); |
|||
o.setConfiguration(null); |
|||
}); |
|||
ruleMapper.insert(dbRule); |
|||
// 测试 strategyCode 不匹配
|
|||
ruleMapper.insert(cloneIgnoreId(dbRule, o -> o.setStrategyCode(null))); |
|||
// 测试 priority 不匹配
|
|||
ruleMapper.insert(cloneIgnoreId(dbRule, o -> o.setPriority(null))); |
|||
// 测试 code 不匹配
|
|||
ruleMapper.insert(cloneIgnoreId(dbRule, o -> o.setCode(null))); |
|||
// 测试 name 不匹配
|
|||
ruleMapper.insert(cloneIgnoreId(dbRule, o -> o.setName(null))); |
|||
// 测试 description 不匹配
|
|||
ruleMapper.insert(cloneIgnoreId(dbRule, o -> o.setDescription(null))); |
|||
// 测试 condition 不匹配
|
|||
ruleMapper.insert(cloneIgnoreId(dbRule, o -> o.setCondition(null))); |
|||
// 测试 configuration 不匹配
|
|||
ruleMapper.insert(cloneIgnoreId(dbRule, o -> o.setConfiguration(null))); |
|||
// 准备参数
|
|||
RuleExportReqVO reqVO = new RuleExportReqVO(); |
|||
reqVO.setStrategyCode(null); |
|||
reqVO.setPriority(null); |
|||
reqVO.setCode(null); |
|||
reqVO.setName(null); |
|||
reqVO.setDescription(null); |
|||
reqVO.setCondition(null); |
|||
reqVO.setConfiguration(null); |
|||
|
|||
// 调用
|
|||
List<RuleDO> list = ruleService.getRuleList(reqVO); |
|||
// 断言
|
|||
assertEquals(1, list.size()); |
|||
assertPojoEquals(dbRule, list.get(0)); |
|||
} |
|||
|
|||
} |
@ -1,236 +0,0 @@ |
|||
package com.win.module.wms.service.shift; |
|||
|
|||
import com.win.module.wms.controller.shift.vo.ShiftCreateReqVO; |
|||
import com.win.module.wms.controller.shift.vo.ShiftExportReqVO; |
|||
import com.win.module.wms.controller.shift.vo.ShiftPageReqVO; |
|||
import com.win.module.wms.controller.shift.vo.ShiftUpdateReqVO; |
|||
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.shift.ShiftDO; |
|||
import com.win.module.wms.dal.mysql.shift.ShiftMapper; |
|||
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.date.LocalDateTimeUtils.*; |
|||
import static com.win.framework.common.util.object.ObjectUtils.*; |
|||
import static org.junit.jupiter.api.Assertions.*; |
|||
|
|||
/** |
|||
* {@link ShiftServiceImpl} 的单元测试类 |
|||
* |
|||
* @author 超级管理员 |
|||
*/ |
|||
@Import(ShiftServiceImpl.class) |
|||
public class ShiftServiceImplTest extends BaseDbUnitTest { |
|||
|
|||
@Resource |
|||
private ShiftServiceImpl shiftService; |
|||
|
|||
@Resource |
|||
private ShiftMapper shiftMapper; |
|||
|
|||
@Test |
|||
public void testCreateShift_success() { |
|||
// 准备参数
|
|||
ShiftCreateReqVO reqVO = randomPojo(ShiftCreateReqVO.class); |
|||
|
|||
// 调用
|
|||
Long shiftId = shiftService.createShift(reqVO); |
|||
// 断言
|
|||
assertNotNull(shiftId); |
|||
// 校验记录的属性是否正确
|
|||
ShiftDO shift = shiftMapper.selectById(shiftId); |
|||
assertPojoEquals(reqVO, shift); |
|||
} |
|||
|
|||
@Test |
|||
public void testUpdateShift_success() { |
|||
// mock 数据
|
|||
ShiftDO dbShift = randomPojo(ShiftDO.class); |
|||
shiftMapper.insert(dbShift);// @Sql: 先插入出一条存在的数据
|
|||
// 准备参数
|
|||
ShiftUpdateReqVO reqVO = randomPojo(ShiftUpdateReqVO.class, o -> { |
|||
o.setId(dbShift.getId()); // 设置更新的 ID
|
|||
}); |
|||
|
|||
// 调用
|
|||
shiftService.updateShift(reqVO); |
|||
// 校验是否更新正确
|
|||
ShiftDO shift = shiftMapper.selectById(reqVO.getId()); // 获取最新的
|
|||
assertPojoEquals(reqVO, shift); |
|||
} |
|||
|
|||
@Test |
|||
public void testUpdateShift_notExists() { |
|||
// 准备参数
|
|||
ShiftUpdateReqVO reqVO = randomPojo(ShiftUpdateReqVO.class); |
|||
|
|||
// 调用, 并断言异常
|
|||
assertServiceException(() -> shiftService.updateShift(reqVO), SHIFT_NOT_EXISTS); |
|||
} |
|||
|
|||
@Test |
|||
public void testDeleteShift_success() { |
|||
// mock 数据
|
|||
ShiftDO dbShift = randomPojo(ShiftDO.class); |
|||
shiftMapper.insert(dbShift);// @Sql: 先插入出一条存在的数据
|
|||
// 准备参数
|
|||
Long id = dbShift.getId(); |
|||
|
|||
// 调用
|
|||
shiftService.deleteShift(id); |
|||
// 校验数据不存在了
|
|||
assertNull(shiftMapper.selectById(id)); |
|||
} |
|||
|
|||
@Test |
|||
public void testDeleteShift_notExists() { |
|||
// 准备参数
|
|||
Long id = randomLongId(); |
|||
|
|||
// 调用, 并断言异常
|
|||
assertServiceException(() -> shiftService.deleteShift(id), SHIFT_NOT_EXISTS); |
|||
} |
|||
|
|||
@Test |
|||
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
|
|||
public void testGetShiftPage() { |
|||
// mock 数据
|
|||
ShiftDO dbShift = randomPojo(ShiftDO.class, o -> { // 等会查询到
|
|||
o.setCode(null); |
|||
o.setName(null); |
|||
o.setDescription(null); |
|||
o.setBeginTime(null); |
|||
o.setEntTime(null); |
|||
o.setActiveTime(null); |
|||
o.setExpireTime(null); |
|||
o.setRemark(null); |
|||
o.setCreateTime(null); |
|||
o.setCreator(null); |
|||
o.setEndAtNextDay(null); |
|||
o.setAvailable(null); |
|||
}); |
|||
shiftMapper.insert(dbShift); |
|||
// 测试 code 不匹配
|
|||
shiftMapper.insert(cloneIgnoreId(dbShift, o -> o.setCode(null))); |
|||
// 测试 name 不匹配
|
|||
shiftMapper.insert(cloneIgnoreId(dbShift, o -> o.setName(null))); |
|||
// 测试 description 不匹配
|
|||
shiftMapper.insert(cloneIgnoreId(dbShift, o -> o.setDescription(null))); |
|||
// 测试 beginTime 不匹配
|
|||
shiftMapper.insert(cloneIgnoreId(dbShift, o -> o.setBeginTime(null))); |
|||
// 测试 entTime 不匹配
|
|||
shiftMapper.insert(cloneIgnoreId(dbShift, o -> o.setEntTime(null))); |
|||
// 测试 activeTime 不匹配
|
|||
shiftMapper.insert(cloneIgnoreId(dbShift, o -> o.setActiveTime(null))); |
|||
// 测试 expireTime 不匹配
|
|||
shiftMapper.insert(cloneIgnoreId(dbShift, o -> o.setExpireTime(null))); |
|||
// 测试 remark 不匹配
|
|||
shiftMapper.insert(cloneIgnoreId(dbShift, o -> o.setRemark(null))); |
|||
// 测试 createTime 不匹配
|
|||
shiftMapper.insert(cloneIgnoreId(dbShift, o -> o.setCreateTime(null))); |
|||
// 测试 creator 不匹配
|
|||
shiftMapper.insert(cloneIgnoreId(dbShift, o -> o.setCreator(null))); |
|||
// 测试 endAtNextDay 不匹配
|
|||
shiftMapper.insert(cloneIgnoreId(dbShift, o -> o.setEndAtNextDay(null))); |
|||
// 测试 available 不匹配
|
|||
shiftMapper.insert(cloneIgnoreId(dbShift, o -> o.setAvailable(null))); |
|||
// 准备参数
|
|||
ShiftPageReqVO reqVO = new ShiftPageReqVO(); |
|||
reqVO.setCode(null); |
|||
reqVO.setName(null); |
|||
reqVO.setDescription(null); |
|||
reqVO.setBeginTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); |
|||
reqVO.setEntTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); |
|||
reqVO.setActiveTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); |
|||
reqVO.setExpireTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); |
|||
reqVO.setRemark(null); |
|||
reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); |
|||
reqVO.setCreator(null); |
|||
reqVO.setEndAtNextDay(null); |
|||
reqVO.setAvailable(null); |
|||
|
|||
// 调用
|
|||
PageResult<ShiftDO> pageResult = shiftService.getShiftPage(reqVO); |
|||
// 断言
|
|||
assertEquals(1, pageResult.getTotal()); |
|||
assertEquals(1, pageResult.getList().size()); |
|||
assertPojoEquals(dbShift, pageResult.getList().get(0)); |
|||
} |
|||
|
|||
@Test |
|||
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
|
|||
public void testGetShiftList() { |
|||
// mock 数据
|
|||
ShiftDO dbShift = randomPojo(ShiftDO.class, o -> { // 等会查询到
|
|||
o.setCode(null); |
|||
o.setName(null); |
|||
o.setDescription(null); |
|||
o.setBeginTime(null); |
|||
o.setEntTime(null); |
|||
o.setActiveTime(null); |
|||
o.setExpireTime(null); |
|||
o.setRemark(null); |
|||
o.setCreateTime(null); |
|||
o.setCreator(null); |
|||
o.setEndAtNextDay(null); |
|||
o.setAvailable(null); |
|||
}); |
|||
shiftMapper.insert(dbShift); |
|||
// 测试 code 不匹配
|
|||
shiftMapper.insert(cloneIgnoreId(dbShift, o -> o.setCode(null))); |
|||
// 测试 name 不匹配
|
|||
shiftMapper.insert(cloneIgnoreId(dbShift, o -> o.setName(null))); |
|||
// 测试 description 不匹配
|
|||
shiftMapper.insert(cloneIgnoreId(dbShift, o -> o.setDescription(null))); |
|||
// 测试 beginTime 不匹配
|
|||
shiftMapper.insert(cloneIgnoreId(dbShift, o -> o.setBeginTime(null))); |
|||
// 测试 entTime 不匹配
|
|||
shiftMapper.insert(cloneIgnoreId(dbShift, o -> o.setEntTime(null))); |
|||
// 测试 activeTime 不匹配
|
|||
shiftMapper.insert(cloneIgnoreId(dbShift, o -> o.setActiveTime(null))); |
|||
// 测试 expireTime 不匹配
|
|||
shiftMapper.insert(cloneIgnoreId(dbShift, o -> o.setExpireTime(null))); |
|||
// 测试 remark 不匹配
|
|||
shiftMapper.insert(cloneIgnoreId(dbShift, o -> o.setRemark(null))); |
|||
// 测试 createTime 不匹配
|
|||
shiftMapper.insert(cloneIgnoreId(dbShift, o -> o.setCreateTime(null))); |
|||
// 测试 creator 不匹配
|
|||
shiftMapper.insert(cloneIgnoreId(dbShift, o -> o.setCreator(null))); |
|||
// 测试 endAtNextDay 不匹配
|
|||
shiftMapper.insert(cloneIgnoreId(dbShift, o -> o.setEndAtNextDay(null))); |
|||
// 测试 available 不匹配
|
|||
shiftMapper.insert(cloneIgnoreId(dbShift, o -> o.setAvailable(null))); |
|||
// 准备参数
|
|||
ShiftExportReqVO reqVO = new ShiftExportReqVO(); |
|||
reqVO.setCode(null); |
|||
reqVO.setName(null); |
|||
reqVO.setDescription(null); |
|||
reqVO.setBeginTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); |
|||
reqVO.setEntTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); |
|||
reqVO.setActiveTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); |
|||
reqVO.setExpireTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); |
|||
reqVO.setRemark(null); |
|||
reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); |
|||
reqVO.setCreator(null); |
|||
reqVO.setEndAtNextDay(null); |
|||
reqVO.setAvailable(null); |
|||
|
|||
// 调用
|
|||
List<ShiftDO> list = shiftService.getShiftList(reqVO); |
|||
// 断言
|
|||
assertEquals(1, list.size()); |
|||
assertPojoEquals(dbShift, list.get(0)); |
|||
} |
|||
|
|||
} |
@ -1,220 +0,0 @@ |
|||
package com.win.module.wms.service.team; |
|||
|
|||
import com.win.module.wms.controller.team.vo.TeamCreateReqVO; |
|||
import com.win.module.wms.controller.team.vo.TeamExportReqVO; |
|||
import com.win.module.wms.controller.team.vo.TeamPageReqVO; |
|||
import com.win.module.wms.controller.team.vo.TeamUpdateReqVO; |
|||
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.team.TeamDO; |
|||
import com.win.module.wms.dal.mysql.team.TeamMapper; |
|||
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.date.LocalDateTimeUtils.*; |
|||
import static com.win.framework.common.util.object.ObjectUtils.*; |
|||
import static org.junit.jupiter.api.Assertions.*; |
|||
|
|||
/** |
|||
* {@link TeamServiceImpl} 的单元测试类 |
|||
* |
|||
* @author 超级管理员 |
|||
*/ |
|||
@Import(TeamServiceImpl.class) |
|||
public class TeamServiceImplTest extends BaseDbUnitTest { |
|||
|
|||
@Resource |
|||
private TeamServiceImpl teamService; |
|||
|
|||
@Resource |
|||
private TeamMapper teamMapper; |
|||
|
|||
@Test |
|||
public void testCreateTeam_success() { |
|||
// 准备参数
|
|||
TeamCreateReqVO reqVO = randomPojo(TeamCreateReqVO.class); |
|||
|
|||
// 调用
|
|||
Long teamId = teamService.createTeam(reqVO); |
|||
// 断言
|
|||
assertNotNull(teamId); |
|||
// 校验记录的属性是否正确
|
|||
TeamDO team = teamMapper.selectById(teamId); |
|||
assertPojoEquals(reqVO, team); |
|||
} |
|||
|
|||
@Test |
|||
public void testUpdateTeam_success() { |
|||
// mock 数据
|
|||
TeamDO dbTeam = randomPojo(TeamDO.class); |
|||
teamMapper.insert(dbTeam);// @Sql: 先插入出一条存在的数据
|
|||
// 准备参数
|
|||
TeamUpdateReqVO reqVO = randomPojo(TeamUpdateReqVO.class, o -> { |
|||
o.setId(dbTeam.getId()); // 设置更新的 ID
|
|||
}); |
|||
|
|||
// 调用
|
|||
teamService.updateTeam(reqVO); |
|||
// 校验是否更新正确
|
|||
TeamDO team = teamMapper.selectById(reqVO.getId()); // 获取最新的
|
|||
assertPojoEquals(reqVO, team); |
|||
} |
|||
|
|||
@Test |
|||
public void testUpdateTeam_notExists() { |
|||
// 准备参数
|
|||
TeamUpdateReqVO reqVO = randomPojo(TeamUpdateReqVO.class); |
|||
|
|||
// 调用, 并断言异常
|
|||
assertServiceException(() -> teamService.updateTeam(reqVO), TEAM_NOT_EXISTS); |
|||
} |
|||
|
|||
@Test |
|||
public void testDeleteTeam_success() { |
|||
// mock 数据
|
|||
TeamDO dbTeam = randomPojo(TeamDO.class); |
|||
teamMapper.insert(dbTeam);// @Sql: 先插入出一条存在的数据
|
|||
// 准备参数
|
|||
Long id = dbTeam.getId(); |
|||
|
|||
// 调用
|
|||
teamService.deleteTeam(id); |
|||
// 校验数据不存在了
|
|||
assertNull(teamMapper.selectById(id)); |
|||
} |
|||
|
|||
@Test |
|||
public void testDeleteTeam_notExists() { |
|||
// 准备参数
|
|||
Long id = randomLongId(); |
|||
|
|||
// 调用, 并断言异常
|
|||
assertServiceException(() -> teamService.deleteTeam(id), TEAM_NOT_EXISTS); |
|||
} |
|||
|
|||
@Test |
|||
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
|
|||
public void testGetTeamPage() { |
|||
// mock 数据
|
|||
TeamDO dbTeam = randomPojo(TeamDO.class, o -> { // 等会查询到
|
|||
o.setCode(null); |
|||
o.setName(null); |
|||
o.setDescription(null); |
|||
o.setMembers(null); |
|||
o.setActiveTime(null); |
|||
o.setExpireTime(null); |
|||
o.setRemark(null); |
|||
o.setCreateTime(null); |
|||
o.setCreator(null); |
|||
o.setAvailable(null); |
|||
}); |
|||
teamMapper.insert(dbTeam); |
|||
// 测试 code 不匹配
|
|||
teamMapper.insert(cloneIgnoreId(dbTeam, o -> o.setCode(null))); |
|||
// 测试 name 不匹配
|
|||
teamMapper.insert(cloneIgnoreId(dbTeam, o -> o.setName(null))); |
|||
// 测试 description 不匹配
|
|||
teamMapper.insert(cloneIgnoreId(dbTeam, o -> o.setDescription(null))); |
|||
// 测试 members 不匹配
|
|||
teamMapper.insert(cloneIgnoreId(dbTeam, o -> o.setMembers(null))); |
|||
// 测试 activeTime 不匹配
|
|||
teamMapper.insert(cloneIgnoreId(dbTeam, o -> o.setActiveTime(null))); |
|||
// 测试 expireTime 不匹配
|
|||
teamMapper.insert(cloneIgnoreId(dbTeam, o -> o.setExpireTime(null))); |
|||
// 测试 remark 不匹配
|
|||
teamMapper.insert(cloneIgnoreId(dbTeam, o -> o.setRemark(null))); |
|||
// 测试 createTime 不匹配
|
|||
teamMapper.insert(cloneIgnoreId(dbTeam, o -> o.setCreateTime(null))); |
|||
// 测试 creator 不匹配
|
|||
teamMapper.insert(cloneIgnoreId(dbTeam, o -> o.setCreator(null))); |
|||
// 测试 available 不匹配
|
|||
teamMapper.insert(cloneIgnoreId(dbTeam, o -> o.setAvailable(null))); |
|||
// 准备参数
|
|||
TeamPageReqVO reqVO = new TeamPageReqVO(); |
|||
reqVO.setCode(null); |
|||
reqVO.setName(null); |
|||
reqVO.setDescription(null); |
|||
reqVO.setMembers(null); |
|||
reqVO.setActiveTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); |
|||
reqVO.setExpireTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); |
|||
reqVO.setRemark(null); |
|||
reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); |
|||
reqVO.setCreator(null); |
|||
reqVO.setAvailable(null); |
|||
|
|||
// 调用
|
|||
PageResult<TeamDO> pageResult = teamService.getTeamPage(reqVO); |
|||
// 断言
|
|||
assertEquals(1, pageResult.getTotal()); |
|||
assertEquals(1, pageResult.getList().size()); |
|||
assertPojoEquals(dbTeam, pageResult.getList().get(0)); |
|||
} |
|||
|
|||
@Test |
|||
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
|
|||
public void testGetTeamList() { |
|||
// mock 数据
|
|||
TeamDO dbTeam = randomPojo(TeamDO.class, o -> { // 等会查询到
|
|||
o.setCode(null); |
|||
o.setName(null); |
|||
o.setDescription(null); |
|||
o.setMembers(null); |
|||
o.setActiveTime(null); |
|||
o.setExpireTime(null); |
|||
o.setRemark(null); |
|||
o.setCreateTime(null); |
|||
o.setCreator(null); |
|||
o.setAvailable(null); |
|||
}); |
|||
teamMapper.insert(dbTeam); |
|||
// 测试 code 不匹配
|
|||
teamMapper.insert(cloneIgnoreId(dbTeam, o -> o.setCode(null))); |
|||
// 测试 name 不匹配
|
|||
teamMapper.insert(cloneIgnoreId(dbTeam, o -> o.setName(null))); |
|||
// 测试 description 不匹配
|
|||
teamMapper.insert(cloneIgnoreId(dbTeam, o -> o.setDescription(null))); |
|||
// 测试 members 不匹配
|
|||
teamMapper.insert(cloneIgnoreId(dbTeam, o -> o.setMembers(null))); |
|||
// 测试 activeTime 不匹配
|
|||
teamMapper.insert(cloneIgnoreId(dbTeam, o -> o.setActiveTime(null))); |
|||
// 测试 expireTime 不匹配
|
|||
teamMapper.insert(cloneIgnoreId(dbTeam, o -> o.setExpireTime(null))); |
|||
// 测试 remark 不匹配
|
|||
teamMapper.insert(cloneIgnoreId(dbTeam, o -> o.setRemark(null))); |
|||
// 测试 createTime 不匹配
|
|||
teamMapper.insert(cloneIgnoreId(dbTeam, o -> o.setCreateTime(null))); |
|||
// 测试 creator 不匹配
|
|||
teamMapper.insert(cloneIgnoreId(dbTeam, o -> o.setCreator(null))); |
|||
// 测试 available 不匹配
|
|||
teamMapper.insert(cloneIgnoreId(dbTeam, o -> o.setAvailable(null))); |
|||
// 准备参数
|
|||
TeamExportReqVO reqVO = new TeamExportReqVO(); |
|||
reqVO.setCode(null); |
|||
reqVO.setName(null); |
|||
reqVO.setDescription(null); |
|||
reqVO.setMembers(null); |
|||
reqVO.setActiveTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); |
|||
reqVO.setExpireTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); |
|||
reqVO.setRemark(null); |
|||
reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); |
|||
reqVO.setCreator(null); |
|||
reqVO.setAvailable(null); |
|||
|
|||
// 调用
|
|||
List<TeamDO> list = teamService.getTeamList(reqVO); |
|||
// 断言
|
|||
assertEquals(1, list.size()); |
|||
assertPojoEquals(dbTeam, list.get(0)); |
|||
} |
|||
|
|||
} |
@ -1,236 +0,0 @@ |
|||
package com.win.module.wms.service.transactiontype; |
|||
|
|||
import com.win.module.wms.controller.transactiontype.vo.TransactiontypeCreateReqVO; |
|||
import com.win.module.wms.controller.transactiontype.vo.TransactiontypeExportReqVO; |
|||
import com.win.module.wms.controller.transactiontype.vo.TransactiontypePageReqVO; |
|||
import com.win.module.wms.controller.transactiontype.vo.TransactiontypeUpdateReqVO; |
|||
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.transactiontype.TransactiontypeDO; |
|||
import com.win.module.wms.dal.mysql.transactiontype.TransactiontypeMapper; |
|||
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.date.LocalDateTimeUtils.*; |
|||
import static com.win.framework.common.util.object.ObjectUtils.*; |
|||
import static org.junit.jupiter.api.Assertions.*; |
|||
|
|||
/** |
|||
* {@link TransactiontypeServiceImpl} 的单元测试类 |
|||
* |
|||
* @author 超级管理员 |
|||
*/ |
|||
@Import(TransactiontypeServiceImpl.class) |
|||
public class TransactiontypeServiceImplTest extends BaseDbUnitTest { |
|||
|
|||
@Resource |
|||
private TransactiontypeServiceImpl transactiontypeService; |
|||
|
|||
@Resource |
|||
private TransactiontypeMapper transactiontypeMapper; |
|||
|
|||
@Test |
|||
public void testCreateTransactiontype_success() { |
|||
// 准备参数
|
|||
TransactiontypeCreateReqVO reqVO = randomPojo(TransactiontypeCreateReqVO.class); |
|||
|
|||
// 调用
|
|||
Long transactiontypeId = transactiontypeService.createTransactiontype(reqVO); |
|||
// 断言
|
|||
assertNotNull(transactiontypeId); |
|||
// 校验记录的属性是否正确
|
|||
TransactiontypeDO transactiontype = transactiontypeMapper.selectById(transactiontypeId); |
|||
assertPojoEquals(reqVO, transactiontype); |
|||
} |
|||
|
|||
@Test |
|||
public void testUpdateTransactiontype_success() { |
|||
// mock 数据
|
|||
TransactiontypeDO dbTransactiontype = randomPojo(TransactiontypeDO.class); |
|||
transactiontypeMapper.insert(dbTransactiontype);// @Sql: 先插入出一条存在的数据
|
|||
// 准备参数
|
|||
TransactiontypeUpdateReqVO reqVO = randomPojo(TransactiontypeUpdateReqVO.class, o -> { |
|||
o.setId(dbTransactiontype.getId()); // 设置更新的 ID
|
|||
}); |
|||
|
|||
// 调用
|
|||
transactiontypeService.updateTransactiontype(reqVO); |
|||
// 校验是否更新正确
|
|||
TransactiontypeDO transactiontype = transactiontypeMapper.selectById(reqVO.getId()); // 获取最新的
|
|||
assertPojoEquals(reqVO, transactiontype); |
|||
} |
|||
|
|||
@Test |
|||
public void testUpdateTransactiontype_notExists() { |
|||
// 准备参数
|
|||
TransactiontypeUpdateReqVO reqVO = randomPojo(TransactiontypeUpdateReqVO.class); |
|||
|
|||
// 调用, 并断言异常
|
|||
assertServiceException(() -> transactiontypeService.updateTransactiontype(reqVO), TRANSACTIONTYPE_NOT_EXISTS); |
|||
} |
|||
|
|||
@Test |
|||
public void testDeleteTransactiontype_success() { |
|||
// mock 数据
|
|||
TransactiontypeDO dbTransactiontype = randomPojo(TransactiontypeDO.class); |
|||
transactiontypeMapper.insert(dbTransactiontype);// @Sql: 先插入出一条存在的数据
|
|||
// 准备参数
|
|||
Long id = dbTransactiontype.getId(); |
|||
|
|||
// 调用
|
|||
transactiontypeService.deleteTransactiontype(id); |
|||
// 校验数据不存在了
|
|||
assertNull(transactiontypeMapper.selectById(id)); |
|||
} |
|||
|
|||
@Test |
|||
public void testDeleteTransactiontype_notExists() { |
|||
// 准备参数
|
|||
Long id = randomLongId(); |
|||
|
|||
// 调用, 并断言异常
|
|||
assertServiceException(() -> transactiontypeService.deleteTransactiontype(id), TRANSACTIONTYPE_NOT_EXISTS); |
|||
} |
|||
|
|||
@Test |
|||
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
|
|||
public void testGetTransactiontypePage() { |
|||
// mock 数据
|
|||
TransactiontypeDO dbTransactiontype = randomPojo(TransactiontypeDO.class, o -> { // 等会查询到
|
|||
o.setCode(null); |
|||
o.setName(null); |
|||
o.setDescription(null); |
|||
o.setInventoryAction(null); |
|||
o.setActiveTime(null); |
|||
o.setExpireTime(null); |
|||
o.setRemark(null); |
|||
o.setCreateTime(null); |
|||
o.setCreator(null); |
|||
o.setAllowNegative(null); |
|||
o.setAvailable(null); |
|||
o.setIsSoftDeleted(null); |
|||
}); |
|||
transactiontypeMapper.insert(dbTransactiontype); |
|||
// 测试 code 不匹配
|
|||
transactiontypeMapper.insert(cloneIgnoreId(dbTransactiontype, o -> o.setCode(null))); |
|||
// 测试 name 不匹配
|
|||
transactiontypeMapper.insert(cloneIgnoreId(dbTransactiontype, o -> o.setName(null))); |
|||
// 测试 description 不匹配
|
|||
transactiontypeMapper.insert(cloneIgnoreId(dbTransactiontype, o -> o.setDescription(null))); |
|||
// 测试 inventoryAction 不匹配
|
|||
transactiontypeMapper.insert(cloneIgnoreId(dbTransactiontype, o -> o.setInventoryAction(null))); |
|||
// 测试 activeTime 不匹配
|
|||
transactiontypeMapper.insert(cloneIgnoreId(dbTransactiontype, o -> o.setActiveTime(null))); |
|||
// 测试 expireTime 不匹配
|
|||
transactiontypeMapper.insert(cloneIgnoreId(dbTransactiontype, o -> o.setExpireTime(null))); |
|||
// 测试 remark 不匹配
|
|||
transactiontypeMapper.insert(cloneIgnoreId(dbTransactiontype, o -> o.setRemark(null))); |
|||
// 测试 createTime 不匹配
|
|||
transactiontypeMapper.insert(cloneIgnoreId(dbTransactiontype, o -> o.setCreateTime(null))); |
|||
// 测试 creator 不匹配
|
|||
transactiontypeMapper.insert(cloneIgnoreId(dbTransactiontype, o -> o.setCreator(null))); |
|||
// 测试 allowNegative 不匹配
|
|||
transactiontypeMapper.insert(cloneIgnoreId(dbTransactiontype, o -> o.setAllowNegative(null))); |
|||
// 测试 available 不匹配
|
|||
transactiontypeMapper.insert(cloneIgnoreId(dbTransactiontype, o -> o.setAvailable(null))); |
|||
// 测试 isSoftDeleted 不匹配
|
|||
transactiontypeMapper.insert(cloneIgnoreId(dbTransactiontype, o -> o.setIsSoftDeleted(null))); |
|||
// 准备参数
|
|||
TransactiontypePageReqVO reqVO = new TransactiontypePageReqVO(); |
|||
reqVO.setCode(null); |
|||
reqVO.setName(null); |
|||
reqVO.setDescription(null); |
|||
reqVO.setInventoryAction(null); |
|||
reqVO.setActiveTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); |
|||
reqVO.setExpireTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); |
|||
reqVO.setRemark(null); |
|||
reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); |
|||
reqVO.setCreator(null); |
|||
reqVO.setAllowNegative(null); |
|||
reqVO.setAvailable(null); |
|||
reqVO.setIsSoftDeleted(null); |
|||
|
|||
// 调用
|
|||
PageResult<TransactiontypeDO> pageResult = transactiontypeService.getTransactiontypePage(reqVO); |
|||
// 断言
|
|||
assertEquals(1, pageResult.getTotal()); |
|||
assertEquals(1, pageResult.getList().size()); |
|||
assertPojoEquals(dbTransactiontype, pageResult.getList().get(0)); |
|||
} |
|||
|
|||
@Test |
|||
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
|
|||
public void testGetTransactiontypeList() { |
|||
// mock 数据
|
|||
TransactiontypeDO dbTransactiontype = randomPojo(TransactiontypeDO.class, o -> { // 等会查询到
|
|||
o.setCode(null); |
|||
o.setName(null); |
|||
o.setDescription(null); |
|||
o.setInventoryAction(null); |
|||
o.setActiveTime(null); |
|||
o.setExpireTime(null); |
|||
o.setRemark(null); |
|||
o.setCreateTime(null); |
|||
o.setCreator(null); |
|||
o.setAllowNegative(null); |
|||
o.setAvailable(null); |
|||
o.setIsSoftDeleted(null); |
|||
}); |
|||
transactiontypeMapper.insert(dbTransactiontype); |
|||
// 测试 code 不匹配
|
|||
transactiontypeMapper.insert(cloneIgnoreId(dbTransactiontype, o -> o.setCode(null))); |
|||
// 测试 name 不匹配
|
|||
transactiontypeMapper.insert(cloneIgnoreId(dbTransactiontype, o -> o.setName(null))); |
|||
// 测试 description 不匹配
|
|||
transactiontypeMapper.insert(cloneIgnoreId(dbTransactiontype, o -> o.setDescription(null))); |
|||
// 测试 inventoryAction 不匹配
|
|||
transactiontypeMapper.insert(cloneIgnoreId(dbTransactiontype, o -> o.setInventoryAction(null))); |
|||
// 测试 activeTime 不匹配
|
|||
transactiontypeMapper.insert(cloneIgnoreId(dbTransactiontype, o -> o.setActiveTime(null))); |
|||
// 测试 expireTime 不匹配
|
|||
transactiontypeMapper.insert(cloneIgnoreId(dbTransactiontype, o -> o.setExpireTime(null))); |
|||
// 测试 remark 不匹配
|
|||
transactiontypeMapper.insert(cloneIgnoreId(dbTransactiontype, o -> o.setRemark(null))); |
|||
// 测试 createTime 不匹配
|
|||
transactiontypeMapper.insert(cloneIgnoreId(dbTransactiontype, o -> o.setCreateTime(null))); |
|||
// 测试 creator 不匹配
|
|||
transactiontypeMapper.insert(cloneIgnoreId(dbTransactiontype, o -> o.setCreator(null))); |
|||
// 测试 allowNegative 不匹配
|
|||
transactiontypeMapper.insert(cloneIgnoreId(dbTransactiontype, o -> o.setAllowNegative(null))); |
|||
// 测试 available 不匹配
|
|||
transactiontypeMapper.insert(cloneIgnoreId(dbTransactiontype, o -> o.setAvailable(null))); |
|||
// 测试 isSoftDeleted 不匹配
|
|||
transactiontypeMapper.insert(cloneIgnoreId(dbTransactiontype, o -> o.setIsSoftDeleted(null))); |
|||
// 准备参数
|
|||
TransactiontypeExportReqVO reqVO = new TransactiontypeExportReqVO(); |
|||
reqVO.setCode(null); |
|||
reqVO.setName(null); |
|||
reqVO.setDescription(null); |
|||
reqVO.setInventoryAction(null); |
|||
reqVO.setActiveTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); |
|||
reqVO.setExpireTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); |
|||
reqVO.setRemark(null); |
|||
reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); |
|||
reqVO.setCreator(null); |
|||
reqVO.setAllowNegative(null); |
|||
reqVO.setAvailable(null); |
|||
reqVO.setIsSoftDeleted(null); |
|||
|
|||
// 调用
|
|||
List<TransactiontypeDO> list = transactiontypeService.getTransactiontypeList(reqVO); |
|||
// 断言
|
|||
assertEquals(1, list.size()); |
|||
assertPojoEquals(dbTransactiontype, list.get(0)); |
|||
} |
|||
|
|||
} |
Loading…
Reference in new issue