Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
test-platform
Project
Project
Details
Activity
Releases
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
马博
test-platform
Commits
f2f23b45
Commit
f2f23b45
authored
Dec 21, 2019
by
panyuli
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'pyl'
parents
47be2a10
f12851d3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
685 additions
and
12 deletions
+685
-12
权益一期线上用户核销中匹配兑换码兑换_DuibaTest.java
...cases/equitySubjectTest/权益一期线上用户核销中匹配兑换码兑换_DuibaTest.java
+18
-10
权益二期线上用户核销匹配权益及兑换码兑换_DuibaTest.java
...ses/equitySubjectTest/权益二期线上用户核销匹配权益及兑换码兑换_DuibaTest.java
+559
-0
equityPrizeService.java
src/test/java/http/service/Activity/equityPrizeService.java
+108
-2
No files found.
src/test/java/http/cases/equitySubjectTest/权益一期线上用户核销中匹配兑换码兑换_DuibaTest.java
View file @
f2f23b45
...
...
@@ -44,6 +44,7 @@ public class 权益一期线上用户核销中匹配兑换码兑换_DuibaTest ex
Response
response
=
equityPrizeService
.
exchange
(
authorization
.
dafuwengLogin
(
uid
),
exc_code
,
null
);
Thread
.
sleep
(
2000
);
Map
<
String
,
Object
>
ChangeStock
=
jdbc
.
findSimpleResult
(
"SELECT * FROM stock.tb_stock WHERE stock_id =1173112680215170105"
);
String
exchanggeStock
=
String
.
valueOf
(
ChangeStock
.
get
(
"stock"
));
...
...
@@ -66,9 +67,11 @@ public class 权益一期线上用户核销中匹配兑换码兑换_DuibaTest ex
throw
new
Exception
(
"异常信息打印:"
+
e
);
}
jdbc
.
update
(
"update goods.tb_equity_goods_record set consumer_id=null ,partner_user_id=null"
+
" ,app_item_id=null ,verification_time=null ,order_num=null where exc_code = '"
+
exc_code
+
"'"
);
}
finally
{
jdbc
.
update
(
"update goods.tb_equity_goods_record set consumer_id=null ,partner_user_id=null"
+
" ,app_item_id=null ,verification_time=null ,order_num=null where exc_code = '"
+
exc_code
+
"'"
);
}
}
@Test
...
...
@@ -266,6 +269,7 @@ public class 权益一期线上用户核销中匹配兑换码兑换_DuibaTest ex
//第一次核销
logger
.
info
(
"用户第一次核销"
);
Response
response
=
equityPrizeService
.
exchange
(
authorization
.
dafuwengLogin
(
uid
),
exc_code
,
null
);
Thread
.
sleep
(
2000
);
Map
<
String
,
Object
>
ChangeStock
=
jdbc
.
findSimpleResult
(
"SELECT * FROM stock.tb_stock WHERE stock_id =1178701910023420109"
);
//第一次兑换之后的商品的库存成功
String
exchanggeStock
=
String
.
valueOf
(
ChangeStock
.
get
(
"stock"
));
...
...
@@ -284,8 +288,10 @@ public class 权益一期线上用户核销中匹配兑换码兑换_DuibaTest ex
logger
.
info
(
"进行第二次核销"
);
response
=
equityPrizeService
.
exchange
(
authorization
.
dafuwengLogin
(
uid
),
exc_code1
,
null
);
ChangeStock
=
jdbc
.
findSimpleResult
(
"SELECT * FROM stock.tb_stock WHERE stock_id =1178701910023420109"
);
exchanggeStock
=
String
.
valueOf
(
ChangeStock
.
get
(
"stock"
));
Thread
.
sleep
(
2000
);
ChangeStock
=
jdbc
.
findSimpleResult
(
"SELECT * FROM stock.tb_stock WHERE stock_id =1178701910023420109"
);
exchanggeStock
=
String
.
valueOf
(
ChangeStock
.
get
(
"stock"
));
//response.prettyPrint();
//获取到 code 数据
code
=
response
.
jsonPath
().
getString
(
"code"
);
...
...
@@ -315,12 +321,14 @@ public class 权益一期线上用户核销中匹配兑换码兑换_DuibaTest ex
throw
new
Exception
(
"异常信息打印:"
+
e
);
}
finally
{
jdbc
.
update
(
"update goods.tb_equity_goods_record set consumer_id=null ,partner_user_id=null"
+
" ,app_item_id=null ,verification_time=null ,order_num=null where exc_code = '"
+
exc_code
+
"'"
);
jdbc
.
update
(
"update goods.tb_equity_goods_record set consumer_id=null ,partner_user_id=null"
+
" ,app_item_id=null ,verification_time=null ,order_num=null where exc_code = '"
+
exc_code1
+
"'"
);
jdbc
.
update
(
"DELETE FROM goods.tb_everyday_limit where app_item_id ='199280 '"
);
}
jdbc
.
update
(
"update goods.tb_equity_goods_record set consumer_id=null ,partner_user_id=null"
+
" ,app_item_id=null ,verification_time=null ,order_num=null where exc_code = '"
+
exc_code
+
"'"
);
jdbc
.
update
(
"update goods.tb_equity_goods_record set consumer_id=null ,partner_user_id=null"
+
" ,app_item_id=null ,verification_time=null ,order_num=null where exc_code = '"
+
exc_code1
+
"'"
);
jdbc
.
update
(
"DELETE FROM goods.tb_everyday_limit where app_item_id ='199280 '"
);
}
}
...
...
src/test/java/http/cases/equitySubjectTest/权益二期线上用户核销匹配权益及兑换码兑换_DuibaTest.java
0 → 100644
View file @
f2f23b45
package
http
.
cases
.
equitySubjectTest
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
http.cases.ExchangeTest.CheckTemplet
;
import
http.service.Activity.equityPrizeService
;
import
http.service.Authorization
;
import
io.restassured.response.Response
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.testng.Assert
;
import
org.testng.annotations.Test
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
public
class
权益二期线上用户核销匹配权益及兑换码兑换
_DuibaTest
extends
CheckTemplet
{
@Autowired
public
equityPrizeService
equityPrizeService
;
@Autowired
private
Authorization
authorization
;
int
uid
=
7409
;
@Test
//(invocationCount=5)一个权益下面多少商品的数据
public
void
权益商品列表数据返回正确
()
throws
Exception
{
//权益id:12 核销下面对应的商品的 实物 :id 199281 = 优惠券id:199282
logger
.
info
(
"权益类表数据返回正确 -开始了"
);
String
equityId
=
"12"
;
//查询权益下面的商品数据
Response
response
=
equityPrizeService
.
chwequityGoodsList
(
authorization
.
dafuwengLogin
(
uid
),
equityId
);
String
code
=
response
.
jsonPath
().
getString
(
"code"
);
Assert
.
assertEquals
(
code
,
"0000000000"
,
"权益类表数据返回正确接口 失败,code:"
+
code
);
String
data
=
JSON
.
parseObject
(
response
.
asString
()).
getString
(
"data"
);
JSONArray
jsonArray
=
JSON
.
parseArray
(
data
);
List
<
String
>
list
=
new
ArrayList
();
for
(
Object
jsonobject:
jsonArray
)
{
String
s
=
jsonobject
.
toString
();
JSONObject
js
=
JSON
.
parseObject
(
s
);
String
appitem
=
js
.
getString
(
"appItemId"
);
list
.
add
(
appitem
);
}
//数组长度的校验 长度判断
Assert
.
assertEquals
(
list
.
size
()+
""
,
"2"
,
"接口数据返回listsize()数值 不一致,size:"
+
list
.
size
()
);
String
appItemId
=
list
.
get
(
0
);
logger
.
info
(
"list.get(0) appItemId:"
+
appItemId
+
"list.get(1) appItemId1:"
+
list
.
get
(
1
));
Assert
.
assertEquals
(
appItemId
,
"199281"
,
"接口获取商品的1id 不一致,code:"
+
appItemId
);
String
appItemId1
=
list
.
get
(
1
);
Assert
.
assertEquals
(
appItemId1
,
"199282"
,
"接口获取商品的2id 不一致,code:"
+
appItemId1
);
logger
.
info
(
"权益类表数据返回正确 -结束了"
);
}
@Test
//(invocationCount=5)一个组件下面多少个权益数据
public
void
权益列表首页接口返回正确
()
throws
Exception
{
logger
.
info
(
"权益列表首页接口返回正确 -开始了"
);
ArrayList
<
Integer
>
list
=
new
ArrayList
<
Integer
>();
list
.
add
(
25
);
list
.
add
(
24
);
Response
response
=
equityPrizeService
.
chwvisualeditorfindEquityListByIds
(
authorization
.
dafuwengLogin
(
uid
),
list
);
response
.
prettyPrint
();
List
<
Integer
>
ids
=
response
.
jsonPath
().
getList
(
"data.id"
);
Assert
.
assertTrue
(
response
.
jsonPath
().
getBoolean
(
"success"
),
"接口返回失败"
);
// Assert.assertEquals(code,"0000000000","权益类表数据返回正确接口 失败,code:"+code );
Assert
.
assertEquals
(
ids
.
size
(),
list
.
size
(),
"数据条数不匹配"
);
logger
.
info
(
"权益列表首页接口返回正确 -结束了"
);
}
@Test
//(invocationCount=5)
public
void
商品兑换首页成功
()
throws
Exception
{
logger
.
info
(
"商品兑换首页成功 -->开始了"
);
String
equityId
=
"12"
;
String
appItemId
=
"199281"
;
String
appSkuId
=
"222"
;
//查询权益下面的商品数据
Response
response
=
equityPrizeService
.
gawequityPrizeindex
(
authorization
.
dafuwengLogin
(
uid
),
equityId
,
appItemId
,
appSkuId
);
Assert
.
assertEquals
(
response
.
prettyPrint
().
contains
(
"确认兑换"
),
true
,
"页面数据没有包含确认兑换"
);
logger
.
info
(
"商品兑换首页成功 -->结束了"
);
}
@Test
public
void
兑换码为
null
核销
()
throws
Exception
{
logger
.
info
(
" 兑换码为null核销-->开始了"
);
String
equityId
=
"12"
;
String
appItemId
=
"199281"
;
String
appSkuId
=
"222"
;
String
excCode
=
null
;
Response
response
=
equityPrizeService
.
gawequityPrizeexchange
(
authorization
.
dafuwengLogin
(
uid
),
excCode
,
appItemId
,
equityId
,
appSkuId
);
String
code
=
response
.
jsonPath
().
getString
(
"code"
);
String
desc
=
response
.
jsonPath
().
getString
(
"desc"
);
logger
.
info
(
"code:"
+
code
+
",desc:"
+
desc
);
//校验
Assert
.
assertEquals
(
code
,
"1001000"
,
"兑换码为null核销 有问题"
);
response
.
prettyPrint
();
logger
.
info
(
" 兑换码为null核销-->结束了"
);
}
@Test
(
description
=
"自有商品优惠券兑换"
)
//取值orderid 取值,等等在写
public
void
ZDH
核销二期自有优惠券核销成功
()
throws
Exception
{
String
excCode
=
"AQAQ49"
;
try
{
logger
.
info
(
" ZDH核销二期自有优惠券核销成功-->开始了"
);
String
equityId
=
"14"
;
String
appItemId
=
"199342"
;
String
appSkuId
=
"224"
;
Map
<
String
,
Object
>
mapStock
=
jdbc
.
findSimpleResult
(
"SELECT * FROM stock.tb_stock WHERE stock_id =1180511530272670111"
);
//获取兑换之前优惠券的库存stock
String
stock
=
String
.
valueOf
(
mapStock
.
get
(
"stock"
));
//请求核销接口
Response
response
=
equityPrizeService
.
gawequityPrizeexchange
(
authorization
.
dafuwengLogin
(
uid
),
excCode
,
appItemId
,
equityId
,
appSkuId
);
response
.
prettyPrint
();
Thread
.
sleep
(
2000
);
mapStock
=
jdbc
.
findSimpleResult
(
"SELECT * FROM stock.tb_stock WHERE stock_id =1180511530272670111"
);
//核销之后优惠券的库存
String
exchanggeStock
=
String
.
valueOf
(
mapStock
.
get
(
"stock"
));
//核对兑换之后以及兑换之后的库存
logger
.
info
(
"stock:"
+
stock
+
"exchanggeStock:"
+
exchanggeStock
);
Assert
.
assertEquals
(
stock
,
(
Integer
.
parseInt
(
exchanggeStock
)
+
1
+
""
),
"兑换之后商品库存兑换不一致-失敗"
);
//获取:订单号
String
orderId
=
response
.
jsonPath
().
getString
(
"data.orderId"
);
logger
.
info
(
"data.orderId= :"
+
orderId
);
Assert
.
assertEquals
(
orderId
.
isEmpty
(),
false
,
"订单号没有获取到"
);
//获取code以及desc
response
.
prettyPrint
();
logger
.
info
(
" ZDH核销二期自有优惠券核销成功-->结束了"
);
}
catch
(
Exception
e
){
throw
new
Exception
(
"异常信息打印:"
+
e
);
}
finally
{
jdbc
.
update
(
"update goods.tb_equity_goods_record set consumer_id=null ,partner_user_id=null"
+
" ,app_item_id=null ,verification_time=null ,order_num=null , app_sku_id =null where exc_code = '"
+
excCode
+
"'"
);
}
}
@Test
public
void
ZDH
核销二期权益已过期
()
throws
Exception
{
//equityId=15
logger
.
info
(
"ZDH核销二期权益已过期【】 --》开始了"
);
String
equityId
=
"15"
;
String
appItemId
=
"199477"
;
String
appSkuId
=
"249"
;
String
excCode
=
"2-ZdH9"
;
Response
response
=
equityPrizeService
.
gawequityPrizeexchange
(
authorization
.
dafuwengLogin
(
uid
),
excCode
,
appItemId
,
equityId
,
appSkuId
);
String
code
=
response
.
jsonPath
().
getString
(
"code"
);
String
desc
=
response
.
jsonPath
().
getString
(
"desc"
);
logger
.
info
(
"code:"
+
code
+
",desc:"
+
desc
);
//校验
Assert
.
assertEquals
(
code
,
"1001003"
,
"ZDH权益已过期 有问题"
);
response
.
prettyPrint
();
logger
.
info
(
" ZDH核销二期权益已过期-->结束了"
);
}
@Test
//匹配权益,输入不是这个权益下的兑换码【匹配权益及兑换码兑换】
public
void
ZDH
二期权益兑换输入其他权益的兑换码
()
throws
Exception
{
//equityId=15
logger
.
info
(
"ZDH二期权益兑换输入其他权益的兑换码 --》开始了"
);
String
equityId
=
"14"
;
String
appItemId
=
"199342"
;
String
appSkuId
=
"224"
;
//exeCode 是权益equityId=15 下的 2-ZdH9
String
excCode
=
"2-ZdH9"
;
Response
response
=
equityPrizeService
.
gawequityPrizeexchange
(
authorization
.
dafuwengLogin
(
uid
),
excCode
,
appItemId
,
equityId
,
appSkuId
);
String
code
=
response
.
jsonPath
().
getString
(
"code"
);
String
desc
=
response
.
jsonPath
().
getString
(
"desc"
);
logger
.
info
(
"code:"
+
code
+
",desc:"
+
desc
);
//校验
Assert
.
assertEquals
(
code
,
"1001000"
,
"ZDH二期权益兑换输入其他权益的兑换码 有问题"
);
response
.
prettyPrint
();
logger
.
info
(
" ZDH二期权益兑换输入其他权益的兑换码-->结束了"
);
}
@Test
public
void
ZDH
二期权益兑换输入不存在的兑换码
()
throws
Exception
{
//equityId=15
logger
.
info
(
"ZDH二期权益兑换输入不存在的兑换码( --》开始了"
);
String
equityId
=
"14"
;
String
appItemId
=
"199342"
;
String
appSkuId
=
"224"
;
String
excCode
=
"AJDNKDNCKDNVKDNKKSNKDN"
;
Response
response
=
equityPrizeService
.
gawequityPrizeexchange
(
authorization
.
dafuwengLogin
(
uid
),
excCode
,
appItemId
,
equityId
,
appSkuId
);
String
code
=
response
.
jsonPath
().
getString
(
"code"
);
String
desc
=
response
.
jsonPath
().
getString
(
"desc"
);
logger
.
info
(
"code:"
+
code
+
",desc:"
+
desc
);
//校验
Assert
.
assertEquals
(
code
,
"1001000"
,
"ZDH二期权益兑换输入不存在的兑换码( 有问题"
);
response
.
prettyPrint
();
logger
.
info
(
" ZDH二期权益兑换输入不存在的兑换码(-->结束了"
);
}
@Test
public
void
ZDH
二期权益权益删除
()
throws
Exception
{
//equityId=15
logger
.
info
(
"ZDH二期权益权益删除( --》开始了"
);
String
equityId
=
"16"
;
String
appItemId
=
"199478"
;
String
appSkuId
=
"250"
;
String
excCode
=
"2-ZdH-DELET8"
;
Response
response
=
equityPrizeService
.
gawequityPrizeexchange
(
authorization
.
dafuwengLogin
(
uid
),
excCode
,
appItemId
,
equityId
,
appSkuId
);
String
code
=
response
.
jsonPath
().
getString
(
"code"
);
String
desc
=
response
.
jsonPath
().
getString
(
"desc"
);
logger
.
info
(
"code:"
+
code
+
",desc:"
+
desc
);
//校验
Assert
.
assertEquals
(
code
,
"1001000"
,
"ZDH二期权益权益删除( 有问题"
);
response
.
prettyPrint
();
logger
.
info
(
" ZDH二期权益权益删除(-->结束了"
);
}
@Test
public
void
ZDH
兑换码删除输入删除的兑换码
()
throws
Exception
{
//equityId=15
logger
.
info
(
"2-ZDH兑换码删除输入删除的兑换码( --》开始了"
);
String
equityId
=
"17"
;
String
appItemId
=
"199479"
;
String
appSkuId
=
"251"
;
String
excCode
=
"2-ZdHDHUN2"
;
Response
response
=
equityPrizeService
.
gawequityPrizeexchange
(
authorization
.
dafuwengLogin
(
uid
),
excCode
,
appItemId
,
equityId
,
appSkuId
);
String
code
=
response
.
jsonPath
().
getString
(
"code"
);
String
desc
=
response
.
jsonPath
().
getString
(
"desc"
);
logger
.
info
(
"code:"
+
code
+
",desc:"
+
desc
);
//校验
Assert
.
assertEquals
(
code
,
"1001000"
,
"2-ZDH兑换码删除输入删除的兑换码( 有问题"
);
response
.
prettyPrint
();
logger
.
info
(
" 2-ZDH兑换码删除输入删除的兑换码(-->结束了"
);
}
@Test
public
void
ZDH
兑换码已核销再次兑换
()
throws
Exception
{
//equityId=15
logger
.
info
(
"2-ZDH兑换码已核销再次兑换( --》开始了"
);
String
equityId
=
"14"
;
String
appItemId
=
"199342"
;
String
appSkuId
=
"224"
;
String
excCode
=
"AQAQ46"
;
Response
response
=
equityPrizeService
.
gawequityPrizeexchange
(
authorization
.
dafuwengLogin
(
uid
),
excCode
,
appItemId
,
equityId
,
appSkuId
);
String
code
=
response
.
jsonPath
().
getString
(
"code"
);
String
desc
=
response
.
jsonPath
().
getString
(
"desc"
);
logger
.
info
(
"code:"
+
code
+
",desc:"
+
desc
);
//校验
Assert
.
assertEquals
(
code
,
"1001001"
,
"2-ZDH兑换码已核销再次兑换( 有问题"
);
response
.
prettyPrint
();
logger
.
info
(
" 2-ZDH兑换码已核销再次兑换(-->结束了"
);
}
@Test
public
void
ZDH
权益未过期兑换码过期
()
throws
Exception
{
//equityId=15
logger
.
info
(
"2-ZDH权益未过期兑换码过期( --》开始了"
);
String
equityId
=
"18"
;
String
appItemId
=
"199479"
;
String
appSkuId
=
"251"
;
String
excCode
=
"AS12"
;
Response
response
=
equityPrizeService
.
gawequityPrizeexchange
(
authorization
.
dafuwengLogin
(
uid
),
excCode
,
appItemId
,
equityId
,
appSkuId
);
String
code
=
response
.
jsonPath
().
getString
(
"code"
);
String
desc
=
response
.
jsonPath
().
getString
(
"desc"
);
logger
.
info
(
"code:"
+
code
+
",desc:"
+
desc
);
//校验
Assert
.
assertEquals
(
code
,
"1001003"
,
"2-ZDH权益未过期兑换码过期( 有问题"
);
response
.
prettyPrint
();
logger
.
info
(
" 2-ZDH权益未过期兑换码过期(-->结束了"
);
}
@Test
public
void
ZDH
权益未开始进行兑换
()
throws
Exception
{
//equityId=15
logger
.
info
(
"2-ZDH权益未开始进行兑换( --》开始了"
);
String
equityId
=
"19"
;
String
appItemId
=
"199480"
;
String
appSkuId
=
"252"
;
String
excCode
=
"ASQ10"
;
Response
response
=
equityPrizeService
.
gawequityPrizeexchange
(
authorization
.
dafuwengLogin
(
uid
),
excCode
,
appItemId
,
equityId
,
appSkuId
);
String
code
=
response
.
jsonPath
().
getString
(
"code"
);
String
desc
=
response
.
jsonPath
().
getString
(
"desc"
);
logger
.
info
(
"code:"
+
code
+
",desc:"
+
desc
);
//校验
Assert
.
assertEquals
(
code
,
"1001002"
,
"2-ZDH权益未开始进行兑换( 有问题"
);
response
.
prettyPrint
();
logger
.
info
(
" 2-ZDH权益未开始进行兑换(-->结束了"
);
}
@Test
(
description
=
"自有商品奖品库存不足"
)
public
void
ZDH
权益已开始库存不足
()
throws
Exception
{
//equityId=15
logger
.
info
(
"2-ZDH权益已开始库存不足( --》开始了"
);
String
equityId
=
"20"
;
String
appItemId
=
"199481"
;
String
appSkuId
=
"253"
;
String
excCode
=
"ASQ25"
;
Response
response
=
equityPrizeService
.
gawequityPrizeexchange
(
authorization
.
dafuwengLogin
(
uid
),
excCode
,
appItemId
,
equityId
,
appSkuId
);
String
code
=
response
.
jsonPath
().
getString
(
"code"
);
String
desc
=
response
.
jsonPath
().
getString
(
"desc"
);
logger
.
info
(
"code:"
+
code
+
",desc:"
+
desc
);
//校验
Assert
.
assertEquals
(
code
,
"1001002"
,
"2-ZDH权益已开始库存不足( 有问题"
);
response
.
prettyPrint
();
logger
.
info
(
" 2-ZDH权益已开始库存不足(-->结束了"
);
}
@Test
(
description
=
"自有商品单规格实物-核销成功"
)
public
void
ZDH
核销二期自有商品自有商品单规格实物
()
throws
Exception
{
String
excCode
=
"ASQ55"
;
try
{
logger
.
info
(
" ZDH核销二期自有商品自有商品单规格实物-->开始了"
);
String
equityId
=
"22"
;
String
appItemId
=
"199482"
;
String
appSkuId
=
"254"
;
Map
<
String
,
Object
>
mapStock
=
jdbc
.
findSimpleResult
(
"SELECT * FROM stock.tb_stock WHERE stock_id =1187647586463670254"
);
//获取兑换之前优惠券的库存stock
String
stock
=
String
.
valueOf
(
mapStock
.
get
(
"stock"
));
//请求核销接口
Response
response
=
equityPrizeService
.
gawequityPrizeexchange
(
authorization
.
dafuwengLogin
(
uid
),
excCode
,
appItemId
,
equityId
,
appSkuId
);
response
.
prettyPrint
();
Thread
.
sleep
(
2000
);
mapStock
=
jdbc
.
findSimpleResult
(
"SELECT * FROM stock.tb_stock WHERE stock_id =1187647586463670254"
);
//核销之后优惠券的库存
String
exchanggeStock
=
String
.
valueOf
(
mapStock
.
get
(
"stock"
));
//核对兑换之后以及兑换之后的库存
logger
.
info
(
"stock:"
+
stock
+
"exchanggeStock:"
+
exchanggeStock
);
Assert
.
assertEquals
(
stock
,
(
Integer
.
parseInt
(
exchanggeStock
)
+
1
+
""
),
"兑换之后商品库存兑换不一致-失敗"
);
//获取:订单号
String
orderId
=
response
.
jsonPath
().
getString
(
"data.orderId"
);
logger
.
info
(
"data.orderId= :"
+
orderId
);
Assert
.
assertEquals
(
orderId
.
isEmpty
(),
false
,
"订单号没有获取到"
);
//获取code以及desc
response
.
prettyPrint
();
logger
.
info
(
" ZDH核销二期自有商品自有商品单规格实物-->结束了"
);
}
catch
(
Exception
e
){
throw
new
Exception
(
"异常信息打印:"
+
e
);
}
jdbc
.
update
(
"update goods.tb_equity_goods_record set consumer_id=null ,partner_user_id=null"
+
" ,app_item_id=null ,verification_time=null ,order_num=null , app_sku_id =null where exc_code = '"
+
excCode
+
"'"
);
}
@Test
(
description
=
"自有商品多规格实物-核销成功 -选择大的 规格"
)
public
void
ZDH
核销二期自有商品多规格实物核销
()
throws
Exception
{
String
excCode
=
"ASQ45"
;
try
{
logger
.
info
(
" ZDH核销二期自有商品多规格实物核销-->开始了"
);
String
equityId
=
"21"
;
String
appItemId
=
"199483"
;
String
appSkuId
=
"256"
;
Map
<
String
,
Object
>
mapStock
=
jdbc
.
findSimpleResult
(
"SELECT * FROM stock.tb_stock WHERE stock_id =1187709945218920256"
);
//获取兑换之前优惠券的库存stock
String
stock
=
String
.
valueOf
(
mapStock
.
get
(
"stock"
));
//请求核销接口
Response
response
=
equityPrizeService
.
gawequityPrizeexchange
(
authorization
.
dafuwengLogin
(
uid
),
excCode
,
appItemId
,
equityId
,
appSkuId
);
response
.
prettyPrint
();
Thread
.
sleep
(
2000
);
mapStock
=
jdbc
.
findSimpleResult
(
"SELECT * FROM stock.tb_stock WHERE stock_id =1187709945218920256"
);
//核销之后优惠券的库存
String
exchanggeStock
=
String
.
valueOf
(
mapStock
.
get
(
"stock"
));
//核对兑换之后以及兑换之后的库存
logger
.
info
(
"stock:"
+
stock
+
"exchanggeStock:"
+
exchanggeStock
);
Assert
.
assertEquals
(
stock
,
(
Integer
.
parseInt
(
exchanggeStock
)
+
1
+
""
),
"兑换之后商品库存兑换不一致-失敗"
);
//获取:订单号
String
orderId
=
response
.
jsonPath
().
getString
(
"data.orderId"
);
logger
.
info
(
"data.orderId= :"
+
orderId
);
Assert
.
assertEquals
(
orderId
.
isEmpty
(),
false
,
"订单号没有获取到"
);
//获取code以及desc
response
.
prettyPrint
();
logger
.
info
(
" ZDH核销二期自有商品多规格实物核销-->结束了"
);
}
catch
(
Exception
e
){
throw
new
Exception
(
"异常信息打印:"
+
e
);
}
finally
{
jdbc
.
update
(
"update goods.tb_equity_goods_record set consumer_id=null ,partner_user_id=null"
+
" ,app_item_id=null ,verification_time=null ,order_num=null , app_sku_id =null where exc_code = '"
+
excCode
+
"'"
);}
}
@Test
(
description
=
"自有商品多规格实物-核销成功 -选择中的 规格 库存不足"
)
public
void
ZDH
核销二期自有商品多规格实物核销其中规格一个无库存
()
throws
Exception
{
String
excCode
=
"ASQ46"
;
try
{
logger
.
info
(
" ZDH核销二期自有商品多规格实物核销其中规格一个无库存-->开始了"
);
String
equityId
=
"21"
;
String
appItemId
=
"199483"
;
String
appSkuId
=
"258"
;
Response
response
=
equityPrizeService
.
gawequityPrizeexchange
(
authorization
.
dafuwengLogin
(
uid
),
excCode
,
appItemId
,
equityId
,
appSkuId
);
String
code
=
response
.
jsonPath
().
getString
(
"code"
);
String
desc
=
response
.
jsonPath
().
getString
(
"desc"
);
logger
.
info
(
"code:"
+
code
+
",desc:"
+
desc
);
//校验
Assert
.
assertEquals
(
code
,
"1001002"
,
"2-ZDH核销二期自有商品多规格实物核销其中规格一个无库存( 有问题"
);
//获取code以及desc
response
.
prettyPrint
();
logger
.
info
(
" ZDH核销二期自有商品多规格实物核销其中规格一个无库存-->结束了"
);
}
catch
(
Exception
e
){
throw
new
Exception
(
"异常信息打印:"
+
e
);
}
jdbc
.
update
(
"update goods.tb_equity_goods_record set consumer_id=null ,partner_user_id=null"
+
" ,app_item_id=null ,verification_time=null ,order_num=null , app_sku_id =null where exc_code = '"
+
excCode
+
"'"
);
}
@Test
(
description
=
"自有商品多规格实物-核销成功 -选择中的 规格 规格不存在"
)
public
void
ZDH
核销二期自有商品多规格实物核销其中规格规格不存在
()
throws
Exception
{
String
excCode
=
"ASQ46"
;
try
{
logger
.
info
(
" ZDH核销二期自有商品多规格实物核销其中规格一个无库存-->开始了"
);
String
equityId
=
"21"
;
String
appItemId
=
"199483"
;
String
appSkuId
=
"2581"
;
Response
response
=
equityPrizeService
.
gawequityPrizeexchange
(
authorization
.
dafuwengLogin
(
uid
),
excCode
,
appItemId
,
equityId
,
appSkuId
);
String
code
=
response
.
jsonPath
().
getString
(
"code"
);
String
desc
=
response
.
jsonPath
().
getString
(
"desc"
);
logger
.
info
(
"code:"
+
code
+
",desc:"
+
desc
);
//校验
Assert
.
assertEquals
(
code
,
"1001002"
,
"2-ZDH核销二期自有商品多规格实物核销其中规格一个无库存( 有问题"
);
//获取code以及desc
response
.
prettyPrint
();
logger
.
info
(
" ZDH核销二期自有商品多规格实物核销其中规格一个无库存-->结束了"
);
}
catch
(
Exception
e
){
throw
new
Exception
(
"异常信息打印:"
+
e
);
}
jdbc
.
update
(
"update goods.tb_equity_goods_record set consumer_id=null ,partner_user_id=null"
+
" ,app_item_id=null ,verification_time=null ,order_num=null , app_sku_id =null where exc_code = '"
+
excCode
+
"'"
);
}
@Test
(
description
=
"自有商品实物下架"
)
public
void
ZDH
自有商品实物下架
()
throws
Exception
{
String
excCode
=
"ASQ83"
;
try
{
logger
.
info
(
" ZDH自有商品实物下架-->开始了"
);
String
equityId
=
"23"
;
String
appItemId
=
"199484"
;
String
appSkuId
=
"259"
;
Response
response
=
equityPrizeService
.
gawequityPrizeexchange
(
authorization
.
dafuwengLogin
(
uid
),
excCode
,
appItemId
,
equityId
,
appSkuId
);
String
code
=
response
.
jsonPath
().
getString
(
"code"
);
String
desc
=
response
.
jsonPath
().
getString
(
"desc"
);
logger
.
info
(
"code:"
+
code
+
",desc:"
+
desc
);
//校验
Assert
.
assertEquals
(
code
,
"1001002"
,
"2-ZDH自有商品实物下架( 有问题"
);
//获取code以及desc
response
.
prettyPrint
();
logger
.
info
(
" ZDH自有商品实物下架-->结束了"
);
}
catch
(
Exception
e
){
throw
new
Exception
(
"异常信息打印:"
+
e
);
}
jdbc
.
update
(
"update goods.tb_equity_goods_record set consumer_id=null ,partner_user_id=null"
+
" ,app_item_id=null ,verification_time=null ,order_num=null , app_sku_id =null where exc_code = '"
+
excCode
+
"'"
);
}
@Test
(
description
=
"自有商品实物删除"
)
public
void
自有商品实物删除
()
throws
Exception
{
String
excCode
=
"ASQ95"
;
try
{
logger
.
info
(
" 自有商品实物删除-->开始了"
);
String
equityId
=
"24"
;
String
appItemId
=
"199485"
;
String
appSkuId
=
"260"
;
Response
response
=
equityPrizeService
.
gawequityPrizeexchange
(
authorization
.
dafuwengLogin
(
uid
),
excCode
,
appItemId
,
equityId
,
appSkuId
);
String
code
=
response
.
jsonPath
().
getString
(
"code"
);
String
desc
=
response
.
jsonPath
().
getString
(
"desc"
);
logger
.
info
(
"code:"
+
code
+
",desc:"
+
desc
);
//校验
Assert
.
assertEquals
(
code
,
"1001002"
,
"2-自有商品实物删除( 有问题"
);
//获取code以及desc
response
.
prettyPrint
();
logger
.
info
(
" 自有商品实物删除-->结束了"
);
}
catch
(
Exception
e
){
throw
new
Exception
(
"异常信息打印:"
+
e
);
}
jdbc
.
update
(
"update goods.tb_equity_goods_record set consumer_id=null ,partner_user_id=null"
+
" ,app_item_id=null ,verification_time=null ,order_num=null , app_sku_id =null where exc_code = '"
+
excCode
+
"'"
);
}
@Test
(
description
=
"自有商品单2-ZDH核销二期限购每日限量【限购】"
)
//兑换限制 -》每日限购2次
public
void
ZDH
核销二期自有商品自有商品每日限购测试
()
throws
Exception
{
String
excCode1
=
"ASQ123"
;
String
excCode2
=
"ASQ122"
;
String
excCode3
=
"ASQ120"
;
try
{
logger
.
info
(
" ZDH核销二期自有商品自有商品每日限购测试-->开始了"
);
String
equityId
=
"25"
;
String
appItemId
=
"199486"
;
String
appSkuId
=
"261"
;
Map
<
String
,
Object
>
mapStock
=
jdbc
.
findSimpleResult
(
"SELECT * FROM stock.tb_stock WHERE stock_id =1187737166225920261"
);
//获取兑换之前优惠券的库存stock
String
stock
=
String
.
valueOf
(
mapStock
.
get
(
"stock"
));
//请求核销接口
logger
.
info
(
"进行第一次核销"
);
Response
response
=
equityPrizeService
.
gawequityPrizeexchange
(
authorization
.
dafuwengLogin
(
uid
),
excCode1
,
appItemId
,
equityId
,
appSkuId
);
response
.
prettyPrint
();
Thread
.
sleep
(
2000
);
mapStock
=
jdbc
.
findSimpleResult
(
"SELECT * FROM stock.tb_stock WHERE stock_id =1187737166225920261"
);
//核销之后优惠券的库存
String
exchanggeStock
=
String
.
valueOf
(
mapStock
.
get
(
"stock"
));
//核对兑换之后以及兑换之后的库存
logger
.
info
(
"总库存stock:"
+
stock
+
"第一次核销的库存exchanggeStock:"
+
exchanggeStock
);
Assert
.
assertEquals
(
stock
,
(
Integer
.
parseInt
(
exchanggeStock
)
+
1
+
""
),
"兑换之后商品库存兑换不一致-失敗"
);
//获取:订单号
String
orderId
=
response
.
jsonPath
().
getString
(
"data.orderId"
);
logger
.
info
(
"第一次核销的订单 号data.orderId="
+
orderId
);
Assert
.
assertEquals
(
orderId
.
isEmpty
(),
false
,
"第一次核销的订单订单号没有获取到"
);
//进行第二次核销
Thread
.
sleep
(
2000
);
logger
.
info
(
"第一次核销正常,进行第二次核销"
);
response
=
equityPrizeService
.
gawequityPrizeexchange
(
authorization
.
dafuwengLogin
(
uid
),
excCode2
,
appItemId
,
equityId
,
appSkuId
);
response
.
prettyPrint
();
//核销之后优惠券的库存
Thread
.
sleep
(
2000
);
mapStock
=
jdbc
.
findSimpleResult
(
"SELECT * FROM stock.tb_stock WHERE stock_id =1187737166225920261"
);
exchanggeStock
=
String
.
valueOf
(
mapStock
.
get
(
"stock"
));
logger
.
info
(
"exchanggeStock 第二次库存:"
+
exchanggeStock
);
Assert
.
assertEquals
(
stock
,
(
Integer
.
parseInt
(
exchanggeStock
)
+
2
+
""
),
"【第二次】兑换之后商品库存兑换不一致-失敗"
);
//获取:订单号
orderId
=
response
.
jsonPath
().
getString
(
"data.orderId"
);
logger
.
info
(
"第二次核销的订单 号data.orderId="
+
orderId
);
Assert
.
assertEquals
(
orderId
.
isEmpty
(),
false
,
"第二次核销的订单订单号没有获取到"
);
//进行第三次核销
Thread
.
sleep
(
1000
);
logger
.
info
(
"第二次核销正常,进行第三次核销"
);
response
=
equityPrizeService
.
gawequityPrizeexchange
(
authorization
.
dafuwengLogin
(
uid
),
excCode3
,
appItemId
,
equityId
,
appSkuId
);
String
code
=
response
.
jsonPath
().
getString
(
"code"
);
String
desc
=
response
.
jsonPath
().
getString
(
"desc"
);
logger
.
info
(
"code:"
+
code
+
",desc:"
+
desc
);
//校验
Assert
.
assertEquals
(
code
,
"1001002"
,
"2-ZDH核销二期自有商品自有商品每日限购测试( 有问题"
);
logger
.
info
(
" ZDH核销二期自有商品自有商品每日限购测试-->结束了"
);
}
catch
(
Exception
e
){
throw
new
Exception
(
"异常信息打印:"
+
e
);
}
finally
{
jdbc
.
update
(
"update goods.tb_equity_goods_record set consumer_id=null ,partner_user_id=null"
+
" ,app_item_id=null ,verification_time=null ,order_num=null , app_sku_id =null "
+
"where exc_code in( '"
+
excCode1
+
"',"
+
"'"
+
excCode2
+
"','"
+
excCode3
+
"')"
);
jdbc
.
update
(
"DELETE FROM goods.tb_everyday_limit where app_item_id ='199486 '"
);
}
}
}
src/test/java/http/service/Activity/equityPrizeService.java
View file @
f2f23b45
package
http
.
service
.
Activity
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
http.service.Authorization
;
import
io.restassured.http.Cookies
;
import
io.restassured.response.Response
;
...
...
@@ -7,10 +9,11 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
org.testng.Assert
;
import
org.testng.annotations.Test
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.*
;
import
static
base
.
Postman
.
logger
;
import
static
io
.
restassured
.
RestAssured
.
given
;
@Service
...
...
@@ -22,6 +25,7 @@ public class equityPrizeService {
/**
* 核销一期 /aaw/equityPrize/exchange
* 匹配兑换码兑换 一期-线上核销
* Request Method: POST
*
* @param excCode 兑换码
...
...
@@ -46,6 +50,108 @@ public class equityPrizeService {
return
response
;
}
/**
* 核销二期匹配 权益及兑换码兑换-线上核销
* 权益商品列表
* /chw//chw/visual-editor/equityGoodsList
* Request Method: GET
*
* @param equityId 权益id
* @return
* @throws Exception
*/
public
Response
chwequityGoodsList
(
Map
cookies
,
String
equityId
)
throws
Exception
{
Response
response
=
given
().
cookies
(
cookies
).
get
(
activityHost
+
"/chw/visual-editor/equityGoodsList?equityId="
+
equityId
);
try
{
// Assert.assertEquals(response.jsonPath().getString("success"), "true", "/aaw/equityPrize/exchange接口失败");
Assert
.
assertEquals
(
String
.
valueOf
(
response
.
getStatusCode
()),
"200"
,
"/chw//chw/visual-editor/equityGoodsList接口失败"
);
}
catch
(
Exception
e
)
{
throw
new
Exception
(
"/chw/visual-editor/equityGoodsList接口失败,返回信息:"
+
response
.
asString
());
}
catch
(
Error
er
)
{
throw
new
Exception
(
"/chw/visual-editor/equityGoodsList接口失败,返回信息:"
+
response
.
asString
());
}
return
response
;
}
@Test
/*
*q权益二期匹配 权益及兑换码兑换-线上核销
* 商品兑换首页
* /gaw/equityPrize/index
* * Request Method: post
* equityId 权益id , appitemid 商品id , appSkuid
* */
public
Response
gawequityPrizeindex
(
Map
cookies
,
String
equityId
,
String
appItemId
,
String
appSkuId
)
throws
Exception
{
logger
.
info
(
activityHost
+
"/gaw/equityPrize/index?equityId="
+
equityId
+
"&appItemId="
+
appItemId
+
"&appSkuId="
+
appSkuId
);
Response
response
=
given
().
cookies
(
cookies
).
get
(
activityHost
+
"/gaw/equityPrize/index?equityId="
+
equityId
+
"&appItemId="
+
appItemId
+
"&appSkuId="
+
appSkuId
);
try
{
Assert
.
assertEquals
(
String
.
valueOf
(
response
.
getStatusCode
()),
"200"
,
"/gaw/equityPrize/index接口失败"
);
}
catch
(
Exception
e
)
{
throw
new
Exception
(
"/gaw/equityPrize/index接口失败,返回信息:"
+
response
.
asString
());
}
catch
(
Error
er
)
{
throw
new
Exception
(
"/gaw/equityPrize/index接口失败,返回信息:"
+
response
.
asString
());
}
return
response
;
}
/*
* 权益核销【匹配 权益及兑换码兑换-线上核销】
* 权益兑换接口sku /gaw/equityPrize/exchange
*
* */
public
Response
gawequityPrizeexchange
(
Map
cookies
,
String
excCode
,
String
appItemId
,
String
equityId
,
String
appSkuId
)
throws
Exception
{
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"excCode"
,
excCode
);
map
.
put
(
"appItemId"
,
appItemId
);
map
.
put
(
"equityId"
,
equityId
);
map
.
put
(
"appSkuId"
,
appSkuId
);
map
.
put
(
"validate"
,
"undefined"
);
//token 代码中写死的测试token
map
.
put
(
"token"
,
"yrJRr7Cddp2YeQd"
);
Response
response
=
given
().
cookies
(
cookies
).
params
(
map
).
post
(
activityHost
+
"/gaw/equityPrize/exchange"
);
try
{
Assert
.
assertEquals
(
String
.
valueOf
(
response
.
getStatusCode
()),
"200"
,
"/gaw/equityPrize/exchange接口失败"
);
}
catch
(
Exception
e
)
{
throw
new
Exception
(
"/gaw/equityPrize/exchange接口失败,返回信息:"
+
response
.
asString
());
}
catch
(
Error
er
)
{
throw
new
Exception
(
"/gaw/equityPrize/exchange接口失败,返回信息:"
+
response
.
asString
());
}
return
response
;
}
/*
* 权益核销【匹配 权益及兑换码兑换-线上核销】
* 权益列表 /chw/visual-editor/findEquityListByIds
*
* */
public
Response
chwvisualeditorfindEquityListByIds
(
Map
cookies
,
List
<
Integer
>
array
)
throws
Exception
{
// JSONObject json = new JSONObject();
// json.put("equityIds", array);
Map
<
String
,
List
<
Integer
>>
map
=
new
HashMap
<>();
map
.
put
(
"equityIds"
,
array
);
Response
response
=
given
().
contentType
(
"application/json;charset=UTF-8"
).
cookies
(
cookies
).
body
(
map
).
post
(
activityHost
+
"/chw/visual-editor/findEquityListByIds"
);
//Response response = given().contentType("application/json;charset=UTF-8").body("{\"equityIds\":[25,24]}").cookies(cookies).post(activityHost + "/chw/visual-editor/findEquityListByIds");
try
{
Assert
.
assertEquals
(
String
.
valueOf
(
response
.
getStatusCode
()),
"200"
,
" /chw/visual-editor/findEquityListByIds接口失败"
);
}
catch
(
Exception
e
)
{
throw
new
Exception
(
"/gaw/equityPrize/exchange接口失败,返回信息:"
+
response
.
asString
());
}
catch
(
Error
er
)
{
throw
new
Exception
(
"/gaw/equityPrize/exchange接口失败,返回信息:"
+
response
.
asString
());
}
return
response
;
}
}
\ No newline at end of file
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