Commit da46efca authored by 赵然's avatar 赵然

zr

parent b84171cf
package http.cases.GameTest;
import base.Config;
import base.DuibaLog;
import http.service.Activity.ManagerService;
import http.service.Activity.NgapiService;
import http.service.Authorization;
import http.service.hd.ActivityService;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
import org.testng.Assert;
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.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.equalTo;
/**
* Created by zhaoran on 2019/12/09.
*/
@ContextConfiguration(classes = Config.class)
public class RconGame extends AbstractTestNGSpringContextTests {
@Autowired
NgapiService ngapiService;
@Autowired
ManagerService managerService;
@Autowired
ActivityService activityService;
@Autowired
Authorization authorization;
@Value("${activity.host}")
String activityHost;
private static DuibaLog logger = DuibaLog.getLogger();
private static final Integer uid = 7417;
private static final String consumerId = "100168013";
@Test
public void 参与游戏测试() throws Exception {
Response response = ngapiService.reconajaxElement(uid,"12399","45532");
String freeLimit = response.jsonPath().getString("data.element.freeLimit");
//扣去1次免费次数
String ExpfreeLimit = String.valueOf(Integer.valueOf(freeLimit)-1);
//进行接口测试传参
this.游戏接口传参("45532");
Response response2 = ngapiService.reconajaxElement(uid,"12399","45532");
freeLimit = response2.jsonPath().getString("data.element.freeLimit");
Assert.assertEquals(freeLimit,ExpfreeLimit,"免费次数扣除不正确");
}
public Response 游戏接口传参(String activityId) throws Exception {
Response response = ngapiService.recondoJoin(uid,activityId,consumerId);
response.prettyPrint();
response.then().body("success", equalTo(true));
String orderId = response.jsonPath().getString("data");
response = ngapiService.recongetStartStatus(uid,orderId);
response.prettyPrint();
// String message = String.valueOf(response.jsonPath().getString("message"));
// int i= 5;
// while(i>0&&(message.equals("处理中"))){
// Thread.sleep(1000);
// response = ngapiService.getStartStatus(uid,ticketId);
// message = String.valueOf(response.jsonPath().getString("message"));
// i--;
// response.prettyPrint();
// }
Assert.assertEquals(response.jsonPath().getString("success"),"true","校验message失败");
// response = ngapiService.submit(uid,ticketId,device);
// response.prettyPrint();
return response;
}
}
\ No newline at end of file
......@@ -90,4 +90,59 @@ public class NgapiService {
return response;
}
public Response reconajaxElement(int uid,String duibaId,String activityId) throws Exception {
Map<String,String> map = new HashMap<>();
map.put("duibaId",duibaId);
map.put("activityId",activityId);
Response response = given().cookies(authorization.dafuwengLogin(uid)).params(map).get(activityHost+"/hdtool/recon/ajaxElement");
try{
Assert.assertEquals(response.jsonPath().getString("success"),"true","/hdtool/recon/ajaxElement接口失败");
}catch(Exception e){
throw new Exception("/hdtool/recon/ajaxElement接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/hdtool/recon/ajaxElement接口失败,返回信息:"+response.asString());
}
return response;
}
public Response recondoJoin(int uid,String activityId,String consumerId) throws Exception {
Map<String,String> map = new HashMap<>();
map.put("activityId",activityId);
map.put("activityType","hdtool");
map.put("consumerId",consumerId);
map.put("token","rl8v7");
logger.info("请求doJoin接口,activityId="+activityId);
Response response = given().cookies(authorization.dafuwengLogin(uid)).params(map).post(activityHost+"/hdtool/recon/doJoin");
try{
Assert.assertEquals(response.jsonPath().getString("success"),"true","/hdtool/recon/doJoin接口失败");
}catch(Exception e){
throw new Exception("/hdtool/recon/doJoin接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/hdtool/recon/doJoin接口失败,返回信息:"+response.asString());
}
return response;
}
public Response recongetStartStatus(int uid, String orderId ) throws Exception {
Map<String,String> map = new HashMap<>();
map.put("orderId",orderId);
logger.info("请求getOrderStatus接口,orderId="+orderId);
Response response = given().cookies(authorization.dafuwengLogin(uid)).params(map).post(activityHost+"/hdtool/recon/ngame/getNgameStartStatus");
try{
Assert.assertEquals(response.jsonPath().getString("success"),"true","/hdtool/recon/ngame/getNgameStartStatus接口失败");
}catch(Exception e){
throw new Exception("/hdtool/recon/ngame/getNgameStartStatus接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/hdtool/recon/ngame/getNgameStartStatus接口失败,返回信息:"+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