Commit 39b60bce authored by 马博's avatar 马博

Merge remote-tracking branch 'origin/master'

parents 188603d6 34f205c3
......@@ -628,6 +628,50 @@ public class 自有新优惠券_兑换限制测试_ExchangeTest extends CheckTem
}
@Test(description = "新优惠券扣库存测试")
public void 优惠券扣库存测试() throws Exception{
int uid = 7312;
String appItemId = "197567";
int skuId = 187;
//查询兑换前的库存
//stock_id 通过表tb_goods_batch 来查询
Map<String,Object> mapStock = jdbc.findSimpleResult("SELECT * FROM stock.tb_stock WHERE stock_id = 1060747299329170094");
String stock = String.valueOf(mapStock.get("stock"));
logger.info("兑换前的库存:" + stock);
Response response = gawService.couponExchange(uid,appItemId,skuId);
String orderId = response.jsonPath().getString("data.orderId");
//获取兑换结果
response = tawService.orderStatus(orderId,uid);
response.prettyPrint();
String status = response.jsonPath().getString("data.status");
int i = 10;
//异步接口,直到兑换成功
while (i> 0 && status.equals("processing")) {
Thread.sleep(1000);
response = tawService.orderStatus(orderId,uid);
response.prettyPrint();
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);
logger.info("兑换后的库存:" + newStock);
Assert.assertEquals(response.jsonPath().getString("data.status"),"success","校验订单状态失败");
Assert.assertEquals(newStock,result,"校验扣库存失败");
logger.info("校验新优惠券商品扣库存成功");
}
......
......@@ -497,55 +497,53 @@ public class 自有新实物_兑换流程测试_ExchangeTest extends CheckTemple
}
@Test(description = "新实物扣库存测试")
public void 实物扣库存测试() throws Exception{
int uid = 7302;
String appItemId = "197385";
String itemId = null;
String skuId = "183";
String credits = "10";
String actualCredits = "10";
//查询兑换前的库存
//stock_id 通过表tb_app_item_sku 来查询
Map<String,Object> mapStock = jdbc.findSimpleResult("SELECT * FROM stock.tb_stock WHERE stock_id = 1059049813690420183");
String stock = String.valueOf(mapStock.get("stock"));
logger.info("兑换前的库存:" + stock);
Response response = gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits);
String orderId = response.jsonPath().getString("data.orderId");
//获取兑换结果
response = tawService.orderStatus(orderId,uid);
response.prettyPrint();
String status = response.jsonPath().getString("data.status");
int i = 10;
//异步接口,直到兑换成功
while (i> 0 && status.equals("processing")) {
Thread.sleep(1000);
response = tawService.orderStatus(orderId,uid);
response.prettyPrint();
status = response.jsonPath().getString("data.status");
i--;
}
mapStock = jdbc.findSimpleResult("SELECT * FROM stock.tb_stock WHERE stock_id = 1059049813690420183");
String newStock = String.valueOf(mapStock.get("stock"));
String result = String.valueOf(Integer.valueOf(stock)-1);
logger.info("兑换后的库存:" + newStock);
//测试使用
//@Test(enabled=true, dataProvider="testdp", threadPoolSize=1, invocationCount=100)
@DataProvider(name = "testdp", parallel = true)
public static Object[][]testdp(){
return new Object[][]{
{1},
{2},
{3},
{4},
{162},
{6},
{8},
{10},
{157},
{158}
};
}
// @Test(enabled=true, dataProvider="testdp", threadPoolSize=1, invocationCount=100)
public void test(int uid) throws Exception {
// System.out.println("Current Thread Id: " + Thread.currentThread().getId() + ". Dataprovider number: "+ dpNumber);
// Thread.sleep(5000);
String appItemId = "159040";
String itemId = "null";
String message = "";
String skuId="144";
String actualCredits="8";
String credits="100";
Assert.assertEquals(response.jsonPath().getString("data.status"),"wait_delivery","校验订单状态失败");
Assert.assertEquals(newStock,result,"校验扣库存失败");
logger.info("校验新实物商品扣库存成功");
Thread.sleep(4000);
Response response = gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits);
response.prettyPrint();
//(enabled=true, dataProvider="testdp", threadPoolSize=1, invocationCount=2)
}
String orderId = response.jsonPath().getString("data.orderId");
response = tawService.orderStatus(orderId,uid);
response.prettyPrint();
}
}
......@@ -500,4 +500,50 @@ public class 自有新虚拟商品_充值_兑换限制_ExchangeTest extends Chec
}
@Test(description = "虚拟商品扣库存测试")
public void 虚拟商品扣库存测试() throws Exception{
int uid = 7313;
Map cookies = authorization.dafuwengLogin(uid);
String appItemId = "197568";
int skuId = 188;
//查询兑换前的库存
//stock_id 通过表tb_app_item_sku 来查询
Map<String,Object> mapStock = jdbc.findSimpleResult("SELECT * FROM stock.tb_stock WHERE stock_id = 1060758938511670188");
String stock = String.valueOf(mapStock.get("stock"));
logger.info("兑换前的库存:" + stock);
Response response = gawService.virtualExchange(cookies, appItemId,skuId);
String orderId = response.jsonPath().getString("data.orderId");
//获取兑换结果
response = tawService.orderStatus(orderId,uid);
response.prettyPrint();
String status = response.jsonPath().getString("data.status");
int i = 10;
//异步接口,直到兑换成功
while (i> 0 && status.equals("processing")) {
Thread.sleep(1000);
response = tawService.orderStatus(orderId,uid);
response.prettyPrint();
status = response.jsonPath().getString("data.status");
i--;
}
mapStock = jdbc.findSimpleResult("SELECT * FROM stock.tb_stock WHERE stock_id = 1060758938511670188");
String newStock = String.valueOf(mapStock.get("stock"));
String result = String.valueOf(Integer.valueOf(stock)-1);
logger.info("兑换后的库存:" + newStock);
Assert.assertEquals(response.jsonPath().getString("data.status"),"success","校验订单状态失败");
Assert.assertEquals(newStock,result,"校验扣库存失败");
logger.info("校验充值商品扣库存成功");
}
}
......@@ -17,7 +17,7 @@ import org.testng.annotations.Test;
/**
* Created by zhaoran on 2018/1/2
*/
public class 定向测试_DuibaTest extends DuibaTestBase {
public class 定向测试 extends DuibaTestBase {
@Autowired
NewActivityService newActivityService;
......
......@@ -222,7 +222,7 @@ public class gawService {
JSONObject jsonParam = JSONObject.parseObject(JSON.toJSONString(map));
logger.info("请求实物兑换接口:"+ "/gaw/couponExchange/create");
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");
......@@ -353,7 +353,7 @@ public class gawService {
JSONObject jsonParam = JSONObject.parseObject(JSON.toJSONString(map));
logger.info("请求实物兑换接口:"+ "/gaw/couponExchange/create");
logger.info("请求虚拟商品兑换接口:"+ "/gaw/virtualExchange/create");
Response response = given().contentType("application/json; charset=UTF-8").cookies(cookie).body(jsonParam).post("http://"+goodsHost+"/gaw/virtualExchange/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");
......
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