Commit c7a95f64 authored by 赵然's avatar 赵然

zr

parent 9204fc49
......@@ -19,7 +19,7 @@ import java.util.List;
* Created by humengxin on 2018/8/21.
*/
@ContextConfiguration(classes = Config.class)
public class 自定义分类 extends AbstractTestNGSpringContextTests {
public class 自定义分类_DuibaTest extends AbstractTestNGSpringContextTests {
@Autowired
ZdyflService zdyflService;
......
package http.cases.SingleLotteryTest;
import base.DuibaTestBase;
import utils.PublicMethod;
import http.service.Activity.ManagerService;
import http.service.Activity.SingleLotteryService;
import http.service.Authorization;
import http.service.hd.DeveloperService;
import utils.MatcherString;
import base.DuibaLog;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.testng.Assert;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
/**
* Created by zhaoran on 2018/4/17.
*/
public class 单品抽奖_中鼓励奖_AccessTest extends DuibaTestBase {
@Autowired
SingleLotteryService singleLotteryService;
@Autowired
DeveloperService developerService;
@Autowired
Authorization authorization;
@Autowired
ManagerService managerService;
@Value("${activity.host}")
String activityHost;
private static DuibaLog logger = DuibaLog.getLogger();
private static String actId;
private static String data;
//指定用户
private static int uid = 2709;
@DataProvider
public Object[][] providerMethod(Method method){
Object[][] result = null;
if(method.getName().equals("鼓励奖限制测试")) {
result = new Object[][]{
new Object[]{1, "27128", "1", "","鼓励奖优惠券数量1,数量用完则判断是否可中主奖"},
new Object[]{2, "27000", "99999", "1","鼓励奖限制,数量用完后用户无法再中鼓励奖"},
};
}
return result;
}
@Test(dataProvider = "providerMethod")
public void 鼓励奖限制测试(int caseNum,String inciteItemId,String inciteItemRemaining,String inciteItemConsumerWinLimit,String casename) throws Exception {
logger.info("-------------------------------------"+casename+"-------------------------------------");
//创建活动
this.创建并上架活动(inciteItemId, inciteItemRemaining, inciteItemConsumerWinLimit);
Response response = developerService.list2("【自动化】鼓励奖限制"+data);
String activityId = response.jsonPath().getString("data.list[0].id");
//当天首次抽奖中鼓励奖
response = this.单品抽奖入参(activityId,activityId,"asdsad");
//根据case选择对应的校验项
switch(caseNum){
case 1:
Assert.assertEquals(response.jsonPath().getString("descrption"),"【勿动】自动化优惠券——商家落地页","校验优惠券标题失败");
Assert.assertEquals(response.jsonPath().getString("lotteryType"), "coupon", "校验奖品类型失败");
Assert.assertEquals(response.jsonPath().getString("showUse"), "true", "校验奖品类型失败");
Assert.assertEquals(response.jsonPath().getString("message"), "成功", "校验message失败");
Assert.assertEquals(response.jsonPath().getString("status"), "1", "校验status失败");
logger.info("第一次抽奖,校验descrption,showUse,lotteryType,message,status成功");
logger.info("当天首次抽奖中鼓励奖—优惠券");
break;
case 2:
Assert.assertEquals(response.jsonPath().getString("descrption"),"自动化测试活动实物","校验优惠券标题失败");
Assert.assertEquals(response.jsonPath().getString("lotteryType"), "object", "校验奖品类型失败");
Assert.assertEquals(response.jsonPath().getString("message"), "成功", "校验message失败");
Assert.assertEquals(response.jsonPath().getString("status"), "1", "校验status失败");
logger.info("第一次抽奖,校验descrption,lotteryType,message,status成功");
logger.info("当天首次抽奖中鼓励奖—实物");
break;
}
//当天第二次抽奖
response = this.单品抽奖入参(activityId,activityId,"asdsad");
Assert.assertEquals(response.jsonPath().getString("descrption"),"支付宝充值","校验优惠券标题失败");
Assert.assertEquals(response.jsonPath().getString("lotteryType"), "alipay", "校验奖品类型失败");
Assert.assertEquals(response.jsonPath().getString("message"), "成功", "校验message失败");
Assert.assertEquals(response.jsonPath().getString("status"), "1", "校验status失败");
logger.info("第二次抽奖lotteryType,useBtnText,success");
logger.info("当天第二次抽奖中主奖—支付宝");
//删除测试数据
this.删除活动();
try {
jdbc.update("delete from credits_dev.duiba_single_lottery where title=?", "【自动化】鼓励奖限制"+data);
jdbc.update("delete from credits_dev.operating_activity where title=?", "【自动化】鼓励奖限制"+data);
} catch (Exception e) {
System.out.println(e);
}
}
public Response 单品抽奖入参(String operationAcitvityId,String oaId,String token) throws Exception {
//进行接口测试传参
Response response =singleLotteryService.doJoin(uid,operationAcitvityId,oaId,token);
//response.prettyPrint();
String id =MatcherString.getString(response.asString(), "singleLotteryOrderId\":(.*?),", 1);
response = singleLotteryService.getOrderStatus(uid,id,"iOS");
int i = 10;
while ("处理中".equals(response.jsonPath().getString("message")) && i > 0) {
Thread.sleep(500);
response = singleLotteryService.getOrderStatus(uid,id,"iOS");
i--;
}
return response;
}
public void 创建并上架活动(String inciteItemId,String inciteItemRemaining,String inciteItemConsumerWinLimit) throws Exception {
data = PublicMethod.data();
String title = "【自动化】鼓励奖限制"+data;
//创建单品抽奖活动
//构建鼓励奖
Map<String,String> incite = new HashMap<>();
incite.put("inciteItemId",inciteItemId);
incite.put("inciteItemRate","100");
incite.put("inciteItemRemaining",inciteItemRemaining);
incite.put("preInciteItemRemaining","99999");
incite.put("inciteItemConsumerWinLimit",inciteItemConsumerWinLimit);
incite.put("inciteItemMinComein","");
singleLotteryService.SingleLottery_create(title,incite);
//获取新建活动id
Response response = singleLotteryService.manager_index();
actId = MatcherString.getString(response.asString(), "<td>(.*?)</td>\n", 1);
//管理后台开启活动
singleLotteryService.changeStatus(actId,"1");
//开发者上架活动
developerService.joinIn(actId,"2");
logger.info("创建活动并上架成功");
}
public void 删除活动() throws Exception{
//管理后台删除单品抽奖活动
singleLotteryService.delete(actId);
//开发者删除推荐位活动
Response response = developerService.list2("【自动化】鼓励奖限制"+data);
String actId = response.jsonPath().getString("data.list[0].id");
developerService.delActivity(actId);
}
}
package http.cases.SingleLotteryTest;
import base.DuibaTestBase;
import utils.PublicMethod;
import http.service.Activity.ManagerService;
import http.service.Activity.SingleLotteryService;
import http.service.Authorization;
import http.service.hd.ActivityService;
import http.service.hd.DeveloperService;
import utils.MatcherString;
import base.DuibaLog;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.Test;
import java.util.HashMap;
import java.util.Map;
/**
* Created by zhaoran on 2018/4/17.
*/
public class 单品抽奖_出奖限制_AccessTest extends DuibaTestBase {
@Autowired
SingleLotteryService singleLotteryService;
@Autowired
DeveloperService developerService;
@Autowired
Authorization authorization;
@Autowired
ManagerService managerService;
@Autowired
ActivityService activityService;
@Value("${activity.host}")
String activityHost;
private static DuibaLog logger = DuibaLog.getLogger();
private static String actId;
private static String data;
//指定用户
private static int uid = 3777;
@AfterClass
public void after() throws Exception{
//数据库删除
try {
jdbc.update("delete from credits_dev.operating_activity where title=?","【自动化】出奖限制"+data);
jdbc.update("delete from credits_dev.duiba_single_lottery where title=?","【自动化】出奖限制"+data);
} catch (Exception e) {
System.out.println(e);
}
}
@Test(description = "每个用户可抽中奖品数上限为1")
public void 出奖限制测试() throws Exception {
this.创建并上架活动();
Response response = developerService.list2("【自动化】出奖限制"+data);
String activityId = response.jsonPath().getString("data.list[0].id");
//当天首次抽奖
response = this.单品抽奖入参(activityId,activityId,"asdsad");
Assert.assertEquals(response.jsonPath().getString("descrption"),"支付宝充值","校验优惠券标题失败");
Assert.assertEquals(response.jsonPath().getString("lotteryType"), "alipay", "校验奖品类型失败");
Assert.assertEquals(response.jsonPath().getString("message"), "成功", "校验message失败");
Assert.assertEquals(response.jsonPath().getString("status"), "1", "校验status失败");
logger.info("第一次抽奖,校验descrption,lotteryType,message,status成功");
//当天第二次抽奖
response = this.单品抽奖入参(activityId,activityId,"asdsad");
logger.info("tuia-engine服务启动成功");
Assert.assertEquals(response.jsonPath().getString("lotteryType"), "lucky", "校验奖品类型失败");
Assert.assertEquals(response.jsonPath().getString("lottery.useBtnText"), "马上使用", "校验是否展示马上使用失败");
Assert.assertEquals(response.jsonPath().getString("success"), "true", "校验success失败");
logger.info("第二次抽奖lotteryType,useBtnText,success");
this.删除活动();
}
public Response 单品抽奖入参(String operationAcitvityId,String oaId,String token) throws Exception {
//进行接口测试传参
Response response =singleLotteryService.doJoin(uid,operationAcitvityId,oaId,token);
//response.prettyPrint();
String id =MatcherString.getString(response.asString(), "singleLotteryOrderId\":(.*?),", 1);
response = singleLotteryService.getOrderStatus(uid,id,"iOS");
int i = 10;
while ("处理中".equals(response.jsonPath().getString("message")) && i > 0) {
Thread.sleep(500);
response = singleLotteryService.getOrderStatus(uid,id,"iOS");
i--;
}
return response;
}
public void 创建并上架活动() throws Exception {
data = PublicMethod.data();
String title = "【自动化】出奖限制"+data;
//创建单品抽奖活动
//构建鼓励奖
Map<String,String> incite = new HashMap<>();
incite.put("inciteItemId","");
incite.put("inciteItemRate","");
incite.put("inciteItemRemaining","");
incite.put("preInciteItemRemaining","");
incite.put("inciteItemConsumerWinLimit","");
incite.put("inciteItemMinComein","");
singleLotteryService.SingleLottery_create(title,incite);
//获取新建活动id
Response response = singleLotteryService.manager_index();
actId = MatcherString.getString(response.asString(), "<td>(.*?)</td>\n", 1);
//管理后台开启活动
singleLotteryService.changeStatus(actId,"1");
//开发者上架活动
developerService.joinIn(actId,"2");
logger.info("创建活动并上架成功");
}
public void 删除活动() throws Exception{
//管理后台删除单品抽奖活动
singleLotteryService.delete(actId);
//开发者删除推荐位活动
Response response = developerService.list2("【自动化】出奖限制"+data);
String actId = response.jsonPath().getString("data.list[0].id");
developerService.delActivity(actId);
}
}
package http.cases.SingleLotteryTest;
import base.Config;
import http.service.Activity.ManagerService;
import http.service.Activity.SingleLotteryService;
import http.service.Authorization;
import http.service.hd.DeveloperService;
import utils.MatcherString;
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.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 java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import static io.restassured.RestAssured.given;
/**
* Created by zhaoran on 2018/4/17.
*/
@ContextConfiguration(classes = Config.class)
public class 单品抽奖_异常场景_AccessTest extends AbstractTestNGSpringContextTests {
@Autowired
SingleLotteryService singleLotteryService;
@Autowired
DeveloperService developerService;
@Autowired
Authorization authorization;
@Autowired
ManagerService managerService;
@Value("${activity.host}")
String activityHost;
private static DuibaLog logger = DuibaLog.getLogger();
//指定用户
private static int uid = 2709;
@DataProvider
public Object[][] providerMethod(Method method){
Object[][] result = null;
if(method.getName().equals("限制抽奖测试")) {
result = new Object[][]{
new Object[]{1, "20065", "积分不足"},
new Object[]{2, "20066", "永久次数抽完"},
new Object[]{3, "20073", "当日次数抽完"},
};
}
if(method.getName().equals("中奖限制测试")) {
result = new Object[][]{
new Object[]{"每人限中1次,次数用完无法中奖", "1340","20915"},
new Object[]{"活动奖品剩余不足,无法中奖", "1341","20927"},
new Object[]{"活动奖品库存不足,无法中奖", "1342","20941"},
};
}
return result;
}
@Test(description = "开发者关闭活动,用户调接口抽奖场景")
public void 活动关闭测试() throws Exception {
//关闭活动
Response HdResponse = developerService.closeActivity("20046","2239");
//参加抽奖
Response response = this.单品抽奖异常场景传参("20046");
//判断结果
Assert.assertEquals(response.jsonPath().getString("success"), "false", "校验success失败");
Assert.assertEquals(response.jsonPath().getString("message"), "活动已结束", "校验message失败");
logger.info("活动状态关闭后的抽奖页面验证成功");
//打开活动
HdResponse = developerService.openActivity("20046","2239");
}
@Test(dataProvider = "providerMethod")
public void 限制抽奖测试(int casenum,String activityId,String casename) throws Exception {
logger.info("-------------------------------------"+casename+"-------------------------------------");
//参加抽奖
Response response = this.单品抽奖异常场景传参(activityId);
//根据case选择对应的校验项
switch(casenum){
case 1:
Assert.assertEquals(response.jsonPath().getString("message"),"积分不足","校验message失败");
logger.info("积分不足测试校验项:messag成功");
break;
case 2:
Assert.assertEquals(response.jsonPath().getString("message"),"已抽完","校验message失败");
Assert.assertEquals(response.jsonPath().getString("lotteryButtonStatus"),"2","校验lotteryButtonStatus失败");
logger.info("永久次数不足测试校验项:message,lotteryButtonStatus成功");
break;
case 3:
String success = MatcherString.getString(response.asString(), "\"success\": (.*?),", 1);
int i= 8;
while(i>0&&(success.equals("true"))){
response = this.单品抽奖异常场景传参(activityId);
success = MatcherString.getString(response.asString(), "\"success\": (.*?),", 1);
i--;
}
Assert.assertEquals(response.jsonPath().getString("message"),"今日已抽完","校验message失败");
Assert.assertEquals(response.jsonPath().getString("lotteryButtonStatus"),"8","校验lotteryButtonStatus失败");
logger.info("今日次数不足测试校验项:message,lotteryButtonStatus成功");
break;
}
//通用校验项
Assert.assertEquals(response.jsonPath().getString("success"),"false","校验success失败");
logger.info("通用校验项:success成功");
}
@Test
public void 未登录抽奖测试() throws Exception {
//获取未登录场景cookie
Response responses = authorization.autoLogin();
//进行接口测试传参
Response response = singleLotteryService.init(responses.getDetailedCookies(),"18873");
//校验项
Assert.assertEquals(response.jsonPath().getString("lotteryButtonStatus"),"7","校验lotteryButtonStatus失败");
logger.info("未登录状态下无免费次数抽奖校验:lotteryButtonStatus成功");
}
@Test(dataProvider = "providerMethod")
public void 中奖限制测试(String casename,String actId,String activityId) throws Exception {
logger.info("-------------------------------------"+casename+"-------------------------------------");
//获取管理员后台活动信息
Response ManagerResponse = singleLotteryService.AdminDuibaSingleLottery(actId);
logger.info("预设中奖商品为:实物类");
logger.info("预设中奖几率为:"+MatcherString.getString(ManagerResponse.asString(), "mainItemRate\" value=\"(.*?)\"", 1)+"%");
logger.info("预设中奖每人限制:"+MatcherString.getString(ManagerResponse.asString(), "consumerWinLimit\" value=\"(.*?)\"", 1));
logger.info("预设剩余奖品数:"+MatcherString.getString(ManagerResponse.asString(), "mainItemRemaining\" value=\"(.*?)\"", 1));
//获取奖品剩余库存
String appItemId = MatcherString.getString(ManagerResponse.asString(), "mainItemId\" value=\"(.*?)\"", 1);
String Objremaind = this.getremind(appItemId);
logger.info("预设奖品库存:"+Objremaind+"个");
//进行接口测试传参
Response response =singleLotteryService.doJoin(uid,activityId,activityId,"asdsad");
//response.prettyPrint();
String id =MatcherString.getString(response.asString(), "singleLotteryOrderId\":(.*?),", 1);
response = singleLotteryService.getOrderStatus(uid,id,"iOS");
int i = 10;
while ("处理中".equals(response.jsonPath().getString("message")) && i > 0) {
Thread.sleep(500);
response = singleLotteryService.getOrderStatus(uid,id,"iOS");
i--;
}
String type = String.valueOf(response.jsonPath().getString("lotteryType"));
if (type.equals("lucky")){
Assert.assertTrue(response.jsonPath().getString("lottery.link").contains("//activity.m.duibatest.com.cn/crecord/recordLuckDetailNew?"));
Assert.assertEquals(response.jsonPath().getString("lottery.useBtnText"),"马上使用","校验useBtnText失败");
Assert.assertEquals(response.jsonPath().getString("isAppLucky"),"true","校验谢谢参与转福袋失败");
logger.info("校验中奖限制测试:link,useBtnText,isAppLucky成功");
logger.info("校验中奖限制测试成功,未返回预设必中实物奖品");
}
if (type.equals("thanks")){
logger.info("福袋库存不足会降级成谢谢参与!");//福袋库存不足会降级成谢谢参与!
}
if (type.equals("object")&&MatcherString.getString(ManagerResponse.asString(), "mainItemRemaining\" value=\"(.*?)\"", 1).equals("0")){
throw new Exception("用例失败,不应返回实物信息:"+response.asString());
}
}
@Test(description = "该单品抽奖已在大富翁app上架可参与")
public void 开发者未上架单品抽奖() {
Response response = this.单品抽奖异常场景传参("33488");
//logger.info("CCCCC"+response.asString());
Assert.assertEquals(response.jsonPath().getString("success"),"false");
Assert.assertEquals(response.jsonPath().getString("message"),"无权访问");
}
public Response 单品抽奖异常场景传参(String activityId) {
Map<String, String> map = new HashMap<>();
map.put("operationAcitvityId", activityId);
map.put("oaId", activityId);
map.put("token", "hdfjks");
Response response = given().cookies(authorization.dafuwengLogin(uid)).params(map).post(activityHost + "/singleLottery/doJoin");
response.prettyPrint();
return response;
}
public String getremind(String gid) throws Exception{
Response ManagerResponse = managerService.CouponConfig(gid);
ManagerResponse.prettyPrint();
String remind = MatcherString.getString(ManagerResponse.asString(), "remaining\" value=\"(.*?)\"", 1);
return remind;
}
}
package http.cases.SingleLotteryTest;
import base.DuibaTestBase;
import http.service.Activity.SingleLotteryService;
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.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import java.lang.reflect.Method;
import java.util.Map;
/**
* Created by zhaoran on 2018/6/8.
*/
public class 自有单品抽奖_AccessTest extends DuibaTestBase {
@Autowired
SingleLotteryService singleLotteryService;
private static DuibaLog logger = DuibaLog.getLogger();
//指定用户
private static int uid = 2709;
@BeforeClass
public void before() {
try {
jdbc.update("delete from orders_consumer.orders_0616 where consumer_id = 100011624 and biz_params = 'DUIBA_SELF'", null);
} catch (Exception e) {
e.printStackTrace();
}
}
@DataProvider
public Object[][] providerMethod(Method method){
Object[][] result = null;
if(method.getName().equals("自有单品抽奖")) {
result = new Object[][]{
new Object[]{1, "26476", "ix18rh", "单品抽奖之优惠券","iOS"},
new Object[]{2, "26477", "ix18rh", "单品抽奖之实物","android"},
new Object[]{3, "26480", "40g83xb5", "单品抽奖之话费充值","iOS"},
new Object[]{4, "26478", "40g83xb5", "单品抽奖之支付宝充值","iOS"},
new Object[]{5, "26479", "9fm5ohz", "单品抽奖之Q币充值","iOS"},
new Object[]{6, "26481", "x62stnum", "单品抽奖之虚拟商品","iOS"},
};
}
return result;
}
@Test(dataProvider = "providerMethod" )
public void 自有单品抽奖(int caseNum,String activityId,String token,String casename,String device) throws Exception {
logger.info("-------------------------------------"+casename+"-------------------------------------");
//查询数据库,当前积分(抽奖扣积分流程校验)
Map<String,Object> mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
String credits = String.valueOf(mapuser.get("credits"));
logger.info("抽奖前积分:"+credits);
//扣去1积分
credits = String.valueOf(Integer.valueOf(credits)-1);
Response response =singleLotteryService.doJoin(uid,activityId,activityId,token);
//response.prettyPrint();
String id =MatcherString.getString(response.asString(), "singleLotteryOrderId\":(.*?),", 1);
response = singleLotteryService.getOrderStatus(uid,id,device);
int i = 10;
while ("处理中".equals(response.jsonPath().getString("message")) && i > 0) {
Thread.sleep(500);
response = singleLotteryService.getOrderStatus(uid,id,device);
i--;
}
//根据case选择对应的校验项
switch(caseNum){
case 1:
Assert.assertEquals(response.jsonPath().getString("descrption"),"【自动化】优惠券-普通","校验优惠券标题失败");
Assert.assertEquals(response.jsonPath().getString("lotteryType"), "coupon", "校验奖品类型失败");
Assert.assertEquals(response.jsonPath().getString("showUse"), "true", "校验是否展示马上使用失败");
Assert.assertEquals(response.jsonPath().getString("useBtnText"), "马上使用", "校验按钮文案展示失败");
if ( device.equals("iOS")) {
Assert.assertEquals(response.jsonPath().getString("iosDownloadUrl"), "www.baidu.com", "校验Url失败");
}else{
Assert.assertEquals(response.jsonPath().getString("androidDownloadUrl"),"www.baidu.com","校验Url失败");
}
logger.info("校验链接券码项:openUrl,useBtnText成功");
break;
case 2:
Assert.assertEquals(response.jsonPath().getString("descrption"),"【自动化测试误删】实物奖品","校验实物标题失败");
Assert.assertTrue(response.jsonPath().getString("url").contains("/activity/takePrizeNew?recordId"),"兑换记录页url与实际url不匹配");
Assert.assertEquals(response.jsonPath().getString("lotteryType"), "object", "校验奖品类型失败");
logger.info("校验商家落地项:descrption,url,lotteryType成功");
break;
case 3:
Assert.assertEquals(response.jsonPath().getString("descrption"),"多档位话费充值","校验实物标题失败");
Assert.assertEquals(response.jsonPath().getString("itemId"), "1", "校验实物ID失败");
Assert.assertEquals(response.jsonPath().getString("lotteryType"), "phonebill", "校验奖品类型失败");
Assert.assertTrue(response.jsonPath().getString("url").contains("/activity/takePrizeNew?recordId"),"兑换记录页url与实际url不匹配");
logger.info("校验商家落地项:descrption,itemId,lotteryType,url成功");
break;
case 4:
Assert.assertEquals(response.jsonPath().getString("descrption"),"支付宝充值","校验实物标题失败");
Assert.assertEquals(response.jsonPath().getString("itemId"), "55", "校验实物ID失败");
Assert.assertEquals(response.jsonPath().getString("lotteryType"), "alipay", "校验奖品类型失败");
Assert.assertTrue(response.jsonPath().getString("url").contains("/activity/takePrizeNew?recordId"),"兑换记录页url与实际url不匹配");
logger.info("校验商家落地项:descrption,itemId,lotteryType,url成功");
break;
case 5:
Assert.assertEquals(response.jsonPath().getString("descrption"),"Q币充值","校验实物标题失败");
Assert.assertEquals(response.jsonPath().getString("itemId"), "2", "校验实物ID失败");
Assert.assertEquals(response.jsonPath().getString("lotteryType"), "qb", "校验奖品类型失败");
Assert.assertTrue(response.jsonPath().getString("url").contains("/activity/takePrizeNew?recordId"),"兑换记录页url与实际url不匹配");
logger.info("校验商家落地项:descrption,itemId,lotteryType,url成功");
break;
case 6:
Assert.assertEquals(response.jsonPath().getString("descrption"),"【自动化】自有虚拟商品","校验优惠券标题失败");
Assert.assertEquals(response.jsonPath().getString("lotteryType"), "virtual", "校验奖品类型失败");
Assert.assertTrue(response.jsonPath().getString("url").contains("//activity.m.duibatest.com.cn/crecord/recordDetailNew"),"兑换记录页url与实际url不匹配");
logger.info("校验链接券码项:openUrl,useBtnText成功");
Thread.sleep(2000);
Map<String, Object> selectResult = jdbc.findSimpleResult("select * from orders_consumer.orders_0616 where consumer_id = 100011624 and biz_params = 'DUIBA_SELF' ",null);
//logger.info("selectResult结果为:"+selectResult);
Assert.assertEquals( selectResult.get("biz_params"),"DUIBA_SELF","虚拟商品出奖标识DUIBA_SELF校验失败");
logger.info("数据库存储虚拟商品标记结果为:"+selectResult.get("biz_params"));
break;
}
//通用校验项
Assert.assertEquals(response.jsonPath().getString("message"), "成功", "校验信息失败");
Assert.assertEquals(response.jsonPath().getString("status"), "1", "校验状态失败");
//查询数据库,获取当前积分
Thread.sleep(3000);
mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
String creditsNew = String.valueOf(mapuser.get("credits"));
logger.info("抽奖后积分:"+creditsNew);
//校验比较,抽奖前后积分
Assert.assertEquals(credits,creditsNew);
logger.info("校验领奖前后积分正确");
}
}
\ No newline at end of file
package http.cases.SingleLotteryTest;
import base.DuibaTestBase;
import http.service.Activity.SingleLotteryService;
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.util.Map;
/**
* Created by zhaoran on 2018/6/8.
*/
public class 自有库存不足_AccessTest extends DuibaTestBase {
@Autowired
SingleLotteryService singleLotteryService;
private static DuibaLog logger = DuibaLog.getLogger();
//指定用户
private static int uid = 3927;
@Test
public void 自有单品抽奖库存不足() throws Exception {
//查询数据库,当前积分(抽奖扣积分流程校验)
Map<String,Object> mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
String credits = String.valueOf(mapuser.get("credits"));
logger.info("抽奖前积分:"+credits);
//扣去1积分
credits = String.valueOf(Integer.valueOf(credits)-1);
Response response =singleLotteryService.doJoin(uid,"34541","34541","238wmftdc");
//response.prettyPrint();
String id =MatcherString.getString(response.asString(), "singleLotteryOrderId\":(.*?),", 1);
response = singleLotteryService.getOrderStatus(uid,id,"iOS");
int i = 10;
while ("处理中".equals(response.jsonPath().getString("message")) && i > 0) {
Thread.sleep(500);
response = singleLotteryService.getOrderStatus(uid,id,"iOS");
i--;
}
Assert.assertEquals(response.jsonPath().getString("lotteryType"), "lucky", "校验奖品类型失败");
Assert.assertEquals(response.jsonPath().getString("lottery.showUse"), "true", "校验是否展示马上使用失败");
Assert.assertEquals(response.jsonPath().getString("lottery.useBtnText"), "马上使用", "校验按钮文案展示失败");
//通用校验项
Assert.assertEquals(response.jsonPath().getString("message"), "成功", "校验信息失败");
Assert.assertEquals(response.jsonPath().getString("status"), "1", "校验状态失败");
//查询数据库,获取当前积分
Thread.sleep(3000);
mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
String creditsNew = String.valueOf(mapuser.get("credits"));
logger.info("抽奖后积分:"+creditsNew);
//校验比较,抽奖前后积分
Assert.assertEquals(credits,creditsNew);
logger.info("校验领奖前后积分正确");
}
}
\ No newline at end of file
......@@ -172,7 +172,7 @@ public class ZdyflService {
return response;
}
//自定义分类-活动移出分类
//自定义分类_DuibaTest-活动移出分类
public Response removeClassifyAppItem1(String classifyId,String operatingActivityId) throws Exception {
String url=hdHost+"/devItem/removeClassifyAppItem";
......@@ -191,7 +191,7 @@ public class ZdyflService {
return response;
}
//自定义分类-商品移出分类
//自定义分类_DuibaTest-商品移出分类
public Response removeClassifyAppItem2(String classifyId,String appItemId) throws Exception {
String url=hdHost+"/devItem/removeClassifyAppItem";
......
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