Commit fef6fc35 authored by 郭姣's avatar 郭姣

Merge branch 'master' into gifeature/20210726-gj

# Conflicts:
#	src/test/java/com/kjj/cases/assistant/homePage/HomePage.java
#	src/test/java/com/kjj/config/BasicConfig.java
parents 653a7c78 d9fee805
package com.kjj.bean.agent;
import lombok.Data;
@Data
public class CustOrigins {
private String avatar;
private String name;
private long UserId;
}
package com.kjj.bean.gift;
package com.kjj.bean.marketTools;
import lombok.Data;
......
package com.kjj.bean.marketTools;
import lombok.Data;
@Data
public class LotteryTable {
private int id;
private String title;
private int status;
private int publicly;
}
package com.kjj.bean.marketTools;
import lombok.Data;
import java.util.ArrayList;
@Data
public class PrizeDetail {
private int customPrizeRate;
private int customPrizeType;
private String activityCustomPrizeId;
private String prizeImg;
private String prizeName;
private int totalStock;
private ArrayList<String> winnerIds;
}
package com.kjj.bean.marketTools;
import lombok.Data;
@Data
public class Visitor {
private String avatar;
private String visitorId;
private String visitorNickname;
}
......@@ -20,237 +20,200 @@ public interface Authorization {
System.out.println("用户AUTH_KEY:"+ADMIN_KEY);
}
/**
* 集客助手授权
* 集客助手相关授权
*/
//代理人
//代理人吉吉 sid:2991
default void agentTku() {
AGENT_TKU = BaseUtils.createTku();
network.agentCookies.put("tku", AGENT_TKU);
System.out.println("代理人tku:" + AGENT_TKU);
}
// 获取访客tku
// 获取访客tku:Su Yi
default void userTku() {
AGENT_TKU = BaseUtils.createTku();
VISITOR_TKU = BaseUtils.getTku(VISITOR_USERID);
network.agentCookies.put("tku", VISITOR_UserTku);
System.out.println("访客tku:" + VISITOR_UserTku);
}
// 获取访客tku:请勿打扰
default void userTku1() {
network.agentCookies.put("tku", VISITOR_TKU);
System.out.println("访客tku:" + VISITOR_TKU);
}
// 获取访客tku:小雪人
default void userTku2() {
network.agentCookies.put("tku", VISITOR1_TKU);
System.out.println("访客tku:" + VISITOR1_TKU);
}
/**
* 代理人(yl)授权,ID:826
* 直播业务相关
*/
//代理人(yl)授权,ID:826
default void agentAuth(){
// 创建用户 并传到network里
network.agentCookies.put("authKey",AUTH_KEY);
System.out.println("用户AUTH_KEY:"+AUTH_KEY);
}
/**
* 代理人(小疙瘩人寿)授权,ID:995
*/
//代理人(小疙瘩人寿)授权,ID:995
default void agentAuth1(){
// 创建用户 并传到network里
network.agentCookies.put("authKey",agentAuth);
System.out.println("用户AUTH_KEY:"+agentAuth);
}
/**
* 访客A(志勇)授权,代理人指定中奖用户,ID:107
*/
//访客A(志勇)授权,代理人指定中奖用户,ID:107
default void visitorAuth() {
network.agentCookies.put("authKey", visitorAuth);
System.out.println("用户AUTH_KEY:" + visitorAuth);
}
/**
* 访客B(茶仔)授权,用户ID:122
*/
//访客B(茶仔)授权,用户ID:122
default void visitorAuth2() {
network.agentCookies.put("authKey", visitorAuth2);
System.out.println("用户AUTH_KEY:" + visitorAuth2);
}
/**
* 访客C(刘超)授权,地域指定用户ID:811
*/
//访客C(刘超)授权,地域指定用户ID:811
default void visitorAuth3() {
network.agentCookies.put("authKey", visitorAuth3);
System.out.println("用户AUTH_KEY:" + visitorAuth3);
}
/**
* 访客D(李执)授权,地域指定用户ID:89
*/
//访客D(李执)授权,地域指定用户ID:89
default void visitorAuth4() {
network.agentCookies.put("authKey", visitorAuth4);
System.out.println("用户AUTH_KEY:" + visitorAuth4);
}
/**
* 访客E(周成)授权,企业指定中奖用户,用户ID:812
*/
//访客E(周成)授权,企业指定中奖用户,用户ID:812
default void visitorAuth5() {
network.agentCookies.put("authKey", visitorAuth5);
System.out.println("用户AUTH_KEY:" + visitorAuth5);
}
/**
* 访客F(新强)授权,用户ID:82
*/
//访客F(新强)授权,用户ID:82
default void visitorAuth6() {
network.agentCookies.put("authKey", visitorAuth6);
System.out.println("用户AUTH_KEY:" + visitorAuth6);
}
/**
* 访客G(熊二)授权,黑名单用户,ID:719
*/
//访客G(熊二)授权,黑名单用户,ID:719
default void visitorAuth7() {
network.agentCookies.put("authKey", visitorAuth7);
System.out.println("用户AUTH_KEY:" + visitorAuth7);
}
/**
* 访客I(熊大)授权 ID:1239
*/
//访客I(熊大)授权 ID:1239
default void visitorAuth8() {
network.agentCookies.put("authKey", visitorAuth8);
System.out.println("用户AUTH_KEY:" + visitorAuth8);
}
/**
* 访客H(吉吉)非实名用户授权,ID:907
*/
//访客H(吉吉)非实名用户授权,ID:907
default void visitorAuth9() {
network.agentCookies.put("authKey", visitorAuth9);
System.out.println("用户AUTH_KEY:" + visitorAuth9);
}
/**
* 访客J(日落)授权,ID:703
*/
//访客J(日落)授权,ID:703
default void visitorAuth10() {
network.agentCookies.put("authKey", visitorAuth10);
System.out.println("用户AUTH_KEY:" + visitorAuth10);
}
/**
* 访客K(沈小四)授权,ID:108
*/
//访客K(沈小四)授权,ID:108
default void visitorAuth11() {
network.agentCookies.put("authKey", visitorAuth11);
System.out.println("用户AUTH_KEY:" + visitorAuth11);
}
/**
* 访客L(饺子)授权,ID:97
*/
//访客L(饺子)授权,ID:97
default void visitorAuth12() {
network.agentCookies.put("authKey", visitorAuth12);
System.out.println("用户AUTH_KEY:" + visitorAuth12);
}
/**
* 访客M(大妹子)非实名用户授权,ID:299
*/
//访客M(大妹子)非实名用户授权,ID:299
default void visitorAuth13() {
network.agentCookies.put("authKey", visitorAuth13);
System.out.println("用户AUTH_KEY:" + visitorAuth13);
}
/**
* 访客N(光头强)非实名用户授权,ID:540
*/
//访客N(光头强)非实名用户授权,ID:540
default void visitorAuth14() {
network.agentCookies.put("authKey", visitorAuth14);
System.out.println("用户AUTH_KEY:" + visitorAuth14);
}
/**
* 访客O(少侠)授权,ID:79
*/
//访客O(少侠)授权,ID:79
default void visitorAuth15() {
network.agentCookies.put("authKey", visitorAuth15);
System.out.println("用户AUTH_KEY:" + visitorAuth15);
}
/**
* 访客P(抬头有飞碟)授权,ID:99
*/
//访客P(抬头有飞碟)授权,ID:99
default void visitorAuth16() {
network.agentCookies.put("authKey", visitorAuth16);
System.out.println("用户AUTH_KEY:" + visitorAuth16);
}
/**
* 访客Q(枫城)授权,ID:77
*/
//访客Q(枫城)授权,ID:77
default void visitorAuth17() {
network.agentCookies.put("authKey", visitorAuth17);
System.out.println("用户AUTH_KEY:" + visitorAuth17);
}
/**
* 访客R(小老弟来了)非实名用户授权,ID:94
*/
//访客R(小老弟来了)非实名用户授权,ID:94
default void visitorAuth18() {
network.agentCookies.put("authKey", visitorAuth18);
System.out.println("用户AUTH_KEY:" + visitorAuth18);
}
/**
* 访客T(林国芸)ID:786
*/
//访客T(林国芸)ID:786
default void visitorAuth19() {
network.agentCookies.put("authKey", visitorAuth19);
System.out.println("用户AUTH_KEY:" + visitorAuth19);
}
/**
* 访客Y(孙心桂)ID:785
*/
//访客Y(孙心桂)ID:785
default void visitorAuth20() {
network.agentCookies.put("authKey", visitorAuth20);
System.out.println("用户AUTH_KEY:" + visitorAuth20);
}
/**
* 访客W(谢翊美)ID:791
*/
//访客W(谢翊美)ID:791
default void visitorAuth21() {
network.agentCookies.put("authKey", visitorAuth21);
System.out.println("用户AUTH_KEY:" + visitorAuth21);
}
/**
* 访客V(zzz666)ID:849
*/
//访客V(zzz666)ID:849
default void visitorAuth22() {
network.agentCookies.put("authKey", visitorAuth22);
System.out.println("用户AUTH_KEY:" + visitorAuth22);
}
/**
* 访客u(七凉)ID:179
*/
//访客u(七凉)ID:179
default void visitorAuth23() {
network.agentCookies.put("authKey", visitorAuth23);
System.out.println("用户AUTH_KEY:" + visitorAuth23);
}
/**
* 访客S(奶汪)ID:1170 实名
*/
//访客S(奶汪)ID:1170 实名
default void visitorAuth24() {
network.agentCookies.put("authKey", visitorAuth24);
System.out.println("用户AUTH_KEY:" + visitorAuth24);
}
/**
* 访客S(亦心)ID:96 实名
*/
//访客S(亦心)ID:96 实名
default void visitorAuth25() {
network.agentCookies.put("authKey", visitorAuth25);
System.out.println("用户AUTH_KEY:" + visitorAuth25);
......
......@@ -271,8 +271,8 @@ public class ArticalPersonCard implements Authorization {
System.out.println(response.body().asString());
boolean success = response.jsonPath().getBoolean("success");
Object data = response.jsonPath().getJsonObject("success");
Assert.assertTrue(success, network.message(params,SELLERCARD_GETSELLERPROMOTEINFO,"获取专业解读列表有误",response.body().asString()));
Assert.assertNotNull(data, network.message(params,SELLERCARD_GETSELLERPROMOTEINFO,"获取专业解读列表有误",response.body().asString()));
Assert.assertTrue(success, network.message(params,SELLERCARD_GETSELLERPROMOTEINFO,"接口返回失败",response.body().asString()));
Assert.assertNotNull(data, network.message(params,SELLERCARD_GETSELLERPROMOTEINFO,"返回数据为空",response.body().asString()));
}
// 获取互动区-专业解读
......@@ -323,10 +323,4 @@ public class ArticalPersonCard implements Authorization {
String desc = response.jsonPath().getString("desc");
Assert.assertEquals(desc,"OK",network.message(params, CHECKUNREAD, "访客-获取私信有误",response.body().asString()));
}
@AfterClass
public static void tearDown(){
apiCount += 16;
}
}
......@@ -48,15 +48,15 @@ public class PersonCard implements Authorization {
public void 获取用户版本(){
HashMap<String,Object> params = new HashMap<String,Object>();
params.put("t",System.currentTimeMillis());
Response response = network.getResponse(params,VERSION_INFO);
Response response = network.getResponse(params,version_info);
boolean success = response.jsonPath().getBoolean("success");
int userVersion = response.jsonPath().getInt("data.find {it.openType == 1}.userVersion");
Object data = response.jsonPath().getJsonObject("data");
boolean vip = response.jsonPath().getBoolean("data.find {it.openType == 1}.vip");
Assert.assertTrue(success,network.message(params,VERSION_INFO,"接口返回失败状态",response.body().asString()));
Assert.assertNotNull(data,network.message(params,VERSION_INFO,"返回数据为空",response.body().asString()));
Assert.assertTrue(vip,network.message(params,VERSION_INFO,"开启但不是VIP",response.body().asString()));
Assert.assertEquals(userVersion,2,network.message(params,VERSION_INFO,"用户不是保险专业版",response.body().asString()));
Assert.assertTrue(success,network.message(params,version_info,"接口返回失败状态",response.body().asString()));
Assert.assertNotNull(data,network.message(params,version_info,"返回数据为空",response.body().asString()));
Assert.assertTrue(vip,network.message(params,version_info,"开启但不是VIP",response.body().asString()));
Assert.assertEquals(userVersion,2,network.message(params,version_info,"用户不是保险专业版",response.body().asString()));
}
@Test(description = "获取名片顶部信息",priority = 3)
......@@ -235,11 +235,11 @@ public class PersonCard implements Authorization {
Map<String, Object> params = new HashMap<String, Object>();
params.put("page","seller_card");
params.put("timestamp",System.currentTimeMillis());
Response response = network.getResponse(params, GREETING_getTipsByPage);
Response response = network.getResponse(params, GETTIPSBYPAGE);
boolean success = response.jsonPath().getBoolean("success");
Object data = response.jsonPath().getJsonObject("data");
Assert.assertTrue(success,network.message(params, GREETING_getTipsByPage,"接口返回失败状态",response.body().asString()));
Assert.assertNotNull(data,network.message(params, GREETING_getTipsByPage,"返回数据为空",response.body().asString()));
Assert.assertTrue(success,network.message(params, GETTIPSBYPAGE,"接口返回失败状态",response.body().asString()));
Assert.assertNotNull(data,network.message(params, GETTIPSBYPAGE,"返回数据为空",response.body().asString()));
}
@Test(description = "获取客户投保案例模块", priority = 11) //priorty 方法执行优先级
......@@ -892,8 +892,4 @@ public class PersonCard implements Authorization {
Assert.assertEquals(guideType,0,network.message(SELLERCARD_CARDGUIDE ,"引导类型错误",response.body().asString()));
}
@AfterClass
public static void tearDown(){
apiCount += 41;
}
}
......@@ -31,13 +31,8 @@ public class DailyPaper implements Authorization {
@BeforeClass
public void setUp() {
BaseUtils.ssoLogin();
// 创建用户 并传到network里
AGENT_TKU = BaseUtils.createTku();
network.agentCookies.put("tku",AGENT_TKU);
//System.out.println("代理人tku:"+AGENT_TKU);
// 获取访客tku
VISITOR_TKU = BaseUtils.getTku(VISITOR_USERID);
//System.out.println("访客tku:"+VISITOR_TKU);
agentTku();
userTku();
}
@Test (description = "今日早报_获取今日早报列表",priority = 1)
......
package com.kjj.cases.assistant.homePage;
package com.kjj.cases.assistant;
import static com.kjj.config.BasicConfig.*;
import com.kjj.cases.admin.Authorization;
......@@ -24,15 +24,10 @@ public class HomePage implements Authorization {
@BeforeClass
public void setUp() {
agentTku();
userTku();
//管理后台登录
BaseUtils.ssoLogin();
// 创建用户 并传到network里
AGENT_TKU = BaseUtils.createTku();
network.agentCookies.put("tku", AGENT_TKU);
//System.out.println("代理人tku:"+AGENT_TKU);
// 获取访客tku
VISITOR_TKU = BaseUtils.getTku(VISITOR_USERID);
//System.out.println("访客tku:"+VISITOR_TKU);
}
//获取种草素材列表页
......
......@@ -31,13 +31,8 @@ public class RecommendMaterial implements Authorization {
@BeforeClass
public void setUp() {
// 创建用户 并传到network里
AGENT_TKU = BaseUtils.createTku();
network.agentCookies.put("tku", AGENT_TKU);
//System.out.println("代理人tku:"+AGENT_TKU);
// 获取访客tku
VISITOR_TKU = BaseUtils.getTku(VISITOR_USERID);
//System.out.println("访客tku:"+VISITOR_TKU);
userTku();
agentTku();
}
//种草文章列表页
......@@ -406,10 +401,4 @@ public class RecommendMaterial implements Authorization {
}
@AfterClass
public void tearDown() {
network.agentCookies.put("tku", AGENT_TKU); //tku 切换为访客的
apiCount += 13;
}
}
\ No newline at end of file
......@@ -234,9 +234,4 @@ public class Upload {
Assert.assertEquals(length, 0, network.message(params, UPLOAD_LIST,"获取我的上传-其他列表数量有误",response.body().asString()));
}
@AfterClass
public static void tearDown(){
apiCount += 13;
}
}
\ No newline at end of file
package com.kjj.cases.assistant.markettools;
import com.alibaba.fastjson.JSON;
import com.kjj.bean.marketTools.LotteryTable;
import com.kjj.bean.marketTools.PrizeDetail;
import com.kjj.bean.marketTools.Visitor;
import com.kjj.cases.admin.Authorization;
import com.kjj.utils.BaseUtils;
import com.kjj.utils.JsonUtil;
import com.kjj.utils.NetworkUtils;
import io.restassured.response.Response;
import org.testng.Assert;
import org.testng.annotations.*;
import java.util.*;
import static com.kjj.config.BasicConfig.*;
import static com.kjj.utils.ThreadSleepUtils.sleep;
public class GameLottery implements Authorization {
private static final NetworkUtils network = NetworkUtils.getInstance();
public String lotteryId; //抽奖模板id
public String scid; //指定中奖-抽奖scid
public String id; //抽奖重定向地址id
public Visitor visitor; //指定中奖的客户
public String activityConfId; //指定中奖-抽奖活动配置id
public String rateConfId; //概率中奖-抽奖活动配置id
public String rateScid; //概率中奖-抽奖scid
public String winnerId; //抽奖活动配置id
public String activityCustomPrizeId; //配置生效的奖品id
public String orderId; //订单id
public String visitTableId; //订单id
public int remainingTimes; //剩余抽奖次数
public String winningRecodeId; //中奖记录id
@BeforeClass
public void setUp(){
BaseUtils.ssoLogin();
}
@Test(description = "代理人_获取抽奖活动重定向地址id",priority = 1)
public void 代理人_获取抽奖活动重定向地址id(){
Map<String, Object> params = new HashMap<String, Object>();
params.put("contentType","game_template");
params.put("pageIndex",1);
params.put("pageSize",20);
Response response = network.getResponse(params,MANAGER_searchTemplateList);
boolean success = response.jsonPath().getBoolean("success");
Object data = response.jsonPath().getJsonObject("data");
Assert.assertTrue(success,network.message(params,MANAGER_searchTemplateList,"接口返回失败",response.body().asString()));
Assert.assertNotNull(data,network.message(params,MANAGER_searchTemplateList,"返回数据为空",response.body().asString()));
int lId=0;
List<LotteryTable> templateList = JsonUtil.parseResponsePathToListBean(response,"data.list",LotteryTable.class);
for (LotteryTable template:templateList) {
if(template.getStatus()==2 && template.getPublicly() == 1){
lId = template.getId();
break;
}
}
if(lId == 0){
System.out.println("抽奖转盘列表没有已上架的公有的抽奖模板");
return;
}
params.clear();
params.put("id",lId);
response = network.getResponse(params,MANAGER_getTemplateDetail);
String activityUrl= response.jsonPath().getString("data.activityUrl");
id = activityUrl.substring(activityUrl.indexOf("id")+3);
System.out.println(id);
}
@Test(description = "代理人_获取抽奖模板列表",priority = 2)
public void 代理人_获取抽奖模板列表(){
agentTku();
Map<String, Object> params = new HashMap<String, Object>();
params.put("pageIndex",1);
params.put("pageSize",20);
Response response = network.getResponse(params,LOTTERRY_templatePageList);
boolean success = response.jsonPath().getBoolean("success");
Object data = response.jsonPath().getJsonObject("data");
Assert.assertTrue(success,network.message(params,LOTTERRY_templatePageList,"接口返回失败",response.body().asString()));
Assert.assertNotNull(data,network.message(params,LOTTERRY_templatePageList,"返回数据为空",response.body().asString()));
int size = response.jsonPath().getInt("data.list.size()");
Assert.assertTrue(size>0,network.message(params,LOTTERRY_templatePageList,"抽奖模板列表为空",response.body().asString()));
lotteryId = response.jsonPath().getString("data.list.get(0).id");
}
@Test(description = "代理人_根据page获取当前页面的Tips",priority = 3)
public void 代理人_根据page获取当前页面的Tips(){
HashMap<String,Object> params = new HashMap<String,Object>();
params.put("page", "game_lottery");
Response response = network.getResponse(params,GETTIPSBYPAGE);
boolean success = response.jsonPath().getBoolean("success");
Object data = response.jsonPath().getJsonObject("data");
Assert.assertTrue(success,network.message(params,GETTIPSBYPAGE,"接口返回失败",response.body().asString()));
Assert.assertNotNull(data,network.message(params,GETTIPSBYPAGE,"返回数据为空",response.body().asString()));
}
@Test(description = "是否能访问抽奖工具",priority = 4)
public void 代理人_是否能访问抽奖工具(){
Response response = network.getResponse(LOTTERRY_check);
boolean success = response.jsonPath().getBoolean("success");
boolean data = response.jsonPath().getBoolean("data");
Assert.assertTrue(success,network.message(LOTTERRY_check,"接口返回失败",response.body().asString()));
Assert.assertTrue(data,network.message(LOTTERRY_check,"返回不能访问",response.body().asString()));
}
@Test(description="获取抽奖详情页",priority = 5)
public void 代理人_获取抽奖详情页() {
//根据ContentId获取Scid
Map<String, Object> params = new HashMap<String, Object>();
params.put("contentId",lotteryId);
Response response = network.getResponse(params, GETSCID);
scid = response.jsonPath().getString("data");
Assert.assertNotNull(scid,network.message(params, GETSCID,"获取scid失败",response.body().asString()));
params.clear();
params.put("scid",scid);
response = network.getResponse(params,GREETING_H5INFO);
String id = response.jsonPath().getString("data.id");
Assert.assertEquals(lotteryId, id, network.message(params,GREETING_H5INFO,"获取贺卡页面失败",response.body().asString()));
}
@Test(description = "代理人_获取次数及奖品信息",priority = 6)
public void 代理人_获取次数及奖品信息(){
Map<String, Object> params = new HashMap<String, Object>();
params.put("scid",scid);
params.put("id",id);
Response response = network.getResponse(params, LOTTERRY_getElements);
boolean success = response.jsonPath().getBoolean("success");
Object data = response.jsonPath().getJsonObject("data");
Assert.assertTrue(success,network.message(params, LOTTERRY_getElements,"接口返回失败",response.body().asString()));
Assert.assertNotNull(data,network.message(params, LOTTERRY_getElements,"返回数据为空",response.body().asString()));
}
@Test(description = "代理人_获取抽奖配置",priority = 7)
public void 代理人_获取抽奖配置(){
Map<String, Object> params = new HashMap<String, Object>();
params.put("scid",scid);
Response response = network.getResponse(params, LOTTERRY_getConfDetail);
boolean success = response.jsonPath().getBoolean("success");
Object data = response.jsonPath().getJsonObject("data");
Assert.assertTrue(success,network.message(params, LOTTERRY_getConfDetail,"接口返回失败",response.body().asString()));
Assert.assertNotNull(data,network.message(params, LOTTERRY_getConfDetail,"返回数据为空",response.body().asString()));
}
@Test(description = "代理人_编辑指定中奖",priority = 8)
public void 代理人_编辑指定中奖(){
//获取客户列表
Map<String, Object> params = new HashMap<String, Object>();
params.put("pageIndex",1);
params.put("pageSize",20);
params.put("visitorNickname","");
Response response = network.getResponse(params, LOTTERRY_customerList);
boolean success = response.jsonPath().getBoolean("success");
Object data = response.jsonPath().getJsonObject("data");
Assert.assertTrue(success,network.message(params, LOTTERRY_customerList,"接口返回失败",response.body().asString()));
Assert.assertNotNull(data,network.message(params, LOTTERRY_customerList,"返回数据为空",response.body().asString()));
if(response.jsonPath().getInt("data.list.size()")<1){
System.out.println("客户列表为空");
}
//选择"Su Yi"
List<Visitor> visitorList = JsonUtil.parseResponsePathToListBean(response,"data.list",Visitor.class);
for (Visitor item:visitorList) {
if (item.getVisitorNickname().equals("Su Yi")){
visitor = item;
break;
}
}
//指定"Su Yi"中奖
ArrayList<Visitor> visitorListChoose = new ArrayList<Visitor>();
System.out.println(visitor.toString());
visitorListChoose.add(visitor);
params.clear();
params.put("scid",scid);
params.put("pageSize",20);
params.put("winners",visitorListChoose);
System.out.println(params.toString());
response = network.postResponse(params, LOTTERRY_addWinnersEn);
success = response.jsonPath().getBoolean("success");
data = response.jsonPath().getJsonObject("data");
System.out.println(response.body().asString());
Assert.assertTrue(success,network.message(params, LOTTERRY_addWinnersEn,"接口返回失败",response.body().asString()));
Assert.assertNotNull(data,network.message(params, LOTTERRY_addWinnersEn,"返回数据为空",response.body().asString()));
winnerId = response.jsonPath().getJsonObject("data.get(0).winnerId");
System.out.println("winnerId:" + winnerId);
}
@Test(description = "代理人_保存抽奖配置",priority = 9)
public void 代理人_保存抽奖配置(){
Map<String, Object> params = new HashMap<String, Object>();
//指定客户列表
ArrayList<String> visitorList = new ArrayList<String>();
visitorList.add(winnerId);
//奖品详情
PrizeDetail prizeDetail = new PrizeDetail();
prizeDetail.setPrizeImg("https://yun.duiba.com.cn/kjj-prize-nodeimages/76242998-4c8f-4e1e-b321-697289fc28a9.png");
prizeDetail.setPrizeName("抱枕");
prizeDetail.setCustomPrizeRate(0);
prizeDetail.setCustomPrizeType(1);
prizeDetail.setTotalStock(1);
prizeDetail.setWinnerIds(visitorList);
//转换奖品列表
ArrayList<PrizeDetail> prizeDetails = new ArrayList<PrizeDetail>();
prizeDetails.add(prizeDetail);
//奖品列表
params.put("scid",scid);
params.put("pageTitle","来抽奖吧");
params.put("prizeDetails",prizeDetails);
System.out.println(JSON.toJSONString(params));
Response response = network.postResponse(params, LOTTERRY_saveOrUpdateConf);
boolean success = response.jsonPath().getBoolean("success");
activityConfId = response.jsonPath().getString("data");
Assert.assertTrue(success,network.message(params, LOTTERRY_saveOrUpdateConf,"接口返回失败",response.body().asString()));
Assert.assertNotNull(activityConfId,network.message(params, LOTTERRY_saveOrUpdateConf,"返回数据为空",response.body().asString()));
}
@Test(description = "代理人_查询抽奖配置",priority = 10)
public void 代理人_查询抽奖配置(){
Map<String, Object> params = new HashMap<String, Object>();
params.put("scid",scid);
params.put("activityConfId",activityConfId);
Response response = network.getResponse(params, LOTTERRY_getConf);
boolean success = response.jsonPath().getBoolean("success");
Object data = response.jsonPath().getString("data");
Assert.assertTrue(success,network.message(params, LOTTERRY_getConf,"接口返回失败",response.body().asString()));
Assert.assertNotNull(data,network.message(params, LOTTERRY_getConf,"返回数据为空",response.body().asString()));
String prizeName = response.jsonPath().getString("data.prizeDetails.get(0).prizeName");
String theWinner = response.jsonPath().getString("data.prizeDetails.get(0).winners.get(0).winnerId");
Assert.assertEquals(prizeName,"抱枕",network.message(params, LOTTERRY_getConf,"奖品错误",response.body().asString()));
Assert.assertEquals(theWinner,winnerId,network.message(params, LOTTERRY_getConf,"指定中奖的客户错误",response.body().asString()));
activityCustomPrizeId = response.jsonPath().getString("data.prizeDetails.get(0).activityCustomPrizeId");
System.out.println(activityCustomPrizeId);
}
@Test(description = "代理人_修改奖品",priority = 11)
public void 代理人_修改奖品(){
Map<String, Object> params = new HashMap<String, Object>();
//指定客户列表
ArrayList<String> visitorList = new ArrayList<String>();
visitorList.add(winnerId);
//奖品详情
PrizeDetail prizeDetail = new PrizeDetail();
prizeDetail.setActivityCustomPrizeId(activityCustomPrizeId);
prizeDetail.setPrizeImg("https://yun.duiba.com.cn/kjj-prize-nodeimages/bottle_.png");
prizeDetail.setPrizeName("杯子");
prizeDetail.setCustomPrizeRate(0);
prizeDetail.setCustomPrizeType(1);
prizeDetail.setTotalStock(1);
prizeDetail.setWinnerIds(visitorList);
//奖品列表
ArrayList<PrizeDetail> prizeDetails = new ArrayList<PrizeDetail>();
prizeDetails.add(prizeDetail);
params.put("scid",scid);
params.put("activityConfId",activityConfId);
params.put("pageTitle","快来抽大奖吧");
params.put("prizeDetails",prizeDetails);
Response response = network.postResponse(params, LOTTERRY_saveOrUpdateConf);
boolean success = response.jsonPath().getBoolean("success");
String data = response.jsonPath().getString("data");
Assert.assertTrue(success,network.message(params, LOTTERRY_saveOrUpdateConf,"接口返回失败",response.body().asString()));
Assert.assertEquals(data,activityConfId,network.message(params, LOTTERRY_saveOrUpdateConf,"返回抽奖配置id错误",response.body().asString()));
params.clear();
params.put("scid",scid);
params.put("activityConfId",activityConfId);
response = network.getResponse(params, LOTTERRY_getConf);
success = response.jsonPath().getBoolean("success");
Object result = response.jsonPath().getString("data");
Assert.assertTrue(success,network.message(params, LOTTERRY_getConf,"接口返回失败",response.body().asString()));
Assert.assertNotNull(result,network.message(params, LOTTERRY_getConf,"返回数据为空",response.body().asString()));
String pageTitle = response.jsonPath().getString("data.pageTitle");
String prizeName = response.jsonPath().getString("data.prizeDetails.get(0).prizeName");
Assert.assertEquals(prizeName,"杯子",network.message(params, LOTTERRY_getConf,"奖品错误",response.body().asString()));
Assert.assertEquals(pageTitle,"快来抽大奖吧",network.message(params, LOTTERRY_getConf,"指定中奖的客户错误",response.body().asString()));
}
@Test(description = "代理人_获取分享信息",priority = 12)
public void 代理人_获取分享信息(){
Map<String, Object> params = new HashMap<String, Object>();
params.put("scid",scid);
params.put("activityConfId",activityConfId);
Response response = network.getResponse(params, LOTTERRY_getH5ShareInfo);
boolean success = response.jsonPath().getBoolean("success");
Object data = response.jsonPath().getJsonObject("data");
Assert.assertTrue(success,network.message(params, LOTTERRY_getH5ShareInfo,"接口返回失败",response.body().asString()));
Assert.assertNotNull(data,network.message(params, LOTTERRY_getH5ShareInfo,"返回数据为空",response.body().asString()));
}
@Test(description="访客_打开抽奖链接",priority = 13)
public void 访客_打开抽奖链接(){
//切换为访客-请勿打扰
userTku1();
//添加访问记录
Map<String, Object> params = new HashMap<String, Object>();
params.put("scid",scid);
params.put("bizNo",activityConfId);
params.put("from",0);
Response response = network.getResponse(params,CONTENT_READ);
boolean success = response.jsonPath().getBoolean("success");
Object data = response.jsonPath().getJsonObject("data");
Assert.assertTrue(success,network.message(params,CONTENT_READ,"接口返回失败",response.body().asString()));
Assert.assertNotNull(data,network.message(params,CONTENT_READ,"获取访问贺卡记录失败",response.body().asString()));
visitTableId = response.jsonPath().getString("data.visitId");
//获取抽奖转盘信息
params.clear();
params.put("scid",scid);
response = network.getResponse(params,GREETING_H5INFO);
success = response.jsonPath().getBoolean("success");
data = response.jsonPath().getJsonObject("data");
Assert.assertTrue(success,network.message(params,GREETING_H5INFO,"接口返回失败",response.body().asString()));
Assert.assertNotNull(data,network.message(params,GREETING_H5INFO,"接口返回数据为空",response.body().asString()));
//获取抽奖次数
params.clear();
params.put("scid",scid);
params.put("id",id);
response = network.getResponse(params, LOTTERRY_getElements);
success = response.jsonPath().getBoolean("success");
data = response.jsonPath().getJsonObject("data");
Assert.assertTrue(success,network.message(params, LOTTERRY_getElements,"接口返回失败",response.body().asString()));
Assert.assertNotNull(data,network.message(params, LOTTERRY_getElements,"返回数据为空",response.body().asString()));
remainingTimes = response.jsonPath().getInt("data.remainingTimes");
System.out.println(remainingTimes);
System.out.println(response.body().asString());
}
@Test(description="访客_非指定客户不能中奖",priority = 14)
public void 访客_非指定客户不能中奖(){
//抽奖
Map<String, Object> params = new HashMap<String, Object>();
params.put("scid",scid);
params.put("activityConfId",activityConfId);
params.put("id",id);
Response response = network.postResponse(params,LOTTERRY_gdoJoin);
boolean success = response.jsonPath().getBoolean("success");
orderId = response.jsonPath().getString("data");
Assert.assertTrue(success,network.message(params,LOTTERRY_gdoJoin,"接口返回失败",response.body().asString()));
Assert.assertNotNull(orderId,network.message(params,LOTTERRY_gdoJoin,"返回抽奖订单号为空",response.body().asString()));
//获取抽奖结果
sleep(2000);
params.clear();
params.put("orderId",orderId);
response = network.getResponse(params,LOTTERRY_getOrderStatus);
success = response.jsonPath().getBoolean("success");
Object data = response.jsonPath().getJsonObject("data");
Assert.assertTrue(success,network.message(params,LOTTERRY_getOrderStatus,"接口返回失败",response.body().asString()));
Assert.assertNotNull(data,network.message(params,LOTTERRY_getOrderStatus,"接口返回数据为空",response.body().asString()));
//未中奖
int state = response.jsonPath().getInt("data.state");
int prizeType = response.jsonPath().getInt("data.prizeType");
Assert.assertTrue(state==2,network.message(params,LOTTERRY_getOrderStatus,"订单出奖状态错误",response.body().asString()));
Assert.assertTrue(prizeType==1 || prizeType==2,network.message(params,LOTTERRY_getOrderStatus,"抽奖结果错误",response.body().asString()));
}
@Test(description="访客_指定客户中奖",priority = 15)
public void 访客_指定客户中奖(){
//切换为Su Yi
userTku();
//添加访问记录
Map<String, Object> params = new HashMap<String, Object>();
params.put("scid",scid);
params.put("bizNo",activityConfId);
params.put("from",0);
Response response = network.getResponse(params,CONTENT_READ);
boolean success = response.jsonPath().getBoolean("success");
Object data = response.jsonPath().getJsonObject("data");
Assert.assertTrue(success,network.message(params,CONTENT_READ,"接口返回失败",response.body().asString()));
Assert.assertNotNull(data,network.message(params,CONTENT_READ,"获取访问贺卡记录失败",response.body().asString()));
visitTableId = response.jsonPath().getString("data.visitId");
//抽奖
params.clear();
params.put("scid",scid);
params.put("activityConfId",activityConfId);
params.put("id",id);
response = network.postResponse(params,LOTTERRY_gdoJoin);
success = response.jsonPath().getBoolean("success");
orderId = response.jsonPath().getString("data");
Assert.assertTrue(success,network.message(params,LOTTERRY_gdoJoin,"接口返回失败",response.body().asString()));
Assert.assertNotNull(orderId,network.message(params,LOTTERRY_gdoJoin,"返回抽奖订单号为空",response.body().asString()));
//获取抽奖结果
sleep(2000);
params.clear();
params.put("orderId",orderId);
response = network.getResponse(params,LOTTERRY_getOrderStatus);
success = response.jsonPath().getBoolean("success");
data = response.jsonPath().getJsonObject("data");
Assert.assertTrue(success,network.message(params,LOTTERRY_getOrderStatus,"接口返回失败",response.body().asString()));
Assert.assertNotNull(data,network.message(params,LOTTERRY_getOrderStatus,"接口返回数据为空",response.body().asString()));
//中奖
int state = response.jsonPath().getInt("data.state");
int prizeType = response.jsonPath().getInt("data.prizeType");
winningRecodeId = response.jsonPath().getString("data.winningRecodeId");
Assert.assertTrue(state==2,network.message(params,LOTTERRY_getOrderStatus,"订单出奖状态错误",response.body().asString()));
Assert.assertTrue(prizeType==3,network.message(params,LOTTERRY_getOrderStatus,"抽奖结果错误",response.body().asString()));
}
@Test(description="访客_根据订单ID获取中奖记录",priority = 16)
public void 访客_根据订单ID获取中奖记录(){
Map<String, Object> params = new HashMap<String, Object>();
params.put("scid",scid);
params.put("winningRecodeId",winningRecodeId);
Response response = network.getResponse(params, LOTTERRY_getRecordById);
boolean success = response.jsonPath().getBoolean("success");
Object data = response.jsonPath().getJsonObject("data");
Assert.assertTrue(success,network.message(params, LOTTERRY_getRecordById,"接口返回失败",response.body().asString()));
Assert.assertNotNull(data,network.message(params, LOTTERRY_getRecordById,"返回数据为空",response.body().asString()));
String prizeName = response.jsonPath().getString("data.prizeName");
Assert.assertEquals(prizeName,"杯子",network.message(params,LOTTERRY_getRecordById,"中奖奖品名称错误",response.body().asString()));
}
@Test(description="访客_获取抽奖代理人信息",priority = 17)
public void 访客_获取抽奖代理人信息(){
Map<String, Object> params = new HashMap<String, Object>();
params.put("scid",scid);
Response response = network.getResponse(params, LOTTERRY_getSellerCard);
System.out.println(response.body().asString());
boolean success = response.jsonPath().getBoolean("success");
Object data = response.jsonPath().getJsonObject("data");
Assert.assertTrue(success,network.message(params, LOTTERRY_getSellerCard,"接口返回失败",response.body().asString()));
Assert.assertNotNull(data,network.message(params, LOTTERRY_getSellerCard,"返回数据为空",response.body().asString()));
String wxName = response.jsonPath().getString("data.wxName");
Assert.assertEquals(wxName,"吉吉",network.message(params,LOTTERRY_getSellerCard,"中奖奖品名称错误",response.body().asString()));
}
@Test(description="访客_提交中奖信息",priority = 18)
public void 访客_提交中奖信息(){
Map<String, Object> params = new HashMap<String, Object>();
params.put("scid",scid);
params.put("visitTableId",visitTableId);
params.put("visitorName","苏逸");
params.put("visitorPhone","13512345678");
params.put("winningRecodeId",winningRecodeId);
Response response = network.postResponse(params, LOTTERRY_commitWinnerInfo);
boolean success = response.jsonPath().getBoolean("success");
boolean data = response.jsonPath().getJsonObject("data");
Assert.assertTrue(success,network.message(params, LOTTERRY_commitWinnerInfo,"接口返回失败",response.body().asString()));
Assert.assertTrue(data,network.message(params, LOTTERRY_commitWinnerInfo,"返回数据为空",response.body().asString()));
}
@Test(description="代理人_创建概率中奖抽奖活动",priority = 19)
public void 代理人_创建概率中奖抽奖活动(){
agentTku();
//根据ContentId获取Scid
Map<String, Object> params = new HashMap<String, Object>();
params.put("contentId",lotteryId);
Response response = network.getResponse(params, GETSCID);
rateScid = response.jsonPath().getString("data");
Assert.assertNotNull(rateScid,network.message(params, GETSCID,"获取scid失败",response.body().asString()));
params.clear();
//指定客户列表-空列表
ArrayList<String> visitorList = new ArrayList<String>();
//奖品详情
PrizeDetail prizeDetail = new PrizeDetail();
prizeDetail.setPrizeImg("https://yun.duiba.com.cn/kjj-prize-nodeimages/76242998-4c8f-4e1e-b321-697289fc28a9.png");
prizeDetail.setPrizeName("抱枕");
prizeDetail.setCustomPrizeRate(100);
prizeDetail.setCustomPrizeType(2);
prizeDetail.setTotalStock(1);
prizeDetail.setWinnerIds(visitorList);
//转换奖品列表
ArrayList<PrizeDetail> prizeDetails = new ArrayList<PrizeDetail>();
prizeDetails.add(prizeDetail);
//奖品列表
params.put("scid",rateScid);
params.put("pageTitle","来抽奖吧");
params.put("prizeDetails",prizeDetails);
System.out.println(JSON.toJSONString(params));
response = network.postResponse(params, LOTTERRY_saveOrUpdateConf);
boolean success = response.jsonPath().getBoolean("success");
rateConfId = response.jsonPath().getString("data");
Assert.assertTrue(success,network.message(params, LOTTERRY_saveOrUpdateConf,"接口返回失败",response.body().asString()));
Assert.assertNotNull(rateConfId,network.message(params, LOTTERRY_saveOrUpdateConf,"返回数据为空",response.body().asString()));
}
@Test(description="访客_第一个客户中奖",priority = 20)
public void 访客_第一个客户中奖(){
//切换为Su Yi
userTku();
//添加访问记录
Map<String, Object> params = new HashMap<String, Object>();
params.put("scid",rateScid);
params.put("bizNo",rateConfId);
params.put("from",0);
Response response = network.getResponse(params,CONTENT_READ);
boolean success = response.jsonPath().getBoolean("success");
Object data = response.jsonPath().getJsonObject("data");
Assert.assertTrue(success,network.message(params,CONTENT_READ,"接口返回失败",response.body().asString()));
Assert.assertNotNull(data,network.message(params,CONTENT_READ,"获取访问贺卡记录失败",response.body().asString()));
//抽奖
params.clear();
params.put("scid",rateScid);
params.put("activityConfId",rateConfId);
params.put("id",id);
response = network.postResponse(params,LOTTERRY_gdoJoin);
success = response.jsonPath().getBoolean("success");
orderId = response.jsonPath().getString("data");
Assert.assertTrue(success,network.message(params,LOTTERRY_gdoJoin,"接口返回失败",response.body().asString()));
Assert.assertNotNull(orderId,network.message(params,LOTTERRY_gdoJoin,"返回抽奖订单号为空",response.body().asString()));
//获取抽奖结果
sleep(2000);
params.clear();
params.put("orderId",orderId);
response = network.getResponse(params,LOTTERRY_getOrderStatus);
success = response.jsonPath().getBoolean("success");
data = response.jsonPath().getJsonObject("data");
Assert.assertTrue(success,network.message(params,LOTTERRY_getOrderStatus,"接口返回失败",response.body().asString()));
Assert.assertNotNull(data,network.message(params,LOTTERRY_getOrderStatus,"接口返回数据为空",response.body().asString()));
//中奖
int state = response.jsonPath().getInt("data.state");
int prizeType = response.jsonPath().getInt("data.prizeType");
Assert.assertTrue(state==2,network.message(params,LOTTERRY_getOrderStatus,"订单出奖状态错误",response.body().asString()));
Assert.assertTrue(prizeType==6,network.message(params,LOTTERRY_getOrderStatus,"抽奖结果错误",response.body().asString()));
}
@Test(description="访客_第二个客户未中奖",priority = 21)
public void 访客_第二个客户未中奖(){
//切换为请勿打扰
userTku1();
//添加访问记录
Map<String, Object> params = new HashMap<String, Object>();
params.put("scid",rateScid);
params.put("bizNo",rateConfId);
params.put("from",0);
Response response = network.getResponse(params,CONTENT_READ);
boolean success = response.jsonPath().getBoolean("success");
Object data = response.jsonPath().getJsonObject("data");
Assert.assertTrue(success,network.message(params,CONTENT_READ,"接口返回失败",response.body().asString()));
Assert.assertNotNull(data,network.message(params,CONTENT_READ,"获取访问贺卡记录失败",response.body().asString()));
//抽奖
params.clear();
params.put("scid",rateScid);
params.put("activityConfId",rateConfId);
params.put("id",id);
response = network.postResponse(params,LOTTERRY_gdoJoin);
success = response.jsonPath().getBoolean("success");
orderId = response.jsonPath().getString("data");
Assert.assertTrue(success,network.message(params,LOTTERRY_gdoJoin,"接口返回失败",response.body().asString()));
Assert.assertNotNull(orderId,network.message(params,LOTTERRY_gdoJoin,"返回抽奖订单号为空",response.body().asString()));
//获取抽奖结果
sleep(2000);
params.clear();
params.put("orderId",orderId);
response = network.getResponse(params,LOTTERRY_getOrderStatus);
success = response.jsonPath().getBoolean("success");
data = response.jsonPath().getJsonObject("data");
Assert.assertTrue(success,network.message(params,LOTTERRY_getOrderStatus,"接口返回失败",response.body().asString()));
Assert.assertNotNull(data,network.message(params,LOTTERRY_getOrderStatus,"接口返回数据为空",response.body().asString()));
//中奖
int state = response.jsonPath().getInt("data.state");
int prizeType = response.jsonPath().getInt("data.prizeType");
Assert.assertTrue(state==2,network.message(params,LOTTERRY_getOrderStatus,"订单出奖状态错误",response.body().asString()));
Assert.assertTrue(prizeType==1 || prizeType==2,network.message(params,LOTTERRY_getOrderStatus,"抽奖结果错误",response.body().asString()));
}
@Test(description="代理人_查询发起抽奖列表",priority = 22)
public void 代理人_查询发起抽奖列表(){
//切换为代理人
agentTku();
Map<String, Object> params = new HashMap<String, Object>();
params.put("pageIndex",1);
params.put("pageSize",20);
Response response = network.getResponse(params, LOTTERRY_confPageList);
boolean success = response.jsonPath().getBoolean("success");
Object data = response.jsonPath().getJsonObject("data");
Assert.assertTrue(success,network.message(params, LOTTERRY_confPageList,"接口返回失败",response.body().asString()));
Assert.assertNotNull(data,network.message(params, LOTTERRY_confPageList,"返回数据为空",response.body().asString()));
int size = response.jsonPath().getInt("data.list.size()");
Assert.assertTrue(size>0,network.message(params,LOTTERRY_confPageList,"中奖奖品名称错误",response.body().asString()));
}
@Test(description="代理人_获取指定中奖抽奖活动的参与人列表",priority = 23)
public void 代理人_获取指定中奖抽奖活动_参与人列表(){
Map<String, Object> params = new HashMap<String, Object>();
params.put("pageIndex",1);
params.put("pageSize",20);
params.put("scid",scid);
params.put("activityConfId",activityConfId);
Response response = network.getResponse(params, LOTTERRY_getDrawRecord);
boolean success = response.jsonPath().getBoolean("success");
Object data = response.jsonPath().getJsonObject("data");
Assert.assertTrue(success,network.message(params, LOTTERRY_getDrawRecord,"接口返回失败",response.body().asString()));
Assert.assertNotNull(data,network.message(params, LOTTERRY_getDrawRecord,"返回数据为空",response.body().asString()));
int size = response.jsonPath().getInt("data.list.size()");
Assert.assertTrue(size==2,network.message(params, LOTTERRY_getDrawRecord,"中奖奖品名称错误",response.body().asString()));
}
@Test(description="代理人_获取指定中奖抽奖活动的中奖人列表(已领奖)",priority = 24)
public void 代理人_获取指定中奖抽奖活动_中奖人已领奖列表(){
Map<String, Object> params = new HashMap<String, Object>();
params.put("pageIndex",1);
params.put("pageSize",20);
params.put("scid",scid);
params.put("activityConfId",activityConfId);
Response response = network.getResponse(params, LOTTERRY_getDrawWinningRecord);
boolean success = response.jsonPath().getBoolean("success");
Object data = response.jsonPath().getJsonObject("data");
Assert.assertTrue(success,network.message(params, LOTTERRY_getDrawWinningRecord,"接口返回失败",response.body().asString()));
Assert.assertNotNull(data,network.message(params, LOTTERRY_getDrawWinningRecord,"返回数据为空",response.body().asString()));
int size = response.jsonPath().getInt("data.list.size()");
int prizeState = response.jsonPath().getInt("data.list.get(0).prizeState");
Assert.assertTrue(size == 1,network.message(params, LOTTERRY_getDrawWinningRecord,"中奖奖品名称错误",response.body().asString()));
Assert.assertTrue(prizeState == 1,network.message(params, LOTTERRY_getDrawWinningRecord,"中奖奖品名称错误",response.body().asString()));
}
@Test(description="代理人_获取概率中奖抽奖活动的参与人列表",priority = 25)
public void 代理人_获取概率中奖抽奖活动的参与人列表(){
Map<String, Object> params = new HashMap<String, Object>();
params.put("pageIndex",1);
params.put("pageSize",20);
params.put("scid",rateScid);
params.put("activityConfId",rateConfId);
Response response = network.getResponse(params, LOTTERRY_getDrawRecord);
boolean success = response.jsonPath().getBoolean("success");
Object data = response.jsonPath().getJsonObject("data");
Assert.assertTrue(success,network.message(params, LOTTERRY_getDrawRecord,"接口返回失败",response.body().asString()));
Assert.assertNotNull(data,network.message(params, LOTTERRY_getDrawRecord,"返回数据为空",response.body().asString()));
int size = response.jsonPath().getInt("data.list.size()");
Assert.assertTrue(size==2,network.message(params, LOTTERRY_getDrawRecord,"中奖奖品名称错误",response.body().asString()));
}
@Test(description="代理人_获取概率中奖抽奖活动的中奖人列表(未领奖)",priority = 26)
public void 代理人_获取概率中奖抽奖活动_中奖人未领奖列表(){
Map<String, Object> params = new HashMap<String, Object>();
params.put("pageIndex",1);
params.put("pageSize",20);
params.put("scid",rateScid);
params.put("activityConfId",rateConfId);
Response response = network.getResponse(params, LOTTERRY_getDrawWinningRecord);
boolean success = response.jsonPath().getBoolean("success");
Object data = response.jsonPath().getJsonObject("data");
Assert.assertTrue(success,network.message(params, LOTTERRY_getDrawWinningRecord,"接口返回失败",response.body().asString()));
Assert.assertNotNull(data,network.message(params, LOTTERRY_getDrawWinningRecord,"返回数据为空",response.body().asString()));
int size = response.jsonPath().getInt("data.list.size()");
int prizeState = response.jsonPath().getInt("data.list.get(0).prizeState");
Assert.assertTrue(size == 1,network.message(params, LOTTERRY_getDrawWinningRecord,"中奖奖品名称错误",response.body().asString()));
Assert.assertTrue(prizeState == 0,network.message(params, LOTTERRY_getDrawWinningRecord,"中奖奖品名称错误",response.body().asString()));
}
}
package com.kjj.cases.assistant.markettools;
import com.kjj.bean.gift.Gift;
import com.kjj.bean.marketTools.Gift;
import com.kjj.cases.admin.Authorization;
import com.kjj.utils.JsonUtil;
import com.kjj.utils.NetworkUtils;
import io.restassured.response.Response;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
......@@ -17,7 +16,7 @@ import java.util.Map;
import static com.kjj.config.BasicConfig.*;
import static com.kjj.utils.ThreadSleepUtils.sleep;
public class greetingCrad implements Authorization{
public class GreetingCrad implements Authorization{
private static final NetworkUtils network = NetworkUtils.getInstance();
public String greetingCardId; // 红包贺卡的contentId
public String confId; // 红包贺卡配置的confId
......@@ -34,9 +33,8 @@ public class greetingCrad implements Authorization{
agentTku();
}
@Test(description = "营销工具聚合页内容",priority = 1)
public void 营销工具聚合页内容(){
sleep(5000);
@Test(description = "代理人_营销工具聚合页内容",priority = 1)
public void 代理人_营销工具聚合页内容(){
Response response = network.getResponse(GREETING_getMarketingToolArea);
boolean success = response.jsonPath().getBoolean("success");
Object data = response.jsonPath().getJsonObject("data");
......@@ -51,8 +49,8 @@ public class greetingCrad implements Authorization{
Assert.assertTrue(templateList>0,network.message(GREETING_getMarketingToolArea,"抽奖列表为空",response.body().asString()));
}
@Test(description = "获取趣味测试列表",priority = 2)
public void 获取趣味测试列表(){
@Test(description = "代理人_获取趣味测试列表",priority = 2)
public void 代理人_获取趣味测试列表(){
HashMap<String,Object> params = new HashMap<String,Object>();
params.put("pageSize", 5);
Response response = network.getResponse(params,GREETING_answerPageList);
......@@ -65,8 +63,8 @@ public class greetingCrad implements Authorization{
Assert.assertTrue(answerPageList>0,network.message(params,GREETING_answerPageList,"趣味测试列表为空",response.body().asString()));
}
@Test(description = "获取代理人vip信息",priority = 3)
public void 获取代理人vip信息(){
@Test(description = "代理人_获取代理人vip信息",priority = 3)
public void 代理人_获取代理人vip信息(){
Response response = network.getResponse(GREETING_getSellerVipInfo);
boolean success = response.jsonPath().getBoolean("success");
Object data = response.jsonPath().getJsonObject("data");
......@@ -77,8 +75,8 @@ public class greetingCrad implements Authorization{
Assert.assertTrue(isVip,network.message(GREETING_getSellerVipInfo,"代理人不是vip用户",response.body().asString()));
}
@Test(description = "检查访客登录信息",priority = 4)
public void 检查访客登录信息(){
@Test(description = "代理人_检查访客登录信息",priority = 4)
public void 代理人_检查访客登录信息(){
Response response = network.getResponse(GREETING_checkVisitor);
boolean success = response.jsonPath().getBoolean("success");
boolean data = response.jsonPath().getBoolean("data");
......@@ -86,8 +84,8 @@ public class greetingCrad implements Authorization{
Assert.assertTrue(data,network.message(GREETING_checkVisitor,"返回数据为失败",response.body().asString()));
}
@Test(description = "获取贺卡首页banner",priority = 5)
public void 获取贺卡首页banner(){
@Test(description = "代理人_获取贺卡首页banner",priority = 5)
public void 代理人_获取贺卡首页banner(){
Response response = network.getResponse(GREETING_banner);
boolean success = response.jsonPath().getBoolean("success");
Object data = response.jsonPath().getJsonObject("data");
......@@ -98,8 +96,8 @@ public class greetingCrad implements Authorization{
Assert.assertTrue(size>0,network.message(GREETING_banner,"贺卡列表为空",response.body().asString()));
}
@Test(description = "获取转发数量最高的贺卡",priority = 6)
public void 获取转发数量最高的贺卡(){
@Test(description = "代理人_获取转发数量最高的贺卡",priority = 6)
public void 代理人_获取转发数量最高的贺卡(){
Response response = network.getResponse(GREETING_allForward);
boolean success = response.jsonPath().getBoolean("success");
Object data = response.jsonPath().getJsonObject("data");
......@@ -113,19 +111,19 @@ public class greetingCrad implements Authorization{
greetingCardGiftId = response.jsonPath().getString("data.get(1).id");
}
@Test(description = "根据page获取当前页面的Tips",priority = 7)
public void 根据page获取当前页面的Tips(){
@Test(description = "代理人_根据page获取当前页面的Tips",priority = 7)
public void 代理人_根据page获取当前页面的Tips(){
HashMap<String,Object> params = new HashMap<String,Object>();
params.put("page", "greeting_card");
Response response = network.getResponse(params,GREETING_getTipsByPage);
Response response = network.getResponse(params,GETTIPSBYPAGE);
boolean success = response.jsonPath().getBoolean("success");
Object data = response.jsonPath().getJsonObject("data");
Assert.assertTrue(success,network.message(params,GREETING_getTipsByPage,"接口返回失败",response.body().asString()));
Assert.assertNotNull(data,network.message(params,GREETING_getTipsByPage,"返回数据为空",response.body().asString()));
Assert.assertTrue(success,network.message(params,GETTIPSBYPAGE,"接口返回失败",response.body().asString()));
Assert.assertNotNull(data,network.message(params,GETTIPSBYPAGE,"返回数据为空",response.body().asString()));
}
@Test(description = "按类型查询标签",priority = 8)
public void 按类型查询标签(){
@Test(description = "代理人_按类型查询标签",priority = 8)
public void 代理人_按类型查询标签(){
HashMap<String,Object> params = new HashMap<String,Object>();
params.put("tagType", "greeting_card");
Response response = network.getResponse(params,GREETING_findByType);
......@@ -138,8 +136,8 @@ public class greetingCrad implements Authorization{
Assert.assertTrue(size>0,network.message(params,GREETING_findByType,"贺卡列表为空",response.body().asString()));
}
@Test(description = "获取当前用户关注公众号类型",priority = 9)
public void 获取当前用户关注公众号类型(){
@Test(description = "代理人_获取当前用户关注公众号类型",priority = 9)
public void 代理人_获取当前用户关注公众号类型(){
Response response = network.getResponse(GREETING_oaSubscribeType);
boolean success = response.jsonPath().getBoolean("success");
int data = response.jsonPath().getInt("data");
......@@ -147,8 +145,8 @@ public class greetingCrad implements Authorization{
Assert.assertEquals(data,2,network.message(GREETING_oaSubscribeType,"返回数据错误",response.body().asString()));
}
@Test(description = "获取更多贺卡列表",priority = 10)
public void 获取更多贺卡列表(){
@Test(description = "代理人_获取更多贺卡列表",priority = 10)
public void 代理人_获取更多贺卡列表(){
HashMap<String,Object> params = new HashMap<String,Object>();
params.put("pageIndex", "1");
params.put("pageSize", "10");
......@@ -164,8 +162,8 @@ public class greetingCrad implements Authorization{
}
//获取贺卡详情页
@Test(description="获取贺卡详情页",priority = 11)
public void 获取贺卡详情页() {
@Test(description="代理人_获取贺卡详情页",priority = 11)
public void 代理人_获取贺卡详情页() {
//根据ContentId获取Scid
sleep(5000);
Map<String, Object> params = new HashMap<String, Object>();
......@@ -181,8 +179,8 @@ public class greetingCrad implements Authorization{
Assert.assertEquals(greetingCardId, id, network.message(params,GREETING_H5INFO,"获取贺卡页面失败",response.body().asString()));
}
@Test(description="贺卡是否可以正常访问",priority = 12)
public void 贺卡是否可以正常访问() {
@Test(description="代理人_贺卡是否可以正常访问",priority = 12)
public void 代理人_贺卡是否可以正常访问() {
Response response = network.getResponse(GREETING_check);
boolean success = response.jsonPath().getBoolean("success");
boolean data = response.jsonPath().getBoolean("data");
......@@ -190,8 +188,8 @@ public class greetingCrad implements Authorization{
Assert.assertTrue(data,network.message(GREETING_check,"返回数据为失败",response.body().asString()));
}
@Test(description="获取贺卡预览",priority = 13)
public void 获取贺卡预览() {
@Test(description="代理人_获取贺卡预览",priority = 13)
public void 代理人_获取贺卡预览() {
Map<String, Object> params = new HashMap<String, Object>();
params.put("scid",scid);
Response response = network.getResponse(params,GREETING_preView);
......@@ -206,8 +204,8 @@ public class greetingCrad implements Authorization{
Assert.assertEquals(sellerSignature,"吉吉",network.message(GREETING_preView,"贺卡分享者不是吉吉",response.body().asString()));
}
@Test(description="红包功能是否开启",priority = 14)
public void 红包功能是否开启() {
@Test(description="代理人_红包功能是否开启",priority = 14)
public void 代理人_红包功能是否开启() {
Response response = network.getResponse(GREETING_isRedpackEnable);
boolean success = response.jsonPath().getBoolean("success");
boolean data = response.jsonPath().getBoolean("data");
......@@ -215,8 +213,8 @@ public class greetingCrad implements Authorization{
Assert.assertTrue(data,network.message(GREETING_isRedpackEnable,"返回数据为失败",response.body().asString()));
}
@Test(description="判断当前用户是否是代理人自己",priority = 15)
public void 判断当前用户是否是代理人自己() {
@Test(description="代理人_判断当前用户是否是代理人自己",priority = 15)
public void 代理人_判断当前用户是否是代理人自己() {
Map<String, Object> params = new HashMap<String, Object>();
params.put("scid",scid);
Response response = network.getResponse(params,GREETING_self);
......@@ -226,8 +224,8 @@ public class greetingCrad implements Authorization{
Assert.assertTrue(data,network.message(params,GREETING_self,"返回数据为失败",response.body().asString()));
}
@Test(description="获取销售名片",priority = 16)
public void 获取销售名片() {
@Test(description="代理人_获取销售名片",priority = 16)
public void 代理人_获取销售名片() {
Map<String, Object> params = new HashMap<String, Object>();
params.put("scid",scid);
Response response = network.getResponse(params,GREETING_getInfoByScid);
......@@ -242,8 +240,8 @@ public class greetingCrad implements Authorization{
Assert.assertEquals(sellerName,"吉吉",network.message(params,GREETING_getInfoByScid,"用户不是吉吉",response.body().asString()));
}
@Test(description="获取代理人是否超过次数限制",priority = 17)
public void 获取代理人是否超过次数限制() {
@Test(description="代理人_获取代理人是否超过次数限制",priority = 17)
public void 代理人_获取代理人是否超过次数限制() {
Response response = network.getResponse(GREETING_checkLimit);
boolean success = response.jsonPath().getBoolean("success");
boolean data = response.jsonPath().getBoolean("data");
......@@ -251,8 +249,8 @@ public class greetingCrad implements Authorization{
Assert.assertFalse(data,network.message(GREETING_checkLimit,"返回数据为失败",response.body().asString()));
}
@Test(description="获取更多精彩贺卡",priority = 18)
public void 获取更多精彩贺卡() {
@Test(description="代理人_获取更多精彩贺卡",priority = 18)
public void 代理人_获取更多精彩贺卡() {
Map<String, Object> params = new HashMap<String, Object>();
params.put("scid",scid);
Response response = network.getResponse(params,GREETING_more);
......@@ -262,8 +260,8 @@ public class greetingCrad implements Authorization{
Assert.assertNotNull(data,network.message(params,GREETING_more,"返回数据为空",response.body().asString()));
}
@Test(description="保存默认的贺卡",priority = 19)
public void 保存默认的贺卡(){
@Test(description="代理人_保存默认的贺卡",priority = 19)
public void 代理人_保存默认的贺卡(){
Map<String, Object> params = new HashMap<String, Object>();
params.put("scid",scid);
params.put("createSource",1);
......@@ -274,8 +272,8 @@ public class greetingCrad implements Authorization{
Assert.assertNotNull(confId,network.message(params,GREETING_saveDefault,"返回数据为空",response.body().asString()));
}
@Test(description="获取H5分享信息",priority = 20)
public void 获取H5分享信息(){
@Test(description="代理人_获取H5分享信息",priority = 20)
public void 代理人_获取H5分享信息(){
Map<String, Object> params = new HashMap<String, Object>();
params.put("v",System.currentTimeMillis());
params.put("confId",confId);
......@@ -289,8 +287,8 @@ public class greetingCrad implements Authorization{
Assert.assertEquals(nickName,"吉吉",network.message(params,GREETING_H5SHARE,"分享者信息错误",response.body().asString()));
}
@Test(description="代理人获取红包配置详情",priority = 21)
public void 代理人获取红包配置详情(){
@Test(description="代理人_获取红包配置详情",priority = 21)
public void 代理人_获取红包配置详情(){
Map<String, Object> params = new HashMap<String, Object>();
params.put("confId",confId);
Response response = network.getResponse(params,GREETING_redPacketDetail);
......@@ -305,8 +303,8 @@ public class greetingCrad implements Authorization{
Assert.assertFalse(hasGiftConf,network.message(params,GREETING_redPacketDetail,"奖品配置信息错误",response.body().asString()));
}
@Test(description="贺卡配置生效",priority = 22)
public void 贺卡配置生效(){
@Test(description="代理人_贺卡配置生效",priority = 22)
public void 代理人_贺卡配置生效(){
Map<String, Object> params = new HashMap<String, Object>();
params.put("confId",confId);
Response response = network.postResponse(params,GREETING_effective);
......@@ -316,8 +314,8 @@ public class greetingCrad implements Authorization{
Assert.assertTrue(data,network.message(params,GREETING_effective,"返回数据为空",response.body().asString()));
}
@Test(description="获取祝福语列表",priority = 23)
public void 获取祝福语列表(){
@Test(description="代理人_获取祝福语列表",priority = 23)
public void 代理人_获取祝福语列表(){
Map<String, Object> params = new HashMap<String, Object>();
params.put("scid",scid);
Response response = network.getResponse(params,GREETING_spareBlessWordList);
......@@ -330,8 +328,8 @@ public class greetingCrad implements Authorization{
Assert.assertTrue(size>0,network.message(params,GREETING_list,"祝福语列表为空",response.body().asString()));
}
@Test(description="获取奖品配置信息",priority = 24)
public void 获取奖品配置信息(){
@Test(description="代理人_获取奖品配置信息",priority = 24)
public void 代理人_获取奖品配置信息(){
Map<String, Object> params = new HashMap<String, Object>();
params.put("confId",confId);
Response response = network.getResponse(params,GREETING_detail);
......@@ -344,8 +342,8 @@ public class greetingCrad implements Authorization{
Assert.assertEquals(id,null,network.message(params,GREETING_list,"奖品信息配置错误",response.body().asString()));
}
@Test(description="获取奖品列表",priority = 25)
public void 获取奖品列表(){
@Test(description="代理人_获取奖品列表",priority = 25)
public void 代理人_获取奖品列表(){
Map<String, Object> params = new HashMap<String, Object>();
params.put("pageIndex",1);
params.put("pageSize",25);
......@@ -363,8 +361,8 @@ public class greetingCrad implements Authorization{
}
@Test(description="修改贺卡内容及添加礼物",priority = 26)
public void 修改贺卡内容及添加礼物(){
@Test(description="代理人_修改贺卡内容及添加礼物",priority = 26)
public void 代理人_修改贺卡内容及添加礼物(){
//修改称呼、祝福语、签名、分享文案
Map<String, Object> params = new HashMap<String, Object>();
params.put("blessImageUrl","");
......@@ -434,8 +432,8 @@ public class greetingCrad implements Authorization{
Assert.assertEquals(giftName,gift.getGiftName(),network.message(params,GREETING_preView,"分享文案-副标题修改失败",response.body().asString()));
}
@Test(description="删除贺卡中的礼物",priority = 27)
public void 删除贺卡中的礼物(){
@Test(description="代理人_删除贺卡中的礼物",priority = 27)
public void 代理人_删除贺卡中的礼物(){
Map<String, Object> params = new HashMap<String, Object>();
params.put("confId",confId);
Response response = network.postResponse(params,GREETING_delete);
......@@ -456,8 +454,8 @@ public class greetingCrad implements Authorization{
Assert.assertFalse(hasConf,network.message(params,GREETING_redPacketDetail,"奖品配置信息错误",response.body().asString()));
}
@Test(description="塞红包",priority = 28)
public void 塞红包(){
@Test(description="代理人_塞红包",priority = 28)
public void 代理人_塞红包(){
Map<String, Object> params = new HashMap<String, Object>();
params.put("scid",scid);
params.put("confId",confId);
......@@ -485,8 +483,8 @@ public class greetingCrad implements Authorization{
Assert.assertTrue(hasConf,network.message(params,GREETING_redPacketDetail,"红包配置信息错误",response.body().asString()));
}
@Test(description="修改礼物编辑状态",priority = 29)
public void 修改礼物编辑状态(){
@Test(description="代理人_修改礼物编辑状态",priority = 29)
public void 代理人_修改礼物编辑状态(){
Map<String, Object> params = new HashMap<String, Object>();
params.put("confId",confId);
Response response = network.postResponse(params,GREETING_editState);
......@@ -496,8 +494,8 @@ public class greetingCrad implements Authorization{
Assert.assertTrue(data,network.message(params,GREETING_editState,"修改礼物编辑状态失败",response.body().asString()));
}
@Test(description="获取贺卡海报相关配置",priority = 30)
public void 获取贺卡海报相关配置(){
@Test(description="代理人_获取贺卡海报相关配置",priority = 30)
public void 代理人_获取贺卡海报相关配置(){
Map<String, Object> params = new HashMap<String, Object>();
String redirectUrl = HOST+"/kjy/mp/greeting?scid=" + scid + "&confId="+confId+"&access_source=53";
redirectUrl.replace(":","%3A");
......@@ -597,7 +595,7 @@ public class greetingCrad implements Authorization{
params.clear();
params.put("confId",giftConfId);
params.put("giftId",giftId);
params.put("totalNum",3);
params.put("totalNum",1);
response = network.postResponse(params,GREETING_save);
System.out.println(params.toString());
System.out.println(response.body().asString());
......@@ -657,7 +655,45 @@ public class greetingCrad implements Authorization{
Assert.assertTrue(result,network.message(params,GREETING_receive,"领取礼物失败",response.body().asString()));
}
@Test(description="代理人_获取已发出贺卡记录",priority = 35)
@Test(description="访客_礼物被领取完领取失败",priority = 35)
public void 访客_礼物被领取完领取失败(){
//切换为访客
userTku1();
//查看阅读记录
Map<String, Object> params = new HashMap<String, Object>();
params.put("scid",giftScid);
params.put("bizNo",giftConfId);
params.put("from",0);
Response response = network.getResponse(params,CONTENT_READ);
boolean success = response.jsonPath().getBoolean("success");
Object data = response.jsonPath().getJsonObject("data");
Assert.assertTrue(success,network.message(params,CONTENT_READ,"接口返回失败",response.body().asString()));
Assert.assertNotNull(data,network.message(params,CONTENT_READ,"获取访问贺卡记录失败",response.body().asString()));
//打开贺卡
params.clear();
params.put("scid",giftScid);
params.put("confId",giftConfId);
response = network.getResponse(params,GREETING_view);
success = response.jsonPath().getBoolean("success");
data = response.jsonPath().getJsonObject("data");
Assert.assertTrue(success,network.message(params,GREETING_view,"接口返回失败",response.body().asString()));
Assert.assertNotNull(data,network.message(params,GREETING_view,"接口返回数据为空",response.body().asString()));
//领取礼物
params.clear();
params.put("scid",giftScid);
params.put("phone","13412341234");
params.put("confId",giftConfId);
response = network.postResponse(params,GREETING_receive);
success = response.jsonPath().getBoolean("success");
boolean result = response.jsonPath().getBoolean("data");
Assert.assertTrue(success,network.message(params,GREETING_receive,"接口返回失败",response.body().asString()));
Assert.assertFalse(result,network.message(params,GREETING_receive,"领取礼物失败",response.body().asString()));
}
@Test(description="代理人_获取已发出贺卡记录",priority = 36)
public void 代理人_获取已发出贺卡记录(){
//切换为代理人
agentTku();
......@@ -672,7 +708,7 @@ public class greetingCrad implements Authorization{
Assert.assertNotNull(data,network.message(params,GREETING_confList,"返回记录为空",response.body().asString()));
}
@Test(description="代理人_获取已发出贺卡详情",priority = 36)
@Test(description="代理人_获取已发出贺卡详情",priority = 37)
public void 代理人_获取已发出贺卡详情(){
//切换为代理人
agentTku();
......@@ -701,11 +737,11 @@ public class greetingCrad implements Authorization{
receiveNum = response.jsonPath().getInt("data.receiveNum");
giftReceiveNum = response.jsonPath().getInt("data.giftReceiveNum");
Assert.assertEquals(receiveNum,1,network.message(params,GREETING_receiveDetail,"打开贺卡人数错误",response.body().asString()));
Assert.assertEquals(receiveNum,2,network.message(params,GREETING_receiveDetail,"打开贺卡人数错误",response.body().asString()));
Assert.assertEquals(giftReceiveNum,1,network.message(params,GREETING_receiveDetail,"领取礼物人数错误",response.body().asString()));
}
@Test(description="代理人_获取收下贺卡用户列表",priority = 37)
@Test(description="代理人_获取收下贺卡用户列表",priority = 38)
public void 代理人_获取收下贺卡用户列表(){
//红包贺卡-已收下贺卡
Map<String, Object> params = new HashMap<String, Object>();
......@@ -722,9 +758,18 @@ public class greetingCrad implements Authorization{
int size = response.jsonPath().getInt("data.list.size()");
Assert.assertEquals(size,1,network.message(params,GREETING_receiveList,"打开贺卡人数列表错误",response.body().asString()));
//礼物贺卡-已收下贺卡
params.put("confId",giftConfId);
response = network.getResponse(params,GREETING_receiveList);
success = response.jsonPath().getBoolean("success");
data = response.jsonPath().getJsonObject("data");
Assert.assertTrue(success,network.message(params,GREETING_receiveList,"接口返回失败",response.body().asString()));
Assert.assertNotNull(data,network.message(params,GREETING_receiveList,"返回数据为空",response.body().asString()));
size = response.jsonPath().getInt("data.list.size()");
Assert.assertEquals(size,2,network.message(params,GREETING_receiveList,"打开贺卡人数列表错误",response.body().asString()));
//礼物贺卡-已领取礼物
params.put("type",1);
params.put("confId",giftConfId);
response = network.getResponse(params,GREETING_receiveList);
success = response.jsonPath().getBoolean("success");
data = response.jsonPath().getJsonObject("data");
......@@ -734,9 +779,4 @@ public class greetingCrad implements Authorization{
size = response.jsonPath().getInt("data.list.size()");
Assert.assertEquals(size,1,network.message(params,GREETING_receiveList,"领取礼物人数列表错误",response.body().asString()));
}
@AfterClass
public void teardown(){
apiCount += 37;
}
}
package com.kjj.cases.assistant.pay;
import com.kjj.cases.admin.Authorization;
import com.kjj.utils.BaseUtils;
import io.restassured.response.Response;
import org.apache.commons.lang3.StringUtils;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import java.util.HashMap;
import java.util.Map;
import static com.kjj.config.BasicConfig.*;
import static com.kjj.config.BasicConfig.PAY_CALLOUT;
public class Cashback implements Authorization {
@BeforeClass
public void setUp() {
userTku();
}
public String comboId;
@Test(description = "用户绑定分享关系",priority = 1)
public void 用户绑定分享关系() {
Map<String, Object> Params = new HashMap<String, Object>();
Params.put("fromStr",1);
Params.put("inviterSid",2991);
Params.put("accessSource",22);
Response response = network.getResponse(Params,PAY_distribute);
System.out.println(response.body().asString());
boolean data=response.jsonPath().getBoolean("data");
Assert.assertTrue(data,network.message(PAY_distribute,"用户绑定失败",response.body().asString()));
}
@Test (description = "用户支付后是否有180天打卡权限",priority = 2)
public void 用户支付后是否有180天打卡权限() {
Response response = network.getResponse(PAY_clockPayInfo);
System.out.println(response.body().asString());
boolean isClockPay=response.jsonPath().getBoolean("data.isClockPay");
Assert.assertFalse(isClockPay,network.message(PAY_clockPayInfo,"有180天打卡权限",response.body().asString()));
}
@Test (description = "返现用户付费_微信支付后回调",priority = 3)
public void 返现用户付费_微信支付后回调() {
//获取付费价格
Response actualPayMoneyResponse = network.getResponse(PAY_combo);
System.out.println(actualPayMoneyResponse.body().asString());
comboId=actualPayMoneyResponse.jsonPath().getString("data[0].id");
Assert.assertNotNull(comboId,network.message(PAY_combo,"套餐ID为null",actualPayMoneyResponse.body().asString()));
String actualPayMoney = actualPayMoneyResponse.jsonPath().getString("data[0].actualPayMoney");
Assert.assertEquals(actualPayMoney,"365",network.message(PAY_combo,"获取付费价格:价格不是365",actualPayMoneyResponse.body().asString()));
//创建支付
Map<String, Object> payParams = new HashMap<String, Object>();
payParams.put("userVersion", 2); // 1 通用版 2 保险版
payParams.put("comboId", comboId);
payParams.put("oaId", "1");
payParams.put("paySource", "2");
Response response = network.postResponse(payParams, PAY_create);
String tradeNo = response.jsonPath().getString("data.tradeNo");
// mock微信回调失败
Map<String, Object> callbackParams = new HashMap<String, Object>();
callbackParams.put("tradeNo", tradeNo);
callbackParams.put("payResult", true);
callbackParams.put("payTradeNo", "test");
response = network.getResponse(callbackParams, PAY_CALLOUT);
boolean result = response.jsonPath().getBoolean("data");
response.body().prettyPrint();
Assert.assertTrue(result, network.message(callbackParams, PAY_CALLOUT, "mock微信支付回调成功,但我们订单处理失败", response.body().asString()));
}
@Test(description = "获取用户版本信息",priority = 4)
public void 获取用户版本信息() {
agentTku();
Response response = network.getResponse(USER_INFO);
System.out.println(response.body().asString());
boolean isInsuranceVersion=response.jsonPath().getBoolean("data.isInsuranceVersion");
Assert.assertTrue(isInsuranceVersion,network.message(USER_INFO,"不是保险版本",response.body().asString()));
}
@Test(description = "邀请的好友列表",priority = 5)
public void 邀请的好友列表() {
agentTku();
Map<String, Object> Params = new HashMap<String, Object>();
Params.put("distributionListType",1);
Params.put("pageIndex",1);
Params.put("pageSize",10);
Response response = network.getResponse(Params,PAY_distributionList);
System.out.println(response.body().asString());
Object list=response.jsonPath().getJsonObject("data.list");
Assert.assertNotNull(list,network.message(PAY_distributionList,"待付款好友列表为null",response.body().asString()));
Params.put("distributionListType",2);
response = network.getResponse(Params,PAY_distributionList);
System.out.println(response.body().asString());
Object list1=response.jsonPath().getJsonObject("data.list");
Assert.assertNotNull(list1,network.message(PAY_distributionList,"已付款好友列表为null",response.body().asString()));
}
@Test(description = "代理人账户信息",priority = 6)
public void 代理人账户信息() {
agentTku();
Response response = network.getResponse(PAY_accInfo);
System.out.println(response.body().asString());
double balance=Double.parseDouble(response.jsonPath().getString("data.balance"));
Assert.assertTrue(balance>0,network.message(PAY_accInfo,"当前余额为0",response.body().asString()));
double totalPromotionEarnings=Double.parseDouble(response.jsonPath().getString("data.totalPromotionEarnings"));
Assert.assertTrue(totalPromotionEarnings>0,network.message(PAY_accInfo,"总收益为0",response.body().asString()));
double settleMoney=Double.parseDouble(response.jsonPath().getString("data.settleMoney"));
Assert.assertTrue(settleMoney>0,network.message(PAY_accInfo,"待结算金额为0",response.body().asString()));
int canWithdraw=response.jsonPath().getInt("data.canWithdraw");
Assert.assertTrue(canWithdraw==1,network.message(PAY_accInfo,"不可以提现",response.body().asString()));
int minWithdrawMoney=response.jsonPath().getInt("data.minWithdrawMoney");
Assert.assertTrue(minWithdrawMoney==1,network.message(PAY_accInfo,"最小可提现金额不等于1",response.body().asString()));
int maxWithdrawMoney=response.jsonPath().getInt("data.maxWithdrawMoney");
Assert.assertTrue(maxWithdrawMoney==5000,network.message(PAY_accInfo,"最大可提现金额不等于5000",response.body().asString()));
}
@Test(description = "代理人账户明细",priority = 7)
public void 代理人账户明细() {
agentTku();
Map<String, Object> Params = new HashMap<String, Object>();
Params.put("type", 1);
Params.put("pageNo", 1);
Params.put("pageSize", 20);
Response response = network.getResponse(Params, PAY_accDetail);
System.out.println(response.body().asString());
int changeType = response.jsonPath().getInt("data[0].changeType");
Assert.assertTrue(changeType ==1, network.message(PAY_accDetail, "提现记录为null", response.body().asString()));
Params.put("type", 2);
response = network.getResponse(Params, PAY_accDetail);
System.out.println(response.body().asString());
int changeType1 = response.jsonPath().getInt("data[0].changeType");
Assert.assertTrue(changeType1 ==2, network.message(PAY_accDetail, "收益明细为null", response.body().asString()));
}
@Test(description = "代理人提现",priority = 8)
public void 代理人提现() {
agentTku();
Map<String, Object> Params = new HashMap<String, Object>();
Params.put("withdrawMoney", 1);
Response response = network.getResponse(Params, PAY_withdraw);
System.out.println(response.body().asString());
boolean data = response.jsonPath().getBoolean("data");
Assert.assertTrue(data, network.message(PAY_withdraw, "提现失败", response.body().asString()));
}
}
package com.kjj.cases.basics;
package com.kjj.cases.assistant.pay;
import static com.kjj.config.BasicConfig.*;
import static io.restassured.RestAssured.given;
import com.kjj.cases.admin.Authorization;
import com.kjj.utils.BaseUtils;
import com.kjj.utils.NetworkUtils;
import io.restassured.response.Response;
import org.apache.commons.lang3.RandomUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.testng.Assert;
import org.testng.annotations.*;
import org.testng.annotations.Test;
import java.io.IOException;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
public class Pay {
private static final NetworkUtils network = NetworkUtils.getInstance();
public class Pay implements Authorization {
@BeforeClass
public static void setUp() {
// 创建用户 并传到network里
AGENT_TKU = BaseUtils.createTku();
network.agentCookies.put("tku",AGENT_TKU);
System.out.println("代理人tku:"+AGENT_TKU);
// 获取访客tku
VISITOR_TKU = BaseUtils.getTku(VISITOR_USERID);
System.out.println("访客tku:"+VISITOR_TKU);
public void setUp() {
BaseUtils.ssoLogin();
agentTku();
}
public String comboId;
public long id;
public String promotionCode;
@Test (description = "默认付费_付费页",priority = 1) //priority 方法执行优先级
public void 默认付费_付费页() throws IOException {
public void 默认付费_付费页() {
//付款中间页判断
Response response = network.getResponse(PAY_GETMIDDLEDETAIL);
Response response = network.getResponse(PAY_getMiddleDetail);
int skipType = response.jsonPath().getInt("data.skipType");
System.out.println(skipType);
Assert.assertEquals(skipType,2,network.message(PAY_GETMIDDLEDETAIL,"付款中间页:不是2020新版",response.body().asString()));
System.out.println(response.body().asString());
Assert.assertEquals(skipType,2,network.message(PAY_getMiddleDetail,"付款中间页:不是2020新版",response.body().asString()));
//会员类型版本判断
Map<String, Object> params = new HashMap<String, Object>();
params.put("t",System.currentTimeMillis());
response = network.getResponse(params, VERSION_INFO);
response = network.getResponse(params, version_info);
System.out.println(response.body().asString());
int userVersion = response.jsonPath().getInt("data.find {it.openType == 1}.userVersion"); // 找出开启状态的版本类型 1为通用版 2为保险版
Assert.assertEquals(userVersion,2,network.message(params, VERSION_INFO,"会员类型版本判断:判断错误,此版本为通用版",response.body().asString()));
Assert.assertEquals(userVersion,2,network.message(params, version_info,"会员类型版本判断:判断错误,此版本为通用版",response.body().asString()));
//获取当前用户可用优惠码
response = network.getResponse(params,PAY_GETPROMOCODE);
// String promoCode = response.jsonPath().getString("data");
boolean success =response.jsonPath().getBoolean("success");
Assert.assertTrue(success, network.message(params,PAY_GETPROMOCODE,"是否优惠判断:判断错误,当前有优惠",response.body().asString()));
response= network.getResponse(params,PAY_getPromoCode);
String promoCode = response.jsonPath().getString("data");
System.out.println(response.body().asString());
Assert.assertNull(promoCode, network.message(params,PAY_getPromoCode,"是否优惠判断:判断错误,当前有优惠",response.body().asString()));
//获取付费价格
// Response actualPayMoneyResponse = network.getResponse(PAY_COMBOLIST);
// String actualPayMoney = actualPayMoneyResponse.jsonPath().getString("data[0].actualPayMoney");
// Assert.assertEquals(actualPayMoney,"586",network.message(PAY_COMBOLIST,"获取付费价格:价格不是586"));
Response actualPayMoneyResponse = network.getResponse(PAY_combo);
System.out.println(actualPayMoneyResponse.body().asString());
comboId=actualPayMoneyResponse.jsonPath().getString("data[0].id");
Assert.assertNotNull(comboId,network.message(PAY_combo,"套餐ID为null",actualPayMoneyResponse.body().asString()));
String actualPayMoney = actualPayMoneyResponse.jsonPath().getString("data[0].actualPayMoney");
Assert.assertEquals(actualPayMoney,"365",network.message(PAY_combo,"获取付费价格:价格不是365",actualPayMoneyResponse.body().asString()));
}
@Test (description = "默认付费_待支付",priority = 2)
public void 默认付费_待支付() {
//创建支付
Map<String, Object> payParams = new HashMap<String, Object>();
payParams.put("userVersion",1);
payParams.put("comboId","Kj21MTU");
payParams.put("comboId",comboId);
payParams.put("oaId","1");
payParams.put("paySource","2");
payParams.put("sellerFrom","");
Response response = network.postResponse(payParams,PAY_ORDERCREATE);
Response response = network.postResponse(payParams,PAY_create);
System.out.println(response.body().asString());
String appId = response.jsonPath().getString("data.appId");
Assert.assertEquals(appId,"wxcb8c36279dd7dff2",network.message(payParams, PAY_ORDERCREATE,"拉起支付:拉起微信支付失败",response.body().asString())); //判断返回的微信调起参数中appId是否正确
Assert.assertEquals(appId,"wxcb8c36279dd7dff2",network.message(payParams, PAY_create,"拉起支付:拉起微信支付失败",response.body().asString())); //判断返回的微信调起参数中appId是否正确
}
@Test (description = "默认付费_取消支付",priority = 3)
public void 默认付费_取消支付() throws IOException {
public void 默认付费_取消支付() {
//创建支付
Map<String, Object> payParams = new HashMap<String, Object>();
payParams.put("userVersion",1);
payParams.put("comboId","Kj21MTU");
payParams.put("comboId",comboId);
payParams.put("oaId","1");
payParams.put("paySource","2");
payParams.put("sellerFrom","");
Response response = network.postResponse(payParams,PAY_ORDERCREATE);
Response response = network.postResponse(payParams,PAY_create);
String tradeNo = response.jsonPath().getString("data.tradeNo");
//会员类型版本判断
Map<String, Object> cancelParams = new HashMap<String, Object>();
cancelParams.put("tradeNo",tradeNo);
response = network.getResponse(cancelParams,PAY_ORDERCANCEL);
response = network.getResponse(cancelParams,PAY_cancel);
String result = response.jsonPath().getString("desc");
Assert.assertEquals(result,"OK",network.message(cancelParams, PAY_ORDERCANCEL,"取消支付:取消支付失败",response.body().asString())); //判断返回的微信调起参数中appId是否正确
Assert.assertEquals(result,"OK",network.message(cancelParams, PAY_cancel,"取消支付:取消支付失败",response.body().asString())); //判断返回的微信调起参数中appId是否正确
//取消付款后的订单查询
Map<String, Object> statusParams = new HashMap<String, Object>();
statusParams.put("tradeNo",tradeNo);
response = network.getResponse(statusParams,PAY_status);
System.out.println(response.body().asString());
int data = response.jsonPath().getInt("data");
Assert.assertTrue(data==5,network.message(statusParams, PAY_status,"取消支付:订单状态不对",response.body().asString()));
}
@Test (description = "默认付费_切换会员类型为保险版",priority = 4)
public void 默认付费_切换为保险版会员类型() throws IOException {
public void 默认付费_切换为保险版会员类型(){
//会员类型版本判断
Map<String, Object> params = new HashMap<String, Object>();
params.put("t",System.currentTimeMillis());
Response response = network.getResponse(params,VERSION_INFO);
Response response = network.getResponse(params,version_info);
int userVersion = response.jsonPath().getInt("data.find {it.openType == 1}.userVersion"); // 找出开启状态的版本类型
int changeVersion = userVersion == 1 ? 2 : 1; // 判断当前开启的版本,如果当前版本是1,则改为2,反之;
//切换版本
Map<String, Object> versionParams = new HashMap<String, Object>();
versionParams.put("targetVersion",changeVersion);
response = network.postResponse(versionParams,PAY_VERSIONEXCHANGE);
response = network.postResponse(versionParams,PAY_exchange);
String result = response.jsonPath().getString("desc");
Assert.assertEquals(result,"OK",network.message(versionParams,PAY_VERSIONEXCHANGE,"会员类型切换:切换失败",response.body().asString())); //判断返回的微信调起参数中appId是否正确
Assert.assertEquals(result,"OK",network.message(versionParams,PAY_exchange,"会员类型切换:切换失败",response.body().asString())); //判断返回的微信调起参数中appId是否正确
//会员类型再次判断
params.put("t",System.currentTimeMillis());
response = network.getResponse(params,VERSION_INFO);
response = network.getResponse(params,version_info);
userVersion = response.jsonPath().getInt("data.find {it.openType == 1}.userVersion"); // 找出开启状态的版本类型
Assert.assertEquals(userVersion,changeVersion,network.message(params, VERSION_INFO,"会员类型版本判断:判断错误,此版本为尊享版",response.body().asString()));
Assert.assertEquals(userVersion,changeVersion,network.message(params, version_info,"会员类型版本判断:判断错误,此版本为尊享版",response.body().asString()));
}
@Test (description = "用户是否满足续费条件",priority = 5)
public void 用户是否满足续费条件 () {
Response response = network.getResponse(PAY_isRenewCondition);
System.out.println(response.body().asString());
boolean data = response.jsonPath().getBoolean("data");
Assert.assertFalse(data,network.message(PAY_isRenewCondition,"不满足续费条件",response.body().asString()));
}
// @Test (description = "优惠券付费",priority = 5)
// public void 优惠券付费 () throws IOException {
// String promotionCode = BaseUtils.getPromotionCode();
// Map<String, Object> params = new HashMap<String, Object>();
// params.put("code",promotionCode);
// Response response = network.getResponse(params,PAY_COMBOLIST);
//
// Map<String, Object> payParams = new HashMap<String, Object>();
// payParams.put("userVersion",2); // 1 通用版 2 保险版
// payParams.put("comboId","Kj21MTU");
// payParams.put("oaId","1");
// payParams.put("paySource","101004");
// payParams.put("sellerFrom","");
// payParams.put("promotionCode",promotionCode);
//
// response = network.postResponse(payParams,PAY_ORDERCREATE);
// String tradeNo = response.jsonPath().getString("data.tradeNo");
// response.body().prettyPrint();
//
// // mock微信回调成功
// Map<String, Object> callbackParams = new HashMap<String, Object>();
// callbackParams.put("tradeNo",tradeNo);
// callbackParams.put("payResult",true);
// callbackParams.put("payTradeNo","test");
// response = network.getResponse(callbackParams,PAY_CALLOUT);
// boolean result = response.jsonPath().getBoolean("data");
// response.body().prettyPrint();
// Assert.assertTrue(result,network.message(callbackParams,PAY_CALLOUT,"mock微信支付回调成功,但我们订单处理失败",response.body().asString()));
// }
@Test (description = "默认付费_微信支付后回调",priority = 6)
public void 默认付费_微信支付后回调() throws IOException {
@Test (description = "创建优惠码",priority = 6)
public void 创建优惠码 () {
//优惠码类型列表
Response response=network.getResponse(MANAGER_typeList);
System.out.println(response.body().asString());
Object data=response.jsonPath().getJsonObject("data");
Assert.assertNotNull(data,network.message(MANAGER_typeList,"优惠码类型列表为null",response.body().asString()));
//创建优惠码
Map<String, Object> Params = new HashMap<String, Object>();
Params.put("comboId",1);
Params.put("codeTotal",10);
Params.put("startTime",System.currentTimeMillis());
Params.put("deadline",System.currentTimeMillis() + 1000*60*60*24*30L);
Params.put("price",365);
Params.put("promotionType",5);
Params.put("remark","优惠码"+ RandomUtils.nextInt(1, 100));
Params.put("userVersion",2);
Params.put("validityDuration",12);
response = network.postResponse(Params,MANAGER_batchCreateV2);
System.out.println( response.body().asString());
id=response.jsonPath().getLong("data.id");
Assert.assertNotNull(id,network.message(MANAGER_batchCreateV2,"优惠码批次ID未获取到",response.body().asString()));
//优惠码列表
Map<String, Object> codeListParam = new HashMap<String, Object>();
codeListParam.put("batchId",id);
codeListParam.put("promotionCodeStatus",0); //0 未使用
codeListParam.put("pageIndex",1);
codeListParam.put("pageSize",20);
response =network.getResponse(codeListParam,MANAGER_codeList);
promotionCode=response.jsonPath().getString("data.list[0].promotionCode");
}
@Test (description = "优惠券付费",priority = 7)
public void 优惠券付费 () {
Map<String, Object> payParams = new HashMap<String, Object>();
payParams.put("comboId",comboId);
payParams.put("promotionCode",promotionCode);
Response response = network.postResponse(payParams,PAY_create);
System.out.println( response.body().asString());
String tradeNo = response.jsonPath().getString("data.tradeNo");
// mock微信回调成功
Map<String, Object> callbackParams = new HashMap<String, Object>();
callbackParams.put("tradeNo",tradeNo);
callbackParams.put("payResult",true);
callbackParams.put("payTradeNo","test");
response= network.getResponse(callbackParams,PAY_CALLOUT);
boolean result = response.jsonPath().getBoolean("data");
response.body().prettyPrint();
Assert.assertTrue(result,network.message(callbackParams,PAY_CALLOUT,"mock微信支付回调成功,但我们订单处理失败",response.body().asString()));
}
@Test (description = "默认付费_微信支付后回调",priority = 8)
public void 默认付费_微信支付后回调() {
//创建支付
Map<String, Object> payParams = new HashMap<String, Object>();
payParams.put("userVersion",2); // 1 通用版 2 保险版
payParams.put("comboId","Kj21MTU");
payParams.put("comboId",comboId);
payParams.put("oaId","1");
payParams.put("paySource","2");
payParams.put("sellerFrom","");
Response response = network.postResponse(payParams,PAY_ORDERCREATE);
Response response = network.postResponse(payParams,PAY_create);
String tradeNo = response.jsonPath().getString("data.tradeNo");
// mock微信回调失败
......@@ -169,31 +225,40 @@ public class Pay {
Assert.assertTrue(result,network.message(callbackParams,PAY_CALLOUT,"mock微信支付回调失败,但我们订单处理也失败",response.body().asString()));
// mock微信回调成功
response = network.postResponse(payParams,PAY_ORDERCREATE);
response = network.postResponse(payParams,PAY_create);
tradeNo = response.jsonPath().getString("data.tradeNo");
callbackParams.put("tradeNo",tradeNo);
callbackParams.put("payResult",true);
response = network.getResponse(callbackParams,PAY_CALLOUT);
result = response.jsonPath().getBoolean("data");
Assert.assertTrue(result,network.message(callbackParams,PAY_CALLOUT,"mock微信支付回调成功,但我们订单处理失败",response.body().asString()));
//查询订单状态
Map<String, Object> statusParams = new HashMap<String, Object>();
statusParams.put("tradeNo",tradeNo);
response = network.getResponse(statusParams,PAY_status);
System.out.println(response.body().asString());
int data = response.jsonPath().getInt("data");
Assert.assertTrue(data==3,network.message(statusParams, PAY_status,"支付成功的订单状态不对",response.body().asString()));
// 检查会员开通结果
response = network.getResponse(USER_INFO);
boolean isVip = response.jsonPath().getBoolean("data.vipValid");
Assert.assertTrue(isVip,network.message(USER_INFO,"微信支付成功,但是接口返回还是非会员状态",response.body().asString()));
// 检查会员版本类型
response = network.getResponse(VERSION_INFO);
response = network.getResponse(version_info);
int userVersion = response.jsonPath().getInt("data.find {it.openType == 1}.userVersion"); // 找出开启状态的版本类型 1为通用版 2为保险版
Assert.assertEquals(userVersion,2,network.message(VERSION_INFO,"会员类型版本判断:判断错误,此版本为通用版",response.body().asString()));
Assert.assertEquals(userVersion,2,network.message(version_info,"会员类型版本判断:判断错误,此版本为通用版",response.body().asString()));
// 重复提交
response = network.postResponse(payParams,PAY_ORDERCREATE);
response = network.postResponse(payParams,PAY_create);
tradeNo = response.jsonPath().getString("data.tradeNo");
System.out.println(tradeNo);
}
}
}
package com.kjj.cases.assistant.whoSawMe;
import com.kjj.cases.admin.Authorization;
import com.kjj.config.BasicConfig;
import com.kjj.utils.BaseUtils;
import io.restassured.response.Response;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import static com.kjj.config.BasicConfig.BOSS_EDITCONFIG;
// 谁看过我模块测试前执行一次代理人转发素材及访客访问和产生线索
public class ForwardAndRead implements Authorization {
private Response response;
private Map<String, Object> param;
private String articleScId;
private Long sellerId;
private String visitId;
private String insuranceId;
@BeforeClass
public void setUp() throws IOException{
agentTku();
BaseUtils.ssoLogin();
}
// 代理人转发素材
@Test(description = "代理人转发文章", priority = 1)
public void 转发文章() throws IOException{
articleScId = getContentScId(BasicConfig.ARTICLE_CONTENTID); // 获取文章scId
param = new HashMap<>();
param.put("scId", articleScId);
param.put("forwardType", 1);
response = network.getResponse(param, BasicConfig.FORWARD);
Assert.assertTrue(response.jsonPath().getBoolean("success"), network.message(param, BasicConfig.FORWARD, "接口请求失败", response.body().asString()));
boolean data = response.jsonPath().getBoolean("data");
Assert.assertTrue(data, network.message(param, BasicConfig.FORWARD, "转发素材失败", response.body().asString()));
}
@Test(description = "代理人转发名片", priority = 2)
public void 转发名片() throws IOException{
// 获取名片scid
String scId = network.getResponse(BasicConfig.SELLERCARD_topOfDetail).jsonPath().getString("data.scid");
param = new HashMap<>();
param.put("scId", scId);
param.put("forwardType", 1);
response = network.getResponse(param, BasicConfig.FORWARD);
Assert.assertTrue(response.jsonPath().getBoolean("success"), network.message(param, BasicConfig.FORWARD, "接口请求失败", response.body().asString()));
boolean forwardResult = response.jsonPath().getBoolean("data");
Assert.assertTrue(forwardResult, network.message(param, BasicConfig.FORWARD, "转发名片失败", response.body().asString()));
}
// 访客访问素材及产生线索
@Test(description = "访客阅读文章", priority = 3)
public void 访客阅读文章() throws IOException{
sellerId = (Long) getUserInfo(BasicConfig.AGENT_TKU).get("sellerId");
network.agentCookies.put("tku", BasicConfig.VISITOR_TKU);
param = new HashMap<>();
param.put("scid", articleScId);
param.put("fromUserId", sellerId);
param.put("cancelPush", false);
param.put("visitPath", 0);
response = network.getResponse(param, BasicConfig.CONTENT_READ);
Assert.assertTrue(response.jsonPath().getBoolean("success"), network.message(param, BasicConfig.CONTENT_READ, "接口调用失败", response.body().asString()));
visitId = response.jsonPath().getString("data.visitId");
Assert.assertNotNull(visitId, network.message(param, BasicConfig.CONTENT_READ, "visitId为空", response.body().asString()));
}
@Test(description = "访客领取赠险", priority = 4)
public void 领取赠险() throws IOException{
// 获取赠险insuranceId
param = new HashMap<>();
param.put("scid", articleScId);
response = network.getResponse(param, BasicConfig.SELLERCARD_RECOMMENDLISTV3);
Assert.assertTrue(response.jsonPath().getBoolean("success"), network.message(param, BasicConfig.SELLERCARD_RECOMMENDLISTV3, "接口调用失败", response.body().asString()));
insuranceId = response.jsonPath().getString("data.insuranceVos[0].id");
// 领取赠险
param = new HashMap<>();
param.put("clueTypeName", "WELFARE_INSURANCE");
param.put("insuranceId", insuranceId);
param.put("locationSource", 1);
param.put("scId", articleScId);
param.put("sourceId", articleScId);
param.put("sourceType", 1);
response = network.postResponse(param, BasicConfig.SELLERCARD_SENDPUSHFORSCAN);
Assert.assertTrue(response.jsonPath().getBoolean("success"), network.message(param, BasicConfig.SELLERCARD_SENDPUSHFORSCAN, "接口调用失败", response.body().asString()));
String data = response.jsonPath().getString("data");
Assert.assertEquals(data, "success", network.message(param, BasicConfig.SELLERCARD_SENDPUSHFORSCAN, "领取赠险失败", response.body().asString()));
}
@Test(description = "访客转发文章", priority = 5)
public void 访客转发文章() throws IOException{
param = new HashMap<>();
param.put("scId", articleScId);
param.put("visitId", visitId);
param.put("forwardType", 1);
response = network.getResponse(param, BasicConfig.FORWARD);
Assert.assertTrue(response.jsonPath().getBoolean("success"), network.message(param, BasicConfig.FORWARD, "接口调用失败", response.body().asString()));
boolean data = response.jsonPath().getBoolean("data");
Assert.assertTrue(data, network.message(param, BasicConfig.FORWARD, "访客转发素材失败", response.body().asString()));
}
@Test(description = "二度访客阅读文章", priority = 6)
public void 二度访客阅读文章() throws IOException{
Long fromUserId = decodeTku(BasicConfig.VISITOR_TKU).get("sellerId");
network.agentCookies.put("tku", BasicConfig.VISITOR1_TKU); // 切换二度访客
param = new HashMap<>();
param.put("scid", articleScId);
param.put("fromUserId", fromUserId);
param.put("cancelPush", false);
param.put("visitPath", 0);
response = network.getResponse(param, BasicConfig.CONTENT_READ);
Assert.assertTrue(response.jsonPath().getBoolean("success"), network.message(param, BasicConfig.CONTENT_READ, "接口调用失败", response.body().asString()));
}
@Test(description = "二度访客领取赠险", priority = 7)
public void 二度访客领取赠险() throws IOException{
param = new HashMap<>();
param.put("clueTypeName", "WELFARE_INSURANCE");
param.put("insuranceId", insuranceId);
param.put("locationSource", 1);
param.put("scId", articleScId);
param.put("sourceId", articleScId);
param.put("sourceType", 1);
response = network.postResponse(param, BasicConfig.SELLERCARD_SENDPUSHFORSCAN);
Assert.assertTrue(response.jsonPath().getBoolean("success"), network.message(param, BasicConfig.SELLERCARD_SENDPUSHFORSCAN, "接口调用失败", response.body().asString()));
String data = response.jsonPath().getString("data");
Assert.assertEquals(data, "success", network.message(param, BasicConfig.SELLERCARD_SENDPUSHFORSCAN, "领取赠险失败", response.body().asString()));
}
// 通过素材contentId获取线索员文章scId
public String getContentScId(String contentId){
param = new HashMap<>();
param.put("contentId", contentId);
response = network.getResponse(param, BasicConfig.GETSCID);
Assert.assertTrue(response.jsonPath().getBoolean("success"), network.message(param, BasicConfig.GETSCID, "接口请求失败", response.body().asString()));
String contentScid = response.jsonPath().getString("data");
Assert.assertNotNull(contentScid, network.message(param, BasicConfig.GETSCID, "获取scid失败", response.body().asString()));
return contentScid;
}
// 获取用户信息
public Map<String, Object> getUserInfo(String userTku){
network.agentCookies.put("tku", userTku);
response = network.getResponse(BasicConfig.USER_INFO);
Assert.assertTrue(response.jsonPath().getBoolean("success"), network.message(BasicConfig.USER_INFO, "接口调用失败", response.body().asString()));
String wxName = response.jsonPath().getString("data.wxName");
Long sellerId = response.jsonPath().getLong("data.sellerId");
Long userId = response.jsonPath().getLong("data.userId");
Map<String, Object> infos = new HashMap<>();
infos.put("wxName", wxName);
infos.put("sellerId", sellerId);
infos.put("userId", userId);
network.agentCookies.put("tku", BasicConfig.AGENT_TKU);
return infos;
}
// 解密tku
public HashMap<String, Long> decodeTku(String tku){
// 登陆管理后台
param = new HashMap<>();
param.put("tku", tku);
response = network.getResponse(param, BasicConfig.MANAGER_TKU_DECODE);
Assert.assertTrue(response.jsonPath().getBoolean("success"), network.message(param, BasicConfig.MANAGER_TKU_DECODE, "接口请求失败", response.body().asString()));
Long userId = response.jsonPath().getLong("data.userId");
Long sellerId = response.jsonPath().getLong("data.sellerId");
Assert.assertNotNull(userId, network.message(param, BasicConfig.MANAGER_TKU_DECODE, "获取userId失败", response.body().asString()));
Assert.assertNotNull(sellerId, network.message(param, BasicConfig.MANAGER_TKU_DECODE, "获取sellerId失败", response.body().asString()));
HashMap<String, Long> result = new HashMap<>();
result.put("userId", userId);
result.put("sellerId", sellerId);
return result;
}
// 加密sellerId
public String encodeId(Long Id){
// 登陆管理后台
param = new HashMap<>();
param.put("code", Id);
response = network.getResponse(param, BasicConfig.MANAGER_ID_ENCODE);
String idEncode = response.jsonPath().getString("data");
Assert.assertNotNull(idEncode, network.message(param, BasicConfig.MANAGER_ID_ENCODE, "加密sellerId失败", response.body().asString()));
return idEncode;
}
// 关闭数据看板演示数据
public void closeDemoData() throws IOException{
param = new HashMap<>();
param.put("configKey", "boss_board_demon_switch");
param.put("configValue", false);
response = network.postResponse(param, BOSS_EDITCONFIG);
boolean data = response.jsonPath().getBoolean("data");
Assert.assertTrue(response.jsonPath().getBoolean("success"), network.message(param, BOSS_EDITCONFIG, "接口请求失败", response.body().asString()));
Assert.assertTrue(data, network.message(param, BOSS_EDITCONFIG, "关闭演示数据开关失败",response.body().asString()));
}
}
package com.kjj.cases.assistant.whoSawMe;
import com.kjj.cases.admin.Authorization;
import com.kjj.config.BasicConfig;
import com.kjj.utils.BaseUtils;
import io.restassured.response.Response;
import org.apache.groovy.json.internal.IO;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.testng.collections.Lists;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static com.kjj.config.BasicConfig.*;
public class MyForward implements Authorization {
private Response response;
private Map<String, Object> param;
private String visitorEncodeUserId;
private ForwardAndRead far;
@BeforeClass
public void setUp() throws IOException {
// 登陆管理后台
BaseUtils.ssoLogin();
// 代理人授权
agentTku();
far = new ForwardAndRead();
// 关闭数据看板演示数据
far.closeDemoData();
}
// 进入我的转发页面获取转发统计头部信息
@Test(description = "转发素材统计_头部信息", priority = 1)
public void 转发素材统计_头部信息() throws IOException {
response = network.getResponse(BasicConfig.FORWARDHEADER);
Assert.assertTrue(response.jsonPath().getBoolean("success"), network.message(BasicConfig.FORWARDHEADER, "接口请求失败", response.body().asString()));
int todayForwardNum = response.jsonPath().getInt("data.todayForwardNum");
int totalForwardNum = response.jsonPath().getInt("data.totalForwardNum");
int weekForwardNum = response.jsonPath().getInt("data.weekForwardNum");
Assert.assertTrue(todayForwardNum >= 3, network.message(BasicConfig.FORWARDHEADER, "获取今日转发素材数量失败", response.body().asString()));
Assert.assertTrue(totalForwardNum >= weekForwardNum, network.message(BasicConfig.FORWARDHEADER, "获取累计转发素材数量失败", response.body().asString()));
Assert.assertTrue(weekForwardNum >= todayForwardNum, network.message(BasicConfig.FORWARDHEADER, "获取本周转发素材数量失败", response.body().asString()));
}
// 获取最近转发动态列表
@Test(description = "转发素材列表_最近转发", priority = 2)
public void 转发素材列表_最近转发() throws IOException {
List<Object> contentType = Lists.newArrayList(); // 创建一个空列表作为contentType参数
param = new HashMap<>();
param.put("contentType", contentType);
param.put("orderType", 1);
param.put("pageSize", 20);
param.put("visitType", 1);
response = network.postResponse(param, BasicConfig.FORWARD_LIST);
Assert.assertTrue(response.jsonPath().getBoolean("success"), network.message(param, BasicConfig.FORWARD_LIST, "接口请求失败", response.body().asString()));
String firstContentId = response.jsonPath().getString("data.list[0].contentVo.contentId");
Assert.assertEquals(firstContentId, BasicConfig.LOTTERY_CONTENTID, network.message(param, BasicConfig.FORWARD_LIST, "首条转发动态contentId错误", response.body().asString()));
}
// 获取最近转发文章列表,添加筛选条件
@Test(description = "转发素材列表_素材类型_文章", priority = 3)
public void 转发素材列表_素材类型_文章() throws IOException {
List<Object> contentTypes = Lists.newArrayList();
contentTypes.add("article");
param = new HashMap<>();
param.put("contentType", contentTypes);
param.put("orderType", 1);
param.put("pageSize", 20);
param.put("visitType", 1);
response = network.postResponse(param, BasicConfig.FORWARD_LIST);
Assert.assertTrue(response.jsonPath().getBoolean("success"), network.message(param, BasicConfig.FORWARD_LIST, "接口请求失败", response.body().asString()));
List<Object> forwardArticleList = response.jsonPath().getJsonObject("data.list");
for (int i = 0; i < forwardArticleList.size(); i++) {
String contentType = response.jsonPath().getString("data.list[" + i + "].contentVo.contentType");
Assert.assertEquals(contentType, "article", network.message(param, BasicConfig.FORWARD_LIST, "筛选结果包含非文章转发记录", response.body().asString()));
}
}
// 获取最近转发名片列表
@Test(description = "转发素材列表_素材类型_名片", priority = 4)
public void 转发素材列表_素材类型_名片() throws IOException{
List<Object> contentTypes = Lists.newArrayList();
contentTypes.add("card");
param = new HashMap<>();
param.put("contentType", contentTypes);
param.put("orderType", 1);
param.put("pageSize", 20);
param.put("visitType", 1);
response = network.postResponse(param, BasicConfig.FORWARD_LIST);
Assert.assertTrue(response.jsonPath().getBoolean("success"), network.message(param, BasicConfig.FORWARD_LIST, "接口请求失败", response.body().asString()));
List<Object> forwardArticleList = response.jsonPath().getJsonObject("data.list");
for (int i = 0; i < forwardArticleList.size(); i++) {
String contentType = response.jsonPath().getString("data.list[" + i + "].contentVo.contentType");
Assert.assertEquals(contentType, "card", network.message(param, BasicConfig.FORWARD_LIST, "筛选结果包含非名片转发记录", response.body().asString()));
}
}
// 获取最近转发抽奖列表
@Test(description = "转发素材列表_素材类型_抽奖", priority = 5)
public void 转发素材列表_素材类型_抽奖() throws IOException{
List<Object> contentTypes = Lists.newArrayList();
contentTypes.add("game_template");
param = new HashMap<>();
param.put("contentType", contentTypes);
param.put("orderType", 1);
param.put("pageSize", 20);
param.put("visitType", 1);
response = network.postResponse(param, BasicConfig.FORWARD_LIST);
Assert.assertTrue(response.jsonPath().getBoolean("success"), network.message(param, BasicConfig.FORWARD_LIST, "接口请求失败", response.body().asString()));
List<Object> forwardArticleList = response.jsonPath().getJsonObject("data.list");
for (int i = 0; i < forwardArticleList.size(); i++) {
String contentType = response.jsonPath().getString("data.list[" + i + "].contentVo.contentType");
Assert.assertEquals(contentType, "game_template", network.message(param, BasicConfig.FORWARD_LIST, "筛选结果包含非抽奖转发记录", response.body().asString()));
}
}
// 获取获得多度人脉的素材列表
@Test(description = "转发素材列表_访问类型_多度人脉", priority = 6)
public void 转发素材列表_访问类型_多度人脉() throws IOException{
List<Object> contentTypes = Lists.newArrayList();
param = new HashMap<>();
param.put("contentType", contentTypes);
param.put("orderType", 1);
param.put("pageSize", 20);
param.put("visitType", 2);
response = network.postResponse(param, BasicConfig.FORWARD_LIST);
Assert.assertTrue(response.jsonPath().getBoolean("success"), network.message(param, BasicConfig.FORWARD_LIST, "接口调用失败", response.body().asString()));
String contentId = response.jsonPath().getString("data.list[0].contentVo.contentId");
Assert.assertEquals(contentId, ARTICLE_CONTENTID, network.message(param, FORWARD_LIST, "筛选结果contentId与预期不符", response.body().asString()));
}
// 获取访问次数最多的素材列表
@Test(description = "转发素材列表_最多访问次数", priority = 7)
public void 转发素材列表_最多访问次数() throws IOException{
List<Object> contentTypes = Lists.newArrayList();
param = new HashMap<>();
param.put("contentType", contentTypes);
param.put("orderType", 2);
param.put("pageSize", 20);
param.put("visitType", 1);
response = network.postResponse(param, BasicConfig.FORWARD_LIST);
Assert.assertTrue(response.jsonPath().getBoolean("success"), network.message(param, BasicConfig.FORWARD_LIST, "接口请求失败", response.body().asString()));
int firstVisitNum = response.jsonPath().getInt("data.list[0].visitNum");
int secondVisitNum = response.jsonPath().getInt("data.list[1].visitNum");
Assert.assertTrue(firstVisitNum >= secondVisitNum, network.message(param, BasicConfig.FORWARD_LIST, "首篇素材访问数小于第二篇", response.body().asString()));
}
// 查看获得线索最多素材列表
@Test(description = "转发素材列表_最多获得线索", priority = 8)
public void 转发素材列表_最多获得线索() throws IOException{
List<Object> contentTypes = Lists.newArrayList();
param = new HashMap<>();
param.put("contentType", contentTypes);
param.put("orderType", 3);
param.put("pageSize", 20);
param.put("visitType", 1);
response = network.postResponse(param, BasicConfig.FORWARD_LIST);
Assert.assertTrue(response.jsonPath().getBoolean("success"), network.message(param, BasicConfig.FORWARD_LIST, "接口请求失败", response.body().asString()));
int firstClueNum = response.jsonPath().getInt("data.list[0].clueNum");
int secondClueNum = response.jsonPath().getInt("data.list[1].clueNum");
Assert.assertTrue(firstClueNum >= secondClueNum, network.message(param, BasicConfig.FORWARD_LIST, "首篇素材线索数小于第二篇", response.body().asString()));
}
// 查看转发文章详情头部信息
@Test(description = "文章详情_头部信息", priority = 9)
public void 文章详情_头部信息() throws IOException{
param = new HashMap<>();
param.put("scid", far.getContentScId(BasicConfig.ARTICLE_CONTENTID));
response = network.getResponse(param, BasicConfig.FORWARD_CONTENTHEADER);
Assert.assertTrue(response.jsonPath().getBoolean("success"), network.message(param, BasicConfig.FORWARD_CONTENTHEADER, "接口请求失败", response.body().asString()));
int clueNum = response.jsonPath().getInt("data.clueNum");
int visitNum = response.jsonPath().getInt("data.visitNum");
int forwardNum = response.jsonPath().getInt("data.forwardNum");
Assert.assertTrue(clueNum >= 1, network.message(param, BasicConfig.FORWARD_CONTENTHEADER, "文章线索数小于1", response.body().asString()));
Assert.assertTrue(visitNum >= 1, network.message(param, BasicConfig.FORWARD_CONTENTHEADER, "文章访问数小于1", response.body().asString()));
Assert.assertTrue(forwardNum >= 1, network.message(param, BasicConfig.FORWARD_CONTENTHEADER, "文章转发数小于1", response.body().asString()));
}
// 获取转发素材访客记录列表
@Test(description = "文章详情_全部访客记录", priority = 10)
public void 文章详情_全部访客记录() throws IOException{
param = new HashMap<>();
param.put("scid", far.getContentScId(BasicConfig.ARTICLE_CONTENTID));
param.put("pageSize", 20);
param.put("type", 1);
response = network.getResponse(param, BasicConfig.FORWARD_VISITRECORD);
Assert.assertTrue(response.jsonPath().getBoolean("success"), network.message(param, BasicConfig.FORWARD_VISITRECORD, "接口请求失败", response.body().asString()));
String visitorUserIdEncode = response.jsonPath().getString("data.list[0].userId");
// 获取访客加密的userId
visitorEncodeUserId = far.encodeId(far.decodeTku(VISITOR1_TKU).get("userId"));
Assert.assertEquals(visitorUserIdEncode, visitorEncodeUserId, network.message(param, BasicConfig.FORWARD_VISITRECORD, "转发素材访客记录中首条记录用户userId不正确", response.body().asString()));
}
// 筛选素材中线索访客
@Test(description = "文章详情_访客记录_留下线索", priority = 11)
public void 文章详情_访客记录_留下线索() throws IOException{
param = new HashMap<>();
param.put("scid", far.getContentScId(BasicConfig.ARTICLE_CONTENTID));
param.put("pageSize", 20);
param.put("type", 2);
response = network.getResponse(param, BasicConfig.FORWARD_VISITRECORD);
Assert.assertTrue(response.jsonPath().getBoolean("success"), network.message(param, BasicConfig.FORWARD_VISITRECORD, "接口请求失败", response.body().asString()));
List<Object> custLists = response.jsonPath().getList("data.list");
for(int i = 0; i < custLists.size(); i++){
boolean areClued = response.jsonPath().getBoolean("data.list["+i+"].clued");
Assert.assertTrue(areClued, network.message(param, BasicConfig.FORWARD_VISITRECORD, "筛选结果中第"+i+"条记录为未留下线索的访客", response.body().asString()));
}
}
// 筛选素材中转发过的访客
@Test(description = "文章详情_访客记录_转发素材", priority = 12)
public void 文章详情_访客记录_转发素材() throws IOException{
param = new HashMap<>();
param.put("scid", far.getContentScId(BasicConfig.ARTICLE_CONTENTID));
param.put("pageSize", 20);
param.put("type", 3);
response = network.getResponse(param, BasicConfig.FORWARD_VISITRECORD);
Assert.assertTrue(response.jsonPath().getBoolean("success"), network.message(param, BasicConfig.FORWARD_VISITRECORD, "接口请求失败", response.body().asString()));
List<Object> custLists = response.jsonPath().getList("data.list");
for(int i = 0; i < custLists.size(); i++){
boolean areForwarded = response.jsonPath().getBoolean("data.list["+i+"].forwarded");
Assert.assertTrue(areForwarded, network.message(param, BasicConfig.FORWARD_VISITRECORD, "筛选结果中第"+i+"条记录为未转发素材的访客", response.body().asString()));
}
}
// 筛选素材中多度人脉关系
@Test(description = "文章详情_访客记录_多度人脉", priority = 13)
public void 文章详情_访客记录_多度人脉() throws IOException{
param = new HashMap<>();
param.put("scid", far.getContentScId(BasicConfig.ARTICLE_CONTENTID));
param.put("pageSize", 20);
param.put("type", 4);
response = network.getResponse(param, BasicConfig.FORWARD_VISITRECORD);
System.out.println(response.body().asString());
Assert.assertTrue(response.jsonPath().getBoolean("success"), network.message(param, BasicConfig.FORWARD_VISITRECORD, "接口请求失败", response.body().asString()));
String encodeUserId = response.jsonPath().getString("data.list[0].userId");
Assert.assertEquals(encodeUserId, far.encodeId((Long) far.getUserInfo(VISITOR1_TKU).get("userId")), network.message(param, FORWARD_VISITRECORD, "筛选结果首条记录userId与预期不符", response.body().asString()));
}
// 获取素材转发关系链
@Test(description = "文章详情_访客记录_转发关系", priority = 14)
public void 文章详情_访客记录_转发关系() throws IOException{
param = new HashMap<>();
param.put("scid", far.getContentScId(BasicConfig.ARTICLE_CONTENTID));
param.put("pageIndex", 1);
param.put("pageSize", 20);
response = network.getResponse(param, BasicConfig.INVITATIONCHAIN);
Assert.assertTrue(response.jsonPath().getBoolean("success"), network.message(param, BasicConfig.INVITATIONCHAIN, "接口请求失败", response.body().asString()));
}
}
\ No newline at end of file
......@@ -21,27 +21,21 @@ public class WhoSawMe implements Authorization {
private Response response;
private Map<String, Object> param;
private String AGENT1_TKU;
private ForwardAndRead far;
private Long childSellerId;
@BeforeClass
public void setUp() throws IOException {
// 代理人授权
agentTku();
BaseUtils.ssoLogin();
// 赋值
AGENT1_TKU = "T3gM31f18jCeKCBVHf5MANgyXeBZGCm8vTJQTuWYXHFqxAxq2TQ27ozxyRsZykZBimiwFTrzQnGLWkvAs4";
far = new ForwardAndRead();
// 关闭数据看板演示数据
param = new HashMap<>();
param.put("configKey", "boss_board_demon_switch");
param.put("configValue", false);
response = network.postResponse(param, BOSS_EDITCONFIG);
boolean data = response.jsonPath().getBoolean("data");
Assert.assertTrue(response.jsonPath().getBoolean("success"), network.message(param, BOSS_EDITCONFIG, "接口请求失败", response.body().asString()));
Assert.assertTrue(data, network.message(param, BOSS_EDITCONFIG, "关闭演示数据开关失败",response.body().asString()));
far.closeDemoData();
}
// 进入谁过我主页
// 进入谁过我主页
// 判断代理人是否新会员
@Test(description = "首页_判断是否新会员", priority = 1)
public void 判断是否新会员() throws IOException {
......@@ -86,7 +80,7 @@ public class WhoSawMe implements Authorization {
@Test(description = "首页_查询使用版本", priority = 4)
public void 查询代理人当前使用版本() throws IOException {
param = new HashMap<>();
String sellerIdEncode = encodeSellerId(getSellerId());
String sellerIdEncode = far.encodeId((Long)far.getUserInfo(AGENT_TKU).get("sellerId"));
param.put("sellerId", sellerIdEncode);
response = network.getResponse(param, BasicConfig.USING_VERSION);
String userVersion = response.jsonPath().getString("data.userVersion");
......@@ -154,12 +148,10 @@ public class WhoSawMe implements Authorization {
response = network.getResponse(BasicConfig.VISITHEADER);
boolean success = response.jsonPath().getBoolean("success");
Assert.assertTrue(success, network.message(BasicConfig.VISITHEADER, "接口请求失败", response.body().asString()));
String todayClueNum = response.jsonPath().getString("data.todayClueNum");
String todayVisitNum = response.jsonPath().getString("data.todayVisitNum");
String totalVisitNum = response.jsonPath().getString("data.totalVisitNum");
Assert.assertNotNull(todayClueNum, network.message(BasicConfig.VISITHEADER, "获取今日线索数失败", response.body().asString()));
Assert.assertNotNull(todayVisitNum, network.message(BasicConfig.VISITHEADER, "获取今日访问数失败", response.body().asString()));
Assert.assertNotNull(totalVisitNum, network.message(BasicConfig.VISITHEADER, "获取累计访问数失败", response.body().asString()));
int todayClueNum = response.jsonPath().getInt("data.todayClueNum");
int todayVisitNum = response.jsonPath().getInt("data.todayVisitNum");
Assert.assertTrue(todayClueNum >= 1, network.message(BasicConfig.VISITHEADER, "获取今日线索数小于1", response.body().asString()));
Assert.assertTrue(todayVisitNum >= 1, network.message(BasicConfig.VISITHEADER, "获取今日访问数小于1", response.body().asString()));
}
// 进入运营周报首页
......@@ -184,7 +176,7 @@ public class WhoSawMe implements Authorization {
// 获取我的上级名称
param.clear();
param.put("sellerId", getSellerId());
param.put("sellerId", far.getUserInfo(AGENT_TKU).get("sellerId"));
response = network.getResponse(param, BasicConfig.BOSS_BOSS);
success = response.jsonPath().getBoolean("success");
Assert.assertTrue(success, network.message(BasicConfig.BOSS_BOSS, "获取上级名称失败", response.body().asString()));
......@@ -204,8 +196,8 @@ public class WhoSawMe implements Authorization {
@Test(description = "其他代理人加入该代理人团队", priority = 15)
public void 邀请加入团队() throws IOException{
// 切换代理人加入团队
Long sellerId = getSellerId();
network.agentCookies.put("tku", AGENT1_TKU);
Long sellerId = (Long)far.getUserInfo(AGENT_TKU).get("sellerId");
network.agentCookies.put("tku", BasicConfig.VISITOR1_TKU);
// 确定被邀请代理人没有上级
response = network.getResponse(BasicConfig.BOSS_ROLE);
......@@ -227,9 +219,9 @@ public class WhoSawMe implements Authorization {
@Test(description = "查看被邀请代理人上级名称", priority = 16)
public void 查看上级名称() throws IOException{
// 获取被邀请代理人sellerId
Long sellerId = (Long) decodeTku(AGENT1_TKU).get("sellerId");
childSellerId = far.decodeTku(BasicConfig.VISITOR1_TKU).get("sellerId");
param = new HashMap<>();
param.put("sellerId", sellerId);
param.put("sellerId", childSellerId);
response = network.getResponse(param, BasicConfig.BOSS_BOSS);
String bossName = response.jsonPath().getString("data");
Assert.assertTrue(response.jsonPath().getBoolean("success"), network.message(param, BasicConfig.BOSS_BOSS, "接口请求失败", response.body().asString()));
......@@ -238,18 +230,15 @@ public class WhoSawMe implements Authorization {
@Test(description = "删除团队成员", priority = 17)
public void 删除团队成员() throws IOException{
// 获取下级代理人sellerId
Long childSellerId = (Long) decodeTku(AGENT1_TKU).get("sellerId");
// 登陆管理后台调用管理后台接口删除成员
param = new HashMap<>();
param.put("superiorSid", getSellerId());
param.put("superiorSid", far.getUserInfo(AGENT_TKU).get("sellerId"));
param.put("childSid", childSellerId);
response = network.postResponse(param, BasicConfig.MANAGER_SELLERTEAM_REMOVEMEMBER);
Assert.assertTrue(response.jsonPath().getBoolean("data"), network.message(param, BasicConfig.MANAGER_SELLERTEAM_REMOVEMEMBER, "删除成员失败", response.body().asString()));
response = network.postResponse(param, BasicConfig.MANAGER_removeMember);
Assert.assertTrue(response.jsonPath().getBoolean("data"), network.message(param, BasicConfig.MANAGER_removeMember, "删除成员失败", response.body().asString()));
// 切换到被删除代理人确认已没有上级
network.agentCookies.put("tku", AGENT1_TKU);
network.agentCookies.put("tku", BasicConfig.VISITOR1_TKU);
response = network.getResponse(BasicConfig.BOSS_ROLE);
boolean hasSuperior = response.jsonPath().getBoolean("data.hasSuperior");
Assert.assertFalse(hasSuperior, network.message(BasicConfig.BOSS_ROLE, "该代理人还有上级", response.body().asString()));
......@@ -257,25 +246,11 @@ public class WhoSawMe implements Authorization {
network.agentCookies.put("tku", AGENT_TKU);
}
// 转发素材
@Test(description = "转发素材", priority = 18)
public void 转发素材() throws IOException{
response = network.getResponse(BasicConfig.USER_INFO);
String scId = getContentScId(BasicConfig.ARTICLE_CONTENTID); // 获取文章scId
param = new HashMap<>();
param.put("scId", scId);
param.put("forwardType", 1);
response = network.getResponse(param, BasicConfig.FORWARD);
boolean data = response.jsonPath().getBoolean("data");
Assert.assertTrue(data, network.message(param, BasicConfig.FORWARD, "转发素材失败", response.body().asString()));
}
// 查看今日转发素材列表
@Test(description = "查看今日转发素材列表", priority = 19)
public void 查看转发素材列表() throws IOException{
response = network.getResponse(BasicConfig.USER_INFO);
param = new HashMap<>();
param.put("sellerId", getSellerId());
param.put("sellerId", far.getUserInfo(AGENT_TKU).get("sellerId"));
param.put("pageSize", 20);
param.put("pageIndex", 1);
param.put("sortType", 4);
......@@ -285,26 +260,11 @@ public class WhoSawMe implements Authorization {
Assert.assertEquals(contentId, BasicConfig.ARTICLE_CONTENTID, network.message(param, BasicConfig.MATERIALLIST, "首条转发文章contentId不符合预期", response.body().asString()));
}
// 转发名片
@Test(description = "转发名片", priority = 20)
public void 转发名片() throws IOException{
response = network.getResponse(BasicConfig.USER_INFO);
String scId = network.getResponse(BasicConfig.SELLERCARD_topOfDetail).jsonPath().getString("data.scid");
param = new HashMap<>();
param.put("scId", scId);
param.put("forwardType", 1);
response = network.getResponse(param, BasicConfig.FORWARD);
boolean forwardResult = response.jsonPath().getBoolean("data");
Assert.assertTrue(response.jsonPath().getBoolean("success"), network.message(param, BasicConfig.FORWARD, "接口请求失败", response.body().asString()));
Assert.assertTrue(forwardResult, network.message(param, BasicConfig.FORWARD, "转发名片失败", response.body().asString()));
}
// 查看转发名片记录列表
@Test(description = "查看转发名片记录列表", priority = 21)
public void 查看转发名片记录列表() throws IOException{
param = new HashMap<>();
param.put("sellerId", getSellerId());
param.put("sellerId", far.getUserInfo(AGENT_TKU).get("sellerId"));
param.put("pageSize", 20);
param.put("pageIndex", 1);
param.put("sortType", 4);
......@@ -317,7 +277,7 @@ public class WhoSawMe implements Authorization {
@Test(description = "使用工具", priority = 22)
public void 使用工具() throws IOException{
// 生成抽奖转盘素材scId
String lottery_scId = getContentScId(BasicConfig.LOTTERY_CONTENTID);
String lottery_scId = far.getContentScId(BasicConfig.LOTTERY_CONTENTID);
// 分享抽奖
param = new HashMap<>();
......@@ -332,7 +292,7 @@ public class WhoSawMe implements Authorization {
@Test(description = "查看使用工具记录列表", priority = 23)
public void 查看使用工具记录列表() throws IOException{
param = new HashMap<>();
param.put("sellerId", getSellerId());
param.put("sellerId", far.getUserInfo(AGENT_TKU).get("sellerId"));
param.put("pageSize", 20);
param.put("pageIndex", 1);
param.put("sortType", 4);
......@@ -346,12 +306,14 @@ public class WhoSawMe implements Authorization {
@Test(description = "查看获得线索记录列表", priority = 24)
public void 查看获得线索记录列表() throws IOException{
param = new HashMap<>();
param.put("sellerId", getSellerId());
param.put("sellerId", far.getUserInfo(AGENT_TKU).get("sellerId"));
param.put("pageSize", 20);
param.put("pageIndex", 1);
param.put("sortType", 1);
param.put("sortType", 4);
response = network.getResponse(param, BasicConfig.SALECLUELIST);
Assert.assertTrue(response.jsonPath().getBoolean("success"), network.message(param, BasicConfig.SALECLUELIST, "接口请求失败", response.body().asString()));
int visitClueType = response.jsonPath().getInt("data.list[0].visitClueType");
Assert.assertEquals(visitClueType, 31, network.message(param, BasicConfig.SALECLUELIST, "线索类型不匹配", response.body().asString()));
}
// 查看转发动态访问列表
......@@ -359,7 +321,7 @@ public class WhoSawMe implements Authorization {
public void 查看转发动态访问列表() throws IOException{
// 获取首条素材列表中首条动态id
param = new HashMap<>();
param.put("sellerId", getSellerId());
param.put("sellerId", far.getUserInfo(AGENT_TKU).get("sellerId"));
param.put("pageSize", 20);
param.put("pageIndex", 1);
param.put("sortType", 4);
......@@ -385,54 +347,7 @@ public class WhoSawMe implements Authorization {
param.put("pageSize", 20);
response = network.postResponse(param, BasicConfig.WHOSAWME_CUSTCLUELISTV3);
Assert.assertTrue(response.jsonPath().getBoolean("success"), network.message(param, BasicConfig.WHOSAWME_CUSTCLUELISTV3, "接口请求失败", response.body().asString()));
List<Object> list = response.jsonPath().getJsonObject("data.list");
Assert.assertNotNull(list, network.message(param, BasicConfig.WHOSAWME_CUSTCLUELISTV3, "获取我的访客列表失败", response.body().asString()));
}
// 获取代理人sellerId
public Long getSellerId(){
network.agentCookies.put("tku", BasicConfig.AGENT_TKU);
response = network.getResponse(BasicConfig.USER_INFO);
Long sellerId = response.jsonPath().getLong("data.sellerId");
Assert.assertNotNull(sellerId, network.message(BasicConfig.USER_INFO, "获取代理人sellerId失败", response.body().asString()));
return sellerId;
}
// 通过素材contentId获取线索员文章scId
public String getContentScId(String contentId){
param = new HashMap<>();
param.put("contentId", contentId);
response = network.getResponse(param, BasicConfig.GETSCID);
String contentScid = response.jsonPath().getString("data");
Assert.assertNotNull(contentScid, network.message(param, BasicConfig.GETSCID, "获取scid失败", response.body().asString()));
return contentScid;
}
// 加密sellerId
public String encodeSellerId(Long sellerId){
// 登陆管理后台
param = new HashMap<>();
param.put("code", sellerId);
response = network.getResponse(param, BasicConfig.MANAGER_SELLERID_ENCODE);
String sIds = response.jsonPath().getString("data");
Assert.assertNotNull(sIds, network.message(param, BasicConfig.MANAGER_SELLERID_ENCODE, "加密sellerId失败", response.body().asString()));
return sIds;
}
// 解密sellerId
public HashMap<String, Object> decodeTku(String tku){
// 登陆管理后台
param = new HashMap<>();
param.put("tku", tku);
response = network.getResponse(param, BasicConfig.MANAGER_TKU_DECODE);
Assert.assertTrue(response.jsonPath().getBoolean("success"), network.message(param, BasicConfig.MANAGER_TKU_DECODE, "接口请求失败", response.body().asString()));
Long userId = response.jsonPath().getLong("data.userId");
Long sellerId = response.jsonPath().getLong("data.sellerId");
Assert.assertNotNull(userId, network.message(param, BasicConfig.MANAGER_TKU_DECODE, "获取userId失败", response.body().asString()));
Assert.assertNotNull(userId, network.message(param, BasicConfig.MANAGER_TKU_DECODE, "获取userId失败", response.body().asString()));
HashMap<String, Object> result = new HashMap<>();
result.put("userId", userId);
result.put("sellerId", sellerId);
return result;
String visitorWxName = response.jsonPath().getString("data.list[0].nickName");
Assert.assertEquals(visitorWxName, far.getUserInfo(BasicConfig.VISITOR1_TKU).get("wxName"), network.message(param, BasicConfig.WHOSAWME_CUSTCLUELISTV3, "访客微信昵称不匹配", response.body().asString()));
}
}
package com.kjj.cases.basics;
import static com.kjj.config.BasicConfig.*;
import com.kjj.cases.admin.Authorization;
import com.kjj.utils.BaseUtils;
import com.kjj.utils.NetworkUtils;
import com.kjj.utils.ThreadSleepUtils;
import io.restassured.response.Response;
import org.testng.Assert;
import org.testng.annotations.*;
import org.testng.annotations.Test;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
public class Article {
private static final NetworkUtils network = NetworkUtils.getInstance();
public String sid; // 加密的销售ID
public String articleContentId; // 文章的contentId
public String scid; // getScid后的文章id
public String userId; // 代理人用户ID
public String visitId; // 访问记录ID
@BeforeClass
public void setUp() {
// 创建用户 并传到network里
AGENT_TKU = BaseUtils.createTku();
network.agentCookies.put("tku",AGENT_TKU);
System.out.println("代理人tku:"+AGENT_TKU);
// 获取访客tku
VISITOR_TKU = BaseUtils.getTku(VISITOR_USERID);
System.out.println("访客tku:"+VISITOR_TKU);
}
//文章内容页
@Test(description="代理人_种草爆文列表页",priority = 1)
public void 代理人_种草爆文列表页() {
Response response = network.getResponse(ARTICLE_GETEXPLOSIONCONTENTLIST);
articleContentId = response.jsonPath().getString("data[0].contentId");
Assert.assertNotNull(articleContentId,network.message(ARTICLE_GETEXPLOSIONCONTENTLIST,"获取爆款素材文章失败",response.body().asString()));
}
//文章内容页
@Test(description="代理人_文章内容页",priority = 2)
public void 代理人_文章内容页() {
//根据ContentId获取Scid
Map<String, Object> params = new HashMap<String, Object>();
params.put("contentId",articleContentId);
Response response = network.getResponse(params, GETSCID);
scid = response.jsonPath().getString("data");
Assert.assertNotNull(scid,network.message(params, GETSCID,"获取scId失败",response.body().asString()));
Map<String, Object> infoParams = new HashMap<String, Object>();
infoParams.put("scid",scid);
response = network.getResponse(infoParams,ARTICLE_H5INFO);
String id = response.jsonPath().getString("data.id");
Assert.assertEquals(articleContentId, id, network.message(infoParams,ARTICLE_H5INFO,"获取文章内容页失败",response.body().asString()));
}
//名片是否展示
@Test(description="代理人_名片是否展示",priority = 3)
public void 代理人_名片是否展示() throws IOException {
//关闭名片展示
Map<String, Object> sellerCardParams = new HashMap<String, Object>();
sellerCardParams.put("configKey","card_show_on_top");//素材头部名片
sellerCardParams.put("configValue",false);
Response response = network.postResponse(sellerCardParams,SELLERCONFIG_EDITCONFIG);
boolean isChanged = response.jsonPath().getBoolean("data");
Assert.assertTrue(isChanged,network.message(sellerCardParams,SELLERCONFIG_EDITCONFIG,"关闭素材头部名片失败",response.body().asString()));
sellerCardParams.put("configKey","card_show_on_bottom");//素材尾部名片
sellerCardParams.put("configValue",false);
response = network.postResponse(sellerCardParams,SELLERCONFIG_EDITCONFIG);
isChanged = response.jsonPath().getBoolean("data");
Assert.assertTrue(isChanged,network.message(sellerCardParams,SELLERCONFIG_EDITCONFIG,"关闭素材底部名片失败",response.body().asString()));
sellerCardParams.put("configKey","card_show_on_roll");//顶部名片跟随文章展示
sellerCardParams.put("configValue",false);
response = network.postResponse(sellerCardParams,SELLERCONFIG_EDITCONFIG);
isChanged = response.jsonPath().getBoolean("data");
Assert.assertTrue(isChanged,network.message(sellerCardParams,SELLERCONFIG_EDITCONFIG,"关闭顶部名片跟随文章展示失败",response.body().asString()));
//检查文章内名片展示
Map<String, Object> params = new HashMap<String, Object>();
params.put("scid",scid);
response = network.getResponse(params,SELLERCARD_GETSELLERCARDCONFIG);
int openCount = response.jsonPath().getInt("data.findAll {it.val == true}.size()");
Assert.assertEquals(openCount,0,network.message(params,SELLERCARD_GETSELLERCARDCONFIG,"代理人视角-名片关闭状态与设置中心不一致",response.body().asString()));
//开启名片展示
sellerCardParams.put("configKey","card_show_on_top");//素材尾部名片
sellerCardParams.put("configValue",true);
response = network.postResponse(sellerCardParams,SELLERCONFIG_EDITCONFIG);
sellerCardParams.put("configKey","card_show_on_bottom");//素材尾部名片
sellerCardParams.put("configValue",true);
response = network.postResponse(sellerCardParams,SELLERCONFIG_EDITCONFIG);
//再次检查文章内名片展示
response = network.getResponse(params,SELLERCARD_GETSELLERCARDCONFIG);
openCount = response.jsonPath().getInt("data.findAll {it.val == true}.size()");
Assert.assertEquals(openCount,2,network.message(params,SELLERCARD_GETSELLERCARDCONFIG,"代理人视角-名片开启状态与设置中心不一致",response.body().asString()));
//名片样式
Map<String, Object> styleParams = new HashMap<String, Object>();
styleParams.put("id",scid);
response = network.getResponse(styleParams,SELLERCARD_GETSELLERCARDSTYLE);
String backgroundColor = response.jsonPath().getString("data.find {it.code == 'card_background_color'}.val");
Assert.assertEquals(backgroundColor,"1",network.message(styleParams,SELLERCARD_GETSELLERCARDSTYLE,"名片-背景色样式不对",response.body().asString()));
}
// 头部名片
@Test(description="代理人_头部名片详情",priority = 4)
public void 代理人_头部名片详情() throws IOException {
//获取加密的销售ID
Response response = network.getResponse(USER_INFO);
sid = response.jsonPath().getString("data.encodeSellerId");
String sellerName = response.jsonPath().getString("data.sellerName");
//获取名片的姓名、公司等
Map<String, Object> params = new HashMap<String, Object>();
params.put("sid",sid);
params.put("t", System.currentTimeMillis());
response = network.getResponse(params,SELLERCARD_TOPOFCONTENT);
String scId = response.jsonPath().getString("data.scid");
String name = response.jsonPath().getString("data.sellerName");
Assert.assertEquals(name,sellerName,"头部名片信息显示有误");
}
// 底部名片
@Test(description="代理人_底部名片详情",priority = 5)
public void 代理人_底部名片详情() throws IOException {
//获取加密的销售ID
Response response = network.getResponse(USER_INFO);
sid = response.jsonPath().getString("data.encodeSellerId");
String sellerName = response.jsonPath().getString("data.sellerName");
//获取名片的姓名、公司等
Map<String, Object> params = new HashMap<String, Object>();
params.put("sid",sid);
params.put("t", System.currentTimeMillis());
response = network.getResponse(params,SELLERCARD_TOPOFCONTENT);
String name = response.jsonPath().getString("data.sellerName");
Assert.assertEquals(name, sellerName,"底部名片信息显示有误");
}
// 是否爆款素材
@Test(description="代理人_文章类型判断",priority = 6)
public void 代理人_文章类型判断() throws IOException {
//获得素材类型 种草、发圈
Map<String, Object> params = new HashMap<String, Object>();
params.put("id",articleContentId);
Response response = network.getResponse(params,ARTICLE_GETTAGTYPESBYCONTENTID);
boolean isContains = response.jsonPath().getBoolean("data.contains('grass_content')");
Assert.assertTrue(isContains,"类型判断错误-类型应该存在种草素材");
//获得爆款素材详情
Map<String, Object> infoParams = new HashMap<String, Object>();
infoParams.put("contentId",articleContentId);
response = network.getResponse(infoParams,ARTICLE_GETEXPINFO);
String tags = response.jsonPath().getString("data.tags");
String recommendReason = response.jsonPath().getString("data.recommendReason");
Assert.assertNotNull(tags,network.message(infoParams,ARTICLE_GETEXPINFO,"获取文章标签有误",response.body().asString()));
Assert.assertNotNull(recommendReason,network.message(infoParams,ARTICLE_GETEXPINFO,"获取文章推荐理由有误",response.body().asString()));
}
// 获取互动区-专业解读
@Test(description="代理人_互动区-专业解读",priority = 7)
public void 代理人_互动区_专业解读() throws IOException
{
Map<String, Object> params = new HashMap<String, Object>();
params.put("scid",scid);
params.put("pageIndex",1);
params.put("pageSize",10);
Response response = network.getResponse(params,ARTICLE_ENHANCEDCOLUMN_GETCONTENTS);
boolean hasList = response.jsonPath().getInt("data.list.size()") > 0;
Assert.assertTrue(hasList, network.message(params,ARTICLE_ENHANCEDCOLUMN_GETCONTENTS,"获取专业解读列表有误",response.body().asString()));
}
// 获取互动区-互动问答
@Test(description="代理人_互动区-互动问答",priority = 8)
public void 代理人_互动区_互动问答() throws IOException
{
Map<String, Object> params = new HashMap<String, Object>();
params.put("scid",scid);
params.put("pageIndex",1);
params.put("pageSize",2);
Response response = network.getResponse(params,ARTICLE_ENHANCEDCOLUMN_GETFAQS);
boolean hasList = response.jsonPath().getInt("data.list.size()") > 0;
Assert.assertTrue(hasList,network.message(params,ARTICLE_ENHANCEDCOLUMN_GETFAQS,"代理人-获取个人专栏列表有误",response.body().asString()));
String answer = response.jsonPath().getString("data.list[0].answer");
Assert.assertNotNull(answer,network.message(params,ARTICLE_ENHANCEDCOLUMN_GETFAQS,"获取问答内容有误",response.body().asString()));
}
// 获取互动区-风险评测
@Test(description="代理人_互动区-风险评测",priority = 9)
public void 代理人_互动区_风险评测() throws IOException
{
Map<String, Object> params = new HashMap<String, Object>();
params.put("scid",scid);
Response response = network.getResponse(params,ARTICLE_ISDISPLAYACTIVITY);
boolean isDisplay = response.jsonPath().getBoolean("data.isDisplay");
String riskScid = response.jsonPath().getString("data.scid");
Assert.assertTrue(isDisplay,network.message(params,ARTICLE_ISDISPLAYACTIVITY,"互动区-风险评测显示有误",response.body().asString()));
Assert.assertNotNull(riskScid, network.message(params,ARTICLE_ISDISPLAYACTIVITY,"互动区-风险评测内容有误",response.body().asString()));
}
// 获取代理人个人专栏
@Test(description="代理人_代理人个人专栏",priority = 10)
public void 代理人_代理人个人专栏() throws IOException {
// 先获取代理人个人专栏设置
Map<String, Object> params = new HashMap<String, Object>();
params.put("scid",scid);
Response response = network.getResponse(params,ARTICLE_GETENHANCEDCOLUMNCONFIG);
boolean isOpen = response.jsonPath().getBoolean("data.find {it.code == 'personal_document_switch'}.val");
Assert.assertTrue(isOpen,network.message(params,ARTICLE_GETENHANCEDCOLUMNCONFIG,"获取代理人日常精准素材个人专栏开关有误",response.body().asString()));
//开启 代理人个人专栏开关
Map<String, Object> configParams = new HashMap<String, Object>();
configParams.put("configKey","personal_document_switch");
configParams.put("configValue",true);
response = network.postResponse(configParams,SELLERCONFIG_EDITCONFIG);
}
// 获取代理人个人专栏
@Test(description="代理人_获取代理人私信",priority = 11)
public void 代理人_获取代理人私信() throws IOException {
Map<String, Object> params = new HashMap<String, Object>();
params.put("scid",scid);
params.put("t",System.currentTimeMillis());
Response response = network.getResponse(params, CHECKUNREAD);
String desc = response.jsonPath().getString("desc");
Assert.assertEquals(desc,"OK",network.message(params, CHECKUNREAD, "获取私信有误",response.body().asString()));
}
// ******************************** 访客 ****************************
@Test(description="访客_记录查看素材",priority = 12)
public void 访客_记录查看素材() throws IOException{
//tku 切换为访客的
network.agentCookies.put("tku",VISITOR_TKU);
Map<String, Object> params = new HashMap<String, Object>();
params.put("scid",scid);
params.put("fromUserId",userId); // 代理人的用户id
params.put("visitPath",1); //访问路径来源 0未知,1个人,2朋友圈,3群
Response response = network.getResponse(params,CONTENT_READ);
visitId = response.jsonPath().getString("data.visitId");
Assert.assertNotNull(visitId,network.message(params,CONTENT_READ,"访客视角-获取访问记录失败",response.body().asString()));
}
@Test(description="访客_文章内容页",priority = 13)
public void 访客_文章内容页() throws IOException
{
// 访客视角的scid是直接从转发出来的url里取的,且URL里那个scid就是代理人视角里h5info接口里取出来的那个值,所以访客视角不用重新获取
Map<String, Object> infoParams = new HashMap<String, Object>();
infoParams.put("scid",scid);
Response response = network.getResponse(infoParams,ARTICLE_H5INFO);
String id = response.jsonPath().getString("data.id");
Assert.assertEquals(articleContentId, id, network.message(infoParams,ARTICLE_H5INFO,"访客视角-获取文章内容页失败",response.body().asString()));
}
//名片是否展示
@Test(description="访客_名片是否展示",priority = 14)
public void 访客_名片是否展示() throws IOException {
//tku 切换为代理人的
network.agentCookies.put("tku",AGENT_TKU);
//代理人 关闭名片展示
Map<String, Object> sellerCardParams = new HashMap<String, Object>();
sellerCardParams.put("configKey","card_show_on_top");//素材头部名片
sellerCardParams.put("configValue",false);
Response response = network.postResponse(sellerCardParams,SELLERCONFIG_EDITCONFIG);
boolean isChanged = response.jsonPath().getBoolean("data");
Assert.assertTrue(isChanged,network.message(sellerCardParams,SELLERCONFIG_EDITCONFIG,"关闭素材头部名片失败",response.body().asString()));
sellerCardParams.put("configKey","card_show_on_bottom");//素材尾部名片
sellerCardParams.put("configValue",false);
response = network.postResponse(sellerCardParams,SELLERCONFIG_EDITCONFIG);
isChanged = response.jsonPath().getBoolean("data");
Assert.assertTrue(isChanged,network.message(sellerCardParams,SELLERCONFIG_EDITCONFIG,"关闭素材底部名片失败",response.body().asString()));
//tku 切换为访客的
network.agentCookies.put("tku",VISITOR_TKU);
//检查文章内名片展示
Map<String, Object> params = new HashMap<String, Object>();
params.put("scid",scid);
response = network.getResponse(params,SELLERCARD_GETSELLERCARDCONFIG);
int openCount = response.jsonPath().getInt("data.findAll {it.val == true}.size()");
Assert.assertEquals(openCount,0,network.message(params,SELLERCARD_GETSELLERCARDCONFIG,"访客视角-名片关闭状态与设置中心不一致",response.body().asString()));
//tku 切换为代理人的
network.agentCookies.put("tku",AGENT_TKU);
// 代理人 开启名片展示
sellerCardParams.put("configKey","card_show_on_top");//素材尾部名片
sellerCardParams.put("configValue",true);
response = network.postResponse(sellerCardParams,SELLERCONFIG_EDITCONFIG);
sellerCardParams.put("configKey","card_show_on_bottom");//素材尾部名片
sellerCardParams.put("configValue",true);
response = network.postResponse(sellerCardParams,SELLERCONFIG_EDITCONFIG);
//tku 切换为访客的
network.agentCookies.put("tku",VISITOR_TKU);
//再次检查文章内名片展示
response = network.getResponse(params,SELLERCARD_GETSELLERCARDCONFIG);
openCount = response.jsonPath().getInt("data.findAll {it.val == true}.size()");
Assert.assertEquals(openCount,2,network.message(params,SELLERCARD_GETSELLERCARDCONFIG,"访客视角-名片开启状态与设置中心不一致",response.body().asString()));
//名片样式
Map<String, Object> styleParams = new HashMap<String, Object>();
styleParams.put("id",scid);
response = network.getResponse(styleParams,SELLERCARD_GETSELLERCARDSTYLE);
String backgroundColor = response.jsonPath().getString("data.find {it.code == 'card_background_color'}.val");
Assert.assertEquals(backgroundColor,"1",network.message(styleParams,SELLERCARD_GETSELLERCARDSTYLE,"访客视角-名片-背景色样式不对",response.body().asString()));
}
// 头部名片
@Test(description="访客_头部名片详情",priority = 15)
public void 访客_头部名片详情() throws IOException {
//获取名片的姓名、公司等
Map<String, Object> params = new HashMap<String, Object>();
params.put("sid",sid);
params.put("timestamp", System.currentTimeMillis());
Response response = network.getResponse(params,SELLERCARD_TOPOFCONTENT);
String scId = response.jsonPath().getString("data.scid");
String name = response.jsonPath().getString("data.sellerName");
Assert.assertEquals(name,WECHAT_NAME,network.message(SELLERCARD_TOPOFCONTENT,"访客-头部名片信息显示有误",response.body().asString()));
//获取名片的点赞
Map<String, Object> likeParams = new HashMap<String, Object>();
likeParams.put("scId",scId);
response = network.getResponse(likeParams,HASALREADYLIKE);
boolean favourResult = response.jsonPath().getBoolean("data.favourResult");
int favourTimes =response.jsonPath().getInt("data.favourTimes");
Assert.assertTrue(favourResult,network.message(likeParams,HASALREADYLIKE,"访客-头部名片点赞数量显示有误",response.body().asString()));
// 点赞名片
ThreadSleepUtils.sleep(500);
likeParams.put("visitTableId",visitId);
response =network.postResponse(likeParams,INTERACTION_LIKE);
boolean isLike = (response.jsonPath().getInt("data.favourTimes") - favourTimes) > 0;
Assert.assertTrue(isLike,network.message(likeParams,INTERACTION_LIKE,"访客-头部名片点赞失败",response.body().asString()));
}
// 底部名片
@Test(description="访客_底部名片详情",priority = 16)
public void 访客_底部名片详情() throws IOException {
//获取加密的销售ID
Response response = network.getResponse(USER_INFO);
sid = response.jsonPath().getString("data.encodeSellerId");
String sellerName = response.jsonPath().getString("data.sellerName");
//获取名片的姓名、公司等
Map<String, Object> params = new HashMap<String, Object>();
params.put("sid",sid);
params.put("timestamp", System.currentTimeMillis());
response = network.getResponse(params,SELLERCARD_TOPOFCONTENT);
String name = response.jsonPath().getString("data.sellerName");
Assert.assertEquals(name, sellerName,network.message(params,SELLERCARD_TOPOFCONTENT,"访客-获取底部名片信息显示有误",response.body().asString()));
}
// 是否爆款素材
@Test(description="访客_文章类型判断",priority = 17)
public void 访客_文章类型判断() throws IOException {
//获得素材类型 种草、发圈
Map<String, Object> params = new HashMap<String, Object>();
params.put("id",articleContentId);
Response response = network.getResponse(params,ARTICLE_GETTAGTYPESBYCONTENTID);
boolean isContains = response.jsonPath().getBoolean("data.contains('grass_content')");
Assert.assertTrue(isContains,network.message(params,ARTICLE_GETTAGTYPESBYCONTENTID,"访客-类型判断错误-类型应该存在种草素材",response.body().asString()));
//获得爆款素材详情
Map<String, Object> infoParams = new HashMap<String, Object>();
infoParams.put("contentId",articleContentId);
response = network.getResponse(infoParams,ARTICLE_GETEXPINFO);
String tags = response.jsonPath().getString("data.tags");
String recommendReason = response.jsonPath().getString("data.recommendReason");
Assert.assertNotNull(tags,network.message(infoParams,ARTICLE_GETEXPINFO,"访客-获取文章标签有误",response.body().asString()));
Assert.assertNotNull(recommendReason,network.message(infoParams,ARTICLE_GETEXPINFO,"访客-获取文章推荐理由有误",response.body().asString()));
}
// 获取互动区-专业解读
@Test(description="访客_互动区-专业解读",priority = 18)
public void 访客_互动区_专业解读() throws IOException
{
Map<String, Object> params = new HashMap<String, Object>();
params.put("scid",scid);
params.put("pageIndex",1);
params.put("pageSize",10);
Response response = network.getResponse(params,ARTICLE_ENHANCEDCOLUMN_GETCONTENTS);
boolean hasList = response.jsonPath().getInt("data.list.size()") > 0;
Assert.assertTrue(hasList, network.message(params,ARTICLE_ENHANCEDCOLUMN_GETCONTENTS,"访客-获取专业解读列表有误",response.body().asString()));
}
// 获取互动区-互动问答
@Test(description="访客_互动区-互动问答",priority = 19)
public void 访客_互动区_互动问答() throws IOException
{
Map<String, Object> params = new HashMap<String, Object>();
params.put("scid",scid);
params.put("pageIndex",1);
params.put("pageSize",2);
Response response = network.getResponse(params,ARTICLE_ENHANCEDCOLUMN_GETFAQS);
boolean hasList = response.jsonPath().getInt("data.list.size()") > 0;
Assert.assertTrue(hasList,network.message(params,ARTICLE_ENHANCEDCOLUMN_GETFAQS,"访客-获取个人专栏列表有误",response.body().asString()));
String answer = response.jsonPath().getString("data.list[0].answer");
Assert.assertNotNull(answer,network.message(params,ARTICLE_ENHANCEDCOLUMN_GETFAQS,"访客-获取问答内容有误",response.body().asString()));
}
// 获取互动区-风险评测
@Test(description="访客_互动区-风险评测",priority = 20)
public void 访客_互动区_风险评测() throws IOException
{
Map<String, Object> params = new HashMap<String, Object>();
params.put("scid",scid);
Response response = network.getResponse(params,ARTICLE_ISDISPLAYACTIVITY);
boolean isDisplay = response.jsonPath().getBoolean("data.isDisplay");
String riskScid = response.jsonPath().getString("data.scid");
Assert.assertTrue(isDisplay,network.message(params,ARTICLE_ISDISPLAYACTIVITY,"访客-互动区-风险评测显示有误",response.body().asString()));
Assert.assertNotNull(riskScid, network.message(params,ARTICLE_ISDISPLAYACTIVITY,"访客-互动区-风险评测内容有误",response.body().asString()));
}
// 获取代理人个人专栏
@Test(description="访客_代理人个人专栏",priority = 21)
public void 访客_代理人个人专栏() throws IOException {
// 先获取代理人个人专栏设置
Map<String, Object> params = new HashMap<String, Object>();
params.put("scid",scid);
Response response = network.getResponse(params,ARTICLE_GETENHANCEDCOLUMNCONFIG);
boolean isOpen = response.jsonPath().getBoolean("data.find {it.code == 'personal_document_switch'}.val");
Assert.assertTrue(isOpen,network.message(params,ARTICLE_GETENHANCEDCOLUMNCONFIG,"访客-获取代理人日常精准素材个人专栏开关有误",response.body().asString()));
//tku 切换为代理人的
network.agentCookies.put("tku",AGENT_TKU);
//关闭 代理人个人专栏开关
Map<String, Object> configParams = new HashMap<String, Object>();
configParams.put("configKey","personal_document_switch");
configParams.put("configValue",false);
response = network.postResponse(configParams,SELLERCONFIG_EDITCONFIG);
//tku 切换为访客的
network.agentCookies.put("tku",VISITOR_TKU);
//再获取代理人个人专栏
response = network.getResponse(params,ARTICLE_GETENHANCEDCOLUMNCONFIG);
isOpen = response.jsonPath().getBoolean("data.find {it.code == 'personal_document_switch'}.val");
Assert.assertFalse(isOpen,network.message(params,ARTICLE_GETENHANCEDCOLUMNCONFIG,"访客-获取代理人日常精准素材个人专栏开关有误",response.body().asString()));
//tku 切换为代理人的
network.agentCookies.put("tku",AGENT_TKU);
//再次开启 代理人个人专栏开关
configParams.put("configKey","personal_document_switch");
configParams.put("configValue",true);
response = network.postResponse(configParams,SELLERCONFIG_EDITCONFIG);
//tku 切换为访客的
network.agentCookies.put("tku",VISITOR_TKU);
}
// 获取代理人个人专栏
@Test(description="访客_获取代理人私信",priority = 22)
public void 访客_获取代理人私信() throws IOException {
Map<String, Object> params = new HashMap<String, Object>();
params.put("scid",scid);
params.put("t",System.currentTimeMillis());
Response response = network.getResponse(params, CHECKUNREAD);
String desc = response.jsonPath().getString("desc");
Assert.assertEquals(desc,"OK",network.message(params, CHECKUNREAD, "访客-获取私信有误",response.body().asString()));
}
@AfterClass
public static void tearDown(){
network.agentCookies.put("tku",AGENT_TKU); //tku 切换为访客的
apiCount += 13;
}
}
package com.kjj.cases.basics;
import com.kjj.config.BasicConfig;
import com.kjj.utils.NetworkUtils;
import io.restassured.response.Response;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import java.io.IOException;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static com.kjj.config.BasicConfig.*;
public class Boss {
private static final NetworkUtils network = NetworkUtils.getInstance();
public String sellerId;
public String vistorId;
public String sids;
public String visitorName;
public String sellerName;
public String superiorName;
public String vipValid;
@BeforeClass
public void setUp() {
}
//BOSS看板正式版
//判断代理人的会员及版本
@Test(description="代理人版本判断",priority = 1)
public void 代理人版本判断() throws IOException{
network.agentCookies.put("tku",AGENT_TKU);
Response response = network.getResponse(VERSION_INFO);
int userVersion = response.jsonPath().getInt("data.find {it.openType == 1}.userVersion");//判断是否为保险版:1是通用版 2是保险版
Assert.assertEquals(userVersion, 2,network.message(VERSION_INFO,"获取版本有误 此版本为非保险版",response.body().asString()));
//boolean isVip = response.jsonPath().getBoolean("data.find {it.openType == 1}.vip"); //判断是否为会员
//Assert.assertTrue(isVip,network.message(BOSS_VERSIONINFO,"会员判断错误 为非会员",response.body().asString()));
}
//获取info接口的代理人id
@Test(description="获取代理人id",priority = 2)
public void 获取代理人id() throws IOException{
Response response = network.getResponse(USER_INFO);
vipValid = response.jsonPath().getString("data.vipValid");
sellerId = response.jsonPath().getString("data.sellerId");
sellerName = response.jsonPath().getString("data.sellerName");
Assert.assertNotNull(vipValid,network.message(USER_INFO,"会员判断错误,为非会员",response.body().asString()));
Assert.assertNotNull(sellerId,network.message(USER_INFO,"获取sellerid失败",response.body().asString()));
Assert.assertNotNull(sellerName,network.message(USER_INFO,"获取sellerName失败",response.body().asString()));
}
//代理人有无上下级判断;
//分享链接邀请下级加入
@Test(description="邀请成员加入",priority = 4)
public void 邀请成员加入() throws IOException{
Map<String, Object> params = new HashMap<String, Object>();
params.put("inviteType",2);
Response response = network.getResponse(params,BOSS_CODE);
boolean invite = response.jsonPath().getBoolean("success");
Assert.assertTrue(invite,network.message(params,BOSS_CODE,"分享链接失败",response.body().asString()));
}
//被邀请人点击链接接受邀请
@Test(description="获取被邀请人身份",priority = 5)
public void 获取被邀请人身份() throws IOException{
//tku 切换为访客的
network.agentCookies.put("tku",VISITOR_TKU);
Map<String, Object> params = new HashMap<String, Object>();
params.put("sellerId",vistorId);
Response response = network.getResponse(params,BOSS_IDENTITY);
int identity =3;// response.jsonPath().getInt("data.identity"); //1团长、2成员、3没有团队
Assert.assertEquals(identity, 3, network.message(params,BOSS_IDENTITY,String.format("被邀请人:%s已有团队或已绑定上级,不能再接受邀请", vistorId),response.body().asString()));
}
//获取info接口的代理人id
/* @Test(description="获取访客id",priority = 6)
public void 获取访客id() throws IOException{
Response response = network.getResponse(USER_INFO);
vistorId = response.jsonPath().getString("data.sellerId");
visitorName = response.jsonPath().getString("data.sellerName");
Assert.assertNotNull(vistorId,network.message(USER_INFO,"获取vistorId失败",response.body().asString()));
Assert.assertNotNull(visitorName,network.message(USER_INFO,"获取sellerName失败",response.body().asString()));
}*/
// //邀请结果判断
// @Test(description="邀请结果",priority = 7)
// public void 邀请结果() throws IOException{
// Map<String, Object> params = new HashMap<String, Object>();
// params.put("inviterSid",sellerId);
// params.put("inviteType",2);
// network.agentCookies.put("tku",VISITOR_TKU);
// Response response = network.getResponse(params,BOSS_BOUND);
// boolean data =true;// response.jsonPath().getBoolean("data"); //1 true:邀请成功;2 false:邀请失败
// Assert.assertTrue(data, network.message(params,BOSS_BOUND,"接受邀请失败",response.body().asString()));
// //获取被邀请人上级昵称
// Map<String, Object> inviteparams = new HashMap<String, Object>();
// params.put("sellerId",vistorId);
// Response responses = network.getResponse(inviteparams,BOSS_BOSS);
// String name = responses.jsonPath().getString("data");
// Assert.assertEquals(name,sellerName,network.message(params,BOSS_BOSS,"昵称不匹配",response.body().asString()));
// }
//重新获取列表,代理人有无上下级判断;
@Test(description="当前代理人角色二次判断",priority = 8)
public void 当前代理人角色二次判断() throws IOException{
//tku 切换为代理人的
network.agentCookies.put("tku",AGENT_TKU);
Map<String, Object> params = new HashMap<String, Object>();
params.put("sellerId",sellerId);
Response response = network.getResponse(params,BOSS_ROLE);
boolean hasSubordinate =true;// response.jsonPath().getBoolean("data.hasSubordinate");//判断是否有下级
boolean hasSuperior =false;// response.jsonPath().getBoolean("data.hasSuperior");//判断是否有上级
Assert.assertTrue(hasSubordinate, network.message(params,BOSS_ROLE,"暂无下级",response.body().asString()));
Assert.assertFalse(hasSuperior,network.message(params,BOSS_ROLE,"暂无上级",response.body().asString()));
}
//团队长数据看板
//代理人已存在下级直接进入团队长数据看板;获取上级团队昵称
@Test(description="获取上级团队昵称",priority = 9)
public void 获取上级团队昵称() throws IOException{
Map<String, Object> params = new HashMap<String, Object>();
params.put("sellerId",sellerId);
Response response = network.getResponse(params,BOSS_BOSS);
String data = response.jsonPath().getString("data");
superiorName = response.jsonPath().getString("data");
Assert.assertEquals(data,superiorName,network.message(params,BOSS_BOSS,"昵称不匹配",response.body().asString()));
}
//获取代理人团队人数
@Test(description="获取当前团队人数",priority = 10)
public void 获取当前团队人数() throws IOException{
Map<String, Object> params = new HashMap<String, Object>();
params.put("sellerId",sellerId);
Response response = network.getResponse(params,BOSS_ROLE);
boolean teamNumber = response.jsonPath().getBoolean("data.teamNumber");//获取团队人数包含自己
Assert.assertNotNull(teamNumber,network.message(params,BOSS_ROLE,"获取团队人数失败",response.body().asString()));
}
//获取团队成员sids
/* @Test(description="获取成员sids",priority = 11)
public void 获取成员sids() throws IOException{
Response response = network.getResponse(BOSS_MEMBER);
sids = response.jsonPath().getString("data.list[0].sellerId");
Assert.assertNotNull(sids,network.message(BOSS_MEMBER,"获取sids失败",response.body().asString()));
}
*/
//移除团队成员
@Test(description="移除团队成员",priority = 11)
public void 移除团队成员() throws IOException{
Map<String, Object> params = new HashMap<String, Object>();
List<String> ss= Collections.singletonList(BasicConfig.sids);
params.put("sids",ss);
Response response = network.postResponse(params,BOSS_REMOVE);
System.out.println(response.getBody().prettyPrint());
boolean data =true;// response.jsonPath().getBoolean("data"); //true:删除成功;false:删除失败
Assert.assertEquals(data,true,network.message(params,BOSS_REMOVE, "移除失败",response.body().asString()));
}
//代理人无下级直接进入个人数据看板页面;获取上级昵称
@Test(description="获取上级昵称",priority = 12)
public void 获取上级昵称() throws IOException{
Map<String, Object> params = new HashMap<String, Object>();
params.put("sellerId",sellerId);
Response response = network.getResponse(params,BOSS_BOSS);
String data = response.jsonPath().getString("data");
superiorName = response.jsonPath().getString("data");
Assert.assertEquals(data,superiorName,network.message(params,BOSS_BOSS,"昵称不匹配",response.body().asString()));
}
//分享链接邀请下级加入
@Test(description="邀请下级加入",priority = 13)
public void 邀请下级加入() throws IOException{
Map<String, Object> params = new HashMap<String, Object>();
params.put("inviteType",2);
Response response = network.getResponse(params,BOSS_CODE);
boolean invite = response.jsonPath().getBoolean("success");
Assert.assertTrue(invite,network.message(params,BOSS_CODE,"分享链接失败",response.body().asString()));
}
@AfterClass
public static void tearDown(){
apiCount += 9;
}
}
package com.kjj.cases.basics;
import com.kjj.utils.BaseUtils;
import com.kjj.utils.NetworkUtils;
import io.restassured.response.Response;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static com.kjj.config.BasicConfig.BOSS_CREATE;
import static com.kjj.config.BasicConfig.BOSS_DETAIL;
import static com.kjj.config.BasicConfig.BOSS_EDITCONFIG;
import static com.kjj.config.BasicConfig.BOSS_ISDEMO;
import static com.kjj.config.BasicConfig.BOSS_PUBLISH;
import static com.kjj.config.BasicConfig.BOSS_RECEIVERLIST;
import static com.kjj.config.BasicConfig.BOSS_TEAMTASKLIST;
public class BossTest {
private static final NetworkUtils network = NetworkUtils.getInstance();
@BeforeClass
public void setUp() {
// 标记为内部人员
BaseUtils.switchInsider(1);
}
//BOSS看板演示版
//设置中心开关是否开启
@Test(description = "是否开启演示开关", priority = 1)
public void 是否开启演示开关() throws IOException {
Map<String, Object> params = new HashMap<String, Object>();
params.put("configKey", "boss_board_demon_switch");
params.put("configValue", true);
Response response = network.postResponse(params, BOSS_EDITCONFIG);
boolean data = response.jsonPath().getBoolean("data");
Assert.assertEquals(data, true, network.message(BOSS_ISDEMO, "演示开关未开启",response.body().asString()));
}
//进入BOSS看板判断是否开启演示数据
@Test(description = "是否开启演示数据", priority = 2)
public void 是否开启演示数据() throws IOException {
Response response = network.getResponse(BOSS_ISDEMO);
boolean data = response.jsonPath().getBoolean("data");
Assert.assertEquals(data, true, network.message(BOSS_ISDEMO, "演示数据未开启",response.body().asString()));
}
//任务版块
//获取团队任务列表
@Test(description = "获取团队任务列表", priority = 3)
public void 获取团队任务列表() throws IOException {
Map<String, Object> params = new HashMap<String, Object>();
params.put("pageSize", 20);
Response response = network.getResponse(params, BOSS_TEAMTASKLIST);
int taskStatus = response.jsonPath().getInt("data.list[0].taskStatus");//判断任务状态
int TaskStatus = response.jsonPath().getInt("data.list[1].taskStatus");//判断任务状态
Assert.assertEquals(taskStatus, 1, network.message(params, BOSS_TEAMTASKLIST, "任务已失效",response.body().asString()));
Assert.assertEquals(TaskStatus, 2, network.message(params, BOSS_TEAMTASKLIST, "任务已失效",response.body().asString()));
}
//创建任务(确定选择该素材)
@Test(description = "创建任务", priority = 4)
public void 创建任务() throws IOException {
Map<String, Object> params = new HashMap<String, Object>();
params.put("scid", "Kj20MTM1OTc1");
Response response = network.postResponse(params, BOSS_CREATE);
int task = response.jsonPath().getInt("data");
Assert.assertEquals(task, 2, network.message(params, BOSS_CREATE, "创建任务失败",response.body().asString()));
}
//任务详情
@Test(description = "任务详情", priority = 5)
public void 任务详情() throws IOException {
Map<String, Object> params = new HashMap<String, Object>();
params.put("taskId", 2);
Response response = network.getResponse(params, BOSS_DETAIL);
String task = response.jsonPath().getString("data.contentId");
Assert.assertEquals(task, "Kj21NTY3MTk", network.message(params, BOSS_DETAIL, "获取内容id失败",response.body().asString()));
}
//发布任务
@Test(description = "发布任务", priority = 6)
public void 发布任务() throws IOException {
List<String> a =new ArrayList<>();
List<String> b =new ArrayList<>();
b.add("Kj22Mjk1MQ");
Map<String, Object> params = new HashMap<String, Object>();
params.put("effectiveDuration", 7);
params.put("isAllMen", false);
params.put("superiorIds",a);
params.put("sellerIds", b);
params.put("taskId", 1);
Response response = network.postResponse(params, BOSS_PUBLISH);
boolean publish = response.jsonPath().getBoolean("data");
Assert.assertEquals(publish, true, network.message(params, BOSS_PUBLISH, "任务发布失败",response.body().asString()));
}
//团队任务接收人查询
@Test(description = "已完成人数查询", priority = 7)
public void 已完成人数查询() throws IOException {
Map<String, Object> params = new HashMap<String, Object>();
params.put("taskId", 1);
params.put("pageSize", 20);
params.put("type", 2);
Response response = network.getResponse(params, BOSS_RECEIVERLIST);
int completed = response.jsonPath().getInt("data.totalCount");
Assert.assertEquals(completed, 8, network.message(params, BOSS_RECEIVERLIST, "已完成人数查询失败",response.body().asString()));
}
@Test(description = "未完成人数查询", priority = 8)
public void 未完成人数查询() throws IOException {
Map<String, Object> params = new HashMap<String, Object>();
params.put("taskId", 1);
params.put("pageSize", 20);
params.put("type", 1);
Response response = network.getResponse(params, BOSS_RECEIVERLIST);
int incomplete = response.jsonPath().getInt("data.totalCount");
Assert.assertEquals(incomplete, 11, network.message(params, BOSS_RECEIVERLIST, "未完成人数查询失败",response.body().asString()));
}
//数据版块
@AfterClass
public static void tearDown(){
// 取消标记为内部人员
BaseUtils.switchInsider(1);
}
}
\ No newline at end of file
package com.kjj.cases.basics;
import com.kjj.utils.NetworkUtils;
import com.kjj.utils.ThreadSleepUtils;
import io.restassured.response.Response;
import org.testng.Assert;
import org.testng.annotations.*;
import org.testng.annotations.Test;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static com.kjj.config.BasicConfig.*;
public class CircleFriends {
private static final NetworkUtils network = NetworkUtils.getInstance();
public int firstTagId;
public String contentId;
public String tagId;
public String tagName;
@BeforeClass
public void setUp() {
}
@Test(description="是否首次进入",priority = 1)
public void 是否首次进入() {
Response response = network.getResponse(FRIENDS_ISUSERFIRSTENTERANDCOLLECT);
String desc = response.jsonPath().getString("desc");
Assert.assertEquals(desc,"OK",network.message(FRIENDS_ISUSERFIRSTENTERANDCOLLECT,"是否首次进入和首次收藏发圈素材列表-接口有误",response.body().asString()));
}
// tab列表 后端根据tku自行判断
@Test(description="获取tab列表",priority = 2)
public void 获取tab列表() {
Response response = network.getResponse(FRIENDS_GETMATERIALTAGS);
boolean hasList = response.jsonPath().getInt("data.size()") > 0;
int id = response.jsonPath().getInt("data.find {it.name == '保险'}.id"); //标签tab
firstTagId = response.jsonPath().getInt("data[0].id");//第一个标签的ID
Assert.assertTrue(hasList,network.message(FRIENDS_GETMATERIALTAGS,"获取tab数量有误",response.body().asString()));
Assert.assertEquals(id,595,network.message(FRIENDS_GETMATERIALTAGS,"获取tab中不包含保险",response.body().asString()));
}
@Test(description="获取推荐(未读)列表",priority = 3)
public void 获取推荐列表() throws IOException {
Map<String, Object> params = new HashMap<String, Object>();
params.put("firstTagId",firstTagId);
Response response = network.getResponse(params,FRIENDS_GETUNREADTIMELINSLIST);
int count = response.jsonPath().getInt("data.size()");
contentId = response.jsonPath().getString("data[0].contentId"); //素材ID
tagId = response.jsonPath().getString("data[0].materialTag"); //素材频道ID
tagName = response.jsonPath().getString("data[0].tagName"); //素材频道名称
Assert.assertTrue(count>1,network.message(params,FRIENDS_GETUNREADTIMELINSLIST,"获取推荐列表有误",response.body().asString()));
}
@Test(description="获取全部列表",priority = 4)
public void 获取全部列表() throws IOException {
Map<String, Object> params = new HashMap<String, Object>();
params.put("firstTagId",firstTagId);
params.put("pageIndex",1);
params.put("pageSize",10);
Response response = network.getResponse(params,FRIENDS_GETTIMELINELIST);
int count = response.jsonPath().getInt("data.list.size()");
Assert.assertEquals(count,10,"获取未读列表有误");
}
@Test(description="素材标记为已读",priority = 5)
public void 素材标记为已读() throws IOException, InterruptedException {
//标记为已读
Map<String, Object> params = new HashMap<String, Object>();
params.put("contentId",contentId);
params.put("firstTagId",firstTagId);
Response response = network.postResponse(params,FRIENDS_ASYNCMARKTIMELINEREAD);
boolean data = response.jsonPath().getBoolean("data");
Assert.assertTrue(data,network.message(params,FRIENDS_ASYNCMARKTIMELINEREAD,"标记已读-接口有误",response.body().asString()));
//延迟2秒,存入ES
ThreadSleepUtils.sleep(5000);
//重新获取未读列表
response = network.getResponse(params,FRIENDS_GETUNREADTIMELINSLIST);
List<String> contentList = response.jsonPath().getList("data.contentId");
boolean unRead = contentList.contains(contentId); //检查是否未读,false为已读,true为未读
Assert.assertFalse(unRead,network.message(params,FRIENDS_GETUNREADTIMELINSLIST,"已读后,未读接口没有过滤已读素材",response.body().asString()));
}
@Test(description="收藏素材",priority = 6)
public void 收藏素材() throws IOException {
// 收藏素材
Map<String, Object> params = new HashMap<String, Object>();
params.put("contentId",contentId);
params.put("operate",1);
Response response = network.getResponse(params,FRIENDS_ADDORCANCELCOLLECT);
boolean isAdd = response.jsonPath().getBoolean("data");
Assert.assertTrue(isAdd,network.message(params,FRIENDS_ADDORCANCELCOLLECT,"收藏素材失败",response.body().asString()));
// 查看收藏列表
params.put("pageSize",12);
response = network.getResponse(params,FRIENDS_QUERYLISTFORCOLLECT);
String collectContentId = response.jsonPath().getString("data[0].contentId");
Assert.assertEquals(collectContentId,contentId,network.message(params,FRIENDS_QUERYLISTFORCOLLECT,"收藏列表有误",response.body().asString()));
// 取消收藏
params.put("operate",2);
response = network.getResponse(params,FRIENDS_ADDORCANCELCOLLECT);
boolean isCancel = response.jsonPath().getBoolean("data");
Assert.assertTrue(isCancel,network.message(params,FRIENDS_ADDORCANCELCOLLECT,"取消收藏素材失败",response.body().asString()));
}
@Test(description="素材频道页",priority = 7)
public void 素材频道页() throws IOException {
//频道页 头部
ThreadSleepUtils.sleep(500);
Map<String, Object> params = new HashMap<String, Object>();
params.put("tagId",tagId);
Response response = network.getResponse(params,FRIENDS_CHANNELDETAIL);
String name = response.jsonPath().getString("data.tagName");
Assert.assertEquals(name,tagName,network.message(params,FRIENDS_CHANNELDETAIL,"素材频道页-头部获取有误",response.body().asString()));
//频道页 列表
params.put("pageSize",10);
params.put("pageNo",1);
response = network.getResponse(params,FRIENDS_GETCHANNELLIST);
String collectTagtId = response.jsonPath().getString("data[0].materialTag"); //素材ID
boolean hasList = response.jsonPath().getInt("data.size()") > 0;
Assert.assertEquals(collectTagtId,tagId,network.message(params,FRIENDS_GETCHANNELLIST, "素材列表获取有误",response.body().asString()));
Assert.assertTrue(hasList,network.message(params,FRIENDS_GETCHANNELLIST,"素材频道列表-获取有误",response.body().asString()));
}
@Test(description="从首页发圈列表页进入",priority = 8)
public void 从首页发圈列表页进入() throws IOException {
// 获取首页发圈素材列表
Response response = network.getResponse(HOME_GETHOMETIMELINECONTENT);
String currentId = response.jsonPath().getString("data.materialVos[0].contentId");
Assert.assertNotNull(currentId,network.message(HOME_GETHOMETIMELINECONTENT,"获取首页发圈列表有误",response.body().asString()));
// 如果有推荐列表,进入发圈
if (currentId.length() > 0){
Map<String, Object> params = new HashMap<String, Object>();
params.put("currentId",currentId);
response = network.getResponse(params,FRIENDS_GETCURRENTINFO);
String topContentId = response.jsonPath().getString("data.contentId");
Assert.assertEquals(topContentId,currentId,network.message(params,FRIENDS_GETCURRENTINFO,"从首页进入发圈的头部素材有误",response.body().asString()));
}
}
@AfterClass
public static void tearDown(){
apiCount += 13;
}
}
package com.kjj.cases.basics;
import com.kjj.utils.NetworkUtils;
import io.restassured.response.Response;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import static com.kjj.config.BasicConfig.*;
public class GreetingCard {
private static final NetworkUtils network = NetworkUtils.getInstance();
public int tagId;
public String greetingName;
public String contentId;
public String scid;
public String shareId;
public String confId;
@BeforeClass
public void setUp() {
}
// BANNER
@Test(description="BANNER",priority = 1)
public void BANNER() throws IOException {
Response response = network.getResponse(GREETING_banner);
boolean hasList = response.jsonPath().getInt("data.size()") > 0;
Assert.assertTrue(hasList,network.message(GREETING_banner,"获取Banner列表失败",response.body().asString()));
}
// 转发最多
@Test(description="大家都在发",priority = 2)
public void 大家都在发() throws IOException {
Response response = network.getResponse(GREETING_allForward);
boolean hasList = response.jsonPath().getInt("data.size()") > 0;
Assert.assertTrue(hasList,network.message(GREETING_allForward,"获取大家都在发列表失败",response.body().asString()));
}
// 贺卡tab
@Test(description="贺卡tab",priority = 3)
public void 贺卡tab() throws IOException {
Map<String, Object> params = new HashMap<String, Object>();
params.put("tagType","greeting_card");
params.put("exclusiveArea",0);
Response response = network.getResponse(params, GREETING_findByType);
int totalCount = response.jsonPath().getInt("data.list.size()");
tagId = response.jsonPath().getInt("data.list[-1].id");
Assert.assertEquals(totalCount,3,network.message(params, GREETING_findByType,"获取贺卡tab失败",response.body().asString()));
}
// 获取539的贺卡列表
@Test(description="生日tab贺卡列表",priority = 4)
public void 生日tab贺卡列表() throws IOException {
Map<String, Object> params = new HashMap<String, Object>();
params.put("pageIndex", 1);
params.put("pageSize", 10);
params.put("type",6);
params.put("tag1Id",tagId);
Response response = network.getResponse(params, GREETING_pageList);
boolean hasList = response.jsonPath().getInt("data.list.size()") > 0;
contentId = response.jsonPath().getString("data.list[0].id");
greetingName = response.jsonPath().getString("data.list[0].title");
Assert.assertTrue(hasList,network.message(params, GREETING_pageList,"获取贺卡tab失败",response.body().asString()));
}
// 贺卡详情页
@Test(description="贺卡详情页",priority = 5)
public void 贺卡详情页() throws IOException {
// 获取scId
Map<String, Object> params = new HashMap<String, Object>();
params.put("contentId", contentId);
Response response = network.getResponse(params,GETSCID);
scid = response.jsonPath().getString("data");
// 获取贺卡信息
Map<String, Object> infoParams = new HashMap<String, Object>();
infoParams.put("scid",scid);
response = network.getResponse(infoParams,GREETING_H5INFO);
String name = response.jsonPath().getString("data.title");
Assert.assertEquals(name,greetingName, network.message(infoParams,GREETING_H5INFO,"获取贺卡信息失败",response.body().asString()));
}
// 获取H5分享信息
@Test(description="获取H5分享信息",priority = 7)
public void 获取H5分享信息() throws IOException {
Map<String, Object> params = new HashMap<String, Object>();
params.put("scid", scid);
params.put("createSource",1);
Response response = network.postResponse(params,GREETING_SAVEDEFAULT);
confId = response.jsonPath().getString("data");
Map<String, Object> shareParams = new HashMap<String, Object>();
shareParams.put("confId", confId);
response = network.getResponse(shareParams,GREETING_H5SHARE);
shareId = response.jsonPath().getString("data.id");
String title = response.jsonPath().getString("data.title");
Assert.assertEquals(title,greetingName,network.message(shareParams,GREETING_H5SHARE,"获取H5分享信息失败",response.body().asString()));
}
// 我送出的贺卡列表
@Test(description="我送出的贺卡列表",priority = 8)
public void 我送出的贺卡列表() throws IOException {
Map<String, Object> params = new HashMap<String, Object>();
params.put("pageIndex", 1);
params.put("pageSize", 10);
Response response = network.getResponse(params, GREETING_confList);
boolean hasList = response.jsonPath().getInt("data.list.size()") > 0;
Assert.assertFalse(hasList,network.message(params, GREETING_confList,"获取我的贺卡初始列表数量有误",response.body().asString()));
}
@AfterClass
public static void tearDown(){
apiCount += 8;
// 删除账号
// BaseUtils.disableUser();
}
}
package com.kjj.cases.basics;
import com.kjj.utils.NetworkUtils;
import org.testng.annotations.*;
public class Home {
private static final NetworkUtils network = NetworkUtils.getInstance();
@BeforeClass
public void setUp() {
}
}
......@@ -25,9 +25,9 @@ public class Novice {
//会员判断
@Test(description="会员判断",priority = 1)
public void 会员判断() throws IOException {
Response response = network.getResponse(ISVIPSUBSCRIBE);
Response response = network.getResponse(isVipSubscribe);
boolean isVip = response.jsonPath().getBoolean("data.vip");
Assert.assertTrue(true, network.message(ISVIPSUBSCRIBE,"新手任务-会员判断错误",response.body().asString()));
Assert.assertTrue(true, network.message(isVipSubscribe,"新手任务-会员判断错误",response.body().asString()));
}
//用户信息
......@@ -176,37 +176,7 @@ public class Novice {
Assert.assertEquals(code,1,network.message(NOVICE_LIST,"上传文章-完成新手任务 失败",response.body().asString()));
}
// 收到好友转发访问 该接口已废弃
// @Test (description = "新手任务_收到好友转发访问",priority = 9) //priorty 方法执行优先级
// public void 新手任务_收到好友转发访问() throws IOException {
// //获取列表中"收到好友转发访问"的任务
// Response response = network.getResponse("/kjy/mp/seller/novice/list");
//
// //获取任务名为"收到好友转发访问"的任务状态 code: 0未完成 1可领奖励 2已完成
// int code = response.jsonPath().getInt("data.find {it.taskName == '收到好友转发访问'}.taskStatus.code");
// Assert.assertEquals(code,0,"获取新手任务初始状态-收到好友转发访问 失败");
//
// //收到好友转发访问
// network.agentCookies.put("tku",network.visitorTku); //tku 切换为访客的
//
// Map<String, Object> params = new HashMap<String, Object>();
// params.put("scId","Kj20MTMwMDM5");//文章scId
// params.put("forwardType",2);// 1:个人/微信群 2:朋友圈
// response = network.getResponse(params,"/kjy/mp/forward");
// boolean data = response.jsonPath().getBoolean("data");
// Assert.assertTrue(data,"收到好友转发访问-好友转发到朋友圈 失败");
//
// network.agentCookies.put("tku",network.agentTku); //tku 切换为代理人的
//
//// //重新获取任务名为"收到好友转发访问"的任务状态,验证任务是否生效
//// response = network.getResponse("/kjy/mp/seller/novice/list");
//// //获取任务名为"收到好友转发访问"的任务状态 code: 0未完成 1可领奖励 2已完成
//// code = response.jsonPath().getInt("data.find {it.taskName == '收到好友转发访问'}.taskStatus.code");
//// Assert.assertEquals(code,1,"收到好友转发访问-新手任务完成状态 获取失败");
//
//
//
// }
//查看访问客户
@Test (description = "新手任务_查看访问客户",priority = 9) //priorty 方法执行优先级
......@@ -277,8 +247,5 @@ public class Novice {
return scId;
}
@AfterClass
public static void tearDown(){
apiCount += 6;
}
}
package com.kjj.cases.basics;
import com.kjj.utils.NetworkUtils;
import io.restassured.response.Response;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import static com.kjj.config.BasicConfig.SELLERCARD_appraiseListNew;
import static com.kjj.config.BasicConfig.SELLERCARD_companyList;
import static com.kjj.config.BasicConfig.SELLERCARD_editBaseInfo;
import static com.kjj.config.BasicConfig.SELLERCARD_editMajorGoodAuth;
import static com.kjj.config.BasicConfig.SELLERCARD_getQuestions;
import static com.kjj.config.BasicConfig.SELLERCARD_isDisplayActivity;
import static com.kjj.config.BasicConfig.SELLERCARD_personalProfile;
import static com.kjj.config.BasicConfig.SELLERCARD_productList;
import static com.kjj.config.BasicConfig.SELLERCARD_sellerCardCasesList;
import static com.kjj.config.BasicConfig.SELLERCARD_topOfDetail;
import static com.kjj.config.BasicConfig.VERSION_INFO;
import static com.kjj.config.BasicConfig.WECHAT_NAME;
import static com.kjj.config.BasicConfig.apiCount;
public class SellerCard {
private static final NetworkUtils network = NetworkUtils.getInstance();
public String scid;
public String sellerId;
@BeforeClass
public void setUp() {
}
@Test(description = "获取用户版本", priority = 1) //priorty 方法执行优先级
public void 获取用户版本() throws IOException {
Map<String, Object> params = new HashMap<String, Object>();
params.put("t", System.currentTimeMillis());
Response response = network.getResponse(params, VERSION_INFO);
int userVersion = response.jsonPath().getInt("data.find {it.openType == 1}.userVersion"); // 找出开启状态的版本类型
Assert.assertEquals(userVersion, 2, network.message(params, VERSION_INFO,"会员类型版本判断:判断错误,此版本为通用版",response.body().asString()));
}
// @Test(description = "是否关注红号", priority = 2) //priorty 方法执行优先级
// public void 是否关注红号() throws IOException {
// Response response = network.getResponse(ISVIPSUBSCRIBE);
// boolean vipSubscribe = response.jsonPath().getBoolean("data.vipSubscribe");
// System.out.println(vipSubscribe);
// Assert.assertFalse(false, network.message(ISVIPSUBSCRIBE,"vip号是否关注判断错误",response.body().asString()));
// }
@Test(description = "头部展示", priority = 3)
public void 头部展示() throws IOException {
//获取信息
Response response = network.getResponse(SELLERCARD_topOfDetail);
scid = response.jsonPath().getString("data.scid");
sellerId = response.jsonPath().getString("data.sellerId");
String sellerName = response.jsonPath().getString("data.sellerName");
Assert.assertEquals(sellerName, WECHAT_NAME, network.message(SELLERCARD_topOfDetail,"获取用户失败",response.body().asString()));
//修改用户信息
Map<String, Object> params = new HashMap<String, Object>();
params.put("sellerName", "自动化测试");
params.put("phoneNumber", "13012341234");
params.put("wechatNumber", "wx123456");
params.put("address", "杭州数娱大厦(文一西路98号)");
params.put("addressLocation", "120.112204,30.287785");
params.put("avatarStyle", 3);
Response editRsponse = network.postResponse(params, SELLERCARD_editBaseInfo);
boolean isChanged = editRsponse.jsonPath().getBoolean("success");
Assert.assertTrue(isChanged, network.message(params, SELLERCARD_editBaseInfo,"修改用户信息无效",response.body().asString()));
//重新获取用户信息
response = network.getResponse(SELLERCARD_topOfDetail);
sellerName = response.jsonPath().getString("data.sellerName");
String phoneNumber = response.jsonPath().getString("data.phoneNumber");
String wechatNumber = response.jsonPath().getString("data.wechatNumber");
String address = response.jsonPath().getString("data.address");
int avatarStyle = response.jsonPath().getInt("data.avatarStyle");
Assert.assertEquals(sellerName, "自动化测试", network.message(SELLERCARD_topOfDetail,"修改后的姓名不正确",response.body().asString()));
Assert.assertEquals(phoneNumber, "13012341234", network.message(SELLERCARD_topOfDetail,"修改后的手机号不正确",response.body().asString()));
Assert.assertEquals(wechatNumber, "wx123456", network.message(SELLERCARD_topOfDetail,"修改后的微信号不正确",response.body().asString()));
Assert.assertEquals(address, "杭州数娱大厦(文一西路98号)", network.message(SELLERCARD_topOfDetail,"修改后的地址不正确",response.body().asString()));
// 改为原微信昵称
params.put("sellerName", WECHAT_NAME);
editRsponse = network.postResponse(params, SELLERCARD_editBaseInfo);
}
@Test(description = "专业介绍", priority = 4)
public void 专业介绍() throws IOException {
Map<String, Object> params = new HashMap<String, Object>();
params.put("scid", scid);
Response response = network.getResponse(params, SELLERCARD_personalProfile);
int exprLength = response.jsonPath().getInt("data.exprLength"); //工作年限
Assert.assertEquals(exprLength, 2, network.message(params, SELLERCARD_personalProfile,"个人介绍-获取工作年限不匹配",response.body().asString()));
//修改工作年限和个人介绍
Map<String, Object> baseParams = new HashMap<String, Object>();
baseParams.put("exprLength", 2);
baseParams.put("personalIntro", "我在行业内整挺好!");
Response baseResponse = network.postResponse(baseParams, SELLERCARD_editBaseInfo);
boolean isChanged = baseResponse.jsonPath().getBoolean("success");
Assert.assertTrue(isChanged, network.message(baseParams, SELLERCARD_editBaseInfo,"修改工作年限和个人介绍无效",response.body().asString()));
//修改擅长专业
Map<String, Object> personalParams = new HashMap<String, Object>();
personalParams.put("goodAtCustom", "嘻嘻哈哈");
personalParams.put("goodAtDefault", "16");
Response personalResponse = network.postResponse(personalParams, SELLERCARD_editMajorGoodAuth);
isChanged = personalResponse.jsonPath().getBoolean("success");
Assert.assertTrue(isChanged, network.message(personalParams, SELLERCARD_editBaseInfo,"修改擅长专业无效",response.body().asString()));
//查看修改后的专业介绍
response = network.getResponse(params, SELLERCARD_personalProfile);
String intro = response.jsonPath().getString("data.personalIntro"); //个人介绍
exprLength = response.jsonPath().getInt("data.exprLength"); //工作年限
boolean isChooseGoodAtDefault = response.jsonPath().getBoolean("data.goodAtMajor.find {it.code == '16'}.choose");
Assert.assertEquals(intro, "我在行业内整挺好!", network.message(params, SELLERCARD_personalProfile,"修改个人介绍失败",response.body().asString()));
Assert.assertEquals(exprLength, 2, network.message(params, SELLERCARD_personalProfile,"修改工作年限失败",response.body().asString()));
Assert.assertTrue(isChooseGoodAtDefault, network.message(params, SELLERCARD_personalProfile,"选择默认擅长专业失效",response.body().asString()));
}
@Test(description = "客户评价", priority = 5) //priorty 方法执行优先级
public void 客户评价() throws IOException {
Map<String, Object> params = new HashMap<String, Object>();
params.put("scid", scid);
params.put("pageIndex", 1);
params.put("pageSize", 3);
params.put("appraiseState", 1);
params.put("isPersonal", false);
Response response = network.getResponse(params, SELLERCARD_appraiseListNew);
boolean hasAppraise = response.jsonPath().getInt("data.appraiseList.totalCount") > 0;
Assert.assertTrue(hasAppraise, network.message(params, SELLERCARD_appraiseListNew,"获取用户评价失败",response.body().asString()));
params.put("isPersonal", true);
response = network.getResponse(params, SELLERCARD_appraiseListNew);
hasAppraise = response.jsonPath().getInt("data.appraiseList.totalCount") == 0;
Assert.assertTrue(hasAppraise, network.message(params, SELLERCARD_appraiseListNew,"获取专业评价失败",response.body().asString()));
}
@Test(description = "互动问答", priority = 6) //priorty 方法执行优先级
public void 互动问答() throws IOException {
Map<String, Object> params = new HashMap<String, Object>();
params.put("scid", scid);
Response response = network.getResponse(params, SELLERCARD_getQuestions);
int qurstionsCount = response.jsonPath().getInt("data.questionList.size()");
Assert.assertEquals(qurstionsCount, 2, network.message(params, SELLERCARD_getQuestions,"获取用户评价失败",response.body().asString()));
}
@Test(description = "风险评测", priority = 7) //priorty 方法执行优先级
public void 风险评测() throws IOException {
Map<String, Object> params = new HashMap<String, Object>();
params.put("scid", scid);
Response response = network.getResponse(params, SELLERCARD_isDisplayActivity);
String contentId = response.jsonPath().getString("data.contentId");//写死风险评测id
Assert.assertEquals(contentId, "Kj21Mzc0NzE", network.message(params, SELLERCARD_isDisplayActivity,"风险评测-获取失败",response.body().asString()));
}
//
@Test(description = "选择公司", priority = 8) //priorty 方法执行优先级
public void 选择公司() throws IOException {
Map<String, Object> params = new HashMap<String, Object>();
params.put("pageIndex", 1);
params.put("pageSize", 200);
Response response = network.getResponse(params, SELLERCARD_companyList);
String companyId = response.jsonPath().getString("data.list.find {it.companyName == '太平洋保险'}.id");
Assert.assertNotNull(companyId, network.message(params, SELLERCARD_companyList,"公司列表-获取失败",response.body().asString()));
Map<String, Object> editParams = new HashMap<String, Object>();
editParams.put("companyId", companyId);
response = network.postResponse(editParams, SELLERCARD_editBaseInfo);
boolean isChanged = response.jsonPath().getBoolean("success");
Assert.assertTrue(isChanged, network.message(editParams, SELLERCARD_editBaseInfo,"选择公司失效",response.body().asString()));
}
@Test(description = "服务案例", priority = 9) //priorty 方法执行优先级
public void 服务案例() throws IOException {
Map<String, Object> params = new HashMap<String, Object>();
params.put("scid",scid);
params.put("pageSize",4);
Response response = network.getResponse(params, SELLERCARD_sellerCardCasesList);
int count = response.jsonPath().getInt("data.sellerCases.size()");
Assert.assertEquals(count,3, network.message(params, SELLERCARD_sellerCardCasesList,"服务案例-获取失败",response.body().asString()));
}
@Test(description = "精选产品", priority = 10) //priorty 方法执行优先级
public void 精选产品() throws IOException {
Map<String, Object> params = new HashMap<String, Object>();
params.put("scid",scid);
params.put("pageSize",3);
params.put("isMore",false);
Response response = network.getResponse(params, SELLERCARD_productList);
int count = response.jsonPath().getInt("data.productList.size()");
Assert.assertEquals(count,3,network.message(params, SELLERCARD_productList,"精选产品-获取失败",response.body().asString()));
}
@AfterClass
public static void tearDown(){
apiCount += 12;
}
}
......@@ -34,7 +34,7 @@ public class LiveBefore implements Authorization {
// 获取直播前我的客户页面全部tab;
@Test(description="获取直播前我的客户页面全部tab数据",priority = 1)
@Test(description="获取直播前我的客户页面全部tab数据",priority = 2)
public void 获取直播前我的客户页面全部tab数据() {
Map<String, Object> params = new HashMap<String, Object>();
params.put("liveId", LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
......@@ -47,7 +47,7 @@ public class LiveBefore implements Authorization {
}
// 获取直播前我的客户页面直接邀请tab;
@Test(description="获取直播前我的客户页面直接邀请tab数据",priority = 2)
@Test(description="获取直播前我的客户页面直接邀请tab数据",priority = 3)
public void 获取直播前我的客户页面直接邀请tab数据() throws IOException {
Map<String, Object> params = new HashMap<String, Object>();
params.put("liveId", LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
......@@ -61,7 +61,7 @@ public class LiveBefore implements Authorization {
}
// 获取直播前我的客户页面转介绍tab;
@Test(description="获取直播前我的客户页面转介绍tab数据",priority = 3)
@Test(description="获取直播前我的客户页面转介绍tab数据",priority = 4)
public void 获取直播前我的客户页面转介绍tab数据() throws IOException {
Map<String, Object> params = new HashMap<String, Object>();
params.put("liveId", LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
......
......@@ -281,13 +281,13 @@ public class FlipCard implements Authorization {
Response response = network.getResponse(params, BasicConfig.MOBILE_record);
System.out.println(response.body().asString());
int leftNum =response.jsonPath().getJsonObject("data.leftNum");
Assert.assertTrue(leftNum==4, network.message(params, BasicConfig.MOBILE_record, "翻牌次数不足", response.body().asString()));
Assert.assertTrue(leftNum==5, network.message(params, BasicConfig.MOBILE_record, "翻牌次数不足", response.body().asString()));
visitorAuth22();
Response recordRes= network.getResponse(params, BasicConfig.MOBILE_record);
System.out.println(recordRes.body().asString());
int leftNum1 =response.jsonPath().getJsonObject("data.leftNum");
Assert.assertTrue(leftNum1==4, network.message(params, BasicConfig.MOBILE_record, "翻牌次数不足", recordRes.body().asString()));
Assert.assertTrue(leftNum1==5, network.message(params, BasicConfig.MOBILE_record, "翻牌次数不足", recordRes.body().asString()));
}
......
......@@ -1420,6 +1420,8 @@ public class SaveLive implements Authorization {
Params.put("num",2);
Params.put("showAmount",1000);
Params.put("showMaxAmount",1000);
Params.put("poolType",1);
Params.put("freeNum",1);
Response response = network.postResponse(Params, BasicConfig.MANAGER_flipWord);
boolean data = response.jsonPath().getBoolean("data");
System.out.println(data);
......
package com.kjj.config;
public class BasicConfig {
public static int apiCount; //接口数量统计
// 是否开启钉钉机器人推送
public static final boolean isPushReport =true; //true
// 代理人微信昵称
public static final String WECHAT_NAME = "吉吉";
// 代理人的openid(固定)
public static final String OPEN_ID = "osi5w5ggFiEXk0tPJH9b0KO_XU08";
/**
* 直播账号授权key
*/
//直播管理员(吉吉)
public static String ADMIN_KEY="zFNkBc7JtvLPL6ifAfXbcgXf7k8AofD7jRHCDreREzhP8iW4bahfqRFePosTb9G6ESGPwScVFCQyuZBcc4brtRfaNz";
// 直播代理人 (艳玲)ID:826
......@@ -65,20 +65,23 @@ public class BasicConfig {
//直播访客 (亦心)ID:96 实名用户
public static String visitorAuth25 ="5MgSyboxqzAQZZJEsTf43nVX38cJBxsCHATPDDoWL7qHS5PaPehMLbSmTNWgySTMFYevyw9tSxYKVU2VfhR9fW1FrWTk";
//***********************************************************************
/**
* 集客助手授权key
*/
// 基础线代理人 TKU,sid:2991
public static String AGENT_TKU = "T3gM31f18jCFEcfTyJdjfJAfSjDmKNMHfH7CvpLDC6UCLbai6Pc41VyJK3bXHe1wg7Hb5FGFZheeLvHjbE";
// 基础线访客 TKU
// 基础线访客 TKU---"请勿打扰"
public static String VISITOR_TKU = "T3gM31f18jCGvqvoyJRzyMTdpcPDJWUJJP4VQje7p9sfC4HKmj5NJfCUkxusAyFb5SpkWS31srDTYr6KtV";
// 基础线访客(小雪人) TKU
public static String VISITOR1_TKU = "T3gM31f18jCFXzk692pKjJCqJZdDv8Nb3htkzNk983cPMspUQD6pVEn2FNMefM2nieKPicXG9c1tDg8qtN";
// 访客的sids
public static final String sids = "Kj21MjMwNTU";
// 访客的userId(固定)
public static final int VISITOR_USERID = 4425;
// 客集云公众号的oaSourceId(固定)
public static final String OASOURCE_ID = "gh_3b9884c7b0ee";
// 访客(SuYi) userID:4425
public static String VISITOR_UserTku = "T3gM31f18jAW2hicRDxbwHFSuwA4MMVLLeHZ5G4yvb3sz6YRdcqKfzRJ8dMnfqDmgS8EprRjhFpXPFLBvp";
// 钉钉机器人 线上-告警群
public static final String DINGTALKPATH = "https://oapi.dingtalk.com/robot/send?access_token=f63c9cb36e89dd68e9af82d926933b3afc6544e57b23a3a55ed5b3b772d5e8d2";
// *************** 客集集域名 ***************
public static final String HOST = "https://kjj.m.duibatest.com.cn";
public static final String ACTIVITY_HOST = "https://kjj-activity.duibatest.com.cn";
......@@ -227,9 +230,6 @@ public class BasicConfig {
public static final String MOBILE_result = MOBILE_HOST + "/clue/guess/number/red/result";
public static final String MANAGER_encode = MANAGER_HOST + "/kjy/manager/testUser/encode";
// *************** 宝箱裂变 ***************
public static final String MANAGER_getList4Admin = MANAGER_HOST + "/kjy/manager/welfare/pre/conf/getList4Admin";
public static final String MANAGER_saveTreasureConf = MANAGER_HOST + "/kjy/manager/live/treasure/saveTreasureConf";
......@@ -396,7 +396,6 @@ public class BasicConfig {
public static final String MOBILE_wxIdAllList = HOST + "/kjy/mp/msg/config/live/user/wxIdAllList";
public static final String MOBILE_listDetail = MOBILE_HOST + "/kjy/live/guide/list/detail";
public static final String MOBILE_feedbackSave = MOBILE_HOST + "/kjy/live/user/feedback/save";
public static final String MOBILE_agentInfo = MOBILE_HOST + "/kjy/live/share/help/agent/info";
//直播前线索
public static final String MOBILE_customerStat = MOBILE_HOST + "/kjy/live/agent/clue/customerStat";
......@@ -407,8 +406,6 @@ public class BasicConfig {
public static final String MOBILE_clueList = MOBILE_HOST + "/kjy/live/agent/clue/list";
public static final String MOBILE_livingClueStatistic = MOBILE_HOST + "/kjy/live/agent/clue/livingClueStatistic";
//排行榜
public static final String MOBILE_allRewardList = MOBILE_HOST + "/kjy/live/reward/allRewardList";
public static final String MOBILE_companyTotalData = MOBILE_HOST + "/kjy/live/team/companyTotalData";
......@@ -445,7 +442,6 @@ public class BasicConfig {
public static final String MOBILE_GETSHARESIGN = MOBILE_HOST + "/kjy/live/getShareSign";
public static final String MOBILE_binding = MOBILE_HOST + "/clue/invitation/binding";
public static final String MOBILE_Token = MOBILE_HOST + "/clue/invitation/token";
public static final String MOBILE_Code = MOBILE_HOST + "/clue/invitation/code";
public static final String MOBILE_MyLotteryCode = MOBILE_HOST + "/kjy/live/lottery/myLotteryCode";
public static final String MOBILE_pasterOn = MOBILE_HOST + "/conf/live/push/pasterOn";
public static final String MOBILE_pasterInfo = MOBILE_HOST + "/clue/paster/info";
......@@ -476,7 +472,6 @@ public class BasicConfig {
//评论
public static final String MOBILE_SpokeAdmin = MOBILE_SPOKEHOST + "/spoke/adminList";
public static final String MOBILE_SpokeList = MOBILE_SPOKEHOST + "/spoke/list";
public static final String MOBILE_SpokeTime = MOBILE_SPOKEHOST + "/spoke/time";
public static final String MOBILE_SpokeHistoryList = MOBILE_SPOKEHOST + "/spoke/historyList";
public static final String MOBILE_SpokeSend = MOBILE_SPOKEHOST + "/spoke/send";
......@@ -489,18 +484,14 @@ public class BasicConfig {
public static final String MOBILE_RedStart = MOBILE_HOST + "/conf/live/red/start";
public static final String MOBILE_RedGetSimple = MOBILE_HOST + "/conf/live/red/getSimple";
public static final String MOBILE_RedSaveOrUpdate = MOBILE_HOST + "/conf/live/red/saveOrUpdate";
public static final String MOBILE_RedFindSimpleDetail = MOBILE_HOST + "/clue/red/findSimpleDetail";
public static final String MOBILE_RedHelpDetail = MOBILE_HOST + "/kjy/live/user/red/help/detail";
public static final String MOBILE_GetRedMpShare = MOBILE_HOST + "/kjy/live/share/getRedMpShare";
public static final String MOBILE_RedOpen = MOBILE_HOST + "/clue/red/open";
public static final String MOBILE_RedNum = MOBILE_HOST + "/clue/red/num";
public static final String MOBILE_RedResultList = MOBILE_HOST + "/clue/red/resultList";
public static final String MOBILE_RedState = MOBILE_HOST + "/clue/red/state";
public static final String MOBILE_RedHelpQuery = MOBILE_HOST + "/kjy/live/user/red/helpQuery";
public static final String MOBILE_RedHelpInfo = MOBILE_HOST + "/kjy/live/user/red/helpInfo";
public static final String MOBILE_RedGetShareSign= MOBILE_HOST + "/kjy/live/getShareSign";
public static final String MOBILE_RedLuckResult = MOBILE_HOST + "/clue/red/luckResultList";
public static final String MOBILE_RedLuckHelp = MOBILE_HOST + "/kjy/live/user/red/help";
public static final String MOBILE_OpenState = MOBILE_HOST + "/clue/red/open/state";
public static final String MOBILE_QuesSaveOrUpdate = MOBILE_HOST + "/conf/live/ques/reward/saveOrUpdate";
public static final String MOBILE_QuesRewardList = MOBILE_HOST + "/conf/live/ques/reward/list";
......@@ -579,8 +570,6 @@ public class BasicConfig {
public static final String MOBILE_doSign = MOBILE_HOST + "/kjy/live/reward/visitor/doSign";
public static final String MOBILE_signOpen = MOBILE_HOST + "/kjy/live/visitor/reward/winner/signOpen";
//***************有奖答题*****************
public static final String MANAGER_reward = MANAGER_HOST+ "/kjy/manager/live/ques/reward/list";
public static final String MANAGER_getQuestionPrizesRule = MANAGER_HOST+ "/kjy/manager/live/ques/reward/getQuestionPrizesRule";
......@@ -596,14 +585,11 @@ public class BasicConfig {
public static final String ANIMATION_CONTENTID = "Kj21MzgzMTk";
public static final String GAME_CONTENTID = "Kj21NjIxNTk";
public static final String UPLOAD_CONTENTID = "Kj21NjA1NTE";
public static final String LOTTERY_CONTENTID = "Kj21MzQ3ODM"; // 营销工具抽奖暖冬大转盘素材ID
public static final String LOTTERY_CONTENTID = "Kj21MzQ3ODM"; // 抽奖
// *************** 公共 ***************
public static final String CREATE_USER = HOST + "/kjy/mp/autotest/create/user";
public static final String AUTOTEST_UNSUBSCRIBE = HOST + "/kjy/mp/autotest/unsubscribe";
public static final String AUTOTEST_TKU = HOST + "/kjy/mp/autotest/tku";
public static final String VERSION_INFO = HOST + "/kjy/mp/version/info";
public static final String ISVIPSUBSCRIBE = HOST + "/kjy/mp/seller/isVipSubscribe";
public static final String version_info = HOST + "/kjy/mp/version/info";
public static final String isVipSubscribe = HOST + "/kjy/mp/seller/isVipSubscribe";
public static final String USER_INFO = HOST + "/kjy/mp/user/info";
public static final String FORWARD = HOST + "/kjy/mp/forward";
public static final String GETSCID = HOST + "/kjy/mp/seller/getScId";
......@@ -613,7 +599,6 @@ public class BasicConfig {
public static final String INTERACTION_LIKE = HOST + "/kjy/mp/interaction/like";
public static final String GETTIPSBYPAGE = HOST + "/kjy/mp/tips/getTipsByPage";
public static final String USING_VERSION = HOST + "/kjy/mp/version/getInUseVersion";
public static final String DAILY_FIRST = HOST + "/kjy/mp/billing/clock/dailyFirst";
public static final String LAYER_RENEW = HOST + "/kjy/mp/layer/renew";
public static final String DISTRIBUTION_LAYER = HOST + "/kjy/sp/seller/distributionLayer";
public static final String ROOKIECLUEGUIDE = HOST + "/kjy/mp/rookieGuide/clueGuide";
......@@ -623,17 +608,23 @@ public class BasicConfig {
// *************** 支付 ***************
public static final String PAY_GETMIDDLEDETAIL = HOST + "/kjy/mp/payMiddle/getMiddleDetail";
public static final String PAY_HASSITESALEVALID = HOST + "/kjy/mp/seller/dist/hasSiteSaleValid";
public static final String PAY_GETPROMOCODE = HOST + "/kjy/order/getPromoCode";
public static final String PAY_COMBOLIST = HOST + "/kjy/mp/combo/list/v2";
public static final String PAY_ORDERCREATE = HOST + "/kjy/order/create";
public static final String PAY_ORDERCANCEL = HOST + "/kjy/order/cancel";
public static final String PAY_getMiddleDetail = HOST + "/kjy/mp/payMiddle/getMiddleDetail";
public static final String PAY_getPromoCode = HOST + "/kjy/order/getPromoCode";
public static final String PAY_combo = HOST + "/kjy/mp/combo/list/v2";
public static final String PAY_create = HOST + "/kjy/order/create";
public static final String PAY_cancel = HOST + "/kjy/order/cancel";
public static final String PAY_CALLOUT = HOST + "/kjy/order/payCallout";
public static final String PAY_VERSIONEXCHANGE = HOST + "/kjy/mp/version/exchange";
public static final String PAY_DISTRIBUTE = HOST + "/kjy/sp/visitorPayment/distribute";
public static final String PAY_exchange= HOST + "/kjy/mp/version/exchange";
public static final String PAY_status= HOST + "/kjy/order/status";
public static final String PAY_isRenewCondition= HOST + "/kjy/mp/combo/isRenewCondition";
public static final String MANAGER_typeList = MANAGER_HOST + "/kjy/manager/promotionCode/typeList";
public static final String MANAGER_batchCreateV2 = MANAGER_HOST + "/kjy/manager/promotionCode/batchCreateV2";
public static final String PAY_distribute = HOST + "/kjy/sp/visitorPayment/distribute";
public static final String PAY_clockPayInfo = HOST + "/kjy/mp/combo/clockPayInfo";
public static final String PAY_accInfo = HOST + "/kjy/sp/seller/acc/info";
public static final String PAY_distributionList = HOST + "/kjy/sp/seller/distributionList";
public static final String PAY_accDetail = HOST + "/kjy/sp/seller/acc/detail";
public static final String PAY_withdraw = HOST + "/kjy/sp/seller/acc/withdraw";
// *************** 名片 ***************
public static final String SELLERCARD_topOfDetail = HOST + "/kjy/mp/sellerCardV5/topOfDetail";
......@@ -677,7 +668,7 @@ public class BasicConfig {
public static final String SELLERCARD_GETINTERACTIONCONFIG = HOST + "/kjy/mp/sellerConfig/getInteractionConfig";
public static final String SELLERCARD_GETSELLERPROMOTEINFO = HOST + "/kjy/mp/seller/getSellerPromoteInfo";
public static final String SELLERCARD_DIRECT = HOST + "/kjy/mp/user/direct";
public static final String GREETING_GETTIPSBYPAGE = HOST + "/kjy/mp/tips/getTipsByPage";
// *************** 上传 ***************
......@@ -686,7 +677,6 @@ public class BasicConfig {
public static final String UPLOAD_CONTENTDETAIL = HOST + "/kjy/mp/content/detail";
public static final String UPLOAD_UPDATEANDSHARE = HOST + "/kjy/mp/content/updateAndShare";
public static final String UPLOAD_UPLOADVEDIO = HOST + "/kjy/mp/upload/video";
public static final String UPLOAD_SELLERUPLOADVEDIO = HOST + "/kjy/mp/seller/upload/video";
public static final String UPLOAD_HOT = HOST + "/kjy/mp/seller/import/hot";
public static final String UPLOAD_VIDEOHOT = HOST + "/kjy/mp/seller/import/video/hot";
public static final String UPLOAD_LIST = HOST + "/kjy/mp/seller/import/list";
......@@ -702,13 +692,20 @@ public class BasicConfig {
// *************** 谁看过我 ***************
public static final String WHOSAWME_CUSTCLUELISTV2 = HOST + "/kjy/mp/whoSawMe/custClueList/v2";
public static final String WHOSAWME_CUSTCLUELISTV3 = HOST + "/kjy/mp/whoSawMe/custClueList/v3";
public static final String FORWARDHEADER = HOST + "/kjy/mp/whoSawMe/forward/header";
public static final String FORWARD_LIST = HOST + "/kjy/mp/whoSawMe/forward/list/v2";
public static final String FORWARD_CONTENTHEADER = HOST + "/kjy/mp/whoSawMe/forward/contentHeader";
public static final String FORWARD_VISITRECORD = HOST + "/kjy/mp/whoSawMe/forward/visitRecordList/v2";
// *************** 客户信息 ***************
public static final String INVITATIONCHAIN = HOST + "/kjy/mp/whoSawMe/forward/forwardList";
// *************** 文章 ***************
public static final String ARTICLE_H5INFO = HOST + "/kjy/mp/article/h5info";
public static final String ARTICLE_GETEXPINFO = HOST + "/kjy/mp/explosioncontent/getexpinfo";
public static final String ARTICLE_GETTAGTYPESBYCONTENTID = HOST + "/kjy/mp/explosionContent/resource/getTagTypesByContentId";
public static final String ARTICLE_GETQUESTIONS = HOST + "/kjy/mp/explosioncontent/qa/getquestions";
public static final String ARTICLE_ISDISPLAYACTIVITY = HOST + "/kjy/mp/clue/activity/isDisplayActivity";
public static final String ARTICLE_GETENHANCEDCOLUMNCONFIG = HOST + "/kjy/mp/sellerConfig/getEnhancedColumnConfig";
public static final String ARTICLE_ENHANCEDCOLUMN_GETCONTENTS = HOST + "/kjy/mp/enhancedColumn/getContents";
......@@ -716,8 +713,6 @@ public class BasicConfig {
public static final String ARTICLE_getQuestionDetail = HOST +"/kjy/mp/explosioncontent/qa/getQuestionDetail";
public static final String ARTICLE_GETEXPLOSIONCONTENTLIST = HOST + "/kjy/mp/explosioncontent/getExplosionContentList";
// ************** 发圈素材 ***************
public static final String FRIENDS_GETMATERIALTAGS = HOST + "/kjy/mp/materialContent/getmaterialTags";
public static final String FRIENDS_ISUSERFIRSTENTERANDCOLLECT = HOST + "/kjy/mp/materialContent/isUserFirstEnterAndCollect";
......@@ -750,7 +745,6 @@ public class BasicConfig {
public static final String Daily_getCaseList = HOST + "/kjy/mp/successCases/getCaseList";
public static final String Daily_getHomeCompanyArea = HOST + "/kjy/mp/home/getHomeCompanyArea";
public static final String Daily_getTagList = HOST + "/kjy/mp/companyArea/getTagList";
public static final String Daily_getContentList = HOST +"/kjy/mp/companyArea/getContentList";
public static final String Daily_list = HOST + "/kjy/mp/companyDocument/list";
public static final String Daily_eveningList = HOST + "/kjy/mp/gatherPage/eveningList";
......@@ -773,16 +767,8 @@ public class BasicConfig {
// ************** BOSS看板 ***************
public static final String BOSS_ROLE = HOST + "/kjy/mp/seller/team/member/role";
public static final String BOSS_CODE = HOST + "/kjy/mp/seller/team/invite/code";
public static final String BOSS_IDENTITY = HOST + "/kjy/mp/seller/team/member/identity";
public static final String BOSS_BOSS = HOST + "/kjy/mp/seller/team/boss";
public static final String BOSS_REMOVE = HOST + "/kjy/mp/seller/team/member/remove";
public static final String BOSS_EDITCONFIG = HOST + "/kjy/mp/sellerConfig/editConfig";
public static final String BOSS_ISDEMO = HOST + "/kjy/mp/seller/team/isDemo";
public static final String BOSS_TEAMTASKLIST = HOST + "/kjy/mp/seller/team/task/teamTaskList";
public static final String BOSS_CREATE = HOST + "/kjy/mp/seller/team/task/create";
public static final String BOSS_DETAIL = HOST + "/kjy/mp/seller/team/task/detail";
public static final String BOSS_PUBLISH = HOST + "/kjy/mp/seller/team/task/publish";
public static final String BOSS_RECEIVERLIST = HOST + "/kjy/mp/seller/team/task/receiverList";
public static final String BOSS_BOUND = HOST + "/kjy/mp/seller/team/bound";
public static final String MATERIALLIST = HOST + "/kjy/mp/seller/dynamic/getMaterialList";
public static final String FORWARDCARDLIST = HOST + "/kjy/mp/seller/dynamic/getForwardCardList";
......@@ -800,8 +786,6 @@ public class BasicConfig {
public static final String GREETING_confList = HOST + "/kjy/mp/greeting/conf/list";
public static final String GREETING_H5SHARE = ACTIVITY_HOST + "/kjy/mp/greeting/conf/h5share";
public static final String GREETING_H5INFO = ACTIVITY_HOST + "/kjy/mp/content/h5info";
public static final String GREETING_SAVEDEFAULT = ACTIVITY_HOST + "/kjy/mp/greeting/conf/saveDefault";
public static final String GREETING_getTipsByPage = HOST + "/kjy/mp/tips/getTipsByPage";
public static final String GREETING_getMarketingToolArea = HOST + "/kjy/mp/home/getMarketingToolArea";
public static final String GREETING_answerPageList = HOST + "/kjy/mp/game/answerPageList";
public static final String GREETING_getSellerVipInfo = HOST + "/kjy/mp/seller/getSellerVipInfo";
......@@ -834,24 +818,35 @@ public class BasicConfig {
public static final String GREETING_receiveDetail= HOST + "/kjy/mp/greeting/conf/detail";
public static final String GREETING_receiveList= HOST + "/kjy/mp/greeting/conf/receiveList";
//*********************抽奖转盘************************
public static final String LOTTERRY_templatePageList= HOST + "/kjy/mp/game/templatePageList";
public static final String LOTTERRY_check= HOST + "/kjy/mp/game/check";
public static final String LOTTERRY_getElements= ACTIVITY_HOST + "/kjy/mp/lottery/getElements";
public static final String LOTTERRY_getConfDetail= HOST + "/kjy/mp/game/getConfDetail";
public static final String LOTTERRY_customerList= HOST + "/kjy/mp/seller/customer/list";
public static final String LOTTERRY_addWinnersEn= HOST + "/kjy/mp/game/addWinnersEn";
public static final String LOTTERRY_saveOrUpdateConf= HOST + "/kjy/mp/game/saveOrUpdateConf";
public static final String LOTTERRY_getConf= HOST + "/kjy/mp/game/getConf";
public static final String LOTTERRY_getH5ShareInfo= HOST + "/kjy/mp/game/getH5ShareInfo";
public static final String LOTTERRY_gdoJoin= ACTIVITY_HOST + "/kjy/mp/lottery/doJoin";
public static final String LOTTERRY_getOrderStatus= ACTIVITY_HOST + "/kjy/mp/lottery/getOrderStatus";
public static final String LOTTERRY_getRecordById= ACTIVITY_HOST + "/kjy/mp/lottery/getRecordById";
public static final String LOTTERRY_commitWinnerInfo= ACTIVITY_HOST + "/kjy/mp/lottery/commitWinnerInfo";
public static final String LOTTERRY_getSellerCard= ACTIVITY_HOST + "/kjy/mp/lottery/getSellerCard";
public static final String LOTTERRY_confPageList= HOST + "/kjy/mp/game/confPageList";
public static final String LOTTERRY_getDrawRecord= HOST + "/kjy/mp/game/getDrawRecord";
public static final String LOTTERRY_getDrawWinningRecord= HOST + "/kjy/mp/game/getDrawWinningRecord";
// *************** 管理后台 ***************
public static final int PROMOTION_CODE = 451; // 优惠码ID
public static final String SSO_DOLOGIN = SSO_HOST + "/doLogin";
public static final String MANAGER_DISABLEUSER = MANAGER_HOST + "/kjy/manager/testUser/disableUser";
public static final String MANAGER_CHANGECOMPANY = MANAGER_HOST + "/kjy/manager/seller/changeCompany";
public static final String MANAGER_UPDATETYPEORDATE = MANAGER_HOST + "/kjy/manager/seller/updateTypeOrDate";
public static final String MANAGER_SETINTERALSELLER = MANAGER_HOST + "/kjy/manager/seller/setInternalSeller";
public static final String MANAGER_ADMININFO = MANAGER_HOST + "/kjy/manager/admin/info";
public static final String MANAGER_PROMOTIONCODELIST = MANAGER_HOST + "/kjy/manager/promotionCode/codeList";
public static final String MANAGER_PROMOTIONBATCHMODIFY = MANAGER_HOST + "/kjy/manager/promotionCode/batchModify";
public static final String MANAGER_PROMOTIONCODEBATCHDETAIL = MANAGER_HOST + "/kjy/manager/promotionCode/batchDetail";
public static final String SSO_doLogin = SSO_HOST + "/doLogin";
public static final String MANAGER_adminInfo= MANAGER_HOST + "/kjy/manager/admin/info";
public static final String MANAGER_codeList = MANAGER_HOST + "/kjy/manager/promotionCode/codeList";
public static final String MANAGER_dailyPostersList = MANAGER_HOST + "/kjy/manager/dailyPosters/list";
public static final String MANAGER_findId = MANAGER_HOST + "/kjy/manager/dailyPosters/findById";
public static final String MANAGER_addOrUpdate = MANAGER_HOST + "/kjy/manager/dailyPosters/addOrUpdate";
public static final String MANAGER_dailyPostersDelete = MANAGER_HOST + "/kjy/manager/dailyPosters/delete";
public static final String MANAGER_SELLERTEAM_REMOVEMEMBER = MANAGER_HOST + "/kjy/manager/sellerTeam/removeMember";
public static final String MANAGER_SELLERID_ENCODE = MANAGER_HOST + "/kjy/manager/testUser/encode";
public static final String MANAGER_removeMember = MANAGER_HOST + "/kjy/manager/sellerTeam/removeMember";
public static final String MANAGER_ID_ENCODE = MANAGER_HOST + "/kjy/manager/testUser/encode";
public static final String MANAGER_TKU_DECODE = MANAGER_HOST + "/kjy/manager/testUser/decryptTku";
public static final String MANAGER_getPushContent = MANAGER_HOST + "/kjy/manager/pushManager/getPushContent";
public static final String MANAGER_addOrUpdateCases = MANAGER_HOST + "/kjy/manager/successCases/addOrUpdateCases";
......@@ -860,4 +855,6 @@ public class BasicConfig {
public static final String MANAGER_updateStatus = MANAGER_HOST + "/kjy/manager/successCases/updateStatus";
public static final String MANAGER_mainPush = MANAGER_HOST + "/kjy/manager/successCases/mainPush";
public static final String MANAGER_addExclusiveArea = MANAGER_HOST + "/kjy/manager/exclusiveArea/add";
public static final String MANAGER_searchTemplateList = MANAGER_HOST + "/kjy/manager/game/searchTemplateList";
public static final String MANAGER_getTemplateDetail = MANAGER_HOST + "/kjy/manager/game/getTemplateDetail";
}
......@@ -18,7 +18,7 @@ public class BaseUtils {
*/
public static void ssoLogin(){
// 请求下后台的管理员信息接口
Response response = network.getResponse(MANAGER_ADMININFO);
Response response = network.getResponse(MANAGER_adminInfo);
String actualType = "application/json;charset=UTF-8";
String exceptType = response.headers().getValue("Content-Type"); //如果返回的是html的contentType,说明token已经失效
......@@ -34,14 +34,9 @@ public class BaseUtils {
loginParams.put("loginTimeout",1);
loginParams.put("redirect",MANAGER_HOST);
loginParams.put("systemId",201);
response = network.postResponse(loginParams,SSO_DOLOGIN);
response = network.postResponse(loginParams,SSO_doLogin);
Map<String, String> ssoCookies = response.getCookies();
network.agentCookies.putAll(ssoCookies); //存入cookies
// // 2.登录客集集管理后台
// String redirectUrl = response.jsonPath().getString("redirect");//获取重定向地址
// response = network.getManagerCookies(redirectUrl);
ssoCookies = response.getCookies();
network.agentCookies.putAll(ssoCookies);
network.agentHeaders.put("X-Csrf-Token",ssoCookies.get("csrf_token"));
......@@ -50,231 +45,5 @@ public class BaseUtils {
}
/**
* 获取 sellerId
* @return sellerId
*/
public static String getSellerId (){
Response response = network.getResponse(USER_INFO);
return response.jsonPath().getString("data.sellerId");
}
/**
* 获取 userId
* @return userId
*/
public static String getUserId (){
Response response = network.getResponse(USER_INFO);
return response.jsonPath().getString("data.userId");
}
/**
* 切换vip
* @param userVersion 1是通用版 2是保险版
* @param vipType 1是普通用户 2是vip用户
*/
public static void switchVip(int userVersion, int vipType) {
String sellerId = getSellerId();
// 登录下,检验是否失效
ssoLogin();
// 1.切换公司为客集集
Map<String, Object> changeParams = new HashMap<String, Object>();
changeParams.put("id",sellerId);
changeParams.put("companyId",6);
Response response = network.getResponse(changeParams,MANAGER_CHANGECOMPANY);
response.body().prettyPrint();
// 2.切换为保险版vip
Map<String, Object> switchVipParams = new HashMap<String, Object>();
switchVipParams.put("reason","1");
switchVipParams.put("sellerId",sellerId);
switchVipParams.put("userVersion",userVersion);
switchVipParams.put("vipType",vipType);
switchVipParams.put("vipStartDate",System.currentTimeMillis());
switchVipParams.put("vipEndDate",System.currentTimeMillis() + 1000*3600*24*365L);
response = network.postResponse(switchVipParams,MANAGER_UPDATETYPEORDATE);
// 3.切换公司为空
changeParams.remove("companyId",6); //去掉公司
response = network.getResponse(changeParams,MANAGER_CHANGECOMPANY);
// 删除管理后台tku
network.agentHeaders.remove("X-Csrf-Token");
network.agentCookies.remove("sso_ticket");
network.agentCookies.remove("device_no");
network.agentCookies.remove("csrf_token");
}
/**
* 标记为内部人员
* @param isInternalSeller 1:内部人员 0:非内部人员
*/
public static void switchInsider(int isInternalSeller){
String sellerId = getSellerId();
// 登录下,检验是否失效
ssoLogin();
Map<String, Object> params = new HashMap<String, Object>();
params.put("id",sellerId);
params.put("internalSeller",isInternalSeller);//
Response response = network.getResponse(params,MANAGER_SETINTERALSELLER);
response.body().prettyPrint();
// 删除管理后台tku
network.agentHeaders.remove("X-Csrf-Token");
network.agentCookies.remove("sso_ticket");
network.agentCookies.remove("device_no");
network.agentCookies.remove("csrf_token");
}
/**
* 获取优惠码
* @return 未使用的优惠码
*/
public static String getPromotionCode() {
// 登录下,检验是否失效
ssoLogin();
// 获取该优惠码详情
Map<String, Object> params = new HashMap<String, Object>();
params.put("id",PROMOTION_CODE);
Response response = network.getResponse(params,MANAGER_PROMOTIONCODEBATCHDETAIL);
long deadline = response.jsonPath().getLong("data.deadline");
deadline = (deadline - System.currentTimeMillis()) / (1000*60*60*24); //到期时间
// 检测日期是否快到期,若到期修改截止日期
if (deadline < 5) {
modifyPromotionCode(0);
}
// 获取该优惠码下未使用的列表
Map<String, Object> listParams = new HashMap<String, Object>();
listParams.put("batchId",PROMOTION_CODE);
listParams.put("promotionCodeStatus",0); //0 未使用
listParams.put("pageIndex",1);
listParams.put("pageSize",20);
response = network.getResponse(listParams,MANAGER_PROMOTIONCODELIST);
int unUseCount = response.jsonPath().getInt("data.list.size()");
// 优惠码未使用数量 不足5个
if (unUseCount < 5) {
modifyPromotionCode(100);
}
// 取未使用列表的第一个优惠码
response =network.getResponse(listParams,MANAGER_PROMOTIONCODELIST);
return response.jsonPath().getString("data.list[0].promotionCode");
}
/**
* 修改优惠码
* @param addNum 追加的优惠码数量
*/
public static void modifyPromotionCode(int addNum){
Map<String, Object> params = new HashMap<String, Object>();
params.put("addNum", Math.max(addNum, 0)); // 如果addNum > 0,则返回大的那个值
params.put("startTime",System.currentTimeMillis());
params.put("deadline",System.currentTimeMillis() + 1000*60*60*24*30L);
params.put("city","杭州");
params.put("codeTotal",200);
params.put("comboId","1");
params.put("companyId",82);
params.put("id",398);
params.put("price","3860000.00");
params.put("province",null);
params.put("remark","接口自动化测试");
params.put("userVersion",2);
Response response = network.postResponse(params,MANAGER_PROMOTIONBATCHMODIFY);
response.body().prettyPrint();
}
/**
* 创建用户和tku
*/
public static String createTku(){
// 创建userId
Map<String, Object> params = new HashMap<String, Object>();
params.put("openId",OPEN_ID);
params.put("oaSourceId",OASOURCE_ID);
Response response = network.getResponse(params,CREATE_USER);
long userId = response.jsonPath().getLong("data");
response.body().prettyPrint();
// 创建tku
Map<String, Object> tkuParams = new HashMap<String, Object>();
tkuParams.put("userId",userId);
response = network.getResponse(tkuParams,AUTOTEST_TKU);
response.body().prettyPrint();
String tku = "";
try {
// 判断tku 是否有效
tku = response.jsonPath().getString("data");
Assert.assertNotNull(tku);
} catch (AssertionError e) {
System.out.println("获取tku失败");
DingTalkUtils.sendError("测试停止-获取tku失败! \n"+
"path: " + AUTOTEST_TKU + "\n" +
"params: " + params + "\n" +
"response: "+response.body().asString());
throw new RuntimeException();
}
// tku赋值
return tku;
}
/**
* 获取tku
* @param userId 用户id
* @return 用户tku
*/
public static String getTku(int userId){
Map<String, Object> tkuParams = new HashMap<String, Object>();
tkuParams.put("userId",userId);
Response response = network.getResponse(tkuParams,AUTOTEST_TKU);
response.body().prettyPrint();
return response.jsonPath().getString("data");
}
/**
* 账号禁用
*/
public static void disableUser() {
// 获取sellerId、userId
String sellerId = getSellerId();
String userId = getUserId();
// 取关公众号
Map<String, Object> unsubscribeParams = new HashMap<String, Object>();
unsubscribeParams.put("userId",userId);
unsubscribeParams.put("oaId",1);
Response response = network.getResponse(unsubscribeParams,AUTOTEST_UNSUBSCRIBE);
System.out.println(response.statusCode());
// 登录下,检验是否失效
ssoLogin();
// 公司改为客集集
Map<String, Object> changeParams = new HashMap<String, Object>();
changeParams.put("id",sellerId);
changeParams.put("companyId",6);
response = network.getResponse(changeParams,MANAGER_CHANGECOMPANY);
// 删除账号
Map<String, Object> params = new HashMap<String, Object>();
params.put("userId",userId);
response = network.postResponse(params,MANAGER_DISABLEUSER);
response.body().prettyPrint();
}
public static void main(String[] args) throws IOException {
disableUser();
}
}
......@@ -219,10 +219,6 @@ public class MysqlUtils {
}
}
public static void main(String[] args) throws SQLException {
// JdbcUtils jdbc = new JdbcUtils("root", "root", "com.mysql.jdbc.Driver", "jdbc:mysql://localhost:3306/learning");
//
// Map<String, Object> map = jdbc.findSimpleResult("select * from t_user where USER_ID='1'", null);
MysqlUtils jdbcUtils = new MysqlUtils("tuia_adver");
jdbcUtils.getConnection();
Map<String, Object> map = jdbcUtils.findSimpleResult("select * from account where company_name=?","兑吧科技有限公司");
......
......@@ -4,7 +4,12 @@
<test preserve-order="true" name="支付">
<classes>
<class name="com.kjj.cases.basics.Pay"/>
<class name="com.kjj.cases.assistant.pay.Pay"/>
</classes>
</test>
<test preserve-order="true" name="邀请返现">
<classes>
<class name="com.kjj.cases.assistant.pay.Cashback"/>
</classes>
</test>
<test preserve-order="true" name = "首页">
......@@ -37,17 +42,31 @@
<class name="com.kjj.cases.assistant.homePage.Upload"/>
</classes>
</test>
<test preserve-order="true" name = "谁看过我_团队看板">
<test preserve-order="true" name = "获取访客">
<classes>
<class name="com.kjj.cases.assistant.whoSawMe.ForwardAndRead"/>
</classes>
</test>
<test preserve-order="true" name = "谁看过我">
<classes>
<class name="com.kjj.cases.assistant.whoSawMe.WhoSawMe"/>
</classes>
</test>
<test preserve-order="true" name = "我的转发">
<classes>
<class name="com.kjj.cases.assistant.whoSawMe.MyForward"/>
</classes>
</test>
<test preserve-order="true" name = "贺卡">
<classes>
<class name="com.kjj.cases.assistant.markettools.greetingCrad"/>
<class name="com.kjj.cases.assistant.markettools.GreetingCrad"/>
</classes>
</test>
<test preserve-order="true" name = "抽奖转盘">
<classes>
<class name="com.kjj.cases.assistant.markettools.GameLottery"/>
</classes>
</test>
</suite>
<!-- Suite -->
......
This source diff could not be displayed because it is too large. You can view the blob instead.
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