Commit ffdd652a authored by 赵然's avatar 赵然

Merge branch 'zr' into develop

parents c0956140 28b38b13
/**
* Copyright (C), 2015-2018
* FileName: 配置测试_AccessTest
* Author: zhaoran
* Date: 2018/12/10 19:45
* Description:
*/
package http.cases.PkMoudleTest;
import base.DuibaLog;
import base.DuibaTestBase;
import http.service.Activity.PkService;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.Test;
import java.math.BigDecimal;
public class 配置测试_AccessTest extends DuibaTestBase {
@Autowired
PkService pkService;
private DuibaLog logger = DuibaLog.getLogger();
private static Integer uid = 5028;//
@Test
public void 配置测试() throws Exception{
Response response = pkService.getBetList(uid);
response.print();
//分积分配置获取
String betType1 = response.jsonPath().getString("data.unbetList[0].betConfig.betType");
String bonusType1 = response.jsonPath().getString("data.unbetList[0].betConfig.bonusType");
String configStatus1 = response.jsonPath().getString("data.unbetList[0].betConfig.configStatus");
String creditsValue1 = response.jsonPath().getString("data.unbetList[0].betConfig.creditsValue");
String id1 = response.jsonPath().getString("data.unbetList[0].betConfig.id");
String shareExp1 = response.jsonPath().getString("data.unbetList[0].betConfig.shareExp");
String title1 = response.jsonPath().getString("data.unbetList[0].betConfig.title");
String unitName1 = response.jsonPath().getString("data.unbetList[0].betConfig.unitName");
//分积分选项获取
String optionId1 = response.jsonPath().getString("data.unbetList[0].options[0].optionId");
String optionImg1 = response.jsonPath().getString("data.unbetList[0].options[0].optionImg");
String optionName1 = response.jsonPath().getString("data.unbetList[0].options[0].optionName");
String optionId2 = response.jsonPath().getString("data.unbetList[0].options[1].optionId");
String optionImg2 = response.jsonPath().getString("data.unbetList[0].options[1].optionImg");
String optionName2 = response.jsonPath().getString("data.unbetList[0].options[1].optionName");
Assert.assertEquals(betType1,"1","校验押注类型失败"); //'押注类型 1-单选单次,2-多选无限制'
Assert.assertEquals(bonusType1,"4","校验瓜分类型失败");//'瓜分类型1瓜分经验2瓜分红包3发奖品4瓜分积分'
Assert.assertEquals(configStatus1,"3","校验投注活动的状态失败");//'投注活动的状态:1关闭不可见2关闭可见3开启4结束'
Assert.assertEquals(creditsValue1,"2.00","校验积分价值失败");//积分价值
Assert.assertEquals(id1,"1354","校验pk id失败");
Assert.assertTrue(new BigDecimal(shareExp1).compareTo(new BigDecimal("99"))==0,"校验瓜分的经验池失败");//瓜分的经验池
Assert.assertEquals(title1,"瓜分积分","校验投注活动标题失败");//投注活动标题
Assert.assertEquals(unitName1,"元宝","校验消耗类型失败");
Assert.assertEquals(optionId1,"2867","校验选项1 id失败");
Assert.assertEquals(optionImg1,"//yun.dui88.com/images/201812/c5vo081h6h.jpg","校验选项1 图片失败");
Assert.assertEquals(optionName1,"分积分1","校验选项1 title失败");
Assert.assertEquals(optionId2,"2868","校验选项2 id失败");
Assert.assertEquals(optionImg2,"//yun.dui88.com/images/201812/5ib6ews6bw.png","校验选项2 图片失败");
Assert.assertEquals(optionName2,"分积分2","校验选项2 title失败");
//分红包配置获取
String betType2 = response.jsonPath().getString("data.unbetList[1].betConfig.betType");
String bonusType2 = response.jsonPath().getString("data.unbetList[1].betConfig.bonusType");
String configStatus2 = response.jsonPath().getString("data.unbetList[1].betConfig.configStatus");
String creditsValue2 = response.jsonPath().getString("data.unbetList[1].betConfig.creditsValue");
String id2 = response.jsonPath().getString("data.unbetList[1].betConfig.id");
String shareExp2 = response.jsonPath().getString("data.unbetList[1].betConfig.shareExp");
String title2 = response.jsonPath().getString("data.unbetList[1].betConfig.title");
String unitName2 = response.jsonPath().getString("data.unbetList[1].betConfig.unitName");
//分红包选项获取
String optionId3 = response.jsonPath().getString("data.unbetList[1].options[0].optionId");
String optionImg3 = response.jsonPath().getString("data.unbetList[1].options[0].optionImg");
String optionName3 = response.jsonPath().getString("data.unbetList[1].options[0].optionName");
String optionId4 = response.jsonPath().getString("data.unbetList[1].options[1].optionId");
String optionImg4 = response.jsonPath().getString("data.unbetList[1].options[1].optionImg");
String optionName4 = response.jsonPath().getString("data.unbetList[1].options[1].optionName");
Assert.assertEquals(betType2,"1","校验押注类型失败"); //'押注类型 1-单选单次,2-多选无限制'
Assert.assertEquals(bonusType2,"2","校验瓜分类型失败");//'瓜分类型1瓜分经验2瓜分红包3发奖品4瓜分积分'
Assert.assertEquals(configStatus2,"3","校验投注活动的状态失败");//'投注活动的状态:1关闭不可见2关闭可见3开启4结束'
Assert.assertEquals(creditsValue2,"3.00","校验积分价值失败");//积分价值
Assert.assertEquals(id2,"1355","校验pk id失败");
Assert.assertTrue(new BigDecimal(shareExp2).compareTo(new BigDecimal("199"))==0,"校验瓜分的经验池失败");//瓜分的经验池
Assert.assertEquals(title2,"瓜分红包","校验投注活动标题失败");//投注活动标题
Assert.assertEquals(unitName2,"元宝","校验消耗类型失败");
Assert.assertEquals(optionId3,"2869","校验选项1 id失败");
Assert.assertEquals(optionImg3,"//yun.dui88.com/images/201812/wfvn1m8wm0.jpg","校验选项1 图片失败");
Assert.assertEquals(optionName3,"分红包选项一","校验选项1 title失败");
Assert.assertEquals(optionId4,"2870","校验选项2 id失败");
Assert.assertEquals(optionImg4,"//yun.dui88.com/images/201812/ifh1kvaq9m.jpg","校验选项2 图片失败");
Assert.assertEquals(optionName4,"分红包选项二","校验选项2 title失败");
logger.info("pk组件分红包、分积分配置校验正确!");
}
}
\ No newline at end of file
...@@ -2,7 +2,10 @@ package http.cases.SingleLotteryTest; ...@@ -2,7 +2,10 @@ package http.cases.SingleLotteryTest;
import base.DuibaLog; import base.DuibaLog;
import base.DuibaTestBase; import base.DuibaTestBase;
import http.service.Activity.SingleLotteryService;
import http.service.Authorization;
import http.service.hd.SigninService; import http.service.hd.SigninService;
import io.restassured.http.Cookies;
import io.restassured.internal.assertion.Assertion; import io.restassured.internal.assertion.Assertion;
import io.restassured.response.Response; import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -10,12 +13,20 @@ import org.testng.Assert; ...@@ -10,12 +13,20 @@ import org.testng.Assert;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import utils.MatcherString; import utils.MatcherString;
import java.util.Map;
import static io.restassured.RestAssured.given;
/** /**
* Created by zhaoran on 2018/6/8. * Created by zhaoran on 2018/6/8.
*/ */
public class 预览单品抽奖_AccessTest extends DuibaTestBase { public class 预览单品抽奖_AccessTest extends DuibaTestBase {
@Autowired @Autowired
SigninService signinService; SigninService signinService;
@Autowired
SingleLotteryService singleLotteryService;
@Autowired
Authorization authorization;
private static DuibaLog logger = DuibaLog.getLogger(); private static DuibaLog logger = DuibaLog.getLogger();
@Test @Test
...@@ -25,6 +36,14 @@ public class 预览单品抽奖_AccessTest extends DuibaTestBase { ...@@ -25,6 +36,14 @@ public class 预览单品抽奖_AccessTest extends DuibaTestBase {
logger.info("预览url为:"+url); logger.info("预览url为:"+url);
Assert.assertEquals(url.contains("http://activity.m.duibatest.com.cn/autoLogin/autologin?appKey=BDqysEMghRqpDWAaQu9S4rLihHm&uid=duiba-preview-user"), true, "校验是否展示马上使用失败"); Assert.assertEquals(url.contains("http://activity.m.duibatest.com.cn/autoLogin/autologin?appKey=BDqysEMghRqpDWAaQu9S4rLihHm&uid=duiba-preview-user"), true, "校验是否展示马上使用失败");
//获取预发场景cookie
Response responses = authorization.previewLogin("BDqysEMghRqpDWAaQu9S4rLihHm","3G9A4pn8M2gVQQJbieW3CF8LRHM4");
//打开活动界面
response = singleLotteryService.index_preview("36732","preview","login",responses.getDetailedCookies());
//判断结果
Assert.assertEquals(MatcherString.getString(response.asString(),"<title>(.*?)</title>",1),"自动化_预览单抽","活动页打开异常!");
logger.info("活动页面打开成功");
} }
......
/**
* Copyright (C), 2015-2018
* FileName: BetMngVo
* Author: qianwenjun
* Date: 2018/8/5 10:12
* Description:
*/
package http.model;
import java.util.List;
/**
* @author 赵然
* @create 2018/12/11
* @since 1.0.0
*/
public class BetDevelopVo {
public List<BetOptionVo> getBetOptionDtoList() {
return betOptionDtoList;
}
public void setBetOptionDtoList(List<BetOptionVo> betOptionDtoList) {
this.betOptionDtoList = betOptionDtoList;
}
private List<BetOptionVo> betOptionDtoList;
private String betType; //'押注类型 1-单选单次,2-多选无限制'
private String bonusAmount; //'每人实际分得金额'
private String bonusType; //'瓜分类型1瓜分经验2瓜分红包3发奖品4瓜分积分'
private String configStatus; //'投注活动的状态:1关闭不可见2关闭可见3开启4结束'
private String creditsValue; //'积分价值'
private String endTime; //'活动结束时间'
private String shareExp; //'瓜分的经验池'
private String startTime; // '活动开始时间'
private String title; //'投注活动标题'
// private String id; //主键
// private String pluginId; //'发奖品时需要填插件id'
// private String prizeLimit; //'发奖品时的发放上限'
// public String getPluginId() {
// return pluginId;
// }
//
// public void setPluginId(String pluginId) {
// this.pluginId = pluginId;
// }
//
// public String getPrizeLimit() {
// return prizeLimit;
// }
// public void setPrizeLimit(String prizeLimit) {
// this.prizeLimit = prizeLimit;
// }
public String getBetType() {
return betType;
}
public void setBetType(String betType) {
this.betType = betType;
}
public String getBonusAmount() {
return bonusAmount;
}
public void setBonusAmount(String bonusAmount) {
this.bonusAmount = bonusAmount;
}
public String getBonusType() {
return bonusType;
}
public void setBonusType(String bonusType) {
this.bonusType = bonusType;
}
public String getConfigStatus() {
return configStatus;
}
public void setConfigStatus(String configStatus) {
this.configStatus = configStatus;
}
public String getCreditsValue() {
return creditsValue;
}
public void setCreditsValue(String creditsValue) {
this.creditsValue = creditsValue;
}
public String getEndTime() {
return endTime;
}
public void setEndTime(String endTime) {
this.endTime = endTime;
}
public String getShareExp() {
return shareExp;
}
public void setShareExp(String shareExp) {
this.shareExp = shareExp;
}
public String getStartTime() {
return startTime;
}
public void setStartTime(String startTime) {
this.startTime = startTime;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
}
\ No newline at end of file
...@@ -19,7 +19,7 @@ public class BetOptionVo { ...@@ -19,7 +19,7 @@ public class BetOptionVo {
private String optionImg; private String optionImg;
private String optionName; private String optionName;
private String rightAnswer;
public String getOptionImg() { public String getOptionImg() {
return optionImg; return optionImg;
...@@ -37,5 +37,11 @@ public class BetOptionVo { ...@@ -37,5 +37,11 @@ public class BetOptionVo {
this.optionName = optionName; this.optionName = optionName;
} }
public String getRightAnswer() {
return rightAnswer;
}
public void setRightAnswer(String rightAnswer) {
this.rightAnswer = rightAnswer;
}
} }
\ No newline at end of file
...@@ -89,7 +89,25 @@ public class SingleLotteryService { ...@@ -89,7 +89,25 @@ public class SingleLotteryService {
} }
return response; return response;
} }
public Response index_preview(String atcId,String type,String from,Cookies cookies) throws Exception {
Map<String,String> map = new HashMap<>();
map.put("id",atcId);
map.put("type",type);
map.put("from",from);
map.put("spm","18714.1.1.1");
logger.info("请求/singleLottery/index接口,id=" + atcId);
Response response = given().cookies(cookies).params(map).get("https://activity.m.duibatest.com.cn" + "/singleLottery/index");
try{
Assert.assertEquals(String.valueOf(response.getStatusCode()),"200","活动页打开异常");
}catch(Exception e){
throw new Exception("/singleLottery/index接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/singleLottery/index接口失败,返回信息:"+response.asString());
}
return response;
}
//访问开发者自有手动开奖 //访问开发者自有手动开奖
public Response index_sd(String atcId) throws Exception { public Response index_sd(String atcId) throws Exception {
Map<String,String> map = new HashMap<>(); Map<String,String> map = new HashMap<>();
......
...@@ -173,6 +173,20 @@ public class Authorization { ...@@ -173,6 +173,20 @@ public class Authorization {
return response; return response;
} }
public Response previewLogin(String appKey,String appSecret){
CreditTool tool=new CreditTool(appKey, appSecret);
Map params=new HashMap();
params.put("uid","duiba-preview-user");
String url=tool.buildUrlWithSign("http://activity.m.duibatest.com.cn/autoLogin/autologin?",params);
logger.info("dafuweng免登陆url为:"+url);
Response response=given().redirects().follow(false).get(url);
logger.info("dafuweng免登陆,响应数据:"+response.asString());
logger.info("dafuweng免登陆,响应状态码:"+response.getStatusCode());
return response;
}
public Map generateSignAutoLogin(String appKey, int uid){ public Map generateSignAutoLogin(String appKey, int uid){
String url = "http://activity.m.duibatest.com.cn/test/generateSign?appKey=" + appKey + "&uid=" + uid + "&vip=5"; String url = "http://activity.m.duibatest.com.cn/test/generateSign?appKey=" + appKey + "&uid=" + uid + "&vip=5";
Response response = given().get(url); Response response = given().get(url);
......
package http.service.hd;
import base.DuibaLog;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import http.model.BetOptionVo;
import http.model.BetDevelopVo;
import http.service.Authorization;
import io.restassured.response.Response;
import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.testng.Assert;
import utils.MatcherString;
import utils.PublicMethod;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static io.restassured.RestAssured.given;
/**
* @author zhaoran
* @create 2018/12/11
* @since 1.0.0
*/
@Service
public class PkDevelopService {
@Value("${hdserver.host}")
String hdHost;
@Value("${manager.host}")
String ManagerHost;
@Autowired
Authorization authorization;
private DuibaLog logger = DuibaLog.getLogger();
public Response betEditor(String appId,String bonusType,String bonusAmount,String shareExp) throws Exception{
String data = PublicMethod.data();
String url = "http://" + hdHost + "/visual-editor/bet/post";
//创建投注项
List<BetOptionVo> betOptionVoList = new ArrayList<>();
BetOptionVo betOptionVo1 = new BetOptionVo();
BetOptionVo betOptionVo2 = new BetOptionVo();
betOptionVo1.setOptionImg("//yun.dui88.com/images/201812/75j84chnkg.jpg");
betOptionVo1.setOptionName("1");
betOptionVo1.setRightAnswer(null);
betOptionVo2.setOptionImg("//yun.dui88.com/images/201812/4f51vmzfpu.png");
betOptionVo2.setOptionName("2");
betOptionVo2.setRightAnswer(null);
betOptionVoList.add(betOptionVo1);
betOptionVoList.add(betOptionVo2);
//创建活动配置
List<BetDevelopVo> betDevelopVoList = new ArrayList<>();
BetDevelopVo betDevelopVo = new BetDevelopVo();
betDevelopVo.setBetOptionDtoList(betOptionVoList);
betDevelopVo.setBetType("1");
betDevelopVo.setBonusType(bonusType);
if (bonusType.equals("2")){
betDevelopVo.setTitle("【自动化】组件pk_瓜分红包"+data);
}else if (bonusType.equals("4")){
betDevelopVo.setTitle("【自动化】组件pk_瓜分积分"+data);
}
betDevelopVo.setBonusAmount(bonusAmount);
betDevelopVo.setConfigStatus("3");
betDevelopVo.setCreditsValue("1");
betDevelopVo.setEndTime("2029-12-31 00:00");
betDevelopVo.setShareExp(shareExp);
betDevelopVoList.add(betDevelopVo);
Map<String,Object> para = new HashMap<>();
para.put("list",betDevelopVoList);
para.put("rules","自动化规则自动化规则");
para.put("title","组件pk自动化");
JSONObject jsonParam = JSONObject.parseObject(JSON.toJSONString(para));
Response betResponse = given().contentType("application/json;charset=UTF-8").cookies(authorization.hdLoginSaas(appId)).body(jsonParam).post(url);
betResponse.prettyPrint();
try{
Assert.assertEquals(betResponse.jsonPath().getString("success"),"true");
}catch(Exception e){
throw new Exception("创建pk活动接口失败,返回信息:"+betResponse.asString());
}catch(Error er){
throw new Exception("创建pk活动接口失败,返回信息:"+betResponse.asString());
}
return betResponse;
}
public Response doDraw() throws Exception{
String url = "http://" + ManagerHost + "/newmanager/betOpenPrize/doDraw";
Map<String,Object> para = new HashMap<>();
// para.put("pageNo","1");
// para.put("pageSize","20");
Response doDrawResponse = given().cookies(authorization.ssoLogin()).params(para).get(url);
try{
Assert.assertEquals(doDrawResponse.jsonPath().getString("success"),"true");
}catch(Exception e){
throw new Exception("pk活动开奖接口失败,返回信息:"+doDrawResponse.asString());
}catch(Error er){
throw new Exception("pk活动开奖接口失败,返回信息:"+doDrawResponse.asString());
}
return doDrawResponse;
}
// public static void main(String[] args) throws Exception{
// String endTime = "2021-12-31 23:55:00";
// PkActivityService pkActivityService = new PkActivityService();
//
// Response betResponse = pkActivityService.bet("2",endTime);
// String betId = MatcherString.getString(betResponse.asString(),"\"data\":(.*?)}",1);
// Response betRelation = pkActivityService.betGroupRelation(betId,endTime);
// Response modifyStatusResponse = pkActivityService.modifySatus(betId);
//
// }
}
\ No newline at end of file
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