Commit 2172591d authored by wangxiaoshuang's avatar wangxiaoshuang

Merge branch 'master' into wxs

parents a1c5b6f1 91a8bc29
...@@ -2,10 +2,7 @@ package base; ...@@ -2,10 +2,7 @@ package base;
import com.codeborne.selenide.WebDriverRunner; import com.codeborne.selenide.WebDriverRunner;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import org.openqa.selenium.By; import org.openqa.selenium.*;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.RemoteWebDriver; import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.ITestResult; import org.testng.ITestResult;
import org.testng.Reporter; import org.testng.Reporter;
...@@ -28,6 +25,9 @@ public class DuibaBaseUi extends DuibaBase{ ...@@ -28,6 +25,9 @@ public class DuibaBaseUi extends DuibaBase{
public ITestResult result; public ITestResult result;
public void open(String url){
driver.get(url);
}
public void switchChrome(){ public void switchChrome(){
WebDriverRunner.closeWebDriver(); WebDriverRunner.closeWebDriver();
driver= WebDriverFactory.createWebDriver(WebDriverType.CHRMOE, ProxyFactory.createProxy()); driver= WebDriverFactory.createWebDriver(WebDriverType.CHRMOE, ProxyFactory.createProxy());
...@@ -132,6 +132,72 @@ public class DuibaBaseUi extends DuibaBase{ ...@@ -132,6 +132,72 @@ public class DuibaBaseUi extends DuibaBase{
} }
}
/**
* 点击通过text(),包含
* @param name
* @throws Exception
*/
public final void clickByTextContains(String name) throws Exception{
String xpath = "//*[contains(text(),'"+name+"')]";
int i=5;
while(i>0){
try {
driver.findElementByXPath(xpath).click();
logger.info("ByXpath:"+xpath+" click");
return;
} catch (Exception e) {
// TODO: handle exception
sleep(1);
i--;
if(i==0)throw e;
}
}
}
/**
* 点击通过text(),包含
* @param name
* @throws Exception
*/
public final void clickByTextContains(String name,int index) throws Exception{
String xpath = "//*[contains(text(),'"+name+"')]";
int i=5;
while(i>0){
try {
driver.findElementsByXPath(xpath).get(index).click();
logger.info("ByXpath:"+xpath+" click");
return;
} catch (Exception e) {
// TODO: handle exception
sleep(1);
i--;
if(i==0)throw e;
}
}
}
public final void clickByTextEqual(String name,int index) throws Exception{
String xpath = "//*[text()='"+name+"']";
int i=5;
while(i>0){
try {
driver.findElementsByXPath(xpath).get(index).click();
logger.info("ByXpath:"+xpath+" click");
return;
} catch (Exception e) {
// TODO: handle exception
sleep(1);
i--;
if(i==0)throw e;
}
}
} }
/** /**
...@@ -158,6 +224,73 @@ public class DuibaBaseUi extends DuibaBase{ ...@@ -158,6 +224,73 @@ public class DuibaBaseUi extends DuibaBase{
} }
public final void clickByXpath(String xpath) throws Exception{
int i=5;
while(i>0){
try {
driver.findElementByXPath(xpath).click();
logger.info("xpath:"+xpath+" click");
return;
} catch (Exception e) {
// TODO: handle exception
sleep(1);
i--;
if(i==0){
logger.info("xpath:"+xpath+" click失败");
throw e;
}
}
}
}
public final void clickByXpath(String xpath,int index) throws Exception{
int i=5;
while(i>0){
try {
driver.findElementsByXPath(xpath).get(index).click();
logger.info("xpath:"+xpath+" click");
return;
} catch (Exception e) {
// TODO: handle exception
sleep(1);
i--;
if(i==0){
logger.info("xpath:"+xpath+" click失败");
throw e;
}
}
}
}
/**
* 点击通过text(),等于
* @param name
* @throws Exception
*/
public final void clickByClass(String name,int index) throws Exception{
String xpath = "//*[@class='"+name+"']";
int i=5;
while(i>0){
try {
driver.findElementsByXPath(xpath).get(index).click();
logger.info("xpath:"+xpath+" click");
return;
} catch (Exception e) {
// TODO: handle exception
sleep(1);
i--;
if(i==0)throw e;
}
}
}
public final void clickByClassNoWait(String name) throws Exception{ public final void clickByClassNoWait(String name) throws Exception{
String xpath = "//*[@class='"+name+"']"; String xpath = "//*[@class='"+name+"']";
...@@ -245,6 +378,17 @@ public class DuibaBaseUi extends DuibaBase{ ...@@ -245,6 +378,17 @@ public class DuibaBaseUi extends DuibaBase{
} }
/**
* 校验元素,通过text
* @param text
* @return
*/
public boolean isExistContainsText(String text){
String xpath = "//*[contains(text(),'"+text+"')]";
return ElementExist(xpath);
}
/** /**
* 校验元素,通过class * 校验元素,通过class
* @param byclass * @param byclass
...@@ -264,4 +408,81 @@ public class DuibaBaseUi extends DuibaBase{ ...@@ -264,4 +408,81 @@ public class DuibaBaseUi extends DuibaBase{
} }
public void inputByContainsAttribut(String atttibut,String name,String tag,String input) throws Exception{
String xpath = "//"+tag+"[contains(@"+atttibut+",'"+name+"')]";
int i=3;
while(i>0){
try {
System.out.println(i);
driver.findElementByXPath(xpath).sendKeys(input);
logger.info("ByXpath:"+xpath+" input");
return;
} catch (Exception e) {
// TODO: handle exception
sleep(1);
i--;
if(i==0)throw e;
}
}
}
public final void inputByXpath(String xpath,String text) throws Exception{
int i=5;
while(i>0){
try {
driver.findElementByXPath(xpath).clear();
driver.findElementByXPath(xpath).sendKeys(text);
logger.info("xpath:"+xpath+" send"+text);
return;
} catch (Exception e) {
// TODO: handle exception
sleep(1);
i--;
if(i==0){
logger.info("xpath:"+xpath+" send失败");
throw e;
}
}
}
}
public final void inputByXpath(String xpath,String text,int index) throws Exception{
int i=5;
while(i>0){
try {
driver.findElementsByXPath(xpath).get(index).clear();
driver.findElementsByXPath(xpath).get(index).sendKeys(text);
logger.info("xpath:"+xpath+" send:"+text);
return;
} catch (Exception e) {
// TODO: handle exception
sleep(1);
i--;
if(i==0){
logger.info("xpath:"+xpath+" send失败");
throw e;
}
}
}
}
public void scrollToTop(){
((JavascriptExecutor) driver).executeScript("window.scrollTo(document.body.scrollHeight,0)");
}
public void scrollToDown(){
((JavascriptExecutor) driver).executeScript("window.scrollTo(0,document.body.scrollHeight)");
}
} }
...@@ -66,6 +66,7 @@ public class MysqlConnPool { ...@@ -66,6 +66,7 @@ public class MysqlConnPool {
* @throws SQLException * @throws SQLException
*/ */
public Map<String, Object> findSimpleResult(String sql, Object ...params) throws SQLException { public Map<String, Object> findSimpleResult(String sql, Object ...params) throws SQLException {
log.info("findSimpleResult开始~~~~~~~~~~~~~~~~~~~~~");
Map<String, Object> map = null; Map<String, Object> map = null;
try(Connection conn = bds.getConnection()){ try(Connection conn = bds.getConnection()){
...@@ -102,11 +103,13 @@ public class MysqlConnPool { ...@@ -102,11 +103,13 @@ public class MysqlConnPool {
}catch(Exception e){ }catch(Exception e){
// e.printStackTrace(); // e.printStackTrace();
log.info("findSimpleResult异常~~~~~~~~~~~~~~~~~~~~~");
log.info("findSimpleResult"+e.toString()); log.info("findSimpleResult"+e.toString());
log.info("test"); log.info("test");
log.info("bds"+bds.toString()); log.info("bds"+bds.toString());
} }
log.info("findSimpleResult结束~~~~~~~~~~~~~~~~~~~~~");
return map; return map;
} }
/** /**
......
...@@ -23,9 +23,9 @@ import static io.restassured.RestAssured.given; ...@@ -23,9 +23,9 @@ import static io.restassured.RestAssured.given;
public class Postman { public class Postman {
final static String dingdingUrl="https://shark.dui88.com/test/integration"; final static String dingdingUrl="https://shark.dui88.com/test/integration";
final static String testPlatformUrl = "http://test-run.duibatest.com.cn/insert"; final static String testPlatformUrl = "http://test-run.duibatest.com.cn/insert";
final static String miriaUrl = "http://miria-aliyun.duibatest.com.cn/autoTest/finish"; final static String miriaUrl = "http://ali-console.duibatest.com.cn/miria/forward/autoTest/finish";
final static String miriaUrlTesting = "http://miria-aliyun.duibatest.com.cn/autoTest/testing"; final static String miriaUrlTesting = "http://ali-console.duibatest.com.cn/miria/forward/autoTest/testing";
final static String miriaUrlFindTestApp = "http://miria-aliyun.duibatest.com.cn/autoTest/findTestApp"; final static String miriaUrlFindTestApp = "http://ali-console.duibatest.com.cn/miria/forward/autoTest/findTestApp";
//dingdingUrl="http://www.json.cn/"; //dingdingUrl="http://www.json.cn/";
// private static Logger logger = LogManager.getLogger(Postman.class); // private static Logger logger = LogManager.getLogger(Postman.class);
......
...@@ -131,7 +131,7 @@ public class 集卡_出奖方式测试_DuibaTest extends DuibaTestBase { ...@@ -131,7 +131,7 @@ public class 集卡_出奖方式测试_DuibaTest extends DuibaTestBase {
logger.info("校验中奖奖品类型成功,自定义活动游戏中奖奖品类型" + response.jsonPath().getString("lottery.type")); logger.info("校验中奖奖品类型成功,自定义活动游戏中奖奖品类型" + response.jsonPath().getString("lottery.type"));
Response openResponse = this.playCollectResult("241", "19931",2720); Response openResponse = this.playCollectResult("241", "19931",2720);
Assert.assertEquals(openResponse.jsonPath().getString("lottery.type"), awardsType, "校验奖项失败"); Assert.assertEquals(openResponse.jsonPath().getString("lottery.type"), "thanks", "校验奖项失败");
logger.info("校验奖品信息type成功, 奖品信息为:" + openResponse.jsonPath().getString("lottery.type")); logger.info("校验奖品信息type成功, 奖品信息为:" + openResponse.jsonPath().getString("lottery.type"));
......
...@@ -117,7 +117,7 @@ public class 活动增加抽奖次数_DuibaTest extends DuibaTestBase { ...@@ -117,7 +117,7 @@ public class 活动增加抽奖次数_DuibaTest extends DuibaTestBase {
return response; return response;
} }
@Test
public void 创建并上架活动() throws Exception { public void 创建并上架活动() throws Exception {
//管理后台创建活动并开启 //管理后台创建活动并开启
Response ManagerResponse = managerService.save_customHdtool(); Response ManagerResponse = managerService.save_customHdtool();
...@@ -126,6 +126,7 @@ public class 活动增加抽奖次数_DuibaTest extends DuibaTestBase { ...@@ -126,6 +126,7 @@ public class 活动增加抽奖次数_DuibaTest extends DuibaTestBase {
managerService.switchSpecifyAndBlack("1", hdtoolId); managerService.switchSpecifyAndBlack("1", hdtoolId);
//定向开发者 //定向开发者
managerService.saveSpecify(hdtoolId,"2239"); managerService.saveSpecify(hdtoolId,"2239");
logger.info("hdtoolId="+hdtoolId);
//开发者上架活动 //开发者上架活动
Response HdResponse = developerService.joinIn(hdtoolId, "12"); Response HdResponse = developerService.joinIn(hdtoolId, "12");
logger.info("创建活动并上架成功"); logger.info("创建活动并上架成功");
......
...@@ -143,7 +143,7 @@ public class 自有活动出奖_DuibaTest extends DuibaTestBase { ...@@ -143,7 +143,7 @@ public class 自有活动出奖_DuibaTest extends DuibaTestBase {
Assert.assertEquals(id,"15703","id不正确"); Assert.assertEquals(id,"15703","id不正确");
Assert.assertEquals(imgurl,"//yun.dui88.com/images/201803/29k6k3x05d.jpg","imgurl不正确"); 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.assertTrue(link.contains("//activity.m.duibatest.com.cn/crecord/recordDetailNew?orderId="),"link不正确");
Assert.assertEquals(title,"【自动化勿动】自有优惠券","title不正确"); Assert.assertEquals(title,"【自动化勿动】zr自有优惠券","title不正确");
Assert.assertEquals(type,"coupon","type不正确"); Assert.assertEquals(type,"coupon","type不正确");
Assert.assertEquals(coupon_code,"123123123","coupon_code不正确"); Assert.assertEquals(coupon_code,"123123123","coupon_code不正确");
Assert.assertEquals(coupon_key,"123123","coupon_key不正确"); Assert.assertEquals(coupon_key,"123123","coupon_key不正确");
......
...@@ -160,6 +160,7 @@ public class Qb_兑换流程测试_ExchangeTest extends CheckTemplet { ...@@ -160,6 +160,7 @@ public class Qb_兑换流程测试_ExchangeTest extends CheckTemplet {
int uid = 3767; int uid = 3767;
//第一次兑换 //第一次兑换
Thread.sleep(5000);
Response response = qbExchangeService.doTakePrize(authorization.dafuwengLogin(uid),"1234345554","1"); Response response = qbExchangeService.doTakePrize(authorization.dafuwengLogin(uid),"1234345554","1");
String orderId = (String)response.jsonPath().get("orderId"); String orderId = (String)response.jsonPath().get("orderId");
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid),orderId); response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid),orderId);
...@@ -172,10 +173,12 @@ public class Qb_兑换流程测试_ExchangeTest extends CheckTemplet { ...@@ -172,10 +173,12 @@ public class Qb_兑换流程测试_ExchangeTest extends CheckTemplet {
i--; i--;
} }
//第二次兑换 //第二次兑换
Thread.sleep(5000);
try{ try{
response = qbExchangeService.doTakePrize(authorization.dafuwengLogin(uid),"1234345554","1"); response = qbExchangeService.doTakePrize(authorization.dafuwengLogin(uid),"1234345554","1");
}catch (Exception e){ }catch (Exception e){
logger.info(e.toString());
message = e.toString(); message = e.toString();
} }
logger.info(message); logger.info(message);
...@@ -188,6 +191,7 @@ public class Qb_兑换流程测试_ExchangeTest extends CheckTemplet { ...@@ -188,6 +191,7 @@ public class Qb_兑换流程测试_ExchangeTest extends CheckTemplet {
int uid = 3767; int uid = 3767;
//第一次兑换 //第一次兑换
Thread.sleep(5000);
Response response = qbExchangeService.doTakePrize(authorization.dafuwengLogin(uid),"1234345554","2"); Response response = qbExchangeService.doTakePrize(authorization.dafuwengLogin(uid),"1234345554","2");
String orderId = (String)response.jsonPath().get("orderId"); String orderId = (String)response.jsonPath().get("orderId");
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid),orderId); response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid),orderId);
...@@ -200,6 +204,7 @@ public class Qb_兑换流程测试_ExchangeTest extends CheckTemplet { ...@@ -200,6 +204,7 @@ public class Qb_兑换流程测试_ExchangeTest extends CheckTemplet {
i--; i--;
} }
//第二次兑换 //第二次兑换
Thread.sleep(5000);
try{ try{
response = qbExchangeService.doTakePrize(authorization.dafuwengLogin(uid),"1234345554","2"); response = qbExchangeService.doTakePrize(authorization.dafuwengLogin(uid),"1234345554","2");
......
...@@ -68,7 +68,8 @@ public class Qb_兑换限制测试_ExchangeTest extends CheckTemplet { ...@@ -68,7 +68,8 @@ public class Qb_兑换限制测试_ExchangeTest extends CheckTemplet {
int uid = 4932; int uid = 4932;
//第一次兑换 //第一次兑换
Response response = qbExchangeService.doTakePrize(authorization.dafuwengLogin(uid),"1234345554","1"); Thread.sleep(4000);
Response response = qbExchangeService.doTakePrize(authorization.dafuwengLogin(uid),"1234343554","1");
String orderId = (String)response.jsonPath().get("orderId"); String orderId = (String)response.jsonPath().get("orderId");
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid),orderId); response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid),orderId);
String message = response.jsonPath().getString("message"); String message = response.jsonPath().getString("message");
...@@ -80,9 +81,11 @@ public class Qb_兑换限制测试_ExchangeTest extends CheckTemplet { ...@@ -80,9 +81,11 @@ public class Qb_兑换限制测试_ExchangeTest extends CheckTemplet {
i--; i--;
} }
//第二次兑换 //第二次兑换
response = qbExchangeService.doTakePrize1(authorization.dafuwengLogin(uid),"1234345554","1"); Thread.sleep(4000);
response = qbExchangeService.doTakePrize1(authorization.dafuwengLogin(uid),"1234341554","1");
message = response.jsonPath().getString("message"); message = response.jsonPath().getString("message");
logger.info(message); logger.info(message);
if(message==null)logger.info(response.asString());
//获取按钮状态 //获取按钮状态
Response detailResponse = mobileService.detail(authorization.dafuwengLogin(uid),"2"); Response detailResponse = mobileService.detail(authorization.dafuwengLogin(uid),"2");
...@@ -99,6 +102,7 @@ public class Qb_兑换限制测试_ExchangeTest extends CheckTemplet { ...@@ -99,6 +102,7 @@ public class Qb_兑换限制测试_ExchangeTest extends CheckTemplet {
int uid = 4933; int uid = 4933;
//第一次兑换 //第一次兑换
Thread.sleep(4000);
Response response = qbExchangeService.doTakePrize(authorization.dafuwengLogin(uid),"1234345554","2"); Response response = qbExchangeService.doTakePrize(authorization.dafuwengLogin(uid),"1234345554","2");
String orderId = (String)response.jsonPath().get("orderId"); String orderId = (String)response.jsonPath().get("orderId");
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid),orderId); response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid),orderId);
...@@ -111,10 +115,11 @@ public class Qb_兑换限制测试_ExchangeTest extends CheckTemplet { ...@@ -111,10 +115,11 @@ public class Qb_兑换限制测试_ExchangeTest extends CheckTemplet {
i--; i--;
} }
//第二次兑换 //第二次兑换
Thread.sleep(4000);
response = qbExchangeService.doTakePrize1(authorization.dafuwengLogin(uid),"12343455541","2"); response = qbExchangeService.doTakePrize1(authorization.dafuwengLogin(uid),"12343455541","2");
response.prettyPrint(); response.prettyPrint();
message = response.jsonPath().getString("message"); message = response.jsonPath().getString("message");
logger.info(message); logger.info("message: " + message);
//获取按钮状态 //获取按钮状态
Response detailResponse = mobileService.detail(authorization.dafuwengLogin(uid),"2"); Response detailResponse = mobileService.detail(authorization.dafuwengLogin(uid),"2");
...@@ -133,7 +138,8 @@ public class Qb_兑换限制测试_ExchangeTest extends CheckTemplet { ...@@ -133,7 +138,8 @@ public class Qb_兑换限制测试_ExchangeTest extends CheckTemplet {
int uid = 4933; int uid = 4933;
//第一次兑换 //第一次兑换
Response response = qbExchangeService.doTakePrize(authorization.dafuwengLogin(uid),"1234345554","3"); Thread.sleep(4000);
Response response = qbExchangeService.doTakePrize(authorization.dafuwengLogin(uid),"12343432554","3");
String orderId = (String)response.jsonPath().get("orderId"); String orderId = (String)response.jsonPath().get("orderId");
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid),orderId); response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid),orderId);
String message = response.jsonPath().getString("message"); String message = response.jsonPath().getString("message");
...@@ -145,7 +151,8 @@ public class Qb_兑换限制测试_ExchangeTest extends CheckTemplet { ...@@ -145,7 +151,8 @@ public class Qb_兑换限制测试_ExchangeTest extends CheckTemplet {
i--; i--;
} }
//第二次兑换 //第二次兑换
response = qbExchangeService.doTakePrize1(authorization.dafuwengLogin(uid),"12343455541","3"); Thread.sleep(4000);
response = qbExchangeService.doTakePrize1(authorization.dafuwengLogin(uid),"123434455541","3");
response.prettyPrint(); response.prettyPrint();
message = response.jsonPath().getString("message"); message = response.jsonPath().getString("message");
logger.info(message); logger.info(message);
...@@ -173,6 +180,7 @@ public class Qb_兑换限制测试_ExchangeTest extends CheckTemplet { ...@@ -173,6 +180,7 @@ public class Qb_兑换限制测试_ExchangeTest extends CheckTemplet {
//会员等级无法兑换 //会员等级无法兑换
try{ try{
Thread.sleep(4000);
Response response = qbExchangeService.doTakePrize(authorization.dafuwengLogin(uid),"1234345554",degreeId); Response response = qbExchangeService.doTakePrize(authorization.dafuwengLogin(uid),"1234345554",degreeId);
response.prettyPrint(); response.prettyPrint();
...@@ -182,6 +190,7 @@ public class Qb_兑换限制测试_ExchangeTest extends CheckTemplet { ...@@ -182,6 +190,7 @@ public class Qb_兑换限制测试_ExchangeTest extends CheckTemplet {
logger.info(message); logger.info(message);
//会员等级可兑换,vip=5 //会员等级可兑换,vip=5
Thread.sleep(4000);
Response response = qbExchangeService.doTakePrize(authorization.generateSignAutoLogin("42vkFzeLnoNjXt6AhMM7LPj4G8pT",vipUid),"1234345554",degreeId); Response response = qbExchangeService.doTakePrize(authorization.generateSignAutoLogin("42vkFzeLnoNjXt6AhMM7LPj4G8pT",vipUid),"1234345554",degreeId);
response.prettyPrint(); response.prettyPrint();
...@@ -198,6 +207,7 @@ public class Qb_兑换限制测试_ExchangeTest extends CheckTemplet { ...@@ -198,6 +207,7 @@ public class Qb_兑换限制测试_ExchangeTest extends CheckTemplet {
int uid = 4934; int uid = 4934;
//第一次兑换 //第一次兑换
Thread.sleep(5000);
Response response = qbExchangeService.doTakePrize(authorization.dafuwengLogin(uid),"123434555412","1"); Response response = qbExchangeService.doTakePrize(authorization.dafuwengLogin(uid),"123434555412","1");
String orderId = (String)response.jsonPath().get("orderId"); String orderId = (String)response.jsonPath().get("orderId");
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid),orderId); response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid),orderId);
...@@ -212,6 +222,7 @@ public class Qb_兑换限制测试_ExchangeTest extends CheckTemplet { ...@@ -212,6 +222,7 @@ public class Qb_兑换限制测试_ExchangeTest extends CheckTemplet {
//第二次兑换 //第二次兑换
//不同的用户,同一个 qq好 //不同的用户,同一个 qq好
int uid1=4935; int uid1=4935;
Thread.sleep(5000);
response = qbExchangeService.doTakePrize1(authorization.dafuwengLogin(uid1),"123434555412","1"); response = qbExchangeService.doTakePrize1(authorization.dafuwengLogin(uid1),"123434555412","1");
response.prettyPrint(); response.prettyPrint();
message = response.jsonPath().getString("message"); message = response.jsonPath().getString("message");
......
...@@ -2,6 +2,7 @@ package http.cases.ExchangeTest; ...@@ -2,6 +2,7 @@ package http.cases.ExchangeTest;
import base.DuibaBase; import base.DuibaBase;
import base.DuibaBases; import base.DuibaBases;
import com.sun.jna.platform.win32.OaIdl;
import http.service.Activity.ManagerService; import http.service.Activity.ManagerService;
import http.service.Authorization; import http.service.Authorization;
import http.service.app.MobileService; import http.service.app.MobileService;
...@@ -10,6 +11,7 @@ import http.service.app.tawService; ...@@ -10,6 +11,7 @@ import http.service.app.tawService;
import http.service.hd.DeveloperAccountService; import http.service.hd.DeveloperAccountService;
import http.service.hd.DappConfigService; import http.service.hd.DappConfigService;
import org.apache.logging.log4j.core.pattern.AbstractStyleNameConverter; import org.apache.logging.log4j.core.pattern.AbstractStyleNameConverter;
import org.codehaus.jackson.annotate.JsonTypeInfo;
import org.testng.annotations.AfterClass; import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider; import org.testng.annotations.DataProvider;
...@@ -26,6 +28,7 @@ import java.util.Map; ...@@ -26,6 +28,7 @@ import java.util.Map;
import utils.RedisUtil; import utils.RedisUtil;
import static io.restassured.RestAssured.given; import static io.restassured.RestAssured.given;
import static io.restassured.RestAssured.urlEncodingEnabled;
/** /**
* Created by lvwenyan on 2019/3/26. * Created by lvwenyan on 2019/3/26.
...@@ -459,6 +462,50 @@ public class 兑吧卡密_兑换流程测试_ExchangeTest extends CheckTemplet { ...@@ -459,6 +462,50 @@ public class 兑吧卡密_兑换流程测试_ExchangeTest extends CheckTemplet {
} }
@Test(description = "兑吧卡密跳转按钮")
public void 马上使用跳转() throws Exception{
String appItemId = "195065";
String itemId = "32609";
String skuId = "106";
Map cookies = authorization.dafuwengLogin(uid);
//优惠券兑换
Response response = gawService.couponExchange(cookies,appItemId,itemId,skuId);
String orderId = response.jsonPath().getString("data.orderId");
//获取兑换结果
response = tawService.orderStatus(orderId,uid);
response.prettyPrint();
String status = response.jsonPath().getString("data.status");
int i = 10;
//异步接口,直到兑换成功
while (i > 0 && status.equals("processing")) {
Thread.sleep(1000);
response = tawService.orderStatus(orderId,uid);
response.prettyPrint();
status = response.jsonPath().getString("data.status");
i--;
}
//优惠券订单结果页
Thread.sleep(3000);
Response detailResponse = tawService.detailItems(orderId,uid);
detailResponse.prettyPrint();
String useButtonText = detailResponse.jsonPath().getString("data[0].useButtonText");
String iosDownloadUrl = detailResponse.jsonPath().getString("data[0].iosDownloadUrl");
String credits = detailResponse.jsonPath().getString("data[0].credits");
String cardAmount = detailResponse.jsonPath().getString("data[0].cardAmount");
Assert.assertEquals(useButtonText,"去使用","校验去使用按钮失败");
Assert.assertEquals(iosDownloadUrl,"http://www.iqiyi.com","校验按钮链接失败");
Assert.assertEquals(credits,"200","校验积分失败");
Assert.assertEquals(cardAmount,"20000","校验面值失败");
logger.info("校验兑吧卡密去使用跳转按钮成功");
}
} }
...@@ -56,6 +56,14 @@ public class 兑吧新优惠券_兑换流程测试_ExchangeTest extends CheckTem ...@@ -56,6 +56,14 @@ public class 兑吧新优惠券_兑换流程测试_ExchangeTest extends CheckTem
new Object[]{3, "193855", "32518","52", "兑吧新优惠券日期兑换限制已结束"}, //case3 new Object[]{3, "193855", "32518","52", "兑吧新优惠券日期兑换限制已结束"}, //case3
}; };
} }
if (method.getName().equals("优惠券马上使用按钮测试")){
result = new Object[][]{
new Object[]{1, "195053", "32594", "105","兑吧新优惠券普通券码跳转"}, //case1
new Object[]{2, "194708", "32595", "91", "兑吧新优惠券跳转链接"}, //case2
new Object[]{3, "194707", "32596","90", "兑吧新优惠券重复券跳转"}, //case3
};
}
return result; return result;
} }
...@@ -429,65 +437,64 @@ public class 兑吧新优惠券_兑换流程测试_ExchangeTest extends CheckTem ...@@ -429,65 +437,64 @@ public class 兑吧新优惠券_兑换流程测试_ExchangeTest extends CheckTem
* @param caseNum 用例编号 * @param caseNum 用例编号
* @param appItemId 商品入库Id * @param appItemId 商品入库Id
* @param itemId 商品id * @param itemId 商品id
* @param skuId skuId
* @param caseName 用例名称打印 * @param caseName 用例名称打印
* @throws Exception * @throws Exception
*/ */
// @Test(dataProvider = "providerMethod") @Test(dataProvider = "providerMethod")
// public void 优惠券马上使用按钮测试(int caseNum, String appItemId, String itemId, String caseName)throws Exception{ public void 优惠券马上使用按钮测试(int caseNum, String appItemId, String itemId, String skuId, String caseName)throws Exception{
//
// logger.info(caseName); logger.info(caseName);
// Map cookies = authorization.dafuwengLogin(uid);
// //优惠券兑换
// String orderId = this.优惠券兑换订单(appItemId,itemId,uid); //优惠券兑换
// Response response = gawService.couponExchange(cookies,appItemId,itemId,skuId);
// //优惠券兑换结果页 String orderId = response.jsonPath().getString("data.orderId");
// Response resultResponse = crecordService.recordDetail(orderId,uid); //获取兑换结果
// //resultResponse.prettyPrint(); response = tawService.orderStatus(orderId,uid);
// String btnText = MatcherString.getString(resultResponse.asString(),"\"btnText\":\"(.*?)\",",1); response.prettyPrint();
// String actualPay = MatcherString.getString(resultResponse.asString(),"\"actualPay\":\"(.*?)\",",1); String status = response.jsonPath().getString("data.status");
// String androidDownload = MatcherString.getString(resultResponse.asString(),"\"androidDownload\":\"(.*?)\",",1); int i = 10;
// String androidDownloadUrl = MatcherString.getString(resultResponse.asString(),"\"androidDownloadUrl\":\"(.*?)\",",1); //异步接口,直到兑换成功
// while (i > 0 && status.equals("processing")) {
// Thread.sleep(1000);
// //优惠券兑换记录页 response = tawService.orderStatus(orderId,uid);
// Thread.sleep(3000); response.prettyPrint();
// Response detailResponse = tawService.detailItems(orderId,uid); status = response.jsonPath().getString("data.status");
// detailResponse.prettyPrint(); i--;
// String useButtonText = detailResponse.jsonPath().getString("data[0].useButtonText"); }
// String iosDownloadUrl = detailResponse.jsonPath().getString("data[0].iosDownloadUrl");
// //优惠券订单结果页
// switch (caseNum){ Thread.sleep(3000);
// Response detailResponse = tawService.detailItems(orderId,uid);
// case 1: detailResponse.prettyPrint();
// Assert.assertEquals(btnText,"马上使用","校验结果页按钮文案失败"); String useButtonText = detailResponse.jsonPath().getString("data[0].useButtonText");
// Assert.assertEquals(actualPay,"10积分","校验结果页积分文案失败"); String iosDownloadUrl = detailResponse.jsonPath().getString("data[0].iosDownloadUrl");
// Assert.assertEquals(androidDownload,"https://m2.mobike.com/active/fission_packet_joint/index.html","校验结果页按钮链接失败"); String credits = detailResponse.jsonPath().getString("data[0].credits");
// String cardAmount = detailResponse.jsonPath().getString("data[0].cardAmount");
// Assert.assertEquals(useButtonText,"去使用","校验兑换记录页按钮文案失败");
// Assert.assertEquals(iosDownloadUrl,"https://m2.mobike.com/active/fission_packet_joint/index.html","校验兑换记录页按钮跳转链接失败"); switch (caseNum){
// logger.info("校验优惠券商家落地页下载链接页面成功");
// break; case 1:
// case 2: Assert.assertEquals(useButtonText,"去使用","校验结果页按钮文案失败");
// Assert.assertEquals(btnText,"马上领取","校验结果页按钮文案失败"); Assert.assertEquals(credits,"100","校验结果页积分文案失败");
// Assert.assertEquals(actualPay,"20积分","校验结果页积分文案失败"); Assert.assertEquals(iosDownloadUrl,"http://www.iqiyi.com","校验结果页按钮链接失败");
// Assert.assertEquals(androidDownload,"https://u.163.com/aoshzxiaoshouxiaoshou4","校验结果页按钮链接失败"); Assert.assertEquals(cardAmount,"20000","校验结果页市场价失败");
// logger.info("校验兑吧新优惠券普通券码跳转成功");
// Assert.assertEquals(useButtonText,"去使用","校验兑换记录页按钮文案失败"); break;
// Assert.assertEquals(iosDownloadUrl,"https://u.163.com/aoshzxiaoshouxiaoshou4","校验兑换记录页按钮跳转链接失败"); case 2:
// logger.info("校验优惠券兑换记录页下载链接页面成功"); Assert.assertEquals(useButtonText,"去使用","校验结果页按钮文案失败");
// break; Assert.assertEquals(iosDownloadUrl,"https://gogokid.jimeng.mobi/magic/runtime/gogokid/?id=4022&channel_id=1663","校验结果页按钮链接失败");
// case 3: logger.info("校验兑吧新优惠券跳转链接成功");
// Assert.assertEquals(btnText,"马上下载","校验结果页按钮文案失败"); break;
// Assert.assertEquals(actualPay,"30积分","校验结果页积分文案失败"); case 3:
// Assert.assertEquals(androidDownloadUrl,"//activity.m.duibatest.com.cn/log/redirect?url=https%3A%2F%2Fm.wkzuche.com%2Fh5%2F%23%2Factivity%2Fshare%3Fchannel%3Ddb%402018&dpm=2239.25.1.0&dcm=101.29710.172294.0","校验结果页按钮链接失败"); Assert.assertEquals(useButtonText,"去使用","校验结果页按钮文案失败");
// Assert.assertEquals(iosDownloadUrl,"https://m.aomygod.com/act-richang-waituibinggan19.9.html?tk=cf40QIFiVx9","校验结果页按钮链接失败");
// Assert.assertEquals(useButtonText,"去使用","校验兑换记录页按钮文案失败"); logger.info("校验兑吧新优惠券重复券跳转链接成功");
// Assert.assertEquals(iosDownloadUrl,"https://m.wkzuche.com/h5/#/activity/share?channel=db@2018","校验兑换记录页按钮跳转链接失败"); break;
// logger.info("校验优惠券链接券页面成功"); }
// break;
// } }
//
// }
......
...@@ -589,6 +589,7 @@ public class 兑吧老优惠券_兑换流程测试_ExchangeTest extends CheckTem ...@@ -589,6 +589,7 @@ public class 兑吧老优惠券_兑换流程测试_ExchangeTest extends CheckTem
@Test @Test
public void 优惠券限时兑换测试() throws Exception{ public void 优惠券限时兑换测试() throws Exception{
//优惠券限时: 18:00~20:00
int uid = 7113; int uid = 7113;
Map<String,String> map = new HashMap<>(); Map<String,String> map = new HashMap<>();
map.put("appItemId","172079"); map.put("appItemId","172079");
...@@ -598,32 +599,33 @@ public class 兑吧老优惠券_兑换流程测试_ExchangeTest extends CheckTem ...@@ -598,32 +599,33 @@ public class 兑吧老优惠券_兑换流程测试_ExchangeTest extends CheckTem
//兑换 //兑换
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.dafuwengLogin(uid)).params(map).post(url + "/couponExchange/exchange"); Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.dafuwengLogin(uid)).params(map).post(url + "/couponExchange/exchange");
response.prettyPrint(); response.prettyPrint();
logger.info("response返回结果:" + response.asString());
//获取按钮状态 //获取按钮状态
Response detailResponse = mobileService.detail(authorization.dafuwengLogin(uid),"29667"); Response detailResponse = mobileService.detail(authorization.dafuwengLogin(uid),"29667");
// detailResponse.prettyPrint();
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1); String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
logger.info("兑换按钮:" + exchangeText);
Calendar cal = Calendar.getInstance(); Calendar cal = Calendar.getInstance();
int hour = cal.get(Calendar.HOUR_OF_DAY); int hour = cal.get(Calendar.HOUR_OF_DAY);
logger.info("当前时间是:" + hour + "时"); logger.info("当前时间是:" + hour + "时");
if(hour >= 0 && hour < 15 ){ if(hour >= 0 && hour < 18 ){
//限时兑换未开始 //限时兑换未开始
Assert.assertEquals(response.jsonPath().getString("message"),"请在限定时间内兑换哦(13)","校验限时兑换失败"); Assert.assertEquals(response.jsonPath().getString("message"),"请在限定时间内兑换哦(13)","校验限时兑换未开始失败");
Assert.assertEquals(exchangeText,"即将开始","校验马上兑换按钮状态失败"); Assert.assertEquals(exchangeText,"即将开始","校验马上兑换按钮状态失败");
logger.info("校验优惠券限时兑换未开始场景成功"); logger.info("校验优惠券限时兑换未开始场景成功");
}else if(hour >= 15 && hour < 19){ }else if(hour >= 18 && hour < 20){
Assert.assertEquals(response.jsonPath().getString("success"),"true","校验限时兑换失败"); Assert.assertEquals(response.jsonPath().getString("success"),"true","校验限时兑换进行中失败");
Assert.assertEquals(exchangeText,"马上兑换","校验马上兑换按钮状态失败"); Assert.assertEquals(exchangeText,"马上兑换","校验马上兑换按钮状态失败");
logger.info("校验优惠券限时兑换进行中场景成功"); logger.info("校验优惠券限时兑换进行中场景成功");
}else{ }else{
Assert.assertEquals(response.jsonPath().getString("message"),"今日已兑完,明天再来哦(14)","校验日期兑换限制失败"); Assert.assertEquals(response.jsonPath().getString("message"),"今日已兑完,明天再来哦(14)","校验限时兑换已结束失败");
Assert.assertEquals(exchangeText,"今日已结束","校验马上兑换按钮状态失败"); Assert.assertEquals(exchangeText,"今日已结束","校验马上兑换按钮状态失败");
logger.info("校验优惠券限时兑换结束场景成功"); logger.info("校验优惠券限时兑换结束场景成功");
...@@ -662,6 +664,7 @@ public class 兑吧老优惠券_兑换流程测试_ExchangeTest extends CheckTem ...@@ -662,6 +664,7 @@ public class 兑吧老优惠券_兑换流程测试_ExchangeTest extends CheckTem
detailResponse.prettyPrint(); detailResponse.prettyPrint();
String useButtonText = detailResponse.jsonPath().getString("data[0].useButtonText"); String useButtonText = detailResponse.jsonPath().getString("data[0].useButtonText");
String iosDownloadUrl = detailResponse.jsonPath().getString("data[0].iosDownloadUrl"); String iosDownloadUrl = detailResponse.jsonPath().getString("data[0].iosDownloadUrl");
String cardAmount = detailResponse.jsonPath().getString("data[0].cardAmount");
switch (caseNum){ switch (caseNum){
...@@ -672,6 +675,7 @@ public class 兑吧老优惠券_兑换流程测试_ExchangeTest extends CheckTem ...@@ -672,6 +675,7 @@ public class 兑吧老优惠券_兑换流程测试_ExchangeTest extends CheckTem
Assert.assertEquals(useButtonText,"去使用","校验兑换记录页按钮文案失败"); Assert.assertEquals(useButtonText,"去使用","校验兑换记录页按钮文案失败");
Assert.assertEquals(iosDownloadUrl,"https://m2.mobike.com/active/fission_packet_joint/index.html","校验兑换记录页按钮跳转链接失败"); Assert.assertEquals(iosDownloadUrl,"https://m2.mobike.com/active/fission_packet_joint/index.html","校验兑换记录页按钮跳转链接失败");
Assert.assertEquals(cardAmount,"10000","校验兑换记录页市场价失败");
logger.info("校验优惠券商家落地页下载链接页面成功"); logger.info("校验优惠券商家落地页下载链接页面成功");
break; break;
case 2: case 2:
......
...@@ -277,9 +277,9 @@ public class 商品订单失败测试_ExchangeTest extends CheckTemplet { ...@@ -277,9 +277,9 @@ public class 商品订单失败测试_ExchangeTest extends CheckTemplet {
String orderStatus = String.valueOf(mapOrder.get("status")); String orderStatus = String.valueOf(mapOrder.get("status"));
String orderError = String.valueOf(mapOrder.get("error4consumer")); String orderError = String.valueOf(mapOrder.get("error4consumer"));
Assert.assertEquals(statusResponse.jsonPath().getString("message"),"40004:Business Failed_PAYEE_NOT_EXIST:收款账号不存在","校验message失败"); Assert.assertEquals(statusResponse.jsonPath().getString("message"),"收款账号不存在","校验message失败");
Assert.assertEquals(orderStatus,"fail","校验数据库status失败"); Assert.assertEquals(orderStatus,"fail","校验数据库status失败");
Assert.assertEquals(orderError,"40004:Business Failed_PAYEE_NOT_EXIST:收款账号不存在","校验数据库error失败"); Assert.assertEquals(orderError,"收款账号不存在","校验数据库error失败");
logger.info("校验支付宝异常账户兑换失败成功"); logger.info("校验支付宝异常账户兑换失败成功");
} }
......
...@@ -45,15 +45,19 @@ public class 多档位话费_兑换流程测试_ExchangeTest extends CheckTemple ...@@ -45,15 +45,19 @@ public class 多档位话费_兑换流程测试_ExchangeTest extends CheckTemple
try{ try{
//话费第一次兑换 //话费第一次兑换
Thread.sleep(3000);
Response response = couponExchangeService.phonebillExchange(authorization.dafuwengLogin(uid),"10"); Response response = couponExchangeService.phonebillExchange(authorization.dafuwengLogin(uid),"10");
response.prettyPrint(); response.prettyPrint();
Assert.assertEquals(response.jsonPath().getString("success"),"true","校验兑换失败"); Assert.assertEquals(response.jsonPath().getString("success"),"true","校验兑换失败");
logger.info("用户成功兑换一次"); logger.info("用户成功兑换一次");
Thread.sleep(6000);
//再次兑换 //再次兑换
try{ try{
response = couponExchangeService.phonebillExchange(authorization.dafuwengLogin(uid),"10"); response = couponExchangeService.phonebillExchange(authorization.dafuwengLogin(uid),"10");
response.prettyPrint(); // response.prettyPrint();
logger.info(response.asString());
}catch (Exception e){ }catch (Exception e){
message = e.toString(); message = e.toString();
...@@ -89,15 +93,19 @@ public class 多档位话费_兑换流程测试_ExchangeTest extends CheckTemple ...@@ -89,15 +93,19 @@ public class 多档位话费_兑换流程测试_ExchangeTest extends CheckTemple
try{ try{
//话费第一次兑换 //话费第一次兑换
Thread.sleep(5000);
Response response = couponExchangeService.phonebillExchange(authorization.dafuwengLogin(uid),"20"); Response response = couponExchangeService.phonebillExchange(authorization.dafuwengLogin(uid),"20");
response.prettyPrint(); response.prettyPrint();
Assert.assertEquals(response.jsonPath().getString("success"),"true","校验兑换失败"); Assert.assertEquals(response.jsonPath().getString("success"),"true","校验兑换失败");
logger.info("用户成功兑换一次"); logger.info("用户成功兑换一次");
Thread.sleep(6000);
//再次兑换 //再次兑换
try{ try{
response = couponExchangeService.phonebillExchange(authorization.dafuwengLogin(uid),"20"); response = couponExchangeService.phonebillExchange(authorization.dafuwengLogin(uid),"20");
response.prettyPrint(); response.prettyPrint();
logger.info(response.asString());
}catch (Exception e){ }catch (Exception e){
message = e.toString(); message = e.toString();
...@@ -132,20 +140,24 @@ public class 多档位话费_兑换流程测试_ExchangeTest extends CheckTemple ...@@ -132,20 +140,24 @@ public class 多档位话费_兑换流程测试_ExchangeTest extends CheckTemple
try{ try{
//话费第一次兑换 //话费第一次兑换
Thread.sleep(5000);
Response response = couponExchangeService.phonebillExchange(authorization.dafuwengLogin(uid),"50"); Response response = couponExchangeService.phonebillExchange(authorization.dafuwengLogin(uid),"50");
response.prettyPrint(); response.prettyPrint();
Assert.assertEquals(response.jsonPath().getString("success"),"true","校验兑换失败"); Assert.assertEquals(response.jsonPath().getString("success"),"true","校验兑换失败");
logger.info("用户成功兑换一次"); logger.info("用户成功兑换一次");
Thread.sleep(6000);
//再次兑换 //再次兑换
try{ try{
response = couponExchangeService.phonebillExchange(authorization.dafuwengLogin(uid),"50"); response = couponExchangeService.phonebillExchange(authorization.dafuwengLogin(uid),"50");
response.prettyPrint(); // response.prettyPrint();
logger.info(response.asString());
}catch (Exception e){ }catch (Exception e){
message = e.toString(); message = e.toString();
} }
logger.info(response.asString());
logger.info("message: " + message); logger.info("message: " + message);
//获取按钮状态 //获取按钮状态
...@@ -181,6 +193,7 @@ public class 多档位话费_兑换流程测试_ExchangeTest extends CheckTemple ...@@ -181,6 +193,7 @@ public class 多档位话费_兑换流程测试_ExchangeTest extends CheckTemple
//会员等级无法兑换 //会员等级无法兑换
try{ try{
// Thread.sleep(3000);
Response response = couponExchangeService.phonebillExchange(authorization.dafuwengLogin(uid),degreeId); Response response = couponExchangeService.phonebillExchange(authorization.dafuwengLogin(uid),degreeId);
response.prettyPrint(); response.prettyPrint();
...@@ -189,6 +202,7 @@ public class 多档位话费_兑换流程测试_ExchangeTest extends CheckTemple ...@@ -189,6 +202,7 @@ public class 多档位话费_兑换流程测试_ExchangeTest extends CheckTemple
} }
logger.info(message); logger.info(message);
Thread.sleep(3000);
//会员等级可兑换,vip=5 //会员等级可兑换,vip=5
Response response = couponExchangeService.phonebillExchange(authorization.generateSignAutoLogin("42vkFzeLnoNjXt6AhMM7LPj4G8pT",vipUid),degreeId); Response response = couponExchangeService.phonebillExchange(authorization.generateSignAutoLogin("42vkFzeLnoNjXt6AhMM7LPj4G8pT",vipUid),degreeId);
response.prettyPrint(); response.prettyPrint();
......
...@@ -157,7 +157,7 @@ public class 开发者账户余额校验测试_ExchangeTest extends CheckTemplet ...@@ -157,7 +157,7 @@ public class 开发者账户余额校验测试_ExchangeTest extends CheckTemplet
//判断订单是否审核成功,如果订单没有成功则继续审核 //判断订单是否审核成功,如果订单没有成功则继续审核
int j =10; int j =10;
while (j > 0 && !flowWork.equals("Success-complete")) { while (j > 0 && !flowWork.equals("Success-complete")) {
Thread.sleep(1000); Thread.sleep(3000);
auditResponse = dsOrderService.submitAudit(orderId,"pass","zhaoran@duiba.com.cn"); auditResponse = dsOrderService.submitAudit(orderId,"pass","zhaoran@duiba.com.cn");
mapOrder = jdbc.findSimpleResult("SELECT * FROM "+Database.orders_consumer+"."+Database.orders8+" where id ="+orderId); mapOrder = jdbc.findSimpleResult("SELECT * FROM "+Database.orders_consumer+"."+Database.orders8+" where id ="+orderId);
flowWork = String.valueOf(mapOrder.get("flowwork_stage")); flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
......
...@@ -59,16 +59,25 @@ public class 自有新优惠券_兑换限制测试_ExchangeTest extends CheckTem ...@@ -59,16 +59,25 @@ public class 自有新优惠券_兑换限制测试_ExchangeTest extends CheckTem
Object[][] result = null; Object[][] result = null;
if (method.getName().equals("日期兑换限制测试")) { if (method.getName().equals("日期兑换限制测试")) {
result = new Object[][]{ result = new Object[][]{
new Object[]{1, "194281",78,"实物日期兑换限制未开始测试"}, //case1 new Object[]{1, "194281",78,"优惠券日期兑换限制未开始测试"}, //case1
new Object[]{2, "194282",79,"实物日期兑换限制进行中测试"}, //case2 new Object[]{2, "194282",79,"优惠券日期兑换限制进行中测试"}, //case2
new Object[]{3, "194283",80,"实物日期兑换限制已结束"}, //case3 new Object[]{3, "194283",80,"优惠券日期兑换限制已结束"}, //case3
}; };
} }
if (method.getName().equals("库存不足测试")) { if (method.getName().equals("库存不足测试")) {
result = new Object[][]{ result = new Object[][]{
new Object[]{"193847", "实物库存不足测试"}, //case1 new Object[]{"193847", "优惠券库存不足测试"}, //case1
}; };
} }
if (method.getName().equals("优惠券马上使用按钮测试")){
result = new Object[][]{
new Object[]{1,"194961",96, "普通券马上使用按钮测试"}, //case1
new Object[]{2,"194962", 97, "链接券马上使用按钮测试"}, //case2
new Object[]{3,"194963", 98, "重复券马上使用按钮测试"}, //case2
};
}
return result; return result;
} }
@Test @Test
...@@ -78,6 +87,7 @@ public class 自有新优惠券_兑换限制测试_ExchangeTest extends CheckTem ...@@ -78,6 +87,7 @@ public class 自有新优惠券_兑换限制测试_ExchangeTest extends CheckTem
try{ try{
//第一次兑换 //第一次兑换
Thread.sleep(4000);
Response response = gawService.couponExchange(uid, appItemId,38); Response response = gawService.couponExchange(uid, appItemId,38);
response.prettyPrint(); response.prettyPrint();
String orderId = response.jsonPath().getString("data.orderId"); String orderId = response.jsonPath().getString("data.orderId");
...@@ -101,7 +111,7 @@ public class 自有新优惠券_兑换限制测试_ExchangeTest extends CheckTem ...@@ -101,7 +111,7 @@ public class 自有新优惠券_兑换限制测试_ExchangeTest extends CheckTem
logger.info("商品兑换按钮:" + exchangeText); logger.info("商品兑换按钮:" + exchangeText);
//第二次兑换 //第二次兑换
Thread.sleep(3000); Thread.sleep(4000);
try{ try{
response = gawService.couponExchange(uid, appItemId,38); response = gawService.couponExchange(uid, appItemId,38);
response.prettyPrint(); response.prettyPrint();
...@@ -135,6 +145,7 @@ public class 自有新优惠券_兑换限制测试_ExchangeTest extends CheckTem ...@@ -135,6 +145,7 @@ public class 自有新优惠券_兑换限制测试_ExchangeTest extends CheckTem
try{ try{
Thread.sleep(4000);
//第一次兑换 //第一次兑换
Response response = gawService.couponExchange(uid, appItemId,40); Response response = gawService.couponExchange(uid, appItemId,40);
String orderId = response.jsonPath().getString("data.orderId"); String orderId = response.jsonPath().getString("data.orderId");
...@@ -152,7 +163,7 @@ public class 自有新优惠券_兑换限制测试_ExchangeTest extends CheckTem ...@@ -152,7 +163,7 @@ public class 自有新优惠券_兑换限制测试_ExchangeTest extends CheckTem
i--; i--;
} }
Thread.sleep(3000); Thread.sleep(4000);
Response detailResponse = mobileService.appItemDetail(authorization.dafuwengLogin(uid),appItemId); Response detailResponse = mobileService.appItemDetail(authorization.dafuwengLogin(uid),appItemId);
detailResponse.prettyPrint(); detailResponse.prettyPrint();
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1); String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
...@@ -196,6 +207,7 @@ public class 自有新优惠券_兑换限制测试_ExchangeTest extends CheckTem ...@@ -196,6 +207,7 @@ public class 自有新优惠券_兑换限制测试_ExchangeTest extends CheckTem
String appItemId = "193845"; String appItemId = "193845";
try{ try{
Thread.sleep(4000);
//第一次兑换 //第一次兑换
Response response = gawService.couponExchange(uid, appItemId,42); Response response = gawService.couponExchange(uid, appItemId,42);
String orderId = response.jsonPath().getString("data.orderId"); String orderId = response.jsonPath().getString("data.orderId");
...@@ -207,7 +219,7 @@ public class 自有新优惠券_兑换限制测试_ExchangeTest extends CheckTem ...@@ -207,7 +219,7 @@ public class 自有新优惠券_兑换限制测试_ExchangeTest extends CheckTem
//异步接口,直到兑换成功 //异步接口,直到兑换成功
while (i > 0 && "兑换正在处理中...".equals(message)) { while (i > 0 && "兑换正在处理中...".equals(message)) {
Thread.sleep(1000); Thread.sleep(1000);
response = mobileService.orderStatusQuery(uid,orderId); response = tawService.orderStatus(orderId,uid);
response.prettyPrint(); response.prettyPrint();
message = response.jsonPath().getString("message"); message = response.jsonPath().getString("message");
i--; i--;
...@@ -219,7 +231,7 @@ public class 自有新优惠券_兑换限制测试_ExchangeTest extends CheckTem ...@@ -219,7 +231,7 @@ public class 自有新优惠券_兑换限制测试_ExchangeTest extends CheckTem
logger.info("商品兑换按钮:" + exchangeText); logger.info("商品兑换按钮:" + exchangeText);
//第二次兑换 //第二次兑换
Thread.sleep(3000); Thread.sleep(4000);
try{ try{
response = gawService.couponExchange(uid, appItemId,42); response = gawService.couponExchange(uid, appItemId,42);
response.prettyPrint(); response.prettyPrint();
...@@ -262,6 +274,7 @@ public class 自有新优惠券_兑换限制测试_ExchangeTest extends CheckTem ...@@ -262,6 +274,7 @@ public class 自有新优惠券_兑换限制测试_ExchangeTest extends CheckTem
String message=null; String message=null;
try{ try{
//兑换 //兑换
Thread.sleep(4000);
Response response = gawService.couponExchange(uid, appItemId,44); Response response = gawService.couponExchange(uid, appItemId,44);
}catch (Exception e){ }catch (Exception e){
...@@ -302,6 +315,7 @@ public class 自有新优惠券_兑换限制测试_ExchangeTest extends CheckTem ...@@ -302,6 +315,7 @@ public class 自有新优惠券_兑换限制测试_ExchangeTest extends CheckTem
//兑换 //兑换
try{ try{
Thread.sleep(4000);
response = gawService.couponExchange(uid, appItemId, skuId); response = gawService.couponExchange(uid, appItemId, skuId);
}catch (Exception e){ }catch (Exception e){
...@@ -351,6 +365,7 @@ public class 自有新优惠券_兑换限制测试_ExchangeTest extends CheckTem ...@@ -351,6 +365,7 @@ public class 自有新优惠券_兑换限制测试_ExchangeTest extends CheckTem
//会员等级无法兑换 //会员等级无法兑换
try{ try{
Thread.sleep(4000);
Response response = gawService.couponExchange(authorization.dafuwengLogin(uid), appItemId,45); Response response = gawService.couponExchange(authorization.dafuwengLogin(uid), appItemId,45);
response.prettyPrint(); response.prettyPrint();
...@@ -360,6 +375,7 @@ public class 自有新优惠券_兑换限制测试_ExchangeTest extends CheckTem ...@@ -360,6 +375,7 @@ public class 自有新优惠券_兑换限制测试_ExchangeTest extends CheckTem
logger.info(message); logger.info(message);
//会员等级可兑换,vip=5 //会员等级可兑换,vip=5
Thread.sleep(4000);
Response response = gawService.couponExchange(authorization.generateSignAutoLogin("3tzVcss7SnAvA5ppT1m1rMPhaBcD",7083,1),appItemId,45); Response response = gawService.couponExchange(authorization.generateSignAutoLogin("3tzVcss7SnAvA5ppT1m1rMPhaBcD",7083,1),appItemId,45);
response.prettyPrint(); response.prettyPrint();
...@@ -376,6 +392,7 @@ public class 自有新优惠券_兑换限制测试_ExchangeTest extends CheckTem ...@@ -376,6 +392,7 @@ public class 自有新优惠券_兑换限制测试_ExchangeTest extends CheckTem
String appItemId = "193844"; String appItemId = "193844";
try{ try{
Thread.sleep(4000);
//第一次兑换 //第一次兑换
Response response = gawService.couponExchange(uid, appItemId,41); Response response = gawService.couponExchange(uid, appItemId,41);
response.prettyPrint(); response.prettyPrint();
...@@ -400,7 +417,7 @@ public class 自有新优惠券_兑换限制测试_ExchangeTest extends CheckTem ...@@ -400,7 +417,7 @@ public class 自有新优惠券_兑换限制测试_ExchangeTest extends CheckTem
logger.info("商品兑换按钮:" + exchangeText); logger.info("商品兑换按钮:" + exchangeText);
//第二次兑换 //第二次兑换
Thread.sleep(3000); Thread.sleep(4000);
try{ try{
response = gawService.couponExchange(uid, appItemId,41); response = gawService.couponExchange(uid, appItemId,41);
response.prettyPrint(); response.prettyPrint();
...@@ -427,4 +444,74 @@ public class 自有新优惠券_兑换限制测试_ExchangeTest extends CheckTem ...@@ -427,4 +444,74 @@ public class 自有新优惠券_兑换限制测试_ExchangeTest extends CheckTem
} }
/**
* @param caseNum 用例编号
* @param appItemId 商品入库Id
* @param skuId skuId
* @param caseName 用例名称打印
* @throws Exception
*/
@Test(dataProvider = "providerMethod")
public void 优惠券马上使用按钮测试(int caseNum, String appItemId, int skuId, String caseName)throws Exception{
int uid = 7028;
logger.info(caseName);
//优惠券兑换
Thread.sleep(4000);
Response response = gawService.couponExchange(authorization.dafuwengLogin(uid),appItemId,skuId);
response.prettyPrint();
String orderId = response.jsonPath().getString("data.orderId");
//获取兑换结果
response = tawService.orderStatus(orderId,uid);
response.prettyPrint();
String message = response.jsonPath().getString("message");
int i = 10;
//异步接口,直到兑换成功
while (i > 0 && "兑换正在处理中...".equals(message)) {
Thread.sleep(1000);
response = tawService.orderStatus(orderId,uid);
response.prettyPrint();
message = response.jsonPath().getString("message");
i--;
}
//优惠券订单结果页
Thread.sleep(4000);
Response detailResponse = tawService.detailItems(orderId,uid);
String useButtonText = detailResponse.jsonPath().getString("data[0].useButtonText");
String iosDownloadUrl = detailResponse.jsonPath().getString("data[0].iosDownloadUrl");
String credits = detailResponse.jsonPath().getString("data[0].credits");
logger.info("跳转链接:"+ iosDownloadUrl);
switch (caseNum){
case 1:
Assert.assertEquals(useButtonText,"去使用","校验按钮文案失败");
Assert.assertEquals(iosDownloadUrl,"https://www.duiba.com.cn","校验按钮跳转链接失败");
Assert.assertEquals(credits,"100","校验积分失败");
logger.info("校验普通券码跳转按钮成功");
break;
case 2:
Assert.assertEquals(useButtonText,"去使用","校验按钮文案失败");
Assert.assertEquals(iosDownloadUrl,"https://www.iqiyi.com","校验按钮跳转链接失败");
Assert.assertEquals(credits,"100","校验积分失败");
logger.info("校验链接券跳转按钮成功");
break;
case 3:
Assert.assertEquals(useButtonText,"去使用","校验按钮文案失败");
Assert.assertEquals(iosDownloadUrl,"https://www.baidu.com","校验按钮跳转链接失败");
Assert.assertEquals(credits,"100","校验积分失败");
logger.info("校验重复券跳转按钮成功");
break;
}
}
} }
...@@ -29,6 +29,7 @@ import static io.restassured.config.RestAssuredConfig.newConfig; ...@@ -29,6 +29,7 @@ import static io.restassured.config.RestAssuredConfig.newConfig;
*/ */
public class 自有新卡密_兑换限制测试_ExchangeTest extends CheckTemplet { public class 自有新卡密_兑换限制测试_ExchangeTest extends CheckTemplet {
/** /**
* 15968831723 duibaduiba123
* 查询库存 SELECT stock_id,id from tb_goods_batch where gtype = 6 and gid = 50 //gtype=6 表示卡密类型,gid 是卡密的id,查到的id是goods_batch_id * 查询库存 SELECT stock_id,id from tb_goods_batch where gtype = 6 and gid = 50 //gtype=6 表示卡密类型,gid 是卡密的id,查到的id是goods_batch_id
* 修改卡密为未使用状态:UPDATE tb_goods_coupon_0014 set status = 0 where goods_batch_id = 145835 //goods_batch_id为tb_goods_batch表中查到的id,tb_goods_coupon_0014 1024分表 卡密的id%1024 * 修改卡密为未使用状态:UPDATE tb_goods_coupon_0014 set status = 0 where goods_batch_id = 145835 //goods_batch_id为tb_goods_batch表中查到的id,tb_goods_coupon_0014 1024分表 卡密的id%1024
*/ */
...@@ -56,6 +57,7 @@ public class 自有新卡密_兑换限制测试_ExchangeTest extends CheckTemple ...@@ -56,6 +57,7 @@ public class 自有新卡密_兑换限制测试_ExchangeTest extends CheckTemple
jdbc.update("DELETE FROM credits_dev.consumer_limit_record_only where consumer_id = ?",consumerId); jdbc.update("DELETE FROM credits_dev.consumer_limit_record_only where consumer_id = ?",consumerId);
jdbc.update("DELETE FROM goods.tb_everyday_limit where app_item_id=194594"); jdbc.update("DELETE FROM goods.tb_everyday_limit where app_item_id=194594");
} catch (SQLException e) { } catch (SQLException e) {
e.printStackTrace(); e.printStackTrace();
} }
...@@ -94,6 +96,7 @@ public class 自有新卡密_兑换限制测试_ExchangeTest extends CheckTemple ...@@ -94,6 +96,7 @@ public class 自有新卡密_兑换限制测试_ExchangeTest extends CheckTemple
try{ try{
//第一次兑换 //第一次兑换
Thread.sleep(4000);
Response response = gawService.couponExchange(uid, appItemId,47); Response response = gawService.couponExchange(uid, appItemId,47);
response.prettyPrint(); response.prettyPrint();
String orderId = response.jsonPath().getString("data.orderId"); String orderId = response.jsonPath().getString("data.orderId");
...@@ -111,13 +114,14 @@ public class 自有新卡密_兑换限制测试_ExchangeTest extends CheckTemple ...@@ -111,13 +114,14 @@ public class 自有新卡密_兑换限制测试_ExchangeTest extends CheckTemple
i--; i--;
} }
Thread.sleep(4000);
Response detailResponse = mobileService.appItemDetail(authorization.dafuwengLogin(uid),appItemId); Response detailResponse = mobileService.appItemDetail(authorization.dafuwengLogin(uid),appItemId);
detailResponse.prettyPrint(); detailResponse.prettyPrint();
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1); String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
logger.info("商品兑换按钮:" + exchangeText); logger.info("商品兑换按钮:" + exchangeText);
//第二次兑换 //第二次兑换
Thread.sleep(3000);
try{ try{
response = gawService.couponExchange(uid, appItemId,47); response = gawService.couponExchange(uid, appItemId,47);
response.prettyPrint(); response.prettyPrint();
...@@ -153,6 +157,7 @@ public class 自有新卡密_兑换限制测试_ExchangeTest extends CheckTemple ...@@ -153,6 +157,7 @@ public class 自有新卡密_兑换限制测试_ExchangeTest extends CheckTemple
try{ try{
//第一次兑换 //第一次兑换
Thread.sleep(4000);
Response response = gawService.couponExchange(uid, appItemId,82); Response response = gawService.couponExchange(uid, appItemId,82);
String orderId = response.jsonPath().getString("data.orderId"); String orderId = response.jsonPath().getString("data.orderId");
//获取兑换结果 //获取兑换结果
...@@ -169,13 +174,13 @@ public class 自有新卡密_兑换限制测试_ExchangeTest extends CheckTemple ...@@ -169,13 +174,13 @@ public class 自有新卡密_兑换限制测试_ExchangeTest extends CheckTemple
i--; i--;
} }
Thread.sleep(4000);
Response detailResponse = mobileService.appItemDetail(authorization.dafuwengLogin(uid),appItemId); Response detailResponse = mobileService.appItemDetail(authorization.dafuwengLogin(uid),appItemId);
detailResponse.prettyPrint(); detailResponse.prettyPrint();
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1); String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
logger.info("商品兑换按钮:" + exchangeText); logger.info("商品兑换按钮:" + exchangeText);
//第二次兑换 //第二次兑换
Thread.sleep(3000);
try{ try{
response = gawService.couponExchange(uid, appItemId,82); response = gawService.couponExchange(uid, appItemId,82);
response.prettyPrint(); response.prettyPrint();
...@@ -212,6 +217,7 @@ public class 自有新卡密_兑换限制测试_ExchangeTest extends CheckTemple ...@@ -212,6 +217,7 @@ public class 自有新卡密_兑换限制测试_ExchangeTest extends CheckTemple
try{ try{
//第一次兑换 //第一次兑换
Thread.sleep(4000);
Response response = gawService.couponExchange(uid, appItemId,83); Response response = gawService.couponExchange(uid, appItemId,83);
String orderId = response.jsonPath().getString("data.orderId"); String orderId = response.jsonPath().getString("data.orderId");
//获取兑换结果 //获取兑换结果
...@@ -234,7 +240,7 @@ public class 自有新卡密_兑换限制测试_ExchangeTest extends CheckTemple ...@@ -234,7 +240,7 @@ public class 自有新卡密_兑换限制测试_ExchangeTest extends CheckTemple
logger.info("商品兑换按钮:" + exchangeText); logger.info("商品兑换按钮:" + exchangeText);
//第二次兑换 //第二次兑换
Thread.sleep(3000); Thread.sleep(4000);
try{ try{
response = gawService.couponExchange(uid, appItemId,83); response = gawService.couponExchange(uid, appItemId,83);
response.prettyPrint(); response.prettyPrint();
...@@ -277,6 +283,7 @@ public class 自有新卡密_兑换限制测试_ExchangeTest extends CheckTemple ...@@ -277,6 +283,7 @@ public class 自有新卡密_兑换限制测试_ExchangeTest extends CheckTemple
String message=null; String message=null;
try{ try{
//兑换 //兑换
Thread.sleep(4000);
Response response = gawService.couponExchange(uid, appItemId,84); Response response = gawService.couponExchange(uid, appItemId,84);
}catch (Exception e){ }catch (Exception e){
...@@ -318,6 +325,7 @@ public class 自有新卡密_兑换限制测试_ExchangeTest extends CheckTemple ...@@ -318,6 +325,7 @@ public class 自有新卡密_兑换限制测试_ExchangeTest extends CheckTemple
//兑换 //兑换
try{ try{
Thread.sleep(4000);
response = gawService.couponExchange(authorization.dafuwengLogin(uid), appItemId, skuId); response = gawService.couponExchange(authorization.dafuwengLogin(uid), appItemId, skuId);
}catch (Exception e){ }catch (Exception e){
...@@ -353,16 +361,18 @@ public class 自有新卡密_兑换限制测试_ExchangeTest extends CheckTemple ...@@ -353,16 +361,18 @@ public class 自有新卡密_兑换限制测试_ExchangeTest extends CheckTemple
} }
}catch (Exception e){ }catch (Exception e){
jdbc.update("UPDATE goods_coupon.tb_goods_coupon_0049 set status = 0 where id = 125"); throw e;
jdbc.update("UPDATE stock.tb_stock set stock=6 where stock_id =947359306160170049");
}finally {
jdbc.update("UPDATE goods_coupon.tb_goods_coupon_0051 set status = 0 where id = 197");
jdbc.update("UPDATE stock.tb_stock set stock=1 where stock_id =950159001410170051");
} }
} }
// @Test @Test
public void 会员等级测试()throws Exception{ public void 会员等级测试()throws Exception{
String appItemId = "194612"; String appItemId = "194612";
...@@ -373,6 +383,7 @@ public class 自有新卡密_兑换限制测试_ExchangeTest extends CheckTemple ...@@ -373,6 +383,7 @@ public class 自有新卡密_兑换限制测试_ExchangeTest extends CheckTemple
//会员等级无法兑换 //会员等级无法兑换
try{ try{
Thread.sleep(4000);
Response response = gawService.couponExchange(authorization.dafuwengLogin(uid), appItemId,86); Response response = gawService.couponExchange(authorization.dafuwengLogin(uid), appItemId,86);
response.prettyPrint(); response.prettyPrint();
...@@ -382,6 +393,7 @@ public class 自有新卡密_兑换限制测试_ExchangeTest extends CheckTemple ...@@ -382,6 +393,7 @@ public class 自有新卡密_兑换限制测试_ExchangeTest extends CheckTemple
logger.info(message); logger.info(message);
//会员等级可兑换,vip=5 //会员等级可兑换,vip=5
Thread.sleep(4000);
Response response = gawService.couponExchange(authorization.generateSignAutoLogin("3tzVcss7SnAvA5ppT1m1rMPhaBcD",7083,1),appItemId,86); Response response = gawService.couponExchange(authorization.generateSignAutoLogin("3tzVcss7SnAvA5ppT1m1rMPhaBcD",7083,1),appItemId,86);
response.prettyPrint(); response.prettyPrint();
...@@ -395,9 +407,10 @@ public class 自有新卡密_兑换限制测试_ExchangeTest extends CheckTemple ...@@ -395,9 +407,10 @@ public class 自有新卡密_兑换限制测试_ExchangeTest extends CheckTemple
throw new Exception("异常信息打印:" + e); throw new Exception("异常信息打印:" + e);
}finally { }finally {
Thread.sleep(2000);
jdbc.update("UPDATE goods_coupon.tb_goods_coupon_0044 set status = 0 where id = 185"); jdbc.update("UPDATE goods_coupon.tb_goods_coupon_0056 set status = 0 where gtype=6 and gid=56");
jdbc.update("UPDATE stock.tb_stock set stock=6 where stock_id =947339907522670044"); jdbc.update("UPDATE stock.tb_stock set stock=6 where stock_id =951829433813920056");
} }
...@@ -411,6 +424,7 @@ public class 自有新卡密_兑换限制测试_ExchangeTest extends CheckTemple ...@@ -411,6 +424,7 @@ public class 自有新卡密_兑换限制测试_ExchangeTest extends CheckTemple
try{ try{
//第一次兑换 //第一次兑换
Thread.sleep(4000);
Response response = gawService.couponExchange(uid, appItemId,85); Response response = gawService.couponExchange(uid, appItemId,85);
response.prettyPrint(); response.prettyPrint();
String orderId = response.jsonPath().getString("data.orderId"); String orderId = response.jsonPath().getString("data.orderId");
...@@ -434,7 +448,7 @@ public class 自有新卡密_兑换限制测试_ExchangeTest extends CheckTemple ...@@ -434,7 +448,7 @@ public class 自有新卡密_兑换限制测试_ExchangeTest extends CheckTemple
logger.info("商品兑换按钮:" + exchangeText); logger.info("商品兑换按钮:" + exchangeText);
//第二次兑换 //第二次兑换
Thread.sleep(3000); Thread.sleep(4000);
try{ try{
response = gawService.couponExchange(uid, appItemId,85); response = gawService.couponExchange(uid, appItemId,85);
response.prettyPrint(); response.prettyPrint();
...@@ -463,4 +477,9 @@ public class 自有新卡密_兑换限制测试_ExchangeTest extends CheckTemple ...@@ -463,4 +477,9 @@ public class 自有新卡密_兑换限制测试_ExchangeTest extends CheckTemple
} }
} }
...@@ -73,6 +73,7 @@ public class 自有新实物_兑换流程测试_ExchangeTest extends CheckTemple ...@@ -73,6 +73,7 @@ public class 自有新实物_兑换流程测试_ExchangeTest extends CheckTemple
try{ try{
//第一次兑换 //第一次兑换
Thread.sleep(3000);
Response response = gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits); Response response = gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits);
String orderId = response.jsonPath().getString("data.orderId"); String orderId = response.jsonPath().getString("data.orderId");
//获取兑换结果 //获取兑换结果
...@@ -124,6 +125,7 @@ public class 自有新实物_兑换流程测试_ExchangeTest extends CheckTemple ...@@ -124,6 +125,7 @@ public class 自有新实物_兑换流程测试_ExchangeTest extends CheckTemple
String credits="2"; String credits="2";
try{ try{
//第一次兑换 //第一次兑换
Thread.sleep(3000);
Response response = gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits); Response response = gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits);
logger.info("********1"+"111111"); logger.info("********1"+"111111");
String orderId = response.jsonPath().getString("data.orderId"); String orderId = response.jsonPath().getString("data.orderId");
...@@ -176,6 +178,7 @@ public class 自有新实物_兑换流程测试_ExchangeTest extends CheckTemple ...@@ -176,6 +178,7 @@ public class 自有新实物_兑换流程测试_ExchangeTest extends CheckTemple
String credits="3"; String credits="3";
try{ try{
//第一次兑换 //第一次兑换
Thread.sleep(3000);
Response response = gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits); Response response = gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits);
String orderId = response.jsonPath().getString("data.orderId"); String orderId = response.jsonPath().getString("data.orderId");
//获取兑换结果 //获取兑换结果
...@@ -227,6 +230,7 @@ public class 自有新实物_兑换流程测试_ExchangeTest extends CheckTemple ...@@ -227,6 +230,7 @@ public class 自有新实物_兑换流程测试_ExchangeTest extends CheckTemple
String credits="5"; String credits="5";
try{ try{
//第一次兑换 //第一次兑换
Thread.sleep(3000);
Response response = gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits); Response response = gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits);
String orderId = response.jsonPath().getString("data.orderId"); String orderId = response.jsonPath().getString("data.orderId");
//获取兑换结果 //获取兑换结果
...@@ -280,6 +284,8 @@ public class 自有新实物_兑换流程测试_ExchangeTest extends CheckTemple ...@@ -280,6 +284,8 @@ public class 自有新实物_兑换流程测试_ExchangeTest extends CheckTemple
logger.info(caseName); logger.info(caseName);
//兑换 //兑换
try{ try{
Thread.sleep(3000);
Response response = gawService.objectExchange(uid,appItemId,itemId); Response response = gawService.objectExchange(uid,appItemId,itemId);
response.prettyPrint(); response.prettyPrint();
}catch (Exception e){ }catch (Exception e){
...@@ -330,6 +336,8 @@ public class 自有新实物_兑换流程测试_ExchangeTest extends CheckTemple ...@@ -330,6 +336,8 @@ public class 自有新实物_兑换流程测试_ExchangeTest extends CheckTemple
logger.info("商品兑换按钮:" + exchangeText); logger.info("商品兑换按钮:" + exchangeText);
try{ try{
Thread.sleep(3000);
Response response = gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits); Response response = gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits);
response.prettyPrint(); response.prettyPrint();
...@@ -355,6 +363,7 @@ public class 自有新实物_兑换流程测试_ExchangeTest extends CheckTemple ...@@ -355,6 +363,7 @@ public class 自有新实物_兑换流程测试_ExchangeTest extends CheckTemple
//会员等级无法兑换 //会员等级无法兑换
try{ try{
//会员等级可兑换,vip=5 //会员等级可兑换,vip=5
Thread.sleep(3000);
Response response =gawService.objectExchange(uid,appItemId,itemId); Response response =gawService.objectExchange(uid,appItemId,itemId);
response.prettyPrint(); response.prettyPrint();
......
...@@ -77,6 +77,7 @@ public class 自有新虚拟商品_充值_兑换限制_ExchangeTest extends Chec ...@@ -77,6 +77,7 @@ public class 自有新虚拟商品_充值_兑换限制_ExchangeTest extends Chec
try{ try{
//第一次兑换 //第一次兑换
Thread.sleep(4000);
Response response = gawService.virtualExchange(cookie, appItemId,48); Response response = gawService.virtualExchange(cookie, appItemId,48);
response.prettyPrint(); response.prettyPrint();
String orderId = response.jsonPath().getString("data.orderId"); String orderId = response.jsonPath().getString("data.orderId");
...@@ -100,7 +101,7 @@ public class 自有新虚拟商品_充值_兑换限制_ExchangeTest extends Chec ...@@ -100,7 +101,7 @@ public class 自有新虚拟商品_充值_兑换限制_ExchangeTest extends Chec
logger.info("商品兑换按钮:" + exchangeText); logger.info("商品兑换按钮:" + exchangeText);
//第二次兑换 //第二次兑换
Thread.sleep(3000); Thread.sleep(4000);
try{ try{
response = gawService.virtualExchange(cookie, appItemId,48);; response = gawService.virtualExchange(cookie, appItemId,48);;
response.prettyPrint(); response.prettyPrint();
...@@ -135,6 +136,7 @@ public class 自有新虚拟商品_充值_兑换限制_ExchangeTest extends Chec ...@@ -135,6 +136,7 @@ public class 自有新虚拟商品_充值_兑换限制_ExchangeTest extends Chec
try{ try{
//第一次兑换 //第一次兑换
Thread.sleep(4000);
Response response = gawService.virtualExchange(cookie, appItemId,54); Response response = gawService.virtualExchange(cookie, appItemId,54);
String orderId = response.jsonPath().getString("data.orderId"); String orderId = response.jsonPath().getString("data.orderId");
//获取兑换结果 //获取兑换结果
...@@ -157,7 +159,7 @@ public class 自有新虚拟商品_充值_兑换限制_ExchangeTest extends Chec ...@@ -157,7 +159,7 @@ public class 自有新虚拟商品_充值_兑换限制_ExchangeTest extends Chec
logger.info("商品兑换按钮:" + exchangeText); logger.info("商品兑换按钮:" + exchangeText);
//第二次兑换 //第二次兑换
Thread.sleep(3000); Thread.sleep(4000);
try{ try{
response = gawService.virtualExchange(cookie, appItemId,54); response = gawService.virtualExchange(cookie, appItemId,54);
response.prettyPrint(); response.prettyPrint();
...@@ -195,6 +197,7 @@ public class 自有新虚拟商品_充值_兑换限制_ExchangeTest extends Chec ...@@ -195,6 +197,7 @@ public class 自有新虚拟商品_充值_兑换限制_ExchangeTest extends Chec
try{ try{
//第一次兑换 //第一次兑换
Thread.sleep(4000);
Response response = gawService.virtualExchange(cookie, appItemId,55); Response response = gawService.virtualExchange(cookie, appItemId,55);
String orderId = response.jsonPath().getString("data.orderId"); String orderId = response.jsonPath().getString("data.orderId");
//获取兑换结果 //获取兑换结果
...@@ -217,7 +220,7 @@ public class 自有新虚拟商品_充值_兑换限制_ExchangeTest extends Chec ...@@ -217,7 +220,7 @@ public class 自有新虚拟商品_充值_兑换限制_ExchangeTest extends Chec
logger.info("商品兑换按钮:" + exchangeText); logger.info("商品兑换按钮:" + exchangeText);
//第二次兑换 //第二次兑换
Thread.sleep(3000); Thread.sleep(4000);
try{ try{
response = gawService.virtualExchange(cookie, appItemId,55); response = gawService.virtualExchange(cookie, appItemId,55);
response.prettyPrint(); response.prettyPrint();
...@@ -260,6 +263,7 @@ public class 自有新虚拟商品_充值_兑换限制_ExchangeTest extends Chec ...@@ -260,6 +263,7 @@ public class 自有新虚拟商品_充值_兑换限制_ExchangeTest extends Chec
String message=null; String message=null;
try{ try{
//兑换 //兑换
Thread.sleep(4000);
Response response = gawService.virtualExchange(cookie, appItemId,57); Response response = gawService.virtualExchange(cookie, appItemId,57);
}catch (Exception e){ }catch (Exception e){
...@@ -300,6 +304,7 @@ public class 自有新虚拟商品_充值_兑换限制_ExchangeTest extends Chec ...@@ -300,6 +304,7 @@ public class 自有新虚拟商品_充值_兑换限制_ExchangeTest extends Chec
//兑换 //兑换
try{ try{
Thread.sleep(4000);
response = gawService.virtualExchange(cookie, appItemId, skuId); response = gawService.virtualExchange(cookie, appItemId, skuId);
}catch (Exception e){ }catch (Exception e){
...@@ -349,6 +354,7 @@ public class 自有新虚拟商品_充值_兑换限制_ExchangeTest extends Chec ...@@ -349,6 +354,7 @@ public class 自有新虚拟商品_充值_兑换限制_ExchangeTest extends Chec
//会员等级无法兑换 //会员等级无法兑换
try{ try{
Thread.sleep(4000);
Response response = gawService.virtualExchange(authorization.dafuwengLogin(uid), appItemId,81); Response response = gawService.virtualExchange(authorization.dafuwengLogin(uid), appItemId,81);
response.prettyPrint(); response.prettyPrint();
...@@ -358,6 +364,7 @@ public class 自有新虚拟商品_充值_兑换限制_ExchangeTest extends Chec ...@@ -358,6 +364,7 @@ public class 自有新虚拟商品_充值_兑换限制_ExchangeTest extends Chec
logger.info(message); logger.info(message);
//会员等级可兑换,vip=5 //会员等级可兑换,vip=5
Thread.sleep(4000);
Response response = gawService.virtualExchange(authorization.generateSignAutoLogin("3tzVcss7SnAvA5ppT1m1rMPhaBcD",7083,1),appItemId,81); Response response = gawService.virtualExchange(authorization.generateSignAutoLogin("3tzVcss7SnAvA5ppT1m1rMPhaBcD",7083,1),appItemId,81);
response.prettyPrint(); response.prettyPrint();
...@@ -375,6 +382,7 @@ public class 自有新虚拟商品_充值_兑换限制_ExchangeTest extends Chec ...@@ -375,6 +382,7 @@ public class 自有新虚拟商品_充值_兑换限制_ExchangeTest extends Chec
try{ try{
//第一次兑换 //第一次兑换
Thread.sleep(4000);
Response response = gawService.virtualExchange(cookie, appItemId,59); Response response = gawService.virtualExchange(cookie, appItemId,59);
response.prettyPrint(); response.prettyPrint();
String orderId = response.jsonPath().getString("data.orderId"); String orderId = response.jsonPath().getString("data.orderId");
...@@ -398,7 +406,7 @@ public class 自有新虚拟商品_充值_兑换限制_ExchangeTest extends Chec ...@@ -398,7 +406,7 @@ public class 自有新虚拟商品_充值_兑换限制_ExchangeTest extends Chec
logger.info("商品兑换按钮:" + exchangeText); logger.info("商品兑换按钮:" + exchangeText);
//第二次兑换 //第二次兑换
Thread.sleep(3000); Thread.sleep(4000);
try{ try{
response = gawService.virtualExchange(cookie, appItemId,59); response = gawService.virtualExchange(cookie, appItemId,59);
response.prettyPrint(); response.prettyPrint();
......
...@@ -8,6 +8,8 @@ import http.service.app.MobileService; ...@@ -8,6 +8,8 @@ import http.service.app.MobileService;
import http.service.app.VirtualExchangeService; import http.service.app.VirtualExchangeService;
import http.service.hd.DappConfigService; import http.service.hd.DappConfigService;
import http.service.hd.DeveloperAccountService; import http.service.hd.DeveloperAccountService;
import http.service.app.CrecordService;
import http.service.app.tawService;
import io.restassured.response.Response; import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert; import org.testng.Assert;
...@@ -41,6 +43,10 @@ public class 自有老优惠券商品_兑换限制测试_ExchangeTest extends Ch ...@@ -41,6 +43,10 @@ public class 自有老优惠券商品_兑换限制测试_ExchangeTest extends Ch
DeveloperAccountService developerAccountService; DeveloperAccountService developerAccountService;
@Autowired @Autowired
DappConfigService dappConfigService; DappConfigService dappConfigService;
@Autowired
CrecordService crecordService;
@Autowired
tawService tawService;
private int uid = 7000; private int uid = 7000;
private String consumerId = "100144141"; private String consumerId = "100144141";
...@@ -78,6 +84,13 @@ public class 自有老优惠券商品_兑换限制测试_ExchangeTest extends Ch ...@@ -78,6 +84,13 @@ public class 自有老优惠券商品_兑换限制测试_ExchangeTest extends Ch
new Object[]{"193826", "实物库存不足测试"}, //case1 new Object[]{"193826", "实物库存不足测试"}, //case1
}; };
} }
if (method.getName().equals("优惠券马上使用按钮测试")){
result = new Object[][]{
new Object[]{1,"194958", "自有优惠券普通跳转链接测试"}, //case1
new Object[]{2,"194959", "自有优惠券链接券跳转测试"}, //case2
};
}
return result; return result;
} }
@Test @Test
...@@ -87,6 +100,7 @@ public class 自有老优惠券商品_兑换限制测试_ExchangeTest extends Ch ...@@ -87,6 +100,7 @@ public class 自有老优惠券商品_兑换限制测试_ExchangeTest extends Ch
try{ try{
//第一次兑换 //第一次兑换
Thread.sleep(3000);
Response response = couponExchangeService.couponExchange(authorization.dafuwengLogin(uid), appItemId, null); Response response = couponExchangeService.couponExchange(authorization.dafuwengLogin(uid), appItemId, null);
response.prettyPrint(); response.prettyPrint();
String orderId = response.jsonPath().getString("orderId"); String orderId = response.jsonPath().getString("orderId");
...@@ -145,6 +159,7 @@ public class 自有老优惠券商品_兑换限制测试_ExchangeTest extends Ch ...@@ -145,6 +159,7 @@ public class 自有老优惠券商品_兑换限制测试_ExchangeTest extends Ch
try{ try{
//第一次兑换 //第一次兑换
Thread.sleep(3000);
Response response = couponExchangeService.couponExchange(authorization.dafuwengLogin(uid), appItemId, null); Response response = couponExchangeService.couponExchange(authorization.dafuwengLogin(uid), appItemId, null);
String orderId = response.jsonPath().getString("orderId"); String orderId = response.jsonPath().getString("orderId");
//获取兑换结果 //获取兑换结果
...@@ -205,6 +220,7 @@ public class 自有老优惠券商品_兑换限制测试_ExchangeTest extends Ch ...@@ -205,6 +220,7 @@ public class 自有老优惠券商品_兑换限制测试_ExchangeTest extends Ch
try{ try{
//第一次兑换 //第一次兑换
Thread.sleep(3000);
Response response = couponExchangeService.couponExchange(authorization.dafuwengLogin(uid), appItemId, null); Response response = couponExchangeService.couponExchange(authorization.dafuwengLogin(uid), appItemId, null);
String orderId = response.jsonPath().getString("orderId"); String orderId = response.jsonPath().getString("orderId");
//获取兑换结果 //获取兑换结果
...@@ -270,6 +286,7 @@ public class 自有老优惠券商品_兑换限制测试_ExchangeTest extends Ch ...@@ -270,6 +286,7 @@ public class 自有老优惠券商品_兑换限制测试_ExchangeTest extends Ch
String message=null; String message=null;
try{ try{
//兑换 //兑换
Thread.sleep(3000);
Response response = couponExchangeService.couponExchange(authorization.dafuwengLogin(uid), appItemId, null); Response response = couponExchangeService.couponExchange(authorization.dafuwengLogin(uid), appItemId, null);
}catch (Exception e){ }catch (Exception e){
...@@ -310,6 +327,7 @@ public class 自有老优惠券商品_兑换限制测试_ExchangeTest extends Ch ...@@ -310,6 +327,7 @@ public class 自有老优惠券商品_兑换限制测试_ExchangeTest extends Ch
//兑换 //兑换
try{ try{
Thread.sleep(3000);
response = couponExchangeService.couponExchange(authorization.dafuwengLogin(uid), appItemId, null); response = couponExchangeService.couponExchange(authorization.dafuwengLogin(uid), appItemId, null);
}catch (Exception e){ }catch (Exception e){
...@@ -359,6 +377,7 @@ public class 自有老优惠券商品_兑换限制测试_ExchangeTest extends Ch ...@@ -359,6 +377,7 @@ public class 自有老优惠券商品_兑换限制测试_ExchangeTest extends Ch
//会员等级无法兑换 //会员等级无法兑换
try{ try{
Thread.sleep(3000);
Response response = couponExchangeService.couponExchange(authorization.dafuwengLogin(uid), appItemId,null); Response response = couponExchangeService.couponExchange(authorization.dafuwengLogin(uid), appItemId,null);
response.prettyPrint(); response.prettyPrint();
...@@ -368,6 +387,7 @@ public class 自有老优惠券商品_兑换限制测试_ExchangeTest extends Ch ...@@ -368,6 +387,7 @@ public class 自有老优惠券商品_兑换限制测试_ExchangeTest extends Ch
logger.info(message); logger.info(message);
//会员等级可兑换,vip=5 //会员等级可兑换,vip=5
Thread.sleep(3000);
Response response = couponExchangeService.couponExchange(authorization.generateSignAutoLogin("2wGQc3MZaQsqYFWcX4gguya5PnnS",3402),appItemId,null); Response response = couponExchangeService.couponExchange(authorization.generateSignAutoLogin("2wGQc3MZaQsqYFWcX4gguya5PnnS",3402),appItemId,null);
response.prettyPrint(); response.prettyPrint();
...@@ -385,6 +405,7 @@ public class 自有老优惠券商品_兑换限制测试_ExchangeTest extends Ch ...@@ -385,6 +405,7 @@ public class 自有老优惠券商品_兑换限制测试_ExchangeTest extends Ch
try{ try{
//第一次兑换 //第一次兑换
Thread.sleep(3000);
Response response = couponExchangeService.couponExchange(authorization.dafuwengLogin(uid), appItemId, null); Response response = couponExchangeService.couponExchange(authorization.dafuwengLogin(uid), appItemId, null);
response.prettyPrint(); response.prettyPrint();
String orderId = response.jsonPath().getString("orderId"); String orderId = response.jsonPath().getString("orderId");
...@@ -435,4 +456,79 @@ public class 自有老优惠券商品_兑换限制测试_ExchangeTest extends Ch ...@@ -435,4 +456,79 @@ public class 自有老优惠券商品_兑换限制测试_ExchangeTest extends Ch
} }
/**
* @param caseNum 用例编号
* @param appItemId 商品入库Id
* @param caseName 用例名称打印
* @throws Exception
*/
@Test(dataProvider = "providerMethod")
public void 优惠券马上使用按钮测试(int caseNum, String appItemId, String caseName)throws Exception{
logger.info(caseName);
//优惠券兑换
Response response = couponExchangeService.couponExchange(authorization.dafuwengLogin(uid), appItemId, null);
response.prettyPrint();
String orderId = response.jsonPath().getString("orderId");
//获取兑换结果
response = mobileService.orderStatusQuery(uid,orderId);
response.prettyPrint();
String message = response.jsonPath().getString("message");
int i = 10;
//异步接口,直到兑换成功
while (i > 0 && "兑换正在处理中...".equals(message)) {
Thread.sleep(1000);
response = mobileService.orderStatusQuery(uid,orderId);
response.prettyPrint();
message = response.jsonPath().getString("message");
i--;
}
//优惠券兑换结果页
Response resultResponse = crecordService.recordDetail(orderId,uid);
// resultResponse.prettyPrint();
String btnText = MatcherString.getString(resultResponse.asString(),"\"btnText\":\"(.*?)\",",1);
String actualPay = MatcherString.getString(resultResponse.asString(),"\"actualPay\":\"(.*?)\",",1);
String androidDownloadUrl = MatcherString.getString(resultResponse.asString(),"\"androidDownloadUrl\":\"(.*?)\",",1);
logger.info("跳转链接:" + androidDownloadUrl);
//优惠券兑换记录页
Thread.sleep(3000);
Response detailResponse = tawService.detailItems(orderId,uid);
// detailResponse.prettyPrint();
String useButtonText = detailResponse.jsonPath().getString("data[0].useButtonText");
String iosDownloadUrl = detailResponse.jsonPath().getString("data[0].iosDownloadUrl");
switch (caseNum){
case 1:
Assert.assertEquals(btnText,"马上前往","校验结果页按钮文案失败");
Assert.assertEquals(actualPay,"1积分","校验结果页积分文案失败");
Assert.assertEquals(androidDownloadUrl,"//activity.m.duibatest.com.cn/log/redirect?url=http%3A%2F%2Fwww.baidu.com&dpm=2239.25.1.0&dcm=102.194958.0.0","校验结果页按钮链接失败");
Assert.assertEquals(useButtonText,"去使用","校验兑换记录页按钮文案失败");
Assert.assertEquals(iosDownloadUrl,"http://www.iqiyi.com","校验兑换记录页按钮跳转链接失败");
logger.info("校验自有优惠券普通券码跳转按钮成功");
break;
case 2:
Assert.assertEquals(btnText,"马上使用","校验结果页按钮文案失败");
Assert.assertEquals(actualPay,"1积分","校验结果页积分文案失败");
Assert.assertEquals(androidDownloadUrl,"//activity.m.duibatest.com.cn/log/redirect?url=https%3A%2F%2Fhj.vc%2F2fzK&dpm=2239.25.1.0&dcm=102.194959.0.0","校验结果页按钮链接失败");
Assert.assertEquals(useButtonText,"去使用","校验兑换记录页按钮文案失败");
Assert.assertEquals(iosDownloadUrl,"https://hj.vc/2fzK","校验兑换记录页按钮跳转链接失败");
logger.info("校验自有优惠券链接券跳转按钮功");
break;
}
}
} }
...@@ -88,6 +88,7 @@ public class 自有老实物_兑换限制测试_ExchangeTest extends CheckTemple ...@@ -88,6 +88,7 @@ public class 自有老实物_兑换限制测试_ExchangeTest extends CheckTemple
try{ try{
//第一次兑换 //第一次兑换
Thread.sleep(3000);
Response response = couponExchangeService.objectExchange(authorization.dafuwengLogin(uid), appItemId, null, "null", "yrJRr7Cddp2YeQd", "null"); Response response = couponExchangeService.objectExchange(authorization.dafuwengLogin(uid), appItemId, null, "null", "yrJRr7Cddp2YeQd", "null");
response.prettyPrint(); response.prettyPrint();
String orderId = response.jsonPath().getString("orderId"); String orderId = response.jsonPath().getString("orderId");
...@@ -146,6 +147,7 @@ public class 自有老实物_兑换限制测试_ExchangeTest extends CheckTemple ...@@ -146,6 +147,7 @@ public class 自有老实物_兑换限制测试_ExchangeTest extends CheckTemple
try{ try{
//第一次兑换 //第一次兑换
Thread.sleep(3000);
Response response = couponExchangeService.objectExchange(authorization.dafuwengLogin(uid), appItemId, null, "null", "yrJRr7Cddp2YeQd", "null"); Response response = couponExchangeService.objectExchange(authorization.dafuwengLogin(uid), appItemId, null, "null", "yrJRr7Cddp2YeQd", "null");
String orderId = response.jsonPath().getString("orderId"); String orderId = response.jsonPath().getString("orderId");
//获取兑换结果 //获取兑换结果
...@@ -206,6 +208,7 @@ public class 自有老实物_兑换限制测试_ExchangeTest extends CheckTemple ...@@ -206,6 +208,7 @@ public class 自有老实物_兑换限制测试_ExchangeTest extends CheckTemple
try{ try{
//第一次兑换 //第一次兑换
Thread.sleep(3000);
Response response = couponExchangeService.objectExchange(authorization.dafuwengLogin(uid), appItemId, null, "null", "yrJRr7Cddp2YeQd", "null"); Response response = couponExchangeService.objectExchange(authorization.dafuwengLogin(uid), appItemId, null, "null", "yrJRr7Cddp2YeQd", "null");
String orderId = response.jsonPath().getString("orderId"); String orderId = response.jsonPath().getString("orderId");
//获取兑换结果 //获取兑换结果
...@@ -272,6 +275,7 @@ public class 自有老实物_兑换限制测试_ExchangeTest extends CheckTemple ...@@ -272,6 +275,7 @@ public class 自有老实物_兑换限制测试_ExchangeTest extends CheckTemple
String message=null; String message=null;
try{ try{
//兑换 //兑换
Thread.sleep(3000);
Response response = couponExchangeService.objectExchange(authorization.dafuwengLogin(uid), appItemId, null, "null", "yrJRr7Cddp2YeQd", "null"); Response response = couponExchangeService.objectExchange(authorization.dafuwengLogin(uid), appItemId, null, "null", "yrJRr7Cddp2YeQd", "null");
}catch (Exception e){ }catch (Exception e){
...@@ -311,6 +315,7 @@ public class 自有老实物_兑换限制测试_ExchangeTest extends CheckTemple ...@@ -311,6 +315,7 @@ public class 自有老实物_兑换限制测试_ExchangeTest extends CheckTemple
map.put("token",token); map.put("token",token);
//兑换 //兑换
Thread.sleep(3000);
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.dafuwengLogin(uid)).params(map).post(url + "/objectExchange/exchange"); Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.dafuwengLogin(uid)).params(map).post(url + "/objectExchange/exchange");
response.prettyPrint(); response.prettyPrint();
...@@ -352,6 +357,7 @@ public class 自有老实物_兑换限制测试_ExchangeTest extends CheckTemple ...@@ -352,6 +357,7 @@ public class 自有老实物_兑换限制测试_ExchangeTest extends CheckTemple
//会员等级无法兑换 //会员等级无法兑换
try{ try{
Thread.sleep(3000);
Response response = couponExchangeService.objectExchange(authorization.dafuwengLogin(uid), appItemId,null, "null", "yrJRr7Cddp2YeQd", "null"); Response response = couponExchangeService.objectExchange(authorization.dafuwengLogin(uid), appItemId,null, "null", "yrJRr7Cddp2YeQd", "null");
response.prettyPrint(); response.prettyPrint();
...@@ -361,6 +367,7 @@ public class 自有老实物_兑换限制测试_ExchangeTest extends CheckTemple ...@@ -361,6 +367,7 @@ public class 自有老实物_兑换限制测试_ExchangeTest extends CheckTemple
logger.info(message); logger.info(message);
//会员等级可兑换,vip=5 //会员等级可兑换,vip=5
Thread.sleep(3000);
Response response = couponExchangeService.objectExchange(authorization.generateSignAutoLogin("2wGQc3MZaQsqYFWcX4gguya5PnnS",3402),appItemId,null,"null","yrJRr7Cddp2YeQd","null"); Response response = couponExchangeService.objectExchange(authorization.generateSignAutoLogin("2wGQc3MZaQsqYFWcX4gguya5PnnS",3402),appItemId,null,"null","yrJRr7Cddp2YeQd","null");
response.prettyPrint(); response.prettyPrint();
...@@ -378,6 +385,7 @@ public class 自有老实物_兑换限制测试_ExchangeTest extends CheckTemple ...@@ -378,6 +385,7 @@ public class 自有老实物_兑换限制测试_ExchangeTest extends CheckTemple
try{ try{
//第一次兑换 //第一次兑换
Thread.sleep(3000);
Response response = couponExchangeService.objectExchange(authorization.dafuwengLogin(uid), appItemId, null, "null", "yrJRr7Cddp2YeQd", "null"); Response response = couponExchangeService.objectExchange(authorization.dafuwengLogin(uid), appItemId, null, "null", "yrJRr7Cddp2YeQd", "null");
response.prettyPrint(); response.prettyPrint();
String orderId = response.jsonPath().getString("orderId"); String orderId = response.jsonPath().getString("orderId");
......
...@@ -85,6 +85,7 @@ public class 自有老虚拟商品_兑换限制测试_ExchangeTest extends Check ...@@ -85,6 +85,7 @@ public class 自有老虚拟商品_兑换限制测试_ExchangeTest extends Check
try{ try{
//第一次兑换 //第一次兑换
Thread.sleep(4000);
Response response = couponExchangeService.virtualExchange(authorization.dafuwengLogin(uid), appItemId, "123456"); Response response = couponExchangeService.virtualExchange(authorization.dafuwengLogin(uid), appItemId, "123456");
response.prettyPrint(); response.prettyPrint();
String orderId = response.jsonPath().getString("orderId"); String orderId = response.jsonPath().getString("orderId");
...@@ -101,6 +102,7 @@ public class 自有老虚拟商品_兑换限制测试_ExchangeTest extends Check ...@@ -101,6 +102,7 @@ public class 自有老虚拟商品_兑换限制测试_ExchangeTest extends Check
message = response.jsonPath().getString("message"); message = response.jsonPath().getString("message");
i--; i--;
} }
Thread.sleep(4000);
Response detailResponse = mobileService.appItemDetail(authorization.dafuwengLogin(uid),appItemId); Response detailResponse = mobileService.appItemDetail(authorization.dafuwengLogin(uid),appItemId);
detailResponse.prettyPrint(); detailResponse.prettyPrint();
...@@ -108,7 +110,6 @@ public class 自有老虚拟商品_兑换限制测试_ExchangeTest extends Check ...@@ -108,7 +110,6 @@ public class 自有老虚拟商品_兑换限制测试_ExchangeTest extends Check
logger.info("商品兑换按钮:" + exchangeText); logger.info("商品兑换按钮:" + exchangeText);
//第二次兑换 //第二次兑换
Thread.sleep(3000);
try{ try{
response = couponExchangeService.virtualExchange(authorization.dafuwengLogin(uid), appItemId, "123456"); response = couponExchangeService.virtualExchange(authorization.dafuwengLogin(uid), appItemId, "123456");
response.prettyPrint(); response.prettyPrint();
...@@ -143,6 +144,7 @@ public class 自有老虚拟商品_兑换限制测试_ExchangeTest extends Check ...@@ -143,6 +144,7 @@ public class 自有老虚拟商品_兑换限制测试_ExchangeTest extends Check
try{ try{
//第一次兑换 //第一次兑换
Thread.sleep(4000);
Response response = couponExchangeService.virtualExchange(authorization.dafuwengLogin(uid), appItemId, "123456"); Response response = couponExchangeService.virtualExchange(authorization.dafuwengLogin(uid), appItemId, "123456");
String orderId = response.jsonPath().getString("orderId"); String orderId = response.jsonPath().getString("orderId");
//获取兑换结果 //获取兑换结果
...@@ -159,13 +161,14 @@ public class 自有老虚拟商品_兑换限制测试_ExchangeTest extends Check ...@@ -159,13 +161,14 @@ public class 自有老虚拟商品_兑换限制测试_ExchangeTest extends Check
i--; i--;
} }
Thread.sleep(4000);
Response detailResponse = mobileService.appItemDetail(authorization.dafuwengLogin(uid),appItemId); Response detailResponse = mobileService.appItemDetail(authorization.dafuwengLogin(uid),appItemId);
detailResponse.prettyPrint(); detailResponse.prettyPrint();
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1); String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
logger.info("商品兑换按钮:" + exchangeText); logger.info("商品兑换按钮:" + exchangeText);
//第二次兑换 //第二次兑换
Thread.sleep(3000);
try{ try{
response = couponExchangeService.virtualExchange(authorization.dafuwengLogin(uid), appItemId, "123456"); response = couponExchangeService.virtualExchange(authorization.dafuwengLogin(uid), appItemId, "123456");
response.prettyPrint(); response.prettyPrint();
...@@ -203,6 +206,7 @@ public class 自有老虚拟商品_兑换限制测试_ExchangeTest extends Check ...@@ -203,6 +206,7 @@ public class 自有老虚拟商品_兑换限制测试_ExchangeTest extends Check
try{ try{
//第一次兑换 //第一次兑换
Thread.sleep(4000);
Response response = couponExchangeService.virtualExchange(authorization.dafuwengLogin(uid), appItemId, "123456"); Response response = couponExchangeService.virtualExchange(authorization.dafuwengLogin(uid), appItemId, "123456");
String orderId = response.jsonPath().getString("orderId"); String orderId = response.jsonPath().getString("orderId");
//获取兑换结果 //获取兑换结果
...@@ -225,7 +229,7 @@ public class 自有老虚拟商品_兑换限制测试_ExchangeTest extends Check ...@@ -225,7 +229,7 @@ public class 自有老虚拟商品_兑换限制测试_ExchangeTest extends Check
logger.info("商品兑换按钮:" + exchangeText); logger.info("商品兑换按钮:" + exchangeText);
//第二次兑换 //第二次兑换
Thread.sleep(3000); Thread.sleep(4000);
try{ try{
response = couponExchangeService.virtualExchange(authorization.dafuwengLogin(uid), appItemId,"123456"); response = couponExchangeService.virtualExchange(authorization.dafuwengLogin(uid), appItemId,"123456");
response.prettyPrint(); response.prettyPrint();
...@@ -268,6 +272,7 @@ public class 自有老虚拟商品_兑换限制测试_ExchangeTest extends Check ...@@ -268,6 +272,7 @@ public class 自有老虚拟商品_兑换限制测试_ExchangeTest extends Check
String message=null; String message=null;
try{ try{
//兑换 //兑换
Thread.sleep(4000);
Response response = couponExchangeService.virtualExchange(authorization.dafuwengLogin(uid), appItemId, "123456"); Response response = couponExchangeService.virtualExchange(authorization.dafuwengLogin(uid), appItemId, "123456");
}catch (Exception e){ }catch (Exception e){
...@@ -308,6 +313,7 @@ public class 自有老虚拟商品_兑换限制测试_ExchangeTest extends Check ...@@ -308,6 +313,7 @@ public class 自有老虚拟商品_兑换限制测试_ExchangeTest extends Check
//兑换 //兑换
try{ try{
Thread.sleep(4000);
response = couponExchangeService.virtualExchange(authorization.dafuwengLogin(uid), appItemId, "123456"); response = couponExchangeService.virtualExchange(authorization.dafuwengLogin(uid), appItemId, "123456");
}catch (Exception e){ }catch (Exception e){
...@@ -357,6 +363,7 @@ public class 自有老虚拟商品_兑换限制测试_ExchangeTest extends Check ...@@ -357,6 +363,7 @@ public class 自有老虚拟商品_兑换限制测试_ExchangeTest extends Check
//会员等级无法兑换 //会员等级无法兑换
try{ try{
Thread.sleep(4000);
Response response = couponExchangeService.virtualExchange(authorization.dafuwengLogin(uid), appItemId,"123456"); Response response = couponExchangeService.virtualExchange(authorization.dafuwengLogin(uid), appItemId,"123456");
response.prettyPrint(); response.prettyPrint();
...@@ -366,6 +373,7 @@ public class 自有老虚拟商品_兑换限制测试_ExchangeTest extends Check ...@@ -366,6 +373,7 @@ public class 自有老虚拟商品_兑换限制测试_ExchangeTest extends Check
logger.info(message); logger.info(message);
//会员等级可兑换,vip=5 //会员等级可兑换,vip=5
Thread.sleep(4000);
Response response = couponExchangeService.virtualExchange(authorization.generateSignAutoLogin("2wGQc3MZaQsqYFWcX4gguya5PnnS",3402),appItemId,"123456"); Response response = couponExchangeService.virtualExchange(authorization.generateSignAutoLogin("2wGQc3MZaQsqYFWcX4gguya5PnnS",3402),appItemId,"123456");
response.prettyPrint(); response.prettyPrint();
...@@ -383,6 +391,7 @@ public class 自有老虚拟商品_兑换限制测试_ExchangeTest extends Check ...@@ -383,6 +391,7 @@ public class 自有老虚拟商品_兑换限制测试_ExchangeTest extends Check
try{ try{
//第一次兑换 //第一次兑换
Thread.sleep(4000);
Response response = couponExchangeService.virtualExchange(authorization.dafuwengLogin(uid), appItemId, "123456"); Response response = couponExchangeService.virtualExchange(authorization.dafuwengLogin(uid), appItemId, "123456");
response.prettyPrint(); response.prettyPrint();
String orderId = response.jsonPath().getString("orderId"); String orderId = response.jsonPath().getString("orderId");
...@@ -400,13 +409,14 @@ public class 自有老虚拟商品_兑换限制测试_ExchangeTest extends Check ...@@ -400,13 +409,14 @@ public class 自有老虚拟商品_兑换限制测试_ExchangeTest extends Check
i--; i--;
} }
Thread.sleep(4000);
Response detailResponse = mobileService.appItemDetail(authorization.dafuwengLogin(uid),appItemId); Response detailResponse = mobileService.appItemDetail(authorization.dafuwengLogin(uid),appItemId);
detailResponse.prettyPrint(); detailResponse.prettyPrint();
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1); String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
logger.info("商品兑换按钮:" + exchangeText); logger.info("商品兑换按钮:" + exchangeText);
//第二次兑换 //第二次兑换
Thread.sleep(3000);
try{ try{
response = couponExchangeService.virtualExchange(authorization.dafuwengLogin(uid), appItemId, "123456"); response = couponExchangeService.virtualExchange(authorization.dafuwengLogin(uid), appItemId, "123456");
response.prettyPrint(); response.prettyPrint();
......
...@@ -95,10 +95,12 @@ public class 话费_兑换限制测试_ExchangeTest extends CheckTemplet{ ...@@ -95,10 +95,12 @@ public class 话费_兑换限制测试_ExchangeTest extends CheckTemplet{
i--; i--;
} }
Thread.sleep(5000);
try{ try{
response = couponExchangeService.phonebillExchange(authorization.dafuwengLogin(uid), "191656", "1662","5"); response = couponExchangeService.phonebillExchange(authorization.dafuwengLogin(uid), "191656", "1662","5");
}catch (Exception e){ }catch (Exception e){
logger.info(e.getMessage());
Assert.assertTrue(e.getMessage().contains("今日已达兑换上限"),"校验每日限制势失败"); Assert.assertTrue(e.getMessage().contains("今日已达兑换上限"),"校验每日限制势失败");
} }
} }
...@@ -136,6 +138,7 @@ public class 话费_兑换限制测试_ExchangeTest extends CheckTemplet{ ...@@ -136,6 +138,7 @@ public class 话费_兑换限制测试_ExchangeTest extends CheckTemplet{
i--; i--;
} }
Thread.sleep(5000);
try{ try{
response = couponExchangeService.phonebillExchange(authorization.dafuwengLogin(uid), "191657", "1663","10"); response = couponExchangeService.phonebillExchange(authorization.dafuwengLogin(uid), "191657", "1663","10");
...@@ -170,6 +173,7 @@ public class 话费_兑换限制测试_ExchangeTest extends CheckTemplet{ ...@@ -170,6 +173,7 @@ public class 话费_兑换限制测试_ExchangeTest extends CheckTemplet{
logger.info("商品兑换按钮:" + exchangeText); logger.info("商品兑换按钮:" + exchangeText);
//第二次兑换 //第二次兑换
Thread.sleep(5000);
try{ try{
response = couponExchangeService.phonebillExchange(authorization.dafuwengLogin(uid),appItemId,itemId,"20"); response = couponExchangeService.phonebillExchange(authorization.dafuwengLogin(uid),appItemId,itemId,"20");
response.prettyPrint(); response.prettyPrint();
......
package http.cases.NewActivityTest;
import base.DuibaTestBase;
import http.service.Manager.AdminNewDuibaHdtoolService;
import http.service.Activity.NewActivityService;
import org.apache.bcel.generic.NEW;
import utils.MatcherString;
import base.DuibaLog;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
/**
* Created by lvwenyan on 2019/4/4.
*/
public class 兑吧活动工具_新商品_DuibaTest extends DuibaTestBase {
@Autowired
AdminNewDuibaHdtoolService adminNewDuibaHdtoolService;
@Autowired
NewActivityService newActivityService;
@Test(description = "兑吧活动工具添加新实物")
public void 添加新实物奖品() throws Exception{
String type = "object";
String name = "兑吧新实物活动专用";
Response response = adminNewDuibaHdtoolService.ajaxFindItemByName(type,name);
response.prettyPrint();
Assert.assertEquals(response.jsonPath().getString("list[0].appItemId"),"32604","校验appItmId失败");
Assert.assertEquals(response.jsonPath().getString("list[0].title"),"兑吧新实物活动专用","校验title失败");
logger.info("校验兑吧活动工具添加新实物奖品成功");
}
@Test(description = "兑吧活动工具中奖新实物")
public void 中奖新实物奖品() throws Exception{
String activityId = "43752";
String token = "ulxn1sd";
int uid = 7126;
Response response = newActivityService.doJoin2(uid,activityId,token);
response.prettyPrint();
String orderId = response.jsonPath().getString("orderId");
response = newActivityService.getOrderStatus2(uid,orderId);
response.prettyPrint();
String result = String.valueOf(response.jsonPath().getString("result"));
int i= 30;
while(i>0&&(result.equals("0"))){
Thread.sleep(1000);
response = newActivityService.getOrderStatus2(uid,orderId);
result = String.valueOf(response.jsonPath().getString("result"));
i--;
response.prettyPrint();
}
Assert.assertEquals(response.jsonPath().getString("lottery.id"),"28244","校验奖品id失败");
Assert.assertEquals(response.jsonPath().getString("lottery.title"),"兑吧新实物","校验奖品title失败");
logger.info("校验兑吧活动工具中奖新实物成功");
}
}
...@@ -222,7 +222,7 @@ public class 扣库存测试_DuibaTest extends DuibaTestBase { ...@@ -222,7 +222,7 @@ public class 扣库存测试_DuibaTest extends DuibaTestBase {
@Test @Test
public void 自有活动工具扣库存测试() throws Exception { public void 自有活动工具扣库存测试() throws Exception {
//获取兑换项库存 //获取兑换项库存
Response response = developerService.appItems("2239","【自动化勿动】自有优惠券"); Response response = developerService.appItems("2239","【自动化勿动】zr自有优惠券");
//response.prettyPrint(); //response.prettyPrint();
String remind = response.jsonPath().getString("data.list[0].remaind"); String remind = response.jsonPath().getString("data.list[0].remaind");
logger.info("抽奖前兑换项库存为:"+remind); logger.info("抽奖前兑换项库存为:"+remind);
...@@ -240,18 +240,18 @@ public class 扣库存测试_DuibaTest extends DuibaTestBase { ...@@ -240,18 +240,18 @@ public class 扣库存测试_DuibaTest extends DuibaTestBase {
response = this.新活动工具接口传参("28247","abcde","iOS"); response = this.新活动工具接口传参("28247","abcde","iOS");
Assert.assertEquals(response.jsonPath().getString("lottery.type"),"coupon","校验type失败"); Assert.assertEquals(response.jsonPath().getString("lottery.type"),"coupon","校验type失败");
Assert.assertEquals(response.jsonPath().getString("lottery.title"),"【自动化勿动】自有优惠券","校验title失败"); Assert.assertEquals(response.jsonPath().getString("lottery.title"),"【自动化勿动】zr自有优惠券","校验title失败");
Assert.assertTrue(response.jsonPath().getString("lottery.link").contains("/crecord/recordDetailNew?orderId=")); Assert.assertTrue(response.jsonPath().getString("lottery.link").contains("/crecord/recordDetailNew?orderId="));
Assert.assertEquals(response.jsonPath().getString("lottery.id"), "16405", "校验id失败"); Assert.assertEquals(response.jsonPath().getString("lottery.id"), "16405", "校验id失败");
logger.info("校验实物商品:type,title,link,id成功"); logger.info("校验实物商品:type,title,link,id成功");
//校验兑换项库存 //校验兑换项库存
response = developerService.appItems("2239","【自动化勿动】自有优惠券"); response = developerService.appItems("2239","【自动化勿动】zr自有优惠券");
String Newremind = response.jsonPath().getString("data.list[0].remaind"); String Newremind = response.jsonPath().getString("data.list[0].remaind");
int i= 10; int i= 10;
while(i>0 && !Newremind.equals(remind)){ while(i>0 && !Newremind.equals(remind)){
Thread.sleep(500); Thread.sleep(500);
response = developerService.appItems("2239","【自动化勿动】自有优惠券"); response = developerService.appItems("2239","【自动化勿动】zr自有优惠券");
Newremind = response.jsonPath().getString("data.list[0].remaind"); Newremind = response.jsonPath().getString("data.list[0].remaind");
i--; i--;
} }
......
package http.cases.NewActivityTest;
import base.DuibaTestBase;
import http.service.Authorization;
import http.service.hd.LaunchService;
import http.service.Activity.NewActivityService;
import org.apache.bcel.generic.NEW;
import utils.MatcherString;
import base.DuibaLog;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import java.util.Map;
/**
* Created by lvwenyan on 2019/4/4.
*/
public class 自有活动工具_新商品_DuibaTest extends DuibaTestBase {
@Autowired
LaunchService launchService;
@Autowired
Authorization authorization;
@Autowired
NewActivityService newActivityService;
int uid = 7126;
@Test(description = "自有活动工具添加新实物奖品")
public void 添加新实物奖品() throws Exception{
Map cookies = authorization.hdLoginCommonNew("15855555555");
String type = "object";
String name = "自有实物活动专用";
String appId = "22561";
Response response = launchService.findItemBySearch(cookies,type,name,appId);
response.prettyPrint();
Assert.assertEquals(response.jsonPath().getString("data.list[0].appItemId"),"195020","校验appItemId失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].title"),"【自动化勿动】自有实物活动专用","校验title失败");
logger.info("校验自有活动工具添加新实物成功");
}
@Test(description = "自有活动工具中奖新实物")
public void 中奖新实物() throws Exception{
String activityId = "43753";
String token = "ulxn1sd";
Response response = newActivityService.doJoin2(uid,activityId,token);
response.prettyPrint();
String orderId = response.jsonPath().getString("orderId");
response = newActivityService.getOrderStatus2(uid,orderId);
response.prettyPrint();
String result = String.valueOf(response.jsonPath().getString("result"));
int i= 30;
while(i>0&&(result.equals("0"))){
Thread.sleep(1000);
response = newActivityService.getOrderStatus2(uid,orderId);
result = String.valueOf(response.jsonPath().getString("result"));
i--;
response.prettyPrint();
}
Assert.assertEquals(response.jsonPath().getString("lottery.id"),"31650","校验奖品id失败");
Assert.assertEquals(response.jsonPath().getString("lottery.title"),"新实物","校验奖品title失败");
logger.info("校验自有活动工具中奖新实物成功");
}
@Test(description = "添加下架的实物奖品")
public void 添加下架的实物奖品() throws Exception{
Map cookies = authorization.hdLoginCommonNew("15855555555");
String type = "object";
String name = "自有实物下架活动专用";
String appId = "22561";
String activityId = "43754";
String token = "h5wn0epv";
//添加奖品
Response findResponse = launchService.findItemBySearch(cookies,type,name,appId);
findResponse.prettyPrint();
Assert.assertEquals(findResponse.jsonPath().getString("data.list[0].appItemId"),"195024","校验appItemId失败");
Assert.assertEquals(findResponse.jsonPath().getString("data.list[0].title"),"【自动化勿动】自有实物下架活动专用","校验title失败");
logger.info("校验自有活动工具添加下架实物成功");
//抽奖
Response response = newActivityService.doJoin2(uid,activityId,token);
// response.prettyPrint();
String orderId = response.jsonPath().getString("orderId");
response = newActivityService.getOrderStatus2(uid,orderId);
response.prettyPrint();
String result = String.valueOf(response.jsonPath().getString("result"));
int i= 30;
while(i>0&&(result.equals("0"))){
Thread.sleep(1000);
response = newActivityService.getOrderStatus2(uid,orderId);
result = String.valueOf(response.jsonPath().getString("result"));
i--;
response.prettyPrint();
}
Assert.assertEquals(response.jsonPath().getString("lottery.id"),"31654","校验奖品id失败");
Assert.assertEquals(response.jsonPath().getString("lottery.title"),"下架实物","校验奖品title失败");
logger.info("校验自有活动工具中奖下架实物成功");
}
}
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
* FileName: 瓜分积分测试_AccessTest * FileName: 瓜分积分测试_AccessTest
* Author: zhaoran * Author: zhaoran
* Date: 2018/12/10 19:45 * Date: 2018/12/10 19:45
* AppId: 21827
* Description: * Description:
*/ */
package http.cases.PkMoudleTest; package http.cases.PkMoudleTest;
...@@ -198,6 +199,7 @@ public class 瓜分积分_实际瓜分_AccessTest extends DuibaTestBase { ...@@ -198,6 +199,7 @@ public class 瓜分积分_实际瓜分_AccessTest extends DuibaTestBase {
Assert.assertEquals(response.jsonPath().getString("data.prizeList[0].bonusType"),"4","中奖弹窗类型校验失败"); Assert.assertEquals(response.jsonPath().getString("data.prizeList[0].bonusType"),"4","中奖弹窗类型校验失败");
Assert.assertEquals(response.jsonPath().getString("data.show"),"true","展示弹窗校验失败"); Assert.assertEquals(response.jsonPath().getString("data.show"),"true","展示弹窗校验失败");
Assert.assertEquals(response.jsonPath().getString("data.unitName"),"金币","积分单位校验失败");
Response response2 = pkService.popup(uid3); Response response2 = pkService.popup(uid3);
response.prettyPrint(); response.prettyPrint();
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* FileName: 瓜分积分测试_AccessTest * FileName: 瓜分积分测试_AccessTest
* Author: zhaoran * Author: zhaoran
* Date: 2018/12/10 19:45 * Date: 2018/12/10 19:45
* Description: * Description: appId 21832
*/ */
package http.cases.PkMoudleTest; package http.cases.PkMoudleTest;
...@@ -204,6 +204,7 @@ public class 瓜分积分_实际瓜分_主胜方_AccessTest extends DuibaTestBas ...@@ -204,6 +204,7 @@ public class 瓜分积分_实际瓜分_主胜方_AccessTest extends DuibaTestBas
Assert.assertEquals(response.jsonPath().getString("data.prizeList[0].bonusType"),"4","中奖弹窗类型校验失败"); Assert.assertEquals(response.jsonPath().getString("data.prizeList[0].bonusType"),"4","中奖弹窗类型校验失败");
Assert.assertEquals(response.jsonPath().getString("data.show"),"true","展示弹窗校验失败"); Assert.assertEquals(response.jsonPath().getString("data.show"),"true","展示弹窗校验失败");
Assert.assertEquals(response.jsonPath().getString("data.unitName"),"金币","积分单位校验失败");
Response response2 = pkService.popup(uid1); Response response2 = pkService.popup(uid1);
response.prettyPrint(); response.prettyPrint();
......
package http.cases.SaasDeveloperTest;
import base.Config;
import base.DuibaLog;
import base.DuibaTestBase;
import http.cases.ExchangeTest.Database;
import http.service.hd.DevItemNewService;
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.PublicMethod;
import java.util.Map;
import http.service.Authorization;
/**
* created by lvwenyan 2019/4/4
*/
public class 新商品_编辑_DuibaTest extends DuibaTestBase {
@Autowired
DevItemNewService devItemNewService;
@Autowired
Authorization authorization;
@Test(description = "保存实物商品修改状态")
public void 保存实物修改状态() throws Exception{
Map cookies = authorization.hdLoginCommonNew("15855555555");
String appId = "22561";
String appItemId = "195026";
String skuId = "101";
try{
Map<String,Object> mapAppItem = jdbc.findSimpleResult("SELECT * FROM goods.app_item WHERE id = " + appItemId);
String status = String.valueOf(mapAppItem.get("status"));
logger.info("商品当前状态:" + status);
Assert.assertEquals(status,"on","校验商品上架状态失败");
//修改实物状态--仓库中,onsale=false
Response response = devItemNewService.doUpdateCredits(cookies,appId,appItemId,skuId,"false");
response.prettyPrint();
mapAppItem = jdbc.findSimpleResult("SELECT * FROM goods.app_item WHERE id = " + appItemId);
status = String.valueOf(mapAppItem.get("status"));
logger.info("商品修改后状态:" + status);
Assert.assertEquals(response.jsonPath().getString("desc"),"成功","校验商品保存失败");
Assert.assertEquals(status,"off","校验商品下架状态失败");
logger.info("校验实物保存修改状态成功");
}catch (Exception e){
throw new Exception("异常信息打印:" + e);
}finally {
//修改实物状态--在售,onsale=true
Response response = devItemNewService.doUpdateCredits(cookies,appId,appItemId,skuId,"true");
response.prettyPrint();
}
}
@Test(description = "修改优惠券商品上架、下架状态")
public void 商品上架与下架() throws Exception{
Map cookies = authorization.hdLoginCommonNew("15855555555");
String appId = "22561";
String appItemIds = "195027";
try{
Map<String,Object> mapAppItem = jdbc.findSimpleResult("SELECT * FROM goods.app_item WHERE id = " + appItemIds);
String status = String.valueOf(mapAppItem.get("status"));
logger.info("商品当前状态:" + status);
Assert.assertEquals(status,"on","校验商品上架状态失败");
//修改状态--下架,status = off
Response response = devItemNewService.batchStandUpOrDown(cookies,appId,appItemIds,"off");
response.prettyPrint();
mapAppItem = jdbc.findSimpleResult("SELECT * FROM goods.app_item WHERE id = " + appItemIds);
status = String.valueOf(mapAppItem.get("status"));
logger.info("商品修改后状态:" + status);
Assert.assertEquals(response.jsonPath().getString("desc"),"成功","校验商品保存失败");
Assert.assertEquals(status,"off","校验商品下架状态失败");
logger.info("校验优惠券修改下架状态成功");
}catch (Exception e){
throw new Exception("异常信息打印:" + e);
}finally {
//修改状态--上架,status= on
Response response = devItemNewService.batchStandUpOrDown(cookies,appId,appItemIds,"on");
response.prettyPrint();
}
}
}
package http.cases.SaasDeveloperTest;
import base.Config;
import base.DuibaLog;
import base.DuibaTestBase;
import http.service.hd.VisualEditorService;
import http.service.Authorization;
import http.cases.ExchangeTest.Database;
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.PublicMethod;
import java.util.Map;
import http.service.Authorization;
/**
* Created by lvwenyan on 2019/4/4
*/
public class 活动管理_DuibaTest extends DuibaTestBase {
@Autowired
Authorization authorization;
@Autowired
VisualEditorService visualEditorService;
@Test(description = "活动管理-活动列表数据")
public void 活动列表() throws Exception{
Map cookies = authorization.hdLoginCommonNew("15855555555");
String appId = "22561";
Response response = visualEditorService.activityList(cookies,"1",appId);
response.prettyPrint();
Assert.assertEquals(response.jsonPath().getString("data.result[0].activityId"),"511","校验PK赛活动id失败");
Assert.assertEquals(response.jsonPath().getString("data.result[0].title"),"lv测试PK赛1","校验PK赛活动title失败");
Assert.assertEquals(response.jsonPath().getString("data.result[0].typeName"),"组件-pk赛","校验PK赛活动typeName失败");
Assert.assertEquals(response.jsonPath().getString("data.result[0].status"),"2","校验PK赛活动status失败");
logger.info("校验活动列表-PK赛成功");
}
}
...@@ -70,7 +70,7 @@ public class 补给站_活动_DuibaTest extends AbstractTestNGSpringContextTests ...@@ -70,7 +70,7 @@ public class 补给站_活动_DuibaTest extends AbstractTestNGSpringContextTests
public void b_添加签到活动() throws Exception{ public void b_添加签到活动() throws Exception{
//查询热门活动-活动列表,获取商品ID //查询热门活动-活动列表,获取商品ID
Response response=developerBJZ.saasActivitys("2",appId); Response response=developerBJZ.saasActivitys("2",appId);
String goodItemId= String.valueOf(response.jsonPath().getString("data.saasActivitys[1].id")); String goodItemId= String.valueOf(response.jsonPath().getString("data.saasActivitys[0].id"));
//获取商品ID,进入商品订购页面,获取SKU //获取商品ID,进入商品订购页面,获取SKU
Response response2=developerBJZ.itemOrderDetail(goodItemId,appId); Response response2=developerBJZ.itemOrderDetail(goodItemId,appId);
String skuId= String.valueOf(response2.jsonPath().getString("data.goodsItemSku[0].skuId")); String skuId= String.valueOf(response2.jsonPath().getString("data.goodsItemSku[0].skuId"));
...@@ -92,7 +92,7 @@ public class 补给站_活动_DuibaTest extends AbstractTestNGSpringContextTests ...@@ -92,7 +92,7 @@ public class 补给站_活动_DuibaTest extends AbstractTestNGSpringContextTests
public void c_待处理的订单() throws Exception{ public void c_待处理的订单() throws Exception{
//查询热门活动-活动列表,获取商品ID //查询热门活动-活动列表,获取商品ID
Response response=developerBJZ.saasActivitys("2",appId); Response response=developerBJZ.saasActivitys("2",appId);
String goodItemId= String.valueOf(response.jsonPath().getString("data.saasActivitys[1].id")); String goodItemId= String.valueOf(response.jsonPath().getString("data.saasActivitys[0].id"));
//获取商品ID,进入商品订购页面,获取SKU //获取商品ID,进入商品订购页面,获取SKU
Response response2=developerBJZ.itemOrderDetail(goodItemId,appId); Response response2=developerBJZ.itemOrderDetail(goodItemId,appId);
String skuId= String.valueOf(response2.jsonPath().getString("data.goodsItemSku[0].skuId")); String skuId= String.valueOf(response2.jsonPath().getString("data.goodsItemSku[0].skuId"));
......
...@@ -30,6 +30,7 @@ public class 开发者签到编辑_signTest extends AbstractTestNGSpringContextT ...@@ -30,6 +30,7 @@ public class 开发者签到编辑_signTest extends AbstractTestNGSpringContextT
Assert.assertEquals(response.jsonPath().getString("data.list[0].openToDev"),"false","来自Duiba的签到编辑权限失败"); Assert.assertEquals(response.jsonPath().getString("data.list[0].openToDev"),"false","来自Duiba的签到编辑权限失败");
Assert.assertEquals(response.jsonPath().getString("data.list[1].openToDev"),"true","来自开发者自有的签到编辑权限失败"); Assert.assertEquals(response.jsonPath().getString("data.list[1].openToDev"),"true","来自开发者自有的签到编辑权限失败");
Assert.assertEquals(response.jsonPath().getString("data.list[2].openToDev"),"true","来自开发者自有的签到编辑权限失败");
logger.info("开发者签到编辑权限校验成功"); logger.info("开发者签到编辑权限校验成功");
} }
......
...@@ -258,4 +258,6 @@ public class SingleLottery_AccessTest extends DuibaTestBase { ...@@ -258,4 +258,6 @@ public class SingleLottery_AccessTest extends DuibaTestBase {
} }
} }
\ No newline at end of file
package http.cases.SingleLotteryTest;
import base.DuibaTestBase;
import http.service.Activity.SingleLotteryService;
import http.service.Manager.AdminDuibaSingleLotteryService;
import utils.MatcherString;
import base.DuibaLog;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
/**
* Created by lvwenyan on 2019/4/4.
*/
public class 兑吧单品抽奖_新商品_AccessTest extends DuibaTestBase {
@Autowired
SingleLotteryService singleLotteryService;
@Autowired
AdminDuibaSingleLotteryService adminDuibaSingleLotteryService;
int uid = 7126;
@Test(description = "添加新商品作为奖品")
public void 选择主奖品为新实物() throws Exception{
String itemId = "32604";
Response response = adminDuibaSingleLotteryService.ajaxFindItemById(itemId);
response.prettyPrint();
String id = response.jsonPath().getString("item.id");
String name = response.jsonPath().getString("item.name");
Assert.assertEquals(id,"32604","校验商品id失败");
Assert.assertEquals(name,"【自动化勿动】兑吧新实物活动专用","校验商品名称失败");
logger.info("校验单品抽奖添加新实物成功");
}
@Test(description = "单品抽奖中奖新实物")
public void 中奖新实物() throws Exception{
String activityId = "43725";
String token = "ix18rh";
Response response =singleLotteryService.doJoin(uid,activityId,activityId,token);
response.prettyPrint();
String id =MatcherString.getString(response.asString(), "singleLotteryOrderId\":(.*?),", 1);
response = singleLotteryService.getOrderStatus(uid,id,"");
int i = 10;
while ("处理中".equals(response.jsonPath().getString("message")) && i > 0) {
Thread.sleep(500);
response = singleLotteryService.getOrderStatus(uid,id,"");
i--;
}
String descrption = response.jsonPath().getString("descrption");
String itemId = response.jsonPath().getString("itemId");
String lotteryType = response.jsonPath().getString("lotteryType");
Assert.assertEquals(descrption,"【自动化勿动】兑吧新实物活动专用","校验descrption失败");
Assert.assertEquals(itemId,"32604","校验itemid失败");
Assert.assertEquals(lotteryType,"object","校验lotteryType失败");
logger.info("校验单品抽奖中奖新实物成功");
}
}
package http.cases.SingleLotteryTest;
import base.DuibaTestBase;
import http.service.Activity.SingleLotteryService;
import http.service.Authorization;
import http.service.hd.AppSingleLotteryService;
import utils.MatcherString;
import base.DuibaLog;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import java.util.HashMap;
import java.util.Map;
/**
* Created by lvwenyan on 2019/4/4.
*/
public class 自有单品抽奖_新商品_AccessTest extends DuibaTestBase {
@Autowired
SingleLotteryService singleLotteryService;
@Autowired
AppSingleLotteryService appSingleLotteryService;
@Autowired
Authorization authorization;
int uid = 7126;
@Test(description = "自有单品抽奖添加新实物商品")
public void 添加新实物奖品() throws Exception{
String appId = "22561";
String appItemId = "195020";
Map cookies = authorization.hdLoginCommonNew("15855555555");
Response response = appSingleLotteryService.ajaxFindAppItemById(cookies,appId,appItemId);
response.prettyPrint();
Assert.assertEquals(response.jsonPath().getString("data.appItemId"),appItemId,"校验appItemId失败");
Assert.assertEquals(response.jsonPath().getString("desc"),"成功","校验desc失败");
logger.info("校验自有单品抽奖添加新实物成功");
}
@Test(description = "自有单品抽奖中奖新实物")
public void 中奖新实物() throws Exception{
String activityId = "43751";
String token = "6xgees";
Response response =singleLotteryService.doJoin(uid,activityId,activityId,token);
response.prettyPrint();
String id =MatcherString.getString(response.asString(), "singleLotteryOrderId\":(.*?),", 1);
response = singleLotteryService.getOrderStatus(uid,id,"");
int i = 10;
while ("处理中".equals(response.jsonPath().getString("message")) && i > 0) {
Thread.sleep(500);
response = singleLotteryService.getOrderStatus(uid,id,"");
i--;
}
String descrption = response.jsonPath().getString("descrption");
String appItemId = response.jsonPath().getString("appItemId");
String lotteryType = response.jsonPath().getString("lotteryType");
Assert.assertEquals(descrption,"【自动化勿动】自有实物活动专用","校验descrption失败");
Assert.assertEquals(appItemId,"195020","校验itemid失败");
Assert.assertEquals(lotteryType,"object","校验lotteryType失败");
logger.info("校验自有单品抽奖中奖新实物成功");
}
}
package http.cases.VisualEditorTest;
import base.Config;
import base.DuibaLog;
import base.DuibaTestBase;
import http.cases.ExchangeTest.Database;
import http.service.hd.DevItemNewService;
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.DataProvider;
import org.testng.annotations.Test;
import utils.PublicMethod;
import java.lang.reflect.Method;
import java.util.Map;
import http.service.Authorization;
/**
* created by lvwenyan 2019/4/17
*/
public class 商品分组组件_DuibaTest extends DuibaTestBase {
@Autowired
DevItemNewService devItemNewService;
@Autowired
Authorization authorization;
@DataProvider
public Object[][] providerMethod(Method method) {
Object[][] result = null;
if (method.getName().equals("后台商品分组组件新商品展示")) {
result = new Object[][]{
new Object[]{1, "2102", "22561", "商品分组-兑吧新商品"}, //case1
new Object[]{2, "2104", "22561", "商品分组-自有新商品"}, //case2
};
}
if (method.getName().equals("后台商品分组组件老商品展示")) {
result = new Object[][]{
new Object[]{1, "2124", "22542", "商品分组-兑吧老商品"}, //case1
new Object[]{2, "2125", "22542", "商品分组-自有老商品"}, //case2
};
}
return result;
}
/**
* @param caseNum 用例编号
* @param classifyId 商品分组Id
* @param appId appId
* @param caseName 用例名称打印
* @throws Exception
*/
@Test(dataProvider = "providerMethod")
public void 后台商品分组组件新商品展示(int caseNum, String classifyId, String appId, String caseName) throws Exception{
logger.info("---" + caseName + "---");
Map cookies = authorization.hdLoginCommonNew("15855555555");
Response response = devItemNewService.appItems(cookies,classifyId,appId);
response.prettyPrint();
switch (caseNum){
case 1:
Assert.assertEquals(response.jsonPath().getString("data.rows[0].title"),"10元话费","校验第一个商品title失败");
Assert.assertEquals(response.jsonPath().getString("data.rows[0].customCredits"),"1000","校验第一个商品credits失败");
Assert.assertEquals(response.jsonPath().getString("data.rows[1].title"),"支付宝充值","校验第二个商品title失败");
Assert.assertEquals(response.jsonPath().getString("data.rows[1].customCredits"),"100000","校验第二个商品credits失败");
Assert.assertEquals(response.jsonPath().getString("data.rows[2].title"),"【自动化勿动】兑吧新实物","校验第三个商品title失败");
Assert.assertEquals(response.jsonPath().getString("data.rows[2].customCredits"),"300","校验第三个商品credits失败");
Assert.assertEquals(response.jsonPath().getString("data.rows[3].title"),"【自动化勿动】兑吧卡密跳转按钮","校验第四个商品title失败");
Assert.assertEquals(response.jsonPath().getString("data.rows[3].customCredits"),"200","校验第四个商品credits失败");
Assert.assertEquals(response.jsonPath().getString("data.rows[4].title"),"【自动化勿动】兑吧新优惠券普通券码跳转","校验第五个商品title失败");
Assert.assertEquals(response.jsonPath().getString("data.rows[4].customCredits"),"100","校验第五个商品credits失败");
logger.info("校验商品分组1-兑吧商品成功");
break;
case 2:
Assert.assertEquals(response.jsonPath().getString("data.rows[0].title"),"【自动化勿动】自有卡密","校验第一个商品title失败");
Assert.assertEquals(response.jsonPath().getString("data.rows[0].customCredits"),"550","校验第一个商品credits失败");
Assert.assertEquals(response.jsonPath().getString("data.rows[1].title"),"【自动化勿动】自有充值商品","校验第二个商品title失败");
Assert.assertEquals(response.jsonPath().getString("data.rows[1].customCredits"),"300","校验第二个商品credits失败");
Assert.assertEquals(response.jsonPath().getString("data.rows[2].title"),"【自动化勿动】自有新实物加钱购","校验第三个商品title失败");
Assert.assertEquals(response.jsonPath().getString("data.rows[2].customCredits"),"150","校验第三个商品credits失败");
Assert.assertEquals(response.jsonPath().getString("data.rows[3].title"),"【自动化勿动】自有新优惠券跳转链接","校验第四个商品title失败");
Assert.assertEquals(response.jsonPath().getString("data.rows[3].customCredits"),"100","校验第四个商品credits失败");
logger.info("校验商品分组2-自有商品成功");
break;
}
}
/**
* @param caseNum 用例编号
* @param classifyId 商品分组Id
* @param appId appId
* @param caseName 用例名称打印
* @throws Exception
*/
@Test(dataProvider = "providerMethod")
public void 后台商品分组组件老商品展示(int caseNum, String classifyId, String appId, String caseName) throws Exception{
logger.info("---" + caseName + "---");
Map cookies = authorization.hdLoginCommonNew("15833333333");
Response response = devItemNewService.appItems(cookies,classifyId,appId);
response.prettyPrint();
switch (caseNum){
case 1:
Assert.assertEquals(response.jsonPath().getString("data.rows[0].title"),"【勿动】兑吧优惠券共享库存测试","校验第一个商品title失败");
Assert.assertEquals(response.jsonPath().getString("data.rows[0].customCredits"),"140","校验第一个商品credits失败");
Assert.assertEquals(response.jsonPath().getString("data.rows[1].title"),"【自动化勿动】兑吧实物日期兑换限制进行中","校验第二个商品title失败");
Assert.assertEquals(response.jsonPath().getString("data.rows[1].customCredits"),"700","校验第二个商品credits失败");
Assert.assertEquals(response.jsonPath().getString("data.rows[2].title"),"5元话费","校验第三个商品title失败");
Assert.assertEquals(response.jsonPath().getString("data.rows[2].customCredits"),"3500","校验第三个商品credits失败");
Assert.assertEquals(response.jsonPath().getString("data.rows[3].title"),"Q币充值","校验第四个商品title失败");
Assert.assertEquals(response.jsonPath().getString("data.rows[3].customCredits"),"700","校验第四个商品credits失败");
Assert.assertEquals(response.jsonPath().getString("data.rows[4].title"),"支付宝充值","校验第五个商品title失败");
Assert.assertEquals(response.jsonPath().getString("data.rows[4].customCredits"),"1000","校验第五个商品credits失败");
logger.info("校验商品分组1-兑吧商品成功");
break;
case 2:
Assert.assertEquals(response.jsonPath().getString("data.rows[0].title"),"【自动化勿动】自有虚拟商品","校验第一个商品title失败");
Assert.assertEquals(response.jsonPath().getString("data.rows[0].customCredits"),"1000","校验第一个商品credits失败");
Assert.assertEquals(response.jsonPath().getString("data.rows[1].title"),"【自动化勿动】自有实物","校验第二个商品title失败");
Assert.assertEquals(response.jsonPath().getString("data.rows[1].customCredits"),"200","校验第二个商品credits失败");
Assert.assertEquals(response.jsonPath().getString("data.rows[2].title"),"【自动化勿动】自有优惠券","校验第三个商品title失败");
Assert.assertEquals(response.jsonPath().getString("data.rows[2].customCredits"),"100","校验第三个商品credits失败");
logger.info("校验商品分组2-自有商品成功");
break;
}
}
}
package http.cases.WalletTest;
import base.DuibaLog;
import base.DuibaTestBase;
import http.service.Activity.GlobalRewardService;
import http.service.Activity.SeedRedPacketService;
import http.service.Activity.WalletAccountService;
import http.service.Authorization;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import utils.HbaseService;
import java.lang.reflect.Method;
import java.text.SimpleDateFormat;
import java.util.*;
import static io.restassured.RestAssured.given;
/**
* Created by 赵然 on 2019/04/04
* AppId: 22565
*/
public class 总帐户提现页校验_AccessTest extends DuibaTestBase{
@Value("${activity.host}")
String activityHost;
@Autowired
SeedRedPacketService seedRedPacketService;
@Autowired
WalletAccountService walletAccountService;
@Autowired
GlobalRewardService globalRewardService;
@Autowired
Authorization authorization;
@Autowired
HbaseService hbaseService;
private DuibaLog logger = DuibaLog.getLogger();
//指定用户
private static int uid = 7112;
private static String consumerId = "100145034";
@Test
public void 提现页校验() throws Exception {
Response response = globalRewardService.toWithdraw(uid);
response.print();
String expireTime = response.jsonPath().getString("data.expireTime");
String perLimitAmount = response.jsonPath().getString("data.perLimitAmount");
String periodOpen = response.jsonPath().getString("data.periodOpen");
Assert.assertEquals(expireTime,"2021/01/31 00:00:00","提现页过期时间校验失败");
Assert.assertEquals(perLimitAmount,"2","提现页满额提现金额校验失败");
Assert.assertEquals(periodOpen,"true","总帐户状态校验失败");
logger.info("总帐户提现页校验成功!");
}
@Test
public void 后台红包周期校验() throws Exception {
Response response = globalRewardService.periodList("18157163293","22565","2");
response.print();
String bonusLimit = response.jsonPath().getString("data[0].bonusLimit");
String forConfirm = response.jsonPath().getString("data[0].forConfirm");
String periodStatus = response.jsonPath().getString("data[0].periodStatus");
String withdrawThreshold = response.jsonPath().getString("data[0].withdrawThreshold");
String relType = response.jsonPath().getString("data[0].relList[0].relType");
String relTypeName = response.jsonPath().getString("data[0].relList[0].relTypeName");
Assert.assertEquals(bonusLimit,"199998","红包预算校验失败");
Assert.assertEquals(forConfirm,"false","确认按钮校验失败");
Assert.assertEquals(periodStatus,"OPEN","总帐户状态校验失败");
Assert.assertEquals(withdrawThreshold,"2","用户提现限制校验失败");
Assert.assertEquals(relType,"PK","关联活动类型校验失败");
Assert.assertEquals(relTypeName,"组件pk","关联活动名称校验失败");
response = globalRewardService.periodCount("18157163293","22565","2");
Assert.assertEquals(response.jsonPath().getString("data"),"1","周期个数校验失败");
}
}
...@@ -37,6 +37,8 @@ public class BetDevelopVo { ...@@ -37,6 +37,8 @@ public class BetDevelopVo {
private String delayHours; //'结算时间' private String delayHours; //'结算时间'
private String isHover; private String isHover;
private String popoverVisible; private String popoverVisible;
private String drawType; // 1: 延迟开奖 2 定时开奖
// private String id; //主键 // private String id; //主键
// private String pluginId; //'发奖品时需要填插件id' // private String pluginId; //'发奖品时需要填插件id'
// private String prizeLimit; //'发奖品时的发放上限' // private String prizeLimit; //'发奖品时的发放上限'
...@@ -150,6 +152,14 @@ public class BetDevelopVo { ...@@ -150,6 +152,14 @@ public class BetDevelopVo {
public void setPopoverVisible(String popoverVisible) { public void setPopoverVisible(String popoverVisible) {
this.popoverVisible = popoverVisible; this.popoverVisible = popoverVisible;
} }
public String getDrawType() {
return drawType;
}
public void setDrawType(String drawType) {
this.drawType = drawType;
}
// public String getId() { // public String getId() {
// return id; // return id;
// } // }
......
package http.service.Activity;
import base.DuibaLog;
import http.service.Authorization;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.testng.Assert;
import java.util.HashMap;
import java.util.Map;
import static io.restassured.RestAssured.given;
/**
* Created by zhaoran on 2019/03/29
*/
@Service
public class GlobalRewardService {
@Autowired
Authorization authorization;
@Value("${activity.host}")
String activityHost;
@Value("${hdserver.host}")
String hdHost;
private DuibaLog logger = DuibaLog.getLogger();
/**
* 红包账户提现
* @param cookies
* @param amount
* @param account
* @param username
* @return
* @throws Exception
*/
public Response withdraw(Map cookies,String amount,String account,String username) throws Exception {
logger.info("请求withdraw");
Map<String,String> map = new HashMap<>();
map.put("amount",amount);
map.put("account",account);
map.put("username",username);
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(cookies).params(map).post(activityHost+"/globalReward/withdraw");
try{
Assert.assertEquals(response.jsonPath().getString("success"),"true","/walletAccount/doTakePrize接口失败");
}catch(Exception e){
throw new Exception("/globalReward/withdraw接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/globalReward/withdraw接口失败,返回信息:"+response.asString());
}
return response;
}
/**
* 红包账户提现页
* @param uid
* @return
* @throws Exception
*/
public Response toWithdraw(int uid) throws Exception {
logger.info("请求toWithdraw");
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.dafuwengLogin(uid)).get(activityHost+"/globalReward/toWithdraw");
try{
Assert.assertEquals(response.jsonPath().getString("success"),"true","/globalReward/toWithdraw接口失败");
}catch(Exception e){
throw new Exception("/globalReward/toWithdraw接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/globalReward/toWithdraw接口失败,返回信息:"+response.asString());
}
return response;
}
/**
* 开发者后台红包周期列表
* @param account
* @param appId
* @param periodStatus 2:进行中
* @return
* @throws Exception
*/
public Response periodList(String account,String appId,String periodStatus) throws Exception {
logger.info("请求periodList");
Map<String,String> map = new HashMap<>();
map.put("periodStatus",periodStatus);
map.put("pageNum","1");
map.put("pageSize","10");
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaasNew(account,appId)).params(map).post("http://"+hdHost+"/redpackets/manageTool/periodList");
try{
Assert.assertEquals(response.jsonPath().getString("success"),"true","/globalReward/toWithdraw接口失败");
}catch(Exception e){
throw new Exception("/redpackets/manageTool/periodList接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/redpackets/manageTool/periodList接口失败,返回信息:"+response.asString());
}
return response;
}
/**
* 开发者后台红包周期个数
* @param account
* @param appId
* @param periodStatus 2:进行中
* @return
* @throws Exception
*/
public Response periodCount(String account,String appId,String periodStatus) throws Exception {
logger.info("请求periodCount");
Map<String,String> map = new HashMap<>();
map.put("periodStatus",periodStatus);
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaasNew(account,appId)).params(map).post("http://"+hdHost+"/redpackets/manageTool/periodCount");
try{
Assert.assertEquals(response.jsonPath().getString("success"),"true","/globalReward/toWithdraw接口失败");
}catch(Exception e){
throw new Exception("/redpackets/manageTool/periodCount接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/redpackets/manageTool/periodCount接口失败,返回信息:"+response.asString());
}
return response;
}
}
...@@ -842,7 +842,9 @@ public class ManagerService { ...@@ -842,7 +842,9 @@ public class ManagerService {
map.put("expressId","123123213213"); map.put("expressId","123123213213");
map.put("expressName","圆通速递"); map.put("expressName","圆通速递");
map.put("orderId",orderId); map.put("orderId",orderId);
Response response = given().relaxedHTTPSValidation().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.ssoLogin()).params(map).post("https://"+url); // Response response = given().relaxedHTTPSValidation().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.ssoLogin()).params(map).post("https://"+url);
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.ssoLogin()).params(map).post("http://"+url);
try { try {
Assert.assertEquals(response.jsonPath().getString("success"), "true"); Assert.assertEquals(response.jsonPath().getString("success"), "true");
} catch (Exception e) { } catch (Exception e) {
......
...@@ -152,9 +152,9 @@ public class SingleLotteryService { ...@@ -152,9 +152,9 @@ public class SingleLotteryService {
try { try {
Assert.assertEquals(String.valueOf(response.getStatusCode()), "200", "管理后台兑换项请求异常"); Assert.assertEquals(String.valueOf(response.getStatusCode()), "200", "管理后台兑换项请求异常");
} catch (Exception e) { } catch (Exception e) {
throw new Exception("/AdminDuibaSingleLottery/edit/接口失败,返回信息:" + response.asString()); throw new Exception("/AdminDuibaSingleLotteryService/edit/接口失败,返回信息:" + response.asString());
} catch (Error er) { } catch (Error er) {
throw new Exception("/AdminDuibaSingleLottery/edit/接口失败,返回信息:" + response.asString()); throw new Exception("/AdminDuibaSingleLotteryService/edit/接口失败,返回信息:" + response.asString());
} }
return response; return response;
} }
...@@ -230,9 +230,9 @@ public class SingleLotteryService { ...@@ -230,9 +230,9 @@ public class SingleLotteryService {
try{ try{
Assert.assertEquals(response.jsonPath().getString("success"), "true", "/AdminDuibaSingleLottery/changeStatus接口失败"); Assert.assertEquals(response.jsonPath().getString("success"), "true", "/AdminDuibaSingleLottery/changeStatus接口失败");
}catch(Exception e){ }catch(Exception e){
throw new Exception("/AdminDuibaSingleLottery/changeStatus接口失败,返回信息:"+response.asString()); throw new Exception("/AdminDuibaSingleLotteryService/changeStatus接口失败,返回信息:"+response.asString());
}catch(Error er){ }catch(Error er){
throw new Exception("/AdminDuibaSingleLottery/changeStatus接口失败,返回信息:"+response.asString()); throw new Exception("/AdminDuibaSingleLotteryService/changeStatus接口失败,返回信息:"+response.asString());
} }
} }
...@@ -243,11 +243,11 @@ public class SingleLotteryService { ...@@ -243,11 +243,11 @@ public class SingleLotteryService {
Response response = given().cookies(authorization.ssoLogin()).post("http://" + url); Response response = given().cookies(authorization.ssoLogin()).post("http://" + url);
try{ try{
Assert.assertEquals(response.jsonPath().getString("success"), "true", "/AdminDuibaSingleLottery/delete/接口失败"); Assert.assertEquals(response.jsonPath().getString("success"), "true", "/AdminDuibaSingleLotteryService/delete/接口失败");
}catch(Exception e){ }catch(Exception e){
throw new Exception("/AdminDuibaSingleLottery/delete/接口失败,返回信息:"+response.asString()); throw new Exception("/AdminDuibaSingleLotteryService/delete/接口失败,返回信息:"+response.asString());
}catch(Error er){ }catch(Error er){
throw new Exception("/AdminDuibaSingleLottery/delete/接口失败,返回信息:"+response.asString()); throw new Exception("/AdminDuibaSingleLotteryService/delete/接口失败,返回信息:"+response.asString());
} }
} }
} }
\ No newline at end of file
...@@ -384,7 +384,7 @@ public class Authorization { ...@@ -384,7 +384,7 @@ public class Authorization {
paras.put("isAutoLogin", "true"); paras.put("isAutoLogin", "true");
paras.put("validate","22"); paras.put("validate","22");
Response response = given().cookies(cookies).params(paras).post(url); Response response = given().cookies(cookies).params(paras).post(url);
response.prettyPrint(); // response.prettyPrint();
hdCookies=new HashMap<>(response.getCookies()); hdCookies=new HashMap<>(response.getCookies());
if(hdCookies!=null&&hdCookies.size()!=0){ if(hdCookies!=null&&hdCookies.size()!=0){
hdCookies.remove("csrf_token"); hdCookies.remove("csrf_token");
......
package http.service.Manager;
import base.DuibaLog;
import cn.com.duiba.activity.center.api.dto.activity.CLRewardDto;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import http.service.Authorization;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.testng.Assert;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static io.restassured.RestAssured.given;
/**
* Created by lvwenyan on 2019/4/4.
*/
@Service
public class AdminDuibaSingleLotteryService {
@Value("${manager.host}")
String ManagerHost; //ManagerHost = mng.duibatest.com.cn
@Autowired
Authorization authorization;
private DuibaLog logger = DuibaLog.getLogger();
//单品抽奖添加奖品
public Response ajaxFindItemById(String itemId) throws Exception{
String url = ManagerHost + "/AdminDuibaSingleLottery/ajaxFindItemById";
Map<String,String> map = new HashMap<>();
map.put("itemId",itemId);
Response response = given().contentType("text/html;charset=UTF-8").cookies(authorization.ssoLogin()).params(map).get("http://"+url);
// response.prettyPrint();
return response;
}
}
package http.service.Manager;
import base.DuibaLog;
import cn.com.duiba.activity.center.api.dto.activity.CLRewardDto;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import http.service.Authorization;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.testng.Assert;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static io.restassured.RestAssured.given;
/**
* Created by lvwenyan on 2019/4/4.
*/
@Service
public class AdminNewDuibaHdtoolService {
@Value("${manager.host}")
String ManagerHost;
@Autowired
Authorization authorization;
private DuibaLog logger = DuibaLog.getLogger();
//单品抽奖添加奖品
public Response ajaxFindItemByName(String type, String name) throws Exception {
String url = ManagerHost + "/AdminNewDuibaHdtool/ajaxFindItemByName";
Map<String, String> map = new HashMap<>();
map.put("type", type);
map.put("name", name);
Response response = given().contentType("application/json;charset=UTF-8").cookies(authorization.ssoLogin()).params(map).get("http://" + url);
try {
Assert.assertEquals(response.jsonPath().getString("success"), "true", "/AdminNewDuibaHdtool/ajaxFindItemByName接口失败");
} catch (Exception e) {
throw new Exception("/AdminNewDuibaHdtool/ajaxFindItemByName接口失败,返回信息:" + response.asString());
} catch (Error er) {
throw new Exception("/AdminNewDuibaHdtool/ajaxFindItemByName接口失败,返回信息:" + response.asString());
}
return response;
}
}
...@@ -263,7 +263,7 @@ public class PluginService { ...@@ -263,7 +263,7 @@ public class PluginService {
} }
//定向插件活动 //定向插件活动
public Response addSpecify(String id) throws Exception { public Response addSpecify(String id, String appIds) throws Exception {
String switchUrl = ManagerHost + "/plugin/switchSpecify"; String switchUrl = ManagerHost + "/plugin/switchSpecify";
String addUrl = ManagerHost + "/SpecifyListAdmin/addSpecifysforPlugin"; String addUrl = ManagerHost + "/SpecifyListAdmin/addSpecifysforPlugin";
...@@ -274,7 +274,7 @@ public class PluginService { ...@@ -274,7 +274,7 @@ public class PluginService {
Map<String, String> addMap = new HashMap<>(); Map<String, String> addMap = new HashMap<>();
addMap.put("activityId",id); addMap.put("activityId",id);
addMap.put("appIds","2239"); addMap.put("appIds",appIds);
logger.info("请求开启定向接口:" + switchUrl); logger.info("请求开启定向接口:" + switchUrl);
Response switchResponse = given().contentType("application/json;charset=UTF-8").cookies(authorization.ssoLogin()).params(switchMap).get("http://"+switchUrl); Response switchResponse = given().contentType("application/json;charset=UTF-8").cookies(authorization.ssoLogin()).params(switchMap).get("http://"+switchUrl);
......
package http.service.hd;
import base.DuibaLog;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.testng.Assert;
import java.util.HashMap;
import java.util.Map;
import static io.restassured.RestAssured.given;
/**
* Created by lvwenyan on 2019/4/4
*/
@Service
public class AppSingleLotteryService {
@Value("${hdserver.host}")
String hdserverHost;
public Response ajaxFindAppItemById(Map cookies, String appId, String appItemId) throws Exception{
String url = hdserverHost + "/appSingleLottery/ajaxFindAppItemById";
Map<String,String> map = new HashMap<>();
map.put("appId",appId);
map.put("appItemId",appItemId);
Response response = given().contentType("application/json;charset=UTF-8").cookies(cookies).params(map).get("http://"+ url);
try{
Assert.assertEquals(response.jsonPath().getString("success"),"true");
}catch(Exception e){
throw new Exception("/appSingleLottery/ajaxFindAppItemById接口失败,返回信息:" + response.asString());
}catch(Error er){
throw new Exception("/appSingleLottery/ajaxFindAppItemById接口失败,返回信息:" + response.asString());
}
return response;
}
}
package http.service.hd;
import base.DuibaLog;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.testng.Assert;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static io.restassured.RestAssured.given;
/**
* Created by lvwenyan on 2019/4/4
*/
@Service
public class DevItemNewService {
@Value("${hdserver.host}")
private String hdserverHost;
private DuibaLog logger = DuibaLog.getLogger();
//保存商品
public Response doUpdateCredits(Map cookies, String appId, String appItemId,String skuId, String onSale) throws Exception{
String url = hdserverHost + "/devItemNew/doUpdateCredits";
Map<String,Object> map = new HashMap<>();
Map<String,Object> mapList = new HashMap<>();
List<Map> list = new ArrayList<>();
mapList.put("skuId",skuId);
list.add(mapList);
map.put("appId",appId);
map.put("appItemId",appItemId);
map.put("buttonText","");
map.put("creditsInfos",list.toArray());
map.put("dateRage","[]");
map.put("exchangeType","1");
map.put("indexHidden","false");
map.put("isOwner","true");
map.put("limitDate","");
map.put("limitEverydayQuantity","");
map.put("lockTypeList","[]");
map.put("multiSku","false");
map.put("onSale",onSale);
map.put("originalPriceBuy","false");
JSONObject jsonParam = JSONObject.parseObject(JSON.toJSONString(map));
logger.info("请求商品保存接口:"+ "/devItemNew/doUpdateCredits");
Response response = given().contentType("application/json; charset=UTF-8").cookies(cookies).body(jsonParam).post("http://" + url);
try{
Assert.assertEquals(response.jsonPath().getString("success"),"true");
}catch(Exception e){
throw new Exception("/devItemNew/doUpdateCredits接口返回异常,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/devItemNew/doUpdateCredits接口返回异常,返回信息:"+response.asString());
}
return response;
}
//商品上架、下架
public Response batchStandUpOrDown(Map cookies, String appId, String appItemIds, String status) throws Exception{
String url = hdserverHost + "/devItemNew/batchStandUpOrDown";
Map<String,String> map = new HashMap<>();
map.put("appId",appId);
map.put("appItemIds",appItemIds);
map.put("status",status);
logger.info("请求商品上架下架接口:"+ "/devItemNew/batchStandUpOrDown");
Response response = given().contentType("application/x-www-form-urlencoded").cookies(cookies).params(map).post("http://" + url);
try{
Assert.assertEquals(response.jsonPath().getString("success"),"true");
}catch(Exception e){
throw new Exception("/devItemNew/batchStandUpOrDown接口返回异常,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/devItemNew/batchStandUpOrDown接口返回异常,返回信息:"+response.asString());
}
return response;
}
//商品分组组件
public Response appItems(Map cookies, String classifyId, String appId) throws Exception{
String url = hdserverHost + "/devItemNew/appItems";
Map<String,String> map = new HashMap<>();
map.put("classifyId",classifyId);
map.put("status","on");
map.put("pageSize","100");
map.put("appId",appId);
map.put("pageNo","1");
logger.info("请求商品分组组件接口:"+ "/devItemNew/appItems");
Response response = given().contentType("application/json;charset=UTF-8").cookies(cookies).params(map).get("http://" + url);
try{
Assert.assertEquals(response.jsonPath().getString("success"),"true");
}catch(Exception e){
throw new Exception("/devItemNew/appItems接口返回异常,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/devItemNew/appItems接口返回异常,返回信息:"+response.asString());
}
return response;
}
}
...@@ -68,4 +68,25 @@ public class LaunchService { ...@@ -68,4 +68,25 @@ public class LaunchService {
return response; return response;
} }
//选择奖品
public Response findItemBySearch(Map cookies, String type, String name, String appId) throws Exception{
String url = hdHost + "/launch/findItemBySearch";
Map<String,String> map = new HashMap<>();
map.put("type",type);
map.put("name",name);
map.put("appId",appId);
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(cookies).params(map).post("http://"+url);
try{
Assert.assertEquals(response.jsonPath().getString("desc"),"成功");
}catch(Exception e){
throw new Exception("请求/launch/findItemBySearch接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("请求/launch/findItemBySearch接口失败,返回信息:"+response.asString());
}
return response;
}
} }
...@@ -74,6 +74,7 @@ public class PkDevelopService { ...@@ -74,6 +74,7 @@ public class PkDevelopService {
betDevelopVo.setEndTime(""); betDevelopVo.setEndTime("");
betDevelopVo.setIsHover("false"); betDevelopVo.setIsHover("false");
betDevelopVo.setPopoverVisible("false"); betDevelopVo.setPopoverVisible("false");
betDevelopVo.setDrawType("1");
betDevelopVo.setShareExp(shareExp); betDevelopVo.setShareExp(shareExp);
if (questionType.equals("2")){ if (questionType.equals("2")){
...@@ -141,6 +142,7 @@ public class PkDevelopService { ...@@ -141,6 +142,7 @@ public class PkDevelopService {
betDevelopVo.setEndTime(""); betDevelopVo.setEndTime("");
betDevelopVo.setIsHover("false"); betDevelopVo.setIsHover("false");
betDevelopVo.setPopoverVisible("false"); betDevelopVo.setPopoverVisible("false");
betDevelopVo.setDrawType("1");
betDevelopVo.setShareExp(shareExp); betDevelopVo.setShareExp(shareExp);
if (questionType.equals("2")){ if (questionType.equals("2")){
...@@ -208,6 +210,7 @@ public class PkDevelopService { ...@@ -208,6 +210,7 @@ public class PkDevelopService {
betDevelopVo.setEndTime(""); betDevelopVo.setEndTime("");
betDevelopVo.setIsHover("false"); betDevelopVo.setIsHover("false");
betDevelopVo.setPopoverVisible("false"); betDevelopVo.setPopoverVisible("false");
betDevelopVo.setDrawType("1");
betDevelopVo.setShareExp(shareExp); betDevelopVo.setShareExp(shareExp);
if (questionType.equals("2")){ if (questionType.equals("2")){
......
package http.service.hd;
import base.DuibaLog;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.testng.Assert;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static io.restassured.RestAssured.given;
/**
* Created by lvwenyan on 2019/4/4
*/
@Service
public class VisualEditorService {
@Value("${hdserver.host}")
private String hdserverHost;
private DuibaLog logger = DuibaLog.getLogger();
//活动管理列表
public Response activityList(Map cookies, String pageNo, String appId) throws Exception{
String url = hdserverHost + "/visual-editor/activity/list";
Map<String,String> map = new HashMap<>();
map.put("pageNo",pageNo);
map.put("pageSize","10");
map.put("appId",appId);
logger.info("请求活动列表接口:"+ "/visual-editor/activity/list");
Response response = given().contentType("application/json; charset=UTF-8").cookies(cookies).params(map).get("http://" + url);
try{
Assert.assertEquals(response.jsonPath().getString("success"),"true");
}catch(Exception e){
throw new Exception("/visual-editor/activity/list接口返回异常,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/visual-editor/activity/list接口返回异常,返回信息:"+response.asString());
}
return response;
}
}
...@@ -69,6 +69,70 @@ public class WebDriverFactory { ...@@ -69,6 +69,70 @@ public class WebDriverFactory {
chromeOptions.addArguments("--args --disable-web-security --user-data-dir"); chromeOptions.addArguments("--args --disable-web-security --user-data-dir");
Properties prop = System.getProperties();
String OS = prop.getProperty("os.name");
boolean bl=OS.startsWith("Mac");
String basePath=WebDriverType.class.getClassLoader().getResource("").getPath();
basePath = basePath.replaceAll("%20"," ");//repaceAll("%20",'');
File directory = new File("");
System.out.println("-----路径:"+directory.getAbsolutePath());
RemoteWebDriver browser=null;
String driverPath=null;
switch (driverType){
case CHRMOE:
if(bl){
driverPath=basePath+"chromedriver";
}else {
driverPath=basePath+"chromedriver.exe";
}
System.setProperty("webdriver.chrome.driver",driverPath);
//add x
new File(driverPath).setExecutable(true);
browser=new ChromeDriver(capabilities);
break;
case MOBLIE:
if(bl){
driverPath=basePath+"chromedriver";
}else {
driverPath=basePath+"chromedriver.exe";
}
System.setProperty("webdriver.chrome.driver",driverPath);
//add x
new File(driverPath).setExecutable(true);
browser=new ChromeDriver(chromeOptions);
break;
case FIREFOX:
browser=new FirefoxDriver(capabilities);
break;
case SAFARI:
browser=new SafariDriver(capabilities);
break;
default:
browser=new ChromeDriver(capabilities);
}
return browser;
}
public static RemoteWebDriver createRemoteWebDriver(WebDriverType driverType){
DesiredCapabilities capabilities = new DesiredCapabilities();
// capabilities.setCapability(CapabilityType.PROXY, proxy);
LoggingPreferences logPrefs = new LoggingPreferences();
logPrefs.enable(LogType.BROWSER, Level.ALL);
capabilities.setCapability(CapabilityType.LOGGING_PREFS,logPrefs);
capabilities.setCapability(CapabilityType.SUPPORTS_APPLICATION_CACHE,false);
capabilities.setCapability(CapabilityType.SUPPORTS_LOCATION_CONTEXT,false);
capabilities.setCapability(CapabilityType.SUPPORTS_WEB_STORAGE,false);
final ChromeOptions chromeOptions = new ChromeOptions();
Map<String, String> mobileEmulation = new HashMap<String, String>();
mobileEmulation.put("deviceName", "Nexus 5");
chromeOptions.setExperimentalOption("mobileEmulation", mobileEmulation);
chromeOptions.addArguments("--args --disable-web-security --user-data-dir");
Properties prop = System.getProperties(); Properties prop = System.getProperties();
String OS = prop.getProperty("os.name"); String OS = prop.getProperty("os.name");
boolean bl=OS.startsWith("Mac"); boolean bl=OS.startsWith("Mac");
......
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