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
55be703c
Commit
55be703c
authored
Mar 03, 2022
by
周晓航
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
购物车添加spock测试
parent
f05b8feb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
113 additions
and
0 deletions
+113
-0
shopping-cart-application-service/pom.xml
+17
-0
shopping-cart-application-service/src/test/spock/cn/freemud/service/impl/ShoppingCartNewServiceImplTest.groovy
+96
-0
No files found.
shopping-cart-application-service/pom.xml
View file @
55be703c
...
@@ -12,11 +12,28 @@
...
@@ -12,11 +12,28 @@
<properties>
<properties>
<jacoco.version>
0.7.5.201505241946
</jacoco.version>
<jacoco.version>
0.7.5.201505241946
</jacoco.version>
<junit.version>
4.12
</junit.version>
<junit.version>
4.12
</junit.version>
<spock.version>
1.3-groovy-2.5
</spock.version>
</properties>
</properties>
<artifactId>
shopping-cart-application-service
</artifactId>
<artifactId>
shopping-cart-application-service
</artifactId>
<dependencies>
<dependencies>
<!--引入spock 核心包-->
<dependency>
<groupId>
org.spockframework
</groupId>
<artifactId>
spock-core
</artifactId>
<version>
${spock.version}
</version>
<scope>
test
</scope>
</dependency>
<!--引入spock 与 spring 集成包-->
<dependency>
<groupId>
org.spockframework
</groupId>
<artifactId>
spock-spring
</artifactId>
<version>
${spock.version}
</version>
<scope>
test
</scope>
</dependency>
<dependency>
<dependency>
<groupId>
com.freemud.application.service.sdk
</groupId>
<groupId>
com.freemud.application.service.sdk
</groupId>
<artifactId>
paymentcenter-sdk
</artifactId>
<artifactId>
paymentcenter-sdk
</artifactId>
...
...
shopping-cart-application-service/src/test/spock/cn/freemud/service/impl/ShoppingCartNewServiceImplTest.groovy
0 → 100644
View file @
55be703c
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.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.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
/**
* @author : xh.Z
* @email : fisherman0510@163.com
* @Date : 2022/3/3 10:04
* @description :
*/
class
ShoppingCartNewServiceImplTest
extends
Specification
{
def
shoppingCartNewServiceImpl
=
new
ShoppingCartNewServiceImpl
()
def
assortmentSdkService
=
new
AssortmentSdkService
()
def
customerInfoManager
=
Mock
(
AssortmentCustomerInfoManager
.
class
)
def
productService
=
new
ProductServiceImpl
()
def
productServiceImpl
=
new
ProductServiceImpl
()
def
shoppingCartConvertAdapter
=
new
ShoppingCartConvertAdapter
()
def
productClient
=
Mock
(
ProductClient
.
class
)
def
activityAdapter
=
new
ActivityAdapter
()
def
couponAdapter
=
new
CouponAdapter
()
def
activityClient
=
Mock
(
ActivityClient
.
class
)
def
shoppingcartBaseServiceImpl
=
Mock
(
ShoppingCartBaseServiceImpl
.
class
)
void
setup
()
{
assortmentSdkService
.
productServiceImpl
=
productServiceImpl
assortmentSdkService
.
shoppingCartConvertAdapter
=
shoppingCartConvertAdapter
shoppingCartNewServiceImpl
.
customerInfoManager
=
customerInfoManager
shoppingCartNewServiceImpl
.
productService
=
productService
shoppingCartNewServiceImpl
.
assortmentSdkService
=
assortmentSdkService
shoppingCartNewServiceImpl
.
activityAdapter
=
activityAdapter
shoppingCartNewServiceImpl
.
couponAdapter
=
couponAdapter
shoppingCartNewServiceImpl
.
activityClient
=
activityClient
productServiceImpl
.
productClient
=
productClient
}
def
"测试 getShoppingCartGoods 订单调用购物车获取结算金额"
()
{
given:
"参数设置"
def
getShoppingCartGoodsApportionRequestVo
=
JSON
.
parseObject
(
"{\"shoppingCartInfoRequestVo\":{\"activityCode\":\"G1643164091158349\",\"buyType\":0,\"couponCode\":\"88709227085491207040\",\"couponCodes\":[{\"activityCode\":\"G1643164091158349\",\"couponCode\":\"88709227085491207040\",\"couponType\":7,\"discountAmount\":800,\"index\":1}],\"flag\":0,\"menuType\":\"saas\",\"orderType\":1,\"partnerId\":\"2581\",\"reachStoreType\":5,\"sendGoods\":[],\"sessionId\":\"eac53a53f8ae62def7f40cb1e47a1bd9791d95a8\",\"shopId\":\"229830\",\"trackingNo\":\"8283bc4c7e5f4bbb8b357e3c0bef7183\",\"useCouponFlag\":1,\"useCustomerScore\":2,\"version\":\"2.0.60.6\"}}"
,
GetShoppingCartGoodsApportionRequestVo
.
class
)
def
premiumExchangeActivity
=
getShoppingCartGoodsApportionRequestVo
.
getPremiumExchangeActivity
()
def
shoppingCartInfoRequestVo
=
getShoppingCartGoodsApportionRequestVo
.
getShoppingCartInfoRequestVo
()
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
)
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
)
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
when:
"调用方法逻辑"
def
response
=
shoppingCartNewServiceImpl
.
getShoppingCartGoods
(
shoppingCartInfoRequestVo
,
premiumExchangeActivity
)
then:
"验证 返回结果"
with
(
response
)
{
code
==
"100"
message
==
"success"
}
}
}
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