Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
X
xm-sportstest
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
xiamai-test
xm-sportstest
Commits
08084911
Commit
08084911
authored
Dec 31, 2024
by
yangfangfang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
物品
parent
dd996357
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
639 additions
and
120 deletions
+639
-120
module/polar/通用设置.xml
+2
-2
src/main/java/com/xiaomai/cases/lunar/goods/GoodCTools.java
+28
-6
src/main/java/com/xiaomai/cases/lunar/goods/testLlistXcxGoodsGroup.java
+147
-1
src/main/java/com/xiaomai/cases/polar/goods/Tools/GoodTools.java
+347
-33
src/main/java/com/xiaomai/cases/polar/goods/createGoods.java
+71
-65
src/main/java/com/xiaomai/cases/polar/goods/createGoodsGroup.java
+2
-2
src/main/java/com/xiaomai/cases/polar/goods/deleteGood.java
+39
-10
src/main/java/com/xiaomai/enums/ApiModule.java
+1
-1
src/main/java/com/xiaomai/enums/LoginAccount.java
+2
-0
No files found.
module/polar/通用设置.xml
View file @
08084911
<?xml
version="1.0" encoding="UTF-8"?>
<?xml
version="1.0" encoding="UTF-8"?>
...
...
@@ -4,7 +4,7 @@
<test
name=
"通用设置模块测试"
preserve-order=
"true"
verbose=
"3"
>
<!-- 再起一个听且唯一的名字 -->
<packages>
<package
name=
"com.xiaomai.cases.polar.setting.*"
></package>
<!-- 添加自己想要集成测试的
case
范围自己定 -->
<package
name=
"com.xiaomai.cases.polar.setting.*"
></package>
<!-- 添加自己想要集成测试的范围自己定 -->
</packages>
</test>
<listeners>
...
...
src/main/java/com/xiaomai/cases/lunar/goods/GoodCTools.java
View file @
08084911
...
...
@@ -16,9 +16,9 @@ public class GoodCTools extends XMBaseTest {
* @author: yff
**/
public
JSONObject
pageXcxHomeGoods
_
C
(
DataUserInfo
...
userInfos
){
public
JSONObject
pageXcxHomeGoodsC
(
DataUserInfo
...
userInfos
){
dataApi
.
setApiModule
(
ApiModule
.
Lunar_Goods
)
.
setApiName
(
"API_pageXcxHomeGoods
_
C"
)
.
setApiName
(
"API_pageXcxHomeGoodsC"
)
.
setTerminal
(
Terminal
.
C
);
super
.
beforeDataRequest
(
userInfos
);
...
...
@@ -26,10 +26,10 @@ public class GoodCTools extends XMBaseTest {
JSONObject
jsonObject
=
new
JSONObject
();
jsonObject
.
put
(
"current"
,
0
);
jsonObject
.
put
(
"size"
,
20
);
jsonObject
.
put
(
"studioId"
,
dataApi
.
getLoginInfo
().
getStudioId
());
JSONArray
jsonArray
=
new
JSONArray
();
jsonObject
.
put
(
"ids"
,
jsonArray
);
jsonObject
.
put
(
"size"
,
20
);
jsonObject
.
put
(
"studioId"
,
dataApi
.
getLoginInfo
().
getStudioId
());
JSONArray
ids
=
new
JSONArray
();
jsonObject
.
put
(
"ids"
,
ids
);
dataApi
.
doRequest
(
RequestType
.
JSON
,
dataparams
,
jsonObject
.
toString
(),
dataheadrs
).
assetsSuccess
(
true
);
return
dataApi
.
getBodyInJSON
();
...
...
@@ -57,4 +57,26 @@ public class GoodCTools extends XMBaseTest {
return
dataApi
.
getBodyInJSON
();
}
/**
* @param
* @description:拉取C端小程序物品组列表
* @author: yff
**/
public
JSONObject
listXcxGoodsGroup
(
DataUserInfo
...
userInfos
){
dataApi
.
setApiModule
(
ApiModule
.
Lunar_Goods
)
.
setApiName
(
"API_listXcxGoodsGroup"
)
.
setTerminal
(
Terminal
.
C
);
super
.
beforeDataRequest
(
userInfos
);
JSONObject
listXcxGoodsGroup
=
new
JSONObject
();
listXcxGoodsGroup
.
put
(
"studioId"
,
dataApi
.
getLoginInfo
().
getStudioId
());
JSONArray
ids
=
new
JSONArray
();
listXcxGoodsGroup
.
put
(
"ids"
,
ids
);
dataApi
.
doRequest
(
RequestType
.
JSON
,
dataparams
,
listXcxGoodsGroup
.
toString
(),
dataheadrs
).
assetsSuccess
(
true
);
return
dataApi
.
getBodyInJSON
();
}
}
src/main/java/com/xiaomai/cases/lunar/goods/testLlistXcxGoodsGroup.java
View file @
08084911
package
com
.
xiaomai
.
cases
.
lunar
.
goods
;
public
class
testLlistXcxGoodsGroup
{
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.xiaomai.basetest.BaseTestImpl
;
import
com.xiaomai.cases.polar.goods.Tools.GoodTools
;
import
com.xiaomai.client.DataUserInfo
;
import
com.xiaomai.enums.ApiModule
;
import
com.xiaomai.enums.LoginAccount
;
import
com.xiaomai.enums.Terminal
;
import
org.testng.Assert
;
import
org.testng.annotations.BeforeMethod
;
import
org.testng.annotations.Test
;
public
class
testLlistXcxGoodsGroup
extends
BaseTestImpl
{
GoodCTools
goodCTools
=
new
GoodCTools
();
GoodTools
goodTools
=
new
GoodTools
();
String
createGoodsId
;
DataUserInfo
info
=
new
DataUserInfo
();
@BeforeMethod
@Override
public
void
beforeTest
(){
setTestInfo
(
ApiModule
.
Lunar_Goods
,
"API_listXcxGoodsGroup"
,
LoginAccount
.
GYM_MINIAPPC
,
Terminal
.
minApp
,
"yff"
);
super
.
beforeTest
();
}
@Test
(
description
=
"拉取C端小程序物品组列表"
)
public
void
testListXcxGoodsGroup
()
{
//切换端位
info
.
setTerminal
(
Terminal
.
B
);
info
.
setLoginUser
(
LoginAccount
.
GYM_PROD
);
//存量分组:"id": "1873903771989471234","name": "自动化分组勿动勿用"
String
id
=
"1873903771989471234"
;
//case1:获取小程序物品分组列表:没有这个分组数据,因为没任何物品
JSONObject
listXcxGoodsGroup
=
goodCTools
.
listXcxGoodsGroup
();
JSONArray
result
=
listXcxGoodsGroup
.
getJSONArray
(
"result"
);
boolean
success
=
false
;
for
(
int
i
=
0
;
i
<
result
.
size
();
i
++){
if
(
!
result
.
getJSONObject
(
i
).
getString
(
"id"
).
equals
(
id
)){
success
=
true
;
}
Assert
.
assertEquals
(
success
,
true
,
"分组里没有一个物品,这个分组不应该在小程序物品组列表展示"
);
}
//case2:获取小程序物品分组列表:有这个分组数据,因为创建了一个单规格&启用&开启小程序售卖的物品
//新建物品
//创建了一个单规格&启用&开启小程序售卖
JSONObject
createGoods
=
goodTools
.
testCreateGoods_single
(
"YES"
,
"0.01"
,
10
,
info
);
createGoodsId
=
createGoods
.
getString
(
"result"
);
//移动至这个分组
JSONObject
batchModifyGoodsBelongGroup
=
goodTools
.
batchModifyGoodsBelongGroup
(
"1873903771989471234"
,
createGoodsId
,
info
);
try
{
Thread
.
sleep
(
3000
);
}
catch
(
InterruptedException
e
)
{
throw
new
RuntimeException
(
e
);
}
//获取小程序物品分组列表:有该分组
JSONObject
listXcxGoodsGroup1
=
goodCTools
.
listXcxGoodsGroup
();
JSONArray
result1
=
listXcxGoodsGroup1
.
getJSONArray
(
"result"
);
boolean
success1
=
false
;
for
(
int
i
=
0
;
i
<
result1
.
size
();
i
++){
if
(
result1
.
getJSONObject
(
i
).
getString
(
"id"
).
equals
(
id
)){
success1
=
true
;
}
Assert
.
assertEquals
(
success1
,
true
,
"分组的物品是启用且开启小程序售卖的,这个分组应该在小程序物品组列表展示"
);
}
//case3:获取小程序物品分组列表:没有这个分组数据,因为分组内的物品为启用&关闭小程序售卖
//修改上个物品为启用&关闭小程序售卖
JSONObject
modifyGoodsXcxSaleState
=
goodTools
.
modifyGoodsXcxSaleState
(
createGoodsId
,
"NO"
,
info
);
try
{
Thread
.
sleep
(
3000
);
}
catch
(
InterruptedException
e
)
{
throw
new
RuntimeException
(
e
);
}
//修改校验1:获取B端物品详情
JSONObject
getDetail
=
goodTools
.
getDetail_goods
(
createGoodsId
,
info
);
String
xcxSaleState
=
getDetail
.
getJSONObject
(
"result"
).
getString
(
"xcxSaleState"
);
Assert
.
assertEquals
(
xcxSaleState
,
"NO"
,
"修改物品的小程序售卖为关闭失败"
);
//获取小程序物品分组列表:没有该分组
JSONObject
listXcxGoodsGroup2
=
goodCTools
.
listXcxGoodsGroup
();
JSONArray
result2
=
listXcxGoodsGroup2
.
getJSONArray
(
"result"
);
boolean
success2
=
false
;
for
(
int
i
=
0
;
i
<
result2
.
size
();
i
++){
if
(
!
result2
.
getJSONObject
(
i
).
getString
(
"id"
).
equals
(
id
)){
success2
=
true
;
}
Assert
.
assertEquals
(
success2
,
true
,
"分组的物品是启用且关闭小程序售卖的,这个分组应该不在小程序物品组列表展示"
);
}
//case4:获取小程序物品分组列表:没有这个分组数据,因为分组内的物品为停用&关闭小程序售卖
//修改上个物品为停用&关闭小程序售卖
JSONObject
modifyGoodsState
=
goodTools
.
modifyGoodsState
(
createGoodsId
,
"NO"
,
info
);
try
{
Thread
.
sleep
(
3000
);
}
catch
(
InterruptedException
e
)
{
throw
new
RuntimeException
(
e
);
}
//修改校验1:获取B端物品详情
JSONObject
getDetail1
=
goodTools
.
getDetail_goods
(
createGoodsId
,
info
);
String
state
=
getDetail1
.
getJSONObject
(
"result"
).
getString
(
"state"
);
Assert
.
assertEquals
(
state
,
"NO"
,
"修改物品的状态为停用失败"
);
//获取小程序物品分组列表:没有该分组
JSONObject
listXcxGoodsGroup3
=
goodCTools
.
listXcxGoodsGroup
();
JSONArray
result3
=
listXcxGoodsGroup3
.
getJSONArray
(
"result"
);
boolean
success3
=
false
;
for
(
int
i
=
0
;
i
<
result3
.
size
();
i
++){
if
(
!
result3
.
getJSONObject
(
i
).
getString
(
"id"
).
equals
(
id
)){
success3
=
true
;
}
Assert
.
assertEquals
(
success3
,
true
,
"分组的物品是停用且关闭小程序售卖的,这个分组应该不在小程序物品组列表展示"
);
}
}
@Test
(
description
=
"清理物品数据"
,
priority
=
1
)
public
void
delete
()
{
goodTools
.
deleteGoods
(
createGoodsId
,
info
);
}
}
src/main/java/com/xiaomai/cases/polar/goods/Tools/GoodTools.java
View file @
08084911
...
...
@@ -10,21 +10,266 @@ import com.xiaomai.utils.RandomStringUtil;
import
com.xiaomai.utils.XMBaseTest
;
public
class
GoodTools
extends
XMBaseTest
{
//
// /**
// * @param
// * @description:新建物品
// * @param multiSpec:是否是多规格;true:多规格;false:单规格
// * @author: yff
// **/
//
// public JSONObject testCreateGoods(boolean multiSpec,DataUserInfo...userInfos) {
// dataApi.setApiModule(ApiModule.Polar_Goods)
// .setApiName("API_createGoods")
// .setTerminal(Terminal.B);
//
// super.beforeDataRequest(userInfos);
//
// String color1 = "黑色";
// String color2 = "白色";
// String size1 = "大的";
// String size2 = "小的";
// String skin1 = "貂蝉";
// String skin2 = "王昭君";
//
// JSONObject jsonObject = new JSONObject();
//
// //多规格
// if (multiSpec==true) {
//
// //商品介绍不为空,纯文本的写法
// JSONObject description = new JSONObject();
// JSONArray items = new JSONArray();
// JSONObject item1 = new JSONObject();
// item1.put("type", "TEXT");
// item1.put("content", "自动化创建的多规格三个规格,每个规格都有两个规格值");
// item1.put("aspect", "");
//
// items.add(item1);
//
// description.put("items", items);
// jsonObject.put("description", description.toString());
//
//
// jsonObject.put("groupId", "1873903328974499841");
// jsonObject.put("multiSpec", true);
// jsonObject.put("name", "自动化创建三个规格" + RandomStringUtil.randomString(2));
// jsonObject.put("xcxSaleState", "YES");
//
//
// JSONObject multiSpecInfo = new JSONObject();
//
// //设置三个规格和每个都有两个规格值
// JSONArray specList = new JSONArray();
// JSONObject specList1 = new JSONObject();
// specList1.put("name", "颜色");
//
// JSONArray specList1SpecValues = new JSONArray();
// JSONObject specList1SpecValues1 = new JSONObject();
// specList1SpecValues1.put("name", color1);
// JSONObject specList1SpecValues2 = new JSONObject();
// specList1SpecValues2.put("name", color2);
// specList1SpecValues.add(specList1SpecValues1);
// specList1SpecValues.add(specList1SpecValues2);
// specList1.put("specValues", specList1SpecValues);
//
// JSONObject specList2 = new JSONObject();
// specList2.put("name", "尺码");
//
// JSONArray specList2SpecValues = new JSONArray();
// JSONObject specList2SpecValues1 = new JSONObject();
// specList2SpecValues1.put("name", size1);
// JSONObject specList2SpecValues2 = new JSONObject();
// specList2SpecValues2.put("name", size2);
// specList2SpecValues.add(specList2SpecValues1);
// specList2SpecValues.add(specList2SpecValues2);
// specList2.put("specValues", specList2SpecValues);
//
//
// JSONObject specList3 = new JSONObject();
// specList3.put("name", "限定皮肤");
//
// JSONArray specList3SpecValues = new JSONArray();
// JSONObject specList3SpecValues1 = new JSONObject();
// specList3SpecValues1.put("name", skin1);
// JSONObject specList3SpecValues2 = new JSONObject();
// specList3SpecValues2.put("name", skin2);
// specList3SpecValues.add(specList3SpecValues1);
// specList3SpecValues.add(specList3SpecValues2);
// specList3.put("specValues", specList3SpecValues);
//
// specList.add(specList1);
// specList.add(specList2);
// specList.add(specList3);
//
// multiSpecInfo.put("specList", specList);
//
//
// try {
// Thread.sleep(3000);
// } catch (InterruptedException e) {
// throw new RuntimeException(e);
// }
//
// //排列出来的组合2*2*2
// JSONArray specCombinationList = new JSONArray();
//
// JSONObject specCombinationList1 = new JSONObject();
//
// JSONArray specCombinationList1Specs = new JSONArray();
// specCombinationList1Specs.add(color1);
// specCombinationList1Specs.add(size1);
// specCombinationList1Specs.add(skin1);
// specCombinationList1.put("specs", specCombinationList1Specs);
// specCombinationList1.put("price", "0.01");
// specCombinationList1.put("inventory", 10);
//
// specCombinationList.add(specCombinationList1);
//
// JSONObject specCombinationList2 = new JSONObject();
// JSONArray specCombinationList2Specs = new JSONArray();
// specCombinationList2Specs.add(color1);
// specCombinationList2Specs.add(size1);
// specCombinationList2Specs.add(skin2);
// specCombinationList2.put("specs", specCombinationList2Specs);
// specCombinationList2.put("price", "0.01");
// specCombinationList2.put("inventory", 10);
//
// specCombinationList.add(specCombinationList2);
//
//
// JSONObject specCombinationList3 = new JSONObject();
// JSONArray specCombinationList3Specs = new JSONArray();
// specCombinationList3Specs.add(color1);
// specCombinationList3Specs.add(size2);
// specCombinationList3Specs.add(skin1);
// specCombinationList3.put("specs", specCombinationList3Specs);
// specCombinationList3.put("price", "0.01");
// specCombinationList3.put("inventory", 10);
//
// specCombinationList.add(specCombinationList3);
//
//
// JSONObject specCombinationList4 = new JSONObject();
// JSONArray specCombinationList4Specs = new JSONArray();
// specCombinationList4Specs.add(color1);
// specCombinationList4Specs.add(size2);
// specCombinationList4Specs.add(skin2);
// specCombinationList4.put("specs", specCombinationList4Specs);
// specCombinationList4.put("price", "0.01");
// specCombinationList4.put("inventory", 10);
//
// specCombinationList.add(specCombinationList4);
//
//
// JSONObject specCombinationList5 = new JSONObject();
// JSONArray specCombinationList5Specs = new JSONArray();
// specCombinationList5Specs.add(color2);
// specCombinationList5Specs.add(size1);
// specCombinationList5Specs.add(skin1);
// specCombinationList5.put("specs", specCombinationList5Specs);
// specCombinationList5.put("price", "0.01");
// specCombinationList5.put("inventory", 10);
//
// specCombinationList.add(specCombinationList5);
//
//
// JSONObject specCombinationList6 = new JSONObject();
// JSONArray specCombinationList6Specs = new JSONArray();
// specCombinationList6Specs.add(color2);
// specCombinationList6Specs.add(size1);
// specCombinationList6Specs.add(skin2);
// specCombinationList6.put("specs", specCombinationList6Specs);
// specCombinationList6.put("price", "0.01");
// specCombinationList6.put("inventory", 10);
//
// specCombinationList.add(specCombinationList6);
//
// JSONObject specCombinationList7 = new JSONObject();
// JSONArray specCombinationList7Specs = new JSONArray();
// specCombinationList7Specs.add(color2);
// specCombinationList7Specs.add(size2);
// specCombinationList7Specs.add(skin1);
// specCombinationList7.put("specs", specCombinationList7Specs);
// specCombinationList7.put("price", "0.01");
// specCombinationList7.put("inventory", 10);
//
// specCombinationList.add(specCombinationList7);
//
//
// JSONObject specCombinationList8 = new JSONObject();
// JSONArray specCombinationList8Specs = new JSONArray();
// specCombinationList8Specs.add(color2);
// specCombinationList8Specs.add(size2);
// specCombinationList8Specs.add(skin2);
// specCombinationList8.put("specs", specCombinationList8Specs);
// specCombinationList8.put("price", "0.01");
// specCombinationList8.put("inventory", 10);
//
// specCombinationList.add(specCombinationList8);
//
// multiSpecInfo.put("specCombinationList", specCombinationList);
// jsonObject.put("multiSpecInfo", multiSpecInfo);
// jsonObject.put("brandId", dataApi.getLoginInfo().getBrandId());
// jsonObject.put("studioId", dataApi.getLoginInfo().getStudioId());
// jsonObject.put("operatorId", dataApi.getLoginInfo().getAdminId());
// }
//
// //单规格
// else if (multiSpec==false){
//
// //商品介绍不为空,纯文本的写法
// JSONObject description = new JSONObject();
// JSONArray items = new JSONArray();
// JSONObject item1 = new JSONObject();
// item1.put("type", "TEXT");
// item1.put("content", "自动化创建的");
// item1.put("aspect", "");
//
// items.add(item1);
//
// description.put("items", items);
// jsonObject.put("description", description.toString());
//
// jsonObject.put("groupId", "1873903328974499841");
// jsonObject.put("multiSpec", false);
// jsonObject.put("name", "自动化创建单规格" + RandomStringUtil.randomString(2));
// jsonObject.put("xcxSaleState", "YES");
// JSONObject jsonObject2 = new JSONObject();
//
// jsonObject2.put("inventory", "10");
// jsonObject2.put("price", "0.01");
//
// jsonObject.put("singleSpecInfo", jsonObject2);
// jsonObject.put("brandId", dataApi.getLoginInfo().getBrandId());
// jsonObject.put("studioId", dataApi.getLoginInfo().getStudioId());
// jsonObject.put("operatorId", dataApi.getLoginInfo().getAdminId());
//
// }
//
// dataApi.doRequest(RequestType.JSON,dataparams,jsonObject.toString(),dataheadrs).assetsSuccess(true);
// return dataApi.getBodyInJSON();
//
// }
/**
* @param
* @description:新建物品
* @param multiSpec:是否是多规格;true:多规格;false:单规格
* @description:新建物品_多规格(三个规格,每个规格都是三个规格值)
* @param xcxSaleState:是否开启小程序售卖 YES:开启 NO:关闭;
* @param price:每个规格值的售价
* @param inventory 库存
* @author: yff
**/
public
JSONObject
testCreateGoods
(
boolean
multiSpec
,
DataUserInfo
...
userInfos
)
{
public
JSONObject
testCreateGoods_multiple
(
String
xcxSaleState
,
String
price
,
int
inventory
,
DataUserInfo
...
userInfos
)
{
dataApi
.
setApiModule
(
ApiModule
.
Polar_Goods
)
.
setApiName
(
"API_createGoods"
)
.
setTerminal
(
Terminal
.
B
);
super
.
beforeDataRequest
(
userInfos
);
// 存量的分组:"id": "1873912725360504834","name": "自动化分组多规格",因为分组不能超过10个,所以很多地方用存量就够了
String
color1
=
"黑色"
;
String
color2
=
"白色"
;
String
size1
=
"大的"
;
...
...
@@ -34,8 +279,6 @@ public class GoodTools extends XMBaseTest {
JSONObject
jsonObject
=
new
JSONObject
();
//多规格
if
(
multiSpec
==
true
)
{
//商品介绍不为空,纯文本的写法
JSONObject
description
=
new
JSONObject
();
...
...
@@ -51,10 +294,10 @@ public class GoodTools extends XMBaseTest {
jsonObject
.
put
(
"description"
,
description
.
toString
());
jsonObject
.
put
(
"groupId"
,
"18
69984687228407810
"
);
jsonObject
.
put
(
"groupId"
,
"18
73912725360504834
"
);
jsonObject
.
put
(
"multiSpec"
,
true
);
jsonObject
.
put
(
"name"
,
"自动化创建三个规格"
+
RandomStringUtil
.
randomString
(
2
));
jsonObject
.
put
(
"xcxSaleState"
,
"YES"
);
jsonObject
.
put
(
"xcxSaleState"
,
xcxSaleState
);
JSONObject
multiSpecInfo
=
new
JSONObject
();
...
...
@@ -121,8 +364,8 @@ public class GoodTools extends XMBaseTest {
specCombinationList1Specs
.
add
(
size1
);
specCombinationList1Specs
.
add
(
skin1
);
specCombinationList1
.
put
(
"specs"
,
specCombinationList1Specs
);
specCombinationList1
.
put
(
"price"
,
"0.01"
);
specCombinationList1
.
put
(
"inventory"
,
10
);
specCombinationList1
.
put
(
"price"
,
price
);
specCombinationList1
.
put
(
"inventory"
,
inventory
);
specCombinationList
.
add
(
specCombinationList1
);
...
...
@@ -132,8 +375,8 @@ public class GoodTools extends XMBaseTest {
specCombinationList2Specs
.
add
(
size1
);
specCombinationList2Specs
.
add
(
skin2
);
specCombinationList2
.
put
(
"specs"
,
specCombinationList2Specs
);
specCombinationList2
.
put
(
"price"
,
"0.01"
);
specCombinationList2
.
put
(
"inventory"
,
10
);
specCombinationList2
.
put
(
"price"
,
price
);
specCombinationList2
.
put
(
"inventory"
,
inventory
);
specCombinationList
.
add
(
specCombinationList2
);
...
...
@@ -144,8 +387,8 @@ public class GoodTools extends XMBaseTest {
specCombinationList3Specs
.
add
(
size2
);
specCombinationList3Specs
.
add
(
skin1
);
specCombinationList3
.
put
(
"specs"
,
specCombinationList3Specs
);
specCombinationList3
.
put
(
"price"
,
"0.01"
);
specCombinationList3
.
put
(
"inventory"
,
10
);
specCombinationList3
.
put
(
"price"
,
price
);
specCombinationList3
.
put
(
"inventory"
,
inventory
);
specCombinationList
.
add
(
specCombinationList3
);
...
...
@@ -156,8 +399,8 @@ public class GoodTools extends XMBaseTest {
specCombinationList4Specs
.
add
(
size2
);
specCombinationList4Specs
.
add
(
skin2
);
specCombinationList4
.
put
(
"specs"
,
specCombinationList4Specs
);
specCombinationList4
.
put
(
"price"
,
"0.01"
);
specCombinationList4
.
put
(
"inventory"
,
10
);
specCombinationList4
.
put
(
"price"
,
price
);
specCombinationList4
.
put
(
"inventory"
,
inventory
);
specCombinationList
.
add
(
specCombinationList4
);
...
...
@@ -168,8 +411,8 @@ public class GoodTools extends XMBaseTest {
specCombinationList5Specs
.
add
(
size1
);
specCombinationList5Specs
.
add
(
skin1
);
specCombinationList5
.
put
(
"specs"
,
specCombinationList5Specs
);
specCombinationList5
.
put
(
"price"
,
"0.01"
);
specCombinationList5
.
put
(
"inventory"
,
10
);
specCombinationList5
.
put
(
"price"
,
price
);
specCombinationList5
.
put
(
"inventory"
,
inventory
);
specCombinationList
.
add
(
specCombinationList5
);
...
...
@@ -180,8 +423,8 @@ public class GoodTools extends XMBaseTest {
specCombinationList6Specs
.
add
(
size1
);
specCombinationList6Specs
.
add
(
skin2
);
specCombinationList6
.
put
(
"specs"
,
specCombinationList6Specs
);
specCombinationList6
.
put
(
"price"
,
"0.01"
);
specCombinationList6
.
put
(
"inventory"
,
10
);
specCombinationList6
.
put
(
"price"
,
price
);
specCombinationList6
.
put
(
"inventory"
,
inventory
);
specCombinationList
.
add
(
specCombinationList6
);
...
...
@@ -191,8 +434,8 @@ public class GoodTools extends XMBaseTest {
specCombinationList7Specs
.
add
(
size2
);
specCombinationList7Specs
.
add
(
skin1
);
specCombinationList7
.
put
(
"specs"
,
specCombinationList7Specs
);
specCombinationList7
.
put
(
"price"
,
"0.01"
);
specCombinationList7
.
put
(
"inventory"
,
10
);
specCombinationList7
.
put
(
"price"
,
price
);
specCombinationList7
.
put
(
"inventory"
,
inventory
);
specCombinationList
.
add
(
specCombinationList7
);
...
...
@@ -203,8 +446,8 @@ public class GoodTools extends XMBaseTest {
specCombinationList8Specs
.
add
(
size2
);
specCombinationList8Specs
.
add
(
skin2
);
specCombinationList8
.
put
(
"specs"
,
specCombinationList8Specs
);
specCombinationList8
.
put
(
"price"
,
"0.01"
);
specCombinationList8
.
put
(
"inventory"
,
10
);
specCombinationList8
.
put
(
"price"
,
price
);
specCombinationList8
.
put
(
"inventory"
,
inventory
);
specCombinationList
.
add
(
specCombinationList8
);
...
...
@@ -213,17 +456,37 @@ public class GoodTools extends XMBaseTest {
jsonObject
.
put
(
"brandId"
,
dataApi
.
getLoginInfo
().
getBrandId
());
jsonObject
.
put
(
"studioId"
,
dataApi
.
getLoginInfo
().
getStudioId
());
jsonObject
.
put
(
"operatorId"
,
dataApi
.
getLoginInfo
().
getAdminId
());
dataApi
.
doRequest
(
RequestType
.
JSON
,
dataparams
,
jsonObject
.
toString
(),
dataheadrs
).
assetsSuccess
(
true
);
return
dataApi
.
getBodyInJSON
();
}
//单规格
else
if
(
multiSpec
==
false
){
/**
* @param
* @description:新建物品_单规格
* @param xcxSaleState:是否开启小程序售卖 YES:开启 NO:关闭
* @param price:每个规格值的售价
* @param inventory 库存
* @author: yff
**/
public
JSONObject
testCreateGoods_single
(
String
xcxSaleState
,
String
price
,
int
inventory
,
DataUserInfo
...
userInfos
)
{
dataApi
.
setApiModule
(
ApiModule
.
Polar_Goods
)
.
setApiName
(
"API_createGoods"
)
.
setTerminal
(
Terminal
.
B
);
super
.
beforeDataRequest
(
userInfos
);
// 存量的分组: "id": "1873903328974499841","name": "自动化分组单规格",因为分组不能超过10个,所以很多地方用存量就够了
JSONObject
jsonObject
=
new
JSONObject
();
//商品介绍不为空,纯文本的写法
JSONObject
description
=
new
JSONObject
();
JSONArray
items
=
new
JSONArray
();
JSONObject
item1
=
new
JSONObject
();
item1
.
put
(
"type"
,
"TEXT"
);
item1
.
put
(
"content"
,
"自动化创建的
"
);
item1
.
put
(
"content"
,
"自动化创建的单规格
"
);
item1
.
put
(
"aspect"
,
""
);
items
.
add
(
item1
);
...
...
@@ -231,22 +494,20 @@ public class GoodTools extends XMBaseTest {
description
.
put
(
"items"
,
items
);
jsonObject
.
put
(
"description"
,
description
.
toString
());
jsonObject
.
put
(
"groupId"
,
"1869984687228407810
"
);
jsonObject
.
put
(
"groupId"
,
"1873903328974499841
"
);
jsonObject
.
put
(
"multiSpec"
,
false
);
jsonObject
.
put
(
"name"
,
"自动化创建单规格"
+
RandomStringUtil
.
randomString
(
2
));
jsonObject
.
put
(
"xcxSaleState"
,
"YES"
);
jsonObject
.
put
(
"xcxSaleState"
,
xcxSaleState
);
JSONObject
jsonObject2
=
new
JSONObject
();
jsonObject2
.
put
(
"inventory"
,
"10"
);
jsonObject2
.
put
(
"price"
,
"0.01"
);
jsonObject2
.
put
(
"inventory"
,
inventory
);
jsonObject2
.
put
(
"price"
,
price
);
jsonObject
.
put
(
"singleSpecInfo"
,
jsonObject2
);
jsonObject
.
put
(
"brandId"
,
dataApi
.
getLoginInfo
().
getBrandId
());
jsonObject
.
put
(
"studioId"
,
dataApi
.
getLoginInfo
().
getStudioId
());
jsonObject
.
put
(
"operatorId"
,
dataApi
.
getLoginInfo
().
getAdminId
());
}
dataApi
.
doRequest
(
RequestType
.
JSON
,
dataparams
,
jsonObject
.
toString
(),
dataheadrs
).
assetsSuccess
(
true
);
return
dataApi
.
getBodyInJSON
();
...
...
@@ -580,5 +841,58 @@ public class GoodTools extends XMBaseTest {
return
dataApi
.
getBodyInJSON
();
}
/**
* @param
* @description:B端修改物品的小程序售卖是否开启
* @param id:物品ID
* @param xcxSaleState:小程序是否开启 YES开启小程序售卖 NO关闭小程序售卖
* @author: yff
**/
public
JSONObject
modifyGoodsXcxSaleState
(
String
id
,
String
xcxSaleState
,
DataUserInfo
...
userInfos
){
dataApi
.
setApiModule
(
ApiModule
.
Polar_Goods
)
.
setApiName
(
"API_modifyGoodsXcxSaleState"
)
.
setTerminal
(
Terminal
.
B
);
super
.
beforeDataRequest
(
userInfos
);
JSONObject
jsonObject
=
new
JSONObject
();
jsonObject
.
put
(
"id"
,
id
);
jsonObject
.
put
(
"xcxSaleState"
,
xcxSaleState
);
jsonObject
.
put
(
"brandId"
,
dataApi
.
getLoginInfo
().
getBrandId
());
jsonObject
.
put
(
"studioId"
,
dataApi
.
getLoginInfo
().
getStudioId
());
jsonObject
.
put
(
"operatorId"
,
dataApi
.
getLoginInfo
().
getAdminId
());
dataApi
.
doRequest
(
RequestType
.
JSON
,
dataparams
,
jsonObject
.
toString
(),
dataheadrs
).
assetsSuccess
(
true
);
return
dataApi
.
getBodyInJSON
();
}
/**
* @param
* @description:B端修改物品状态是否为开启
* @param id:物品ID
* @param state:物品状态 YES启用 NO停用
* @author: yff
**/
public
JSONObject
modifyGoodsState
(
String
id
,
String
state
,
DataUserInfo
...
userInfos
){
dataApi
.
setApiModule
(
ApiModule
.
Polar_Goods
)
.
setApiName
(
"API_modifyGoodsState"
)
.
setTerminal
(
Terminal
.
B
);
super
.
beforeDataRequest
(
userInfos
);
JSONObject
jsonObject
=
new
JSONObject
();
jsonObject
.
put
(
"id"
,
id
);
jsonObject
.
put
(
"state"
,
state
);
jsonObject
.
put
(
"brandId"
,
dataApi
.
getLoginInfo
().
getBrandId
());
jsonObject
.
put
(
"studioId"
,
dataApi
.
getLoginInfo
().
getStudioId
());
jsonObject
.
put
(
"operatorId"
,
dataApi
.
getLoginInfo
().
getAdminId
());
dataApi
.
doRequest
(
RequestType
.
JSON
,
dataparams
,
jsonObject
.
toString
(),
dataheadrs
).
assetsSuccess
(
true
);
return
dataApi
.
getBodyInJSON
();
}
}
src/main/java/com/xiaomai/cases/polar/goods/createGoods.java
View file @
08084911
...
...
@@ -4,6 +4,8 @@ import com.alibaba.fastjson.JSONArray;
import
com.alibaba.fastjson.JSONObject
;
import
com.xiaomai.cases.lunar.goods.GoodCTools
;
import
com.xiaomai.cases.polar.goods.Tools.GoodTools
;
import
com.xiaomai.client.DataUserInfo
;
import
com.xiaomai.client.XMAppApi
;
import
com.xiaomai.enums.ApiModule
;
import
com.xiaomai.enums.LoginAccount
;
import
com.xiaomai.enums.RequestType
;
...
...
@@ -21,12 +23,14 @@ public class createGoods extends XMBaseTest {
String
studioResult1
;
String
studioResult2
;
DataUserInfo
info
=
new
DataUserInfo
();
@BeforeMethod
public
void
beforeTest
()
{
xmAppApi
.
setApiModule
(
ApiModule
.
Polar_Goods
)
.
setApiName
(
"API_createGoods"
)
.
setLoginUser
(
LoginAccount
.
YFF_RC
)
.
setLoginUser
(
LoginAccount
.
GYM_PROD
)
.
setTerminal
(
Terminal
.
B
);
dal
.
setCase_owner
(
"yff"
)
...
...
@@ -38,27 +42,28 @@ public class createGoods extends XMBaseTest {
public
void
testCreateGoods
()
{
//分组是存量的
,
因为只能创建10个,超了的话还是要用存量的
//分组是存量的
: "id": "1873912725360504834","name": "自动化分组多规格",
因为只能创建10个,超了的话还是要用存量的
//获取物品列表
//获取
B端
物品列表
JSONObject
beforeTotalStudioGoods
=
goodTools
.
studioGoods
();
int
beforeTotal
=
Integer
.
parseInt
(
beforeTotalStudioGoods
.
getJSONObject
(
"result"
).
getString
(
"total"
));
//
// //切换端位
// DataUserInfo info = new DataUserInfo();
// info.setTerminal(Terminal.C);
// info.setLoginUser(LoginAccount.GYM_MINIAPPC);
//切换端位
//切换端位
info
.
setTerminal
(
Terminal
.
minApp
);
info
.
setLoginUser
(
LoginAccount
.
GYM_MINIAPPC
);
try
{
Thread
.
sleep
(
3
000
);
Thread
.
sleep
(
6
000
);
}
catch
(
InterruptedException
e
)
{
throw
new
RuntimeException
(
e
);
}
// JSONObject beforePageXcxHomeGoods_C = goodCTools.pageXcxHomeGoods_
C(info);
//
int beforeTotal_C = Integer.parseInt(beforePageXcxHomeGoods_C.getJSONObject("result").getString("total"));
JSONObject
beforePageXcxHomeGoods_C
=
goodCTools
.
pageXcxHomeGoods
C
(
info
);
int
beforeTotal_C
=
Integer
.
parseInt
(
beforePageXcxHomeGoods_C
.
getJSONObject
(
"result"
).
getString
(
"total"
));
String
name
=
"自动化创建三个规格"
+
RandomStringUtil
.
randomString
(
2
);
...
...
@@ -93,7 +98,7 @@ public class createGoods extends XMBaseTest {
jsonObject
.
put
(
"description"
,
description
.
toString
());
jsonObject
.
put
(
"groupId"
,
"18
69984687228407810
"
);
jsonObject
.
put
(
"groupId"
,
"18
73912725360504834
"
);
jsonObject
.
put
(
"multiSpec"
,
true
);
jsonObject
.
put
(
"name"
,
name
);
jsonObject
.
put
(
"xcxSaleState"
,
"YES"
);
...
...
@@ -282,22 +287,22 @@ public class createGoods extends XMBaseTest {
throw
new
RuntimeException
(
e
);
}
//
//校验:
//
//校验2:获取C端物品列表
//
//①统计值增加1
//
//②有对应的商品id
// JSONObject afterPageXcxHomeGoods_C = goodCTools.pageXcxHomeGoods_
C(info);
//
int afterTotal_C = Integer.parseInt(afterPageXcxHomeGoods_C.getJSONObject("result").getString("total"));
//
JSONArray records_C = afterPageXcxHomeGoods_C.getJSONObject("result").getJSONArray("records");
//
//
boolean success_C=false;
//
for (int i = 0; i < records_C.size(); i++) {
//
if (records_C.getJSONObject(i).getString("id").equals(studioResult1)) {
//
success_C=true;
//
}
//
Assert.assertEquals(success_C, true, "新建三个规格的物品成功,但C端的物品列表未找到对应增加的物品ID");
//
}
//
Assert.assertEquals(afterTotal_C, beforeTotal_C + 1, "新建三个规格的物品成功,但C端物品列表的统计值未增加");
//校验:
//校验2:获取C端物品列表
//①统计值增加1
//②有对应的商品id
JSONObject
afterPageXcxHomeGoods_C
=
goodCTools
.
pageXcxHomeGoods
C
(
info
);
int
afterTotal_C
=
Integer
.
parseInt
(
afterPageXcxHomeGoods_C
.
getJSONObject
(
"result"
).
getString
(
"total"
));
JSONArray
records_C
=
afterPageXcxHomeGoods_C
.
getJSONObject
(
"result"
).
getJSONArray
(
"records"
);
boolean
success_C
=
false
;
for
(
int
i
=
0
;
i
<
records_C
.
size
();
i
++)
{
if
(
records_C
.
getJSONObject
(
i
).
getString
(
"id"
).
equals
(
studioResult1
))
{
success_C
=
true
;
}
Assert
.
assertEquals
(
success_C
,
true
,
"新建三个规格的物品成功,但C端的物品列表未找到对应增加的物品ID"
);
}
Assert
.
assertEquals
(
afterTotal_C
,
beforeTotal_C
+
1
,
"新建三个规格的物品成功,但C端物品列表的统计值未增加"
);
//校验3:获取B端物品详情,状态是开启,小程序售卖也是开启
...
...
@@ -318,13 +323,13 @@ public class createGoods extends XMBaseTest {
}
catch
(
InterruptedException
e
)
{
throw
new
RuntimeException
(
e
);
}
//
//
//校验4:获取C端物品详情,状态是开启,小程序售卖也是开启
//
JSONObject getDetail_goods_C=goodCTools.getDetail_goods_C(studioResult1,info);
//
String state_C=getDetail_goods_C.getJSONObject("result").getString("state");
//
String xcxSaleState_C=getDetail_goods_C.getJSONObject("result").getString("xcxSaleState");
//
Assert.assertEquals(state_C,"YES","新建物品是启用,但C端物品详情展示非启用");
//
Assert.assertEquals(xcxSaleState_C,"YES","新建物品是开启小程序售卖,但C端物品详情展示非开启小程序售卖");
//校验4:获取C端物品详情,状态是开启,小程序售卖也是开启
JSONObject
getDetail_goods_C
=
goodCTools
.
getDetail_goods_C
(
studioResult1
,
info
);
String
state_C
=
getDetail_goods_C
.
getJSONObject
(
"result"
).
getString
(
"state"
);
String
xcxSaleState_C
=
getDetail_goods_C
.
getJSONObject
(
"result"
).
getString
(
"xcxSaleState"
);
Assert
.
assertEquals
(
state_C
,
"YES"
,
"新建物品是启用,但C端物品详情展示非启用"
);
Assert
.
assertEquals
(
xcxSaleState_C
,
"YES"
,
"新建物品是开启小程序售卖,但C端物品详情展示非开启小程序售卖"
);
//校验5:获取B端查看多规格的库存详情,和物品详情的规格id都一致
...
...
@@ -352,15 +357,16 @@ public class createGoods extends XMBaseTest {
@Test
(
description
=
"创建物品-单规格"
)
public
void
testCreateGoods_1
()
{
//单规格:"id": "1873903328974499841", "name": "自动化分组单规格",
//获取物品列表
JSONObject
beforeTotalStudioGoods
=
goodTools
.
studioGoods
();
int
beforeTotal
=
Integer
.
parseInt
(
beforeTotalStudioGoods
.
getJSONObject
(
"result"
).
getString
(
"total"
));
// //切换端位
// DataUserInfo info = new DataUserInfo();
// info.setTerminal(Terminal.C);
// info.setLoginUser(LoginAccount.GYM_MINIAPPC);
//切换端位
info
.
setTerminal
(
Terminal
.
minApp
);
info
.
setLoginUser
(
LoginAccount
.
GYM_MINIAPPC
);
try
{
Thread
.
sleep
(
3000
);
...
...
@@ -369,8 +375,8 @@ public class createGoods extends XMBaseTest {
}
// JSONObject beforePageXcxHomeGoods_C = goodCTools.pageXcxHomeGoods_
C(info);
//
int beforeTotal_C = Integer.parseInt(beforePageXcxHomeGoods_C.getJSONObject("result").getString("total"));
JSONObject
beforePageXcxHomeGoods_C
=
goodCTools
.
pageXcxHomeGoods
C
(
info
);
int
beforeTotal_C
=
Integer
.
parseInt
(
beforePageXcxHomeGoods_C
.
getJSONObject
(
"result"
).
getString
(
"total"
));
String
name
=
"自动化创建单规格"
+
RandomStringUtil
.
randomString
(
2
);
...
...
@@ -393,7 +399,7 @@ public class createGoods extends XMBaseTest {
description
.
put
(
"items"
,
items
);
jsonObject
.
put
(
"description"
,
description
.
toString
());
jsonObject
.
put
(
"groupId"
,
"18
69984687228407810
"
);
jsonObject
.
put
(
"groupId"
,
"18
73903328974499841
"
);
jsonObject
.
put
(
"multiSpec"
,
false
);
jsonObject
.
put
(
"name"
,
"自动化创建单规格"
+
RandomStringUtil
.
randomString
(
2
));
jsonObject
.
put
(
"xcxSaleState"
,
"YES"
);
...
...
@@ -434,22 +440,22 @@ public class createGoods extends XMBaseTest {
throw
new
RuntimeException
(
e
);
}
//
//校验:
//
//校验2:获取C端物品列表
//
//①统计值增加1
//
//②有对应的商品id
// JSONObject afterPageXcxHomeGoods_C = goodCTools.pageXcxHomeGoods_
C(info);
//
int afterTotal_C = Integer.parseInt(afterPageXcxHomeGoods_C.getJSONObject("result").getString("total"));
//
JSONArray records_C = afterPageXcxHomeGoods_C.getJSONObject("result").getJSONArray("records");
//
//
boolean success_C=false;
//
for (int i = 0; i < records_C.size(); i++) {
//
if (records_C.getJSONObject(i).getString("id").equals(studioResult2)) {
//
success_C=true;
//
}
//
Assert.assertEquals(success_C, true, "新建三个规格的物品成功,但C端的物品列表未找到对应增加的物品ID");
//
}
//
Assert.assertEquals(afterTotal_C, beforeTotal_C + 1, "新建三个规格的物品成功,但C端物品列表的统计值未增加");
//校验:
//校验2:获取C端物品列表
//①统计值增加1
//②有对应的商品id
JSONObject
afterPageXcxHomeGoods_C
=
goodCTools
.
pageXcxHomeGoods
C
(
info
);
int
afterTotal_C
=
Integer
.
parseInt
(
afterPageXcxHomeGoods_C
.
getJSONObject
(
"result"
).
getString
(
"total"
));
JSONArray
records_C
=
afterPageXcxHomeGoods_C
.
getJSONObject
(
"result"
).
getJSONArray
(
"records"
);
boolean
success_C
=
false
;
for
(
int
i
=
0
;
i
<
records_C
.
size
();
i
++)
{
if
(
records_C
.
getJSONObject
(
i
).
getString
(
"id"
).
equals
(
studioResult2
))
{
success_C
=
true
;
}
Assert
.
assertEquals
(
success_C
,
true
,
"新建三个规格的物品成功,但C端的物品列表未找到对应增加的物品ID"
);
}
Assert
.
assertEquals
(
afterTotal_C
,
beforeTotal_C
+
1
,
"新建三个规格的物品成功,但C端物品列表的统计值未增加"
);
//校验3:获取B端物品详情,状态是开启,小程序售卖也是开启
...
...
@@ -464,13 +470,13 @@ public class createGoods extends XMBaseTest {
}
catch
(
InterruptedException
e
)
{
throw
new
RuntimeException
(
e
);
}
//
//
//校验4:获取C端物品详情,状态是开启,小程序售卖也是开启
//
JSONObject getDetail_goods_C=goodCTools.getDetail_goods_C(studioResult2,info);
//
String state_C=getDetail_goods_C.getJSONObject("result").getString("state");
//
String xcxSaleState_C=getDetail_goods_C.getJSONObject("result").getString("xcxSaleState");
//
Assert.assertEquals(state_C,"YES","新建物品是启用,但C端物品详情展示非启用");
//
Assert.assertEquals(xcxSaleState_C,"YES","新建物品是开启小程序售卖,但C端物品详情展示非开启小程序售卖");
//校验4:获取C端物品详情,状态是开启,小程序售卖也是开启
JSONObject
getDetail_goods_C
=
goodCTools
.
getDetail_goods_C
(
studioResult2
,
info
);
String
state_C
=
getDetail_goods_C
.
getJSONObject
(
"result"
).
getString
(
"state"
);
String
xcxSaleState_C
=
getDetail_goods_C
.
getJSONObject
(
"result"
).
getString
(
"xcxSaleState"
);
Assert
.
assertEquals
(
state_C
,
"YES"
,
"新建物品是启用,但C端物品详情展示非启用"
);
Assert
.
assertEquals
(
xcxSaleState_C
,
"YES"
,
"新建物品是开启小程序售卖,但C端物品详情展示非开启小程序售卖"
);
...
...
src/main/java/com/xiaomai/cases/polar/goods/createGoodsGroup.java
View file @
08084911
...
...
@@ -27,7 +27,7 @@ public class createGoodsGroup extends XMBaseTest {
public
void
beforeTest
()
{
xmAppApi
.
setApiModule
(
ApiModule
.
Polar_Goods
)
.
setApiName
(
"API_createGoodsGroup"
)
.
setLoginUser
(
LoginAccount
.
YFF_RC
)
.
setLoginUser
(
LoginAccount
.
GYM_PROD
)
.
setTerminal
(
Terminal
.
B
);
dal
.
setCase_owner
(
"yff"
)
...
...
@@ -77,7 +77,7 @@ public class createGoodsGroup extends XMBaseTest {
}
//新建一个物品
JSONObject
create
=
goodTools
.
testCreateGoods
(
true
);
JSONObject
create
=
goodTools
.
testCreateGoods
_multiple
(
"YES"
,
"0.01"
,
10
);
createId
=
create
.
getString
(
"result"
);
//新建分组成功后,批量移动物品至其分组
...
...
src/main/java/com/xiaomai/cases/polar/goods/deleteGood.java
View file @
08084911
package
com
.
xiaomai
.
cases
.
polar
.
goods
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.xiaomai.cases.polar.goods.Tools.GoodTools
;
import
com.xiaomai.enums.ApiModule
;
...
...
@@ -7,6 +8,7 @@ import com.xiaomai.enums.LoginAccount;
import
com.xiaomai.enums.RequestType
;
import
com.xiaomai.enums.Terminal
;
import
com.xiaomai.utils.XMBaseTest
;
import
org.testng.Assert
;
import
org.testng.annotations.BeforeMethod
;
import
org.testng.annotations.Test
;
...
...
@@ -18,7 +20,7 @@ public class deleteGood extends XMBaseTest {
public
void
beforeTest
()
{
xmAppApi
.
setApiModule
(
ApiModule
.
Polar_Goods
)
.
setApiName
(
"API_delete"
)
.
setLoginUser
(
LoginAccount
.
YFF_RC
)
.
setLoginUser
(
LoginAccount
.
GYM_PROD
)
.
setTerminal
(
Terminal
.
B
);
dal
.
setCase_owner
(
"yff"
)
...
...
@@ -30,12 +32,24 @@ public class deleteGood extends XMBaseTest {
@Test
(
description
=
"删除物品"
)
public
void
testCreateGoods
()
{
// JSONObject jsonObject=goodTools.testCreateGoods(true);
//新建物品
JSONObject
createGoods
=
goodTools
.
testCreateGoods_multiple
(
"YES"
,
"0.01"
,
10
);
String
id
=
createGoods
.
getString
(
"result"
);
//获取物品列表
JSONObject
studioGoods
=
goodTools
.
studioGoods
();
String
id
=
studioGoods
.
getJSONObject
(
"result"
).
getJSONArray
(
"records"
).
getJSONObject
(
0
).
getString
(
"id"
);
JSONArray
records
=
studioGoods
.
getJSONObject
(
"result"
).
getJSONArray
(
"records"
);
boolean
success
=
false
;
for
(
int
i
=
0
;
i
<
records
.
size
();
i
++){
if
(
records
.
getJSONObject
(
i
).
getString
(
"id"
).
equals
(
id
)){
success
=
true
;
}
Assert
.
assertEquals
(
success
,
true
,
"新建物品成功,但物品列表没有新增此条数据"
);
}
//删除物品
JSONObject
jsonObject
=
new
JSONObject
();
jsonObject
.
put
(
"id"
,
id
);
...
...
@@ -45,18 +59,32 @@ public class deleteGood extends XMBaseTest {
xmAppApi
.
doRequest
(
RequestType
.
JSON
,
params
,
jsonObject
.
toJSONString
(),
headers
).
assetsSuccess
(
true
);
try
{
Thread
.
sleep
(
5
000
);
Thread
.
sleep
(
3
000
);
}
catch
(
InterruptedException
e
)
{
throw
new
RuntimeException
(
e
);
}
}
@Test
public
void
xun
(){
for
(
int
i
=
0
;
i
<
46
;
i
++){
testCreateGoods
();
//校验1:物品列表中没有此数据
JSONObject
afterStudioGoods
=
goodTools
.
studioGoods
();
JSONArray
afterRecords
=
afterStudioGoods
.
getJSONObject
(
"result"
).
getJSONArray
(
"records"
);
boolean
afterSuccess
=
false
;
for
(
int
i
=
0
;
i
<
afterRecords
.
size
();
i
++){
if
(
!
afterRecords
.
getJSONObject
(
i
).
getString
(
"id"
).
equals
(
id
)){
afterSuccess
=
true
;
}
Assert
.
assertEquals
(
afterSuccess
,
true
,
"删除物品成功,但物品列表还有此条数据"
);
}
}
// @Test
// public void xun(){
// for(int i=0;i<20;i++){
// testCreateGoods();
// }
// }
}
\ No newline at end of file
src/main/java/com/xiaomai/enums/ApiModule.java
View file @
08084911
...
...
@@ -50,7 +50,7 @@ public class ApiModule {
public
static
String
Lunar_Training
=
"lunar_training"
;
//训练
public
static
String
Lunar_Share
=
"lunar_share"
;
//分享
public
static
String
Lunar_VenueArea
=
"lunar_venueArea"
;
//场地
public
static
String
Lunar_Goods
=
"lunar_
G
oods"
;
//物品
public
static
String
Lunar_Goods
=
"lunar_
g
oods"
;
//物品
public
static
String
Lunar_Invitation
=
"lunar_invitation"
;
...
...
src/main/java/com/xiaomai/enums/LoginAccount.java
View file @
08084911
...
...
@@ -24,4 +24,6 @@ public class LoginAccount {
public
static
String
YFF_RC
=
"yff_rc"
;
public
static
String
YFF_GRAY
=
"yff_gray"
;
//芳芳场馆
}
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