Commit 84b6032d authored by 周松波's avatar 周松波

Merge branch 'develop' into songbo

parents 924366d6 e496df78
......@@ -261,6 +261,12 @@
<artifactId>guava</artifactId>
<version>21.0</version>
</dependency>
<dependency>
<groupId>cn.com.duiba.tool</groupId>
<artifactId>java-gitlab-api</artifactId>
<version>1.3.8</version>
</dependency>
</dependencies>
<build>
......
......@@ -2,6 +2,7 @@ package base;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.gitlab.api.models.GitlabProjectMerges;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.core.env.Environment;
......@@ -52,6 +53,15 @@ public class DingdingResult {
names.addAll(Arrays.asList(getNames));
Map<String,String> params = new HashMap<>();
params.put("jobName",getJob());
changes = Postman.sendFindTestApp(params);
GitlabProjectMerges gitlabProjectMerges = GitlabUtils.getMessage("credits-group",changes);
changes = changes+" 提交者:"+gitlabProjectMerges.getAuthor().getName()+" 描述:"+gitlabProjectMerges.getDescription();
/*从jenkins上获取项目变更
Map<String,String> resentChanges=BeTested.getChangesWithin(30,changeMap);
System.out.println(resentChanges);
if(resentChanges!=null&&resentChanges.size()>0){
......@@ -77,7 +87,7 @@ public class DingdingResult {
if(changes.length()>140){
changes=changes.substring(0,141)+"……";
}
//project="tuia-media";
*/
this.total=total;
this.passCount=passCount;
this.skipCount=skipCount;
......@@ -125,14 +135,16 @@ public class DingdingResult {
result.put("skipCount",this.total);
result.put("failCount",0);
}
result.put("changes",this.changes+"<br>");
// result.put("changes",this.changes+"<br>");
result.put("changes",this.changes);
if(this.failCount>0||exceptionServices.size()>0||exceptionMessage.size()>0){
try{
String name = this.changes.split("—")[1].split("/")[0];
names.add(name);
}catch(Exception e){
System.out.println(e);
}
// try{
// String name = this.changes.split("—")[1].split("/")[0];
// names.add(name);
// }catch(Exception e){
// System.out.println(e);
// }
}else {
names.clear();
......
package base;
import org.gitlab.api.GitlabAPI;
import org.gitlab.api.models.GitabProjectLatelyChangeQry;
import org.gitlab.api.models.GitlabProject;
import org.gitlab.api.models.GitlabProjectMerges;
import java.io.IOException;
import java.util.List;
/**
* Created by mabo on 2018/12/5
*/
public class GitlabUtils {
public static final String GIT_URL = "http://gitlab2.dui88.com";
public static final String SECRET = "rCyBy1sQ-JckquyFmo4c";
public static GitlabProjectMerges getMessage(String namespace,String projectname){
GitlabAPI gitlabAPI = GitlabAPI.connect(GitlabUtils.GIT_URL, GitlabUtils.SECRET);
GitlabProject gitlabProject= null;
try {
gitlabProject = gitlabAPI.getProject(namespace,projectname);
// gitlabProject = gitlabAPI.getProject("credits-group","hdtool-web");
} catch (IOException e) {
e.printStackTrace();
}
GitabProjectLatelyChangeQry qry = new GitabProjectLatelyChangeQry();
qry.setId(gitlabProject.getId());
qry.setTargetBranch("develop");
List<GitlabProjectMerges> projectMerges = null;
try {
projectMerges = gitlabAPI.getLatelyMergeInfo(qry);
} catch (IOException e) {
e.printStackTrace();
}
System.out.println(projectMerges.size());
GitlabProjectMerges gitlabProjectMerges = projectMerges.get(0);
return gitlabProjectMerges;
}
public static void main(String[] args) throws IOException {
// GitlabAPI gitlabAPI = GitlabAPI.connect(GitlabUtils.GIT_URL, GitlabUtils.SECRET);
// GitlabProject gitlabProject=gitlabAPI.getProject("credits-group","hdtool-web");
//
// GitabProjectLatelyChangeQry qry = new GitabProjectLatelyChangeQry();
// qry.setId(gitlabProject.getId());
// qry.setTargetBranch("develop");
// List<GitlabProjectMerges> projectMerges = gitlabAPI.getLatelyMergeInfo(qry);
// System.out.println(projectMerges.size());
// GitlabProjectMerges gitlabProjectMerges = projectMerges.get(0);
GitlabProjectMerges gitlabProjectMerges = getMessage("credits-group","trade-access-web");
System.out.println(gitlabProjectMerges.getDescription());
System.out.println(gitlabProjectMerges.getAuthor().getName());
System.out.println(gitlabProjectMerges.getAuthor().getUsername());
System.out.println(gitlabProjectMerges.getAuthor().getId());
}
}
......@@ -21,9 +21,12 @@ import static io.restassured.RestAssured.given;
* Created by hanzhanli on 2017/11/9.
*/
public class Postman {
static String dingdingUrl="https://shark.dui88.com/test/integration";
static String testPlatformUrl = "http://101.37.27.82:8080/insert";
static String miriaUrl = "http://miria-aliyun.duibatest.com.cn/autoTest/finish";
final static String dingdingUrl="https://shark.dui88.com/test/integration";
final static String testPlatformUrl = "http://101.37.27.82:8080/insert";
final static String miriaUrl = "http://miria-aliyun.duibatest.com.cn/autoTest/finish";
final static String miriaUrlTesting = "http://miria-aliyun.duibatest.com.cn/autoTest/testing";
final static String miriaUrlFindTestApp = "http://miria-aliyun.duibatest.com.cn/autoTest/findTestApp";
//dingdingUrl="http://www.json.cn/";
private static Logger logger = LogManager.getLogger(Postman.class);
public static void send2Dingding(Map result){
......@@ -58,6 +61,22 @@ public class Postman {
System.out.println("miriaUrl:"+miriaUrl);
System.out.println("miria响应结果:"+response.asString());
}
public static void sendTesting(Map result){
Response response=given().params(result).get(miriaUrlTesting);
System.out.println("jobName:"+result.get("jobName"));
System.out.println("miriaUrl:"+miriaUrlTesting);
System.out.println("miria响应结果:"+response.asString());
}
public static String sendFindTestApp(Map result){
Response response=given().params(result).get(miriaUrlFindTestApp);
System.out.println("jobName:"+result.get("jobName"));
System.out.println("miriaUrl:"+miriaUrlTesting);
System.out.println("miria响应结果:"+response.asString());
String value = response.jsonPath().getString("value");
return value;
}
public static Boolean getName(){
Calendar c = Calendar.getInstance();
Date date = new Date();
......
package base;
import java.io.UnsupportedEncodingException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.core.env.Environment;
import org.testng.*;
/**
......@@ -12,6 +18,12 @@ import org.testng.*;
public class TestListener implements ITestListener {
public DuibaLog logger = DuibaLog.getLogger();
String run = System.getProperty("run");
ApplicationContext context = new AnnotationConfigApplicationContext(Config.class);
Environment env=context.getBean(Environment.class);
public TestListener() throws UnsupportedEncodingException {
}
public void onFinish(ITestContext context) {
Iterator<ITestResult> listOfFailedTests = context.getFailedTests().getAllResults().iterator();
while (listOfFailedTests.hasNext()) {
......@@ -65,16 +77,26 @@ public class TestListener implements ITestListener {
// TODO Auto-generated method stub
logger.info("onStart~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
//服务检查
boolean ServiceDoctor=Boolean.parseBoolean(System.getProperty("ServiceDoctor"));
if(ServiceDoctor){
try{
serviceDoctor();
}catch (SkipException e){
SFExpress.skip = context.getAllTestMethods().length;
// throw e;
}
}
//运行开始,触发互斥功能,用于定时任务
Map<String,String> mapJob = new HashMap<>();
try {
mapJob.put("jobName",getJob());
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
Postman.sendTesting(mapJob);
}
public void serviceDoctor(){
logger.info("duiba-server开始检测");
......@@ -107,4 +129,13 @@ public class TestListener implements ITestListener {
res = simpleDateFormat.format(date);
return res;
}
public String getJob() throws UnsupportedEncodingException {
return getByRun(run,"job");
}
public String getByRun(String run,String type) throws UnsupportedEncodingException {
run = run.substring(run.indexOf("_")+1, run.indexOf("."));
run =this.env.getProperty(run+"."+type);
return new String(run.getBytes("ISO-8859-1"), "UTF-8");//ISO-8859-1
}
}
\ No newline at end of file
......@@ -253,6 +253,7 @@ public class CustomActivity_DuibaTest extends DuibaTestBase {
String orderId = response.jsonPath().getString("orderId");
newActivityService.submit(orderId);
Thread.sleep(1000);
response = newActivityService.getOrderStatus2(orderId, device);
String result = String.valueOf(response.jsonPath().getString("result"));
int i = 8;
......
......@@ -61,19 +61,32 @@ public class 答题_答对题数抽奖_DuibaTest extends AbstractTestNGSpringCon
Assert.assertEquals(submitResponse.jsonPath().getString("message"),message);
} else {
Assert.assertEquals(submitResponse.jsonPath().getInt("rightCount"),rightCount);
for (int i =1; i <= 5; i++) {
//获取中奖结果,校验中奖结果
// for (int i =1; i <= 5; i++) {
// //获取中奖结果,校验中奖结果
// Response lotterysResponse = activityCtrlService.getOrderStatus(orderId);
// int result = lotterysResponse.jsonPath().getInt("result");
// if(result != 0) {
// Assert.assertTrue(lotterysResponse.jsonPath().getBoolean("success"));
// // Assert.assertEquals(lotterysResponse.jsonPath().getString("lottery.type"),prize);
// Assert.assertTrue(prize.contains(lotterysResponse.jsonPath().getString("lottery.type")));
// break;
// }
// Thread.sleep(500);
// }
Thread.sleep(2000);
Response lotterysResponse = activityCtrlService.getOrderStatus(orderId);
int result = lotterysResponse.jsonPath().getInt("result");
if(result != 0) {
String result = lotterysResponse.jsonPath().getString("result");
int i= 30;
while(i>0&&(result.equals("0"))){
Thread.sleep(1000);
lotterysResponse = activityCtrlService.getOrderStatus(orderId);
result = lotterysResponse.jsonPath().getString("result");
i--;
lotterysResponse.prettyPrint();
}
Assert.assertTrue(lotterysResponse.jsonPath().getBoolean("success"));
// Assert.assertEquals(lotterysResponse.jsonPath().getString("lottery.type"),prize);
Assert.assertTrue(prize.contains(lotterysResponse.jsonPath().getString("lottery.type")));
break;
}
Thread.sleep(500);
}
Assert.assertFalse(false,caseDesc+" 测试失败,轮询5次未请求到中奖结果");
// Assert.assertFalse(false,caseDesc+" 测试失败,轮询5次未请求到中奖结果");
}
}
......
......@@ -110,7 +110,8 @@ public class 自有答题测试_DuibaTest extends DuibaTestBase {
Assert.assertEquals(response.jsonPath().getString("rightCount"),"1","校验答题数失败");
logger.info("校验答题正确数成功");
response = newActivityService.getOrderStatus(uid,orderId);
Assert.assertEquals(response.jsonPath().getString("result"),"0","校验抽奖结果失败");
Assert.assertEquals(response.jsonPath().getString("lottery.type"),"qb","校验奖品类型失败");
Assert.assertEquals(response.jsonPath().getString("result"),"2","校验抽奖结果失败");
break;
case 3:
Assert.assertEquals(response.jsonPath().getString("rightCount"),"0","校验答题数失败");
......
......@@ -51,12 +51,12 @@ public class Qb_兑换流程测试_ExchangeTest extends CheckTemplet {
private DuibaLog logger = DuibaLog.getLogger();
@BeforeClass
public void beforeClass(){
//模版设置成处理后成功
supplierExchangeTemplateService.use("476");
}
// @BeforeClass
// public void beforeClass(){
// //模版设置成处理后成功
// supplierExchangeTemplateService.use("476");
//
// }
@BeforeMethod
public void beforeMethod() throws SQLException {
jdbc.update("DELETE FROM credits_dev.consumer_limit_record_only WHERE item_id = '2'");
......@@ -69,6 +69,7 @@ public class Qb_兑换流程测试_ExchangeTest extends CheckTemplet {
return result;
}
@Test
public void qbExchange() throws Exception {
int uid = 3767;
......
package http.cases.ExchangeTest;
import base.DuibaLog;
import http.service.Activity.ManagerService;
import http.service.Authorization;
import http.service.app.*;
import http.service.hd.DeveloperAccountService;
import http.service.hd.DsOrderService;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import utils.ExcelDataProvider;
import utils.MatcherString;
import java.io.IOException;
import java.lang.reflect.Method;
import java.sql.SQLException;
import java.util.Iterator;
import java.util.Map;
/**
* Created by mabo on 2018/9/13
*/
public class Qb_兑换限制测试_ExchangeTest extends CheckTemplet {
@Autowired
private MobileService mobileService;
@Autowired
private Authorization authorization;
@Autowired
private CouponExchangeService couponExchangeService;
@Autowired
private CrecordService crecordService;
@Autowired
ManagerService managerService;
@Autowired
VirtualExchangeService virtualExchangeService;
@Autowired
QbExchangeService qbExchangeService;
@Autowired
DeveloperAccountService developerAccountService;
@Autowired
DsOrderService dsOrderService;
@Autowired
SupplierExchangeTemplateService supplierExchangeTemplateService;
private DuibaLog logger = DuibaLog.getLogger();
@BeforeMethod
public void beforeMethod() throws SQLException {
jdbc.update("DELETE FROM credits_dev.consumer_limit_record_only WHERE item_id = '2'");
jdbc.update("DELETE FROM credits_dev.consumer_limit_record WHERE item_id = '2'");
}
@DataProvider
public Iterator<Object[]> providerMethodQb(Method method) throws IOException {
Iterator<Object[]> result = null;
result = new ExcelDataProvider("duiba/qb兑换");
return result;
}
@Test(description = "每限日兑换制同一个用户使用同一个QQ号")
public void 每限日兑换制同一个用户兑换同一个qq() throws Exception {
logger.info("Q币每限日兑换制同一个用户兑换同一个qq开始");
int uid = 4932;
//第一次兑换
Response response = qbExchangeService.doTakePrize(authorization.dafuwengLogin(uid),"1234345554","1");
String orderId = (String)response.jsonPath().get("orderId");
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid),orderId);
String message = response.jsonPath().getString("message");
int i=10;
while(!message.equals("兑换提交成功!待处理")&&i>0){
Thread.sleep(1000);
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid),orderId);
message = response.jsonPath().getString("message");
i--;
}
//第二次兑换
response = qbExchangeService.doTakePrize1(authorization.dafuwengLogin(uid),"1234345554","1");
message = response.jsonPath().getString("message");
logger.info(message);
Assert.assertTrue(message.contains("已兑完"));
logger.info("Q币每限日兑换制同一个用户兑换同一个qq成功");
}
@Test(description = "每限日兑换制同一个用户使用不同一个QQ号")
public void 每限日兑换制同一个用户使用不同一个QQ() throws Exception {
logger.info("每限日兑换制同一个用户使用不同一个QQ号开始");
int uid = 4933;
//第一次兑换
Response response = qbExchangeService.doTakePrize(authorization.dafuwengLogin(uid),"1234345554","1");
String orderId = (String)response.jsonPath().get("orderId");
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid),orderId);
String message = response.jsonPath().getString("message");
int i=10;
while(!message.equals("兑换提交成功!待处理")&&i>0){
Thread.sleep(1000);
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid),orderId);
message = response.jsonPath().getString("message");
i--;
}
//第二次兑换
response = qbExchangeService.doTakePrize1(authorization.dafuwengLogin(uid),"12343455541","1");
response.prettyPrint();
message = response.jsonPath().getString("message");
logger.info(message);
Assert.assertTrue(message.contains("已兑完"));
// Assert.assertTrue(message.contains("\"success\":false"));
logger.info("每限日兑换制同一个用户使用不同一个QQ号成功");
}
@Test(description = "每限日兑换制不同一个用户使用同一个QQ号")
public void 每限日兑换制不同一个用户使用同一个QQ() throws Exception {
logger.info("每限日兑换制不同一个用户使用同一个QQ号开始");
int uid = 4934;
//第一次兑换
Response response = qbExchangeService.doTakePrize(authorization.dafuwengLogin(uid),"123434555412","1");
String orderId = (String)response.jsonPath().get("orderId");
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid),orderId);
String message = response.jsonPath().getString("message");
int i=10;
while(!message.equals("兑换提交成功!待处理")&&i>0){
Thread.sleep(1000);
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid),orderId);
message = response.jsonPath().getString("message");
i--;
}
//第二次兑换
//不同的用户,同一个 qq好
int uid1=4935;
response = qbExchangeService.doTakePrize1(authorization.dafuwengLogin(uid1),"123434555412","1");
response.prettyPrint();
message = response.jsonPath().getString("message");
logger.info(message);
Assert.assertTrue(message.contains("抱歉,该QQ号已达到每天充值上限,请换一个QQ号吧。"));
logger.info("每限日兑换制不同一个用户使用同一个QQ号成功");
}
}
......@@ -726,7 +726,7 @@ public class 优惠券_兑换流程测试_ExchangeTest extends CheckTemplet {
* @param caseName 用例名称打印
* @throws Exception
*/
@Test(dataProvider = "providerMethod")
//@Test(dataProvider = "providerMethod")
public void 优惠券地区兑换限制测试(int caseNum, String appItemId, String itemId, String token,String caseName) throws Exception{
logger.info(caseName);
......
......@@ -393,7 +393,7 @@ public class Item_FloorTest extends DuibaTestBase {
JsonPath jsonPath=from(s.substring(s.indexOf("{"),s.length()-1));
List<Map> list = jsonPath.getList("list",Map.class);
Assert.assertEquals(list.size(),listDev.size(),"开发者配置和手机端展示数量不符");
// Assert.assertEquals(list.size(),listDev.size(),"开发者配置和手机端展示数量不符");
......
......@@ -152,7 +152,11 @@ public class 抽奖异常测试_DuibaTest extends DuibaTestBase {
//获取未登录场景cookie
Response responses = authorization.autoLogin();
//进行接口测试传参
Response response = newActivityService.doJoin(responses.getDetailedCookies(),data.get("token"),data.get("activityId"));
Map<String,String> map = responses.getCookies();
logger.info("cookies:"+map.toString());
if(responses.getDetailedCookies()==null)logger.info("cookies = = null");
Response response = newActivityService.doJoinMap(map,data.get("token"),data.get("activityId"));
// Response response = newActivityService.doJoin(responses.getDetailedCookies(),data.get("token"),data.get("activityId"));
response.prettyPrint();
String success = String.valueOf(response.jsonPath().getString("success"));
//根据case选择校验项
......@@ -180,6 +184,10 @@ public class 抽奖异常测试_DuibaTest extends DuibaTestBase {
Assert.assertTrue(response.jsonPath().getString("lottery.link").contains("/activity/takePrizeNew?recordId="));
Assert.assertEquals(response.jsonPath().getString("lottery.id"), "11628", "校验id失败");
logger.info("未登录状态下有免费次数抽奖校验:title,link,id成功");
response = newActivityService.login(map,"2239.3.3.0");
Assert.assertEquals(response.jsonPath().getString("success"),"true","登录跳转接口访问失败!");
}
}
......
......@@ -62,7 +62,7 @@ public class 无积分测试_DuibaTest extends DuibaTestBase {
Assert.assertEquals(response_ajax.jsonPath().getString("element.status"),"4","校验status失败");
logger.info("ajax校验项:status成功");
Assert.assertEquals(response.jsonPath().getString("message"),"永久次数已用完","校验message失败");
Assert.assertEquals(response.jsonPath().getString("status"),"3","校验status失败");
Assert.assertEquals(response.jsonPath().getString("status"),"4","校验status失败");
Assert.assertEquals(response.jsonPath().getString("success"),"false","校验success失败");
logger.info("doJoin校验项:message,status,success成功");
break;
......@@ -84,7 +84,7 @@ public class 无积分测试_DuibaTest extends DuibaTestBase {
}
//切换回2720用户
authorization.dafuwengLogin(2720,true);
//authorization.dafuwengLogin(2720,true);
}
......
......@@ -70,7 +70,10 @@ public class 新集卡_开奖流程_DuibaTest extends DuibaTestBase {
String collectRuleId = data.get("collectRuleId");
Integer uid = Integer.valueOf(data.get("uid").toString());
String count = data.get("count");
String consumerId = data.get("consumerId");
String itemIdDb = data.get("itemId");
clearCardInfo(itemIdDb,consumerId);
String itemId = null;
for (int i=0;i<Integer.valueOf(count);i++){
......@@ -447,4 +450,11 @@ public class 新集卡_开奖流程_DuibaTest extends DuibaTestBase {
}
public void clearCardInfo(String itemId ,String comsumerIds) throws Exception{
String dbName = "collect_card_consumer.tb_collect_card_info_"+ String.format("%04d", Long.parseLong(comsumerIds)%1024);
logger.info("用户的分表名dbName为"+dbName);
Boolean res1 = jdbc.update("update "+dbName+" set item_count = '0' where item_id = ? and consumer_id = ?",itemId,comsumerIds);
}
}
\ No newline at end of file
......@@ -68,7 +68,7 @@ public class pk_列表测试_AccessTest extends DuibaTestBase {
List<BetMobileVo> unbetList_uid_18816 = response_uid_18816.jsonPath().getList("data.unbetList",BetMobileVo.class);
logger.info("unbetList_uid_188166的信息为"+ JSONObject.toJSONString(unbetList_uid_18816));
Assert.assertEquals(String.valueOf(unbetList_uid_18816.size()),"0","已投注的活动为0校验失败");
Assert.assertEquals(String.valueOf(betedList_uid_18816.size()),"0","未投注的活动为0校验失败");
Assert.assertEquals(String.valueOf(betedList_uid_18816.size()),"2","未投注的活动为0校验失败");
logger.info("没有添加pk楼层,用户的列表数据校验成功,均为空,betedList_uid_18816="+ JSON.toJSONString(betedList_uid_18816)+"\nunbetList_uid_18816="+ JSON.toJSONString(unbetList_uid_18816));
......@@ -85,7 +85,7 @@ public class pk_列表测试_AccessTest extends DuibaTestBase {
List<BetMobileVo> betedList_uided_2239 = response_uided_2239.jsonPath().getList("data.betedList",BetMobileVo.class);
List<BetMobileVo> unbetList_uided_2239 = response_uided_2239.jsonPath().getList("data.unbetList",BetMobileVo.class);
Assert.assertEquals(String.valueOf(betedList_uided_2239.size()),"2","已投注的活动为2校验失败");
Assert.assertEquals(String.valueOf(unbetList_uided_2239.size()),"4","已投注的活动为4校验失败");
Assert.assertEquals(String.valueOf(unbetList_uided_2239.size()),"5","已投注的活动为4校验失败");
logger.info("添加pk楼层未参加活动,未押注活动列表数据校验成功,unbetList_uided_2239="+ JSON.toJSONString(unbetList_uided_2239)+"\n已押注列表为空betedList_uided_2239="+ JSON.toJSONString(betedList_uided_2239));
for (int i=0;i<betedList_uided_2239.size()-1;i++){
......
......@@ -221,9 +221,10 @@ public class pk_开奖_批量用户开奖测试 extends DuibaTestBase {
try {
Boolean result1 = jdbc.update("delete from act_com_conf.tb_bet_option where bet_id in (select id from act_com_conf.tb_bet_config where title like '【自动化】瓜分红包%')");
Boolean result4 = jdbc.update("delete from act_record.tb_bet_record where bet_id in (select id from act_com_conf.tb_bet_config where title like '【自动化】瓜分红包%')");
Boolean result5 = jdbc.update("delete from bet_activity.tb_bet_result where bet_id in (select id from act_com_conf.tb_bet_config where title like '【自动化】瓜分红包%')");
Boolean result2 = jdbc.update("delete from act_com_conf.tb_bet_group_relation where bet_id in (select id from act_com_conf.tb_bet_config where title like '【自动化】瓜分红包%')");
Boolean result3 = jdbc.update("delete from act_com_conf.tb_bet_config where title like '【自动化】瓜分红包%'");
Boolean result4 = jdbc.update("delete from act_record.tb_bet_record where bet_id in (select id from act_com_conf.tb_bet_config where title like '【自动化】瓜分红包%')");
clear(consumerIds);
......
......@@ -234,6 +234,7 @@ public class pk_开奖_瓜分红包_押注人数不同测试_AccessTest extends
Boolean result1 = jdbc.update("delete from act_com_conf.tb_bet_option where bet_id in (select id from act_com_conf.tb_bet_config where title like '【自动化】瓜分红包%')");
Boolean result4 = jdbc.update("delete from act_record.tb_bet_record where bet_id in (select id from act_com_conf.tb_bet_config where title like '【自动化】瓜分红包%')");
Boolean result5 = jdbc.update("delete from bet_activity.tb_bet_result where bet_id in (select id from act_com_conf.tb_bet_config where title like '【自动化】瓜分红包%')");
Boolean result2 = jdbc.update("delete from act_com_conf.tb_bet_group_relation where bet_id in (select id from act_com_conf.tb_bet_config where title like '【自动化】瓜分红包%')");
Boolean result3 = jdbc.update("delete from act_com_conf.tb_bet_config where title like '【自动化】瓜分红包%'");
......
......@@ -186,6 +186,7 @@ public class pk_开奖_瓜分红包_押注人数相同测试_AccessTest extends
Boolean result1 = jdbc.update("delete from act_com_conf.tb_bet_option where bet_id in (select id from act_com_conf.tb_bet_config where title like '【自动化】瓜分红包%')");
Boolean result4 = jdbc.update("delete from act_record.tb_bet_record where bet_id in (select id from act_com_conf.tb_bet_config where title like '【自动化】瓜分红包%')");
Boolean result5 = jdbc.update("delete from bet_activity.tb_bet_result where bet_id in (select id from act_com_conf.tb_bet_config where title like '【自动化】瓜分红包%')");
Boolean result2 = jdbc.update("delete from act_com_conf.tb_bet_group_relation where bet_id in (select id from act_com_conf.tb_bet_config where title like '【自动化】瓜分红包%')");
Boolean result3 = jdbc.update("delete from act_com_conf.tb_bet_config where title like '【自动化】瓜分红包%'");
......
......@@ -10,7 +10,9 @@ package http.cases.PkTest;
import base.DuibaLog;
import base.DuibaTestBase;
import com.alibaba.fastjson.JSONObject;
import http.service.Activity.PkService;
import http.service.Manager.EditManagerInfoService;
import http.service.hd.DeveloperConfigService;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -19,8 +21,10 @@ import org.testng.Assert;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import utils.GetCookieUtil;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -38,6 +42,10 @@ public class pk_押注测试_AccessTest extends DuibaTestBase {
PkService pkService;
@Autowired
DeveloperConfigService developerConfigService;
@Autowired
EditManagerInfoService editManagerInfoService;
private DuibaLog logger = DuibaLog.getLogger();
......@@ -47,6 +55,7 @@ public class pk_押注测试_AccessTest extends DuibaTestBase {
private static String uid02_consumerId = "100066016";
private String consumerIds = "";
private List<String> orderIds = new ArrayList<>();
......@@ -68,7 +77,7 @@ public class pk_押注测试_AccessTest extends DuibaTestBase {
@Test
public void 押注测试() throws Exception{
public void 押注_红包活动测试() throws Exception{
Map<String,Object> user = jdbc.findSimpleResult("select * from dafuweng.user where id=?\n",uid01);
Map<String,Object> consumer = jdbc.findSimpleResult("select * from new_consumer.consumer_0010 where id=?\n",uid01_consumerId);
Long userCredit = Long.parseLong(user.get("credits").toString());
......@@ -143,6 +152,40 @@ public class pk_押注测试_AccessTest extends DuibaTestBase {
}
@Test
public void 押注_新用户首次参与测试() throws Exception{
Map<String,String> user = this.createUser();
consumerIds = user.get("consumerId");
logger.info("consumerIds的信息为"+consumerIds);
Response doJoinResponse = pkService.doJoin2(Integer.valueOf(user.get("uid")),"124","248");
doJoinResponse.prettyPrint();
Assert.assertEquals(doJoinResponse.jsonPath().getString("code").toString(),"100060");
}
public Map<String,String> createUser() throws Exception{
Map<String,String> map = new HashMap<>();
Response response = editManagerInfoService.createUser("pk活动首次参与用户");
Map<String,Object> user = jdbc.findSimpleResult("select * from dafuweng.user where name = 'pk活动首次参与用户' and app_id = '67'\n");
String uid = user.get("id").toString();
String url = GetCookieUtil.genUrl(uid,"3erv8LvBxKBSyuGK5i8FSGyYoFD1");
JSONObject cookie = GetCookieUtil.getConsumerIdFromCookie(url);
map.put("uid",uid);
map.put("consumerId",cookie.get("cid").toString());
logger.info("用户信息为,uid="+uid+"consumerId="+cookie.get("cid").toString());
return map;
}
public void clear(String comsumerIds) throws Exception{
Boolean res = jdbc.update("delete from dafuweng.user where name = 'pk活动首次参与用户' and app_id = '67'");
String dbName = "new_consumer.consumer_"+ String.format("%04d", Long.parseLong(comsumerIds)/10000000);
logger.info("用户的分表名dbName为"+dbName);
Boolean res1 = jdbc.update("delete from "+dbName+" where id = ?",comsumerIds);
}
@AfterMethod
public void tearDown() {
......@@ -152,6 +195,8 @@ public class pk_押注测试_AccessTest extends DuibaTestBase {
for (String orderId:orderIds){
Boolean result2 = jdbc.update("delete from activity_order_con.tb_trade_center_activity_order_0735 where order_num = ?\n",orderId);
}
clear(consumerIds);
}catch (Exception e){
e.printStackTrace();
......
......@@ -150,9 +150,10 @@ public class PluginDrawingtool_pluginTest extends DuibaTestBase {
logger.info("校验链接券码成功");
break;
case 2:
Assert.assertTrue(response.jsonPath().getString("lottery.openUrl").contains("//activity.m.duibatest.com.cn/crecord/recordDetailNew"));
// Assert.assertTrue(response.jsonPath().getString("lottery.openUrl").contains("//activity.m.duibatest.com.cn/crecord/recordDetailNew"));
Assert.assertTrue(response.jsonPath().getString("lottery.iosDownloadUrl").contains("//activity.m.duibatest.com.cn/crecord/recordDetailNew"));
Assert.assertEquals(response.jsonPath().getString("lottery.id"), "2003", "校验id失败");
Assert.assertEquals(response.jsonPath().getString("lottery.showUse"), "true", "校验是否展示马上使用失败");
Assert.assertEquals(response.jsonPath().getString("lottery.showUse"), "false", "校验是否展示马上使用失败");
Assert.assertEquals(response.jsonPath().getString("lottery.useBtnText"), "查看使用方法", "校验按钮文案展示失败");
logger.info("校验跳转兑换记录链接成功");
break;
......
......@@ -78,7 +78,7 @@ public class 插件_优惠券测试_pluginTest extends DuibaTestBase {
String androidDL = MatcherString.getString(managerResponse.asString(), "androidurl: '(.*?)',", 1);
String iOSDL = MatcherString.getString(managerResponse.asString(), "iosurl: '(.*?)',", 1);
String usebtn = MatcherString.getString(managerResponse.asString(), "usebtn: '(.*?)',", 1);
String actLinkEx = "//activity.m.duibatest.com.cn/crecord/recordDetailNew/";
String actLinkEx = "//activity.m.duibatest.com.cn/crecord/recordDetailNew";
String linkUrl = MatcherString.getString(linkResponse.asString(), "target=\"_blank\" href=\"(.*?)\">", 1);
//进行接口测试传参
......
package http.cases.SaasDeveloperTest;
import base.Config;
import base.DuibaTestBase;
import http.service.Saas.DeveloperBJZ;
import base.DuibaLog;
import http.service.Saas.DeveloperObjectService;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
import org.testng.Assert;
import org.testng.annotations.Test;
@ContextConfiguration(classes = Config.class)
public class 补给站 extends DuibaTestBase {
@Autowired
DeveloperBJZ developerBJZ;
@Autowired
DeveloperObjectService developerObjectService;
private DuibaLog logger = DuibaLog.getLogger();
String appId="19515";
//添加、上架至尊版实物
@Test
public void a_添加至尊版实物() throws Exception{
//查询列表,获取ID
Response response =developerBJZ.item("2");
String id= String.valueOf(response.jsonPath().getString("data.list[0].id"));
String title= String.valueOf(response.jsonPath().getString("data.list[0].title"));
//添加
developerBJZ.ajaxAddRepo(appId,id);
//上架
developerBJZ.ajaxDirectUp(appId,id);
//查询商品列表,验证商品是否上架成功
Response response2 =developerObjectService.appItems(appId,title);
String appItemId = String.valueOf(response2.jsonPath().getString("data.list[0].id"));
Assert.assertEquals(response2.jsonPath().getString("data.list[0].title"), "测试至尊享版-实物3", "校验实物标题失败");
Assert.assertEquals(response2.jsonPath().getString("data.list[0].status"), "1", "校验实物状态失败");
Assert.assertEquals(response2.jsonPath().getString("data.list[0].type"), "object", "校验实物类型失败");
logger.info("校验title,status成功");
//删除添加的商品
developerObjectService.ajaxDel(appItemId);
}
//添加、上架优惠券
@Test
public void b_添加至尊版优惠券() throws Exception{
//查询列表,获取ID
Response response =developerBJZ.coupons(appId,"2");
String id= String.valueOf(response.jsonPath().getString("data.list[0].id"));
String title= String.valueOf(response.jsonPath().getString("data.list[0].title"));
//添加
developerBJZ.ajaxAddRepo(appId,id);
//上架
developerBJZ.ajaxDirectUp(appId,id);
//查询商品列表,验证商品是否上架成功
Response response2 =developerObjectService.appItems(appId,title);
String appItemId = String.valueOf(response2.jsonPath().getString("data.list[0].id"));
Assert.assertEquals(response2.jsonPath().getString("data.list[0].title"), "测试至尊享版-优惠券", "校验优惠券标题名称失败");
Assert.assertEquals(response2.jsonPath().getString("data.list[0].status"), "1", "校验优惠券状态失败");
Assert.assertEquals(response2.jsonPath().getString("data.list[0].type"), "coupon", "校验优惠券类型失败");
logger.info("校验title,status成功");
//删除添加的商品
developerObjectService.ajaxDel(appItemId);
}
//添加活动
@Test
public void c_添加活动() throws Exception{
//查询热门活动-活动列表,获取商品ID
Response response=developerBJZ.saasActivitys("3");
String goodItemId= String.valueOf(response.jsonPath().getString("data.saasActivitys[0].id"));
//获取商品ID,进入商品订购页面,获取SKU
Response response2=developerBJZ.itemOrderDetail(goodItemId);
String skuId= String.valueOf(response2.jsonPath().getString("data.goodsItemSku[0].skuId"));
//点击订购,传入SKU创建订单
logger.info("kuid==="+skuId);
Response response3=developerBJZ.createAutomationOrderNew(skuId);
String orderid= String.valueOf(response3.jsonPath().getString("data"));
logger.info("kuid==="+orderid);
//下单购买
Response response4=developerBJZ.orderAccountPay(orderid);
}
}
package http.cases.SaasDeveloperTest;
import base.Config;
import http.service.Saas.DeveloperBJZ;
import base.DuibaLog;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
import org.testng.Assert;
import org.testng.annotations.Test;
@ContextConfiguration(classes = Config.class)
public class 补给站_商品_DuibaTest extends AbstractTestNGSpringContextTests {
@Autowired
DeveloperBJZ developerBJZ;
private DuibaLog logger = DuibaLog.getLogger();
//至尊版app
private static String appId = "19515";
//旗舰版app
private static String appId2 = "21695";
@Test(description = "至尊版app添加、上架至尊版实物")
public void a_添加至尊版实物() throws Exception {
//查询列表,获取ID
Response response = developerBJZ.items("2", appId);
String itemId = String.valueOf(response.jsonPath().getString("data.list[0].id"));
String itemIds = String.valueOf(response.jsonPath().getString("data.list[0].id"));
String itemName = String.valueOf(response.jsonPath().getString("data.list[0].title"));
//添加
developerBJZ.ajaxAddRepo(appId, itemId);
//上架
developerBJZ.ajaxDirectUp(appId, itemIds);
//查询商品列表,验证商品是否上架成功
Response response2 = developerBJZ.appItems(appId, itemName);
String appItemId2 = response2.jsonPath().getString("data.list[0].id");
Assert.assertEquals(response2.jsonPath().getString("data.list[0].title"), "测试至尊享版-实物3", "校验实物标题失败");
Assert.assertEquals(response2.jsonPath().getString("data.list[0].status"), "1", "校验实物状态失败");
Assert.assertEquals(response2.jsonPath().getString("data.list[0].type"), "object", "校验实物类型失败");
logger.info("校验title,status,type成功");
//删除添加的商品
developerBJZ.ajaxDel(appId, appItemId2);
}
@Test(description = "旗舰版app添加、上架至尊版实物:异常场景,提示不能上架")
public void b_旗舰版添加至尊版实物() throws Exception {
//查询列表,获取ID
Response response = developerBJZ.items("2", appId2);
String id = String.valueOf(response.jsonPath().getString("data.list[0].id"));
//上架
Response response2 = developerBJZ.ajaxDirectUp2(appId2, id);
//接口提示,至尊版专享,不能上架
Assert.assertEquals(response2.jsonPath().getString("desc"), "至尊版专享", "校验接口上架失败");
}
@Test(description = "优质好货搜索功能")
public void c_实物搜索() throws Exception {
// 根据具体的名称搜索出实物
developerBJZ.items2("2", appId);
// 输入精确的名称查询不到此实物
developerBJZ.items3("2", appId);
}
@Test(description = "//添加、上架优惠券")
public void d_添加至尊版优惠券() throws Exception {
//查询列表,获取ID
Response response = developerBJZ.coupons(appId, "2");
String itemId = String.valueOf(response.jsonPath().getString("data.list[0].id"));
String itemIds = String.valueOf(response.jsonPath().getString("data.list[0].id"));
String itemName = String.valueOf(response.jsonPath().getString("data.list[0].title"));
//添加
developerBJZ.ajaxAddRepo(appId, itemId);
//上架
developerBJZ.ajaxDirectUp(appId, itemIds);
//查询商品列表,验证商品是否上架成功
Response response2 = developerBJZ.appItems(appId, itemName);
String appItemId2 = String.valueOf(response2.jsonPath().getString("data.list[0].id"));
Assert.assertEquals(response2.jsonPath().getString("data.list[0].title"), "测试至尊享版-优惠券", "校验优惠券标题名称失败");
Assert.assertEquals(response2.jsonPath().getString("data.list[0].status"), "1", "校验优惠券状态失败");
Assert.assertEquals(response2.jsonPath().getString("data.list[0].type"), "coupon", "校验优惠券类型失败");
logger.info("校验title,status,type成功");
//删除添加的优惠券
developerBJZ.ajaxDel(appId, appItemId2);
}
@Test(description = "//旗舰版app添加、上架至尊版优惠券:异常场景,提示不能上架")
public void e_旗舰版添加至尊版优惠券() throws Exception {
//查询列表,获取ID
Response response = developerBJZ.coupons(appId2, "2");
String id = String.valueOf(response.jsonPath().getString("data.list[0].id"));
//上架
Response response2 = developerBJZ.ajaxDirectUp2(appId2, id);
//接口提示,至尊版专享,不能上架
Assert.assertEquals(response2.jsonPath().getString("desc"), "至尊版专享", "校验接口上架失败");
}
@Test(description = "//添加直冲类")
public void f_添加直冲类() throws Exception {
Response response = developerBJZ.directCharges(appId);
String itemId = String.valueOf(response.jsonPath().getString("data.list[1].id"));
String itemName = String.valueOf(response.jsonPath().getString("data.list[1].title"));
//添加直冲类
developerBJZ.ajaxAddRepo(appId, itemId);
//查询商品列表,验证商品是否添加成功
Response response2 = developerBJZ.appItems(appId, itemName);
String appItemId2 = String.valueOf(response2.jsonPath().getString("data.list[0].id"));
Assert.assertEquals(response2.jsonPath().getString("data.list[0].title"), "Q币充值", "校验标题名称失败");
Assert.assertEquals(response2.jsonPath().getString("data.list[0].status"), "0", "校验状态失败");
Assert.assertEquals(response2.jsonPath().getString("data.list[0].type"), "qb", "校验类型失败");
logger.info("校验title,status,type成功");
//删除添加的直冲类
developerBJZ.ajaxDel(appId, appItemId2);
}
}
\ No newline at end of file
package http.cases.SaasDeveloperTest;
import base.Config;
import http.service.Saas.DeveloperBJZ;
import base.DuibaLog;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
import org.testng.Assert;
import org.testng.annotations.Test;
@ContextConfiguration(classes = Config.class)
public class 补给站_活动_DuibaTest extends AbstractTestNGSpringContextTests{
@Autowired
DeveloperBJZ developerBJZ;
private DuibaLog logger = DuibaLog.getLogger();
//至尊版app
String appId="19515";
//旗舰版app
String appId2="21695";
//添加活动
@Test(description = "//添加活动")
public void a_添加活动() throws Exception{
//查询热门活动-活动列表,获取商品ID
Response response=developerBJZ.saasActivitys("3",appId);
String goodItemId= String.valueOf(response.jsonPath().getString("data.saasActivitys[0].id"));
//获取商品ID,进入商品订购页面,获取SKU
Response response2=developerBJZ.itemOrderDetail(goodItemId,appId);
String skuId= String.valueOf(response2.jsonPath().getString("data.goodsItemSku[0].skuId"));
//点击订购,传入SKU创建订单
logger.info("kuid==="+skuId);
Response response3=developerBJZ.createAutomationOrderNew(skuId,appId);
String orderid= String.valueOf(response3.jsonPath().getString("data"));
logger.info("kuid==="+orderid);
//下单购买
developerBJZ.orderAccountPay(orderid,appId);
//查询是否购买成功
Response response4=developerBJZ.findOrderById(orderid,appId);
Assert.assertEquals(response4.jsonPath().getString("data.vo.funcName"), "自动化测试活动--勿动", "校验名称失败");
Assert.assertEquals(response4.jsonPath().getString("data.vo.limitTime"), "一年", "校验购买期限失败");
logger.info("校验名称,期限成功");
}
@Test(description = "//添加签到活动")
public void b_添加签到活动() throws Exception{
//查询热门活动-活动列表,获取商品ID
Response response=developerBJZ.saasActivitys("2",appId);
String goodItemId= String.valueOf(response.jsonPath().getString("data.saasActivitys[1].id"));
//获取商品ID,进入商品订购页面,获取SKU
Response response2=developerBJZ.itemOrderDetail(goodItemId,appId);
String skuId= String.valueOf(response2.jsonPath().getString("data.goodsItemSku[0].skuId"));
//点击订购,传入SKU创建订单
logger.info("kuid==="+skuId);
Response response3=developerBJZ.createAutomationOrderNew(skuId,appId);
String orderid= String.valueOf(response3.jsonPath().getString("data"));
logger.info("kuid==="+orderid);
//下单购买
developerBJZ.orderAccountPay(orderid,appId);
//查询是否购买成功
Response response4=developerBJZ.findOrderById(orderid,appId);
Assert.assertEquals(response4.jsonPath().getString("data.vo.funcName"), "SaaS签到", "校验名称失败");
logger.info("校验名称成功");
}
@Test(description = "付款时有待处理的订单(异常场景)")
public void c_待处理的订单() throws Exception{
//查询热门活动-活动列表,获取商品ID
Response response=developerBJZ.saasActivitys("2",appId);
String goodItemId= String.valueOf(response.jsonPath().getString("data.saasActivitys[1].id"));
//获取商品ID,进入商品订购页面,获取SKU
Response response2=developerBJZ.itemOrderDetail(goodItemId,appId);
String skuId= String.valueOf(response2.jsonPath().getString("data.goodsItemSku[0].skuId"));
//点击订购,传入SKU创建订单
logger.info("kuid==="+skuId);
developerBJZ.createAutomationOrderNew(skuId,appId);
developerBJZ.createAutomationOrderNew2(skuId,appId);
Assert.assertEquals(developerBJZ.createAutomationOrderNew2(skuId,appId).jsonPath().getString("desc"), "订单未处理", "校验订单待处理成功");
//查询待处理订单
Response response3=developerBJZ.selectOrders("1",appId);
Assert.assertEquals(response3.jsonPath().getString("data.list[0].serviceName"), "SaaS签到", "校验名称失败");
logger.info("查询待处理订单成功");
}
@Test(description="查询交易关闭的订单")
public void d_交易关闭的订单() throws Exception{
//查询待付款订单
Response response=developerBJZ.selectOrders("1",appId);
String orderId=String.valueOf(response.jsonPath().getString("data.list[0].id"));
// 点击取消付款,进入到交易关闭订单
developerBJZ.cancleOrder(orderId,appId);
Response response2=developerBJZ.selectOrders("3",appId);
Assert.assertEquals(response2.jsonPath().getString("data.list[0].serviceName"), "SaaS签到", "校验名称失败");
logger.info("查询交易关闭订单成功");
}
}
......@@ -31,8 +31,9 @@ public class 设置_应用信息_DuibaTest extends AbstractTestNGSpringContextTe
String unitName = isDecimalOpen ? "元" : "积分";
updateAppInfoService.UpdateAppInfo(appId,unitName,earnCreditsUrl,creditsDetailUrl,isDecimalOpen);
Thread.sleep(1000);
Response response2= updateAppInfoService.appInfo(appId);
Assert.assertEquals(response2.jsonPath().getString("data.name"), "(saas)接口自动化应用", "校验应用名称失败");
Assert.assertEquals(response2.jsonPath().getString("data.name"), "(saas自动化)至尊版", "校验应用名称失败");
Assert.assertEquals(response2.jsonPath().getString("data.earnCreditsLetter"), "积分文案&2", "校验积分文案失败");
Assert.assertEquals(response2.jsonPath().getString("data.creditsDetailUrl"), "https://www.baidu.com/s?ie=utf-8&f=8&rsv_bp=1&tn=baidu&wd=www.baidu.com", "校验积分明细链接失败");
logger.info("保存应用信息成功");
......
......@@ -70,7 +70,7 @@ public class 开发者签到管理_signTest extends AbstractTestNGSpringContextT
Response response=signService.selectsignOperList();
//查看签到列表个数是否成功
Assert.assertEquals(response.jsonPath().getString("data.list[0].id"),"90", "校验签到id失败");
Assert.assertEquals(response.jsonPath().getString("data.params.total"),"1", "校验总个数失败");
Assert.assertEquals(response.jsonPath().getString("data.params.total"),"2", "校验总个数失败");
logger.info("校验签到总个数成功");
}
......
package http.cases.SingleLotteryTest;
import base.DuibaLog;
import base.DuibaTestBase;
import http.service.hd.SigninService;
import io.restassured.internal.assertion.Assertion;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.Test;
import utils.MatcherString;
/**
* Created by zhaoran on 2018/6/8.
*/
public class 预览单品抽奖_AccessTest extends DuibaTestBase {
@Autowired
SigninService signinService;
private static DuibaLog logger = DuibaLog.getLogger();
@Test
public void 预览单抽() throws Exception {
Response response = signinService.preview("18714","3","2772","36732","zhaoran@duiba.com.cn");
String url = response.jsonPath().getString("data.url");
logger.info("预览url为:"+url);
Assert.assertEquals(url.contains("http://activity.m.duibatest.com.cn/autoLogin/autologin?appKey=BDqysEMghRqpDWAaQu9S4rLihHm&uid=duiba-preview-user"), true, "校验是否展示马上使用失败");
}
}
\ No newline at end of file
package http.cases.WalletTest;
import base.DuibaTestBase;
import org.testng.annotations.BeforeClass;
import utils.RedisUtil;
import http.service.Activity.SeedRedPacketService;
import http.service.Activity.WalletAccountService;
......@@ -28,6 +29,15 @@ public class 种红包_AccessTest extends DuibaTestBase{
Authorization authorization;
private DuibaLog logger = DuibaLog.getLogger();
@BeforeClass
public void beforeclass() {
try {
//前置操作,确保土地是空地状态
seedRedPacketService.updateUserLand("19380","1","1","100066444","3");
} catch (Exception e) {
logger.info("数据前后置操作异常");
}
}
@Test
public void 种红包() throws Exception {
......
......@@ -108,11 +108,12 @@ public class 账户余额清零_AccessTest extends DuibaTestBase {
//获取最新的提现记录
Thread.sleep(3000);
Map cookies = authorization.dafuwengLogin(uid);
Response response = walletAccountService.walletDetail(cookies);
String money = response.jsonPath().getString("data[1].money");
String subType = response.jsonPath().getString("data[1].subType");
String description = response.jsonPath().getString("data[1].description");
String money = response.jsonPath().getString("data[0].money");
String subType = response.jsonPath().getString("data[0].subType");
String description = response.jsonPath().getString("data[0].description");
Assert.assertTrue(new BigDecimal(money).compareTo(new BigDecimal("100"))==0,"扣款金额校验失败");
Assert.assertEquals(subType, "0", "日志类型校验失败");
......
......@@ -42,8 +42,8 @@ public class 账户异常提现_AccessTest extends DuibaTestBase{
//指定用户
private static int uid = 4459;
private static String consumerId = "100098000";
private static int uid2 = 4460;
private static String consumerId2 = "100098001";
private static int uid2 = 4822;
private static String consumerId2 = "100108125";
private static int uid3 = 4793;
private static String consumerId3 = "100108076";
private static int uid4 = 4474;
......@@ -103,9 +103,11 @@ public class 账户异常提现_AccessTest extends DuibaTestBase{
@Test
public void 提现账号已使用() throws Exception {
//修改账户过期时间,确保账户余额不会过期清零
jdbc.update("update consumer_account_log.tb_expire_consumer_account set gmt_modified ='"+getTime(1)+"' where account_id = '"+consumerId2+"_6_0'");
//获取原账户余额
Map<String, Object> selectResult = jdbc.findSimpleResult("select * from consumer_accounts.tb_consumer_account_0977 where account_id = '"+consumerId2+"_6_0' ");
Map<String, Object> selectResult = jdbc.findSimpleResult("select * from consumer_accounts.tb_consumer_account_0861 where account_id = '"+consumerId2+"_6_0' ");
int balance = Integer.parseInt(String.valueOf(selectResult.get("balance_amount")));
logger.info("账户原有余额为"+balance);
......@@ -119,7 +121,7 @@ public class 账户异常提现_AccessTest extends DuibaTestBase{
Assert.assertEquals(response.jsonPath().getString("message"),"一个支付宝账户仅允许一个账户提现","/walletAccount/doTakePrize接口失败");
//获取新账户余额
selectResult = jdbc.findSimpleResult("select * from consumer_accounts.tb_consumer_account_0977 where account_id = '"+consumerId2+"_6_0' ");
selectResult = jdbc.findSimpleResult("select * from consumer_accounts.tb_consumer_account_0861 where account_id = '"+consumerId2+"_6_0' ");
int balanceNew = Integer.parseInt(String.valueOf(selectResult.get("balance_amount")));
logger.info("账户新余额为"+balanceNew);
......
......@@ -38,8 +38,8 @@ public class 账户正常提现_AccessTest extends DuibaTestBase{
HbaseService hbaseService;
private DuibaLog logger = DuibaLog.getLogger();
//指定用户
private static int uid = 4244;
private static String consumerId = "100092758";
private static int uid = 4823;
private static String consumerId = "100108126";
private static String orderId;
@AfterClass
public void afterclass() {
......@@ -77,7 +77,7 @@ public class 账户正常提现_AccessTest extends DuibaTestBase{
public void a_提现失败_账户错误(int caseNum,String alipay,String realname) throws Exception {
//获取原账户余额
Map<String, Object> selectResult = jdbc.findSimpleResult("select * from consumer_accounts.tb_consumer_account_0854 where account_id = '100092758_6_0' ");
Map<String, Object> selectResult = jdbc.findSimpleResult("select * from consumer_accounts.tb_consumer_account_0862 where account_id = '100108126_6_0' ");
int balance = Integer.parseInt(String.valueOf(selectResult.get("balance_amount")));
logger.info("账户原有余额为"+balance);
......@@ -101,7 +101,7 @@ public class 账户正常提现_AccessTest extends DuibaTestBase{
}
//获取新账户余额
selectResult = jdbc.findSimpleResult("select * from consumer_accounts.tb_consumer_account_0854 where account_id = '100092758_6_0' ");
selectResult = jdbc.findSimpleResult("select * from consumer_accounts.tb_consumer_account_0862 where account_id = '100108126_6_0' ");
int balanceNew = Integer.parseInt(String.valueOf(selectResult.get("balance_amount")));
logger.info("账户新余额为"+balanceNew);
......@@ -113,7 +113,7 @@ public class 账户正常提现_AccessTest extends DuibaTestBase{
public void b_正常提现() throws Exception {
//获取原账户余额
Map<String, Object> selectResult = jdbc.findSimpleResult("select * from consumer_accounts.tb_consumer_account_0854 where account_id = '100092758_6_0' ");
Map<String, Object> selectResult = jdbc.findSimpleResult("select * from consumer_accounts.tb_consumer_account_0862 where account_id = '100108126_6_0' ");
int balance = Integer.parseInt(String.valueOf(selectResult.get("balance_amount")));
logger.info("账户原有余额为"+balance);
balance = balance - 1;
......@@ -123,7 +123,7 @@ public class 账户正常提现_AccessTest extends DuibaTestBase{
this.账户提现(cookies,"peeulk6392@sandbox.com","沙箱环境");
Thread.sleep(2000);
//获取新账户余额
selectResult = jdbc.findSimpleResult("select * from consumer_accounts.tb_consumer_account_0854 where account_id = '100092758_6_0' ");
selectResult = jdbc.findSimpleResult("select * from consumer_accounts.tb_consumer_account_0862 where account_id = '100108126_6_0' ");
int balanceNew = Integer.parseInt(String.valueOf(selectResult.get("balance_amount")));
logger.info("账户新余额为"+balanceNew);
Assert.assertEquals(balanceNew,balance,"全局红包增加账户余额失败");
......@@ -169,7 +169,7 @@ public class 账户正常提现_AccessTest extends DuibaTestBase{
public void d_提现失败_登录次数不足() throws Exception {
//获取原账户余额
Map<String, Object> selectResult = jdbc.findSimpleResult("select * from consumer_accounts.tb_consumer_account_0854 where account_id = '100092758_6_0' ");
Map<String, Object> selectResult = jdbc.findSimpleResult("select * from consumer_accounts.tb_consumer_account_0862 where account_id = '100108126_6_0' ");
int balance = Integer.parseInt(String.valueOf(selectResult.get("balance_amount")));
logger.info("账户原有余额为"+balance);
......@@ -183,7 +183,7 @@ public class 账户正常提现_AccessTest extends DuibaTestBase{
Assert.assertEquals(response.jsonPath().getString("message"),"连续登录天数不足","/walletAccount/doTakePrize接口失败");
//获取新账户余额
selectResult = jdbc.findSimpleResult("select * from consumer_accounts.tb_consumer_account_0854 where account_id = '100092758_6_0' ");
selectResult = jdbc.findSimpleResult("select * from consumer_accounts.tb_consumer_account_0862 where account_id = '100108126_6_0' ");
int balanceNew = Integer.parseInt(String.valueOf(selectResult.get("balance_amount")));
logger.info("账户新余额为"+balanceNew);
......
......@@ -68,6 +68,7 @@ public class NewActivityService {
map.put("oaId",activityId);
logger.info("请求/hdtool/doJoin接口,activityId="+activityId);
logger.info("url:"+url+"/hdtool/doJoin");
Response response = given().cookies(cookies).params(map).post(url+"/hdtool/doJoin");
try{
Assert.assertEquals(String.valueOf(response.getStatusCode()),"200");
......@@ -79,6 +80,43 @@ public class NewActivityService {
}
return response;
}
public Response doJoinMap(Map cookies, String token,String activityId) throws Exception {
Map<String,String> map = new HashMap<>();
map.put("token",token);
map.put("activityId",activityId);
map.put("oaId",activityId);
logger.info("请求/hdtool/doJoin接口,activityId="+activityId);
logger.info("url:"+url+"/hdtool/doJoin");
Response response = given().cookies(cookies).params(map).post(url+"/hdtool/doJoin");
try{
Assert.assertEquals(String.valueOf(response.getStatusCode()),"200");
logger.info("/hdtool/doJoin接口成功,返回信息:"+response.asString());
}catch(Exception e){
throw new Exception("/hdtool/doJoin接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/hdtool/doJoin接口失败,返回信息:"+response.asString());
}
return response;
}
public Response login(Map cookies, String dpm) throws Exception {
Map<String,String> map = new HashMap<>();
map.put("dpm",dpm);
logger.info("请求/hdtool/login接口");
logger.info("url:"+url+"/hdtool/login");
Response response = given().cookies(cookies).params(map).post(url+"/hdtool/login");
try{
Assert.assertEquals(String.valueOf(response.getStatusCode()),"200");
logger.info("/hdtool/login接口成功,返回信息:"+response.asString());
}catch(Exception e){
throw new Exception("/hdtool/login接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/hdtool/login接口失败,返回信息:"+response.asString());
}
return response;
}
public Response doJoin2( String activityId,String token) throws Exception{
Map<String,String> map = new HashMap<>();
......
......@@ -55,6 +55,7 @@ public class Authorization {
private static Map<String,String> hdCookies;
private static Map<String,String> hdCookiesMabo;
private static Map<String,String> hdCookiesSaas;
private static Map<String,Map> hdCookiesSaasByApp = new ConcurrentHashMap<>();
private static Map<String,Map> hdCookiesCommon = new ConcurrentHashMap<>();
private static Map<String,String> openbsCookies;
private Map<String,String> ssoCookies =null;
......@@ -167,6 +168,9 @@ public class Authorization {
String url=tool.buildUrlWithSign("http://activity.m.duibatest.com.cn/autoLogin/autologin?",params);
logger.info("dafuweng免登陆url为:"+url);
Response response=given().redirects().follow(false).get(url);
logger.info("dafuweng免登陆,响应数据:"+response.asString());
logger.info("dafuweng免登陆,响应状态码:"+response.getStatusCode());
return response;
}
public Map generateSignAutoLogin(String appKey, int uid){
......@@ -244,7 +248,10 @@ public class Authorization {
}
public Map hdLoginSaas(String appId){
int i=10;
logger.info("hdCookiesSaasByApp cookies:"+hdCookiesSaasByApp.toString());
Map<String,String> hdCookies = hdCookiesSaasByApp.get(appId);
while((hdCookies==null||hdCookies.size()==0)&&i>0) {
Response token=this.hdGetToken();
String url = PROTOCOL + hdHost + hdLoginPath;
Map<String,String> cookies=token.getCookies();
......@@ -254,12 +261,22 @@ public class Authorization {
paras.put("redirect", "/redirectApp");
paras.put("isAutoLogin", "true");
Response response = given().cookies(cookies).params(paras).post(url);
Map<String,String> hdCookiesSaasByApp=new HashMap<>(response.getCookies());
Map<String,String> map = response.getCookies();
logger.info("cookies:"+map.toString());
hdCookies=new HashMap<>(response.getCookies());
if(hdCookies!=null||hdCookies.size()!=0) {
//取消安全校验
hdCookiesSaasByApp.remove("csrf_token");
hdCookiesSaasByApp.put("appId",appId);
return hdCookiesSaasByApp;
hdCookies.remove("csrf_token");
hdCookies.put("appId", appId);
hdCookies.put("duibaAppId", appId);
logger.info("cookies2:"+hdCookies.toString());
hdCookiesSaasByApp.put(appId,hdCookies);
}
i--;
}
logger.info("hdCookiesSaasByApp cookies集合:"+hdCookiesSaasByApp.toString());
return hdCookies;
}
//密码为duibaduiba123
public Map hdLoginCommon(String email){
......@@ -276,7 +293,7 @@ public class Authorization {
paras.put("isAutoLogin", "true");
Response response = given().cookies(cookies).params(paras).post(url);
hdCookies=new HashMap<>(response.getCookies());
if(hdCookies==null||hdCookies.size()==0){
if(hdCookies!=null||hdCookies.size()!=0){
hdCookies.remove("csrf_token");
hdCookiesCommon.put(email,hdCookies);
}
......@@ -306,7 +323,7 @@ public class Authorization {
Response response = given().cookies(cookies).params(paras).post(url);
response.prettyPrint();
hdCookies=new HashMap<>(response.getCookies());
if(hdCookies==null||hdCookies.size()==0){
if(hdCookies!=null||hdCookies.size()!=0){
hdCookies.remove("csrf_token");
hdCookiesCommon.put(account,hdCookies);
}
......
......@@ -20,6 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.testng.Assert;
import utils.MatcherString;
import java.util.ArrayList;
import java.util.HashMap;
......@@ -119,8 +120,14 @@ public class PkActivityService {
if (bonusType.equals("2")){
para.put("bonusAmount","0.1");//实际瓜分红包金额
para.put("title","【自动化】瓜分红包"+time);
}else {
}else if (bonusType.equals("1")){
para.put("title","【自动化】瓜分经验"+time);
}else {
para.put("title","【自动化】瓜分优惠券");
para.put("bonusAmount","");
para.put("pluginId","12");//插件id
para.put("prizeLimit","1000");//发放上限
}
para.put("configStatus","1");
para.put("creditsValue","1");
......@@ -303,6 +310,82 @@ public class PkActivityService {
}
//创建pk开奖的插件活动id
public Response pluginSave(String pkActivityId) throws Exception {
String saveUrl = "http://"+ ManagerHost + "/plugin/save";
String configUrl ="http://"+ ManagerHost + "/plugin/editConfig.htm";
//获取创建活动的token
Response response=given().contentType("text/html;charset=UTF-8").cookies(authorization.ssoLogin()).get(configUrl);
String token = MatcherString.getString(response.asString(), "token: '(.*?)'", 1);
List<Map<String,String>> listPrizes = new ArrayList<>();
Map<String,String> award = new HashMap<>();
award.put("type","coupon");
award.put("description","优惠券");
award.put("logo","//yun.duiba.com.cn/developer/img/activityTool/slotMachine/coupon.png");
award.put("valid","true");
award.put("rate","100");
award.put("arealimit","false");
award.put("stockBeforeChange","0");
award.put("rewardFalg","false");
award.put("prizeTag","");
award.put("winLimitScope","1");
award.put("prizesLimitScope","daily");
award.put("itemId","27097");
award.put("name","LV优惠券自动化测试链接券");
award.put("stockAfterChange","10");
award.put("remaining","10");
listPrizes.add(award);
String prizes = JSON.toJSONString(listPrizes);
Map<String, String> map = new HashMap<>();
map.put("title", "【自动化】pk开奖插件");
map.put("brickId", "92");
map.put("ruleDescription", "自动化活动规则");
map.put("rateDescription", "自动化概率说明");
map.put("multiSkinsMode", "false");
map.put("multiSkinIds","[]");
map.put("triggerTime","[]");
map.put("limitCount","1");
map.put("exitDays", "7");
map.put("anticheatExchangeLimit", "false");
map.put("limitScope", "forever");
map.put("prizes",prizes);
map.put("tag","[]");
map.put("triggerType", "1");
map.put("hiddenForDeveloper", "false");
map.put("joinVerificy", "true");
map.put("duibaRelateMode", "false");
map.put("channelType","0");
map.put("token",token);
map.put("copy", "false");
map.put("subType","plugdraw");
map.put("joinVerificyMode","15");
map.put("pkId",pkActivityId);
map.put("scenarios", "chome");
logger.info("请求保存插件活动接口的参数为:" + JSONObject.toJSONString(map));
logger.info("请求保存插件活动接口:" + saveUrl);
Response saveResponse = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.ssoLogin()).params(map).post(saveUrl);
saveResponse.prettyPrint();
try{
Assert.assertEquals(saveResponse.jsonPath().getString("success"),"true");
}catch(Exception e){
throw new Exception("创建插件活动接口失败,返回信息:"+saveResponse.asString());
}catch(Error er){
throw new Exception("创建插件活动接口失败,返回信息:"+saveResponse.asString());
}
return saveResponse;
}
// public static void main(String[] args) throws Exception{
// String endTime = "2021-12-31 23:55:00";
// PkActivityService pkActivityService = new PkActivityService();
......
......@@ -2,6 +2,7 @@ package http.service.Manager;
import base.DuibaLog;
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;
......@@ -345,9 +346,4 @@ public class PluginService {
}
}
......@@ -34,7 +34,7 @@ public class UpdateAppInfoService {
Map<String,Object> map = new HashMap<>();
map.put("appId",appId);
map.put("creditsRate","100");
map.put("appName","(saas)接口自动化应用");
map.put("appName","(saas自动化)至尊版");
map.put("appTitle","自动化测试使用");
map.put("logoVal","//yun.dui88.com/images/201809/svieibjtn0.png");
map.put("unitName",unitName);
......
......@@ -33,6 +33,7 @@ public class QbExchangeService {
map.put("token","0nmfgduh8");
Response response = given().params(map).cookies(cookies).post(activityHost+"/qbExchange/exchange");
try{
Assert.assertEquals(response.jsonPath().getString("success"),"true","/qbExchange/exchange接口失败");
......@@ -45,4 +46,27 @@ public class QbExchangeService {
return response;
}
public Response doTakePrize1(Map cookies, String qq, String degreeId) throws Exception {
logger.info("请求/qbExchange/exchange");
Map<String,String> map = new HashMap<>();
map.put("qq",qq);
map.put("degreeId",degreeId);
map.put("token","0nmfgduh8");
Response response = given().params(map).cookies(cookies).post(activityHost+"/qbExchange/exchange");
String message = response.jsonPath().getString("data.message");
logger .info(message);
try{
Assert.assertEquals(String.valueOf(response.getStatusCode()), "200", "/objectExchange/exchange接口返回异常");
}catch(Exception e){
throw new Exception("/qbExchange/exchange接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/qbExchange/exchange接口失败,返回信息:"+response.asString());
}
return response;
}
}
......@@ -48,8 +48,8 @@ public class ActivityCtrlService {
params.put("actId",actId);
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.dafuwengLogin(uid)).params(params)
.post(activityHost+"/newActivity/ajaxElement");
logger.info("请求/newActivity/ajaxElement接口,响应结果:"+response.asString());
.post(activityHost+"/hdtool/ajaxElement");
logger.info("请求/hdtool/ajaxElement接口,响应结果:"+response.asString());
return response;
}
......@@ -58,8 +58,8 @@ public class ActivityCtrlService {
params.put("activityId",activityId);
params.put("token",token);
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.dafuwengLogin(uid)).params(params)
.post(activityHost+"/newActivity/doJoin");
logger.info("请求/newActivity/doJoin接口,响应结果:"+response.asString());
.post(activityHost+"/hdtool/doJoin");
logger.info("请求/hdtool/doJoin接口,响应结果:"+response.asString());
return response;
}
......@@ -84,8 +84,8 @@ public class ActivityCtrlService {
params.put("answerData",answerData);
params.put("token",token);
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.dafuwengLogin(uid)).params(params)
.post(activityHost+"/newActivity/submit");
logger.info("请求/newActivity/submit接口,响应结果:"+response.asString());
.post(activityHost+"/hdtool/submit");
logger.info("请求/hdtool/submit接口,响应结果:"+response.asString());
return response;
}
......@@ -96,14 +96,14 @@ public class ActivityCtrlService {
*/
public Response getOrderStatus(long orderId) throws Exception{
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.dafuwengLogin(uid)).param("orderId",orderId)
.post(activityHost+"/newActivity/getOrderStatus");
logger.info("请求/newActivity/getOrderStatus接口,响应结果:"+response.asString());
.post(activityHost+"/hdtool/getOrderStatus");
logger.info("请求/hdtool/getOrderStatus接口,响应结果:"+response.asString());
try{
Assert.assertEquals(response.jsonPath().getString("success"),"true");
}catch(Exception e){
throw new Exception("/newActivity/getOrderStatus接口失败,返回信息:"+response.asString());
throw new Exception("/hdtool/getOrderStatus接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/newActivity/getOrderStatus接口失败,返回信息:"+response.asString());
throw new Exception("/hdtool/getOrderStatus接口失败,返回信息:"+response.asString());
}
return response;
......
......@@ -619,7 +619,7 @@ public class DeveloperService {
return response;
}
//删除活动
//删除自有签到活动
public Response delete(String signId) throws Exception {
Map<String,String> map = new HashMap<>();
......@@ -1110,4 +1110,123 @@ public class DeveloperService {
return response;
}
//保存自有答题活动--所有字段
public Response saveQuestion(String title,String awards,String questionRecord,String creditsType,String freeLimit,String freeScope,String limitCount,String limitScope,String optionNum) throws Exception {
String url=hdHost+"/question/save";
Map<String,String> map = new HashMap<>();
map.put("subType","question");
map.put("title",title);
map.put("anticheatExchangeLimit","true");
map.put("awards",awards);
map.put("questionRecord",questionRecord);
map.put("credits","22");
map.put("creditsType",creditsType);
map.put("banner","//yun.duiba.com.cn/upload/S2T4p1474356849960.png");
map.put("thumbnail","//yun.duiba.com.cn/upload/ljoka1474356876322.png");
map.put("bannerImgNew","//yun.duiba.com.cn/upload/qzfsmsyo9s.png");
map.put("appId","2239");
map.put("freeLimit",freeLimit);
map.put("freeScope",freeScope);
map.put("limitCount",limitCount);
map.put("limitScope",limitScope);
map.put("optionNum",optionNum);
map.put("autoOffDate","2020-12-08 00:00");
map.put("id","");
logger.info("创建自有答题活动:"+url);
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLogin()).params(map).post("http://"+url);
response.prettyPrint();
try{
Assert.assertEquals(response.jsonPath().getString("desc"),"成功");
}catch(Exception e){
throw new Exception("创建自有答题活动接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("创建自有答题活动接口失败,返回信息:"+response.asString());
}
return response;
}
//编辑自有答题活动
public Response editQuestion(String actId) throws Exception {
String url=hdHost+"/question/editData";
Map<String,String> map = new HashMap<>();
map.put("appId","2239");
map.put("actId",actId);
map.put("type","question");
logger.info("请求编辑自有答题活动url:"+url);
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLogin()).params(map).post("http://"+url);
response.prettyPrint();
try{
Assert.assertEquals(response.jsonPath().getString("desc"),"成功");
}catch(Exception e){
throw new Exception("编辑自有答题活动接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("编辑自有答题活动接口失败,返回信息:"+response.asString());
}
return response;
}
//创建自有弹层签到--所有字段
public Response saveSign(String title,String signType,String prizes,String signCredits) throws Exception {
String url=hdHost+"/signConfig/signSave";
Map<String,String> map = new HashMap<>();
map.put("title",title);
map.put("rateDescription","测试概率shuom");
map.put("ruleDescription","测试活动规则");
map.put("signType",signType);
map.put("prizes",prizes);
map.put("imageUrl","//yun.duiba.com.cn/developer_new/images/activities/sign.jpg");
map.put("triggerType","chome");
map.put("deletedPrizeIds","");
map.put("signCredits",signCredits);
map.put("status","0");
map.put("anticheatExchangeLimit","true");
map.put("appId","2239");
map.put("id","");
logger.info("创建自有签到活动:"+url);
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLogin()).params(map).post("http://"+url);
response.prettyPrint();
try{
Assert.assertEquals(response.jsonPath().getString("desc"),"成功");
}catch(Exception e){
throw new Exception("创建自有签到活动接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("创建自有签到活动接口失败,返回信息:"+response.asString());
}
return response;
}
//编辑自有弹层签到
public Response editSign(String id) throws Exception {
String url=hdHost+"/signConfig/signEdit";
Map<String,String> map = new HashMap<>();
map.put("id",id);
map.put("appId","2239");
logger.info("编辑自有签到活动:"+url);
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLogin()).params(map).post("http://"+url);
response.prettyPrint();
try{
Assert.assertEquals(response.jsonPath().getString("success"),"true");
}catch(Exception e){
throw new Exception("编辑自有签到活动接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("编辑自有签到活动接口失败,返回信息:"+response.asString());
}
return response;
}
}
package http.service.hd;
import http.service.Authorization;
import base.DuibaLog;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.testng.Assert;
import java.util.HashMap;
import java.util.Map;
import static io.restassured.RestAssured.given;
/**
* Created by lvwenyan on 2018/12/06.
*/
@Service
public class LaunchService {
@Value("${hdserver.host}")
String hdHost;
@Autowired
Authorization authorization;
private DuibaLog logger = DuibaLog.getLogger();
//获取活动默认数据
public Response getDataConfigUrl(String type) throws Exception{
String url = hdHost + "/launch/getDataConfigUrl";
Map<String,String> map = new HashMap<>();
map.put("appId","2239");
map.put("type",type);
logger.info("请求数据配置接口:" + url);
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLogin()).params(map).post("http://"+url);
response.prettyPrint();
try{
Assert.assertEquals(response.jsonPath().getString("desc"),"成功");
}catch(Exception e){
throw new Exception("请求数据配置接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("请求数据配置接口失败,返回信息:"+response.asString());
}
return response;
}
//获取活动默认奖品
public Response obtain() throws Exception{
String url = hdHost + "/launch/obtain";
Map<String,String> map = new HashMap<>();
map.put("appId","2239");
logger.info("请求获取奖品接口:" + url);
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLogin()).params(map).post("http://"+url);
response.prettyPrint();
try{
Assert.assertEquals(response.jsonPath().getString("desc"),"成功");
}catch(Exception e){
throw new Exception("请求获取奖品接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("请求获取奖品接口失败,返回信息:"+response.asString());
}
return response;
}
}
......@@ -82,4 +82,24 @@ public class SigninService {
}
return response;
}
//活动预览
public Response preview(String appId,String type,String sourceId,String activityId,String email) throws Exception{
Map<String,String> map = new HashMap<>();
map.put("appId",appId);
map.put("type",type);
map.put("sourceId",sourceId);
map.put("activityId",activityId);
Response response = given().cookies(authorization.hdLoginCommon(email)).params(map).post("http://"+hdHost+"/activity/preview");
response.prettyPrint();
try{
Assert.assertEquals(response.jsonPath().getString("success"),"true");
}catch(Exception e){
throw new Exception("/activity/preview接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/activity/preview接口失败,返回信息:"+response.asString());
}
return response;
}
}
......@@ -32,46 +32,46 @@ db.maxtotal = 6
pluginTest.project=插件
pluginTest.names=zhaoran,qianwenjun
pluginTest.group=插件-接口自动化
pluginTest.resultUrl=http://tst.deploy.dui88.com/view/duibaTest/job/duibaPlugin_interface/HTML_Report/suite1_test1_results.html
pluginTest.resultUrl=http://tst-idc.deploy.dui88.com/view/duibaTest/job/duibaPlugin_interface/HTML_20Report/suite1_test1_results.html
pluginTest.job=duibaPlugin_interface
signTest.project=签到
signTest.names=zhousongbo
signTest.group=签到-接口自动化
signTest.resultUrl=http://tst.deploy.dui88.com/view/duibaTest/job/duibaSign_interface/HTML_Report/suite1_test1_results.html
signTest.resultUrl=http://tst-idc.deploy.dui88.com/view/duibaTest/job/duibaSign_interface/HTML_20Report/suite1_test1_results.html
signTest.job=duibaSign_interface
FloorTest.project=楼层
FloorTest.names=zhaoran,qianwenjun
FloorTest.group=楼层-接口自动化
FloorTest.resultUrl=http://tst.deploy.dui88.com/view/duibaTest/job/duibaFloor_interface/HTML_Report/suite1_test1_results.html
FloorTest.resultUrl=http://tst-idc.deploy.dui88.com/view/duibaTest/job/duibaFloor_interface/HTML_20Report/suite1_test1_results.html
FloorTest.job=duibaFloor_interface
DuibaTest.project=活动工具
DuibaTest.names=zhaoran,qianwenjun
DuibaTest.group=活动工具-接口自动化
DuibaTest.resultUrl=http://tst.deploy.dui88.com/view/duibaTest/job/duiba_interface/HTML_Report/suite1_test1_results.html
DuibaTest.resultUrl=http://tst-idc.deploy.dui88.com/view/duibaTest/job/duiba_interface/HTML_20Report/suite1_test1_results.html
DuibaTest.job=duiba_interface
AccessTest.project=综合业务(单品抽奖/秒杀/游戏)
AccessTest.names=zhaoran,qianwenjun
AccessTest.group=综合业务-接口自动化
AccessTest.resultUrl=http://tst.deploy.dui88.com/view/duibaTest/job/duibaAccess_interface/HTML_Report/suite1_test1_results.html
AccessTest.resultUrl=http://tst-idc.deploy.dui88.com/view/duibaTest/job/duibaAccess_interface/HTML_20Report/suite1_test1_results.html
AccessTest.job=duibaAccess_interface
JenkinsTest.project=综合业务(单品抽奖/秒杀/游戏)
JenkinsTest.names=zhaoran,qianwenjun
JenkinsTest.group=综合业务-接口自动化
JenkinsTest.resultUrl=http://tst.deploy.dui88.com/view/duibaTest/job/duibaAccess_interface/HTML_Report/suite1_test1_results.html
JenkinsTest.resultUrl=http://tst-idc.deploy.dui88.com/view/duibaTest/job/duibaAccess_interface/HTML_20Report/suite1_test1_results.html
ExchangeTest.project=普兑业务
ExchangeTest.names=panyuli
ExchangeTest.group=普兑业务-接口自动化
ExchangeTest.resultUrl=http://tst.deploy.dui88.com/view/duibaTest/job/duibaExchange_interface/HTML_Report/suite1_test1_results.html
ExchangeTest.resultUrl=http://tst-idc.deploy.dui88.com/view/duibaTest/job/duibaExchange_interface/HTML_20Report/suite1_test1_results.html
ExchangeTest.job=duibaExchange_interface
SeckillTest.project=秒杀业务
SeckillTest.names=qianwenjun
SeckillTest.group=秒杀业务-接口自动化
SeckillTest.resultUrl=http://tst.deploy.dui88.com/view/duibaTest/job/Seckill_interface/HTML_Report/suite1_test1_results.html
SeckillTest.resultUrl=http://tst-idc.deploy.dui88.com/view/duibaTest/job/Seckill_interface/HTML_20Report/suite1_test1_results.html
SeckillTest.job=Seckill_interface
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