商品spu和sku测试类调整

pull/2/head
franky 2022-05-18 14:47:58 +08:00
parent e314f4aaeb
commit a86cbde090
2 changed files with 53 additions and 61 deletions

View File

@ -99,7 +99,7 @@ public class SkuServiceImplTest extends BaseDbUnitTest {
// 准备参数 // 准备参数
Integer id = 1; Integer id = 1;
// 调用, 并断言异常spu // 调用, 并断言异常
assertServiceException(() -> skuService.deleteSku(id), SKU_NOT_EXISTS); assertServiceException(() -> skuService.deleteSku(id), SKU_NOT_EXISTS);
} }
@ -108,25 +108,21 @@ public class SkuServiceImplTest extends BaseDbUnitTest {
public void testGetSkuPage() { public void testGetSkuPage() {
// mock 数据 // mock 数据
SkuDO dbSku = randomPojo(SkuDO.class, o -> { // 等会查询到 SkuDO dbSku = randomPojo(SkuDO.class, o -> { // 等会查询到
o.setCreateTime(null);
o.setSpuId(null); o.setSpuId(null);
o.setSkuStatus(null); o.setProperties(null);
o.setAttrs(null);
o.setPrice(null); o.setPrice(null);
o.setOriginalPrice(null); o.setOriginalPrice(null);
o.setCostPrice(null); o.setCostPrice(null);
o.setBarCode(null); o.setBarCode(null);
o.setPicUrl(null); o.setPicUrl(null);
o.setStatus(null);
o.setCreateTime(null);
}); });
skuMapper.insert(dbSku); skuMapper.insert(dbSku);
// 测试 createTime 不匹配
skuMapper.insert(cloneIgnoreId(dbSku, o -> o.setCreateTime(null)));
// 测试 spuId 不匹配 // 测试 spuId 不匹配
skuMapper.insert(cloneIgnoreId(dbSku, o -> o.setSpuId(null))); skuMapper.insert(cloneIgnoreId(dbSku, o -> o.setSpuId(null)));
// 测试 skuStatus 不匹配 // 测试 properties 不匹配
skuMapper.insert(cloneIgnoreId(dbSku, o -> o.setSkuStatus(null))); skuMapper.insert(cloneIgnoreId(dbSku, o -> o.setProperties(null)));
// 测试 attrs 不匹配
skuMapper.insert(cloneIgnoreId(dbSku, o -> o.setAttrs(null)));
// 测试 price 不匹配 // 测试 price 不匹配
skuMapper.insert(cloneIgnoreId(dbSku, o -> o.setPrice(null))); skuMapper.insert(cloneIgnoreId(dbSku, o -> o.setPrice(null)));
// 测试 originalPrice 不匹配 // 测试 originalPrice 不匹配
@ -137,18 +133,22 @@ public class SkuServiceImplTest extends BaseDbUnitTest {
skuMapper.insert(cloneIgnoreId(dbSku, o -> o.setBarCode(null))); skuMapper.insert(cloneIgnoreId(dbSku, o -> o.setBarCode(null)));
// 测试 picUrl 不匹配 // 测试 picUrl 不匹配
skuMapper.insert(cloneIgnoreId(dbSku, o -> o.setPicUrl(null))); skuMapper.insert(cloneIgnoreId(dbSku, o -> o.setPicUrl(null)));
// 测试 status 不匹配
skuMapper.insert(cloneIgnoreId(dbSku, o -> o.setStatus(null)));
// 测试 createTime 不匹配
skuMapper.insert(cloneIgnoreId(dbSku, o -> o.setCreateTime(null)));
// 准备参数 // 准备参数
SkuPageReqVO reqVO = new SkuPageReqVO(); SkuPageReqVO reqVO = new SkuPageReqVO();
reqVO.setBeginCreateTime(null);
reqVO.setEndCreateTime(null);
reqVO.setSpuId(null); reqVO.setSpuId(null);
reqVO.setSkuStatus(null); reqVO.setProperties(null);
reqVO.setAttrs(null);
reqVO.setPrice(null); reqVO.setPrice(null);
reqVO.setOriginalPrice(null); reqVO.setOriginalPrice(null);
reqVO.setCostPrice(null); reqVO.setCostPrice(null);
reqVO.setBarCode(null); reqVO.setBarCode(null);
reqVO.setPicUrl(null); reqVO.setPicUrl(null);
reqVO.setStatus(null);
reqVO.setBeginCreateTime(null);
reqVO.setEndCreateTime(null);
// 调用 // 调用
PageResult<SkuDO> pageResult = skuService.getSkuPage(reqVO); PageResult<SkuDO> pageResult = skuService.getSkuPage(reqVO);
@ -163,25 +163,21 @@ public class SkuServiceImplTest extends BaseDbUnitTest {
public void testGetSkuList() { public void testGetSkuList() {
// mock 数据 // mock 数据
SkuDO dbSku = randomPojo(SkuDO.class, o -> { // 等会查询到 SkuDO dbSku = randomPojo(SkuDO.class, o -> { // 等会查询到
o.setCreateTime(null);
o.setSpuId(null); o.setSpuId(null);
o.setSkuStatus(null); o.setProperties(null);
o.setAttrs(null);
o.setPrice(null); o.setPrice(null);
o.setOriginalPrice(null); o.setOriginalPrice(null);
o.setCostPrice(null); o.setCostPrice(null);
o.setBarCode(null); o.setBarCode(null);
o.setPicUrl(null); o.setPicUrl(null);
o.setStatus(null);
o.setCreateTime(null);
}); });
skuMapper.insert(dbSku); skuMapper.insert(dbSku);
// 测试 createTime 不匹配
skuMapper.insert(cloneIgnoreId(dbSku, o -> o.setCreateTime(null)));
// 测试 spuId 不匹配 // 测试 spuId 不匹配
skuMapper.insert(cloneIgnoreId(dbSku, o -> o.setSpuId(null))); skuMapper.insert(cloneIgnoreId(dbSku, o -> o.setSpuId(null)));
// 测试 skuStatus 不匹配 // 测试 properties 不匹配
skuMapper.insert(cloneIgnoreId(dbSku, o -> o.setSkuStatus(null))); skuMapper.insert(cloneIgnoreId(dbSku, o -> o.setProperties(null)));
// 测试 attrs 不匹配
skuMapper.insert(cloneIgnoreId(dbSku, o -> o.setAttrs(null)));
// 测试 price 不匹配 // 测试 price 不匹配
skuMapper.insert(cloneIgnoreId(dbSku, o -> o.setPrice(null))); skuMapper.insert(cloneIgnoreId(dbSku, o -> o.setPrice(null)));
// 测试 originalPrice 不匹配 // 测试 originalPrice 不匹配
@ -192,18 +188,22 @@ public class SkuServiceImplTest extends BaseDbUnitTest {
skuMapper.insert(cloneIgnoreId(dbSku, o -> o.setBarCode(null))); skuMapper.insert(cloneIgnoreId(dbSku, o -> o.setBarCode(null)));
// 测试 picUrl 不匹配 // 测试 picUrl 不匹配
skuMapper.insert(cloneIgnoreId(dbSku, o -> o.setPicUrl(null))); skuMapper.insert(cloneIgnoreId(dbSku, o -> o.setPicUrl(null)));
// 测试 status 不匹配
skuMapper.insert(cloneIgnoreId(dbSku, o -> o.setStatus(null)));
// 测试 createTime 不匹配
skuMapper.insert(cloneIgnoreId(dbSku, o -> o.setCreateTime(null)));
// 准备参数 // 准备参数
SkuExportReqVO reqVO = new SkuExportReqVO(); SkuExportReqVO reqVO = new SkuExportReqVO();
reqVO.setBeginCreateTime(null);
reqVO.setEndCreateTime(null);
reqVO.setSpuId(null); reqVO.setSpuId(null);
reqVO.setSkuStatus(null); reqVO.setProperties(null);
reqVO.setAttrs(null);
reqVO.setPrice(null); reqVO.setPrice(null);
reqVO.setOriginalPrice(null); reqVO.setOriginalPrice(null);
reqVO.setCostPrice(null); reqVO.setCostPrice(null);
reqVO.setBarCode(null); reqVO.setBarCode(null);
reqVO.setPicUrl(null); reqVO.setPicUrl(null);
reqVO.setStatus(null);
reqVO.setBeginCreateTime(null);
reqVO.setEndCreateTime(null);
// 调用 // 调用
List<SkuDO> list = skuService.getSkuList(reqVO); List<SkuDO> list = skuService.getSkuList(reqVO);

View File

@ -108,34 +108,27 @@ public class SpuServiceImplTest extends BaseDbUnitTest {
public void testGetSpuPage() { public void testGetSpuPage() {
// mock 数据 // mock 数据
SpuDO dbSpu = randomPojo(SpuDO.class, o -> { // 等会查询到 SpuDO dbSpu = randomPojo(SpuDO.class, o -> { // 等会查询到
o.setCreateTime(null);
o.setName(null); o.setName(null);
o.setVisible(null);
o.setSellPoint(null); o.setSellPoint(null);
o.setDescription(null); o.setDescription(null);
o.setCid(null); o.setCategoryId(null);
o.setListPicUrl(null);
o.setPicUrls(null); o.setPicUrls(null);
o.setSort(null); o.setSort(null);
o.setLikeCount(null); o.setLikeCount(null);
o.setPrice(null); o.setPrice(null);
o.setQuantity(null); o.setQuantity(null);
o.setStatus(null);
o.setCreateTime(null);
}); });
spuMapper.insert(dbSpu); spuMapper.insert(dbSpu);
// 测试 createTime 不匹配
spuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setCreateTime(null)));
// 测试 name 不匹配 // 测试 name 不匹配
spuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setName(null))); spuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setName(null)));
// 测试 visible 不匹配
spuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setVisible(null)));
// 测试 sellPoint 不匹配 // 测试 sellPoint 不匹配
spuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setSellPoint(null))); spuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setSellPoint(null)));
// 测试 description 不匹配 // 测试 description 不匹配
spuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setDescription(null))); spuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setDescription(null)));
// 测试 cid 不匹配 // 测试 categoryId 不匹配
spuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setCid(null))); spuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setCategoryId(null)));
// 测试 listPicUrl 不匹配
spuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setListPicUrl(null)));
// 测试 picUrls 不匹配 // 测试 picUrls 不匹配
spuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setPicUrls(null))); spuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setPicUrls(null)));
// 测试 sort 不匹配 // 测试 sort 不匹配
@ -146,21 +139,24 @@ public class SpuServiceImplTest extends BaseDbUnitTest {
spuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setPrice(null))); spuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setPrice(null)));
// 测试 quantity 不匹配 // 测试 quantity 不匹配
spuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setQuantity(null))); spuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setQuantity(null)));
// 测试 status 不匹配
spuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setStatus(null)));
// 测试 createTime 不匹配
spuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setCreateTime(null)));
// 准备参数 // 准备参数
SpuPageReqVO reqVO = new SpuPageReqVO(); SpuPageReqVO reqVO = new SpuPageReqVO();
reqVO.setBeginCreateTime(null);
reqVO.setEndCreateTime(null);
reqVO.setName(null); reqVO.setName(null);
reqVO.setVisible(null);
reqVO.setSellPoint(null); reqVO.setSellPoint(null);
reqVO.setDescription(null); reqVO.setDescription(null);
reqVO.setCid(null); reqVO.setCategoryId(null);
reqVO.setListPicUrl(null);
reqVO.setPicUrls(null); reqVO.setPicUrls(null);
reqVO.setSort(null); reqVO.setSort(null);
reqVO.setLikeCount(null); reqVO.setLikeCount(null);
reqVO.setPrice(null); reqVO.setPrice(null);
reqVO.setQuantity(null); reqVO.setQuantity(null);
reqVO.setStatus(null);
reqVO.setBeginCreateTime(null);
reqVO.setEndCreateTime(null);
// 调用 // 调用
PageResult<SpuDO> pageResult = spuService.getSpuPage(reqVO); PageResult<SpuDO> pageResult = spuService.getSpuPage(reqVO);
@ -175,34 +171,27 @@ public class SpuServiceImplTest extends BaseDbUnitTest {
public void testGetSpuList() { public void testGetSpuList() {
// mock 数据 // mock 数据
SpuDO dbSpu = randomPojo(SpuDO.class, o -> { // 等会查询到 SpuDO dbSpu = randomPojo(SpuDO.class, o -> { // 等会查询到
o.setCreateTime(null);
o.setName(null); o.setName(null);
o.setVisible(null);
o.setSellPoint(null); o.setSellPoint(null);
o.setDescription(null); o.setDescription(null);
o.setCid(null); o.setCategoryId(null);
o.setListPicUrl(null);
o.setPicUrls(null); o.setPicUrls(null);
o.setSort(null); o.setSort(null);
o.setLikeCount(null); o.setLikeCount(null);
o.setPrice(null); o.setPrice(null);
o.setQuantity(null); o.setQuantity(null);
o.setStatus(null);
o.setCreateTime(null);
}); });
spuMapper.insert(dbSpu); spuMapper.insert(dbSpu);
// 测试 createTime 不匹配
spuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setCreateTime(null)));
// 测试 name 不匹配 // 测试 name 不匹配
spuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setName(null))); spuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setName(null)));
// 测试 visible 不匹配
spuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setVisible(null)));
// 测试 sellPoint 不匹配 // 测试 sellPoint 不匹配
spuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setSellPoint(null))); spuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setSellPoint(null)));
// 测试 description 不匹配 // 测试 description 不匹配
spuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setDescription(null))); spuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setDescription(null)));
// 测试 cid 不匹配 // 测试 categoryId 不匹配
spuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setCid(null))); spuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setCategoryId(null)));
// 测试 listPicUrl 不匹配
spuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setListPicUrl(null)));
// 测试 picUrls 不匹配 // 测试 picUrls 不匹配
spuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setPicUrls(null))); spuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setPicUrls(null)));
// 测试 sort 不匹配 // 测试 sort 不匹配
@ -213,21 +202,24 @@ public class SpuServiceImplTest extends BaseDbUnitTest {
spuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setPrice(null))); spuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setPrice(null)));
// 测试 quantity 不匹配 // 测试 quantity 不匹配
spuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setQuantity(null))); spuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setQuantity(null)));
// 测试 status 不匹配
spuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setStatus(null)));
// 测试 createTime 不匹配
spuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setCreateTime(null)));
// 准备参数 // 准备参数
SpuExportReqVO reqVO = new SpuExportReqVO(); SpuExportReqVO reqVO = new SpuExportReqVO();
reqVO.setBeginCreateTime(null);
reqVO.setEndCreateTime(null);
reqVO.setName(null); reqVO.setName(null);
reqVO.setVisible(null);
reqVO.setSellPoint(null); reqVO.setSellPoint(null);
reqVO.setDescription(null); reqVO.setDescription(null);
reqVO.setCid(null); reqVO.setCategoryId(null);
reqVO.setListPicUrl(null);
reqVO.setPicUrls(null); reqVO.setPicUrls(null);
reqVO.setSort(null); reqVO.setSort(null);
reqVO.setLikeCount(null); reqVO.setLikeCount(null);
reqVO.setPrice(null); reqVO.setPrice(null);
reqVO.setQuantity(null); reqVO.setQuantity(null);
reqVO.setStatus(null);
reqVO.setBeginCreateTime(null);
reqVO.setEndCreateTime(null);
// 调用 // 调用
List<SpuDO> list = spuService.getSpuList(reqVO); List<SpuDO> list = spuService.getSpuList(reqVO);