From a86cbde090569cf6c6850ab44000ee7ef8ca8042 Mon Sep 17 00:00:00 2001 From: franky <16621167566@163.com> Date: Wed, 18 May 2022 14:47:58 +0800 Subject: [PATCH] =?UTF-8?q?=E5=95=86=E5=93=81spu=E5=92=8Csku=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E7=B1=BB=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/sku/SkuServiceImplTest.java | 54 ++++++++--------- .../service/spu/SpuServiceImplTest.java | 60 ++++++++----------- 2 files changed, 53 insertions(+), 61 deletions(-) diff --git a/yudao-module-mall/yudao-module-product-biz/src/test/java/cn/iocoder/yudao/module/product/service/sku/SkuServiceImplTest.java b/yudao-module-mall/yudao-module-product-biz/src/test/java/cn/iocoder/yudao/module/product/service/sku/SkuServiceImplTest.java index 3653df03f..1b2085bd5 100755 --- a/yudao-module-mall/yudao-module-product-biz/src/test/java/cn/iocoder/yudao/module/product/service/sku/SkuServiceImplTest.java +++ b/yudao-module-mall/yudao-module-product-biz/src/test/java/cn/iocoder/yudao/module/product/service/sku/SkuServiceImplTest.java @@ -99,7 +99,7 @@ public class SkuServiceImplTest extends BaseDbUnitTest { // 准备参数 Integer id = 1; - // 调用, 并断言异常spu + // 调用, 并断言异常 assertServiceException(() -> skuService.deleteSku(id), SKU_NOT_EXISTS); } @@ -108,25 +108,21 @@ public class SkuServiceImplTest extends BaseDbUnitTest { public void testGetSkuPage() { // mock 数据 SkuDO dbSku = randomPojo(SkuDO.class, o -> { // 等会查询到 - o.setCreateTime(null); o.setSpuId(null); - o.setSkuStatus(null); - o.setAttrs(null); + o.setProperties(null); o.setPrice(null); o.setOriginalPrice(null); o.setCostPrice(null); o.setBarCode(null); o.setPicUrl(null); + o.setStatus(null); + o.setCreateTime(null); }); skuMapper.insert(dbSku); - // 测试 createTime 不匹配 - skuMapper.insert(cloneIgnoreId(dbSku, o -> o.setCreateTime(null))); // 测试 spuId 不匹配 skuMapper.insert(cloneIgnoreId(dbSku, o -> o.setSpuId(null))); - // 测试 skuStatus 不匹配 - skuMapper.insert(cloneIgnoreId(dbSku, o -> o.setSkuStatus(null))); - // 测试 attrs 不匹配 - skuMapper.insert(cloneIgnoreId(dbSku, o -> o.setAttrs(null))); + // 测试 properties 不匹配 + skuMapper.insert(cloneIgnoreId(dbSku, o -> o.setProperties(null))); // 测试 price 不匹配 skuMapper.insert(cloneIgnoreId(dbSku, o -> o.setPrice(null))); // 测试 originalPrice 不匹配 @@ -137,18 +133,22 @@ public class SkuServiceImplTest extends BaseDbUnitTest { skuMapper.insert(cloneIgnoreId(dbSku, o -> o.setBarCode(null))); // 测试 picUrl 不匹配 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(); - reqVO.setBeginCreateTime(null); - reqVO.setEndCreateTime(null); reqVO.setSpuId(null); - reqVO.setSkuStatus(null); - reqVO.setAttrs(null); + reqVO.setProperties(null); reqVO.setPrice(null); reqVO.setOriginalPrice(null); reqVO.setCostPrice(null); reqVO.setBarCode(null); reqVO.setPicUrl(null); + reqVO.setStatus(null); + reqVO.setBeginCreateTime(null); + reqVO.setEndCreateTime(null); // 调用 PageResult pageResult = skuService.getSkuPage(reqVO); @@ -163,25 +163,21 @@ public class SkuServiceImplTest extends BaseDbUnitTest { public void testGetSkuList() { // mock 数据 SkuDO dbSku = randomPojo(SkuDO.class, o -> { // 等会查询到 - o.setCreateTime(null); o.setSpuId(null); - o.setSkuStatus(null); - o.setAttrs(null); + o.setProperties(null); o.setPrice(null); o.setOriginalPrice(null); o.setCostPrice(null); o.setBarCode(null); o.setPicUrl(null); + o.setStatus(null); + o.setCreateTime(null); }); skuMapper.insert(dbSku); - // 测试 createTime 不匹配 - skuMapper.insert(cloneIgnoreId(dbSku, o -> o.setCreateTime(null))); // 测试 spuId 不匹配 skuMapper.insert(cloneIgnoreId(dbSku, o -> o.setSpuId(null))); - // 测试 skuStatus 不匹配 - skuMapper.insert(cloneIgnoreId(dbSku, o -> o.setSkuStatus(null))); - // 测试 attrs 不匹配 - skuMapper.insert(cloneIgnoreId(dbSku, o -> o.setAttrs(null))); + // 测试 properties 不匹配 + skuMapper.insert(cloneIgnoreId(dbSku, o -> o.setProperties(null))); // 测试 price 不匹配 skuMapper.insert(cloneIgnoreId(dbSku, o -> o.setPrice(null))); // 测试 originalPrice 不匹配 @@ -192,18 +188,22 @@ public class SkuServiceImplTest extends BaseDbUnitTest { skuMapper.insert(cloneIgnoreId(dbSku, o -> o.setBarCode(null))); // 测试 picUrl 不匹配 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(); - reqVO.setBeginCreateTime(null); - reqVO.setEndCreateTime(null); reqVO.setSpuId(null); - reqVO.setSkuStatus(null); - reqVO.setAttrs(null); + reqVO.setProperties(null); reqVO.setPrice(null); reqVO.setOriginalPrice(null); reqVO.setCostPrice(null); reqVO.setBarCode(null); reqVO.setPicUrl(null); + reqVO.setStatus(null); + reqVO.setBeginCreateTime(null); + reqVO.setEndCreateTime(null); // 调用 List list = skuService.getSkuList(reqVO); diff --git a/yudao-module-mall/yudao-module-product-biz/src/test/java/cn/iocoder/yudao/module/product/service/spu/SpuServiceImplTest.java b/yudao-module-mall/yudao-module-product-biz/src/test/java/cn/iocoder/yudao/module/product/service/spu/SpuServiceImplTest.java index 55e7e5c8d..c8bd50ad8 100755 --- a/yudao-module-mall/yudao-module-product-biz/src/test/java/cn/iocoder/yudao/module/product/service/spu/SpuServiceImplTest.java +++ b/yudao-module-mall/yudao-module-product-biz/src/test/java/cn/iocoder/yudao/module/product/service/spu/SpuServiceImplTest.java @@ -108,34 +108,27 @@ public class SpuServiceImplTest extends BaseDbUnitTest { public void testGetSpuPage() { // mock 数据 SpuDO dbSpu = randomPojo(SpuDO.class, o -> { // 等会查询到 - o.setCreateTime(null); o.setName(null); - o.setVisible(null); o.setSellPoint(null); o.setDescription(null); - o.setCid(null); - o.setListPicUrl(null); + o.setCategoryId(null); o.setPicUrls(null); o.setSort(null); o.setLikeCount(null); o.setPrice(null); o.setQuantity(null); + o.setStatus(null); + o.setCreateTime(null); }); spuMapper.insert(dbSpu); - // 测试 createTime 不匹配 - spuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setCreateTime(null))); // 测试 name 不匹配 spuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setName(null))); - // 测试 visible 不匹配 - spuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setVisible(null))); // 测试 sellPoint 不匹配 spuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setSellPoint(null))); // 测试 description 不匹配 spuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setDescription(null))); - // 测试 cid 不匹配 - spuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setCid(null))); - // 测试 listPicUrl 不匹配 - spuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setListPicUrl(null))); + // 测试 categoryId 不匹配 + spuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setCategoryId(null))); // 测试 picUrls 不匹配 spuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setPicUrls(null))); // 测试 sort 不匹配 @@ -146,21 +139,24 @@ public class SpuServiceImplTest extends BaseDbUnitTest { spuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setPrice(null))); // 测试 quantity 不匹配 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(); - reqVO.setBeginCreateTime(null); - reqVO.setEndCreateTime(null); reqVO.setName(null); - reqVO.setVisible(null); reqVO.setSellPoint(null); reqVO.setDescription(null); - reqVO.setCid(null); - reqVO.setListPicUrl(null); + reqVO.setCategoryId(null); reqVO.setPicUrls(null); reqVO.setSort(null); reqVO.setLikeCount(null); reqVO.setPrice(null); reqVO.setQuantity(null); + reqVO.setStatus(null); + reqVO.setBeginCreateTime(null); + reqVO.setEndCreateTime(null); // 调用 PageResult pageResult = spuService.getSpuPage(reqVO); @@ -175,34 +171,27 @@ public class SpuServiceImplTest extends BaseDbUnitTest { public void testGetSpuList() { // mock 数据 SpuDO dbSpu = randomPojo(SpuDO.class, o -> { // 等会查询到 - o.setCreateTime(null); o.setName(null); - o.setVisible(null); o.setSellPoint(null); o.setDescription(null); - o.setCid(null); - o.setListPicUrl(null); + o.setCategoryId(null); o.setPicUrls(null); o.setSort(null); o.setLikeCount(null); o.setPrice(null); o.setQuantity(null); + o.setStatus(null); + o.setCreateTime(null); }); spuMapper.insert(dbSpu); - // 测试 createTime 不匹配 - spuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setCreateTime(null))); // 测试 name 不匹配 spuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setName(null))); - // 测试 visible 不匹配 - spuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setVisible(null))); // 测试 sellPoint 不匹配 spuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setSellPoint(null))); // 测试 description 不匹配 spuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setDescription(null))); - // 测试 cid 不匹配 - spuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setCid(null))); - // 测试 listPicUrl 不匹配 - spuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setListPicUrl(null))); + // 测试 categoryId 不匹配 + spuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setCategoryId(null))); // 测试 picUrls 不匹配 spuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setPicUrls(null))); // 测试 sort 不匹配 @@ -213,21 +202,24 @@ public class SpuServiceImplTest extends BaseDbUnitTest { spuMapper.insert(cloneIgnoreId(dbSpu, o -> o.setPrice(null))); // 测试 quantity 不匹配 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(); - reqVO.setBeginCreateTime(null); - reqVO.setEndCreateTime(null); reqVO.setName(null); - reqVO.setVisible(null); reqVO.setSellPoint(null); reqVO.setDescription(null); - reqVO.setCid(null); - reqVO.setListPicUrl(null); + reqVO.setCategoryId(null); reqVO.setPicUrls(null); reqVO.setSort(null); reqVO.setLikeCount(null); reqVO.setPrice(null); reqVO.setQuantity(null); + reqVO.setStatus(null); + reqVO.setBeginCreateTime(null); + reqVO.setEndCreateTime(null); // 调用 List list = spuService.getSpuList(reqVO);