Commit 86a3ba5f authored by 赵然's avatar 赵然

Merge branch 'zr' into develop

parents 06f12af5 4b4bd954
package http.cases.ActivityReconTest;
import base.Config;
import base.DuibaLog;
import http.service.Activity.ActivityReconService;
import http.service.Activity.ManagerService;
import http.service.Activity.NewActivityService;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
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.Iterator;
import java.util.Map;
/**
* Created by zhaoran on 2019/2/21
*/
@ContextConfiguration(classes = Config.class)
public class 优惠券测试 extends AbstractTestNGSpringContextTests {
@Autowired
ActivityReconService activityReconService;
@Autowired
ManagerService managerService;
private static DuibaLog logger = DuibaLog.getLogger();
@DataProvider
public Iterator<Object[]> providerMethod(Method method) throws IOException {
Iterator<Object[]> result = null;
if(method.getName().equals("优惠券测试")) {
result = new ExcelDataProvider("duiba/活动优惠券");
}
return result;
}
@Test(dataProvider = "providerMethod")
public void 优惠券测试(Map<String,String> data) throws Exception {
Thread.sleep(2000);
logger.info("-------------------------------------"+data.get("casename")+"-------------------------------------");
//获取管理员后台优惠券待校验项
Response ManagerResponse = managerService.CouponConfig(data.get("couponId"));
Response LinkResponse = managerService.ShowCoupons(data.get("couponId"));
String acttitle = MatcherString.getString(ManagerResponse.asString(), "name=\"name\" value=\"(.*?)\">", 1);
String androidDL = MatcherString.getString(ManagerResponse.asString(), "androidurl: '(.*?)',", 1);
String iOSDL = MatcherString.getString(ManagerResponse.asString(), "iosurl: '(.*?)',", 1);
String actusebtn = MatcherString.getString(ManagerResponse.asString(), "usebtn: '(.*?)',", 1);
String actLinkEx = "//activity.m.duibatest.com.cn/crecord/recordDetailNew";
String linkUrl = MatcherString.getString(LinkResponse.asString(), "target=\"_blank\" href=\"(.*?)\">", 1);
//获取管理员后台优惠券库存
String remind = MatcherString.getString(LinkResponse.asString(), "option remain=\"(.*?)\"", 1);
logger.info("抽奖前当前库存:"+remind);
//扣去1库存
remind = String.valueOf(Integer.valueOf(remind)-1);
//进行接口测试传参
Response response = this.新活动工具接口传参(data.get("activityId"),data.get("token"),data.get("device"));
// response.prettyPrint();
//根据case选择对应的校验项
int casenum = Integer.parseInt(data.get("casenum"));
switch(casenum){
case 1:
Assert.assertEquals(response.jsonPath().getString("data.lottery.iosDownloadUrl"),linkUrl,"校验Url失败");
Assert.assertEquals(response.jsonPath().getString("data.lottery.useBtnText"),actusebtn,"校验useBtnText失败");
logger.info("校验链接券码项:openUrl,useBtnText成功");
break;
case 2:
if ( data.get("device").equals("iOS")) {
Assert.assertEquals(response.jsonPath().getString("data.lottery.iosDownloadUrl"), iOSDL, "校验Url失败");
}else{
Assert.assertEquals(response.jsonPath().getString("data.lottery.androidDownloadUrl"),androidDL,"校验Url失败");
}
Assert.assertEquals(response.jsonPath().getString("data.lottery.useBtnText"),actusebtn,"校验useBtnText失败");
logger.info("校验商家落地项:openUrl,useBtnText成功");
break;
case 3:
Assert.assertTrue(response.jsonPath().getString("data.lottery.iosDownloadUrl").contains(actLinkEx),"兑换记录页url与实际url不匹配");
Assert.assertEquals(response.jsonPath().getString("data.lottery.useBtnText"),"查看使用方法","校验useBtnText失败");
logger.info("校验兑换记录项:openUrl,useBtnText成功");
break;
}
//通用校验项
Assert.assertEquals(response.jsonPath().getString("data.lottery.title"),acttitle,"校验title失败");
logger.info("校验通用项:title成功");
//获取管理员后台优惠券库存
Thread.sleep(5000);
Response LinkResponse2 = managerService.ShowCoupons(data.get("couponId"));
String Newremind = MatcherString.getString(LinkResponse2.asString(), "option remain=\"(.*?)\"", 1);
logger.info("抽奖后当前库存:"+Newremind);
//校验比较,抽奖前后优惠券库存
Assert.assertEquals(Newremind,remind);
logger.info("校验抽奖前后库存正确");
}
public Response 新活动工具接口传参(String activityId,String token,String device) throws Exception {
Response response = activityReconService.doJoin2(activityId,token);
response.prettyPrint();
String orderId = response.jsonPath().getString("data");
response = activityReconService.getOrderStatus2(orderId,device);
response.prettyPrint();
String result = String.valueOf(response.jsonPath().getString("code"));
int i= 30;
while(i>0&&(result.equals("C000000001"))){
Thread.sleep(1000);
response = activityReconService.getOrderStatus2(orderId,device);
result = String.valueOf(response.jsonPath().getString("code"));
i--;
response.prettyPrint();
}
return response;
}
}
\ No newline at end of file
package http.cases.ActivityReconTest;
import base.DuibaLog;
import base.DuibaTestBase;
import http.service.Activity.ActivityReconService;
import http.service.Activity.ManagerService;
import http.service.Activity.NewActivityService;
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/9/21
*/
public class 全局红包账户 extends DuibaTestBase {
@Autowired
ActivityReconService activityReconService;
@Autowired
ManagerService managerService;
private static DuibaLog logger = DuibaLog.getLogger();
@Test
public void 全局红包测试() throws Exception {
Map<String, Object> selectResult = jdbc.findSimpleResult("select * from consumer_accounts.tb_consumer_account_0687 where account_id = '100025007_0_0' ");
int balance = Integer.parseInt(String.valueOf(selectResult.get("balance_amount")));
logger.info("账户原有余额为"+balance);
//进行接口测试传参
Response response = this.新活动工具接口传参("32696","7ywbta5","iOS");
// response.prettyPrint();
Assert.assertEquals(response.jsonPath().getString("data.lottery.bonusMax"),"50","校验红包最大值失败");
Assert.assertEquals(response.jsonPath().getString("data.lottery.bonusMin"),"10","校验红包最小值失败");
int bonus = Integer.parseInt(response.jsonPath().getString("data.lottery.bonus"));
logger.info("中奖金额为"+bonus);
balance = balance + bonus;
logger.info("预期余额为"+balance);
selectResult = jdbc.findSimpleResult("select * from consumer_accounts.tb_consumer_account_0687 where account_id = '100025007_0_0' ");
int balanceNew = Integer.parseInt(String.valueOf(selectResult.get("balance_amount")));
logger.info("实际余额为"+balanceNew);
Assert.assertEquals(balanceNew,balance,"全局红包增加账户余额失败");
}
public Response 新活动工具接口传参(String activityId,String token,String device) throws Exception {
Response response = activityReconService.doJoin2(activityId,token);
response.prettyPrint();
String orderId = response.jsonPath().getString("data");
response = activityReconService.getOrderStatus2(orderId,device);
response.prettyPrint();
String result = String.valueOf(response.jsonPath().getString("code"));
int i= 30;
while(i>0&&(result.equals("C000000001"))){
Thread.sleep(1000);
response = activityReconService.getOrderStatus2(orderId,device);
result = String.valueOf(response.jsonPath().getString("code"));
i--;
response.prettyPrint();
}
return response;
}
}
\ No newline at end of file
package http.cases.ActivityReconTest;
import base.Config;
import base.DuibaLog;
import base.DuibaTestBase;
import http.service.Activity.ActivityReconService;
import http.service.Activity.ManagerService;
import http.service.Activity.NewActivityService;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.testng.Assert;
import org.testng.annotations.Test;
import utils.MatcherString;
import java.util.Map;
/**
* @author zhaoran
* @create 2018/1/2
* @since 1.0.0
*/
@ContextConfiguration(classes = Config.class)
public class 出奖订单测试 extends DuibaTestBase {
@Autowired
ActivityReconService activityReconService;
@Autowired
ManagerService managerService;
private static DuibaLog logger = DuibaLog.getLogger();
@Test(description = "开发者虚拟商品接口设置为不通状态,充值不会成功")
public void 出奖虚拟订单校验() throws Exception {
//获取库存
String remind= this.getremind_db("27508");
//扣去1库存
remind = String.valueOf(Integer.valueOf(remind)-1);
//进行接口测试传参
Response response = activityReconService.doJoin2("21079","asdasd");
response.prettyPrint();
String orderId = response.jsonPath().getString("data");
response = activityReconService.getOrderStatus2(orderId,"iOS");
response.prettyPrint();
String result = String.valueOf(response.jsonPath().getString("code"));
int i= 30;
while(i>0&&(result.equals("C000000001"))){
Thread.sleep(1000);
response = activityReconService.getOrderStatus2(orderId,"iOS");
result = String.valueOf(response.jsonPath().getString("code"));
i--;
response.prettyPrint();
}
Assert.assertTrue(response.jsonPath().getString("data.lottery.link").contains("/activity/takePrizeNew?"),"校验link失败");
Assert.assertEquals(response.jsonPath().getString("data.lottery.type"),"virtual","校验useBtnText失败");
Assert.assertEquals(response.jsonPath().getString("success"),"true","校验success失败");
logger.info("校验链接券码项:link,type,success");
Thread.sleep(2000);
Map<String, Object> selectResult = jdbc.findSimpleResult("select * from credits_hdtool.hdtool_orders_0687 where id = '"+orderId+"'");
logger.info("主订单为:"+selectResult.get("main_order_num"));
String main_orderId = String.valueOf(selectResult.get("main_order_num"));
Map<String, Object> selectResult2 = jdbc.findSimpleResult("select * from orders_consumer.orders_0687 where order_num = '"+main_orderId+"' ");
//logger.info("selectResult结果为:"+selectResult);
Assert.assertEquals( selectResult2.get("biz_params"),"DUIBA_TEST","虚拟商品出奖标识DUIBA_TEST校验失败");
logger.info("数据库存储虚拟商品标记结果为:"+selectResult2.get("biz_params"));
String flowWork = String.valueOf(selectResult2.get("flowwork_stage"));
int j =10;
while (j > 0 && !flowWork.equals("Success-complete")) {
Thread.sleep(1000);
selectResult2 = jdbc.findSimpleResult("select * from orders_consumer.orders_0687 where order_num = '"+main_orderId+"' ");
flowWork = String.valueOf(selectResult2.get("flowwork_stage"));
logger.info("数据库订单节点:" + flowWork);
j--;
}
// Assert.assertEquals(selectResult2.get("error4developer"),"上游充值异常","报错信息校验失败");
Assert.assertEquals(flowWork,"Success-complete","数据库主订单流程节点校验失败");
//校验库存
String Newremind= this.getremind_db("27508");
Assert.assertEquals(Newremind,remind);
logger.info("校验抽奖前后库存正确");
}
@Test
public void 出奖优惠券订单校验() throws Exception {
Response response = activityReconService.doJoin2("31711","asdasd");
response.prettyPrint();
String orderId = response.jsonPath().getString("data");
response = activityReconService.getOrderStatus2(orderId,"iOS");
response.prettyPrint();
String result = String.valueOf(response.jsonPath().getString("code"));
int i= 30;
while(i>0&&(result.equals("C000000001"))){
Thread.sleep(1000);
response = activityReconService.getOrderStatus2(orderId,"iOS");
result = String.valueOf(response.jsonPath().getString("code"));
i--;
response.prettyPrint();
}
Map<String, Object> selectResult = jdbc.findSimpleResult("select * from credits_hdtool.hdtool_orders_0687 where id = '"+orderId+"' ",null);
logger.info("主订单为:"+selectResult.get("main_order_num"));
String main_orderId = String.valueOf(selectResult.get("main_order_num"));
Map<String, Object> selectResult2 = jdbc.findSimpleResult("select * from orders_consumer.orders_0687 where order_num = '"+main_orderId+"' ");
logger.info("数据库订单节点:"+selectResult2.get("flowwork_stage"));
String flowWork = String.valueOf(selectResult2.get("flowwork_stage"));
int j =10;
while (j > 0 && !flowWork.equals("Success-complete")) {
Thread.sleep(300);
selectResult2 = jdbc.findSimpleResult("select * from orders_consumer.orders_0687 where order_num = '"+main_orderId+"' ");
flowWork = String.valueOf(selectResult2.get("flowwork_stage"));
logger.info("数据库订单节点:" + flowWork);
j--;
}
Assert.assertEquals(flowWork,"Success-complete","数据库主订单流程节点校验失败");
Assert.assertEquals(String.valueOf(selectResult2.get("item_id")),"31135","数据库主订单奖项id校验失败");
}
@Test
public void 出奖实物订单校验() throws Exception {
Response response = activityReconService.doJoin2("31713","asdasd");
response.prettyPrint();
String orderId = response.jsonPath().getString("data");
// logger.info("orderId=" + orderId );
response = activityReconService.getOrderStatus2(orderId,"iOS");
response.prettyPrint();
String result = String.valueOf(response.jsonPath().getString("code"));
int i= 30;
while(i>0&&(result.equals("C000000001"))){
Thread.sleep(1000);
response = activityReconService.getOrderStatus2(orderId,"iOS");
result = String.valueOf(response.jsonPath().getString("code"));
i--;
response.prettyPrint();
}
String type = String.valueOf(response.jsonPath().getString("data.lottery.type"));
//领奖操作
String recordId = MatcherString.getString(response.asString(), "recordId=(.*?)&", 1);
response = activityReconService.doTakePrize(2720,type, recordId);
Assert.assertEquals(response.jsonPath().getString("message"), "领奖成功");
logger.info("结果:" + type + "领奖流程成功");
Map<String, Object> selectResult = jdbc.findSimpleResult("select * from credits_hdtool.hdtool_orders_0687 where id = '"+orderId+"'");
String main_orderId = String.valueOf(selectResult.get("main_order_num"));
logger.info("主订单为:"+main_orderId);
Map<String, Object> selectResult2 = jdbc.findSimpleResult("select * from orders_consumer.orders_0687 where order_num = '"+main_orderId+"' ");
String flowWork = String.valueOf(selectResult2.get("flowwork_stage"));
logger.info("领奖后数据库订单节点:"+flowWork);
int j =10;
while (j > 0 && !flowWork.equals("SupplierExchange-started")) {
Thread.sleep(300);
selectResult2 = jdbc.findSimpleResult("select * from orders_consumer.orders_0687 where order_num = '"+main_orderId+"' ");
flowWork = String.valueOf(selectResult2.get("flowwork_stage"));
logger.info("领奖后数据库订单节点:" + flowWork);
j--;
}
Assert.assertEquals(flowWork,"SupplierExchange-started","数据库主订单流程节点校验失败");
Assert.assertEquals(String.valueOf(selectResult2.get("item_id")),"27131","数据库主订单奖项id校验失败");
Assert.assertEquals(String.valueOf(selectResult2.get("biz_params")),"胡梦新:18258853242:浙江省:杭州市:西湖区:西溪街道:数娱大厦 ","数据库主订单biz_params校验失败");
Assert.assertEquals(String.valueOf(selectResult2.get("pay_status")),"prereduce","数据库主订单pay_status校验失败");
Assert.assertEquals(String.valueOf(selectResult2.get("status")),"consume_success","数据库主订单status校验失败");
Map<String, Object> selectResult3 = jdbc.findSimpleResult("select * from credits_hdtool.hdtool_orders_0687 where id = '"+orderId+"'");
String orderId_send = String.valueOf(selectResult3.get("main_order_id"));
logger.info("发货订单为:"+orderId_send);
//发货操作
managerService.expressSend(orderId_send);
logger.info("实物发货订单成功");
selectResult3 = jdbc.findSimpleResult("select * from orders_consumer.orders_0687 where order_num = '"+main_orderId+"'");
String flowWork2 = String.valueOf(selectResult3.get("flowwork_stage"));
logger.info("发货后数据库订单节点:"+flowWork2);
int k =10;
while (k > 0 && !flowWork2.equals("Success-complete")) {
Thread.sleep(1000);
selectResult3 = jdbc.findSimpleResult("select * from orders_consumer.orders_0687 where order_num = '"+main_orderId+"' ");
flowWork2 = String.valueOf(selectResult3.get("flowwork_stage"));
logger.info("发货后数据库订单节点:" + flowWork2);
k--;
}
Assert.assertEquals(String.valueOf(selectResult3.get("pay_status")),"successs","数据库主订单pay_status校验失败");
Assert.assertEquals(String.valueOf(selectResult3.get("status")),"success","数据库主订单status校验失败");
}
public String getremind_db(String gid) throws Exception{
Thread.sleep(1000);
Map map = jdbc.findSimpleResult("select * from goods.item where id = "+gid);
String stock_id = String.valueOf(map.get("stock_id"));
Map map2 = jdbc.findSimpleResult("select * from stock.tb_stock where stock_id = "+stock_id);
String stock = String.valueOf(map2.get("stock"));
return stock;
}
}
\ No newline at end of file
package http.cases.ActivityReconTest;
import base.DuibaTestBase;
import http.service.Activity.ActivityReconService;
import http.service.Activity.ManagerService;
import http.service.Activity.NewActivityService;
import http.service.hd.ActivityService;
import http.service.hd.CustomHdToolCtrlService;
import http.service.hd.DeveloperService;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.Test;
import utils.RedisUtil;
/**
* Created by zhaoran on 2018/07/10
*/
public class 多奖项中奖限制 extends DuibaTestBase {
@Autowired
ActivityReconService activityReconService;
@Autowired
ManagerService managerService;
@Autowired
DeveloperService developerService;
@Autowired
CustomHdToolCtrlService customHdToolCtrlService;
@Autowired
ActivityService activityService;
@AfterClass
public void after() throws Exception{
//数据库删除
try {
//case:[多奖项中奖限制测试_永久]数据处理:删除永久中奖记录
jdbc.update("UPDATE ckvtable.tb_kvtable_0687 SET int_value = '0' WHERE vkey = 'activity-centerwinOptionNum_100025007_35869_hdtool25885'");
//case:[多奖项中奖限制测试_每日]数据处理:删除每日中奖记录
RedisUtil.clearKey("PRIZE_K004_35934_100025007");
} catch (Exception e) {
System.out.println(e);
}
}
@Test
public void 多奖项中奖限制测试_永久() throws Exception {
//第一次抽奖
Response response = this.新活动工具接口传参("35869","adsdas","iOS");
Assert.assertEquals( String.valueOf(response.jsonPath().getString("data.lottery.type")),"phonebill","第一次抽奖出奖类型失败");
Assert.assertEquals( String.valueOf(response.jsonPath().getString("data.lottery.title")),"话费","第一次抽奖出奖title失败");
//第二次抽奖
response = this.新活动工具接口传参("35869","adsdas","iOS");
Assert.assertEquals( String.valueOf(response.jsonPath().getString("data.lottery.type")),"lucky","第二次抽奖出奖类型失败");
Assert.assertEquals( String.valueOf(response.jsonPath().getString("data.lottery.useBtnText")),"马上使用","第二次抽奖出奖文案失败");
}
@Test
public void 多奖项中奖限制测试_每日() throws Exception {
//第一次抽奖
Response response = this.新活动工具接口传参("35934","adsdas","iOS");
Assert.assertEquals( String.valueOf(response.jsonPath().getString("data.lottery.type")),"phonebill","第一次抽奖出奖类型失败");
Assert.assertEquals( String.valueOf(response.jsonPath().getString("data.lottery.title")),"话费","第一次抽奖出奖title失败");
//第二次抽奖
response = this.新活动工具接口传参("35934","adsdas","iOS");
Assert.assertEquals( String.valueOf(response.jsonPath().getString("data.lottery.type")),"lucky","第二次抽奖出奖类型失败");
Assert.assertEquals( String.valueOf(response.jsonPath().getString("data.lottery.useBtnText")),"马上使用","第二次抽奖出奖文案失败");
}
public Response 新活动工具接口传参(String activityId,String token,String device) throws Exception {
Response response = activityReconService.doJoin2(activityId,token);
response.prettyPrint();
String orderId = response.jsonPath().getString("data");
response = activityReconService.getOrderStatus2(orderId,device);
response.prettyPrint();
String result = String.valueOf(response.jsonPath().getString("code"));
int i= 8;
while(i>0&&(result.equals("0"))){
Thread.sleep(1000);
response = activityReconService.getOrderStatus2(orderId,device);
result = String.valueOf(response.jsonPath().getString("code"));
i--;
response.prettyPrint();
}
return response;
}
}
\ No newline at end of file
package http.cases.ActivityReconTest;
import base.DuibaLog;
import base.DuibaTestBase;
import http.service.Activity.ActivityReconService;
import http.service.Activity.ManagerService;
import http.service.Activity.NewActivityService;
import http.service.hd.ActivityService;
import http.service.hd.CustomHdToolCtrlService;
import http.service.hd.DeveloperService;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.Test;
import utils.HbaseService;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
/**
* Created by zhaoran on 2018/07/10
*/
public class 奖品发放限制 extends DuibaTestBase {
@Autowired
ActivityReconService activityReconService;
@Autowired
ManagerService managerService;
@Autowired
DeveloperService developerService;
@Autowired
CustomHdToolCtrlService customHdToolCtrlService;
@Autowired
ActivityService activityService;
@Autowired
HbaseService hbaseService;
private static DuibaLog logger = DuibaLog.getLogger();
@AfterClass
public void after() throws Exception{
//数据库删除
try {
//case:[奖品发放限制测试_永久]数据处理:删除永久中奖记录
jdbc.update("UPDATE ckvtable.tb_kvtable_0687 SET int_value = '0' WHERE vkey = 'activity-centerwinOptionNum_100025007_35868_hdtool25884'");
//case:[奖品发放限制测试_每日]数据处理:删除每日中奖记录
String y_m_d = getTime2(0);
String key = "k05_PRIZE_K001_"+y_m_d+"_hdtool25933_100025007";
hbaseService.deleteHBASEKey2(key);
} catch (Exception e) {
System.out.println(e);
}
}
@Test
public void 奖品发放限制测试_永久() throws Exception {
//第一次抽奖
Response response = this.新活动工具接口传参("35868","adsdas","iOS");
Assert.assertEquals( String.valueOf(response.jsonPath().getString("data.lottery.type")),"phonebill","第一次抽奖出奖类型失败");
Assert.assertEquals( String.valueOf(response.jsonPath().getString("data.lottery.title")),"话费","第一次抽奖出奖title失败");
//第二次抽奖
response = this.新活动工具接口传参("35868","adsdas","iOS");
Assert.assertEquals( String.valueOf(response.jsonPath().getString("data.lottery.type")),"lucky","第一次抽奖出奖类型失败");
Assert.assertEquals( String.valueOf(response.jsonPath().getString("data.lottery.useBtnText")),"马上使用","第一次抽奖出奖文案失败");
}
@Test
public void 奖品发放限制测试_每日() throws Exception {
//第一次抽奖
Response response = this.新活动工具接口传参("35920","adsdas","iOS");
Assert.assertEquals( String.valueOf(response.jsonPath().getString("data.lottery.type")),"phonebill","第一次抽奖出奖类型失败,请考虑是否activity-access-web发布了master分支所导致");
Assert.assertEquals( String.valueOf(response.jsonPath().getString("data.lottery.title")),"话费","第一次抽奖出奖title失败");
//第二次抽奖
response = this.新活动工具接口传参("35920","adsdas","iOS");
Assert.assertEquals( String.valueOf(response.jsonPath().getString("data.lottery.type")),"lucky","第一次抽奖出奖类型失败");
Assert.assertEquals( String.valueOf(response.jsonPath().getString("data.lottery.useBtnText")),"马上使用","第一次抽奖出奖文案失败");
}
public Response 新活动工具接口传参(String activityId,String token,String device) throws Exception {
Response response = activityReconService.doJoin2(activityId,token);
response.prettyPrint();
String orderId = response.jsonPath().getString("data");
response = activityReconService.getOrderStatus2(orderId,device);
response.prettyPrint();
String result = String.valueOf(response.jsonPath().getString("code"));
int i= 30;
while(i>0&&(result.equals("C000000001"))){
Thread.sleep(1000);
response = activityReconService.getOrderStatus2(orderId,device);
result = String.valueOf(response.jsonPath().getString("code"));
i--;
response.prettyPrint();
}
return response;
}
public String getTime2(int amount){
SimpleDateFormat dateFormat = new SimpleDateFormat("YYYY-MM-dd", Locale.ENGLISH);
Date date = new Date();
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.DAY_OF_MONTH, amount);
date = calendar.getTime();
// System.out.println(dateFormat.format(date));
String time = dateFormat.format(date);
// System.out.println(time);
return time;
}
}
\ No newline at end of file
package http.cases.ActivityReconTest;
import base.DuibaLog;
import base.DuibaTestBase;
import http.service.Activity.ActivityReconService;
import http.service.Activity.ManagerService;
import http.service.Activity.NewActivityService;
import http.service.hd.DeveloperService;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
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.Iterator;
import java.util.Map;
/**
* Created by zhaoran on 2018/1/2
*/
public class 扣库存测试 extends DuibaTestBase {
@Autowired
ActivityReconService activityReconService;
@Autowired
ManagerService managerService;
@Autowired
DeveloperService developerService;
private static DuibaLog logger = DuibaLog.getLogger();
@DataProvider
public Iterator<Object[]> providerMethod(Method method) throws IOException {
Iterator<Object[]> result = null;
if(method.getName().equals("活动工具扣库存测试")) {
result = new ExcelDataProvider("duiba/扣库存测试");
}
return result;
}
@Test(dataProvider = "providerMethod",description = "历史活动扣库存逻辑,无stock_id")
public void 活动工具扣库存测试(Map<String,String> data) throws Exception {
logger.info("-------------------------------------"+data.get("casename")+"-------------------------------------");
//获取兑换项库存
String remind= this.getremind_db(data.get("gid"));
//扣去1库存
remind = String.valueOf(Integer.valueOf(remind)-1);
//获取奖项库存
Map map = jdbc.findSimpleResult("select * from credits_activity.act_pre_stock where relation_type = 'hdtool' and relation_config_id = "+data.get("actId"));
String db_quantity = String.valueOf(map.get("prize_quantity"));
//扣去1库存
db_quantity = String.valueOf(Integer.valueOf(db_quantity)-1);
Response response = this.新活动工具接口传参(data.get("activityId"),data.get("token"),"iOS");
String type = String.valueOf(response.jsonPath().getString("data.lottery.type"));
if (type.equals("virtual")){
Assert.assertTrue(response.jsonPath().getString("data.lottery.link").contains("/activity/takePrizeNew?recordId="));
Assert.assertEquals(response.jsonPath().getString("data.lottery.id"), "11612", "校验id失败");
logger.info("校验虚拟商品:link,id成功");
}
if (type.equals("collectGoods")){
Assert.assertEquals(response.jsonPath().getString("data.lottery.itemId"), "27133", "校验itemId失败");
Assert.assertEquals(response.jsonPath().getString("data.lottery.id"), "11614", "校验id失败");
logger.info("校验集卡商品:link,id成功");
}
if (type.equals("object")){
Assert.assertEquals(response.jsonPath().getString("data.lottery.title"),"实物奖品","校验title失败");
Assert.assertTrue(response.jsonPath().getString("data.lottery.link").contains("/activity/takePrizeNew?recordId="));
Assert.assertEquals(response.jsonPath().getString("data.lottery.id"), "11604", "校验id失败");
logger.info("校验实物商品:link,id成功");
}
//校验兑换项库存
String Newremind= this.getremind_db(data.get("gid"));
Assert.assertEquals(Newremind,remind);
logger.info("校验抽奖前后兑换项库存正确");
//获取页面奖项库存库存
response = managerService.getDataEditConfig(data.get("actId"));
String showRemind = response.jsonPath().getString("awards[1].remaind");
logger.info("校验后页面展示库存为:"+showRemind);
//校验奖项库存
Assert.assertEquals(showRemind,db_quantity);
logger.info("校验抽奖前后奖项库存正确");
}
//@Test
public void 闯关活动扣库存测试() throws Exception {
//获取兑换项库存
String remind= this.getremind_db("27000");
//扣去1库存
remind = String.valueOf(Integer.valueOf(remind)-1);
//获取奖项库存
String db_quantity = this.getremind_pre("7116","0");
//扣去1库存
db_quantity = String.valueOf(Integer.valueOf(db_quantity)-1);
Response response = activityReconService.doJoin2("28050","abcde");
response.prettyPrint();
String orderId = response.jsonPath().getString("orderId");
response.prettyPrint();
response = activityReconService.throughSubmit(orderId);
orderId = response.jsonPath().getString("orderId");
response = activityReconService.getOrderStatus2(orderId,"iOS");
response.prettyPrint();
String result = String.valueOf(response.jsonPath().getString("result"));
int i= 30;
while(i>0&&(result.equals("0"))){
Thread.sleep(1000);
response = activityReconService.getOrderStatus2(orderId,"iOS");
result = String.valueOf(response.jsonPath().getString("result"));
i--;
response.prettyPrint();
}
String type = String.valueOf(response.jsonPath().getString("lottery.type"));
Assert.assertEquals(type,"object","校验type失败");
Assert.assertEquals(response.jsonPath().getString("lottery.title"),"自动化实物","校验title失败");
Assert.assertTrue(response.jsonPath().getString("lottery.link").contains("/activity/takePrizeNew?recordId="));
Assert.assertEquals(response.jsonPath().getString("lottery.id"), "19338", "校验id失败");
logger.info("校验实物商品:title,link,id成功");
//校验兑换项库存
String Newremind= this.getremind_db("27000");
Assert.assertEquals(Newremind,remind);
logger.info("校验抽奖前后兑换项库存正确");
//获取页面奖项库存库存
response = managerService.edit("7116");
String showRemind = response.jsonPath().getString("data.awards[1].remaind");
logger.info("校验后页面展示库存为:"+showRemind);
//校验奖项库存
Assert.assertEquals(showRemind,db_quantity);
logger.info("校验抽奖前后奖项库存正确");
}
@Test
public void 自定义活动扣库存测试() throws Exception {
//获取兑换项库存
String remind= this.getremind_db("27000");
//扣去1库存
remind = String.valueOf(Integer.valueOf(remind)-1);
//获取奖项库存
String db_quantity = this.getremind_pre("8788","0");
//扣去1库存
db_quantity = String.valueOf(Integer.valueOf(db_quantity)-1);
Response response = this.新活动工具接口传参("31116","abcde","iOS");
String type = String.valueOf(response.jsonPath().getString("data.lottery.type"));
Assert.assertEquals(type,"object","校验type失败");
Assert.assertEquals(response.jsonPath().getString("data.lottery.title"),"测试实物","校验title失败");
Assert.assertTrue(response.jsonPath().getString("data.lottery.link").contains("/activity/takePrizeNew?recordId="));
Assert.assertEquals(response.jsonPath().getString("data.lottery.id"), "21780", "校验id失败");
logger.info("校验实物商品:title,link,id成功");
//校验兑换项库存
String Newremind= this.getremind_db("27000");
Assert.assertEquals(Newremind,remind);
logger.info("校验抽奖前后兑换项库存正确");
//获取页面奖项库存库存
response = managerService.edit("8788");
String showRemind = response.jsonPath().getString("data.awards[1].remaind");
logger.info("校验后页面展示库存为:"+showRemind);
//校验奖项库存
Assert.assertEquals(showRemind,db_quantity);
logger.info("校验抽奖前后奖项库存正确");
}
@Test
public void 预分配扣库存测试() throws Exception {
//获取兑换项库存
String remind= this.getremind_db("27000");
//扣去1库存
remind = String.valueOf(Integer.valueOf(remind)-1);
//获取奖项库存
String db_quantity_org = this.getremind_pre("8789","0");
//获取预分配库存
String db_quantity_allo = this.getremind_pre("8789","2239");
//预分配扣去1库存(预期值)
db_quantity_allo = String.valueOf(Integer.valueOf(db_quantity_allo)-1);
Response response = this.新活动工具接口传参("31117","abcde","iOS");
String type = String.valueOf(response.jsonPath().getString("data.lottery.type"));
Assert.assertEquals(type,"object","校验type失败");
Assert.assertEquals(response.jsonPath().getString("data.lottery.title"),"测试实物","校验title失败");
Assert.assertTrue(response.jsonPath().getString("data.lottery.link").contains("/activity/takePrizeNew?recordId="));
Assert.assertEquals(response.jsonPath().getString("data.lottery.id"), "21782", "校验id失败");
logger.info("校验实物商品:title,link,id成功");
//校验兑换项库存
String Newremind= this.getremind_db("27000");
Assert.assertEquals(Newremind,remind);
logger.info("校验抽奖前后兑换项库存正确");
//校验奖项库存
String db_quantity_org_later = this.getremind_pre("8789","0");
Assert.assertEquals(db_quantity_org_later,db_quantity_org,"校验抽奖前后校验奖项库存失败");
logger.info("校验抽奖前后奖项项库存正确");
//校验预分配库存
String db_quantity_allo_later = this.getremind_pre("8789","2239");
Assert.assertEquals(db_quantity_allo_later,db_quantity_allo,"校验抽奖前后校验奖项库存失败");
logger.info("校验抽奖前后预分配库存正确");
}
@Test
public void 自有活动工具扣库存测试() throws Exception {
//获取兑换项库存
Response response = developerService.appItems("2239","【自动化勿动】自有优惠券");
//response.prettyPrint();
String remind = response.jsonPath().getString("data.list[0].remaind");
logger.info("抽奖前兑换项库存为:"+remind);
//扣去1库存
remind = String.valueOf(Integer.valueOf(remind)-1);
//获取奖项库存
Map map = jdbc.findSimpleResult("select * from credits_dev.operating_activity_options where id = 16405");
String db_quantity = String.valueOf(map.get("remaining"));
logger.info("抽奖前奖项库存为:"+db_quantity);
//扣去1库存
db_quantity = String.valueOf(Integer.valueOf(db_quantity)-1);
response = this.新活动工具接口传参("28247","abcde","iOS");
Assert.assertEquals(response.jsonPath().getString("data.lottery.type"),"coupon","校验type失败");
Assert.assertEquals(response.jsonPath().getString("data.lottery.title"),"【自动化勿动】自有优惠券","校验title失败");
Assert.assertTrue(response.jsonPath().getString("data.lottery.link").contains("/crecord/recordDetailNew?orderId="));
Assert.assertEquals(response.jsonPath().getString("data.lottery.id"), "16405", "校验id失败");
logger.info("校验实物商品:type,title,link,id成功");
//校验兑换项库存
response = developerService.appItems("2239","【自动化勿动】自有优惠券");
String Newremind = response.jsonPath().getString("data.list[0].remaind");
int i= 10;
while(i>0 && !Newremind.equals(remind)){
Thread.sleep(500);
response = developerService.appItems("2239","【自动化勿动】自有优惠券");
Newremind = response.jsonPath().getString("data.list[0].remaind");
i--;
}
logger.info("抽奖后兑换项库存为:"+Newremind);
Assert.assertEquals(Newremind,remind);
logger.info("校验抽奖前后兑换项库存正确");
//获取页面奖项库存库存
// response = developerService.appItems("2239","【自动化勿动】自有优惠券");
// String showRemind = response.jsonPath().getString("awards[1].remaind");
// logger.info("校验后页面展示库存为:"+showRemind);
//获取奖项库存
map = jdbc.findSimpleResult("select * from credits_dev.operating_activity_options where id = 16405");
String db_quantity_new = String.valueOf(map.get("remaining"));
logger.info("抽奖后奖项库存为:"+db_quantity_new);
//校验奖项库存
Assert.assertEquals(db_quantity_new,db_quantity);
logger.info("校验抽奖前后奖项库存正确");
}
public Response 新活动工具接口传参(String activityId,String token,String device) throws Exception {
Response response = activityReconService.doJoin2(activityId,token);
response.prettyPrint();
String orderId = response.jsonPath().getString("data");
response = activityReconService.getOrderStatus2(orderId,device);
response.prettyPrint();
String result = String.valueOf(response.jsonPath().getString("code"));
int i= 30;
while(i>0&&(result.equals("C000000001"))){
Thread.sleep(1000);
response = activityReconService.getOrderStatus2(orderId,device);
result = String.valueOf(response.jsonPath().getString("code"));
i--;
response.prettyPrint();
}
return response;
}
public String getremind(String gid) throws Exception{
Thread.sleep(1000);
Response ManagerResponse = managerService.CouponConfig(gid);
ManagerResponse.prettyPrint();
String remind = MatcherString.getString(ManagerResponse.asString(), "remaining\" value=\"(.*?)\"", 1);
logger.info("当前库存:"+remind);
return remind;
}
public String getremind_db(String gid) throws Exception{
Thread.sleep(1000);
Map map = jdbc.findSimpleResult("select * from goods.item where id = "+gid);
String stock_id = String.valueOf(map.get("stock_id"));
Map map2 = jdbc.findSimpleResult("select * from stock.tb_stock where stock_id = "+stock_id);
String stock = String.valueOf(map2.get("stock"));
return stock;
}
public String getremind_pre(String actId,String appId) throws Exception{
Thread.sleep(1000);
Map map = jdbc.findSimpleResult("select * from credits_activity.act_pre_stock where relation_config_id = "+actId+" and app_id = "+appId+"");
String stock_id = String.valueOf(map.get("stock_id"));
Map map2 = jdbc.findSimpleResult("select * from stock.tb_stock where stock_id = "+stock_id);
String db_quantity = String.valueOf(map2.get("stock"));
return db_quantity;
}
}
\ No newline at end of file
package http.cases.ActivityReconTest;
import base.DuibaLog;
import base.DuibaTestBase;
import base.MysqlUtils;
import http.service.Activity.ActivityReconService;
import http.service.Activity.ManagerService;
import http.service.Activity.NewActivityService;
import http.service.Authorization;
import http.service.hd.DeveloperService;
import http.service.hd.SigninService;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
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;
/**
* Created by zhaoran on 2018/1/2
*/
public class 抽奖异常测试 extends DuibaTestBase {
@Autowired
ActivityReconService activityReconService;
@Autowired
ManagerService managerService;
@Autowired
SigninService signinService;
@Autowired
Authorization authorization;
@Autowired
DeveloperService developerService;
private static DuibaLog logger = DuibaLog.getLogger();
private MysqlUtils jdbc;
private String url = "http://activity.m.duibatest.com.cn";
@DataProvider
public Iterator<Object[]> providerMethod(Method method) throws IOException {
Iterator<Object[]> result = null;
if(method.getName().equals("限制抽奖测试")) {
result = new ExcelDataProvider("duiba/限制抽奖数据");
}else
if(method.getName().equals("未登录抽奖测试")) {
result = new ExcelDataProvider("duiba/未登录抽奖数据");
}else
if(method.getName().equals("中奖限制测试")) {
result = new ExcelDataProvider("duiba/中奖限制数据");
}
return result;
}
// @DataProvider
// public Object[][] providerData(Method method){
// Object[][] result = null;
// if(method.getName().equals("活动黑名单测试")) {
// result = new Object[][]{
// new Object[]{"18900","3026", "true"},
// new Object[]{"18900","3026", "false"},};
// }
// return result;
// }
@Test
public void 活动关闭测试() throws Exception {
//关闭活动
Response HdResponse = developerService.closeActivity("18583","2239");
//打开活动界面
Response response = activityReconService.index("18583");
//判断结果
Assert.assertEquals(MatcherString.getString(response.asString(),"<title>(.*?)</title>\n",1),"活动结束","活动页打开异常!");
logger.info("活动状态关闭后的抽奖验证成功");
//打开活动
HdResponse = developerService.openActivity("18583","2239");
}
@Test
public void 扣积分失败测试() throws Exception {
managerService.index();
try {
//修改活动扣积分模板 consumeTemplateId: 1-扣积分成功;2-扣积分失败
Response HdResponse = managerService.doEdit2("2");
//进行接口测试传参
Response response = this.新活动工具接口传参失败("27018","q1l0ry");
response.print();
//判断结果
Assert.assertEquals(response.jsonPath().getString("desc"),"订单处理失败","校验message失败");
Assert.assertEquals(response.jsonPath().getString("code"),"E100203003","校验result失败");
Assert.assertEquals(response.jsonPath().getString("success"),"false","校验success失败");
logger.info("扣积分失败测试验证成功");
} catch (Exception e) {
throw new Exception("扣积分失败测试!");
} finally{
//还原活动扣积分模板 consumeTemplateId: 1-扣积分成功;2-扣积分失败
Response HdResponse = managerService.doEdit2("1");
}
}
@Test(dataProvider = "providerMethod")
public void 限制抽奖测试(Map<String,String> data) throws Exception {
logger.info("-------------------------------------"+data.get("casename")+"-------------------------------------");
Map<String,String> map = new HashMap<>();
map.put("activityId",data.get("activityId"));
map.put("token",data.get("token"));
logger.info("请求/hdtool/recon/doJoin接口");
Response response = given().cookies(authorization.dafuwengLogin(2720)).params(map).post(url+"/hdtool/recon/doJoin");
response.prettyPrint();
//根据case选择对应的校验项
int casenum = Integer.parseInt(data.get("casenum"));
switch(casenum){
case 1:
Assert.assertEquals(response.jsonPath().getString("desc"),"用户积分不足","校验message失败");
Assert.assertEquals(response.jsonPath().getString("code"),"E100201007","校验status失败");
logger.info("积分不足测试校验项:message,status成功");
break;
case 2:
Assert.assertEquals(response.jsonPath().getString("desc"),"没有抽奖次数-限制","校验message失败");
Assert.assertEquals(response.jsonPath().getString("code"),"E100202008","校验status失败");
logger.info("永久次数不足测试校验项:desc,code成功");
break;
case 3:
String success = String.valueOf(response.jsonPath().getString("success"));
int i= 8;
while(i>0&&(success.equals("true"))){
response = given().cookies(authorization.dafuwengLogin(2720)).params(map).post(url+"/hdtool/recon/doJoin");
success = String.valueOf(response.jsonPath().getString("success"));
i--;
}
Assert.assertEquals(response.jsonPath().getString("desc"),"今日没有抽奖次数-限制","校验message失败");
Assert.assertEquals(response.jsonPath().getString("code"),"E100202007","校验status失败");
logger.info("今日次数不足测试校验项:desc,code成功");
break;
}
//通用校验项
Assert.assertEquals(response.jsonPath().getString("success"),"false","校验success失败");
logger.info("通用校验项:success成功");
Thread.sleep(3000);
}
@Test(dataProvider = "providerMethod")
public void 未登录抽奖测试(Map<String,String> data) throws Exception {
logger.info("-------------------------------------"+data.get("casename")+"-------------------------------------");
//根据case选择校验项
if (data.get("activityId").equals("18587")){
//获取未登录场景cookie
Response responses = authorization.autoLogin();
//进行接口测试传参
Map<String,String> map = responses.getCookies();
logger.info("cookies:"+map.toString());
if(responses.getDetailedCookies()==null)logger.info("cookies = = null");
Response response = activityReconService.doJoinMap(map,data.get("token"),data.get("activityId"));
response.prettyPrint();
String success = String.valueOf(response.jsonPath().getString("success"));
Assert.assertEquals(response.jsonPath().getString("desc"),"未登录用户或者预览用户不能参与活动","校验message失败");
Assert.assertEquals(response.jsonPath().getString("code"),"E100201002","校验status失败");
logger.info("未登录状态下无免费次数抽奖校验:message,status成功");
}
if (data.get("activityId").equals("18586")){
//获取未登录场景cookie
Response responses = activityReconService.indexOpenbs("18586");
//进行接口测试传参
Map<String,String> map = responses.getCookies();
logger.info("cookies:"+map.toString());
if(responses.getDetailedCookies()==null)logger.info("cookies = = null");
Response response = activityReconService.doJoinMap(map,data.get("token"),data.get("activityId"));
response.prettyPrint();
String orderId = response.jsonPath().getString("data");
response = activityReconService.getOrderStatus(responses.getDetailedCookies(),orderId);
response.prettyPrint();
String result = String.valueOf(response.jsonPath().getString("code"));
int i= 8;
while(i>0&&(result.equals("C000000001"))){
Thread.sleep(1000);
response = activityReconService.getOrderStatus(responses.getDetailedCookies(),orderId);
result = String.valueOf(response.jsonPath().getString("code"));
i--;
response.prettyPrint();
}
response.prettyPrint();
Assert.assertEquals(response.jsonPath().getString("data.lottery.title"),"话费","校验title失败");
Assert.assertTrue(response.jsonPath().getString("data.lottery.link").contains("/activity/takePrizeNew?recordId="));
Assert.assertEquals(response.jsonPath().getString("data.lottery.id"), "11628", "校验id失败");
logger.info("未登录状态下有免费次数抽奖校验:title,link,id成功");
response = activityReconService.login(map,"2239.3.3.0");
Assert.assertEquals(response.jsonPath().getString("success"),"true","登录跳转接口访问失败!");
}
}
@Test(dataProvider = "providerMethod")
public void 中奖限制测试(Map<String,String> data) throws Exception {
logger.info("-------------------------------------"+data.get("casename")+"-------------------------------------");
//获取管理员后台活动信息
Response ManagerResponse = managerService.getDataEditConfig(data.get("actId"));
//获取奖品剩余库存
String appItemId = String.valueOf(ManagerResponse.jsonPath().getString("awards[1].appItemId"));
String Objremaind = this.getremind(appItemId);
logger.info("预设必中奖品类型为:"+ManagerResponse.jsonPath().getString("data.awards[1].type"));
logger.info("预设中奖几率为:"+ManagerResponse.jsonPath().getString("data.awards[1].probability")+"%");
logger.info("预设中奖每人限制:"+ManagerResponse.jsonPath().getString("data.awards[1].limit")+"次");
logger.info("预设剩余奖品数:"+ManagerResponse.jsonPath().getString("data.awards[1].remaind")+"个");
logger.info("预设奖品库存:"+Objremaind+"个");
if (Objremaind.equals("0")){
Assert.assertEquals(ManagerResponse.jsonPath().getString("awards[1].valid"),"false","校验奖品是否有效失败");
}
//进行接口测试传参
Response response = this.新活动工具接口传参(data.get("activityId"),data.get("token"),"iOS");
String type = String.valueOf(response.jsonPath().getString("data.lottery.type"));
if (type.equals("lucky")){
Assert.assertTrue(response.jsonPath().getString("data.lottery.link").contains("//activity.m.duibatest.com.cn/crecord/recordLuckDetailNew?"));
Assert.assertEquals(response.jsonPath().getString("data.lottery.useBtnText"),"马上使用","校验useBtnText失败");
logger.info("校验中奖限制测试:link,useBtnText成功");
logger.info("校验中奖限制测试成功,未返回预设必中"+ManagerResponse.jsonPath().getString("data.awards[1].type")+"奖品");
}
if (type.equals("thanks")){
logger.info("福袋库存不足会降级成谢谢参与!");//福袋库存不足会降级成谢谢参与!
}
if (type.equals("object")&&ManagerResponse.jsonPath().getString("awards[1].remaind").equals("0")){
throw new Exception("用例失败,不应返回实物信息:"+response.asString());
}
}
//@Test(dataProvider = "providerData")
public void 活动黑名单测试test(String id,String activityId,String status) throws Exception {
//将开发者ID加入活动的黑名单
Response HdResponse = managerService.switchBlack(activityId,status);
Thread.sleep(60000);
//打开活动界面
Response response = activityReconService.index(id);
//判断结果
if(status.equals("true")){
Assert.assertEquals(MatcherString.getString(response.asString(),"<title>(.*?)</title>\n",1),"活动结束","活动页打开异常!");
}else {
Assert.assertEquals(MatcherString.getString(response.asString(),"<title>(.*?)</title>\n",1),"【勿动】自动化—黑名单","活动页打开异常!");
}
logger.info("黑名单开关的抽奖页面验证成功");
}
@Test
public void 活动黑名单测试() throws Exception {
//打开活动界面
Response response = activityReconService.index("18900");
//判断结果
Assert.assertEquals(MatcherString.getString(response.asString(),"<title>(.*?)</title>\n",1),"活动结束","活动页打开异常!");
logger.info("黑名单开关的抽奖页面验证成功");
}
//@Test
public void 活动保底测试() throws Exception {
//获取管理员后台活动信息
// Response ManagerResponse = managerService.getDataEditConfig("3146");
//获取奖品剩余库存
// String low = String.valueOf(ManagerResponse.jsonPath().getString("awards[1].low"));
// logger.info("奖品保底人数:"+low+"人");
//设置活动保底人数
Response ManagerResponse = managerService.save("3146","【勿动】自动化-保底人数","0","80");
}
@Test(description = "该活动已在大富翁app上架可参与")
public void 开发者未上架活动(){
Map<String,String> map = new HashMap<>();
map.put("activityId","33486");
map.put("token","u73vb2oxn");
logger.info("请求/hdtool/recon/doJoin接口,activityId=33486");
Response response = given().cookies(authorization.dafuwengLogin(2720)).params(map).post(url+"/hdtool/recon/doJoin");
response.print();
Assert.assertEquals(response.jsonPath().getString("success"),"false");
Assert.assertEquals(response.jsonPath().getString("desc"),"活动不存在!");
Assert.assertEquals(response.jsonPath().getString("code"),"E100202002");
}
public Response 新活动工具接口传参(String activityId,String token,String device) throws Exception {
Response response = activityReconService.doJoin2(activityId,token);
response.prettyPrint();
String orderId = response.jsonPath().getString("data");
response = activityReconService.getOrderStatus2(orderId,device);
response.prettyPrint();
String result = String.valueOf(response.jsonPath().getString("code"));
int i= 8;
while(i>0&&(result.equals("C000000001"))){
Thread.sleep(1000);
response = activityReconService.getOrderStatus2(orderId,device);
result = String.valueOf(response.jsonPath().getString("code"));
i--;
response.prettyPrint();
}
return response;
}
public Response 新活动工具接口传参失败(String activityId,String token) throws Exception {
Response response = activityReconService.doJoin2(3268,activityId,token);
response.prettyPrint();
String orderId = response.jsonPath().getString("data");
logger.info("订单号为:"+orderId);
response = activityReconService.getOrderStatus2(3268,orderId);
response.prettyPrint();
String result = String.valueOf(response.jsonPath().getString("code"));
int i= 8;
while(i>0&&(result.equals("C000000001"))){
Thread.sleep(1000);
response = activityReconService.getOrderStatus2(3268,orderId);
result = String.valueOf(response.jsonPath().getString("code"));
i--;
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);
//logger.info("当前库存:"+remind);
return remind;
}
}
\ No newline at end of file
package http.cases.ActivityReconTest;
import base.DuibaLog;
import base.DuibaTestBase;
import http.service.Activity.ActivityReconService;
import http.service.Activity.ManagerService;
import http.service.Activity.NewActivityService;
import http.service.hd.ActivityService;
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;
import java.util.Map;
/**
* Created by zhaoran on 2018/1/2
*/
public class 新活动工具测试 extends DuibaTestBase {
@Autowired
ActivityReconService activityReconService;
@Autowired
ManagerService managerService;
@Autowired
ActivityService activityService;
private static DuibaLog logger = DuibaLog.getLogger();
private static int uid = 4259;
@Test
public void 福袋商品测试() throws Exception {
logger.info("-------------------------------------活动中奖福袋商品-------------------------------------");
Response response = this.新活动工具接口传参(uid,"18567","1gffs6mq3");
Assert.assertEquals(response.jsonPath().getString("data.lottery.type"), "lucky", "校验类型失败");
Assert.assertTrue(response.jsonPath().getString("data.lottery.link").contains("//activity.m.duibatest.com.cn/crecord/recordLuckDetailNew?"));
Assert.assertTrue(response.jsonPath().getString("data.lottery.iosDownloadUrl").contains("activityId=18567"));
Assert.assertTrue(response.jsonPath().getString("data.lottery.iosDownloadUrl").contains("//activity.tuiatest.cn/activity/redirect"));
Assert.assertEquals(response.jsonPath().getString("data.lottery.id"), "11587", "校验id失败");
Assert.assertEquals(response.jsonPath().getString("data.lottery.showUse"), "true", "校验显示按钮失败");
Assert.assertEquals(response.jsonPath().getString("data.lottery.useBtnText"),"马上使用","校验useBtnText失败");
logger.info("校验福袋:link,id,useBtnText成功");
}
@Test
public void 谢谢参与转福袋测试() throws Exception {
logger.info("-------------------------------------活动中奖谢谢参与转福袋-------------------------------------");
Response response = this.新活动工具接口传参(uid,"26640","1gffs6mq3");
Assert.assertEquals(response.jsonPath().getString("data.lottery.isAppLucky"), "true", "校验是否安慰奖失败");
Assert.assertEquals(response.jsonPath().getString("data.lottery.type"), "lucky", "校验类型失败");
Assert.assertTrue(response.jsonPath().getString("data.lottery.link").contains("//activity.m.duibatest.com.cn/crecord/recordLuckDetailNew?"));
Assert.assertTrue(response.jsonPath().getString("data.lottery.iosDownloadUrl").contains("activityId=26640"));
Assert.assertTrue(response.jsonPath().getString("data.lottery.iosDownloadUrl").contains("//activity.tuiatest.cn/activity/redirect"));
Assert.assertEquals(response.jsonPath().getString("data.lottery.showUse"), "true", "校验显示按钮失败");
Assert.assertEquals(response.jsonPath().getString("data.lottery.useBtnText"),"马上使用","校验useBtnText失败");
logger.info("校验福袋:link,id,useBtnText成功");
}
@Test
public void 免费次数测试() throws Exception {
Response response1 = activityReconService.ajaxElement(uid,"3251","19114");
String freeLimit = String.valueOf(response1.jsonPath().getString("data.element.freeLimit"));
logger.info("抽奖前剩余免费抽奖次数:"+freeLimit);
freeLimit = String.valueOf(Integer.valueOf(freeLimit)-1);
Response response = this.新活动工具接口传参(uid,"19114","ogw24k6ns");
Thread.sleep(1000);
Response response2 = activityReconService.ajaxElement(uid,"3251","19114");
String freeLimitNew = String.valueOf(response2.jsonPath().getString("data.element.freeLimit"));
logger.info("抽奖后剩余免费抽奖次数:"+freeLimitNew);
//校验比较,抽奖前后积分
Assert.assertEquals(freeLimitNew,freeLimit);
logger.info("校验抽奖前后剩余次数正确");
}
@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 = this.新活动工具接口传参(uid,"18580","m8rhchc");
response.print();
Assert.assertEquals(response.jsonPath().getString("data.lottery.type"),"again","校验type失败");
Assert.assertEquals(response.jsonPath().getString("data.lottery.id"), "11608", "校验id失败");
//Assert.assertEquals(response.jsonPath().getString("result"), "3", "校验result失败");
logger.info("校验:type,id,result成功");
//第一次抽奖后查询数据库,获取当前积分
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("校验第一次抽奖前后积分正确");
//第二次抽奖
response = activityReconService.doJoin2(uid,"18580","m8rhchc",response.jsonPath().getString("againTag"));
response.prettyPrint();
Thread.sleep(2000);
//第二次抽奖后查询数据库,获取当前积分
mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
String creditsNew2 = String.valueOf(mapuser.get("credits"));
logger.info("第二次抽奖后积分:"+creditsNew2);
//校验比较,抽奖前后积分
Assert.assertEquals(creditsNew,creditsNew2);
logger.info("校验第二次抽奖前后积分正确");
}
public Response 新活动工具接口传参(int uid,String activityId,String token) throws Exception {
Response response = activityReconService.doJoin2(uid,activityId,token);
response.prettyPrint();
String orderId = response.jsonPath().getString("data");
response = activityReconService.getOrderStatus2(uid,orderId);
response.prettyPrint();
String result = String.valueOf(response.jsonPath().getString("code"));
int i= 30;
while(i>0&&(result.equals("C000000001"))){
Thread.sleep(1000);
response = activityReconService.getOrderStatus2(uid,orderId);
result = String.valueOf(response.jsonPath().getString("code"));
i--;
response.prettyPrint();
}
return response;
}
/**
* 提供精确的减法运算。
* @param v1 被减数
* @param v2 减数
* @return 两个参数的差
*/
public static double sub(double v1,double v2){
BigDecimal b1 = new BigDecimal(Double.toString(v1));
BigDecimal b2 = new BigDecimal(Double.toString(v2));
return b1.subtract(b2).doubleValue();
}
}
\ No newline at end of file
package http.cases.ActivityReconTest;
import base.DuibaLog;
import base.DuibaTestBase;
import http.service.Activity.ActivityReconService;
import http.service.Activity.ManagerService;
import http.service.Activity.NewActivityService;
import http.service.Authorization;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
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/1/2
*/
public class 无积分测试 extends DuibaTestBase {
@Autowired
ActivityReconService activityReconService;
@Autowired
ManagerService managerService;
@Autowired
Authorization authorization;
private static DuibaLog logger = DuibaLog.getLogger();
private String url = "http://activity.m.duibatest.com.cn";
@DataProvider
public Object[][] providerMethod(Method method){
Object[][] result = null;
if(method.getName().equals("参与次数测试")) {
result = new Object[][]{
new Object[]{1,"5243","23105", "永久限制5次,不免费"},
new Object[]{2,"5314","23314", "无限制,不免费"},
new Object[]{3,"5315","23315", "无限制,每天免费999"},
};
}
return result;
}
@Test(dataProvider = "providerMethod")
public void 参与次数测试(int casenum,String hdToolId,String activityId,String casename) throws Exception {
logger.info("-------------------------------------"+casename+"-------------------------------------");
//校验ajax接口关键字段返回
logger.info("请求/hdtool/recon/ajaxElement接口");
Response response_ajax = this.ajaxElement(hdToolId,activityId);
Assert.assertEquals(response_ajax.jsonPath().getString("data.element.isCreditsTypeOpen"),"true","校验isCreditsTypeOpen失败");
logger.info("请求/hdtool/recon/doJoin接口");
Response response = this.doJoin(activityId);
response.prettyPrint();
//根据case选择对应的校验项
switch(casenum){
case 1:
Assert.assertEquals(response_ajax.jsonPath().getString("data.element.status"),"4","校验status失败");
logger.info("ajax校验项:status成功");
Assert.assertEquals(response.jsonPath().getString("desc"),"没有抽奖次数-限制","校验message失败");
Assert.assertEquals(response.jsonPath().getString("code"),"E100202008","校验status失败");
Assert.assertEquals(response.jsonPath().getString("success"),"false","校验success失败");
logger.info("doJoin校验项:message,status,success成功");
break;
case 2:
Assert.assertEquals(response_ajax.jsonPath().getString("data.element.status"),"3","校验status失败");
logger.info("ajax校验项:status成功");
Assert.assertEquals(response.jsonPath().getString("desc"),"今日没有抽奖次数-免费","校验message失败");
Assert.assertEquals(response.jsonPath().getString("code"),"E100202009","校验status失败");
Assert.assertEquals(response.jsonPath().getString("success"),"false","校验success失败");
logger.info("doJoin校验项:message,status,success成功");
break;
case 3:
Assert.assertEquals(response_ajax.jsonPath().getString("data.element.status"),"5","校验status失败");
logger.info("ajax校验项:status成功");
Assert.assertEquals(response.jsonPath().getString("desc"),"OK","校验needCredits失败");
Assert.assertEquals(response.jsonPath().getString("success"),"true","校验success失败");
logger.info("doJoin校验项:needCredits,success成功");
break;
}
//切换回2720用户
//authorization.dafuwengLogin(2720,true);
}
public Response ajaxElement(String hdToolId,String activityId) throws Exception {
Map<String, String> map = new HashMap<>();
map.put("duibaId",hdToolId);
map.put("activityId",activityId);
logger.info("请求/hdtool/recon/ajaxElement接口");
Response response_ajax = given().cookies(authorization.dafuwengLogin(2723,true)).params(map).get(url+"/hdtool/recon/ajaxElement");
try{
Assert.assertEquals(response_ajax.jsonPath().getString("success"),"true");
}catch(Exception e){
throw new Exception("/hdtool/recon/ajaxElement接口失败,返回信息:"+response_ajax.asString());
}catch(Error er){
throw new Exception("/hdtool/recon/ajaxElement接口失败,返回信息:"+response_ajax.asString());
}
return response_ajax;
}
public Response doJoin(String activityId) throws Exception {
Map<String,String> map2 = new HashMap<>();
map2.put("activityId",activityId);
map2.put("token","1hrja7");
logger.info("请求/hdtool/ajaxElement接口");
Response response = given().cookies(authorization.dafuwengLogin(2723)).params(map2).post(url+"/hdtool/recon/doJoin");
return response;
}
}
\ No newline at end of file
package http.cases.ActivityReconTest;
import base.Config;
import base.DuibaLog;
import http.service.Activity.ActivityReconService;
import http.service.Activity.ManagerService;
import http.service.Activity.NewActivityService;
import http.service.Activity.SingleLotteryService;
import http.service.hd.DeveloperService;
import http.service.hd.SigninService;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
import org.testng.Assert;
import org.testng.annotations.Test;
/**
* Created by zhaoran on 2018/5/19.
*/
@ContextConfiguration(classes = Config.class)
public class 自有_活动中奖限制 extends AbstractTestNGSpringContextTests {
@Autowired
SigninService signinService;
@Autowired
DeveloperService developerService;
@Autowired
ManagerService managerService;
@Autowired
ActivityReconService activityReconService;
@Autowired
SingleLotteryService singleLotteryService;
private static DuibaLog logger = DuibaLog.getLogger();
@Test(description = "自有活动设置中奖限制为1次")
public void 中奖限制() throws Exception {
//进行接口测试传参
Response response = this.自有活动接口传参("21939","abcde","iOS");
String type = String.valueOf(response.jsonPath().getString("data.lottery.type"));
if (type.equals("lucky")){
Assert.assertTrue(response.jsonPath().getString("data.lottery.link").contains("//activity.m.duibatest.com.cn/crecord/recordLuckDetailNew?"));
Assert.assertEquals(response.jsonPath().getString("data.lottery.useBtnText"),"马上使用","校验useBtnText失败");
logger.info("校验中奖限制测试:link,useBtnText成功");
logger.info("校验中奖限制测试成功,未返回预设必中优惠券信息");
}
if (type.equals("thanks")){
logger.info("福袋库存不足会降级成谢谢参与!");//福袋库存不足会降级成谢谢参与!
}
if (type.equals("coupon")){
throw new Exception("用例失败,不应返回优惠券信息:"+response.asString());
}
}
public Response 自有活动接口传参(String activityId,String token,String device) throws Exception {
Response response = activityReconService.doJoin2(activityId,token);
response.prettyPrint();
String orderId = response.jsonPath().getString("data");
response = activityReconService.getOrderStatus2(orderId,device);
response.prettyPrint();
String result = String.valueOf(response.jsonPath().getString("code"));
int i= 8;
while(i>0&&(result.equals("C000000001"))){
Thread.sleep(1000);
response = activityReconService.getOrderStatus2(orderId,device);
result = String.valueOf(response.jsonPath().getString("code"));
i--;
response.prettyPrint();
}
return response;
}
}
\ No newline at end of file
package http.cases.ActivityReconTest;
import base.Config;
import base.DuibaLog;
import http.service.Activity.ActivityReconService;
import http.service.Activity.NewActivityService;
import http.service.hd.DeveloperService;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
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;
/**
* Created by zhaoran on 2018/3/15
*/
@ContextConfiguration(classes = Config.class)
public class 自有_活动次数测试 extends AbstractTestNGSpringContextTests {
@Autowired
ActivityReconService activityReconService;
@Autowired
DeveloperService developerService;
private static DuibaLog logger = DuibaLog.getLogger();
@DataProvider
public Object[][] providerMethod(Method method){
Object[][] result = null;
if(method.getName().equals("活动次数测试")) {
result = new Object[][]{
new Object[]{1, "5","10","限制5次,免费10次"},
new Object[]{2, "8","3","限制8次,免费3次"},
new Object[]{3, "","6","无限制次数,免费6次"},
new Object[]{4, "7","","限制7次,无免费次数"},
};
}
if(method.getName().equals("活动次数测试2")) {
result = new Object[][]{
new Object[]{1, "26248","限制5次,免费10次"},
new Object[]{2, "26249","限制8次,免费3次"},
new Object[]{3, "26250","无限制次数,免费6次"},
new Object[]{4, "21001","限制7次,无免费次数"},
};
}
return result;
}
@Test(dataProvider = "providerMethod")
public void 活动次数测试2(int casenum,String activityId,String casename) throws Exception {
logger.info("-------------------------------------"+casename+"-------------------------------------");
//获取免费次数
Response response = activityReconService.ajaxElement("", activityId);
response.print();
switch(casenum){
case 1:
Assert.assertEquals(response.jsonPath().getString("element.freeLimit"), "5", "校验freeLimit失败");
Assert.assertEquals(response.jsonPath().getString("element.status"), "7", "校验显示status失败");
break;
case 2:
Assert.assertEquals(response.jsonPath().getString("element.freeLimit"), "3", "校验freeLimit失败");
Assert.assertEquals(response.jsonPath().getString("element.status"), "7", "校验显示status失败");
break;
case 3:
Assert.assertEquals(response.jsonPath().getString("element.freeLimit"), "6", "校验freeLimit失败");
Assert.assertEquals(response.jsonPath().getString("element.status"), "7", "校验显示status失败");
break;
case 4:
Assert.assertEquals(response.jsonPath().getString("element.freeLimit"), "7", "校验freeLimit失败");
Assert.assertEquals(response.jsonPath().getString("element.status"), "6", "校验显示status失败");
break;
}
logger.info("校验ajax接口的游戏次数正常:freeLimit,status");
}
}
package http.cases.ActivityReconTest;
import base.Config;
import base.DuibaLog;
import http.service.Activity.ActivityReconService;
import http.service.Activity.ManagerService;
import http.service.Activity.NewActivityService;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
import org.testng.Assert;
import org.testng.annotations.Test;
/**
* Created by zhaoran on 2018/1/2
*/
@ContextConfiguration(classes = Config.class)
public class 自有_独立活动测试 extends AbstractTestNGSpringContextTests {
@Autowired
ActivityReconService activityReconService;
@Autowired
ManagerService managerService;
private static DuibaLog logger = DuibaLog.getLogger();
@Test(description = "积分模式下的自有独立活动测试")
public void 独立活动测试() throws Exception {
//校验ajax接口关键字段返回
logger.info("请求/hdtool/ajaxElement接口");
Response response_ajax = activityReconService.ajaxElement("","23316");
Assert.assertEquals(response_ajax.jsonPath().getString("element.isCreditsTypeOpen"),"true","校验isCreditsTypeOpen失败");
Assert.assertEquals(response_ajax.jsonPath().getString("element.status"),"7","校验status失败");
Assert.assertEquals(response_ajax.jsonPath().getString("element.needCredits"),"0","校验status失败");
logger.info("ajax校验项:isCreditsTypeOpen,status成功");
String freeLimit = response_ajax.jsonPath().getString("element.freeLimit");
logger.info("抽奖前当日免费次数剩余:"+freeLimit);
freeLimit = String.valueOf(Integer.valueOf(freeLimit)-1);
logger.info("抽奖后预期免费次数剩余:"+freeLimit);
logger.info("请求/hdtool/doJoin接口");
Response response = activityReconService.doJoin2("23316","ia9a7");
String orderId = response.jsonPath().getString("data");
response = activityReconService.getOrderStatus2(orderId);
String result = response.jsonPath().getString("code");
int i = 30;
while(i>0&&result.equals("C000000001")){
Thread.sleep(1000);
response = activityReconService.getOrderStatus2(orderId);
result = response.jsonPath().getString("code");
i--;
}
Assert.assertEquals(response.jsonPath().getString("data.element.isCreditsTypeOpen"),"true","校验isCreditsTypeOpen失败");
Assert.assertEquals(response.jsonPath().getString("data.element.status"),"7","校验status失败");
Assert.assertEquals(response.jsonPath().getString("data.lottery.title"),"支付宝","校验title失败");
Assert.assertEquals(response.jsonPath().getString("data.lottery.type"),"alipay","校验type失败");
Assert.assertEquals(response.jsonPath().getString("success"),"true","校验success失败");
logger.info("doJoin校验项:isCreditsTypeOpen,status,title,type,success成功");
String freeLimitNew = response.jsonPath().getString("data.element.freeLimit");
logger.info("抽奖后实际免费次数剩余:"+freeLimitNew);
Assert.assertEquals(freeLimitNew,freeLimit,"扣免费次数失败");
}
}
\ No newline at end of file
package http.cases.ActivityReconTest;
import base.DuibaLog;
import base.DuibaTestBase;
import http.service.Activity.ActivityReconService;
import http.service.Activity.NewActivityService;
import http.service.Authorization;
import http.service.hd.ActivityService;
import http.service.hd.DeveloperService;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.Test;
import utils.MatcherString;
import java.util.Map;
/**
* Created by mabo on 2018/5/17
*/
public class 自有_自有活动出奖 extends DuibaTestBase {
@Autowired
ActivityReconService activityReconService;
@Autowired
Authorization authorization;
@Autowired
ActivityService activityService;
@Autowired
DeveloperService developerService;
private DuibaLog logger = DuibaLog.getLogger();
@Test(description = "出奖及领奖操作以及订单校验")
public void 出奖自有实物() throws Exception {
Map map = jdbc.findSimpleResult("select * from stock.tb_stock where stock_id = 674900849714500524");
int remaining = (int)map.get("stock");
Response response = activityReconService.doJoin2("21803","h5ps61");
String orderId = response.jsonPath().getString("data");
response = activityReconService.getOrderStatus2(orderId);
String result = response.jsonPath().getString("code");
int i = 30;
while(i>0&&result.equals("C000000001")){
Thread.sleep(1000);
response = activityReconService.getOrderStatus2(orderId);
response.prettyPeek();
result = response.jsonPath().getString("code");
i--;
}
String id = response.jsonPath().getString("data.lottery.id");
String imgurl = response.jsonPath().getString("data.lottery.imgUrl");
String link = response.jsonPath().getString("data.lottery.link");
String title = response.jsonPath().getString("data.lottery.title");
String type = response.jsonPath().getString("data.lottery.type");
Assert.assertEquals(id,"15712","id不正确");
Assert.assertEquals(imgurl,"//yun.duiba.com.cn/upload/1uF0l1462438316968.png","imgurl不正确");
Assert.assertTrue(link.contains("/activity/takePrizeNew?recordId="),"link不正确");
Assert.assertEquals(title,"自有实物","title不正确");
Assert.assertEquals(type,"object","type不正确");
Thread.sleep(1000);
map = jdbc.findSimpleResult("select * from stock.tb_stock where stock_id = 674900849714500524");
int remainingNew = (int)map.get("stock");
Assert.assertEquals(remaining-1,remainingNew,"扣库存失败");
//领奖操作
String recordId = MatcherString.getString(response.asString(), "recordId=(.*?)&", 1);
response = activityReconService.doTakePrize(2720,type, recordId);
Assert.assertEquals(response.jsonPath().getString("message"), "领奖成功");
logger.info("结果:" + type + "领奖流程成功");
//校验领奖后的订单状态
Map<String, Object> selectResult = jdbc.findSimpleResult("select * from credits_hdtool.hdtool_orders_0687 where id = '"+orderId+"'");
String main_orderId = String.valueOf(selectResult.get("main_order_num"));
logger.info("主订单为:"+main_orderId);
Map<String, Object> selectResult2 = jdbc.findSimpleResult("select * from orders_consumer.orders_0687 where order_num = '"+main_orderId+"' ");
String flowWork = String.valueOf(selectResult2.get("flowwork_stage"));
logger.info("领奖后数据库订单节点:"+flowWork);
int j =10;
while (j > 0 && !flowWork.equals("SupplierExchange-started")) {
Thread.sleep(300);
selectResult2 = jdbc.findSimpleResult("select * from orders_consumer.orders_0687 where order_num = '"+main_orderId+"' ");
flowWork = String.valueOf(selectResult2.get("flowwork_stage"));
logger.info("领奖后数据库订单节点:" + flowWork);
j--;
}
Assert.assertEquals(flowWork,"SupplierExchange-started","数据库主订单流程节点校验失败");
Assert.assertEquals(String.valueOf(selectResult2.get("biz_params")),"胡梦新:18258853242:浙江省:杭州市:西湖区:西溪街道:数娱大厦 ","数据库主订单biz_params校验失败");
Assert.assertEquals(String.valueOf(selectResult2.get("pay_status")),"none","数据库主订单pay_status校验失败");
Assert.assertEquals(String.valueOf(selectResult2.get("status")),"consume_success","数据库主订单status校验失败");
//发货操作
Map<String, Object> selectResult3 = jdbc.findSimpleResult("select * from orders_consumer.orders_0687 where order_num = '"+main_orderId+"' ");
String orderId_send = String.valueOf(selectResult3.get("supplier_order_id"));
logger.info("发货订单为:"+orderId_send);
// Thread.sleep(3000);
developerService.doDeliverObject(orderId_send,"5");
logger.info("自有实物发货订单成功");
//校验发货后的订单状态
selectResult3 = jdbc.findSimpleResult("select * from orders_consumer.orders_0687 where order_num = '"+main_orderId+"'");
String flowWork2 = String.valueOf(selectResult3.get("flowwork_stage"));
logger.info("发货后数据库订单节点:"+flowWork2);
int k =10;
while (k > 0 && !flowWork2.equals("Success-complete")) {
Thread.sleep(1000);
selectResult3 = jdbc.findSimpleResult("select * from orders_consumer.orders_0687 where order_num = '"+main_orderId+"' ");
flowWork2 = String.valueOf(selectResult3.get("flowwork_stage"));
logger.info("发货后数据库订单节点:" + flowWork2);
k--;
}
Assert.assertEquals(String.valueOf(selectResult3.get("pay_status")),"none","数据库主订单pay_status校验失败");
Assert.assertEquals(String.valueOf(selectResult3.get("status")),"success","数据库主订单status校验失败");
}
@Test(description = "出奖及订单校验")
public void 出奖自有优惠券() throws Exception {
Response response = activityReconService.doJoin2("21792","h5ps61");
String orderId = response.jsonPath().getString("data");
response = activityReconService.getOrderStatus2(orderId);
String result = response.jsonPath().getString("code");
int i = 30;
while(i>0&&result.equals("C000000001")){
Thread.sleep(1000);
response = activityReconService.getOrderStatus2(orderId);
result = response.jsonPath().getString("code");
i--;
}
String id = response.jsonPath().getString("data.lottery.id");
String imgurl = response.jsonPath().getString("data.lottery.imgUrl");
String link = response.jsonPath().getString("data.lottery.link");
String title = response.jsonPath().getString("data.lottery.title");
String type = response.jsonPath().getString("data.lottery.type");
String coupon_code = response.jsonPath().getString("data.lottery.coupon_code");
String coupon_key = response.jsonPath().getString("data.lottery.coupon_key");
Assert.assertEquals(id,"15703","id不正确");
Assert.assertEquals(imgurl,"//yun.dui88.com/images/201803/29k6k3x05d.jpg","imgurl不正确");
Assert.assertTrue(link.contains("//activity.m.duibatest.com.cn/crecord/recordDetailNew?orderId="),"link不正确");
Assert.assertEquals(title,"【自动化勿动】自有优惠券","title不正确");
Assert.assertEquals(type,"coupon","type不正确");
Assert.assertEquals(coupon_code,"123123123","coupon_code不正确");
Assert.assertEquals(coupon_key,"123123","coupon_key不正确");
Map<String, Object> selectResult = jdbc.findSimpleResult("select * from credits_hdtool.hdtool_orders_0687 where id = '"+orderId+"' ",null);
logger.info("主订单为:"+selectResult.get("main_order_num"));
String main_orderId = String.valueOf(selectResult.get("main_order_num"));
Map<String, Object> selectResult2 = jdbc.findSimpleResult("select * from orders_consumer.orders_0687 where order_num = '"+main_orderId+"' ");
logger.info("数据库订单节点:"+selectResult2.get("flowwork_stage"));
String flowWork = String.valueOf(selectResult2.get("flowwork_stage"));
int j =10;
while (j > 0 && !flowWork.equals("Success-complete")) {
Thread.sleep(300);
selectResult2 = jdbc.findSimpleResult("select * from orders_consumer.orders_0687 where order_num = '"+main_orderId+"' ");
flowWork = String.valueOf(selectResult2.get("flowwork_stage"));
logger.info("数据库订单节点:" + flowWork);
j--;
}
Assert.assertEquals(flowWork,"Success-complete","数据库主订单流程节点校验失败");
}
@Test
public void 出奖自有虚拟商品() throws Exception {
Map map = jdbc.findSimpleResult("select * from stock.tb_stock where stock_id = 674900860200070105");
int remaining = (int)map.get("stock");
Response response = activityReconService.doJoin2("21793","h5ps61");
String orderId = response.jsonPath().getString("data");
response = activityReconService.getOrderStatus2(orderId);
String result = response.jsonPath().getString("code");
int i = 30;
while(i>0&&result.equals("C000000001")){
Thread.sleep(1000);
response = activityReconService.getOrderStatus2(orderId);
result = response.jsonPath().getString("code");
i--;
}
String id = response.jsonPath().getString("data.lottery.id");
String imgurl = response.jsonPath().getString("data.lottery.imgUrl");
String link = response.jsonPath().getString("data.lottery.link");
String title = response.jsonPath().getString("data.lottery.title");
String type = response.jsonPath().getString("data.lottery.type");
Assert.assertEquals(id,"15707","id不正确");
Assert.assertEquals(imgurl,"//yun.duiba.com.cn/developer/img/activityTool/slotMachine/virtual.png","imgurl不正确");
//Assert.assertEquals(link,"/activity/takePrizeNew?recordId=3402918&dbnewopen","link正确");
Assert.assertTrue(link.contains("/activity/takePrizeNew?recordId="),"link不正确");
Assert.assertEquals(title,"虚拟商品","title不正确");
Assert.assertEquals(type,"virtual","type不正确");
Thread.sleep(1000);
map = jdbc.findSimpleResult("select * from stock.tb_stock where stock_id = 674900860200070105");
int remainingNew = (int)map.get("stock");
Assert.assertEquals(remaining-1,remainingNew,"扣库存失败");
}
@Test
public void 出奖兑吧实物() throws Exception {
Map map = jdbc.findSimpleResult("select * from stock.tb_stock where stock_id = 674900440770170322 ");
int remaining = (int)map.get("stock");
Response response = activityReconService.doJoin2("22637","h5ps61");
String orderId = response.jsonPath().getString("data");
response = activityReconService.getOrderStatus2(orderId);
String result = response.jsonPath().getString("code");
int i = 30;
while(i>0&&result.equals("C000000001")){
Thread.sleep(1000);
response = activityReconService.getOrderStatus2(orderId);
response.prettyPeek();
result = response.jsonPath().getString("code");
i--;
}
String id = response.jsonPath().getString("data.lottery.id");
String imgurl = response.jsonPath().getString("data.lottery.imgUrl");
String link = response.jsonPath().getString("data.lottery.link");
String title = response.jsonPath().getString("data.lottery.title");
String type = response.jsonPath().getString("data.lottery.type");
Assert.assertEquals(id,"15812","id不正确");
Assert.assertEquals(imgurl,"//yun.duiba.com.cn/developer/img/activityTool/shake/object.png","imgurl不正确");
Assert.assertTrue(link.contains("/activity/takePrizeNew?recordId="),"link不正确");
Assert.assertEquals(title,"兑吧实物","title不正确");
Assert.assertEquals(type,"object","type不正确");
Thread.sleep(1000);
map = jdbc.findSimpleResult("select * from stock.tb_stock where stock_id = 674900440770170322 ");
int remainingNew = (int)map.get("stock");
Assert.assertEquals(remaining-1,remainingNew,"扣库存失败");
}
@Test
public void 出奖兑吧优惠券() throws Exception {
Response response = activityReconService.doJoin2("22636","h5ps61");
String orderId = response.jsonPath().getString("data");
response = activityReconService.getOrderStatus2(orderId);
String result = response.jsonPath().getString("code");
int i = 30;
while(i>0&&result.equals("C000000001")){
Thread.sleep(1000);
response = activityReconService.getOrderStatus2(orderId);
result = response.jsonPath().getString("code");
i--;
}
String id = response.jsonPath().getString("data.lottery.id");
String imgurl = response.jsonPath().getString("data.lottery.imgUrl");
String link = response.jsonPath().getString("data.lottery.link");
String title = response.jsonPath().getString("data.lottery.title");
String type = response.jsonPath().getString("data.lottery.type");
String coupon_code = response.jsonPath().getString("data.lottery.coupon_code");
String coupon_key = response.jsonPath().getString("data.lottery.coupon_key");
Assert.assertEquals(id,"15810","id不正确");
Assert.assertTrue(link.contains("//activity.m.duibatest.com.cn/crecord/recordDetailNew?orderId="),"link不正确");
Assert.assertEquals(title,"【自动化】优惠券-普通","title不正确");
Assert.assertEquals(type,"coupon","type不正确");
}
@Test
public void 出奖话费() throws Exception {
Response response = activityReconService.doJoin2("22647","h5ps61");
String orderId = response.jsonPath().getString("data");
response = activityReconService.getOrderStatus2(orderId);
String result = response.jsonPath().getString("code");
int i = 30;
while(i>0&&result.equals("C000000001")){
Thread.sleep(1000);
response = activityReconService.getOrderStatus2(orderId);
result = response.jsonPath().getString("code");
i--;
}
String id = response.jsonPath().getString("data.lottery.id");
String imgurl = response.jsonPath().getString("data.lottery.imgUrl");
String link = response.jsonPath().getString("data.lottery.link");
String title = response.jsonPath().getString("data.lottery.title");
String type = response.jsonPath().getString("data.lottery.type");
Assert.assertEquals(id,"15815","id不正确");
Assert.assertEquals(imgurl,"//yun.duiba.com.cn/developer/img/activityTool/shake/phone.png","imgurl不正确");
Assert.assertTrue(link.contains("//activity.m.duibatest.com.cn/activity/takePrizeNew?recordId="),"link不正确");
Assert.assertEquals(title,"话费","title不正确");
Assert.assertEquals(type,"phonebill","type不正确");
}
@Test
public void 出奖支付宝() throws Exception {
Response response = activityReconService.doJoin2("22648","h5ps61");
String orderId = response.jsonPath().getString("data");
response = activityReconService.getOrderStatus2(orderId);
String result = response.jsonPath().getString("code");
int i = 30;
while(i>0&&result.equals("C000000001")){
Thread.sleep(1000);
response = activityReconService.getOrderStatus2(orderId);
result = response.jsonPath().getString("code");
i--;
}
String id = response.jsonPath().getString("data.lottery.id");
String imgurl = response.jsonPath().getString("data.lottery.imgUrl");
String link = response.jsonPath().getString("data.lottery.link");
String title = response.jsonPath().getString("data.lottery.title");
String type = response.jsonPath().getString("data.lottery.type");
Assert.assertEquals(id,"15817","id不正确");
Assert.assertEquals(imgurl,"//yun.duiba.com.cn/developer/img/activityTool/shake/alipay.png","imgurl不正确");
Assert.assertTrue(link.contains("//activity.m.duibatest.com.cn/activity/takePrizeNew?recordId="),"link不正确");
Assert.assertEquals(title,"支付宝","title不正确");
Assert.assertEquals(type,"alipay","type不正确");
}
@Test
public void 出奖Q() throws Exception {
Response response = activityReconService.doJoin2("22649","h5ps61");
String orderId = response.jsonPath().getString("data");
response = activityReconService.getOrderStatus2(orderId);
String result = response.jsonPath().getString("code");
int i = 30;
while(i>0&&result.equals("C000000001")){
Thread.sleep(1000);
response = activityReconService.getOrderStatus2(orderId);
result = response.jsonPath().getString("code");
i--;
}
String id = response.jsonPath().getString("data.lottery.id");
String imgurl = response.jsonPath().getString("data.lottery.imgUrl");
String link = response.jsonPath().getString("data.lottery.link");
String title = response.jsonPath().getString("data.lottery.title");
String type = response.jsonPath().getString("data.lottery.type");
Assert.assertEquals(id,"15819","id不正确");
Assert.assertEquals(imgurl,"//yun.duiba.com.cn/developer/img/activityTool/shake/qb.png","imgurl不正确");
Assert.assertTrue(link.contains("//activity.m.duibatest.com.cn/activity/takePrizeNew?recordId="),"link不正确");
Assert.assertEquals(title,"Q币","title不正确");
Assert.assertEquals(type,"qb","type不正确");
}
@Test
public void 出奖福袋() throws Exception {
Response response = activityReconService.doJoin2("22651","h5ps61");
String orderId = response.jsonPath().getString("data");
response = activityReconService.getOrderStatus2(orderId);
String result = response.jsonPath().getString("code");
int i = 30;
while(i>0&&result.equals("C000000001")){
Thread.sleep(1000);
response = activityReconService.getOrderStatus2(orderId);
result = response.jsonPath().getString("code");
i--;
}
Assert.assertEquals(response.jsonPath().getString("data.lottery.type"), "lucky", "校验类型失败");
Assert.assertTrue(response.jsonPath().getString("data.lottery.link").contains("//activity.m.duibatest.com.cn/crecord/recordLuckDetailNew?"));
Assert.assertTrue(response.jsonPath().getString("data.lottery.iosDownloadUrl").contains("activityId=22651"));
Assert.assertTrue(response.jsonPath().getString("data.lottery.iosDownloadUrl").contains("//activity.tuiatest.cn/activity/redirect"));
Assert.assertEquals(response.jsonPath().getString("data.lottery.id"), "15821", "校验id失败");
Assert.assertEquals(response.jsonPath().getString("data.lottery.showUse"), "true", "校验显示按钮失败");
Assert.assertEquals(response.jsonPath().getString("data.lottery.useBtnText"),"马上使用","校验useBtnText失败");
logger.info("校验福袋:link,id,useBtnText成功");
}
}
package http.cases.ActivityReconTest;
import base.DuibaLog;
import base.DuibaTestBase;
import http.service.Activity.ActivityReconService;
import http.service.Activity.ManagerService;
import http.service.Activity.NewActivityService;
import http.service.hd.ActivityService;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.Test;
/**
* Created by zhaoran on 2018/10/25
*/
public class 谢谢参与测试 extends DuibaTestBase {
@Autowired
ActivityReconService activityReconService;
@Autowired
ManagerService managerService;
@Autowired
ActivityService activityService;
private static DuibaLog logger = DuibaLog.getLogger();
private static Integer uid = 3661;
@Test
public void 谢谢参与测试() throws Exception {
logger.info("-------------------------------------活动中奖谢谢参与-------------------------------------");
Response response = this.新活动工具接口传参(uid,"34514","1gffs6mq3");
Assert.assertEquals(response.jsonPath().getString("data.lottery.type"), "thanks", "校验类型失败");
Assert.assertEquals(response.jsonPath().getString("data.lottery.id").isEmpty(), false, "校验id失败");
Assert.assertNotNull(response.jsonPath().getString("data.lottery.id"),"校验id失败");
//校验返回字段
Assert.assertEquals(response.asString().contains("id"),true,"校验id失败");
logger.info("校验type,id成功");
}
public Response 新活动工具接口传参(int uid,String activityId,String token) throws Exception {
Response response = activityReconService.doJoin2(uid,activityId,token);
response.prettyPrint();
String orderId = response.jsonPath().getString("data");
response = activityReconService.getOrderStatus2(uid,orderId);
response.prettyPrint();
String result = String.valueOf(response.jsonPath().getString("code"));
int i= 30;
while(i>0&&(result.equals("C000000001"))){
Thread.sleep(1000);
response = activityReconService.getOrderStatus2(uid,orderId);
result = String.valueOf(response.jsonPath().getString("code"));
i--;
response.prettyPrint();
}
return response;
}
}
\ No newline at end of file
......@@ -69,7 +69,7 @@ public class Exchange_ExchangeTest extends CheckTemplet {
Map<String,String> map = authorization.dafuwengLogin(uid);
Assert.assertEquals(String.valueOf(response.getStatusCode()),"200","活动详情页请求异常");
//实物兑换
response = couponExchangeService.objectExchange(map,"159143","2619","null","z9sydmcs","null");
response = couponExchangeService.objectExchange(map,"159143","2619","null","yrJRr7Cddp2YeQd","null");
// response.prettyPrint();
//校验兑换成功
// Assert.assertEquals(response.jsonPath().getString("success"),"true");
......
......@@ -76,7 +76,7 @@ public class ObjectExchange_ExchangeTest extends CheckTemplet {
Map<String, String> map = authorization.dafuwengLogin(uid);
Assert.assertEquals(String.valueOf(response.getStatusCode()), "200", "活动详情页请求异常");
//实物兑换
response = couponExchangeService.objectExchange(map, "159143", "2619", "null", "z9sydmcs", "null");
response = couponExchangeService.objectExchange(map, "159143", "2619", "null", "yrJRr7Cddp2YeQd", "null");
// response.prettyPrint();
//校验兑换成功
// Assert.assertEquals(response.jsonPath().getString("success"),"true");
......@@ -287,7 +287,7 @@ public class ObjectExchange_ExchangeTest extends CheckTemplet {
Map<String, String> map = authorization.dafuwengLogin(uid);
Assert.assertEquals(String.valueOf(response.getStatusCode()), "200", "活动详情页请求异常");
//实物兑换
response = couponExchangeService.objectExchange(map, "161100", null, "null", "z9sydmcs", "null");
response = couponExchangeService.objectExchange(map, "161100", null, "null", "yrJRr7Cddp2YeQd", "null");
// response.prettyPrint();
//校验兑换成功
// Assert.assertEquals(response.jsonPath().getString("success"),"true");
......@@ -439,7 +439,7 @@ public class ObjectExchange_ExchangeTest extends CheckTemplet {
}
//直充类流量兑换
@Test(description = "直充类流量兑换")
//@Test(description = "直充类流量兑换")
public void 流量兑换() throws Exception {
int uid = 4376;
Thread.sleep(2000);
......
......@@ -151,7 +151,7 @@ public class Qb_兑换流程测试_ExchangeTest extends CheckTemplet {
message = e.toString();
}
logger.info(message);
Assert.assertTrue(message.contains("没有兑换成功"));
Assert.assertTrue(message.contains("已兑完"));
Assert.assertTrue(message.contains("\"success\":false"));
}
......
......@@ -72,16 +72,16 @@ public class 优惠券_兑换流程测试_ExchangeTest extends CheckTemplet {
Object[][] result = null;
if (method.getName().equals("优惠券日期兑换限制测试")) {
result = new Object[][]{
new Object[]{1, "171479", "29538", "69xjl0a", "优惠券日期兑换限制未开始"}, //case1
new Object[]{2, "171480", "29539", "z9sydmcs", "优惠券日期兑换限制进行中"}, //case2
new Object[]{3, "171481", "29540", "cmixdqn", "优惠券日期兑换限制已结束"}, //case2
new Object[]{1, "171479", "29538", "yrJRr7Cddp2YeQd", "优惠券日期兑换限制未开始"}, //case1
new Object[]{2, "171480", "29539", "yrJRr7Cddp2YeQd", "优惠券日期兑换限制进行中"}, //case2
new Object[]{3, "171481", "29540", "yrJRr7Cddp2YeQd", "优惠券日期兑换限制已结束"}, //case2
};
}
if (method.getName().equals("优惠券库存不足测试")) {
result = new Object[][]{
new Object[]{"169775", "29180", "69xjl0a", "优惠券商品库存不足测试"}, //case1
new Object[]{"172163", "29677", "z9sydmcs", "优惠券定向库存不足测试"}, //case2
new Object[]{"174773","30286","qyarwreq","优惠券预分配库存不足测试"},
new Object[]{"169775", "29180", "yrJRr7Cddp2YeQd", "优惠券商品库存不足测试"}, //case1
new Object[]{"172163", "29677", "yrJRr7Cddp2YeQd", "优惠券定向库存不足测试"}, //case2
new Object[]{"174773","30286","yrJRr7Cddp2YeQd","优惠券预分配库存不足测试"},
};
}
......@@ -101,17 +101,17 @@ public class 优惠券_兑换流程测试_ExchangeTest extends CheckTemplet {
}
if (method.getName().equals("自有优惠券会员等级测试")){
result = new Object[][]{
new Object[]{1,"172713","pmqy9","优惠券会员等级范围测试"}, //case1
new Object[]{2,"172715","3bam907y", "优惠券会员特定等级测试"}, //case2
new Object[]{1,"172713","yrJRr7Cddp2YeQd","优惠券会员等级范围测试"}, //case1
new Object[]{2,"172715","yrJRr7Cddp2YeQd", "优惠券会员特定等级测试"}, //case2
};
}
if (method.getName().equals("优惠券地区兑换限制测试")){
result = new Object[][]{
new Object[]{1,"175459","30434","pmqy9","优惠券地区黑名单不可兑测试"}, //case1
new Object[]{2,"175603","30435","3bam907y", "优惠券地区黑名单可兑测试"}, //case2
new Object[]{3,"175604","30436","6dc8ntp", "优惠券地区白名单可兑测试"}, //case3
new Object[]{4,"175605","30437","tvtgya6","优惠券地区白名单不可兑测试"}, //case4
new Object[]{1,"175459","30434","yrJRr7Cddp2YeQd","优惠券地区黑名单不可兑测试"}, //case1
new Object[]{2,"175603","30435","yrJRr7Cddp2YeQd", "优惠券地区黑名单可兑测试"}, //case2
new Object[]{3,"175604","30436","yrJRr7Cddp2YeQd", "优惠券地区白名单可兑测试"}, //case3
new Object[]{4,"175605","30437","yrJRr7Cddp2YeQd","优惠券地区白名单不可兑测试"}, //case4
};
......@@ -218,7 +218,7 @@ public class 优惠券_兑换流程测试_ExchangeTest extends CheckTemplet {
Map<String,String> map = new HashMap<>();
map.put("appItemId","174928");
map.put("itemId","30319");
map.put("token","uvbhjc");
map.put("token","yrJRr7Cddp2YeQd");
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.dafuwengLogin(uid)).params(map).post(url + "/couponExchange/exchange");
response.prettyPrint();
......@@ -385,7 +385,7 @@ public class 优惠券_兑换流程测试_ExchangeTest extends CheckTemplet {
Map<String,String> map = new HashMap<>();
map.put("appItemId","170294");
map.put("itemId","29293");
map.put("token","69xjl0a");
map.put("token","yrJRr7Cddp2YeQd");
try{
//优惠券兑换,用户兑换限制次数1次
......@@ -427,7 +427,7 @@ public class 优惠券_兑换流程测试_ExchangeTest extends CheckTemplet {
Map<String,String> map = new HashMap<>();
map.put("appItemId","171478");
map.put("itemId","29531");
map.put("token","69xjl0a");
map.put("token","yrJRr7Cddp2YeQd");
try{
//优惠券兑换,用户兑换限制次数1次
......@@ -468,7 +468,7 @@ public class 优惠券_兑换流程测试_ExchangeTest extends CheckTemplet {
Map<String,String> map = new HashMap<>();
map.put("appItemId","170295");
map.put("itemId","29294");
map.put("token","69xjl0a");
map.put("token","yrJRr7Cddp2YeQd");
try{
//优惠券兑换,用户兑换限制次数1次
......@@ -562,7 +562,7 @@ public class 优惠券_兑换流程测试_ExchangeTest extends CheckTemplet {
Map<String,String> map = new HashMap<>();
map.put("appItemId","172079");
map.put("itemId","29667");
map.put("token","69xjl0a");
map.put("token","yrJRr7Cddp2YeQd");
//兑换
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.dafuwengLogin(uid)).params(map).post(url + "/couponExchange/exchange");
......@@ -608,7 +608,7 @@ public class 优惠券_兑换流程测试_ExchangeTest extends CheckTemplet {
* @param caseName 用例名称打印
* @throws Exception
*/
@Test(dataProvider = "providerMethod")
//@Test(dataProvider = "providerMethod")
public void 优惠券马上使用按钮测试(int caseNum, String appItemId, String itemId, String caseName)throws Exception{
logger.info(caseName);
......
......@@ -139,7 +139,7 @@ public class 商品订单失败测试_ExchangeTest extends CheckTemplet {
//校验订单状态,校验返回库存和积分
Assert.assertEquals(orderStatus,"fail","校验数据库status失败");
Assert.assertEquals(orderError,"审核不通过(备注:测试订单审核不通过)","校验数据库error失败");
Assert.assertEquals(orderError,"审核不通过(测试订单审核不通过)","校验数据库error失败");
logger.info("校验实物订单审核不通过成功");
Assert.assertEquals(stockNew,stock,"校验stock失败");
......
......@@ -54,7 +54,7 @@ public class 实物_兑换异常测试_ExchangeTest extends CheckTemplet {
Map<String, String> map = authorization.dafuwengLogin(3086);
Assert.assertEquals(String.valueOf(response.getStatusCode()), "200", "活动详情页请求异常");
//实物兑换
response = couponExchangeService.objectExchange(map, "167141", "28515", "null", "z9sydmcs", "null");
response = couponExchangeService.objectExchange(map, "167141", "28515", "null", "yrJRr7Cddp2YeQd", "null");
response.prettyPrint();
//校验兑换成功
// Assert.assertEquals(response.jsonPath().getString("success"),"true");
......@@ -91,7 +91,7 @@ public class 实物_兑换异常测试_ExchangeTest extends CheckTemplet {
Map<String, String> map = authorization.dafuwengLogin(uid);
Assert.assertEquals(String.valueOf(response.getStatusCode()), "200", "活动详情页请求异常");
//实物兑换
Response response1 = couponExchangeService.objectExchange1(map, "167611", "28633", "null", "z9sydmcs", "null");
Response response1 = couponExchangeService.objectExchange1(map, "167611", "28633", "null", "yrJRr7Cddp2YeQd", "null");
response1.prettyPrint();
//校验兑换成功
// Assert.assertEquals(response.jsonPath().getString("success"),"true");
......@@ -132,7 +132,7 @@ public class 实物_兑换异常测试_ExchangeTest extends CheckTemplet {
String message=null;
String succcess = null;
try{
Response response = couponExchangeService.objectExchange1(authorization.dafuwengLogin(uid), "178880", "31050", "null", "z9sydmcs", "null");
Response response = couponExchangeService.objectExchange1(authorization.dafuwengLogin(uid), "178880", "31050", "null", "yrJRr7Cddp2YeQd", "null");
message = response.jsonPath().getString("message");
}catch (Exception e){
......@@ -148,7 +148,7 @@ public class 实物_兑换异常测试_ExchangeTest extends CheckTemplet {
int uid = 3490;
//第一次兑换
Response response = couponExchangeService.objectExchange(authorization.dafuwengLogin(uid), "178879", "31049", "null", "z9sydmcs", "null");
Response response = couponExchangeService.objectExchange(authorization.dafuwengLogin(uid), "178879", "31049", "null", "yrJRr7Cddp2YeQd", "null");
response.prettyPrint();
String orderId = response.jsonPath().getString("orderId");
......@@ -167,7 +167,7 @@ public class 实物_兑换异常测试_ExchangeTest extends CheckTemplet {
}
//第二次兑换
try{
response = couponExchangeService.objectExchange(authorization.dafuwengLogin(uid), "178879", "31049", "null", "z9sydmcs", "null");
response = couponExchangeService.objectExchange(authorization.dafuwengLogin(uid), "178879", "31049", "null", "yrJRr7Cddp2YeQd", "null");
response.prettyPrint();
}catch (Exception e){
......
......@@ -58,13 +58,13 @@ public class 平台券_兑换流程测试_ExchangeTest extends CheckTemplet {
Object[][] result = null;
if (method.getName().equals("平台券库存不足测试")) {
result = new Object[][]{
new Object[]{"73734759122009","n990y8dac","平台券商品库存不足测试"}, //case1
new Object[]{"73734793724984", "s4c0zy","平台券预分配库存不足测试"}, //case2
new Object[]{"73734759122009","yrJRr7Cddp2YeQd","平台券商品库存不足测试"}, //case1
new Object[]{"73734793724984", "yrJRr7Cddp2YeQd","平台券预分配库存不足测试"}, //case2
};
}
if(method.getName().equals("平台券预分配库存测试")){
result = new Object[][]{
new Object[]{"73734759122009","n990y8dac","平台券商品库存不足测试"}, //case1
new Object[]{"73734759122009","yrJRr7Cddp2YeQd","平台券商品库存不足测试"}, //case1
};
}
......@@ -158,7 +158,7 @@ public class 平台券_兑换流程测试_ExchangeTest extends CheckTemplet {
Map<String,String> map = new HashMap<>();
map.put("pcgId","73725292586909");
map.put("token","dnsog");
map.put("token","yrJRr7Cddp2YeQd");
//获取按钮状态
Response detailResponse = appPlatformCouponService.platformDetail(3086,true,"73725292586909");
......@@ -243,7 +243,7 @@ public class 平台券_兑换流程测试_ExchangeTest extends CheckTemplet {
//每日限额用完,无法再次兑换
Map<String,String> map = new HashMap<>();
map.put("pcgId","74735076603359");
map.put("token","dnsog");
map.put("token","yrJRr7Cddp2YeQd");
//获取按钮状态
Response detailResponse = appPlatformCouponService.platformDetail(uid,"74735076603359");
......@@ -282,7 +282,7 @@ public class 平台券_兑换流程测试_ExchangeTest extends CheckTemplet {
//用户限制次数用完,无法兑换
Map<String,String> map = new HashMap<>();
map.put("pcgId","74371944595109");
map.put("token","dnsog");
map.put("token","yrJRr7Cddp2YeQd");
//获取按钮状态
Response detailResponse = appPlatformCouponService.platformDetail(uid,"74371944595109");
......
......@@ -203,7 +203,7 @@ public class 支付宝_兑换流程测试_ExchangeTest extends CheckTemplet {
map.put("realname","沙箱环境");
map.put("degreeId","10");
map.put("itemId","55");
map.put("token","fw7qga0");
map.put("token","yrJRr7Cddp2YeQd");
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.dafuwengLogin(3490)).params(map).post(url+"/alipayExchange/exchange");
response.prettyPrint();
......@@ -213,7 +213,7 @@ public class 支付宝_兑换流程测试_ExchangeTest extends CheckTemplet {
logger.info("兑换后的开发者账户余额:" + remainMoneyNew);
Assert.assertEquals(exchangeText,"已兑完","校验马上兑换按钮状态失败");
Assert.assertEquals(response.jsonPath().getString("message"),"对不起,没有兑换成功,请挑选其他吧(2)","校验message失败");
Assert.assertEquals(response.jsonPath().getString("message"),"已兑完","校验message失败");
Assert.assertEquals(remainMoneyNew,remainMoney,"校验开发者账户余额失败");
logger.info("校验支付宝商品余额不足成功");
......@@ -250,7 +250,7 @@ public class 支付宝_兑换流程测试_ExchangeTest extends CheckTemplet {
map.put("realname","沙箱环境");
map.put("degreeId","1");
map.put("itemId","55");
map.put("token","fw7qga0");
map.put("token","yrJRr7Cddp2YeQd");
//会员符合条件,兑换
Response successResponse = this.支付宝兑换(3574,"peeulk6392@sandbox.com","沙箱环境","1");
......@@ -282,7 +282,7 @@ public class 支付宝_兑换流程测试_ExchangeTest extends CheckTemplet {
map.put("realname",realName);
map.put("degreeId",degreeId);
map.put("itemId","55");
map.put("token","fw7qga0");
map.put("token","yrJRr7Cddp2YeQd");
try{
//支付宝兑换
......
......@@ -242,7 +242,7 @@ public class 虚拟商品_兑换异常测试_ExchangeTest extends CheckTemplet {
}
}
@Test(description = "虚拟商品自定义兑换按钮文案马上使用按钮")
//@Test(description = "虚拟商品自定义兑换按钮文案马上使用按钮")
public void 虚拟商品自定义兑换按钮文案马上使用按钮() throws Exception {
logger.info("虚拟商品马上使用按钮验证开始");
//创建虚拟商品的时候,有自定义兑换按钮文案的文案设置,将文案设置成马上使用
......@@ -419,7 +419,7 @@ public class 虚拟商品_兑换异常测试_ExchangeTest extends CheckTemplet {
}
@Test(description = "自动化】虚拟商品日期兑换时间进行中")
//@Test(description = "自动化】虚拟商品日期兑换时间进行中")
public void 虚拟商品日期兑换时间进行中() throws Exception {
logger.info("【自动化】虚拟商品日期兑换时间进行中开始验证");
//创建虚拟商品的时候,有自定义兑换按钮文案的文案设置,将文案设置成马上使用
......
......@@ -56,7 +56,7 @@ public class 异常订单测试_ExchangeTest extends DuibaTestBase {
Map<String, String> map = authorization.dafuwengLogin(uid,true);
Assert.assertEquals(String.valueOf(response.getStatusCode()), "200", "活动详情页请求异常");
//实物兑换
Response response1 = couponExchangeService.objectExchange1(map, "167611", "28633", "null", "z9sydmcs", "null");
Response response1 = couponExchangeService.objectExchange1(map, "167611", "28633", "null", "yrJRr7Cddp2YeQd", "null");
response1.prettyPrint();
String message2 = response1.jsonPath().getString("message");
......@@ -71,7 +71,7 @@ public class 异常订单测试_ExchangeTest extends DuibaTestBase {
Map<String, String> map = authorization.dafuwengLogin(4819);
Assert.assertEquals(String.valueOf(response.getStatusCode()), "200", "活动详情页请求异常");
//实物兑换
Response response2 = couponExchangeService.objectExchange2(map, "179139", "null", "null", "z9sydmcs", "null");
Response response2 = couponExchangeService.objectExchange2(map, "179139", "null", "null", "yrJRr7Cddp2YeQd", "null");
response2.prettyPrint();
String message3 = response2.jsonPath().getString("message");
......@@ -91,7 +91,7 @@ public class 异常订单测试_ExchangeTest extends DuibaTestBase {
// response.prettyPrint();
Assert.assertEquals(String.valueOf(response.getStatusCode()), "200", "活动详情页请求异常");
//实物兑换
Response response2 = couponExchangeService.objectExchange2(userCookies, "179139", "null", "null", "z9sydmcs", "null");
Response response2 = couponExchangeService.objectExchange2(userCookies, "179139", "null", "null", "yrJRr7Cddp2YeQd", "null");
response2.prettyPrint();
String message3 = response2.jsonPath().getString("message");
......@@ -110,7 +110,7 @@ public class 异常订单测试_ExchangeTest extends DuibaTestBase {
public void run() {
logger.info("开始执行 ");
try {
Response response2 = couponExchangeService.objectExchange2(userCookies, "179139", "null", "null", "z9sydmcs", "null");
Response response2 = couponExchangeService.objectExchange2(userCookies, "179139", "null", "null", "yrJRr7Cddp2YeQd", "null");
} catch (Exception e) {
e.printStackTrace();
}
......
......@@ -149,23 +149,33 @@ public class 抽奖异常测试_DuibaTest extends DuibaTestBase {
@Test(dataProvider = "providerMethod")
public void 未登录抽奖测试(Map<String,String> data) throws Exception {
logger.info("-------------------------------------"+data.get("casename")+"-------------------------------------");
//获取未登录场景cookie
Response responses = authorization.autoLogin();
//进行接口测试传参
Map<String,String> map = responses.getCookies();
logger.info("cookies:"+map.toString());
if(responses.getDetailedCookies()==null)logger.info("cookies = = null");
Response response = newActivityService.doJoinMap(map,data.get("token"),data.get("activityId"));
// Response response = newActivityService.doJoin(responses.getDetailedCookies(),data.get("token"),data.get("activityId"));
response.prettyPrint();
String success = String.valueOf(response.jsonPath().getString("success"));
//根据case选择校验项
if (success.equals("false")){
if (data.get("activityId").equals("18587")){
//获取未登录场景cookie
Response responses = authorization.autoLogin();
//进行接口测试传参
Map<String,String> map = responses.getCookies();
logger.info("cookies:"+map.toString());
if(responses.getDetailedCookies()==null)logger.info("cookies = = null");
Response response = newActivityService.doJoinMap(map,data.get("token"),data.get("activityId"));
response.prettyPrint();
String success = String.valueOf(response.jsonPath().getString("success"));
Assert.assertEquals(response.jsonPath().getString("message"),"请先登录","校验message失败");
Assert.assertEquals(response.jsonPath().getString("status"), "18", "校验status失败");
Assert.assertEquals(response.jsonPath().getString("status"),"18","校验status失败");
logger.info("未登录状态下无免费次数抽奖校验:message,status成功");
}
if (success.equals("true")){
if (data.get("activityId").equals("18586")){
//获取未登录场景cookie
Response responses = newActivityService.indexOpenbs("18586");
//进行接口测试传参
Map<String,String> map = responses.getCookies();
logger.info("cookies:"+map.toString());
if(responses.getDetailedCookies()==null)logger.info("cookies = = null");
Response response = newActivityService.doJoinMap(map,data.get("token"),data.get("activityId"));
response.prettyPrint();
String orderId = response.jsonPath().getString("orderId");
response = newActivityService.getOrderStatus(responses.getDetailedCookies(),orderId);
response.prettyPrint();
......
package http.service.Activity;
import base.DuibaLog;
import http.service.Authorization;
import io.restassured.http.Cookies;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.testng.Assert;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import static io.restassured.RestAssured.given;
@Service
public class ActivityReconService {
private String url = "http://activity.m.duibatest.com.cn";
private String url2 = "http://home.m.duibatest.com.cn";
private DuibaLog logger = DuibaLog.getLogger();
@Autowired
Authorization authorization;
public Response getHdtoolConfig( String actId,String hdToolId) throws Exception{
Map<String,String> map = new HashMap<>();
map.put("actId",actId);
map.put("hdType","duiba");
map.put("hdToolId",hdToolId);
logger.info("请求/hdtool/getHdtoolConfig接口");
Response response = given().cookies(authorization.dafuwengLogin(2720)).params(map).post(url+"/hdtool/getHdtoolConfig");
try{
Assert.assertEquals(response.jsonPath().getString("success"),"true");
}catch(Exception e){
throw new Exception("/hdtool/getHdtoolConfig接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/hdtool/getHdtoolConfig接口失败,返回信息:"+response.asString());
}
return response;
}
public Response prizeDetail( String itemId) throws Exception{
Map<String,String> map = new HashMap<>();
map.put("itemId",itemId);
map.put("appId","2239");
logger.info("请求/hdtool/prizeDetail接口");
Response response = given().cookies(authorization.dafuwengLogin(2720)).params(map).post(url+"/hdtool/prizeDetail");
try{
Assert.assertEquals(response.jsonPath().getString("success"),"true");
}catch(Exception e){
throw new Exception("/hdtool/prizeDetail接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/hdtool/prizeDetail接口失败,返回信息:"+response.asString());
}
return response;
}
public Response doJoin(Cookies cookies, String token,String activityId) throws Exception {
Map<String,String> map = new HashMap<>();
map.put("token",token);
map.put("activityId",activityId);
map.put("oaId",activityId);
logger.info("请求hdtool/recon/doJoin接口,activityId="+activityId);
logger.info("url:"+url+"hdtool/recon/doJoin");
Response response = given().cookies(cookies).params(map).post(url+"/hdtool/recon/doJoin");
try{
Assert.assertEquals(String.valueOf(response.getStatusCode()),"200");
logger.info("hdtool/recon/doJoin接口成功,返回信息:"+response.asString());
}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 doJoinMap(Map cookies, String token,String activityId) throws Exception {
Map<String,String> map = new HashMap<>();
map.put("token",token);
map.put("activityId",activityId);
map.put("oaId",activityId);
logger.info("请求/hdtool/recon/doJoin接口,activityId="+activityId);
logger.info("url:"+url+"/hdtool/recon/doJoin");
Response response = given().cookies(cookies).params(map).post(url+"/hdtool/recon/doJoin");
try{
Assert.assertEquals(String.valueOf(response.getStatusCode()),"200");
logger.info("/hdtool/recon/doJoin接口成功,返回信息:"+response.asString());
}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 login(Map cookies, String dpm) throws Exception {
Map<String,String> map = new HashMap<>();
map.put("dpm",dpm);
logger.info("请求/hdtool/login接口");
logger.info("url:"+url+"/hdtool/login");
Response response = given().cookies(cookies).params(map).post(url+"/hdtool/login");
try{
Assert.assertEquals(String.valueOf(response.getStatusCode()),"200");
logger.info("/hdtool/login接口成功,返回信息:"+response.asString());
}catch(Exception e){
throw new Exception("/hdtool/login接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/hdtool/login接口失败,返回信息:"+response.asString());
}
return response;
}
public Response doJoin2( String activityId,String token) throws Exception{
Map<String,String> map = new HashMap<>();
map.put("activityId",activityId);
map.put("token",token);
logger.info("请求/hdtool/doJoin接口,activityId="+activityId);
Response response = given().cookies(authorization.dafuwengLogin(2720)).params(map).post(url+"/hdtool/recon/doJoin");
try{
Assert.assertEquals(response.jsonPath().getString("success"),"true");
}catch(Exception e){
throw new Exception("/hdtool/doJoin接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/hdtool/doJoin接口失败,返回信息:"+response.asString());
}
return response;
}
public Response doJoin2( int uid,String activityId,String token) throws Exception{
Map<String,String> map = new HashMap<>();
map.put("activityId",activityId);
map.put("token",token);
logger.info("请求hdtool/recon/doJoin接口,activityId="+activityId);
Response response = given().cookies(authorization.dafuwengLogin(uid)).params(map).post(url+"/hdtool/recon/doJoin");
try{
Assert.assertEquals(response.jsonPath().getString("success"),"true");
}catch(Exception e){
throw new Exception("/hdtool/doJoin接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/hdtool/doJoin接口失败,返回信息:"+response.asString());
}
return response;
}
public Response doJoin2( int uid,String activityId,String token,String orderId) throws Exception{
Map<String,String> map = new HashMap<>();
map.put("activityId",activityId);
map.put("token",token);
map.put("againOrderId",orderId);
logger.info("请求/hdtool/recon/doJoin接口,activityId="+activityId);
Response response = given().cookies(authorization.dafuwengLogin(uid)).params(map).post(url+"/hdtool/recon/doJoin");
try{
Assert.assertEquals(response.jsonPath().getString("success"),"true");
}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 doJoin3( String activityId,String token,String collectRuleId) throws Exception{
Map<String,String> map = new HashMap<>();
map.put("activityId",activityId);
map.put("token",token);
// map.put("collectRuleId",collectRuleId);
logger.info("请求/hdtool/doJoin接口,activityId="+activityId);
Response response = given().cookies(authorization.dafuwengLogin(2720)).params(map).post(url+"/hdtool/doJoin");
try{
Assert.assertEquals(response.jsonPath().getString("success"),"true");
}catch(Exception e){
throw new Exception("/hdtool/doJoin接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/hdtool/doJoin接口失败,返回信息:"+response.asString());
}
return response;
}
public Response doJoin4( String activityId,String token,String collectRuleId,Integer uid) throws Exception{
Map<String,String> map = new HashMap<>();
map.put("activityId",activityId);
map.put("token",token);
// map.put("collectRuleId",collectRuleId);
logger.info("请求/hdtool/doJoin接口,activityId="+activityId);
Response response = given().cookies(authorization.dafuwengLogin(uid)).params(map).post(url+"/hdtool/doJoin");
try{
Assert.assertEquals(response.jsonPath().getString("success"),"true");
}catch(Exception e){
throw new Exception("/hdtool/doJoin接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/hdtool/doJoin接口失败,返回信息:"+response.asString());
}
return response;
}
public Response doJoin5( String activityId,String token,String collectRuleId,Integer uid) throws Exception{
Map<String,String> map = new HashMap<>();
map.put("activityId",activityId);
map.put("token",token);
map.put("collectRuleId",collectRuleId);
logger.info("请求/hdtool/doJoin接口,activityId="+activityId);
Response response = given().cookies(authorization.dafuwengLogin(uid)).params(map).post(url+"/hdtool/doJoin");
try{
Assert.assertEquals(response.jsonPath().getString("success"),"true");
}catch(Exception e){
throw new Exception("/hdtool/doJoin接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/hdtool/doJoin接口失败,返回信息:"+response.asString());
}
return response;
}
public Response doJoin5( int uid,String activityId) throws Exception{
Map<String,String> map = new HashMap<>();
map.put("activityId",activityId);
map.put("oaId",activityId);
logger.info("请求/hdtool/doJoin接口,activityId="+activityId);
Response response = given().cookies(authorization.dafuwengLogin(uid)).params(map).post(url+"/question/doJoin");
try{
Assert.assertEquals(response.jsonPath().getString("success"),"true");
}catch(Exception e){
throw new Exception("/hdtool/doJoin接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/hdtool/doJoin接口失败,返回信息:"+response.asString());
}
return response;
}
public Response getOrderStatus(Cookies cookies,String orderId) throws Exception {
Map<String,String> map = new HashMap<>();
map.put("orderId",orderId);
logger.info("请求/hdtool/recon/getOrderStatus接口,orderId="+orderId);
Response response = given().cookies(cookies).cookies(authorization.dafuwengLogin(2720)).params(map).get(url+"/hdtool/recon/getOrderStatus");
try{
Assert.assertEquals(response.jsonPath().getString("success"),"true");
}catch(Exception e){
throw new Exception("/hdtool/recon/getOrderStatus接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/hdtool/recon/getOrderStatus接口失败,返回信息:"+response.asString());
}
return response;
}
public Response getOrderStatus2(String orderId) throws Exception {
Map<String,String> map = new HashMap<>();
map.put("orderId",orderId);
logger.info("请求/hdtool/recon/getOrderStatus接口,orderId="+orderId);
Response response = given().cookies(authorization.dafuwengLogin(2720)).params(map).get(url+"/hdtool/recon/getOrderStatus");
try{
//Assert.assertEquals(response.jsonPath().getString("success"),"true");
Assert.assertEquals(String.valueOf(response.getStatusCode()),"200");
}catch(Exception e){
throw new Exception("/hdtool/recon/getOrderStatus接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/hdtool/recon/getOrderStatus接口失败,返回信息:"+response.asString());
}
return response;
}
public Response getOrderStatus2(int uid,String orderId) throws Exception {
Map<String,String> map = new HashMap<>();
map.put("orderId",orderId);
logger.info("请求/hdtool/recon/getOrderStatus接口,orderId="+orderId);
Response response = given().cookies(authorization.dafuwengLogin(uid)).params(map).get(url+"/hdtool/recon/getOrderStatus");
try{
//Assert.assertEquals(response.jsonPath().getString("success"),"true");
Assert.assertEquals(String.valueOf(response.getStatusCode()),"200");
}catch(Exception e){
throw new Exception("/hdtool/recon/getOrderStatus接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/hdtool/recon/getOrderStatus接口失败,返回信息:"+response.asString());
}
return response;
}
public Response getOrderStatus21(String orderId,Integer uid) throws Exception {
Map<String,String> map = new HashMap<>();
map.put("orderId",orderId);
logger.info("请求/hdtool/getOrderStatus接口,orderId="+orderId);
Response response = given().cookies(authorization.dafuwengLogin(uid)).params(map).post(url+"/hdtool/getOrderStatus");
try{
//Assert.assertEquals(response.jsonPath().getString("success"),"true");
Assert.assertEquals(String.valueOf(response.getStatusCode()),"200");
}catch(Exception e){
throw new Exception("/hdtool/getOrderStatus接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/hdtool/getOrderStatus接口失败,返回信息:"+response.asString());
}
return response;
}
public Response getOrderStatus2(String orderId,String device) throws Exception {
Map<String,String> map = new HashMap<>();
map.put("orderId",orderId);
Map<String,String> maphead = new HashMap<>();
if ( device.equals("iOS")) {
maphead.put("User-Agent", "Mozilla/5.0 (iPhone; CPU iPhone OS 10_3 like Mac OS X) AppleWebKit/602.1.50 (KHTML, like Gecko) CriOS/56.0.2924.75 Mobile/14E5239e Safari/602.1");
}else{
maphead.put("User-Agent", "Mozilla/5.0 (Linux; Android 5.0; SM-G900P Build/LRX21T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.108 Mobile Safari/537.36");
}
logger.info("请求/hdtool/recon/getOrderStatus接口,orderId="+orderId);
Response response = given().headers(maphead).cookies(authorization.dafuwengLogin(2720)).params(map).get(url+"/hdtool/recon/getOrderStatus");
try{
Assert.assertEquals(response.jsonPath().getString("success"),"true");
}catch(Exception e){
throw new Exception("/hdtool/recon/getOrderStatus接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/hdtool/recon/getOrderStatus接口失败,返回信息:"+response.asString());
}
return response;
}
public Response getOrderStatus3(String orderId) throws Exception {
Map<String,String> map = new HashMap<>();
map.put("orderId",orderId);
logger.info("请求/collectRule/getOrderStatus接口,orderId="+orderId);
Response response = given().cookies(authorization.dafuwengLogin(2720)).params(map).post(url+"/collectRule/getOrderStatus");
try{
Assert.assertEquals(response.jsonPath().getString("success"),"true");
}catch(Exception e){
throw new Exception("/collectRule/getOrderStatus接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/collectRule/getOrderStatus接口失败,返回信息:"+response.asString());
}
return response;
}
public Response getOrderStatus31(String orderId,Integer uid) throws Exception {
Map<String,String> map = new HashMap<>();
map.put("orderId",orderId);
logger.info("请求/collectRule/getOrderStatus接口,orderId="+orderId);
Response response = given().cookies(authorization.dafuwengLogin(uid)).params(map).post(url+"/collectRule/getOrderStatus");
response.prettyPrint();
try{
Assert.assertEquals(response.jsonPath().getString("success"),"true");
}catch(Exception e){
throw new Exception("/collectRule/getOrderStatus接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/collectRule/getOrderStatus接口失败,返回信息:"+response.asString());
}
return response;
}
//自有答题——获取订单状态
public Response getOrderStatus(int uid,String orderId) throws Exception {
Map<String,String> map = new HashMap<>();
map.put("orderId",orderId);
logger.info("请求/question/getOrderStatus接口,orderId="+orderId);
Response response = given().cookies(authorization.dafuwengLogin(uid)).params(map).post(url+"/question/getOrderStatus");
response.prettyPrint();
try{
Assert.assertEquals(response.jsonPath().getString("success"),"true");
}catch(Exception e){
throw new Exception("/question/getOrderStatus接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/question/getOrderStatus接口失败,返回信息:"+response.asString());
}
return response;
}
//闯关
public Response throughSubmit(String orderId) throws Exception {
Map<String,String> map = new HashMap<>();
map.put("orderId",orderId);
logger.info("请求/hdtool/throughSubmit接口,orderId="+orderId);
Response response = given().cookies(authorization.dafuwengLogin(2720)).params(map).post(url+"/hdtool/throughSubmit");
try{
Assert.assertEquals(response.jsonPath().getString("success"),"true");
//Assert.assertEquals(String.valueOf(response.getStatusCode()),"200");
}catch(Exception e){
throw new Exception("/hdtool/throughSubmit接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/hdtool/throughSubmit接口失败,返回信息:"+response.asString());
}
return response;
}
//访问活动工具首页接口
public Response index(String atcId) throws Exception {
Map<String,String> map = new HashMap<>();
map.put("id",atcId);
logger.info("请求/hdtool/index接口,id=" + atcId);
Response response = given().cookies(authorization.dafuwengLogin(2720)).params(map).post(url + "/hdtool/index");
try{
Assert.assertEquals(String.valueOf(response.getStatusCode()),"200","活动页打开异常");
}catch(Exception e){
throw new Exception("/hdtool/index接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/hdtool/index接口失败,返回信息:"+response.asString());
}
return response;
}
public Response indexOpenbs(String atcId) throws Exception {
Map<String,String> map = new HashMap<>();
map.put("id",atcId);
map.put("appKey","2wGQc3MZaQsqYFWcX4gguya5PnnS");
map.put("openBs","");
logger.info("请求/hdtool/index接口,id=" + atcId);
Response response = given().cookies(authorization.dafuwengLogin(2720)).params(map).post(url + "/hdtool/index");
try{
Assert.assertEquals(String.valueOf(response.getStatusCode()),"200","活动页打开异常");
}catch(Exception e){
throw new Exception("/hdtool/index接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/hdtool/index接口失败,返回信息:"+response.asString());
}
return response;
}
//访问答题活动首页接口
public Response index_dt(String atcId) throws Exception {
Map<String,String> map = new HashMap<>();
map.put("id",atcId);
logger.info("请求/question/index接口,id=" + atcId);
Response response = given().cookies(authorization.dafuwengLogin(2720)).params(map).post(url + "/question/index");
try{
Assert.assertEquals(String.valueOf(response.getStatusCode()),"200","活动页打开异常");
}catch(Exception e){
throw new Exception("/question/index接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/question/index接口失败,返回信息:"+response.asString());
}
return response;
}
public Response redirect(Cookies cookies,String dcm,String dpm,String url){
Map<String,String> map = new HashMap<>();
map.put("dcm",dcm);
map.put("dpm",dpm);
map.put("url",url);
Response response = given().cookies(cookies).params(map).get(url+"/log/redirect");
return response;
}
public Response doTakePrize(int uid,String type,String recordId) throws Exception {
Map<String,String> map = new HashMap<>();
if (type.equals("phonebill")){
map.put("phone","15868174769");
map.put("mobile","中国移动");
map.put("province","浙江");
map.put("recordId",recordId);
map.put("token","3amxkp");
}
if (type.equals("alipay")){
map.put("alipay","psvmue9607@sandbox.com");
map.put("realname","沙箱环境");
map.put("recordId",recordId);
map.put("token","12mvxkef");
}
if (type.equals("object")){
map.put("addrName","胡梦新");
map.put("addrPhone","18258853242");
map.put("addrProvince","浙江省");
map.put("addrCity","杭州市");
map.put("addrArea","西湖区");
map.put("addrDetail","数娱大厦");
map.put("recordId",recordId);
map.put("token","12mvxkef");
}
if (type.equals("qb")){
map.put("qq","972900096");
map.put("recordId",recordId);
map.put("token","77hi27wz");
}
logger.info("请求/activity/doTakePrize接口");
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.dafuwengLogin(uid)).params(map).post(url+"/activity/doTakePrize");
try{
Assert.assertEquals(response.jsonPath().getString("success"),"true");
}catch(Exception e){
throw new Exception("/activity/doTakePrize接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/activity/doTakePrize接口失败,返回信息:"+response.asString());
}
return response;
}
//自定义答题活动--提交答案
public void submit(String orderId) throws Exception {
Map<String,String> map = new HashMap<>();
map.put("orderId",orderId);
map.put("answerData","[{\"id\":465,\"option\":3}]");
logger.info("请求/hdtool/submit接口,orderId="+orderId);
Response response = given().cookies(authorization.dafuwengLogin(2720)).params(map).post(url+"/hdtool/submit");
try{
Assert.assertEquals(response.jsonPath().getString("success"),"true");
}catch(Exception e){
throw new Exception("/hdtool/submit接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/hdtool/submit接口失败,返回信息:"+response.asString());
}
}
//自有答题活动--提交答案
public Response submit(int uid,String orderId,String token,String ans1,String ans2) throws Exception {
Map<String,String> map = new HashMap<>();
map.put("orderId",orderId);
map.put("token",token);
map.put("answerData","[{\"id\":2353,\"option\":"+ans1+"},{\"id\":2354,\"option\":"+ans2+"}]");
logger.info("请求/question/submit接口,orderId="+orderId);
Response response = given().cookies(authorization.dafuwengLogin(uid)).params(map).post(url+"/question/submit");
try{
Assert.assertEquals(String.valueOf(response.getStatusCode()),"200","接口请求异常");
}catch(Exception e){
throw new Exception("/question/submit接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/question/submit接口失败,返回信息:"+response.asString());
}
return response;
}
//自定义活动--增加免费抽奖次数接口
public Response addtimes(String addCount,String activityId,String activityType) throws Exception {
Map<String,String> map = new HashMap<>();
map.put("addCount",addCount);
map.put("activityId",activityId);
map.put("activityType",activityType);
map.put("timestamp",Long.toString(new Date().getTime()));
logger.info(Long.toString(new Date().getTime()));
logger.info("请求 /activityVist/addTimesForActivity接口");
Response response = given().cookies(authorization.dafuwengLogin(2720)).params(map).post(url+"/activityVist/addTimesForActivity");
try{
Assert.assertEquals(response.jsonPath().getString("success"),"true");
}catch(Exception e){
throw new Exception("/activityVist/addTimesForActivity接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/activityVist/addTimesForActivity接口失败,返回信息:"+response.asString());
}
return response;
}
public Response ajaxElement(String hdType,String hdToolId,String actId,String preview) throws Exception {
Map<String,String> map = new HashMap<>();
map.put("hdType",hdType);
map.put("hdToolId",hdToolId);
map.put("actId",actId);
map.put("preview",preview);
// logger.info("请求 /hdtool/ajaxElement接口");
Response response = given().cookies(authorization.dafuwengLogin(2720)).params(map).post(url+"/hdtool/ajaxElement");
try{
Assert.assertEquals(response.jsonPath().getString("success"),"true");
}catch(Exception e){
throw new Exception("/hdtool/ajaxElement接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/hdtool/ajaxElement接口失败,返回信息:"+response.asString());
}
return response;
}
public Response ajaxElement(int uid,String hdType,String hdToolId,String actId,String preview) throws Exception {
Map<String,String> map = new HashMap<>();
map.put("hdType",hdType);
map.put("hdToolId",hdToolId);
map.put("actId",actId);
map.put("preview",preview);
logger.info("请求 /question/ajaxElement接口");
Response response = given().cookies(authorization.dafuwengLogin(uid)).params(map).post(url+"/question/ajaxElement");
try{
Assert.assertEquals(response.jsonPath().getString("success"),"true");
}catch(Exception e){
throw new Exception("/question/ajaxElement接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/question/ajaxElement接口失败,返回信息:"+response.asString());
}
return response;
}
public Response ajaxElement(String hdToolId,String actId ) throws Exception{
Map<String, String> map = new HashMap<>();
map.put("hdToolId",hdToolId);
map.put("actId",actId);
logger.info("请求/hdtool/ajaxElement接口");
Response response = given().cookies(authorization.dafuwengLogin(2720)).params(map).get(url+"/hdtool/ajaxElement");
try{
Assert.assertEquals(response.jsonPath().getString("success"),"true");
}catch(Exception e){
throw new Exception("/hdtool/ajaxElement接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/hdtool/ajaxElement接口失败,返回信息:"+response.asString());
}
return response;
}
public Response ajaxElement(int uid, String hdToolId,String actId ) throws Exception{
Map<String, String> map = new HashMap<>();
map.put("duibaId",hdToolId);
map.put("activityId",actId);
logger.info("请求/hdtool/recon/ajaxElement接口");
Response response = given().cookies(authorization.dafuwengLogin(uid)).params(map).get(url+"/hdtool/recon/ajaxElement");
try{
Assert.assertEquals(response.jsonPath().getString("success"),"true");
}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 getRecommend(String atcId) throws Exception {
Response response = given().cookies(authorization.dafuwengLogin(2720)).param("operatingActivityId",atcId).get(url+"/recommend/getRecommendSkin");
String recommendid = response.jsonPath().getString("recommendSkin.id");
Map<String,String> map = new HashMap<>();
map.put("operatingActivityId",atcId);
map.put("requestType","activity");
map.put("recommendSkinId",recommendid);
response = given().cookies(authorization.dafuwengLogin(2720)).params(map).get(url+"/recommend/getRecommend");
try{
Assert.assertEquals(response.jsonPath().getString("success"),"true");
}catch(Exception e){
throw new Exception("/recommend/getRecommend接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/recommend/getRecommend接口失败,返回信息:"+response.asString());
}
return response;
}
public Response getRecommend2(String atcId) throws Exception {
Map<String,String> map = new HashMap<>();
map.put("operatingActivityId",atcId);
map.put("requestType","activity");
Response response = given().cookies(authorization.dafuwengLogin(2720)).params(map).get(url+"/recommend/getRecommend");
try{
Assert.assertEquals(response.jsonPath().getString("success"),"true");
}catch(Exception e){
throw new Exception("/recommend/getRecommend接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/recommend/getRecommend接口失败,返回信息:"+response.asString());
}
return response;
}
public Response openCollectGoodsPrize( String collectRuleId,String actId) throws Exception{
Map<String,String> map = new HashMap<>();
map.put("collectRuleId",collectRuleId);
map.put("actId",actId);
logger.info("请求/collectRule/openCollectGoodsPrize接口,activityId="+actId);
Response response = given().cookies(authorization.dafuwengLogin(2720)).params(map).get(url+"/collectRule/openCollectGoodsPrize");
try{
Assert.assertEquals(response.jsonPath().getString("success"),"true");
}catch(Exception e){
throw new Exception("/collectRule/openCollectGoodsPrize接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/collectRule/openCollectGoodsPrize接口失败,返回信息:"+response.asString());
}
return response;
}
public Response openCollectGoodsPrize3( String collectRuleId,String actId,Integer uid) throws Exception{
Map<String,String> map = new HashMap<>();
map.put("collectRuleId",collectRuleId);
map.put("actId",actId);
logger.info("请求/collectRule/openCollectGoodsPrize接口,activityId="+actId);
Response response = given().cookies(authorization.dafuwengLogin(uid)).params(map).get(url+"/collectRule/openCollectGoodsPrize");
try{
Assert.assertEquals(response.jsonPath().getString("success"),"true");
}catch(Exception e){
throw new Exception("/collectRule/openCollectGoodsPrize接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/collectRule/openCollectGoodsPrize接口失败,返回信息:"+response.asString());
}
return response;
}
public Response openCollectGoodsPrize2( String collectRuleId,String actId,String message) throws Exception{
Map<String,String> map = new HashMap<>();
map.put("collectRuleId",collectRuleId);
map.put("actId",actId);
logger.info("请求/collectRule/openCollectGoodsPrize接口,activityId="+actId);
Response response = given().cookies(authorization.dafuwengLogin(2720)).params(map).get(url+"/collectRule/openCollectGoodsPrize");
try{
Assert.assertEquals(response.jsonPath().getString("success"),"false");
Assert.assertEquals(response.jsonPath().getString("message"),message,"错误message校验失败");
}catch(Exception e){
throw new Exception("/collectRule/openCollectGoodsPrize接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/collectRule/openCollectGoodsPrize接口失败,返回信息:"+response.asString());
}
return response;
}
public Response getCollectGoodsInfo(String collectRuleId) throws Exception{
Map<String, String> map = new HashMap<>();
map.put("collectRuleId",collectRuleId);
logger.info("请求/collectRule/getCollectGoodsInfo接口,collectRuleId="+collectRuleId);
Response response = given().cookies(authorization.dafuwengLogin(2720)).params(map).get(url+"/collectRule/getCollectGoodsInfo");
try{
Assert.assertEquals(response.jsonPath().getString("success"),"true");
}catch(Exception e){
throw new Exception("/collectRule/getCollectGoodsInfo接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/collectRule/getCollectGoodsInfo接口失败,返回信息:"+response.asString());
}
return response;
}
public Response getCollectGoodsInfo2(String collectRuleId,Integer uid) throws Exception{
Map<String, String> map = new HashMap<>();
map.put("collectRuleId",collectRuleId);
logger.info("请求/collectRule/getCollectGoodsInfo接口,collectRuleId="+collectRuleId);
Response response = given().cookies(authorization.dafuwengLogin(uid)).params(map).get(url+"/collectRule/getCollectGoodsInfo");
try{
Assert.assertEquals(response.jsonPath().getString("success"),"true");
}catch(Exception e){
throw new Exception("/collectRule/getCollectGoodsInfo接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/collectRule/getCollectGoodsInfo接口失败,返回信息:"+response.asString());
}
return response;
}
//获取活动分享码
public Response getShareCode(String activityId,String activityType) throws Exception{
Map<String, String> map = new HashMap<>();
map.put("activityId",activityId);
map.put("activityType",activityType);
logger.info("请求/activtyShareCode/getShareCode接口");
Response response = given().cookies(authorization.dafuwengLogin(2720)).params(map).post(url+"/activtyShareCode/getShareCode");
try{
Assert.assertEquals(response.jsonPath().getString("success"),"true");
}catch(Exception e){
throw new Exception("/activtyShareCode/getShareCode接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/activtyShareCode/getShareCode接口失败,返回信息:"+response.asString());
}
return response;
}
//助力抽奖
public Response helpShareCodeV2(int userId,String clGoodsRuleId,String activityId,String activityType,String shareCode) throws Exception{
Map<String, String> map = new HashMap<>();
map.put("clGoodsRuleId",clGoodsRuleId);
map.put("activityId",activityId);
map.put("activityType",activityType);
map.put("shareCode",shareCode);
logger.info("请求/activtyShareCode/helpShareCodeV2接口");
Response response = given().cookies(authorization.dafuwengLogin(userId,true)).params(map).post(url+"/activtyShareCode/helpShareCodeV2");
try{
Assert.assertEquals(String.valueOf(response.getStatusCode()),"200","接口请求异常");
}catch(Exception e){
throw new Exception("/activtyShareCode/helpShareCodeV2接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/activtyShareCode/helpShareCodeV2接口失败,返回信息:"+response.asString());
}
authorization.dafuwengLogin(2720,true);
return response;
}
//邀请码抽奖
public Response doHelp(int userId,String activityId,String activityType,String shareCode) throws Exception{
Map<String, String> map = new HashMap<>();
map.put("activityId",activityId);
map.put("activityType",activityType);
map.put("shareCode",shareCode);
logger.info("请求/activtyShareCode/doHelp接口");
Response response = given().cookies(authorization.dafuwengLogin(userId,true)).params(map).post(url+"/activtyShareCode/doHelp");
try{
Assert.assertEquals(String.valueOf(response.getStatusCode()),"200","接口请求异常");
}catch(Exception e){
throw new Exception("/activtyShareCode/doHelp接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/activtyShareCode/doHelp接口失败,返回信息:"+response.asString());
}
authorization.dafuwengLogin(2720,true);
return response;
}
//邀请码订单开奖
public Response inviteBonusRecord(String data,int userId) throws Exception{
logger.info("请求/activtyShareCode/inviteBonusRecord接口");
Response response = given().cookies(authorization.dafuwengLogin(userId,true)).get(url+"/activtyShareCode/inviteBonusRecord/"+data);
try{
Assert.assertEquals(String.valueOf(response.getStatusCode()),"200","接口请求异常");
}catch(Exception e){
throw new Exception("/activtyShareCode/inviteBonusRecord,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/activtyShareCode/inviteBonusRecord,返回信息:"+response.asString());
}
authorization.dafuwengLogin(2720,true);
return response;
}
// public static void main(String[] args) {
// NewtoolsService service = new NewtoolsService();
// Response response = service.index("17236");
// NewActivityService services = new NewActivityService();
// services.doJoin(response.getDetailedCookies(),"");
// }
}
......@@ -423,6 +423,25 @@ public class NewActivityService {
}
return response;
}
//openbs访问活动首页
public Response indexOpenbs(String atcId) throws Exception {
Map<String,String> map = new HashMap<>();
map.put("id",atcId);
map.put("appKey","2wGQc3MZaQsqYFWcX4gguya5PnnS");
map.put("openBs","openbs");
logger.info("请求/hdtool/index接口,id=" + atcId);
Response response = given().cookies(authorization.dafuwengLogin(2720)).params(map).post(url + "/hdtool/index");
try{
Assert.assertEquals(String.valueOf(response.getStatusCode()),"200","活动页打开异常");
}catch(Exception e){
throw new Exception("/hdtool/index接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/hdtool/index接口失败,返回信息:"+response.asString());
}
return response;
}
//访问答题活动首页接口
public Response index_dt(String atcId) throws Exception {
Map<String,String> map = new HashMap<>();
......
......@@ -35,7 +35,7 @@ public class AlipayExchangeService {
map.put("realname",realname);
map.put("degreeId",degreeId);
map.put("itemId","55");
map.put("token","fw7qga0");
map.put("token","yrJRr7Cddp2YeQd");
logger.info("请求/alipayExchange/exchange接口");
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.dafuwengLogin(uid)).params(map).post(url);
......
......@@ -45,7 +45,7 @@ public class AppPlatformCouponService {
public Response takeOrder(int uid,String pcgId) throws Exception {
Map<String,String> map = new HashMap<>();
map.put("pcgId",pcgId);
map.put("token","dnsog");
map.put("token","yrJRr7Cddp2YeQd");
logger.info("请求/platformCoupon/takeOrder接口");
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.dafuwengLogin(uid)).params(map).post("http://"+goodsHost+"/platformCoupon/takeOrder");
......
......@@ -122,7 +122,7 @@ public class CouponExchangeService {
Map<String,String> map = new HashMap<>();
map.put("appItemId",appItemId);
map.put("itemId",itemId);
map.put("token","ds6tla07c");
map.put("token","yrJRr7Cddp2YeQd");
map.put("degreeId","1");
map.put("phone","18012341234");
map.put("phoneCatName","中国电信");
......@@ -148,7 +148,7 @@ public class CouponExchangeService {
public Response phonebillExchange(Map cookies,String degreeId) throws Exception {
Map<String,String> map = new HashMap<>();
map.put("token","ds6tla07c");
map.put("token","yrJRr7Cddp2YeQd");
map.put("degreeId",degreeId);
map.put("phone","18012341234");
map.put("phoneCatName","中国电信");
......@@ -174,7 +174,7 @@ public class CouponExchangeService {
public Response phoneflowExchange(Map cookies,String degreeId,String itemId,String phone,String phoneCatName,String phoneProvince) throws Exception {
Map<String,String> map = new HashMap<>();
map.put("itemId",itemId);
map.put("token","cmixdqn");
map.put("token","yrJRr7Cddp2YeQd");
map.put("degreeId",degreeId);
map.put("phone",phone);
map.put("phoneCatName",phoneCatName);
......@@ -224,7 +224,7 @@ public class CouponExchangeService {
Map<String,String> map = new HashMap<>();
map.put("appItemId",appItemId);
map.put("itemId",itemId);
map.put("token","xt7czv3c4");
map.put("token","yrJRr7Cddp2YeQd");
map.put("addrName","胡梦新");
map.put("addrPhone","18258853242");
map.put("addrProvince","浙江省");
......@@ -250,7 +250,7 @@ public class CouponExchangeService {
Map<String,String> map = new HashMap<>();
map.put("appItemId",appItemId);
map.put("itemId",itemId);
map.put("token","xt7czv3c4");
map.put("token","yrJRr7Cddp2YeQd");
map.put("addrName","胡梦新");
map.put("addrPhone","18258853242");
map.put("addrProvince","浙江省");
......@@ -279,7 +279,7 @@ public class CouponExchangeService {
map.put("realname","沙箱环境");
map.put("degreeId","1");
map.put("itemId",itemId);
map.put("token","jnwwwv");
map.put("token","yrJRr7Cddp2YeQd");
logger.info("请求/alipayExchange/exchange接口");
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.dafuwengLogin(uid)).params(map).post("http://"+goodsHost+"/alipayExchange/exchange");
......
......@@ -30,7 +30,7 @@ public class QbExchangeService {
Map<String,String> map = new HashMap<>();
map.put("qq",qq);
map.put("degreeId",degreeId);
map.put("token","0nmfgduh8");
map.put("token","yrJRr7Cddp2YeQd");
Response response = given().params(map).cookies(cookies).post(activityHost+"/qbExchange/exchange");
......@@ -53,7 +53,7 @@ public class QbExchangeService {
Map<String,String> map = new HashMap<>();
map.put("qq",qq);
map.put("degreeId",degreeId);
map.put("token","0nmfgduh8");
map.put("token","yrJRr7Cddp2YeQd");
Response response = given().params(map).cookies(cookies).post(activityHost+"/qbExchange/exchange");
String message = response.jsonPath().getString("data.message");
......
......@@ -25,7 +25,7 @@ public class VirtualExchangeService {
Map<String,String> map = new HashMap<>();
map.put("appItemId",appItemId);
map.put("degreeId",degreeId);
map.put("token","xz9eyi");
map.put("token","yrJRr7Cddp2YeQd");
logger.info("请求/virtualExchange/exchange接口");
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(cookies).params(map).post("http://"+goodsHost+"/virtualExchange/exchange");//couponExchange
......@@ -48,7 +48,7 @@ public class VirtualExchangeService {
Map<String,String> map = new HashMap<>();
map.put("appItemId",appItemId);
map.put("degreeId",degreeId);
map.put("token","xz9eyi");
map.put("token","yrJRr7Cddp2YeQd");
logger.info("请求/virtualExchange/exchange接口");
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(cookies).params(map).post("http://"+goodsHost+"/virtualExchange/exchange");//couponExchange
......
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