Commit 587ad665 authored by 吕雯燕's avatar 吕雯燕

lv

parent a0235647
......@@ -7,6 +7,7 @@ import http.service.Activity.ManagerService;
import http.service.Activity.NewActivityService;
import http.service.Activity.SingleLotteryService;
import http.service.hd.DeveloperService;
import http.service.hd.LaunchService;
import http.service.hd.SigninService;
import utils.MatcherString;
import base.DuibaLog;
......@@ -26,6 +27,8 @@ public class 新建活动测试_DuibaTest extends DuibaTestBase{
@Autowired
DeveloperService developerService;
@Autowired
LaunchService launchService;
private static DuibaLog logger = DuibaLog.getLogger();
......@@ -81,8 +84,20 @@ public class 新建活动测试_DuibaTest extends DuibaTestBase{
new Object[]{1,"[{\"type\":\"coupon\",\"title\":\"优惠券\",\"img\":\"//yun.duiba.com.cn/upload/bust51462438317113.png\",\"valid\":true,\"probability\":\"1\",\"show\":true,\"arealimit\":false,\"pronumber\":\"1\",\"alipay\":\"\",\"description\":\"\",\"appItemId\":172178,\"name\":\"【勿动】自有优惠券审核通过测试\",\"remaind\":\"100\"},{\"type\":\"object\",\"title\":\"实物\",\"img\":\"//yun.duiba.com.cn/upload/1uF0l1462438316968.png\",\"valid\":true,\"probability\":\"2\",\"show\":true,\"arealimit\":false,\"pronumber\":\"2\",\"alipay\":\"\",\"description\":\"\",\"appItemId\":175491,\"name\":\"【自动化】自有实物19:51:09\",\"remaind\":\"50\"},{\"type\":\"virtual\",\"title\":\"虚拟商品\",\"img\":\"//yun.duiba.com.cn/developer/img/activityTool/slotMachine/virtual.png\",\"valid\":true,\"probability\":\"3\",\"show\":true,\"arealimit\":false,\"pronumber\":\"3\",\"alipay\":\"\",\"description\":\"\",\"appItemId\":159849,\"value\":\"DUIBA_SELF\",\"remaind\":\"10\"}]",
"[{\"index\":null,\"type\":\"text\",\"rightAnswer\":1,\"name\":\"文字题1\",\"option1\":\"文字题1A\",\"option2\":\"文字题1B\",\"option3\":\"文字题1C\",\"option4\":\"文字题1D\"},{\"index\":null,\"type\":\"text\",\"rightAnswer\":\"2\",\"name\":\"文字题2\",\"option1\":\"文字题2A\",\"option2\":\"文字题2B\",\"option3\":\"文字题2C\",\"option4\":\"文字题2D\"},{\"index\":null,\"type\":\"text\",\"rightAnswer\":\"3\",\"name\":\"文字题3\",\"option1\":\"文字题3A\",\"option2\":\"文字题3B\",\"option3\":\"文字题3C\",\"option4\":\"文字题3D\"}]",
"0","","everyday","12","everyday","3","新建自有答题独立活动-文字题"}, //case1
new Object[]{2,"[{\"type\":\"virtual\",\"title\":\"虚拟商品\",\"img\":\"//yun.duiba.com.cn/developer/img/activityTool/slotMachine/virtual.png\",\"valid\":true,\"probability\":\"2\",\"show\":true,\"arealimit\":false,\"pronumber\":\"2\",\"alipay\":\"\",\"description\":\"\",\"appItemId\":178060,\"value\":\"test\",\"remaind\":\"200\"}]",
"[{\"index\":null,\"type\":\"image\",\"rightAnswer\":1,\"name\":\"图片题1\",\"option1\":\"//yun.dui88.com/images/201812/dbdzbihqdu.png\",\"option2\":\"//yun.dui88.com/images/201812/6uoag0r7wi.png\",\"option3\":\"//yun.dui88.com/images/201812/5ht2x4zyjn.gif\",\"option4\":\"//yun.dui88.com/images/201812/gk6pvpoabr.png\"},{\"index\":null,\"type\":\"image\",\"rightAnswer\":\"2\",\"name\":\"图片题2\",\"option1\":\"//yun.dui88.com/images/201812/c3iyatkw3u.png\",\"option2\":\"//yun.dui88.com/images/201812/stzcy6dzaf.gif\",\"option3\":\"//yun.dui88.com/images/201812/nkmpgb7jcd.png\",\"option4\":\"//yun.dui88.com/images/201812/6r5hwfet8e.png\"}]",
"0","","everyday","30","forever","2","新建自有答题独立活动-图片题"}, //case2
};
}else
if(method.getName().equals("新建自有签到活动")){
result = new Object[][]{
new Object[]{1,"0","[{\"type\":\"alipay\",\"description\":\"支付宝\",\"logo\":\"//yun.duiba.com.cn/developer/img/activityTool/slotMachine/alipay.png\",\"appItemId\":156493,\"arealimit\":false,\"rate\":\"50\",\"name\":\"\",\"valid\":true,\"otherUse\":5,\"remaining\":\"100\",\"winLimit\":\"1\",\"minComein\":\"10\",\"facePrice\":\"10\",\"stockAfterChange\":\"100\",\"stockBeforeChange\":0}]",
"10,20,30,40,50","新建签到活动-连续签到"}, //case1
new Object[]{2,"1","[{\"type\":\"virtual\",\"description\":\"虚拟商品\",\"logo\":\"//yun.duiba.com.cn/developer/img/activityTool/slotMachine/virtual.png\",\"appItemId\":178060,\"arealimit\":false,\"rate\":\"50\",\"name\":\"test\",\"valid\":true,\"otherUse\":1,\"remaining\":\"100\",\"winLimit\":\"1\",\"minComein\":\"\",\"facePrice\":\"\",\"stockAfterChange\":\"100\",\"stockBeforeChange\":0},{\"type\":\"phonebill\",\"description\":\"话费\",\"logo\":\"//yun.duiba.com.cn/developer/img/activityTool/slotMachine/phonebill.png\",\"appItemId\":156496,\"arealimit\":false,\"rate\":\"5\",\"name\":\"\",\"valid\":true,\"otherUse\":7,\"remaining\":\"50\",\"winLimit\":\"1\",\"minComein\":\"100\",\"facePrice\":\"10\",\"stockAfterChange\":\"50\",\"stockBeforeChange\":0}]",
"5,10,15,20,25,30,35","新建签到活动-连续周期签到"}, //case2
};
}
return result;
......@@ -123,6 +138,7 @@ public class 新建活动测试_DuibaTest extends DuibaTestBase{
Assert.assertEquals(editResponse.jsonPath().getString("data.freeScope"),"everyday","校验活动免费抽奖次数类型失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.limitCount"),"5","校验活动限制次数失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.limitScope"),"everyday","校验活动限制次数类型失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.bannerImgNew"),"//yun.duiba.com.cn/upload/newHdTool/turntable_cricle/banner_750x220.png","校验活动新版banner图失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.awards[1].name"),"【自动化勿动】自有优惠券","校验活动奖品名称失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.awards[1].limit"),"1","校验活动奖品中奖限制失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.awards[1].oldRemaind"),"100","校验活动奖品数量失败");
......@@ -339,6 +355,7 @@ public class 新建活动测试_DuibaTest extends DuibaTestBase{
Assert.assertEquals(editResponse.jsonPath().getString("data.freeScope"),"everyday","校验活动免费抽奖次数类型失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.limitCount"),"5","校验活动限制次数失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.limitScope"),"everyday","校验活动限制类型失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.bannerImgNew"),"//yun.duiba.com.cn/upload/qzfsmsyo9s.png","校验活动新版banner图失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.questionRecord[0].name"),"文字题一","校验活动题目名称失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.questionRecord[0].type"),"text","校验活动题目类型失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.awards[0].name"),"【勿动】自有优惠券审核通过测试","校验活动奖品名称失败");
......@@ -378,14 +395,14 @@ public class 新建活动测试_DuibaTest extends DuibaTestBase{
* @param caseName 用例名称
* @throws Exception
*/
// @Test(dataProvider = "providerMethod")
@Test(dataProvider = "providerMethod")
public void 新建自有答题独立活动(int caseNum,String awards,String questionRecord,String creditsType,String freeLimit,String freeScope,String limitCount,String limitScope,String optionNum,String caseName) throws Exception{
logger.info("-----------------------------"+caseName+"-----------------------------");
String data = PublicMethod.data();
String title = "【自动化】自有答题独立活动"+data;
//新建自有答题活动
//新建自有答题独立活动
developerService.saveQuestion(title,awards,questionRecord,creditsType,freeLimit,freeScope,limitCount,limitScope,optionNum);
//获取活动id
......@@ -409,7 +426,13 @@ public class 新建活动测试_DuibaTest extends DuibaTestBase{
logger.info("校验新建自有答题独立活动-1内容成功");
break;
case 2:
Assert.assertEquals(editResponse.jsonPath().getString("data.freeLimit"),"30","校验活动免费次数失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.limitCount"),"30","校验活动限制次数失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.limitScope"),"forever","校验活动限制类型失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.questionRecord[1].name"),"图片题2","校验活动题目名称失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.questionRecord[1].type"),"image","校验活动题目类型失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.awards[0].probability"),"2","校验活动奖品获奖资格失败");
logger.info("校验新建自有答题独立活动-2内容成功");
break;
}
......@@ -420,6 +443,88 @@ public class 新建活动测试_DuibaTest extends DuibaTestBase{
}
/**
* @param caseNum 用例编号
* @param signType 签到类型
* @param prizes 额外奖励
* @param signCredits 签到获得积分数
* @param caseName 用例名称
* @throws Exception
*/
@Test(dataProvider = "providerMethod")
public void 新建自有签到活动(int caseNum,String signType,String prizes,String signCredits,String caseName) throws Exception{
logger.info("-----------------------------"+caseName+"-----------------------------");
String data = PublicMethod.data();
String title = "【自动化】自有签到活动"+data;
//新建自有答题独立活动
developerService.saveSign(title,signType,prizes,signCredits);
//获取活动id
Response listResponse = developerService.signList();
String id = String.valueOf(listResponse.jsonPath().getString("datas[0].id"));
logger.info(id);
//编辑活动,校验活动内容
Response editResponse = developerService.editSign(id);
switch (caseNum){
case 1:
Assert.assertEquals(editResponse.jsonPath().getString("data.anticheatExchangeLimit"),"true","校验直充类防刷失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.signCredits"),"10,20,30,40,50","校验签到获得积分数失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.signType"),"0","校验签到类型失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.ruleDescription"),"测试活动规则","校验活动规则失败");
Assert.assertEquals(editResponse.jsonPath().getString("prizes[0].appItemId"),"156493","校验额外奖励奖品id失败");
Assert.assertEquals(editResponse.jsonPath().getString("prizes[0].type"),"alipay","校验额外奖励奖品类型失败");
Assert.assertEquals(editResponse.jsonPath().getString("prizes[0].winLimit"),"1","校验额外奖励奖品中奖限制失败");
logger.info("校验新建自有签到活动-1内容成功");
break;
case 2:
Assert.assertEquals(editResponse.jsonPath().getString("data.signCredits"),"5,10,15,20,25,30,35","校验签到获得积分数失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.signType"),"1","校验签到类型失败");
Assert.assertEquals(editResponse.jsonPath().getString("prizes[0].appItemId"),"156496","校验额外奖励奖品0id失败");
Assert.assertEquals(editResponse.jsonPath().getString("prizes[0].type"),"phonebill","校验额外奖励奖品0类型失败");
Assert.assertEquals(editResponse.jsonPath().getString("prizes[1].appItemId"),"178060","校验额外奖励奖品1id失败");
Assert.assertEquals(editResponse.jsonPath().getString("prizes[1].type"),"virtual","校验额外奖励奖品1类型失败");
logger.info("校验新建自有签到活动-2内容成功");
break;
}
//删除测试数据
this.删除自有签到活动();
}
@Test(description = "活动工具获取默认数据测试")
public void 新建活动工具获取默认数据() throws Exception{
//获取砸彩蛋活动数据配置项
Response dataResponse = launchService.getDataConfigUrl("smashg");
//添加奖品,获取默认奖品接口
Response obtainResponse = launchService.obtain();
Assert.assertEquals(dataResponse.jsonPath().getString("data.dataConfig.defaultAwardImgs.alipay"),"//yun.duiba.com.cn/upload/KkZMp1462438317113.png","校验支付宝奖品默认图片失败");
Assert.assertEquals(dataResponse.jsonPath().getString("data.dataConfig.minAwards"),"4","校验最小活动奖品数失败");
Assert.assertEquals(dataResponse.jsonPath().getString("data.dataConfig.tip"),"为保证活动效果,请为此活动配置4~8个奖品。未中奖默认为“谢谢参与”。","校验奖项配置提示语失败");
Assert.assertEquals(dataResponse.jsonPath().getString("data.dataConfig.upload.bannerImgNew.url"),"//yun.duiba.com.cn/upload/newHdTool/hitEgg/banner_750x220.png","校验展示图片新版banner图失败");
Assert.assertEquals(dataResponse.jsonPath().getString("data.dataConfig.upload.award.size.height"),"250","校验奖品图片尺寸失败");
Assert.assertEquals(dataResponse.jsonPath().getString("data.dataConfig.upload.award.size.width"),"250","校验奖品图片尺寸失败");
Assert.assertEquals(dataResponse.jsonPath().getString("data.title"),"砸彩蛋","校验title失败");
logger.info("校验新建活动工具获取图片配置项成功");
Assert.assertEquals(obtainResponse.jsonPath().getString("data.items.alipay"),"156493","校验支付宝奖品id失败");
Assert.assertEquals(obtainResponse.jsonPath().getString("data.items.phonebill"),"156496","校验话费奖品id失败");
Assert.assertEquals(obtainResponse.jsonPath().getString("data.items.qb"),"156494","校验Q币奖品id失败");
Assert.assertTrue(obtainResponse.jsonPath().getString("data.virtualList").contains("【勿动】虚拟商品"), "校验虚拟商品奖品失败");
logger.info("校验新建活动工具获取默认奖品成功");
}
......@@ -431,4 +536,11 @@ public class 新建活动测试_DuibaTest extends DuibaTestBase{
developerService.delActivity(actId);
}
//删除自有签到活动
public void 删除自有签到活动() throws Exception{
//开发者删除自有签到活动
Response HdResponse = developerService.signList();
String id = HdResponse.jsonPath().getString("datas[0].id");
developerService.delete(id);
}
}
......@@ -619,7 +619,7 @@ public class DeveloperService {
return response;
}
//删除活动
//删除自有签到活动
public Response delete(String signId) throws Exception {
Map<String,String> map = new HashMap<>();
......@@ -1172,4 +1172,61 @@ public class DeveloperService {
return response;
}
//创建自有弹层签到--所有字段
public Response saveSign(String title,String signType,String prizes,String signCredits) throws Exception {
String url=hdHost+"/signConfig/signSave";
Map<String,String> map = new HashMap<>();
map.put("title",title);
map.put("rateDescription","测试概率shuom");
map.put("ruleDescription","测试活动规则");
map.put("signType",signType);
map.put("prizes",prizes);
map.put("imageUrl","//yun.duiba.com.cn/developer_new/images/activities/sign.jpg");
map.put("triggerType","chome");
map.put("deletedPrizeIds","");
map.put("signCredits",signCredits);
map.put("status","0");
map.put("anticheatExchangeLimit","true");
map.put("appId","2239");
map.put("id","");
logger.info("创建自有签到活动:"+url);
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLogin()).params(map).post("http://"+url);
response.prettyPrint();
try{
Assert.assertEquals(response.jsonPath().getString("desc"),"成功");
}catch(Exception e){
throw new Exception("创建自有签到活动接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("创建自有签到活动接口失败,返回信息:"+response.asString());
}
return response;
}
//编辑自有弹层签到
public Response editSign(String id) throws Exception {
String url=hdHost+"/signConfig/signEdit";
Map<String,String> map = new HashMap<>();
map.put("id",id);
map.put("appId","2239");
logger.info("编辑自有签到活动:"+url);
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLogin()).params(map).post("http://"+url);
response.prettyPrint();
try{
Assert.assertEquals(response.jsonPath().getString("success"),"true");
}catch(Exception e){
throw new Exception("编辑自有签到活动接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("编辑自有签到活动接口失败,返回信息:"+response.asString());
}
return response;
}
}
package http.service.hd;
import http.service.Authorization;
import base.DuibaLog;
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;
/**
* Created by lvwenyan on 2018/12/06.
*/
@Service
public class LaunchService {
@Value("${hdserver.host}")
String hdHost;
@Autowired
Authorization authorization;
private DuibaLog logger = DuibaLog.getLogger();
//获取活动默认数据
public Response getDataConfigUrl(String type) throws Exception{
String url = hdHost + "/launch/getDataConfigUrl";
Map<String,String> map = new HashMap<>();
map.put("appId","2239");
map.put("type",type);
logger.info("请求数据配置接口:" + url);
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLogin()).params(map).post("http://"+url);
response.prettyPrint();
try{
Assert.assertEquals(response.jsonPath().getString("desc"),"成功");
}catch(Exception e){
throw new Exception("请求数据配置接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("请求数据配置接口失败,返回信息:"+response.asString());
}
return response;
}
//获取活动默认奖品
public Response obtain() throws Exception{
String url = hdHost + "/launch/obtain";
Map<String,String> map = new HashMap<>();
map.put("appId","2239");
logger.info("请求获取奖品接口:" + url);
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLogin()).params(map).post("http://"+url);
response.prettyPrint();
try{
Assert.assertEquals(response.jsonPath().getString("desc"),"成功");
}catch(Exception e){
throw new Exception("请求获取奖品接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("请求获取奖品接口失败,返回信息:"+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