Commit 174f3d3a authored by 吕雯燕's avatar 吕雯燕

Merge branch 'develop' of gitlab2.dui88.com:mabo/test-platform into develop

parents a0235647 6a07135d
......@@ -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());
}
}
......@@ -25,6 +25,7 @@ public class Postman {
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);
......@@ -67,6 +68,15 @@ public class Postman {
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();
......
......@@ -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(),"开发者配置和手机端展示数量不符");
......
......@@ -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);
......
/**
* Copyright (C), 2015-2018
* FileName: pk_开奖_瓜分红包_押注人数不同测试_AccessTest
* Author: qianwenjun
* Date: 2018/8/9 20:13
* Description:
*/
package http.cases.PkTest;
import base.DuibaLog;
import base.DuibaTestBase;
import com.alibaba.fastjson.JSONObject;
import http.model.BetMngVo;
import http.service.Activity.PkService;
import http.service.Manager.PkActivityService;
import http.service.Manager.PluginService;
import io.restassured.response.Response;
import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* 〈〉
*
* @author qianwenjun
* @create 2018/8/9
* @since 1.0.0
*/
public class pk_开奖_瓜分优惠券_AccessTest extends DuibaTestBase {
@Autowired
PkService pkService;
@Autowired
PkActivityService pkActivityService;
@Autowired
PluginService pluginService;
private static DuibaLog logger = DuibaLog.getLogger();
private String groupId = "7";
private Integer user01 = 4907;//appid=18816
private String consumerId01 = "100109082";//activity_order_con.tb_trade_center_activity_order_0794
private Integer user02 = 4908;//appid=18816
private String consumerId02 = "100109083";//activity_order_con.tb_trade_center_activity_order_0795
private Integer user03 = 4909;//appid=2239
private String consumerId03 = "100109084";//activity_order_con.tb_trade_center_activity_order_0796
List<String> wins = new ArrayList<>();
List<String> loses = new ArrayList<>();
private String newBetId = "";
private List<String> optionsIds = new ArrayList<>();
private String pluginId = "";
@BeforeMethod
//注意初始化的方法不能与父类的相同,会被覆盖住
public void setUpPkActivity() {
try {
createPk("3","2020-08-12 00:00:00",groupId);
Response cretePlugin = pkActivityService.pluginSave(newBetId);
cretePlugin.prettyPrint();
//先定向再开启
Map<String, Object> mapId = jdbc.findSimpleResult("SELECT * FROM credits_activity.tb_activity_plugin ORDER BY gmt_create DESC LIMIT 1");
pluginId = String.valueOf(mapId.get("id"));
logger.info("pk瓜分优惠券开奖的id为"+pluginId);
pluginService.changeStatus(pluginId, "1");
Boolean res = jdbc.update("update act_com_conf.tb_bet_config set plugin_id = ? where id = ?",pluginId,newBetId);
}catch (Exception e){
e.printStackTrace();
}
}
@Test
public void 调试() throws Exception{
// Response cretePlugin = pkActivityService.pluginSave("1123");
// cretePlugin.prettyPrint();
}
@Test
public void 瓜分红包_两个选项_押注人数不同_开奖测试() throws Exception{
List<Map<String,Object>> pks = jdbc.findModeResult("select * from act_com_conf.tb_bet_option where bet_id = ?",newBetId);
logger.info("pk活动信息为"+JSONObject.toJSONString(pks));
for (int i=0;i<pks.size();i++){
optionsIds.add(pks.get(i).get("id").toString());
}
logger.info("pk活动id为:"+newBetId+",选项id为:"+ optionsIds.toString());
//押注第一个选项:user01,user02
//押注第二个选项:user03,user04
Response res1 = pkService.doJoin(user01,newBetId,optionsIds.get(0));
Response res2 = pkService.doJoin(user02,newBetId,optionsIds.get(1));
Response res3 = pkService.doJoin(user03,newBetId,optionsIds.get(0));
wins.add(consumerId01);
wins.add(consumerId03);
loses.add(consumerId02);
//修改开奖时间
this.modifyOpenPrizeTime(newBetId,60);
// 调用开奖接口
Response doDrowRresponse = pkActivityService.doDraw();
Assert.assertEquals(doDrowRresponse.jsonPath().getString("success"),"true","开奖结果校验失败");
Assert.assertEquals(doDrowRresponse.jsonPath().getString("data"),"开奖中。。。","开奖messag校验失败");
Thread.sleep(8000);
//校验点
//1、pk活动表配置的状态更新为4;2、订单表的addCredits字段为瓜分的红包值;3、先押注 的选项为胜方,胜负的额押注人数>负方的押注人数,4、校验account表的红包值加上去
checkPKConfig();
checkPKResult("18816");
checkUserOrder(wins,loses);
checkRecord(wins,loses);
}
public void createPk(String bounsType,String endTime,String groupId) throws Exception {
Response betResponse = pkActivityService.betForSetUp(bounsType,endTime);
logger.info("新建pk活动的结果信息为"+JSONObject.toJSONString(betResponse.prettyPrint()));
betResponse.prettyPrint();
String betId = betResponse.jsonPath().getString("data");newBetId = betId;
logger.info("newBetId的信息为"+newBetId);
Response betRelation = pkActivityService.betGroupRelation(betId,endTime,groupId);
Response modifyStatusResponse = pkActivityService.modifySatus(betId);
}
public void modifyOpenPrizeTime(String betId,int x) throws Exception{
DateTime time1 = new DateTime();
DateTime endTime = time1.minusMillis(x);
DateTimeFormatter format = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss");
String endTimeStr = "2018-11-26 20:24:39";
logger.info("\ntime1="+ format.print(time1.getMillis())+"\n设置的开奖时间endTime="+ endTimeStr);
Boolean result1 = jdbc.update("update act_com_conf.tb_bet_config set end_time = ? where id = ?\n",endTimeStr,betId);
Boolean result2 = jdbc.update("update act_com_conf.tb_bet_group_relation set end_time = ? where bet_id = ?\n",endTimeStr,betId);
}
public void checkPKConfig() throws Exception{
Map<String,Object> betConfig = jdbc.findSimpleResult("select * from act_com_conf.tb_bet_config where id = ?",newBetId);
logger.info("betConfig的信息为:"+ JSONObject.toJSONString(betConfig));
Assert.assertEquals(betConfig.get("config_status").toString(),"4","配置表状态更新失败");
Map<String,Object> betGroupRelation = jdbc.findSimpleResult("select * from act_com_conf.tb_bet_group_relation where bet_id = ?\n",newBetId);
Assert.assertEquals(betGroupRelation.get("config_status").toString(),"4","pk关系表开奖状态更新失败");
logger.info("pk活动配置表状态更新为:"+betConfig.get("config_status").toString()+",pk关系表活动状态更新为:"+betGroupRelation.get("config_status").toString());
Response betList = pkActivityService.getMngBetList();
// betList.prettyPrint();
List<BetMngVo> betMngVoList = betList.jsonPath().getList("data.page",BetMngVo.class);
for (BetMngVo bet:betMngVoList){
if (bet.getId().equals(newBetId)){
Assert.assertEquals(bet.getConfigStatus(),"4","开奖结果校验失败");
}
}
}
public void checkPKResult(String appId) throws Exception{
Map<String,Object> bet1Result = jdbc.findSimpleResult("select * from bet_activity.tb_bet_result where bet_id = ? and option_id = ? and app_id = ?\n",newBetId,optionsIds.get(0),appId);
Assert.assertEquals(bet1Result.get("rank").toString(),"1","开始押注的选项获胜校验失败");
Map<String,Object> bet2Result = jdbc.findSimpleResult("select * from bet_activity.tb_bet_result where bet_id = ? and option_id = ? and app_id = ?\n",newBetId,optionsIds.get(1),appId);
Assert.assertEquals(bet2Result.get("rank").toString(),"2","开始押注的选项获胜校验失败");
Long bet1Times = Long.valueOf(bet1Result.get("bet_times").toString());
Long bet2Times = Long.valueOf(bet2Result.get("bet_times").toString());
Assert.assertTrue(bet1Times>bet2Times,"活动获胜人数比失败人数多校验失败");
logger.info("选项1的押注人数为:"+bet1Result.get("bet_times").toString()+",选项2的押注人数为:"+bet2Result.get("bet_times").toString());
}
public void checkUserOrder(List<String> wins,List<String> loses) throws Exception{
for (int i=0;i<wins.size();i++){
String dbName = "activity_order_con.tb_trade_center_activity_order_"+ String.format("%04d", Long.parseLong(wins.get(i)) % 1024);
logger.info("用户的分表名dbName为"+dbName);
Map<String,Object> user_order = jdbc.findSimpleResult("select * from "+dbName+" where consumer_id = ? and duiba_activity_id = ?\n",wins.get(i),newBetId);
Long account = Long.valueOf(user_order.get("exchange_status").toString());
Assert.assertEquals(account.toString(),"1","开奖后订单更新");
logger.info("用户"+wins.get(i)+"订单状态为待领奖:"+user_order.get("exchange_status").toString());
}
for (int i=0;i<loses.size();i++){
String dbName = "activity_order_con.tb_trade_center_activity_order_"+ String.format("%04d", Long.parseLong(loses.get(i)) % 1024);
logger.info("用户的分表名dbName为"+dbName);
Map<String,Object> user_order = jdbc.findSimpleResult("select * from "+dbName+" where consumer_id = ? and duiba_activity_id = ?\n",loses.get(i),newBetId);
String account = user_order.get("exchange_status").toString();
Assert.assertEquals(account.toString(),"-1","开奖后订单更新");
logger.info("用户"+loses.get(i)+"订单状态为:"+user_order.get("add_credits").toString());
}
}
public void checkRecord(List<String> wins,List<String> loses) throws Exception{
for (int i=0;i<wins.size();i++){
Map<String,Object> useRecord = jdbc.findSimpleResult("select * from act_record.tb_bet_record where bet_id = ? and consumer_id = ? \n",newBetId,wins.get(i));
Assert.assertEquals(useRecord.get("bonus").toString(), "0", "record表的红包值校验失败");
Assert.assertEquals(useRecord.get("exchange_status").toString(), "1", "record表的发奖状态校验失败");
logger.info("用户"+wins.get(i)+"订单获取的红包值为:"+useRecord.get("bonus").toString()+"领奖状态为待领奖"+useRecord.get("exchange_status").toString());
}
for (int i=0;i<loses.size();i++){
Map<String,Object> useRecord = jdbc.findSimpleResult("select * from act_record.tb_bet_record where bet_id = ? and consumer_id = ? \n",newBetId,loses.get(i));
Assert.assertEquals(useRecord.get("bonus").toString(), "0", "record表的红包值校验失败");
Assert.assertEquals(useRecord.get("exchange_status").toString(), "0", "record表的发奖状态校验失败");
logger.info("用户"+loses.get(i)+"订单获取的红包值为:"+useRecord.get("bonus").toString()+"领奖状态为待领奖"+useRecord.get("exchange_status").toString());
}
}
// @AfterClass
public void tearDown() {
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 result7 = jdbc.update("delete from credits_activity.tb_activity_center_option where activity_id in (select id from credits_activity.tb_activity_plugin where title like '【自动化】pk开奖%')\n");
Boolean result6 = jdbc.update("delete from credits_activity.tb_activity_plugin where title like '【自动化】pk开奖%'\n");
} catch (SQLException e) {
e.printStackTrace();
} catch (Exception e){
e.printStackTrace();
}
}
}
\ No newline at end of file
/**
* Copyright (C), 2015-2018
* FileName: pk_开奖_瓜分红包_押注人数不同测试_AccessTest
* Author: qianwenjun
* Date: 2018/8/9 20:13
* Description:
*/
package http.cases.PkTest;
import base.DuibaLog;
import base.DuibaTestBase;
import com.alibaba.fastjson.JSONObject;
import http.model.BetMngVo;
import http.service.Activity.PkService;
import http.service.Manager.PkActivityService;
import io.restassured.response.Response;
import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* 〈〉
*
* @author qianwenjun
* @create 2018/8/9
* @since 1.0.0
*/
public class pk_开奖_瓜分红包_投放两个app_AccessTest extends DuibaTestBase {
@Autowired
PkService pkService;
@Autowired
PkActivityService pkActivityService;
private static DuibaLog logger = DuibaLog.getLogger();
private String groupId = "6,7";
private Integer user01 = 4812;//appid=18816
private String consumerId01 = "100108112";//activity_order_con.tb_trade_center_activity_order_0848
private Integer user02 = 4813;//appid=18816
private String consumerId02 = "100108113";//activity_order_con.tb_trade_center_activity_order_0849
private Integer user03 = 4814;//appid=2239
private String consumerId03 = "100108114";//activity_order_con.tb_trade_center_activity_order_0850
private Integer user04 = 4815;//appid=2239
private String consumerId04 = "100108115";//activity_order_con.tb_trade_center_activity_order_0851
List<String> wins = new ArrayList<>();
List<String> loses = new ArrayList<>();
private String newBetId = "";
private List<String> optionsIds = new ArrayList<>();
@BeforeMethod
//注意初始化的方法不能与父类的相同,会被覆盖住
public void setUpPkActivity() {
try {
createPk("2","2020-08-12 00:00:00",groupId);
}catch (Exception e){
e.printStackTrace();
}
}
@Test
public void 瓜分红包_两个选项_押注人数不同_开奖测试() throws Exception{
List<Map<String,Object>> pks = jdbc.findModeResult("select * from act_com_conf.tb_bet_option where bet_id = ?",newBetId);
logger.info("pk活动信息为"+JSONObject.toJSONString(pks));
for (int i=0;i<pks.size();i++){
optionsIds.add(pks.get(i).get("id").toString());
}
logger.info("pk活动id为:"+newBetId+",选项id为:"+ optionsIds.toString());
Map<String,Object> user01_account1 = jdbc.findSimpleResult("select * from consumer_accounts.tb_consumer_account_0848 where consumer_id = '100108112' and account_type = '6'\n");
Long use1_Acc1 = Long.valueOf(user01_account1.get("balance_amount").toString());
Map<String,Object> user02_account1 = jdbc.findSimpleResult("select * from consumer_accounts.tb_consumer_account_0849 where consumer_id = '100108113' and account_type = '6'\n");
Long use2_Acc1 = Long.valueOf(user02_account1.get("balance_amount").toString());
Map<String,Object> user03_account1 = jdbc.findSimpleResult("select * from consumer_accounts.tb_consumer_account_0850 where consumer_id = '100108114' and account_type = '6'\n");
Long use3_Acc1 = Long.valueOf(user03_account1.get("balance_amount").toString());
Map<String,Object> user04_account1 = jdbc.findSimpleResult("select * from consumer_accounts.tb_consumer_account_0851 where consumer_id = '100108115' and account_type = '6'\n");
Long use4_Acc1 = Long.valueOf(user04_account1.get("balance_amount").toString());
//押注第一个选项:user01,user02
//押注第二个选项:user03,user04
Response res1 = pkService.doJoin(user01,newBetId,optionsIds.get(0));
Response res2 = pkService.doJoin(user02,newBetId,optionsIds.get(1));
Response res3 = pkService.doJoin(user03,newBetId,optionsIds.get(0));
Response res4 = pkService.doJoin(user04,newBetId,optionsIds.get(1));
wins.add(consumerId01);
wins.add(consumerId03);
loses.add(consumerId02);
loses.add(consumerId04);
//修改开奖时间
this.modifyOpenPrizeTime(newBetId,60);
//调用开奖接口
Response doDrowRresponse = pkActivityService.doDraw();
Assert.assertEquals(doDrowRresponse.jsonPath().getString("success"),"true","开奖结果校验失败");
Assert.assertEquals(doDrowRresponse.jsonPath().getString("data"),"开奖中。。。","开奖messag校验失败");
Thread.sleep(8000);
//校验点
//1、pk活动表配置的状态更新为4;2、订单表的addCredits字段为瓜分的红包值;3、先押注 的选项为胜方,胜负的额押注人数>负方的押注人数,4、校验account表的红包值加上去
checkPKConfig();
checkPKResult("18816");
checkPKResult("2239");
checkUserOrder(wins,loses);
checkRecord(wins,loses);
Map<String,Object> user01_account2 = jdbc.findSimpleResult("select * from consumer_accounts.tb_consumer_account_0848 where consumer_id = '100108112' and account_type = '6'\n");
Long use1_Acc2 = Long.valueOf(user01_account2.get("balance_amount").toString());
Assert.assertEquals(use1_Acc2.toString(),String.valueOf(use1_Acc1+10),"用户1入账校验失败");
Map<String,Object> user02_account2 = jdbc.findSimpleResult("select * from consumer_accounts.tb_consumer_account_0849 where consumer_id = '100108113' and account_type = '6'\n");
Long use2_Acc2 = Long.valueOf(user02_account2.get("balance_amount").toString());
Assert.assertEquals(use2_Acc2,use2_Acc1,"用户2入账校验失败");
Map<String,Object> user03_account2 = jdbc.findSimpleResult("select * from consumer_accounts.tb_consumer_account_0850 where consumer_id = '100108114' and account_type = '6'\n");
Long use3_Acc2 = Long.valueOf(user03_account2.get("balance_amount").toString());
Assert.assertEquals(use3_Acc2.toString(),String.valueOf(use3_Acc1+10),"用户3入账校验失败");
Map<String,Object> user04_account2 = jdbc.findSimpleResult("select * from consumer_accounts.tb_consumer_account_0851 where consumer_id = '100108115' and account_type = '6'\n");
Long use4_Acc2 = Long.valueOf(user04_account2.get("balance_amount").toString());
Assert.assertEquals(use4_Acc2,use4_Acc1,"用户4入账校验失败");
}
public void createPk(String bounsType,String endTime,String groupId) throws Exception {
Response betResponse = pkActivityService.betForSetUp(bounsType,endTime);
logger.info("新建pk活动的结果信息为"+JSONObject.toJSONString(betResponse.prettyPrint()));
betResponse.prettyPrint();
String betId = betResponse.jsonPath().getString("data");newBetId = betId;
logger.info("newBetId的信息为"+newBetId);
Response betRelation = pkActivityService.betGroupRelation(betId,endTime,groupId);
Response modifyStatusResponse = pkActivityService.modifySatus(betId);
}
public void modifyOpenPrizeTime(String betId,int x) throws Exception{
DateTime time1 = new DateTime();
// int x=20+(int)(Math.random()*100);
DateTime endTime = time1.minusMillis(x);
DateTimeFormatter format = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss");
// String endTimeStr = format.print(endTime.getMillis()).toString();
String endTimeStr = "2018-11-26 20:24:39";
logger.info("\ntime1="+ format.print(time1.getMillis())+"\n设置的开奖时间endTime="+ endTimeStr);
Boolean result1 = jdbc.update("update act_com_conf.tb_bet_config set end_time = ? where id = ?\n",endTimeStr,betId);
Boolean result2 = jdbc.update("update act_com_conf.tb_bet_group_relation set end_time = ? where bet_id = ?\n",endTimeStr,betId);
}
public void checkPKConfig() throws Exception{
Map<String,Object> betConfig = jdbc.findSimpleResult("select * from act_com_conf.tb_bet_config where id = ?",newBetId);
logger.info("betConfig的信息为:"+ JSONObject.toJSONString(betConfig));
Assert.assertEquals(betConfig.get("config_status").toString(),"4","配置表状态更新失败");
Map<String,Object> betGroupRelation = jdbc.findSimpleResult("select * from act_com_conf.tb_bet_group_relation where bet_id = ?\n",newBetId);
Assert.assertEquals(betGroupRelation.get("config_status").toString(),"4","pk关系表开奖状态更新失败");
logger.info("pk活动配置表状态更新为:"+betConfig.get("config_status").toString()+",pk关系表活动状态更新为:"+betGroupRelation.get("config_status").toString());
Response betList = pkActivityService.getMngBetList();
betList.prettyPrint();
List<BetMngVo> betMngVoList = betList.jsonPath().getList("data.page",BetMngVo.class);
for (BetMngVo bet:betMngVoList){
if (bet.getId().equals(newBetId)){
Assert.assertEquals(bet.getConfigStatus(),"4","开奖结果校验失败");
}
}
}
public void checkPKResult(String appId) throws Exception{
Map<String,Object> bet1Result = jdbc.findSimpleResult("select * from bet_activity.tb_bet_result where bet_id = ? and option_id = ? and app_id = ?\n",newBetId,optionsIds.get(0),appId);
Assert.assertEquals(bet1Result.get("rank").toString(),"1","开始押注的选项获胜校验失败");
Map<String,Object> bet2Result = jdbc.findSimpleResult("select * from bet_activity.tb_bet_result where bet_id = ? and option_id = ? and app_id = ?\n",newBetId,optionsIds.get(1),appId);
Assert.assertEquals(bet2Result.get("rank").toString(),"2","开始押注的选项获胜校验失败");
Long bet1Times = Long.valueOf(bet1Result.get("bet_times").toString());
Long bet2Times = Long.valueOf(bet2Result.get("bet_times").toString());
Assert.assertTrue(bet1Times>bet2Times,"活动获胜人数比失败人数多校验失败");
logger.info("选项1的押注人数为:"+bet1Result.get("bet_times").toString()+",选项2的押注人数为:"+bet2Result.get("bet_times").toString());
}
public void checkUserOrder(List<String> wins,List<String> loses) throws Exception{
for (int i=0;i<wins.size();i++){
String dbName = "activity_order_con.tb_trade_center_activity_order_"+ String.format("%04d", Long.parseLong(wins.get(i)) % 1024);
logger.info("用户的分表名dbName为"+dbName);
Map<String,Object> user_order = jdbc.findSimpleResult("select * from "+dbName+" where consumer_id = ? and duiba_activity_id = ?\n",wins.get(i),newBetId);
Long account = Long.valueOf(user_order.get("add_credits").toString());
Assert.assertEquals(account.toString(),"10","开奖后订单更新");
logger.info("用户"+wins.get(i)+"订单获取的红包值为:"+user_order.get("add_credits").toString());
}
for (int i=0;i<loses.size();i++){
String dbName = "activity_order_con.tb_trade_center_activity_order_"+ String.format("%04d", Long.parseLong(loses.get(i)) % 1024);
logger.info("用户的分表名dbName为"+dbName);
Map<String,Object> user_order = jdbc.findSimpleResult("select * from "+dbName+" where consumer_id = ? and duiba_activity_id = ?\n",loses.get(i),newBetId);
String account = user_order.get("add_credits").toString();
Assert.assertEquals(account.toString(),"","开奖后订单更新");
logger.info("用户"+loses.get(i)+"订单获取的红包值为:"+user_order.get("add_credits").toString());
}
}
public void checkRecord(List<String> wins,List<String> loses) throws Exception{
for (int i=0;i<wins.size();i++){
Map<String,Object> useRecord = jdbc.findSimpleResult("select * from act_record.tb_bet_record where bet_id = ? and consumer_id = ? \n",newBetId,wins.get(i));
Assert.assertEquals(useRecord.get("bonus").toString(), "10", "record表的红包值校验失败");
Assert.assertEquals(useRecord.get("exchange_status").toString(), "2", "record表的发奖状态校验失败");
logger.info("用户"+wins.get(i)+"订单获取的红包值为:"+useRecord.get("bonus").toString());
}
for (int i=0;i<loses.size();i++){
Map<String,Object> useRecord = jdbc.findSimpleResult("select * from act_record.tb_bet_record where bet_id = ? and consumer_id = ? \n",newBetId,loses.get(i));
Assert.assertEquals(useRecord.get("bonus").toString(), "0", "record表的红包值校验失败");
Assert.assertEquals(useRecord.get("exchange_status").toString(), "0", "record表的发奖状态校验失败");
logger.info("用户"+loses.get(i)+"订单获取的红包值为:"+useRecord.get("bonus").toString());
}
}
@AfterClass
public void tearDown() {
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 '【自动化】瓜分红包%'");
} catch (SQLException e) {
e.printStackTrace();
} catch (Exception e){
e.printStackTrace();
}
}
}
\ No newline at end of file
......@@ -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();
......
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.Activity.SingleLotteryService;
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.MatcherString;
import utils.RedisUtil;
import java.lang.reflect.Method;
import java.text.SimpleDateFormat;
import java.util.*;
import static io.restassured.RestAssured.given;
/**
* Created by zhaoran on 2018/6/8.
*/
public class 自有单抽限制_AccessTest extends DuibaTestBase {
@Autowired
SingleLotteryService singleLotteryService;
@Autowired
Authorization authorization;
@Value("${activity.host}")
String activityHost;
@Value("${manager.host}")
private static DuibaLog logger = DuibaLog.getLogger();
//指定用户
private static int uid = 4881;
private static int uid2 = 4882;
private static int uid3 = 4883;
private static int uid4 = 4884;
private static int uid5 = 4885;
private static int uid6 = 4886;
@BeforeClass
public void before() {
try {
//清除每日用户抽奖限制记录
RedisUtil.clearKey("AC_K001_36686_"+getTime(0));
//清除永久用户抽奖限制记录
jdbc.update("delete from ckvtable.tb_kvtable_0804 where vkey = 'activity-centerjoinNum_100109092_36708'");
//清除每日用户免费抽奖记录
RedisUtil.clearKey("AC_K002_36685_"+getTime(0));
//清除永久用户免费抽奖记录
jdbc.update("delete from ckvtable.tb_kvtable_0830 where vkey = 'activity-centerfreeNum_100109118_36731'");
//清除永久用户中奖一次记录
jdbc.update("delete from ckvtable.tb_kvtable_0831 where vkey = 'activity-centerwinOptionNum_100109119_36687_sigleLottery1'");
jdbc.update("delete from ckvtable.tb_kvtable_0831 where vkey = 'activity-centerwinOptionNum_100109119_36687_sigleLottery0'");
//清除每日用户中奖一次记录
jdbc.update("delete from credits_dev.single_lottery_order where consumer_id = '100109120' and prize_name = '自动化单抽实物'");
} catch (Exception e) {
e.printStackTrace();
}
}
@Test
public void 每日用户抽奖限制() throws Exception{
Map<String, String> map = new HashMap<>();
map.put("operationAcitvityId", "36686");
map.put("oaId", "36686");
map.put("token", "12321");
Response response = given().cookies(authorization.dafuwengLogin(uid2)).params(map).post(activityHost + "/singleLottery/doJoin");
response.print();
Assert.assertEquals(response.jsonPath().getString("success"), "true", "校验success失败");
Thread.sleep(1000);
response = given().cookies(authorization.dafuwengLogin(uid2)).params(map).post(activityHost + "/singleLottery/doJoin");
response.print();
Assert.assertEquals(response.jsonPath().getString("success"), "false", "校验success失败");
Assert.assertEquals(response.jsonPath().getString("lotteryButtonStatus"), "8", "校验状态失败");
Assert.assertEquals(response.jsonPath().getString("message"), "今日已抽完", "校验信息失败");
logger.info("校验success、lotteryButtonStatus、message正确");
}
@Test
public void 永久用户抽奖限制() throws Exception{
Map<String, String> map = new HashMap<>();
map.put("operationAcitvityId", "36708");
map.put("oaId", "36708");
map.put("token", "12321");
Response response = given().cookies(authorization.dafuwengLogin(uid2)).params(map).post(activityHost + "/singleLottery/doJoin");
response.print();
Assert.assertEquals(response.jsonPath().getString("success"), "true", "校验success失败");
Thread.sleep(1000);
response = given().cookies(authorization.dafuwengLogin(uid2)).params(map).post(activityHost + "/singleLottery/doJoin");
response.print();
Assert.assertEquals(response.jsonPath().getString("success"), "false", "校验success失败");
Assert.assertEquals(response.jsonPath().getString("lotteryButtonStatus"), "2", "校验状态失败");
Assert.assertEquals(response.jsonPath().getString("message"), "已抽完", "校验信息失败");
logger.info("校验success、lotteryButtonStatus、message正确");
}
@Test
public void 每日免费抽奖限制() throws Exception{
//查询数据库,当前积分(抽奖扣积分流程校验)
Map<String,Object> mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid3);
String credits = String.valueOf(mapuser.get("credits"));
logger.info("第一次抽奖前积分:"+credits);
Map<String, String> map = new HashMap<>();
map.put("operationAcitvityId", "36685");
map.put("oaId", "36685");
map.put("token", "12321");
Response response = given().cookies(authorization.dafuwengLogin(uid3)).params(map).post(activityHost + "/singleLottery/doJoin");
response.print();
Assert.assertEquals(response.jsonPath().getString("success"), "true", "校验success失败");
//查询数据库,当前积分(抽奖扣积分流程校验)
mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid3);
String credits2 = String.valueOf(mapuser.get("credits"));
logger.info("第一次抽奖后积分:"+credits2);
Assert.assertEquals(credits, credits2, "校验免费抽奖失败");
credits2 = String.valueOf(Integer.valueOf(credits2)-1);
Thread.sleep(1000);
response = given().cookies(authorization.dafuwengLogin(uid3)).params(map).post(activityHost + "/singleLottery/doJoin");
response.print();
Assert.assertEquals(response.jsonPath().getString("success"), "true", "校验success失败");
//查询数据库,当前积分(抽奖扣积分流程校验)
mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid3);
String credits3 = String.valueOf(mapuser.get("credits"));
logger.info("第二次抽奖后积分:"+credits3);
Assert.assertEquals(credits3, credits2, "校验扣积分抽奖失败");
logger.info("校验每日一次免费抽奖限制正确");
}
@Test
public void 永久免费抽奖限制() throws Exception{
//查询数据库,当前积分(抽奖扣积分流程校验)
Map<String,Object> mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid4);
String credits = String.valueOf(mapuser.get("credits"));
logger.info("第一次抽奖前积分:"+credits);
Map<String, String> map = new HashMap<>();
map.put("operationAcitvityId", "36731");
map.put("oaId", "36731");
map.put("token", "12321");
Response response = given().cookies(authorization.dafuwengLogin(uid4)).params(map).post(activityHost + "/singleLottery/doJoin");
response.print();
Assert.assertEquals(response.jsonPath().getString("success"), "true", "校验success失败");
//查询数据库,当前积分(抽奖扣积分流程校验)
mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid4);
String credits2 = String.valueOf(mapuser.get("credits"));
logger.info("第一次抽奖后积分:"+credits2);
Assert.assertEquals(credits, credits2, "校验免费抽奖失败");
credits2 = String.valueOf(Integer.valueOf(credits2)-1);
Thread.sleep(1000);
response = given().cookies(authorization.dafuwengLogin(uid4)).params(map).post(activityHost + "/singleLottery/doJoin");
response.print();
Assert.assertEquals(response.jsonPath().getString("success"), "true", "校验success失败");
//查询数据库,当前积分(抽奖扣积分流程校验)
mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid4);
String credits3 = String.valueOf(mapuser.get("credits"));
logger.info("第二次抽奖后积分:"+credits3);
Assert.assertEquals(credits3, credits2, "校验扣积分抽奖失败");
logger.info("校验永久一次免费抽奖限制正确");
}
@Test
public void 每日用户中奖限制() throws Exception{
Map<String, String> map = new HashMap<>();
map.put("operationAcitvityId", "36688");
map.put("oaId", "36688");
map.put("token", "12321");
Response response = given().cookies(authorization.dafuwengLogin(uid6)).params(map).post(activityHost + "/singleLottery/doJoin");
String id =MatcherString.getString(response.asString(), "singleLotteryOrderId\":(.*?),", 1);
response = singleLotteryService.getOrderStatus(uid6,id,"iOS");
int i = 10;
while ("处理中".equals(response.jsonPath().getString("message")) && i > 0) {
Thread.sleep(500);
response = singleLotteryService.getOrderStatus(uid6,id,"iOS");
i--;
}
Assert.assertEquals(response.jsonPath().getString("descrption"),"自动化单抽实物","校验优惠券标题失败");
Assert.assertEquals(response.jsonPath().getString("lotteryType"), "object", "校验奖品类型失败");
Assert.assertEquals(response.jsonPath().getString("lotteryButtonStatus"), "1", "校验状态失败");
Assert.assertEquals(response.jsonPath().getString("message"), "成功", "校验message失败");
Thread.sleep(1000);
response = given().cookies(authorization.dafuwengLogin(uid6)).params(map).post(activityHost + "/singleLottery/doJoin");
String id2 =MatcherString.getString(response.asString(), "singleLotteryOrderId\":(.*?),", 1);
response.print();
response = singleLotteryService.getOrderStatus(uid6,id2,"iOS");
int n = 10;
while ("处理中".equals(response.jsonPath().getString("message")) && n > 0) {
Thread.sleep(500);
response = singleLotteryService.getOrderStatus(uid6,id2,"iOS");
response.print();
n--;
}
Assert.assertEquals(response.jsonPath().getString("success"), "true", "校验success失败");
Assert.assertEquals(response.jsonPath().getString("lotteryButtonStatus"), "1", "校验状态失败");
Assert.assertNull(response.jsonPath().getString("descrption"), "校验奖项失败");
logger.info("校验每日用户中奖一次限制正确");
}
@Test
public void 永久用户中奖限制() throws Exception{
Map<String, String> map = new HashMap<>();
map.put("operationAcitvityId", "36687");
map.put("oaId", "36687");
map.put("token", "12321");
Response response = given().cookies(authorization.dafuwengLogin(uid5)).params(map).post(activityHost + "/singleLottery/doJoin");
String id =MatcherString.getString(response.asString(), "singleLotteryOrderId\":(.*?),", 1);
response = singleLotteryService.getOrderStatus(uid5,id,"iOS");
int i = 10;
while ("处理中".equals(response.jsonPath().getString("message")) && i > 0) {
Thread.sleep(500);
response = singleLotteryService.getOrderStatus(uid5,id,"iOS");
i--;
}
Assert.assertEquals(response.jsonPath().getString("descrption"),"自动化单抽实物","校验优惠券标题失败");
Assert.assertEquals(response.jsonPath().getString("lotteryType"), "object", "校验奖品类型失败");
Assert.assertEquals(response.jsonPath().getString("lotteryButtonStatus"), "1", "校验状态失败");
Assert.assertEquals(response.jsonPath().getString("message"), "成功", "校验message失败");
Thread.sleep(1000);
response = given().cookies(authorization.dafuwengLogin(uid5)).params(map).post(activityHost + "/singleLottery/doJoin");
String id2 =MatcherString.getString(response.asString(), "singleLotteryOrderId\":(.*?),", 1);
response.print();
response = singleLotteryService.getOrderStatus(uid5,id2,"iOS");
int n = 10;
while ("处理中".equals(response.jsonPath().getString("message")) && n > 0) {
Thread.sleep(500);
response = singleLotteryService.getOrderStatus(uid5,id2,"iOS");
response.print();
n--;
}
Assert.assertEquals(response.jsonPath().getString("success"), "true", "校验success失败");
Assert.assertEquals(response.jsonPath().getString("lotteryButtonStatus"), "1", "校验状态失败");
Assert.assertNull(response.jsonPath().getString("descrption"), "校验奖项失败");
logger.info("校验永久用户中奖一次限制正确");
}
@Test
public void 抽奖日期限制(){
Map<String, String> map = new HashMap<>();
map.put("operationAcitvityId", "36689");
map.put("oaId", "36689");
map.put("token", "12321");
Response response = given().cookies(authorization.dafuwengLogin(uid)).params(map).post(activityHost + "/singleLottery/doJoin");
//response.prettyPeek();
Assert.assertEquals(response.jsonPath().getString("success"), "false", "校验success失败");
Assert.assertEquals(response.jsonPath().getString("lotteryButtonStatus"), "4", "校验状态失败");
Assert.assertEquals(response.jsonPath().getString("message"), "已结束", "校验信息失败");
logger.info("校验success、lotteryButtonStatus、message正确");
}
public String getTime(int amount){
SimpleDateFormat dateFormat = new SimpleDateFormat("YYYY-MM-dd", Locale.ENGLISH);
Date date = new Date();
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.MONTH, amount);
date = calendar.getTime();
// System.out.println(dateFormat.format(date));
String time = dateFormat.format(date);
// System.out.println(time);
return time;
}
}
\ No newline at end of file
package http.cases.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 {
......
......@@ -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;
......@@ -247,22 +248,35 @@ 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();
Map<String, String> paras = new HashMap<>();
paras.put("email", "wxs@duiba.com.cn");
paras.put("password", SecurityUtils.getMD5("dbZcFiIc5yMHcee/o/PJEfyZjug="+from(token.asString()).getString("data.loginsToken")));
paras.put("redirect", "/redirectApp");
paras.put("isAutoLogin", "true");
Response response = given().cookies(cookies).params(paras).post(url);
Map<String,String> map = response.getCookies();
logger.info("cookies:"+map.toString());
hdCookies=new HashMap<>(response.getCookies());
if(hdCookies!=null||hdCookies.size()!=0) {
//取消安全校验
hdCookies.remove("csrf_token");
hdCookies.put("appId", appId);
hdCookies.put("duibaAppId", appId);
logger.info("cookies2:"+hdCookies.toString());
hdCookiesSaasByApp.put(appId,hdCookies);
}
Response token=this.hdGetToken();
String url = PROTOCOL + hdHost + hdLoginPath;
Map<String,String> cookies=token.getCookies();
Map<String, String> paras = new HashMap<>();
paras.put("email", "wxs@duiba.com.cn");
paras.put("password", SecurityUtils.getMD5("dbZcFiIc5yMHcee/o/PJEfyZjug="+from(token.asString()).getString("data.loginsToken")));
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());
//取消安全校验
hdCookiesSaasByApp.remove("csrf_token");
hdCookiesSaasByApp.put("appId",appId);
return hdCookiesSaasByApp;
i--;
}
logger.info("hdCookiesSaasByApp cookies集合:"+hdCookiesSaasByApp.toString());
return hdCookies;
}
//密码为duibaduiba123
public Map hdLoginCommon(String email){
......@@ -279,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);
}
......@@ -309,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 {
}
}
......@@ -27,156 +27,341 @@ public class DeveloperBJZ {
Authorization authorization;
private DuibaLog logger = DuibaLog.getLogger();
//优质好货--查询至尊版特权TAB
public Response item(String type) throws Exception{
String url="http://"+hdHost+"/saasitem/items";
public Response items(String type,String appId) throws Exception {
String url = "http://" + hdHost + "/saasitem/items";
Map<String,String> map = new HashMap<>();
map.put("type",type);
map.put("rowId","1");
map.put("itemName","");
map.put("max","20");
// logger.info("********"+url);
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas()).params(map).get(url);
// response.prettyPrint();
try{
Assert.assertEquals(response.jsonPath().getString("desc"),"成功");
}catch(Exception e){
throw new Exception("创建接口1失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("创建接口2失败,返回信息:"+response.asString());
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas(appId)).params(map).get(url);
response.prettyPrint();
try {
Assert.assertEquals(response.jsonPath().getString("desc"), "成功");
} catch (Exception e) {
throw new Exception("创建接口1失败,返回信息:" + response.asString());
} catch (Error er) {
throw new Exception("创建接口2失败,返回信息:" + response.asString());
}
return response;
}
//至尊特权添加商品
public Response ajaxAddRepo(String appId,String itemId) throws Exception{
String url="http://"+hdHost+"/devRepo/ajaxAddRepo";
//搜索具体的实物
public Response items2(String type, String appId) throws Exception {
String url = "http://" + hdHost + "/saasitem/items";
Map<String,String> map = new HashMap<>();
map.put("type",type);
map.put("rowId","1");
map.put("itemName","测试至尊享版-实物3");
map.put("max","20");
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas(appId)).params(map).get(url);
response.prettyPrint();
try {
Assert.assertEquals(response.jsonPath().getString("desc"), "成功");
} catch (Exception e) {
throw new Exception("创建接口1失败,返回信息:" + response.asString());
} catch (Error er) {
throw new Exception("创建接口2失败,返回信息:" + response.asString());
}
return response;
}
//搜索具体的实物,查出无结果
public Response items3(String type,String appId) throws Exception {
String url = "http://" + hdHost + "/saasitem/items";
Map<String,String> map = new HashMap<>();
map.put("type",type);
map.put("rowId","1");
map.put("itemName","测试至尊享版-实物31");
map.put("max","20");
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas(appId)).params(map).get(url);
try {
Assert.assertEquals(response.jsonPath().getString("desc"), "成功");
} catch (Exception e) {
throw new Exception("创建接口1失败,返回信息:" + response.asString());
} catch (Error er) {
throw new Exception("创建接口2失败,返回信息:" + response.asString());
}
return response;
}
//至尊特权添加商品
public Response ajaxAddRepo(String appId, String itemId) throws Exception {
String url = "http://" + hdHost + "/devRepo/ajaxAddRepo";
Map<String, String> map = new HashMap<>();
map.put("appId",appId);
map.put("itemId",itemId);
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas()).params(map).post(url);
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas(appId)).params(map).post(url);
// response.prettyPrint();
try{
Assert.assertEquals(response.jsonPath().getString("desc"),"成功");
}catch(Exception e){
throw new Exception("创建接口1失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("创建接口2失败,返回信息:"+response.asString());
try {
Assert.assertEquals(response.jsonPath().getString("desc"), "成功");
} catch (Exception e) {
throw new Exception("创建接口1失败,返回信息:" + response.asString());
} catch (Error er) {
throw new Exception("创建接口2失败,返回信息:" + response.asString());
}
return response;
}
//至尊特权上架商品
public Response ajaxDirectUp(String appId,String itemIds) throws Exception{
String url="http://"+hdHost+"/devRepo/ajaxDirectUp";
Map<String,String> map = new HashMap<>();
public Response ajaxDirectUp(String appId, String itemIds) throws Exception {
String url = "http://" + hdHost + "/devRepo/ajaxDirectUp";
Map<String, String> map = new HashMap<>();
map.put("appId",appId);
map.put("itemIds",itemIds);
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas()).params(map).post(url);
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas(appId)).params(map).post(url);
response.prettyPrint();
try{
Assert.assertEquals(response.jsonPath().getString("desc"),"直接上架成功");
}catch(Exception e){
throw new Exception("创建接口1失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("创建接口2失败,返回信息:"+response.asString());
try {
Assert.assertEquals(response.jsonPath().getString("desc"), "直接上架成功");
} catch (Exception e) {
throw new Exception("创建接口1失败,返回信息:" + response.asString());
} catch (Error er) {
throw new Exception("创建接口2失败,返回信息:" + response.asString());
}
return response;
}
//大牌好券--查询至尊版特权TAB
public Response coupons(String appId,String type) throws Exception{
String url="http://"+hdHost+"/saasitem/coupons";
//旗舰版app上架:至尊特权商品
public Response ajaxDirectUp2(String appId, String itemIds) throws Exception {
String url = "http://" + hdHost + "/devRepo/ajaxDirectUp";
Map<String,String> map = new HashMap<>();
map.put("appId",appId);
map.put("itemIds", itemIds);
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas(appId)).params(map).post(url);
response.prettyPrint();
try {
Assert.assertEquals(response.jsonPath().getString("desc"), "至尊版专享");
} catch (Exception e) {
throw new Exception("创建接口1失败,返回信息:" + response.asString());
} catch (Error er) {
throw new Exception("创建接口2失败,返回信息:" + response.asString());
}
return response;
}
//大牌好券--查询至尊版特权TAB
public Response coupons(String appId, String type) throws Exception {
String url = "http://" + hdHost + "/saasitem/coupons";
Map<String, String> map = new HashMap<>();
map.put("appId",appId);
map.put("type",type);
map.put("rowId","1");
map.put("subType","");
map.put("max","12");
// logger.info("********"+url);
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas()).params(map).get(url);
// response.prettyPrint();
try{
Assert.assertEquals(response.jsonPath().getString("desc"),"成功");
}catch(Exception e){
throw new Exception("创建接口1失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("创建接口2失败,返回信息:"+response.asString());
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas(appId)).params(map).get(url);response.prettyPrint();
try {
Assert.assertEquals(response.jsonPath().getString("desc"), "成功");
} catch (Exception e) {
throw new Exception("创建接口1失败,返回信息:" + response.asString());
} catch (Error er) {
throw new Exception("创建接口2失败,返回信息:" + response.asString());
}
return response;
}
//热门活动--查询活动
public Response saasActivitys(String categoryId) throws Exception{
String url="http://"+hdHost+"/saasitem/saasActivitys";
public Response saasActivitys(String categoryId, String appId) throws Exception {
String url = "http://" + hdHost + "/saasitem/saasActivitys";
Map<String,Object> map = new HashMap<>();
map.put("attrIds","");
map.put("rowId","1");
map.put("max","25");
map.put("categoryId",categoryId);
logger.info("********"+url);
logger.info("********" + url);
//json 格式转成form表单
JSONObject jsonParam = JSONObject.parseObject(JSON.toJSONString(map));
Response response=given().contentType("application/json;charset=UTF-8").cookies(authorization.hdLoginSaas("19515")).body(jsonParam).post(url);
// response.prettyPrint();
try{
Assert.assertEquals(response.jsonPath().getString("desc"),"成功");
}catch(Exception e){
throw new Exception("创建接口1失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("创建接口2失败,返回信息:"+response.asString());
Response response = given().contentType("application/json;charset=UTF-8").cookies(authorization.hdLoginSaas(appId)).body(jsonParam).post(url);
try {
Assert.assertEquals(response.jsonPath().getString("desc"), "成功");
} catch (Exception e) {
throw new Exception("创建接口1失败,返回信息:" + response.asString());
} catch (Error er) {
throw new Exception("创建接口2失败,返回信息:" + response.asString());
}
return response;
}
//选中活动
public Response itemOrderDetail(String goodItemId) throws Exception{
String url="http://"+hdHost+"/saasitem/itemOrderDetail";
Map<String,String> map = new HashMap<>();
map.put("goodItemId",goodItemId);
public Response itemOrderDetail(String goodItemId, String appId) throws Exception {
String url = "http://" + hdHost + "/saasitem/itemOrderDetail";
Map<String, String> map = new HashMap<>();
map.put("goodItemId", goodItemId);
// logger.info("********"+url);
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas()).params(map).get(url);
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas(appId)).params(map).get(url);
// response.prettyPrint();
try{
Assert.assertEquals(response.jsonPath().getString("desc"),"成功");
}catch(Exception e){
throw new Exception("创建接口1失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("创建接口2失败,返回信息:"+response.asString());
try {
Assert.assertEquals(response.jsonPath().getString("desc"), "成功");
} catch (Exception e) {
throw new Exception("创建接口1失败,返回信息:" + response.asString());
} catch (Error er) {
throw new Exception("创建接口2失败,返回信息:" + response.asString());
}
return response;
}
//订购活动--创建订单
public Response createAutomationOrderNew(String skuId) throws Exception{
String url="http://"+hdHost+"/saas/createAutomationOrderNew";
Map<String,String> map = new HashMap<>();
map.put("skuId",skuId);
public Response createAutomationOrderNew(String skuId, String appId) throws Exception {
String url = "http://" + hdHost + "/saas/createAutomationOrderNew";
Map<String, String> map = new HashMap<>();
map.put("skuId", skuId);
// logger.info("********"+url);
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas("19515")).params(map).post(url);
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas(appId)).params(map).post(url);
// response.prettyPrint();
try{
Assert.assertEquals(response.jsonPath().getString("desc"),"成功");
}catch(Exception e){
throw new Exception("创建接口1失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("创建接口2失败,返回信息:"+response.asString());
try {
Assert.assertEquals(response.jsonPath().getString("desc"), "成功");
} catch (Exception e) {
throw new Exception("创建接口1失败,返回信息:" + response.asString());
} catch (Error er) {
throw new Exception("创建接口2失败,返回信息:" + response.asString());
}
return response;
}
//订购活动--创建订单
public Response createAutomationOrderNew2(String skuId, String appId) throws Exception {
String url = "http://" + hdHost + "/saas/createAutomationOrderNew";
Map<String, String> map = new HashMap<>();
map.put("skuId", skuId);
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas(appId)).params(map).post(url);
try {
Assert.assertEquals(response.jsonPath().getString("desc"), "订单未处理");
} catch (Exception e) {
throw new Exception("创建接口1失败,返回信息:" + response.asString());
} catch (Error er) {
throw new Exception("创建接口2失败,返回信息:" + response.asString());
}
return response;
}
//订购--账户余额付款
public Response orderAccountPay(String orderId) throws Exception{
String url="http://"+hdHost+"/saas/orderAccountPay";
Map<String,String> map = new HashMap<>();
public Response orderAccountPay(String orderId, String appId) throws Exception {
String url = "http://" + hdHost + "/saas/orderAccountPay";
Map<String, String> map = new HashMap<>();
map.put("orderId",orderId);
// logger.info("********"+url);
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas()).params(map).get(url);
// response.prettyPrint();
try{
Assert.assertEquals(response.jsonPath().getString("desc"),"成功");
}catch(Exception e){
throw new Exception("创建接口1失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("创建接口2失败,返回信息:"+response.asString());
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas(appId)).params(map).get(url);response.prettyPrint();
try {
Assert.assertEquals(response.jsonPath().getString("desc"), "成功");
} catch (Exception e) {
throw new Exception("创建接口1失败,返回信息:" + response.asString());
} catch (Error er) {
throw new Exception("创建接口2失败,返回信息:" + response.asString());
}
return response;
}
//查询购买的活动订单信息
public Response findOrderById(String orderId, String appId) throws Exception {
String url = "http://" + hdHost + "/saas/findOrderById";
Map<String, String> map = new HashMap<>();
map.put("orderId",orderId);
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas(appId)).params(map).get(url);
response.prettyPrint();
try {
Assert.assertEquals(response.jsonPath().getString("desc"), "成功");
} catch (Exception e) {
throw new Exception("创建接口1失败,返回信息:" + response.asString());
} catch (Error er) {
throw new Exception("创建接口2失败,返回信息:" + response.asString());
}
return response;
}
//查看记录是否添加购买成功
public Response selectOrders(String orderStatus, String appId) throws Exception {
String url = "http://" + hdHost + "/saas/selectOrders";
Map<String, String> map = new HashMap<>();
map.put("orderStatus",orderStatus);
map.put("appId",appId);
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas(appId)).params(map).get(url);response.prettyPrint();
try {
Assert.assertEquals(response.jsonPath().getString("desc"), "成功");
} catch (Exception e) {
throw new Exception("创建接口1失败,返回信息:" + response.asString());
} catch (Error er) {
throw new Exception("创建接口2失败,返回信息:" + response.asString());
}
return response;
}
//取消付款
public Response cancleOrder(String orderId ,String appId) throws Exception {
String url = "http://" + hdHost + "/saas/cancleOrder";
Map<String, String> map = new HashMap<>();
map.put("orderId",orderId);
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas(appId)).params(map).post(url);
response.prettyPrint();
try {
Assert.assertEquals(response.jsonPath().getString("desc"), "成功");
} catch (Exception e) {
throw new Exception("创建接口1失败,返回信息:" + response.asString());
} catch (Error er) {
throw new Exception("创建接口2失败,返回信息:" + response.asString());
}
return response;
}
//查询直冲类商品
public Response directCharges(String appId) throws Exception {
String url = "http://" + hdHost + "/saasitem/directCharges";
Map<String, String> map = new HashMap<>();
map.put("rowId","1");
map.put("max","20");
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas(appId)).params(map).get(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 appItems(String appId, String itemName) throws Exception {
String url = "http://" + hdHost + "/devItem/appItems";
Map<String,String> map = new HashMap<>();
map.put("rowId", "1");
map.put("itemType", "");
map.put("belong", "");
map.put("status", "");
map.put("priceType", "");
map.put("itemName",itemName);
map.put("appId",appId);
map.put("classifyId", "");
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas(appId)).params(map).post(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 ajaxDel(String appId,String appItemId) throws Exception {
String url = "http://" + hdHost + "/devItem/ajaxDel";
Map<String, String> map = new HashMap<>();
map.put("appId",appId);
map.put("appItemId",appItemId);
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas(appId)).params(map).post(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;
}
}
......@@ -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);
......
......@@ -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;
}
}
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