Commit 4fc5441d authored by panyuli's avatar panyuli

Merge branch 'pyl' into develop

parents 32447c32 76da1ac6
package http.cases.ExchangeTest;
import base.DuibaLog;
import http.service.Activity.ManagerService;
import http.service.Authorization;
import http.service.app.*;
import http.service.hd.DeveloperAccountService;
import http.service.hd.DsOrderService;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import utils.ExcelDataProvider;
import utils.MatcherString;
import java.io.IOException;
import java.lang.reflect.Method;
import java.sql.SQLException;
import java.util.Iterator;
import java.util.Map;
/**
* Created by mabo on 2018/9/13
*/
public class Qb_兑换限制测试_ExchangeTest extends CheckTemplet {
@Autowired
private MobileService mobileService;
@Autowired
private Authorization authorization;
@Autowired
private CouponExchangeService couponExchangeService;
@Autowired
private CrecordService crecordService;
@Autowired
ManagerService managerService;
@Autowired
VirtualExchangeService virtualExchangeService;
@Autowired
QbExchangeService qbExchangeService;
@Autowired
DeveloperAccountService developerAccountService;
@Autowired
DsOrderService dsOrderService;
@Autowired
SupplierExchangeTemplateService supplierExchangeTemplateService;
private DuibaLog logger = DuibaLog.getLogger();
@BeforeMethod
public void beforeMethod() throws SQLException {
jdbc.update("DELETE FROM credits_dev.consumer_limit_record_only WHERE item_id = '2'");
jdbc.update("DELETE FROM credits_dev.consumer_limit_record WHERE item_id = '2'");
}
@DataProvider
public Iterator<Object[]> providerMethodQb(Method method) throws IOException {
Iterator<Object[]> result = null;
result = new ExcelDataProvider("duiba/qb兑换");
return result;
}
@Test(description = "每限日兑换制同一个用户使用同一个QQ号")
public void 每限日兑换制同一个用户兑换同一个qq() throws Exception {
logger.info("Q币每限日兑换制同一个用户兑换同一个qq开始");
int uid = 4932;
//第一次兑换
Response response = qbExchangeService.doTakePrize(authorization.dafuwengLogin(uid),"1234345554","1");
String orderId = (String)response.jsonPath().get("orderId");
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid),orderId);
String message = response.jsonPath().getString("message");
int i=10;
while(!message.equals("兑换提交成功!待处理")&&i>0){
Thread.sleep(1000);
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid),orderId);
message = response.jsonPath().getString("message");
i--;
}
//第二次兑换
response = qbExchangeService.doTakePrize1(authorization.dafuwengLogin(uid),"1234345554","1");
message = response.jsonPath().getString("message");
logger.info(message);
Assert.assertTrue(message.contains("已兑完"));
logger.info("Q币每限日兑换制同一个用户兑换同一个qq成功");
}
@Test(description = "每限日兑换制同一个用户使用不同一个QQ号")
public void 每限日兑换制同一个用户使用不同一个QQ() throws Exception {
logger.info("每限日兑换制同一个用户使用不同一个QQ号开始");
int uid = 4933;
//第一次兑换
Response response = qbExchangeService.doTakePrize(authorization.dafuwengLogin(uid),"1234345554","1");
String orderId = (String)response.jsonPath().get("orderId");
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid),orderId);
String message = response.jsonPath().getString("message");
int i=10;
while(!message.equals("兑换提交成功!待处理")&&i>0){
Thread.sleep(1000);
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid),orderId);
message = response.jsonPath().getString("message");
i--;
}
//第二次兑换
response = qbExchangeService.doTakePrize1(authorization.dafuwengLogin(uid),"12343455541","1");
response.prettyPrint();
message = response.jsonPath().getString("message");
logger.info(message);
Assert.assertTrue(message.contains("已兑完"));
// Assert.assertTrue(message.contains("\"success\":false"));
logger.info("每限日兑换制同一个用户使用不同一个QQ号成功");
}
@Test(description = "每限日兑换制不同一个用户使用同一个QQ号")
public void 每限日兑换制不同一个用户使用同一个QQ() throws Exception {
logger.info("每限日兑换制不同一个用户使用同一个QQ号开始");
int uid = 4934;
//第一次兑换
Response response = qbExchangeService.doTakePrize(authorization.dafuwengLogin(uid),"123434555412","1");
String orderId = (String)response.jsonPath().get("orderId");
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid),orderId);
String message = response.jsonPath().getString("message");
int i=10;
while(!message.equals("兑换提交成功!待处理")&&i>0){
Thread.sleep(1000);
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid),orderId);
message = response.jsonPath().getString("message");
i--;
}
//第二次兑换
//不同的用户,同一个 qq好
int uid1=4935;
response = qbExchangeService.doTakePrize1(authorization.dafuwengLogin(uid1),"123434555412","1");
response.prettyPrint();
message = response.jsonPath().getString("message");
logger.info(message);
Assert.assertTrue(message.contains("抱歉,该QQ号已达到每天充值上限,请换一个QQ号吧。"));
logger.info("每限日兑换制不同一个用户使用同一个QQ号成功");
}
}
......@@ -33,6 +33,7 @@ public class QbExchangeService {
map.put("token","0nmfgduh8");
Response response = given().params(map).cookies(cookies).post(activityHost+"/qbExchange/exchange");
try{
Assert.assertEquals(response.jsonPath().getString("success"),"true","/qbExchange/exchange接口失败");
......@@ -45,4 +46,27 @@ public class QbExchangeService {
return response;
}
public Response doTakePrize1(Map cookies, String qq, String degreeId) throws Exception {
logger.info("请求/qbExchange/exchange");
Map<String,String> map = new HashMap<>();
map.put("qq",qq);
map.put("degreeId",degreeId);
map.put("token","0nmfgduh8");
Response response = given().params(map).cookies(cookies).post(activityHost+"/qbExchange/exchange");
String message = response.jsonPath().getString("data.message");
logger .info(message);
try{
Assert.assertEquals(String.valueOf(response.getStatusCode()), "200", "/objectExchange/exchange接口返回异常");
}catch(Exception e){
throw new Exception("/qbExchange/exchange接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/qbExchange/exchange接口失败,返回信息:"+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