Commit 7c97c630 authored by 吕雯燕's avatar 吕雯燕

lv

parent ff707124
package http.cases.ExchangeTest;
import base.DuibaBase;
import base.DuibaBases;
import http.service.Activity.ManagerService;
import http.service.Authorization;
import http.service.app.MobileService;
import http.service.app.gawService;
import http.service.app.tawService;
import http.service.hd.DeveloperAccountService;
import http.service.hd.DappConfigService;
import org.apache.logging.log4j.core.pattern.AbstractStyleNameConverter;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import utils.MatcherString;
import base.DuibaLog;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.Test;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import utils.RedisUtil;
import static io.restassured.RestAssured.given;
/**
* Created by lvwenyan on 2019/3/19.
*/
public class 兑吧新实物_兑换流程测试_ExchangeTest extends CheckTemplet {
@Autowired
gawService gawService;
@Autowired
tawService tawService;
int uid = 6866;
// @Test(description = "兑吧新实物每人限购每日限制")
public void 每人限购每日限制测试() throws Exception {
String appItemId = "192950";
String itemId = "32439";
// try{
//第一次兑换
Response response = gawService.objectExchange(uid,appItemId,itemId);
String orderId = response.jsonPath().getString("data.orderId");
//获取兑换结果
response = tawService.orderStatus(orderId,uid);
response.prettyPrint();
//
// Response detailResponse = mobileService.detail(authorization.dafuwengLogin(uid),itemId);
// String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
// logger.info("商品兑换按钮:" + exchangeText);
//
// //第二次兑换
// Thread.sleep(3000);
// try{
// response = couponExchangeService.objectExchange(authorization.dafuwengLogin(uid), appItemId, itemId, "null", "yrJRr7Cddp2YeQd", "null");
// response.prettyPrint();
//
// }catch (Exception e){
// message = e.toString();
// }
// logger.info(message);
//
// Assert.assertTrue(message.contains("今日已达兑换上限"),"校验message失败");
// Assert.assertTrue(message.contains("\"success\":false"),"校验success失败");
//
// Assert.assertEquals(exchangeText,"今日已达兑换上限","校验兑换按钮失败");
// logger.info("校验实物用户每日限制消费成功");
//
// }catch (Exception e){
//
// throw new Exception("异常信息打印:" + e);
//
// }finally {
// jdbc.update("DELETE FROM credits_dev.consumer_limit_record WHERE item_id = '"+itemId+"'");
//
// }
}
}
package http.service.app;
import base.DuibaLog;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import http.service.Authorization;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.testng.Assert;
import java.util.HashMap;
import java.util.Map;
import static io.restassured.RestAssured.given;
@Service
public class gawService {
@Value("${goods.host}")
private String goodsHost;
@Autowired
Authorization authorization;
private DuibaLog logger = DuibaLog.getLogger();
//普通实物兑换接口
public Response objectExchange(int uid, String appItemId,String itemId) throws Exception {
Map<String,Object> map = new HashMap<>();
map.put("remark",""); //买家留言
map.put("degreeId","");
map.put("actualPrice","0"); //总金额
map.put("actualCredits","100"); //总积分
map.put("itemParam","[{\"itemId\":"+itemId+",\"skuId\":16,\"appItemId\":"+appItemId+",\"credits\":\"100\",\"price\":0}]");
map.put("payType","3");
map.put("expressPrice","0");
map.put("validate","");
map.put("token","yrJRr7Cddp2YeQd");
JSONObject jsonParam = JSONObject.parseObject(JSON.toJSONString(map));
logger.info("请求实物兑换接口:"+ "/gaw/objectExchange/create");
Response response = given().contentType("application/json; charset=UTF-8").cookies(authorization.dafuwengLogin(uid)).body(jsonParam).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;
}
}
......@@ -45,4 +45,28 @@ public class tawService {
}
//订单轮询接口
public Response orderStatus(String orderId,int uid) throws Exception{
Map<String,String> map = new HashMap<>();
map.put("orderId",orderId);
Response response = given().cookies(authorization.dafuwengLogin(uid)).params(map).get("http://"+tradeHost+"/taw/h5/orderStatus");
try{
Assert.assertEquals(response.jsonPath().getString("success"),"true","/taw/h5/orderStatus接口失败");
}catch(Exception e){
throw new Exception("/taw/h5/orderStatus接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/taw/h5/orderStatus接口失败,返回信息:"+response.asString());
}
return response;
}
}
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