Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
O
order-group
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
order-group-application
order-group
Commits
31a51a00
Commit
31a51a00
authored
Mar 04, 2022
by
周晓航
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
购物车添加spock测试
parent
55be703c
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
25 deletions
+24
-25
shopping-cart-application-service/src/test/spock/cn/freemud/service/impl/ShoppingCartNewServiceImplTest.groovy
+24
-25
No files found.
shopping-cart-application-service/src/test/spock/cn/freemud/service/impl/ShoppingCartNewServiceImplTest.groovy
View file @
31a51a00
...
...
@@ -2,23 +2,16 @@ package cn.freemud.service.impl
import
cn.freemud.adapter.ActivityAdapter
import
cn.freemud.adapter.CouponAdapter
import
cn.freemud.adapter.ShoppingCartConvertAdapter
import
cn.freemud.base.entity.BaseResponse
import
cn.freemud.demo.manager.product.ProductService
import
cn.freemud.entities.dto.ProductBaseResponse
import
cn.freemud.entities.dto.calculate.ActivityCalculationDiscountResponseDto
import
cn.freemud.entities.dto.product.
ValiadShopProductResponse
import
cn.freemud.entities.dto.product.
CheckCartRequest
import
cn.freemud.entities.vo.CartGoods
import
cn.freemud.entities.vo.CreateOrderVo
import
cn.freemud.entities.vo.CustomerInfoVo
import
cn.freemud.entities.vo.GetShoppingCartGoodsApportionRequestVo
import
cn.freemud.
entities.vo.ShoppingCartInfoRequestVo
import
cn.freemud.
service.impl.calculate.CalculationSharingDiscountService
import
cn.freemud.service.thirdparty.ActivityClient
import
cn.freemud.service.thirdparty.ProductClient
import
com.alibaba.fastjson.JSON
import
com.freemud.api.assortment.datamanager.entity.vo.AssortmentCustomerInfoVo
import
com.freemud.api.assortment.datamanager.manager.customer.AssortmentCustomerInfoManager
import
com.freemud.sdk.api.assortment.shoppingcart.service.impl.ShoppingCartBaseServiceImpl
import
spock.lang.Specification
/**
...
...
@@ -30,27 +23,29 @@ import spock.lang.Specification
class
ShoppingCartNewServiceImplTest
extends
Specification
{
def
shoppingCartNewServiceImpl
=
new
ShoppingCartNewServiceImpl
()
def
assortmentSdkService
=
new
AssortmentSdkService
(
)
def
assortmentSdkService
=
Mock
(
AssortmentSdkService
.
class
)
def
customerInfoManager
=
Mock
(
AssortmentCustomerInfoManager
.
class
)
def
productService
=
new
ProductServiceImpl
()
def
productServiceImpl
=
new
ProductServiceImpl
()
def
shoppingCartConvertAdapter
=
new
ShoppingCartConvertAdapter
()
def
productService
=
Mock
(
ProductServiceImpl
.
class
)
def
productClient
=
Mock
(
ProductClient
.
class
)
def
activityAdapter
=
new
ActivityAdapter
()
def
couponAdapter
=
new
CouponAdapter
()
def
activityClient
=
Mock
(
ActivityClient
.
class
)
def
shoppingcartBaseServiceImpl
=
Mock
(
ShoppingCartBaseServiceImpl
.
class
)
def
productServiceImpl
=
new
ProductServiceImpl
()
def
sharingDiscountService
=
new
CalculationSharingDiscountService
()
void
setup
()
{
assortmentSdkService
.
productServiceImpl
=
productServiceImpl
assortmentSdkService
.
shoppingCartConvertAdapter
=
shoppingCartConvertAdapter
shoppingCartNewServiceImpl
.
customerInfoManager
=
customerInfoManager
shoppingCartNewServiceImpl
.
productService
=
productService
shoppingCartNewServiceImpl
.
assortmentSdkService
=
assortmentSdkService
shoppingCartNewServiceImpl
.
activityAdapter
=
activityAdapter
shoppingCartNewServiceImpl
.
couponAdapter
=
couponAdapter
// fisherman 测试过程中, 需要测试 新老算价需要自己 控制开关
shoppingCartNewServiceImpl
.
newSharing
=
"{\"type\":1,\"grayList\":\"2581\",\"enable\":true}"
shoppingCartNewServiceImpl
.
activityClient
=
activityClient
shoppingCartNewServiceImpl
.
sharingDiscountService
=
sharingDiscountService
productServiceImpl
.
productClient
=
productClient
sharingDiscountService
.
activityClient
=
activityClient
}
def
"测试 getShoppingCartGoods 订单调用购物车获取结算金额"
()
{
...
...
@@ -63,8 +58,6 @@ class ShoppingCartNewServiceImplTest extends Specification {
def
customerInfoVo
=
JSON
.
parseObject
(
"{\"accessToken\":\"\",\"alipayUserId\":\"\",\"appId\":\"wx3f7ca0c75b213380\",\"appSecret\":\"\",\"appsecret\":\"\",\"channel\":\"1\",\"customerId\":\"\",\"devBrand\":\"\",\"devModel\":\"\",\"iappId\":\"7\",\"memberId\":\"3614319825989629832\",\"mobile\":\"17327190802\",\"newMember\":false,\"nickName\":\"SWEET SUGA\",\"openId\":\"o98fP4qjUo7xm-nT-JAaVEk9yBqM\",\"openid\":\"o98fP4qjUo7xm-nT-JAaVEk9yBqM\",\"partnerId\":\"2581\",\"photoUrl\":\"https://thirdwx.qlogo.cn/mmopen/vi_32/zahIlicTNSM0IA0qjOryv6s0SzIhlwW9EpQKvL63GbPhBwficMAibDohDEibSCQU0I5KohibIpp0yL57TWRcVKrRH2A/132\",\"registerTime\":\"2021-02-26 14:10:26\",\"sessionId\":\"eac53a53f8ae62def7f40cb1e47a1bd9791d95a8\",\"sessionKey\":\"GCyyapzbBSM4yXh9AduGOw==\",\"session_key\":\"GCyyapzbBSM4yXh9AduGOw==\",\"storeId\":\"\",\"tableNumber\":\"\",\"thirdPartyMemberID\":\"\",\"thirdPartyPartnerID\":\"\",\"unionId\":\"o7cEm68JPFhbrzqb0a0BcQE-dDVA\",\"wxAppId\":\"wx3f7ca0c75b213380\",\"wxAppid\":\"wx3f7ca0c75b213380\"}"
,
AssortmentCustomerInfoVo
.
class
)
def
valiadResponse
=
JSON
.
parseObject
(
"{\"data\":{\"failureList\":[],\"successList\":[{\"productType\":{\"additionalGroupList\":[],\"appIdList\":[],\"barcode\":\"\",\"brandId\":\"\",\"brandName\":\"\",\"businessNo\":\"\",\"businessType\":\"\",\"category\":\"0102\",\"categoryName\":\"正价单品\",\"comboType\":0,\"companyId\":\"2581\",\"completeFlag\":2,\"customerCode\":\"hn80180054\",\"customerName\":\"\",\"detailImages\":[],\"detailText\":\" \",\"finalPrice\":500,\"foreignDetailText\":\"\",\"foreignName\":\"\",\"foreignRawMaterial\":\"\",\"foreignRemark\":\"\",\"foreignUnit\":\"\",\"isDishware\":0,\"isLimitNumProduct\":0,\"isRecommend\":0,\"isShopMenu\":0,\"isSkuProduct\":0,\"isUpdateSetMeal\":1,\"labelNames\":[{\"backgroundColor\":\"\",\"endTime\":\"\",\"fontColor\":\"\",\"foreignName\":\"\",\"foreverShow\":0,\"id\":201728920800923959,\"isVisible\":1,\"labelDetail\":\"\",\"labelForm\":0,\"name\":\"辣味🌶🌶\",\"options\":\"\",\"partnerId\":\"2581\",\"productList\":[],\"startTime\":\"\",\"status\":0,\"storeId\":\"\",\"type\":\"0\"}],\"linkedId\":\"\",\"maxLimitNumber\":0,\"maxNum\":0,\"maxRestrictionQty\":0,\"memberDiscount\":100,\"memberPrice\":0,\"minLimitNumber\":0,\"minNum\":0,\"minRestrictionQty\":0,\"name\":\"元气鸡排T\",\"openMemberDiscount\":0,\"options\":\"\",\"originalPrice\":500,\"otherDesc\":\"\",\"packPrice\":0,\"partnerStatus\":2,\"picture\":\"https://picture.sandload.cn/1619082050722.jpg\",\"pid\":\"201889968054882060\",\"pknumber\":1,\"priceOrigin\":\"\",\"priceSource\":2,\"productAttributeGroupList\":[],\"productBindingCouponTypes\":[],\"productCategoryDetailList\":[],\"productCode\":\"010200095\",\"productComboList\":[],\"productGroupList\":[],\"productPictureList\":[{\"sequence\":0,\"type\":\"default\",\"url\":\"https://picture.sandload.cn/1619082050722.jpg\"}],\"productSpecification\":[],\"productionLocation\":\"\",\"rawMaterial\":\"\",\"remark\":\"元气满满的鸡排,带来一天的活力\",\"riseSell\":1,\"saleCount\":0,\"salesChannel\":\"\",\"sellTimeList\":[],\"sellTimeMonthList\":[],\"sellTimeRangeList\":[],\"sellTimeValid\":true,\"sequence\":0,\"shopLongTermSalesVolume\":0,\"shopShortTermSalesVolume\":0,\"singleOrder\":0,\"skuList\":[],\"skuSpecValues\":[],\"sourceChannel\":\"\",\"specProductId\":\"\",\"specification\":\"\",\"specificationGroupList\":[],\"specificationList\":[],\"standardGoodsFlag\":2,\"status\":2,\"stock\":9999,\"stockLimit\":2,\"storeCondition\":\"\",\"storeProductName\":\"\",\"tax\":0.01,\"taxId\":\"\",\"trueOriginalPrice\":0,\"type\":1,\"unit\":\"\",\"valid\":true,\"version\":0,\"weight\":0.0,\"weightType\":0},\"skuId\":\"201889968054882060\",\"spuId\":\"201889968054882060\",\"subProductTypeMap\":null,\"uuid\":\"6dabf892-901b-40b8-a985-5c097c905678\"}]},\"errcode\":100,\"errmsg\":\"获取门店必选分类商品成功\"}"
,
ProductBaseResponse
.
class
)
def
activityCalculationDiscountResponseDto
=
JSON
.
parseObject
(
"{\"msg\":\"成功\",\"result\":{\"apportionGoods\":[{\"apportionAmount\":0,\"apportionDetails\":[],\"cartGoodsUid\":\"6dabf892-901b-40b8-a985-5c097c905678\",\"goodsId\":\"201889968054882060\",\"goodsQuantity\":1,\"nowPrice\":500,\"originalPrice\":500},{\"apportionAmount\":800,\"apportionDetails\":[{\"activityApportionAmount\":800,\"activityCode\":\"88709227085491207040\",\"activityName\":\"鸡米花买一送一券\",\"activityType\":330,\"apportionType\":-1}],\"cartGoodsUid\":\"d0fb5162-2f51-4e8c-9e61-fadade791483\",\"goodsId\":\"201889966261817090\",\"goodsQuantity\":1,\"nowPrice\":0,\"originalPrice\":800},{\"apportionAmount\":0,\"apportionDetails\":[],\"cartGoodsUid\":\"d0fb5162-2f51-4e8c-9e61-fadade791483\",\"goodsId\":\"201889966261817090\",\"goodsQuantity\":1,\"nowPrice\":800,\"originalPrice\":800}],\"couponDiscounts\":[{\"activityName\":\"鸡米花买一送一券\",\"activityType\":330,\"couponCode\":\"88709227085491207040\",\"discountAmount\":800}],\"discounts\":[{\"activityName\":\"鸡米花买一送一券\",\"discount\":800}],\"goods\":[{\"cartGoodType\":0,\"cartGoodsUid\":\"6dabf892-901b-40b8-a985-5c097c905678\",\"discountAmount\":0,\"discounts\":[],\"gift\":false,\"goodsId\":\"201889968054882060\",\"goodsQuantity\":1,\"meal\":false,\"nowPrice\":500,\"originalPrice\":500,\"realAmount\":500,\"score\":0,\"smallMaterial\":[]},{\"actualGoodsNumber\":1,\"cartGoodType\":0,\"cartGoodsUid\":\"d0fb5162-2f51-4e8c-9e61-fadade791483\",\"discountAmount\":800,\"discounts\":[{\"activityCode\":\"88709227085491207040\",\"activityName\":\"鸡米花买一送一券\",\"actualGoodsNumber\":1,\"addOnQuantity\":0,\"discount\":800,\"goodsId\":\"201889966261817090\",\"signleDiscount\":800,\"type\":330}],\"gift\":false,\"goodsId\":\"201889966261817090\",\"goodsQuantity\":2,\"meal\":false,\"nowPrice\":800,\"originalPrice\":800,\"realAmount\":800,\"score\":0,\"smallMaterial\":[]}],\"isScoreLimit\":0,\"nightDistributionFee\":0,\"originalTotalAmount\":2100,\"stocks\":[],\"totalAmount\":1300,\"totalDiscountAmount\":800,\"v3Promotion\":false},\"statusCode\":\"100\",\"ver\":1}"
,
ActivityCalculationDiscountResponseDto
.
class
)
...
...
@@ -72,17 +65,22 @@ class ShoppingCartNewServiceImplTest extends Specification {
def
goodList
=
JSON
.
parseArray
(
"[{\"addCartTime\":1646286585880,\"amount\":800,\"canUseCoupon\":0,\"cartGoodsUid\":\"b8eca7b4-8627-4726-8560-b1d9f74a1c8b\",\"couponCode\":\"88709227085491207040\",\"createTimeMili\":1646286585880,\"extra\":[],\"goodsId\":\"spq88709227085491207040\",\"goodsType\":10,\"isB3S1Coupon\":0,\"isB3S1CouponGoods\":0,\"isMonthCard\":0,\"isMonthCardGoods\":0,\"isSunnyCoupon\":0,\"isUseMonthCard\":0,\"linkedId\":\"\",\"originalAmount\":0,\"originalPrice\":800,\"originalProductType\":1,\"packPrice\":0,\"pic\":\"https://picture.sandload.cn/1619081297921.jpg\",\"productComboList\":[],\"productGroupList\":[],\"productMaterialList\":[],\"qty\":2,\"skuId\":\"201889966261817090\",\"skuName\":\"鸡米花T\",\"spuId\":\"201889966261817090\",\"stockLimit\":false,\"unit\":\"\",\"weight\":0.0,\"weightType\":false},{\"addCartTime\":1646286600492,\"amount\":500,\"canUseCoupon\":1,\"cartGoodsUid\":\"87653424-e6ef-45c7-ad84-2ebc777cccc9\",\"categoryName\":\"缤纷小食\",\"classificationForeignName\":\"正价单品\",\"classificationId\":\"0102\",\"classificationName\":\"正价单品\",\"createTimeMili\":1646286600492,\"customerCode\":\"hn80180054\",\"finalPrice\":500,\"foreignName\":\"\",\"goodsId\":\"201889968054882060\",\"goodsType\":5,\"isB3S1Coupon\":0,\"isB3S1CouponGoods\":0,\"isMonthCard\":0,\"isMonthCardGoods\":0,\"isSunnyCoupon\":0,\"isUseMonthCard\":0,\"linkedId\":\"\",\"materialAmount\":0,\"memberDiscount\":100,\"name\":\"元气鸡排T\",\"originalAmount\":500,\"originalMaterialAmount\":0,\"originalPrice\":500,\"originalProductType\":1,\"packPrice\":0,\"pic\":\"https://picture.sandload.cn/1619082050722.jpg\",\"productComboList\":[],\"productGroupList\":[],\"productMaterialList\":[],\"qty\":1,\"riseSell\":1,\"singleOrder\":0,\"skuForeignName\":\"\",\"skuId\":\"\",\"skuName\":\"元气鸡排T\",\"spuForeignName\":\"\",\"spuId\":\"201889968054882060\",\"spuName\":\"元气鸡排T\",\"stockLimit\":false,\"subForeignName\":\"\",\"subName\":\"\",\"tax\":0.01,\"taxId\":\"\",\"unit\":\"\",\"weight\":0.0,\"weightType\":false}]"
,
CartGoods
.
class
)
def
checkCartRequest
=
new
CheckCartRequest
()
checkCartRequest
.
setCartGoodsList
(
goodList
)
def
hasRequiredProducts
=
false
and:
"调三方反馈参数 为自己的参数对象 "
assortmentSdkService
.
getNowBuyShoppingCart
(
_
)
>>
goodList
customerInfoManager
.
getCustomerInfoByObject
(
"eac53a53f8ae62def7f40cb1e47a1bd9791d95a8"
)
>>
customerInfoVo
productService
.
hasRequiredProducts
(
"2581"
,
"3"
,
new
ArrayList
<
CartGoods
>(),
2
)
>>
false
productClient
.
validateShopProduct
(
null
)
>>
valiadResponse
// 默认走v1 老算价
shoppingCartNewServiceImpl
.
grayPush
(
null
,
null
,
"2"
)
>>
false
activityClient
.
calculationDiscount
(
null
)
>>
activityCalculationDiscountResponseDto
assortmentSdkService
.
getShoppingCart
(
_
,
_
,
_
,
_
,
_
,
_
,
_
)
>>
goodList
productService
.
hasRequiredProducts
(
_
,
_
,
_
,
_
)
>>
hasRequiredProducts
assortmentSdkService
.
checkShoppingCartSdk
(
_
,
_
,
_
,
_
,
_
,
_
,
_
,
_
)
>>
checkCartRequest
activityClient
.
calculationDiscount
(
_
)
>>
activityCalculationDiscountResponseDto
when:
"调用方法逻辑"
// 测试过程中, 需要测试 新老算价需要自己 控制开关
def
response
=
shoppingCartNewServiceImpl
.
getShoppingCartGoods
(
shoppingCartInfoRequestVo
,
premiumExchangeActivity
)
then:
"验证 返回结果"
...
...
@@ -93,4 +91,5 @@ class ShoppingCartNewServiceImplTest extends Specification {
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment