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
982f2047
Commit
982f2047
authored
Mar 16, 2022
by
周晓航
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
暂时未完成对 添加购物车接口进行mock
parent
70a3dbed
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
3 deletions
+58
-3
shopping-cart-application-service/src/test/spock/cn/freemud/service/impl/ShoppingCartNewServiceImplTest.groovy
+1
-3
shopping-cart-application-service/src/test/spock/cn/freemud/service/impl/ShoppingCartNewServiceImpt2PowerMockTest.groovy
+57
-0
No files found.
shopping-cart-application-service/src/test/spock/cn/freemud/service/impl/ShoppingCartNewServiceImplTest.groovy
View file @
982f2047
...
@@ -10,6 +10,7 @@ import cn.freemud.entities.dto.calculate.ActivityCalculationDiscountResponseDto
...
@@ -10,6 +10,7 @@ import cn.freemud.entities.dto.calculate.ActivityCalculationDiscountResponseDto
import
cn.freemud.entities.dto.product.CheckCartRequest
import
cn.freemud.entities.dto.product.CheckCartRequest
import
cn.freemud.entities.dto.product.ValiadShopProductResponse
import
cn.freemud.entities.dto.product.ValiadShopProductResponse
import
cn.freemud.entities.dto.product.ValiadShopProductResult
import
cn.freemud.entities.dto.product.ValiadShopProductResult
import
cn.freemud.entities.vo.AddShoppingCartGoodsRequestVo
import
cn.freemud.entities.vo.CartGoods
import
cn.freemud.entities.vo.CartGoods
import
cn.freemud.entities.vo.GetShoppingCartGoodsApportionRequestVo
import
cn.freemud.entities.vo.GetShoppingCartGoodsApportionRequestVo
import
cn.freemud.service.CommonService
import
cn.freemud.service.CommonService
...
@@ -69,9 +70,6 @@ class ShoppingCartNewServiceImplTest extends Specification {
...
@@ -69,9 +70,6 @@ class ShoppingCartNewServiceImplTest extends Specification {
}
}
def
"测试 /addGoods"
()
{
}
def
"测试 /getShoppingCartGoodsApportion 订单调用购物车获取结算金额"
()
{
def
"测试 /getShoppingCartGoodsApportion 订单调用购物车获取结算金额"
()
{
...
...
shopping-cart-application-service/src/test/spock/cn/freemud/service/impl/ShoppingCartNewServiceImpt2PowerMockTest.groovy
0 → 100644
View file @
982f2047
package
cn.freemud.service.impl
import
cn.freemud.adapter.ShoppingCartConvertAdapter
import
cn.freemud.entities.vo.AddShoppingCartGoodsRequestVo
import
com.alibaba.fastjson.JSON
import
com.freemud.api.assortment.datamanager.entity.vo.AssortmentCustomerInfoVo
import
com.freemud.api.assortment.datamanager.manager.customer.AssortmentCustomerInfoManager
import
org.junit.runner.RunWith
import
org.mockito.Mockito
import
org.powermock.api.mockito.PowerMockito
import
org.powermock.core.classloader.annotations.PrepareForTest
import
org.powermock.modules.junit4.PowerMockRunner
import
org.powermock.modules.junit4.PowerMockRunnerDelegate
import
org.spockframework.runtime.Sputnik
import
spock.lang.Specification
/**
* @author : xh.Z
* @email : fisherman0510@163.com
* @Date : 2022/3/16 15:16
* @description :
*/
@RunWith
(
PowerMockRunner
.
class
)
@PowerMockRunnerDelegate
(
Sputnik
.
class
)
@PrepareForTest
(
ShoppingCartConvertAdapter
.
class
)
class
ShoppingCartNewServiceImpt2PowerMockTest
extends
Specification
{
def
shoppingCartNewServiceImpl
=
new
ShoppingCartNewServiceImpl
()
def
customerInfoManager
=
PowerMockito
.
mock
(
AssortmentCustomerInfoManager
)
void
setup
()
{
shoppingCartNewServiceImpl
.
customerInfoManager
=
customerInfoManager
// mock静态类
PowerMockito
.
mockStatic
(
ShoppingCartConvertAdapter
.
class
)
}
def
"测试 /addGoods"
()
{
given:
"request 请求参数"
def
addShoppingCartGoodsRequestVo
=
JSON
.
parseObject
(
"{\"channelType\":\"saas\",\"channel\":1,\"partnerId\":\"2690\",\"appId\":\"wxa1f272347828dae8\",\"version\":\"2.0.68.7\",\"sessionId\":\"1410a547ea1bf178f17032a9e12ac6606db8cc6f\",\"orderType\":1,\"menuType\":\"saas\",\"shopId\":\"QAJIALE001\",\"spuId\":\"215809930343585821\",\"skuId\":\"\",\"qty\":1,\"categoryId\":\"0101\",\"productMaterialList\":[],\"categoryName\":\"单品\",\"productComboList\":[],\"productGroupList\":[],\"receiveId\":\"\",\"bizType\":null}"
,
AddShoppingCartGoodsRequestVo
.
class
)
and:
"模拟第三方响应结果数据"
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
)
and:
"调三方反馈参数 为自己的参数对象"
customerInfoManager
.
getCustomerInfoByObject
(
"eac53a53f8ae62def7f40cb1e47a1bd9791d95a8"
)
>>
customerInfoVo
and:
"模拟第三方调用"
Mockito
.
when
(
customerInfoManager
.
getCustomerInfoByObject
(
Mockito
.
any
())).
thenReturn
(
customerInfoVo
)
and:
"静态方法mock"
PowerMockito
.
mockStatic
(
ShoppingCartConvertAdapter
.
convent2SkuId
(
addShoppingCartGoodsRequestVo
))
PowerMockito
.
mockStatic
(
ShoppingCartConvertAdapter
.
convent2CartGoods
(
addShoppingCartGoodsRequestVo
))
}
}
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