Commit 8a039d82 authored by wangxiaoshuang's avatar wangxiaoshuang

wxs

parent c6d89476
......@@ -35,6 +35,7 @@ public class 自有新优惠券_兑换限制测试_ExchangeTest extends CheckTem
private int uid = 7003;
private String consumerId = "100144145";
private boolean bl=false;
private String url = "http://activity.m.duibatest.com.cn";
......@@ -362,14 +363,13 @@ public class 自有新优惠券_兑换限制测试_ExchangeTest extends CheckTem
@Test
public void 会员等级测试()throws Exception{
String appItemId = "193848";
String message = "";
//会员等级无法兑换
try{
Thread.sleep(4000);
Response response = gawService.couponExchange(authorization.dafuwengLogin(uid), appItemId,45);
Response response = gawService.couponExchange(authorization.dafuwengLogin(uid), appItemId,45,bl);
response.prettyPrint();
}catch (Exception e){
......@@ -379,7 +379,7 @@ public class 自有新优惠券_兑换限制测试_ExchangeTest extends CheckTem
//会员等级可兑换,vip=5
Thread.sleep(4000);
Response response = gawService.couponExchange(authorization.generateSignAutoLogin("3tzVcss7SnAvA5ppT1m1rMPhaBcD",7083,1),appItemId,45);
Response response = gawService.couponExchange(authorization.generateSignAutoLogin("3tzVcss7SnAvA5ppT1m1rMPhaBcD",7083,1),appItemId,45,bl);
response.prettyPrint();
Assert.assertTrue(message.contains("未达到会员等级要求"),"校验message失败");
......@@ -524,7 +524,7 @@ public class 自有新优惠券_兑换限制测试_ExchangeTest extends CheckTem
//优惠券兑换
Thread.sleep(4000);
Response response = gawService.couponExchange(authorization.dafuwengLogin(uid),appItemId,skuId);
Response response = gawService.couponExchange(authorization.dafuwengLogin(uid),appItemId,skuId,bl);
response.prettyPrint();
String orderId = response.jsonPath().getString("data.orderId");
//获取兑换结果
......@@ -656,7 +656,6 @@ public class 自有新优惠券_兑换限制测试_ExchangeTest extends CheckTem
status = response.jsonPath().getString("data.status");
i--;
}
mapStock = jdbc.findSimpleResult("SELECT * FROM stock.tb_stock WHERE stock_id = 1060747299329170094");
String newStock = String.valueOf(mapStock.get("stock"));
String result = String.valueOf(Integer.valueOf(stock)-1);
......
......@@ -44,6 +44,7 @@ public class 自有新卡密_兑换限制测试_ExchangeTest extends CheckTemple
private int uid = 7004;
private String consumerId = "100144146";
private boolean bl=false;
private String url = "http://activity.m.duibatest.com.cn";
......@@ -326,7 +327,7 @@ public class 自有新卡密_兑换限制测试_ExchangeTest extends CheckTemple
//兑换
try{
Thread.sleep(4000);
response = gawService.couponExchange(authorization.dafuwengLogin(uid), appItemId, skuId);
response = gawService.couponExchange(authorization.dafuwengLogin(uid), appItemId, skuId,bl);
}catch (Exception e){
message = e.getMessage();
......@@ -384,7 +385,7 @@ public class 自有新卡密_兑换限制测试_ExchangeTest extends CheckTemple
//会员等级无法兑换
try{
Thread.sleep(4000);
Response response = gawService.couponExchange(authorization.dafuwengLogin(uid), appItemId,86);
Response response = gawService.couponExchange(authorization.dafuwengLogin(uid), appItemId,86,bl);
response.prettyPrint();
}catch (Exception e){
......@@ -394,7 +395,7 @@ public class 自有新卡密_兑换限制测试_ExchangeTest extends CheckTemple
//会员等级可兑换,vip=5
Thread.sleep(4000);
Response response = gawService.couponExchange(authorization.generateSignAutoLogin("3tzVcss7SnAvA5ppT1m1rMPhaBcD",7083,1),appItemId,86);
Response response = gawService.couponExchange(authorization.generateSignAutoLogin("3tzVcss7SnAvA5ppT1m1rMPhaBcD",7083,1),appItemId,86,bl);
response.prettyPrint();
Assert.assertTrue(message.contains("未达到会员等级要求"),"校验message失败");
......
......@@ -71,11 +71,12 @@ public class 自有新实物_兑换流程测试_ExchangeTest extends CheckTemple
String skuId="17";
String actualCredits="1";
String credits="1";
boolean bl=false;
try{
//第一次兑换
Thread.sleep(3000);
Response response = gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits);
Response response = gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits,bl);
String orderId = response.jsonPath().getString("data.orderId");
//获取兑换结果
response = tawService.orderStatus(orderId,uid);
......@@ -99,7 +100,7 @@ public class 自有新实物_兑换流程测试_ExchangeTest extends CheckTemple
//第二次兑换
try{
response = gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits);
response = gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits,bl);
response.prettyPrint();
}catch (Exception e){
......@@ -125,10 +126,12 @@ public class 自有新实物_兑换流程测试_ExchangeTest extends CheckTemple
String skuId="24";
String actualCredits="2";
String credits="2";
boolean bl=false;
try{
//第一次兑换
Thread.sleep(3000);
Response response = gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits);
Response response = gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits,bl);
logger.info("********1"+"111111");
String orderId = response.jsonPath().getString("data.orderId");
//获取兑换结果
......@@ -152,7 +155,7 @@ public class 自有新实物_兑换流程测试_ExchangeTest extends CheckTemple
//第二次兑换
try{
response = gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits);
response = gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits,bl);
logger.info("********2");
response.prettyPrint();
......@@ -181,10 +184,12 @@ public class 自有新实物_兑换流程测试_ExchangeTest extends CheckTemple
String skuId="25";
String actualCredits="3";
String credits="3";
boolean bl=false;
try{
//第一次兑换
Thread.sleep(3000);
Response response = gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits);
Response response = gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits,bl);
String orderId = response.jsonPath().getString("data.orderId");
//获取兑换结果
response = tawService.orderStatus(orderId,uid);
......@@ -206,7 +211,8 @@ public class 自有新实物_兑换流程测试_ExchangeTest extends CheckTemple
// logger.info("商品兑换按钮:" + exchangeText);
//第二次兑换
try{
response = gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits);
response = gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits,bl
);
response.prettyPrint();
}catch (Exception e){
......@@ -233,10 +239,13 @@ public class 自有新实物_兑换流程测试_ExchangeTest extends CheckTemple
String skuId="26";
String actualCredits="5";
String credits="5";
boolean bl=false;
try{
//第一次兑换
Thread.sleep(3000);
Response response = gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits);
Response response = gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits,bl
);
String orderId = response.jsonPath().getString("data.orderId");
//获取兑换结果
response = tawService.orderStatus(orderId,uid);
......@@ -258,7 +267,8 @@ public class 自有新实物_兑换流程测试_ExchangeTest extends CheckTemple
// logger.info("商品兑换按钮:" + exchangeText);
//第二次兑换
try{
response = gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits);
response = gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits,bl
);
response.prettyPrint();
}catch (Exception e){
......@@ -336,6 +346,8 @@ public class 自有新实物_兑换流程测试_ExchangeTest extends CheckTemple
String skuId="33";
String actualCredits="8";
String credits="8";
boolean bl=false;
jdbc.update("UPDATE stock.tb_stock set stock = 0 where stock_id = 940298957084170033");
Thread.sleep(1000);
......@@ -347,7 +359,7 @@ public class 自有新实物_兑换流程测试_ExchangeTest extends CheckTemple
try{
Thread.sleep(3000);
Response response = gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits);
Response response = gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits,bl);
response.prettyPrint();
}catch (Exception e){
......@@ -448,10 +460,10 @@ public class 自有新实物_兑换流程测试_ExchangeTest extends CheckTemple
String appItemId = "197041";
String itemId = null ;
String skuId = "159";
boolean bl=false;
//实物兑换,积分传0
Response response =gawService.objectExchange(uid,appItemId,itemId,skuId,"0","0");
Response response =gawService.objectExchange(uid,appItemId,itemId,skuId,"0","0",bl);
response.prettyPrint();
String orderId = response.jsonPath().getString("data.orderId");
......@@ -506,6 +518,8 @@ public class 自有新实物_兑换流程测试_ExchangeTest extends CheckTemple
String skuId = "183";
String credits = "10";
String actualCredits = "10";
boolean bl=false;
//查询兑换前的库存
//stock_id 通过表tb_app_item_sku 来查询
......@@ -513,7 +527,7 @@ public class 自有新实物_兑换流程测试_ExchangeTest extends CheckTemple
String stock = String.valueOf(mapStock.get("stock"));
logger.info("兑换前的库存:" + stock);
Response response = gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits);
Response response = gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits,bl);
String orderId = response.jsonPath().getString("data.orderId");
//获取兑换结果
response = tawService.orderStatus(orderId,uid);
......
......@@ -125,7 +125,7 @@ public class gawService {
//普通自有新实物兑换接口
public Response objectExchange(int uid, String appItemId,String itemId,String skuId,String credits,String actualCredits ) throws Exception {
public Response objectExchange(int uid, String appItemId,String itemId,String skuId,String credits,String actualCredits,boolean bl ) throws Exception {
Map<String,Object> map = new HashMap<>();
Map<String,Object> mapList = new HashMap<>();
......@@ -147,6 +147,7 @@ public class gawService {
map.put("expressPrice","0");
map.put("validate","");
map.put("token","yrJRr7Cddp2YeQd");
map.put("vipFlag",bl);
JSONObject jsonParam = JSONObject.parseObject(JSON.toJSONString(map));
......@@ -227,6 +228,51 @@ public class gawService {
// Response saveResponse = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.dafuwengLogin(uid)).params(map).post("http://"+goodsHost+"/gaw/objectExchange/create");
// response.prettyPrint();
try{
Assert.assertEquals(response.jsonPath().getString("success"),"true");
}catch(Exception e){
throw new Exception("/gaw/objectExchange/create接口返回异常,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/gaw/objectExchange/create接口返回异常,返回信息:"+response.asString());
}
return response;
}
//会员商品优惠券兑换接口
public Response couponExchange2(int uid, String appItemId,String credits,String actualCredits, int skuId,boolean bl) throws Exception {
Map<String,Object> map = new HashMap<>();
Map<String,Object> mapList = new HashMap<>();
List<Map> list = new ArrayList<>();
mapList.put("skuId",skuId);
mapList.put("appItemId",appItemId);
mapList.put("credits",credits);
mapList.put("price",0);
list.add(mapList);
map.put("remark",""); //买家留言
map.put("degreeId","");
map.put("actualPrice","0"); //总金额
map.put("actualCredits",actualCredits); //总积分
map.put("itemParam",list.toArray());
map.put("payType","3");
map.put("expressPrice","0");
map.put("validate","");
map.put("token","yrJRr7Cddp2YeQd");
map.put("vipFlag",bl);
JSONObject jsonParam = JSONObject.parseObject(JSON.toJSONString(map));
logger.info("请求优惠券兑换接口:"+ "/gaw/couponExchange/create");
Response response = given().contentType("application/json; charset=UTF-8").cookies(authorization.dafuwengLogin(uid)).body(jsonParam).post("http://"+goodsHost+"/gaw/couponExchange/create");
// Response saveResponse = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.dafuwengLogin(uid)).params(map).post("http://"+goodsHost+"/gaw/objectExchange/create");
// response.prettyPrint();
try{
......@@ -284,7 +330,7 @@ public class gawService {
}
//优惠券兑换接口
public Response couponExchange(Map cookie, String appItemId,int skuId) throws Exception {
public Response couponExchange(Map cookie, String appItemId,int skuId,boolean bl) throws Exception {
Map<String,Object> map = new HashMap<>();
Map<String,Object> mapList = new HashMap<>();
......@@ -305,6 +351,7 @@ public class gawService {
map.put("expressPrice","0");
map.put("validate","");
map.put("token","yrJRr7Cddp2YeQd");
map.put("vipFlag",bl);
JSONObject jsonParam = JSONObject.parseObject(JSON.toJSONString(map));
......
......@@ -74,7 +74,7 @@ public class testservice extends AbstractTestNGSpringContextTestsDuiba {
Thread.sleep(3000);
Response response = gawService.objectExchange(1,appItemId,itemId,skuId,credits,actualCredits);
Response response = gawService.objectExchange(1,appItemId,itemId,skuId,credits,actualCredits,false);
response.prettyPrint();
//(enabled=true, dataProvider="testdp", threadPoolSize=1, invocationCount=2)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment