Commit c43da568 authored by 吕雯燕's avatar 吕雯燕

lv

parent 87e7bdb9
......@@ -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();
}
}
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