Commit b1f0b841 authored by xiamengchen's avatar xiamengchen

Merge branch 'master' into feature/20210805-xmc

parents efc92989 29455e09
......@@ -8,7 +8,7 @@ import org.testng.Assert;
import org.testng.annotations.*;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;
......@@ -17,12 +17,11 @@ import static com.kjj.utils.BaseUtils.*;
import static com.kjj.utils.ThreadSleepUtils.sleep;
public class NoviceGuidance implements Authorization {
private int userId; //小葡萄的用户id
private int sellerId; //小葡萄的销售id
private long userId; //小葡萄的用户id
private long sellerId; //小葡萄的销售id
private String grasscontentId; //文章id
private String scid; //转发文章的scid
private String visitId; //访问id
private String tku; //小葡萄的tku
private static final NetworkUtils network = NetworkUtils.getInstance();
@BeforeClass
public void setUp(){
......@@ -30,111 +29,22 @@ public class NoviceGuidance implements Authorization {
}
@Test(description = "禁用代理人小葡萄",priority = 1)
public void 禁用代理人小葡萄() throws UnsupportedEncodingException {
public void 禁用代理人小葡萄() throws UnsupportedEncodingException, SQLException {
//取关公众号
network.agentHeaders.put("Content-Type","text/plain");
String str = "<xml><ToUserName><![CDATA[gh_3b9884c7b0ee]]></ToUserName><FromUserName><![CDATA[osi5w5kT-smQ42Fc-ByO4G8C-E1M]]></FromUserName><CreateTime>1628040963</CreateTime><MsgType><![CDATA[event]]></MsgType><Event><![CDATA[unsubscribe]]></Event></xml>";
Response response = network.postXMLResponse(str,MANAGER_oamsg);
System.out.println("取关\n"+response.body().asString());
network.agentHeaders.put("Content-Type","application/json");
//找到小葡萄的用户id
Map<String, Object> params = new HashMap<String, Object>();
params.put("sellerName","小葡萄");
params.put("sellerId","");
params.put("pageNo",1);
params.put("pageSize",50);
params.put("agentId","");
params.put("phoneNumber","");
response = network.getResponse(params,MANAGER_vipList);
System.out.println(params.toString());
boolean success = response.jsonPath().getBoolean("success");
Object data = response.jsonPath().getJsonObject("data");
System.out.println(response.body().asString());
Assert.assertTrue(success,network.message(params,MANAGER_vipList,"接口返回失败",response.body().asString()));
Assert.assertNotNull(data,network.message(params,MANAGER_vipList,"返回数据为空",response.body().asString()));
userId = response.jsonPath().getInt("data.list.get(0).userId");
sellerId = response.jsonPath().getInt("data.list.get(0).userVersionList.get(0).sellerId");
userId = (long) unsubscribe();
//禁用账号
params.put("userId",userId);
response = network.postResponse(params,MANAGER_disableUser);
success = response.jsonPath().getBoolean("success");
boolean result = response.jsonPath().getBoolean("data");
System.out.println("禁用:"+response.body().asString());
Assert.assertTrue(success,network.message(params,MANAGER_disableUser,"接口返回失败",response.body().asString()));
Assert.assertTrue(result,network.message(params,MANAGER_disableUser,"返回数据为空",response.body().asString()));
disableUser(userId);
}
@Test(description = "小葡萄关注公众号",priority = 2)
public void 小葡萄关注公众号(){
@Test(description = "小葡萄关注公众号并切换为会员",priority = 2)
public void 小葡萄关注公众号并切换为会员() throws SQLException {
//关注公众号
network.agentHeaders.put("Content-Type","text/plain");
String str = "<xml><ToUserName><![CDATA[gh_3b9884c7b0ee]]></ToUserName><FromUserName><![CDATA[osi5w5kT-smQ42Fc-ByO4G8C-E1M]]></FromUserName><CreateTime>1628040971</CreateTime><MsgType><![CDATA[event]]></MsgType><Event><![CDATA[subscribe]]></Event></xml>";
Response response = network.postXMLResponse(str,MANAGER_oamsg);
System.out.println("关注\n"+response.body().asString());
sleep(5000);
network.agentHeaders.put("Content-Type","application/json");
//找到小葡萄的用户id
Map<String, Object> params = new HashMap<String, Object>();
params.put("sellerName","小葡萄");
params.put("sellerId","");
params.put("pageNo",1);
params.put("pageSize",50);
params.put("agentId","");
params.put("phoneNumber","");
response = network.getResponse(params,MANAGER_vipList);
System.out.println(params.toString());
boolean success = response.jsonPath().getBoolean("success");
Object data = response.jsonPath().getJsonObject("data");
System.out.println(response.body().asString());
Assert.assertTrue(success,network.message(params,MANAGER_vipList,"接口返回失败",response.body().asString()));
Assert.assertNotNull(data,network.message(params,MANAGER_vipList,"返回数据为空",response.body().asString()));
userId = response.jsonPath().getInt("data.list.get(0).userId");
sellerId = response.jsonPath().getInt("data.list.get(0).userVersionList.get(0).sellerId");
//切换代理人公司
params.clear();
params.put("id",sellerId);
params.put("companyId",6);
response = network.getResponse(params,MANAGER_changeCompany);
System.out.println(params.toString());
success = response.jsonPath().getBoolean("success");
boolean result = response.jsonPath().getBoolean("data");
System.out.println(response.body().asString());
Assert.assertTrue(success,network.message(params,MANAGER_changeCompany,"接口返回失败",response.body().asString()));
Assert.assertTrue(result,network.message(params,MANAGER_changeCompany,"返回数据为空",response.body().asString()));
userId = (long) subscribe();
//切换会员
params.put("reason","测试账号");
params.put("sellerId",sellerId);
params.put("userVersion",2);
params.put("vipEndDate","2022-08-04T07:10:03.582Z");
params.put("vipStartDate","2021-08-04T07:10:03.582Z");
params.put("vipType",2);
response = network.postResponse(params,MANAGER_updateTypeOrDate);
success = response.jsonPath().getBoolean("success");
result = response.jsonPath().getBoolean("data");
Assert.assertTrue(success,network.message(params,MANAGER_updateTypeOrDate,"接口返回失败",response.body().asString()));
Assert.assertTrue(result,network.message(params,MANAGER_updateTypeOrDate,"返回数据为空",response.body().asString()));
}
@Test(description = "获取小葡萄的tku",priority = 3)
public void 获取小葡萄的tku(){
Map<String, Object> params = new HashMap<String, Object>();
params.put("userId",userId);
params.put("validDays",365);
Response response = network.getResponse(params,MANAGER_encryptTku);
boolean success = response.jsonPath().getBoolean("success");
Assert.assertTrue(success,network.message(ROOKIEGUIDE_homeGuide,"接口返回失败",response.body().asString()));
tku = response.jsonPath().getString("data");
network.agentCookies.put("tku", tku);
System.out.println("代理人tku:" + tku);
updateTypeOrDate(userId);
}
@Test(description = "进入首页唤起完善名片引导",priority = 4)
@Test(description = "进入首页唤起完善名片引导",priority = 3)
public void 进入首页唤起完善名片引导(){
Response response = network.getResponse(ROOKIEGUIDE_homeGuide);
boolean success = response.jsonPath().getBoolean("success");
......@@ -143,7 +53,7 @@ public class NoviceGuidance implements Authorization {
Assert.assertEquals(guideType,11,network.message(ROOKIEGUIDE_homeGuide,"返回数据为空",response.body().asString()));
}
@Test(description = "小葡萄保存名片基本信息",priority = 5)
@Test(description = "小葡萄保存名片基本信息",priority = 4)
public void 小葡萄保存名片基本信息() {
HashMap<String, Object> params = new HashMap<String, Object>();
//修改用户信息
......@@ -154,7 +64,7 @@ public class NoviceGuidance implements Authorization {
Assert.assertTrue(success, network.message(params, SELLERCARD_editBaseInfo, "接口返回失败状态", response.body().asString()));
}
@Test(description = "进入名片后唤起新手引导",priority = 6)
@Test(description = "进入名片后唤起新手引导",priority = 5)
public void 进入名片后唤起新手引导(){
Response response = network.getResponse(SELLERCARD_CARDGUIDE);
boolean success = response.jsonPath().getBoolean("success");
......@@ -163,7 +73,7 @@ public class NoviceGuidance implements Authorization {
Assert.assertEquals(guideType,21,network.message(SELLERCARD_CARDGUIDE ,"引导类型错误",response.body().asString()));
}
@Test(description = "完成名片的新手引导",priority = 7)
@Test(description = "完成名片的新手引导",priority = 6)
public void 完成名片的新手引导(){
Map<String, Object> params = new HashMap<String, Object>();
params.put("guideType", 21);
......@@ -181,7 +91,7 @@ public class NoviceGuidance implements Authorization {
Assert.assertEquals(guideType,0,network.message(SELLERCARD_CARDGUIDE ,"引导类型错误",response.body().asString()));
}
@Test(description = "再次进入首页唤起没有新手引导",priority = 8)
@Test(description = "再次进入首页唤起没有新手引导",priority = 7)
public void 再次进入首页唤起没有新手引导(){
Response response = network.getResponse(ROOKIEGUIDE_homeGuide);
boolean success = response.jsonPath().getBoolean("success");
......@@ -190,7 +100,7 @@ public class NoviceGuidance implements Authorization {
Assert.assertEquals(guideType,12,network.message(ROOKIEGUIDE_homeGuide,"返回数据为空",response.body().asString()));
}
@Test(description = "进入谁看过我后唤起转发引导",priority = 9)
@Test(description = "进入谁看过我后唤起转发引导",priority = 8)
public void 进入谁看过我后唤起转发引导(){
Response response = network.getResponse(ROOKIECLUEGUIDE);
boolean success = response.jsonPath().getBoolean("success");
......@@ -199,7 +109,7 @@ public class NoviceGuidance implements Authorization {
Assert.assertEquals(guideType,35,network.message(ROOKIECLUEGUIDE ,"引导类型错误",response.body().asString()));
}
@Test(description = "点击完成线索的转发引导",priority = 10)
@Test(description = "点击完成线索的转发引导",priority = 9)
public void 点击完成线索的转发引导(){
Response response = network.getResponse(SELLERCARD_CARDGUIDE);
Map<String, Object> params = new HashMap<String, Object>();
......@@ -224,7 +134,7 @@ public class NoviceGuidance implements Authorization {
Assert.assertEquals(guideType,0,network.message(ROOKIECLUEGUIDE ,"引导类型错误",response.body().asString()));
}
@Test(description = "代理人转发文章后访客查看文章",priority = 11)
@Test(description = "代理人转发文章后访客查看文章",priority = 10)
public void 代理人转发文章(){
//获取种草素材id
Response response = network.getResponse(ARTICLE_GETEXPLOSIONCONTENTLIST);
......@@ -258,7 +168,7 @@ public class NoviceGuidance implements Authorization {
Assert.assertNotNull(visitId, network.message(params, CONTENT_READ, "访客记录查看素材失败", response.body().asString()));
}
@Test(description = "代理人点击谁看过我显示备注引导",priority = 12)
@Test(description = "代理人点击谁看过我显示备注引导",priority = 11)
public void 代理人点击谁看过我显示备注引导(){
network.agentCookies.put("tku", tku);
Response response = network.getResponse(ROOKIECLUEGUIDE);
......@@ -268,7 +178,7 @@ public class NoviceGuidance implements Authorization {
Assert.assertEquals(guideType,34,network.message(ROOKIECLUEGUIDE ,"引导类型错误",response.body().asString()));
}
@Test(description = "点击完成线索的备注引导",priority = 13)
@Test(description = "点击完成线索的备注引导",priority = 12)
public void 点击完成线索的备注引导(){
Response response = network.getResponse(SELLERCARD_CARDGUIDE);
Map<String, Object> params = new HashMap<String, Object>();
......@@ -285,7 +195,7 @@ public class NoviceGuidance implements Authorization {
Assert.assertTrue(success,network.message(ROOKIECLUEGUIDE ,"接口返回失败",response.body().asString()));
Assert.assertEquals(guideType,0,network.message(ROOKIECLUEGUIDE ,"引导类型错误",response.body().asString()));
}
@Test(description = "代理人转发文章后访客领取资料包",priority = 14)
@Test(description = "代理人转发文章后访客领取资料包",priority = 13)
public void 代理人转发文章后访客领取资料包(){
userTku();
sleep(2000);
......@@ -330,7 +240,7 @@ public class NoviceGuidance implements Authorization {
Assert.assertTrue(success,network.message(params,SELLERCARD_SENDPUSHFORSCAN ,"接口返回失败",response.body().asString()));
Assert.assertEquals(result,"success",network.message(params,SELLERCARD_SENDPUSHFORSCAN ,"领取赠险失败",response.body().asString()));
}
@Test(description = "代理人点击谁看过我显示备注引导",priority = 15)
@Test(description = "代理人点击谁看过我显示备注引导",priority = 14)
public void 代理人点击谁看过我显示跟进机会引导(){
network.agentCookies.put("tku", tku);
......@@ -342,7 +252,7 @@ public class NoviceGuidance implements Authorization {
Assert.assertEquals(guideType,31,network.message(ROOKIECLUEGUIDE ,"引导类型错误",response.body().asString()));
}
@Test(description = "点击完成线索的备注引导",priority = 16)
@Test(description = "点击完成线索的备注引导",priority = 15)
public void 点击完成线索的跟进机会引导(){
Response response = network.getResponse(SELLERCARD_CARDGUIDE);
Map<String, Object> params = new HashMap<String, Object>();
......@@ -373,6 +283,4 @@ public class NoviceGuidance implements Authorization {
Assert.assertTrue(success,network.message(ROOKIECLUEGUIDE ,"接口返回失败",response.body().asString()));
Assert.assertEquals(guideType,0,network.message(ROOKIECLUEGUIDE ,"引导类型错误",response.body().asString()));
}
}
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 Novice {
private static final NetworkUtils network = NetworkUtils.getInstance();
@BeforeClass
public void setUp() {
}
//会员判断
@Test(description="会员判断",priority = 1)
public void 会员判断() throws IOException {
Response response = network.getResponse(isVipSubscribe);
boolean isVip = response.jsonPath().getBoolean("data.vip");
Assert.assertTrue(true, network.message(isVipSubscribe,"新手任务-会员判断错误",response.body().asString()));
}
//用户信息
@Test(description = "用户信息",priority = 2)
public void 用户信息()throws IOException{
Response response = network.getResponse(USER_INFO);
String wxName = response.jsonPath().getString("data.wxName");
Assert.assertEquals(wxName,"Su Yi",network.message(USER_INFO,"新手任务-获取用户信息失败",response.body().asString()));
}
//新手任务列表
@Test (description = "新手任务列表",priority = 3) //priorty 方法执行优先级
public void 新手任务列表() throws IOException {
Response response = network.getResponse(NOVICE_LIST);
System.out.println(response.getBody().prettyPrint());
int length = response.jsonPath().getInt("data.size()");
Assert.assertEquals(length,12,network.message(NOVICE_LIST,"新手任务-任务列表数量不对",response.body().asString()));
}
// 关注公众号 需要微信回调,无法实现
// @Test (description = "新手任务_关注公众号",priority = 4) //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,"关注公众号-任务初始状态 获取失败");
//
// //关注导师微信号和关注客集集公众号(关注需要微信回调,无法实现)
//
// //重新获取任务名为"关注公众号"的任务状态,验证任务是否生效
//
// }
// 转发文章
@Test (description = "新手任务_转发文章",priority = 5) //priorty 方法执行优先级
public void 新手任务_转发文章() throws IOException {
//获取列表中"转发文章"的任务
Response response = network.getResponse(NOVICE_LIST);
//获取任务名为"转发文章"的任务状态 code: 0未完成 1可领奖励 2已完成
int code = response.jsonPath().getInt("data.find {it.taskName == '转发文章'}.taskStatus.code");
Assert.assertEquals(code,0,network.message(NOVICE_LIST,"转发文章-任务初始状态 获取失败",response.body().asString()));
//转发文章到朋友圈
Map<String, Object> params = new HashMap<String, Object>();
params.put("scId",getScId(ARTICLE_CONTENTID));//文章scId
params.put("forwardType",1);// 1:个人/微信群 2:朋友圈
response = network.getResponse(params,FORWARD);
boolean data = response.jsonPath().getBoolean("data");
Assert.assertTrue(data, network.message(params, FORWARD,"转发文章-转发到朋友圈 失败",response.body().asString()));
//重新获取任务名为"转发文章"的任务状态,验证任务是否生效
response = network.getResponse(NOVICE_LIST);
//获取任务名为"转发文章"的任务状态 code: 0未完成 1可领奖励 2已完成
code = response.jsonPath().getInt("data.find {it.taskName == '转发文章'}.taskStatus.code");
Assert.assertEquals(code,1,network.message(NOVICE_LIST,"转发文章-新手任务完成状态 获取失败",response.body().asString()));
}
// 转发动画
@Test (description = "新手任务_转发动画",priority = 6) //priorty 方法执行优先级
public void 新手任务_转发动画() throws IOException {
//获取列表中"转发动画"的任务
Response response = network.getResponse(NOVICE_LIST);
//获取任务名为"转发动画"的任务状态 code: 0未完成 1可领奖励 2已完成
int code = response.jsonPath().getInt("data.find {it.taskName == '转发动画'}.taskStatus.code");
Assert.assertEquals(code,0, network.message(NOVICE_LIST,"转发动画-任务初始状态 获取失败",response.body().asString()));
//转发动画到朋友圈
Map<String, Object> params = new HashMap<String, Object>();
params.put("scId",getScId(ANIMATION_CONTENTID));//动画scId
params.put("forwardType",2);// 1:个人/微信群 2:朋友圈
response = network.getResponse(params,FORWARD);
boolean data = response.jsonPath().getBoolean("data");
Assert.assertTrue(data, network.message(params, FORWARD,"转发动画-转发到朋友圈 失败",response.body().asString()));
//重新获取任务名为"转发动画"的任务状态,验证任务是否生效
response = network.getResponse(NOVICE_LIST);
//获取任务名为"转发动画"的任务状态 code: 0未完成 1可领奖励 2已完成
code = response.jsonPath().getInt("data.find {it.taskName == '转发动画'}.taskStatus.code");
Assert.assertEquals(code,1,network.message(NOVICE_LIST,"转发动画-新手任务完成状态 获取失败",response.body().asString()));
}
// 转发游戏
@Test (description = "新手任务_转发游戏",priority = 7) //priorty 方法执行优先级
public void 新手任务_转发游戏() throws IOException {
//获取列表中"转发游戏"的任务
Response response = network.getResponse(NOVICE_LIST);
//获取任务名为"转发游戏"的任务状态 code: 0未完成 1可领奖励 2已完成
int code = response.jsonPath().getInt("data.find {it.taskName == '转发游戏(内测中)'}.taskStatus.code");
Assert.assertEquals(code,0,network.message(NOVICE_LIST,"转发游戏-任务初始状态 获取失败",response.body().asString()));
//转发游戏到朋友圈
Map<String, Object> params = new HashMap<String, Object>();
params.put("scId",getScId(GAME_CONTENTID));//游戏scId
params.put("forwardType",2);// 1:个人/微信群 2:朋友圈
response = network.getResponse(params,FORWARD);
boolean data = response.jsonPath().getBoolean("data");
Assert.assertTrue(data,network.message(params,FORWARD,"转发游戏-转发到朋友圈 失败",response.body().asString()));
//重新获取任务名为"转发游戏"的任务状态,验证任务是否生效
response = network.getResponse(NOVICE_LIST);
//获取任务名为"转发游戏"的任务状态 code: 0未完成 1可领奖励 2已完成
code = response.jsonPath().getInt("data.find {it.taskName == '转发游戏(内测中)'}.taskStatus.code");
Assert.assertEquals(code,1,network.message(NOVICE_LIST,"转发游戏-新手任务完成状态 获取失败",response.body().asString()));
}
//上传文章
@Test (description = "新手任务_上传文章",priority = 8) //priorty 方法执行优先级
public void 新手任务_上传文章() throws IOException {
//获取列表中"上传文章"的任务
Response response = network.getResponse(NOVICE_LIST);
//获取任务名为"上传文章"的任务状态 code: 0未完成 1可领奖励 2已完成
int code = response.jsonPath().getInt("data.find {it.taskName == '上传文章'}.taskStatus.code");
Assert.assertEquals(code,0,network.message(NOVICE_LIST,"上传文章-任务初始状态 获取失败",response.body().asString()));
//上传文章并发到朋友圈 (文章已经在上传case执行过,所以找到那篇文章进行转发就好)
Map<String, Object> params = new HashMap<String, Object>();
params.put("pageIndex",1);
params.put("pageNo",1);
params.put("pageSize",10);
//获取我的上传里文章的列表
params.put("type","article");
response = network.getResponse(params,UPLOAD_LIST);
String contentType = response.jsonPath().getString("data[0].contentType");
String contentId = response.jsonPath().getString("data[0].id");//获取文章的contentd
Assert.assertEquals(contentType, "article", network.message(params, UPLOAD_LIST,"上传文章-获取我的上传-文章列表数量有误",response.body().asString()));
//转发文章到朋友圈
Map<String, Object> shareParams = new HashMap<String, Object>();
shareParams.put("scId",getScId(contentId));
shareParams.put("forwardType",2);
response = network.getResponse(shareParams,FORWARD);
boolean data = response.jsonPath().getBoolean("data");
Assert.assertTrue(data,network.message(shareParams, FORWARD,"上传文章-发到朋友圈 失败",response.body().asString()));
//重新获取任务名为"上传文章"的任务状态,验证任务是否生效
response = network.getResponse(NOVICE_LIST);
//获取任务名为"上传文章"的任务状态 code: 0未完成 1可领奖励 2已完成
code = response.jsonPath().getInt("data.find {it.taskName == '上传文章'}.taskStatus.code");
Assert.assertEquals(code,1,network.message(NOVICE_LIST,"上传文章-完成新手任务 失败",response.body().asString()));
}
//查看访问客户
@Test (description = "新手任务_查看访问客户",priority = 9) //priorty 方法执行优先级
public void 新手任务_查看访问客户() throws IOException {
//获取列表中"查看访问客户"的任务
Response response = network.getResponse(NOVICE_LIST);
//获取任务名为"查看访问客户"的任务状态 code: 0未完成 1可领奖励 2已完成
int code = response.jsonPath().getInt("data.find {it.taskName == '查看访问客户'}.taskStatus.code");
Assert.assertEquals(code,0,network.message(NOVICE_LIST,"获取新手任务初始状态-查看访问客户 失败",response.body().asString()));
//好友转发一篇我的素材
network.agentCookies.put("tku",VISITOR_TKU); //tku 切换为访客的
Map<String, Object> params = new HashMap<String, Object>();
params.put("scId",getScId(UPLOAD_CONTENTID));//文章scId
params.put("forwardType",2);// 1:个人/微信群 2:朋友圈
response = network.getResponse(params,FORWARD);
boolean data = response.jsonPath().getBoolean("data");
Assert.assertTrue(data,network.message(params,FORWARD,"查看访问客户-好友转发到朋友圈 失败",response.body().asString()));
network.agentCookies.put("tku",AGENT_TKU); //tku 切换为代理人的
//进入谁看过我,查看访客列表
Map<String, Object> whoSawMeParams = new HashMap<String, Object>();
whoSawMeParams.put("pageIndex",1);
whoSawMeParams.put("pageSize",30);
response = network.getResponse(whoSawMeParams, WHOSAWME_CUSTCLUELISTV2);
boolean hasnext = response.jsonPath().getBoolean("data.hasNext");
int length = response.jsonPath().getInt("data.list.size()");
Assert.assertNotEquals(0,network.message(whoSawMeParams, WHOSAWME_CUSTCLUELISTV2,"获取谁看过我列表成功",response.body().asString()));
//点击查看,进入线索详情页
Map<String, Object> noviceParams = new HashMap<String, Object>();
noviceParams.put("sceneCode","noviceTask_visitorsCustomerInfoComplete");
response = network.postResponse(noviceParams,NOVICE_MONGOLIANLAYERISPLAY);
String desc = response.jsonPath().getString("desc");
//重新获取任务名为"查看访问客户"的任务状态,验证任务是否生效
response = network.getResponse(NOVICE_LIST);
//获取任务名为"查看访问客户"的任务状态 code: 0未完成 1可领奖励 2已完成
code = response.jsonPath().getInt("data.find {it.taskName == '查看访问客户'}.taskStatus.code");
Assert.assertEquals(code,1, network.message(NOVICE_LIST,"查看访问客户-新手任务完成状态 获取失败",response.body().asString()));
}
//完善名片 名片改动,此处始终会处于未完成状态,待产品优化
@Test (description = "新手任务_完善名片",priority = 9) //priorty 方法执行优先级
public void 新手任务_完善名片() throws IOException {
//获取列表中"完善名片"的任务
Response response = network.getResponse(NOVICE_LIST);
//获取任务名为"完善名片"的任务状态 code: 0未完成 1可领奖励 2已完成
int code = response.jsonPath().getInt("data.find {it.taskName == '完善名片'}.taskStatus.code");
Assert.assertEquals(code,0, network.message(NOVICE_LIST,"获取新手任务初始状态-完善名片 失败",response.body().asString()));
//完善名片
//重新获取任务名为"完善名片"的任务状态,验证任务是否生效
}
//获取ScId
public String getScId (String contentId){
Map<String, Object> params = new HashMap<String, Object>();
params.put("contentId",contentId);
Response response = network.getResponse(params, GETSCID);
String scId = response.jsonPath().getString("data");
Assert.assertNotNull(scId,network.message(params, GETSCID,"获取scId失败",response.body().asString()));
return scId;
}
}
......@@ -8,6 +8,7 @@ import com.kjj.cases.admin.Authorization;
import com.kjj.config.BasicConfig;
import com.kjj.constants.LiveConstants;
import com.kjj.utils.JsonUtil;
import com.kjj.utils.ThreadSleepUtils;
import io.restassured.response.Response;
import org.apache.commons.lang3.RandomUtils;
import org.testng.Assert;
......@@ -22,8 +23,6 @@ import static com.kjj.config.BasicConfig.*;
public class Agent implements Authorization {
@BeforeClass
public void setUp() { agentAuth(); }
public String id;
public String videoId;
public String videoTitle;
......@@ -35,14 +34,15 @@ public class Agent implements Authorization {
public String teamName;
public String sellerName;
@BeforeClass
public void setUp() { agentAuth(); }
@Test(description="获取用户信息判断是否是代理人",priority = 1)
public void 获取用户信息判断是否是代理人() {
Map<String, Object> params = new HashMap<String, Object>();
Response response = network.getResponse(params, BasicConfig.MOBILE_userInfo1);
Object data = response.jsonPath().getJsonObject("data");
System.out.println(data);
System.out.println(response.body().asString());
Object jobNumber = response.jsonPath().getJsonObject("data.jobNumber");
System.out.println(jobNumber);
Assert.assertNotNull(jobNumber, network.message(params, BasicConfig.MOBILE_userInfo1, "用户非代理人", response.body().asString()));
}
......@@ -52,8 +52,8 @@ public class Agent implements Authorization {
Map<String, Object> params = new HashMap<String, Object>();
params.put("appid","wx4d7276f866bd24c8");
Response response = network.getResponse(params, BasicConfig.MOBILE_isForbidden);
System.out.println(response.body().asString());
Boolean data =response.jsonPath().getBoolean("data");
System.out.println(data);
Assert.assertFalse(data, network.message(params, BasicConfig.MOBILE_isForbidden, "禁止分享", response.body().asString()));
}
......@@ -441,6 +441,24 @@ public class Agent implements Authorization {
}
@Test(description="获取小程序短链",priority = 28)
public void 获取小程序短链() {
Map<String, Object> params = new HashMap<String, Object>();
params.put("liveId", LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
params.put("shortType",2);
Response response =null;
for (int i = 0; i < 10; i++) {
response = network.postResponse(params,MOBILE_getShortUrl);
String data = response.jsonPath().getString("data");
System.out.println(data);
if (data!=null) return;
}
Assert.fail(network.message(params, BasicConfig.MOBILE_getShortUrl, "获取小程序短链失败", response.body().asString()));
}
}
......
......@@ -13,78 +13,71 @@ import java.util.List;
import java.util.Map;
public class Customer implements Authorization {
public String customerId;
public String lastLiveId;
public String id;
@BeforeClass
public void setUp() { agentAuth(); }
public String customerId;
@Test(description = "查询代理人客户列表_全部tab", priority = 1)
public void 查询代理人客户列表_全部tab() {
Map<String, Object> Params = new HashMap<>();
Params.put("pageIndex",1);
Params.put("pageSize",10);
Response response = network.getResponse(Params, BasicConfig.MOBILE_customerList);
@Test(description = "客户数量统计", priority = 1)
public void 客户数量统计() {
Response response = network.getResponse(BasicConfig.MOBILE_potentialCount);
System.out.println(response.body().asString());
Object list = response.jsonPath().getJsonObject("data.list");
Assert.assertNotNull(list, network.message(Params, BasicConfig.MOBILE_customerList, "未获取到中奖名单配置信息", response.body().asString()));
List<CustomerList>lists= JsonUtil.parseResponseToPageBean(response,CustomerList.class);
customerId=lists.get(0).getCustomerId();
int sumCount=response.jsonPath().getInt("data.sumCount");
Assert.assertTrue(sumCount>26, network.message(BasicConfig.MOBILE_potentialCount, "总客户数量不对", response.body().asString()));
int lastLiveCount = response.jsonPath().getJsonObject("data.lastLiveCount");
Assert.assertTrue(lastLiveCount>1, network.message(BasicConfig.MOBILE_potentialCount, "最近一场直播客户数量为null", response.body().asString()));
int potentialCount = response.jsonPath().getJsonObject("data.potentialCount");
Assert.assertTrue(potentialCount>1, network.message(BasicConfig.MOBILE_potentialCount, "准客户数量为null", response.body().asString()));
lastLiveId=response.jsonPath().getString("data.lastLiveId");
}
@Test(description = "查询代理人客户列表_高价值", priority = 2)
public void 查询代理人客户列表_高价值() {
@Test(description = "代理人最近一场直播客户列表", priority = 2)
public void 代理人最近一场直播客户列表() {
Map<String, Object> Params = new HashMap<>();
Params.put("pageIndex",1);
Params.put("pageSize",10);
Params.put("clueLevel",3);
Response response = network.getResponse(Params, BasicConfig.MOBILE_customerList);
Params.put("lastLiveId",lastLiveId);
Response response = network.getResponse(BasicConfig.MOBILE_lastLiveList);
System.out.println(response.body().asString());
Object list = response.jsonPath().getJsonObject("data.list");
Assert.assertNotNull(list, network.message(Params, BasicConfig.MOBILE_customerList, "未获取到中奖名单配置信息", response.body().asString()));
Object list=response.jsonPath().getJsonObject("data.list");
Assert.assertNotNull(list,network.message(BasicConfig.MOBILE_lastLiveList, "代理人最近一场直播客户列表为null", response.body().asString()));
}
@Test(description = "查询代理人客户列表_中价值", priority = 3)
public void 查询代理人客户列表_中价值() {
@Test(description = "准客户列表", priority = 3)
public void 准客户列表() {
Map<String, Object> Params = new HashMap<>();
Params.put("pageIndex",1);
Params.put("pageSize",10);
Params.put("clueLevel",2);
Response response = network.getResponse(Params, BasicConfig.MOBILE_customerList);
Params.put("customerType",1);//0-普通客户,1-潜在客户
Response response = network.getResponse(BasicConfig.MOBILE_customerList);
System.out.println(response.body().asString());
Object list = response.jsonPath().getJsonObject("data.list");
Assert.assertNotNull(list, network.message(Params, BasicConfig.MOBILE_customerList, "未获取到中奖名单配置信息", response.body().asString()));
Object list=response.jsonPath().getJsonObject("data.list");
Assert.assertNotNull(list,network.message(BasicConfig.MOBILE_customerList, "代理人最近一场直播客户列表为null", response.body().asString()));
}
@Test(description = "查询代理人客户列表_普通价值", priority = 4)
public void 查询代理人客户列表_普通价值() {
@Test(description = "查询代理人客户列表_全部tab", priority = 4)
public void 查询代理人客户列表_全部tab() {
Map<String, Object> Params = new HashMap<>();
Params.put("pageIndex",1);
Params.put("pageSize",10);
Params.put("clueLevel",1);
Response response = network.getResponse(Params, BasicConfig.MOBILE_customerList);
System.out.println(response.body().asString());
Object list = response.jsonPath().getJsonObject("data.list");
Assert.assertNotNull(list, network.message(Params, BasicConfig.MOBILE_customerList, "未获取到中奖名单配置信息", response.body().asString()));
}
@Test(description = "查询代理人客户数量", priority = 5)
public void 查询代理人客户数量() {
Response response = network.getResponse(BasicConfig.MOBILE_count);
System.out.println(response.body().asString());
int customerNum=response.jsonPath().getInt("data.customerNum");
Assert.assertTrue(customerNum>26, network.message(BasicConfig.MOBILE_count, "总客户数量不对", response.body().asString()));
int lastOneNewNum = response.jsonPath().getJsonObject("data.lastOneNewNum");
Assert.assertTrue(lastOneNewNum>15, network.message(BasicConfig.MOBILE_count, "上场新增客户数量", response.body().asString()));
List<CustomerList>lists= JsonUtil.parseResponseToPageBean(response,CustomerList.class);
customerId=lists.get(0).getCustomerId();
}
@Test(description = "查询客户直播线索汇总信息", priority = 6)
@Test(description = "查询客户直播线索汇总信息", priority = 5)
public void 查询客户直播线索汇总信息() {
Map<String, Object> Params = new HashMap<>();
Params.put("customerId",customerId);
......@@ -98,77 +91,84 @@ public class Customer implements Authorization {
}
@Test(description = "编辑客户基本信息", priority = 7)
@Test(description = "编辑客户基本信息", priority = 6)
public void 编辑客户基本信息() {
Map<String, Object> genderParam = new HashMap<>();
genderParam.put("customerId",customerId);
genderParam.put("key",1);
genderParam.put("value",1);
Response response = network.postResponse(genderParam,BasicConfig.MOBILE_customerUpdate);
Map<String, Object> Params = new HashMap<>();
Params.put("customerId",customerId);
Params.put("key",1);
Params.put("value",1);
Response response = network.postResponse(Params,BasicConfig.MOBILE_customerUpdate);
System.out.println(response.body().asString());
boolean data=response.jsonPath().getBoolean("data");
Assert.assertTrue(data, network.message(BasicConfig.MOBILE_customerUpdate, "性别修改失败", response.body().asString()));
Map<String, Object> ageParam = new HashMap<>();
ageParam.put("customerId",customerId);
ageParam.put("key",2);
ageParam.put("value",2);
Response ageRes = network.postResponse(ageParam,BasicConfig.MOBILE_customerUpdate);
System.out.println(ageRes.body().asString());
boolean data1=ageRes.jsonPath().getBoolean("data");
Assert.assertTrue(data1, network.message(BasicConfig.MOBILE_customerUpdate, "年龄修改失败", ageRes.body().asString()));
Map<String, Object> professionalParam = new HashMap<>();
professionalParam.put("customerId",customerId);
professionalParam.put("key",3);
professionalParam.put("value","技术");
Response professionalRes = network.postResponse(professionalParam,BasicConfig.MOBILE_customerUpdate);
System.out.println(professionalRes.body().asString());
boolean data2=professionalRes.jsonPath().getBoolean("data");
Assert.assertTrue(data2, network.message(BasicConfig.MOBILE_customerUpdate, "职业修改失败", professionalRes.body().asString()));
Map<String, Object> incomeParam = new HashMap<>();
incomeParam.put("customerId",customerId);
incomeParam.put("key",4);
incomeParam.put("value",2);
Response incomeRes = network.postResponse(incomeParam,BasicConfig.MOBILE_customerUpdate);
System.out.println(incomeRes.body().asString());
boolean data3=incomeRes.jsonPath().getBoolean("data");
Assert.assertTrue(data3, network.message(BasicConfig.MOBILE_customerUpdate, "收入修改失败", incomeRes.body().asString()));
Map<String, Object> addressParam = new HashMap<>();
addressParam.put("customerId",customerId);
addressParam.put("key",5);
addressParam.put("value","");
Response addressRes = network.postResponse(addressParam,BasicConfig.MOBILE_customerUpdate);
System.out.println(addressRes.body().asString());
boolean data4=addressRes.jsonPath().getBoolean("data");
Assert.assertTrue(data4, network.message(BasicConfig.MOBILE_customerUpdate, "所在地址修改失败", addressRes.body().asString()));
Map<String, Object> hobbyParam = new HashMap<>();
hobbyParam.put("customerId",customerId);
hobbyParam.put("key",6);
hobbyParam.put("value","打球");
Response hobbyRes = network.postResponse(hobbyParam,BasicConfig.MOBILE_customerUpdate);
System.out.println(hobbyRes.body().asString());
boolean data5=hobbyRes.jsonPath().getBoolean("data");
Assert.assertTrue(data5, network.message(BasicConfig.MOBILE_customerUpdate, "爱好修改失败", hobbyRes.body().asString()));
Map<String, Object> insuranceParam = new HashMap<>();
insuranceParam.put("customerId",customerId);
insuranceParam.put("key",7);
insuranceParam.put("value",4);
Response insuranceRes = network.postResponse(insuranceParam,BasicConfig.MOBILE_customerUpdate);
System.out.println(insuranceRes.body().asString());
boolean data6=insuranceRes.jsonPath().getBoolean("data");
Assert.assertTrue(data6, network.message(BasicConfig.MOBILE_customerUpdate, "保险意识强弱修改失败", hobbyRes.body().asString()));
Map<String, Object> bartenderParam = new HashMap<>();
bartenderParam.put("customerId",customerId);
bartenderParam.put("key",8);
bartenderParam.put("value",0);
Response bartenderRes = network.postResponse(bartenderParam,BasicConfig.MOBILE_customerUpdate);
System.out.println(bartenderRes.body().asString());
boolean data7=bartenderRes.jsonPath().getBoolean("data");
Assert.assertTrue(data7, network.message(BasicConfig.MOBILE_customerUpdate, "持保情况修改失败", hobbyRes.body().asString()));
Params.clear();
Params.put("customerId",customerId);
Params.put("key",2);
Params.put("value",2);
response = network.postResponse(Params,BasicConfig.MOBILE_customerUpdate);
System.out.println(response.body().asString());
boolean data1=response.jsonPath().getBoolean("data");
Assert.assertTrue(data1, network.message(BasicConfig.MOBILE_customerUpdate, "年龄修改失败", response.body().asString()));
Params.clear();
Params.put("customerId",customerId);
Params.put("key",3);
Params.put("value","技术");
response = network.postResponse(Params,BasicConfig.MOBILE_customerUpdate);
System.out.println(response.body().asString());
boolean data2=response.jsonPath().getBoolean("data");
Assert.assertTrue(data2, network.message(BasicConfig.MOBILE_customerUpdate, "职业修改失败", response.body().asString()));
Params.clear();
Params.put("customerId",customerId);
Params.put("key",4);
Params.put("value",2);
response = network.postResponse(Params,BasicConfig.MOBILE_customerUpdate);
System.out.println(response.body().asString());
boolean data3=response.jsonPath().getBoolean("data");
Assert.assertTrue(data3, network.message(BasicConfig.MOBILE_customerUpdate, "收入修改失败", response.body().asString()));
Params.clear();
Params.put("customerId",customerId);
Params.put("key",5);
Params.put("value","");
response = network.postResponse(Params,BasicConfig.MOBILE_customerUpdate);
System.out.println(response.body().asString());
boolean data4=response.jsonPath().getBoolean("data");
Assert.assertTrue(data4, network.message(BasicConfig.MOBILE_customerUpdate, "所在地址修改失败", response.body().asString()));
Params.clear();
Params.put("customerId",customerId);
Params.put("key",6);
Params.put("value","打球");
response = network.postResponse(Params,BasicConfig.MOBILE_customerUpdate);
System.out.println(response.body().asString());
boolean data5=response.jsonPath().getBoolean("data");
Assert.assertTrue(data5, network.message(BasicConfig.MOBILE_customerUpdate, "爱好修改失败", response.body().asString()));
Params.clear();
Params.put("customerId",customerId);
Params.put("key",7);
Params.put("value",4);
response = network.postResponse(Params,BasicConfig.MOBILE_customerUpdate);
System.out.println(response.body().asString());
boolean data6=response.jsonPath().getBoolean("data");
Assert.assertTrue(data6, network.message(BasicConfig.MOBILE_customerUpdate, "保险意识强弱修改失败", response.body().asString()));
Params.clear();
Params.put("customerId",customerId);
Params.put("key",8);
Params.put("value",0);
response = network.postResponse(Params,BasicConfig.MOBILE_customerUpdate);
System.out.println(response.body().asString());
boolean data7=response.jsonPath().getBoolean("data");
Assert.assertTrue(data7, network.message(BasicConfig.MOBILE_customerUpdate, "持保情况修改失败", response.body().asString()));
}
@Test(description = "查询客户基本信息", priority = 8)
@Test(description = "查询客户基本信息", priority = 7)
public void 查询客户基本信息() {
Map<String, Object> Params = new HashMap<>();
Params.put("customerId",customerId);
......@@ -179,7 +179,7 @@ public class Customer implements Authorization {
}
@Test(description = "查询客户详情头像信息栏", priority = 9)
@Test(description = "查询客户详情头像信息栏", priority = 8)
public void 查询客户详情头像信息栏() {
Map<String, Object> Params = new HashMap<>();
Params.put("customerId",customerId);
......@@ -189,11 +189,12 @@ public class Customer implements Authorization {
Assert.assertEquals(nickName,"朱志勇", network.message(BasicConfig.MOBILE_customerDetail, "昵称不匹配", response.body().asString()));
int clueLevel=response.jsonPath().getInt("data.clueLevel");
Assert.assertTrue(clueLevel==3, network.message(BasicConfig.MOBILE_customerDetail, "不是高价值线索", response.body().asString()));
int customerType=response.jsonPath().getInt("data.customerType");
Assert.assertTrue(customerType==1, network.message(BasicConfig.MOBILE_customerDetail, "不是准客户", response.body().asString()));
}
@Test(description = "查询客户直播场次详情信息", priority = 10)
@Test(description = "查询客户直播场次详情信息", priority = 9)
public void 查询客户直播场次详情信息() {
Map<String, Object> Params = new HashMap<>();
Params.put("customerId",customerId);
......@@ -207,7 +208,7 @@ public class Customer implements Authorization {
}
@Test(description = "修改客户备注名", priority = 11)
@Test(description = "修改客户备注名", priority = 10)
public void 修改客户备注名() {
Map<String, Object> Params = new HashMap<>();
Params.put("liveUserId",customerId);
......@@ -219,5 +220,44 @@ public class Customer implements Authorization {
}
@Test(description = "跟进机会列表", priority = 11)
public void 跟进机会列表() {
Map<String, Object> Params = new HashMap<>();
Params.put("liveVisitorId",customerId);
Params.put("pageIndex",1);
Params.put("pageSize",5);
Response response = network.getResponse(Params,BasicConfig.MOBILE_followChanceList);
System.out.println(response.body().asString());
id=response.jsonPath().getJsonObject("data.list[0].id");
Assert.assertNotNull(id, network.message(BasicConfig.MOBILE_followChanceList, "跟进机会列表为null", response.body().asString()));
}
@Test(description = "获取跟进机会回复建议", priority = 12)
public void 获取跟进机会回复建议() {
Map<String, Object> Params = new HashMap<>();
Params.put("liveVisitorId",customerId);
Response response = network.getResponse(Params,BasicConfig.MOBILE_customerGetReplyAdvice);
System.out.println(response.body().asString());
int clueType=response.jsonPath().getInt("data.adviceMsgVos[0].replyMsgList[0].clueType");
Assert.assertTrue(clueType==5, network.message(BasicConfig.MOBILE_customerGetReplyAdvice, "回复建议为null", response.body().asString()));
}
@Test(description = "跟进机会详情", priority = 12)
public void 跟进机会详情() {
Map<String, Object> Params = new HashMap<>();
Params.put("id",id);
Response response = network.getResponse(Params,BasicConfig.MOBILE_followChanceDetail);
System.out.println(response.body().asString());
int chanceType=response.jsonPath().getInt("data.chanceType");
Assert.assertTrue(chanceType==1, network.message(BasicConfig.MOBILE_followChanceDetail, "跟进类型非咨询", response.body().asString()));
String question=response.jsonPath().getString("data.question");
Assert.assertEquals(question,"咨询问题一",network.message(BasicConfig.MOBILE_followChanceDetail, "咨询问题为null", response.body().asString()));
}
}
......@@ -17,11 +17,11 @@ import java.util.List;
import java.util.Map;
public class LiveLater implements Authorization {
public String pageSize;
public List<LiveUserList> liveUserId;
@BeforeClass
public void setUp() { agentAuth(); }
public String pageSize;
public List<LiveUserList> liveUserId;
//获取回收成功案例
......
package com.kjj.cases.live.agent;
import com.kjj.cases.admin.Authorization;
import com.kjj.config.BasicConfig;
import com.kjj.constants.LiveConstants;
import com.kjj.utils.ThreadSleepUtils;
import io.restassured.response.Response;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import java.util.HashMap;
import java.util.Map;
public class Potential implements Authorization {
public String bizConfId;
@BeforeClass
public void setUp() { visitorAuth(); }
@Test(description = "直播间名片", priority =1)
public void 直播间名片() {
Map<String, Object> Params = new HashMap<>();
Params.put("liveId", LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
Response response = network.getResponse(Params, BasicConfig.ANCHOR_card);
System.out.println(response.body().asString());
Object data = response.jsonPath().getJsonObject("data");
Assert.assertNotNull(data, network.message(Params, BasicConfig.ANCHOR_card, "未获取直播间名片信息", response.body().asString()));
}
@Test(description = "获取推送问题咨询", priority =2)
public void 获取推送问题() {
Map<String, Object> Params = new HashMap<>();
Params.put("liveId", LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
Response response = network.getResponse(Params, BasicConfig.ANCHOR_questions);
System.out.println(response.body().asString());
bizConfId=response.jsonPath().getString("data[0].id");
Assert.assertNotNull(bizConfId, network.message(Params, BasicConfig.ANCHOR_questions, "为获取到问题ID", response.body().asString()));
}
@Test(description = "潜在客户提交咨询信息", priority =3)
public void 潜在客户提交信息() {
Map<String, Object> Params = new HashMap<>();
Params.put("liveId", LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
Params.put("bizConfId",bizConfId);
Params.put("chanceType",1);
Response response = network.postResponse(Params, BasicConfig.ANCHOR_submit);
System.out.println(response.body().asString());
boolean data=response.jsonPath().getBoolean("data");
Assert.assertTrue(data, network.message(Params, BasicConfig.ANCHOR_submit, "客户提交信息失败", response.body().asString()));
}
@Test(description = "潜在客户标记同意", priority =4)
public void 潜在客户标记同意() {
Map<String, Object> Params = new HashMap<>();
Params.put("liveId", LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
Params.put("bizConfId",bizConfId);
Params.put("chanceType",1);
Params.put("agreeFlag",true);
Response response = network.postResponse(Params, BasicConfig.ANCHOR_agree);
System.out.println(response.body().asString());
boolean data=response.jsonPath().getBoolean("data");
Assert.assertTrue(data, network.message(Params, BasicConfig.ANCHOR_agree, "客户未标记同意", response.body().asString()));
}
@Test(description = "获取访客已提交的问题", priority =5)
public void 获取访客已提交的问题() {
Map<String, Object> Params = new HashMap<>();
Params.put("liveId", LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
Response response = network.getResponse(Params, BasicConfig.ANCHOR_questionSubmitted);
System.out.println(response.body().asString());
String id=response.jsonPath().getString("data.id");
Assert.assertEquals(id,bizConfId, network.message(Params, BasicConfig.ANCHOR_questionSubmitted, "访客已提交的问题为null", response.body().asString()));
}
@Test(description = "获取访客跟进机会同意状态", priority =6)
public void 获取访客跟进机会同意状态() {
ThreadSleepUtils.sleep(1000);
Map<String, Object> Params = new HashMap<>();
Params.put("liveId", LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
Params.put("chanceType",1);
Params.put("bizConfId",bizConfId);
Response response = network.getResponse(Params, BasicConfig.ANCHOR_agreeStatus);
System.out.println(response.body().asString());
boolean data=response.jsonPath().getBoolean("data");
Assert.assertTrue(data, network.message(Params, BasicConfig.ANCHOR_agreeStatus, "客跟进机会同意状态为false", response.body().asString()));
}
@Test(description = "获取对话模版oss地址", priority =7)
public void 获取对话模版oss地址() {
Response response = network.getResponse(BasicConfig.ANCHOR_ossDialogue);
System.out.println(response.body().asString());
boolean data=response.jsonPath().getBoolean("data");
Assert.assertNotNull(data, network.message(BasicConfig.ANCHOR_ossDialogue, "未获取到对话模版oss地址", response.body().asString()));
}
}
......@@ -19,7 +19,6 @@ import java.util.Map;
public class LiveVisitors implements Authorization
{
public String confId_imageText;
public String confId_form;
public String confId_link;
......@@ -28,8 +27,6 @@ public class LiveVisitors implements Authorization
public String id;
public List<ResourcePushList>PushList;
/*助播端端权益列表*/
@Test(description = "助播端权益列表", priority = 1)
public void 助播端权益列表()
......@@ -251,9 +248,6 @@ public class LiveVisitors implements Authorization
Assert.assertTrue(data,network.message(params,BasicConfig.MOBILE_ResourceTestSubmit,"提交秒薪测试失败",response.body().asString()));
}
//********************代理人*************//
//********************代理人*************//
//********************代理人*************//
/*代理人端权益列表查询*/
@Test(description = "代理人端权益列表查询", priority = 14)
public void 代理人端权益列表查询()
......@@ -418,6 +412,7 @@ public class LiveVisitors implements Authorization
public void 获取推送列表()
{
adminAuth();
ThreadSleepUtils.sleep(1000);
Map<String, Object> params = new HashMap<>();
params.put("liveId", LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
params.put("confId", this.PushList.get(5).getConfId());
......@@ -454,9 +449,37 @@ public class LiveVisitors implements Authorization
Assert.assertTrue(data, network.message(params, BasicConfig.MOBILE_pasterOff, "贴片下架失败", response.body().asString()));
}
/**
* 资料-我要咨询
*/
@Test(description = "资料咨询时客户标记同意", priority =28)
public void 资料咨询时客户标记同意() {
Map<String, Object> Params = new HashMap<>();
Params.put("liveId", LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
Params.put("bizConfId",confId_link);
Params.put("chanceType",2);
Params.put("agreeFlag",true);
Response response = network.postResponse(Params, BasicConfig.ANCHOR_agree);
System.out.println(response.body().asString());
boolean data=response.jsonPath().getBoolean("data");
Assert.assertTrue(data, network.message(Params, BasicConfig.ANCHOR_agree, "客户未标记同意", response.body().asString()));
}
@Test(description = "获取访客跟进机会同意状态", priority =29)
public void 获取访客跟进机会同意状态() {
Map<String, Object> Params = new HashMap<>();
Params.put("liveId", LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
Params.put("chanceType",2);
Params.put("bizConfId",confId_link);
Response response = network.getResponse(Params, BasicConfig.ANCHOR_agreeStatus);
System.out.println(response.body().asString());
boolean data=response.jsonPath().getBoolean("data");
Assert.assertTrue(data, network.message(Params, BasicConfig.ANCHOR_agreeStatus, "客跟进机会同意状态为false", response.body().asString()));
}
}
......@@ -164,7 +164,7 @@ public class FlipCard implements Authorization {
params.put("shareType",2);
Response signRes = network.getResponse(params, BasicConfig.MOBILE_sign);
String data = signRes.jsonPath().getString("data");
this.shareSign = data;
shareSign = data;
System.out.println(shareSign);
Assert.assertNotNull(shareSign, network.message(params, BasicConfig.MOBILE_sign, "分享失败", signRes.body().asString()));
......
......@@ -49,7 +49,7 @@ public class SaveLive implements Authorization {
long broadcastTime = DateUtils.addHours(new Date(), 5).getTime();
Params.put("noticeTime", noticeTime);
Params.put("broadcastTime", broadcastTime);
Params.put("shareContent", "自动化直播");
Params.put("shareContent", "自动化直播 #{shortLink}");
Params.put("shelfStatus", 2);
Params.put("secondPoster", "https://streamimg.kjjcrm.com/kjy/image/20210201/cc999ebde48e49f99ac3f0d93480453f.jpg");
Params.put("regionType",2);
......
......@@ -97,6 +97,15 @@ public class BasicConfig {
public static final String ANCHOR_getConfDetail = MOBILE_HOST + "/conf/pre/getConfDetail";
public static final String ANCHOR_CLOSE = MOBILE_HOST + "/conf/live/close";
// *************** 准客户 ***************
public static final String ANCHOR_card = MOBILE_HOST + "/clue/agent/card";
public static final String ANCHOR_questions = MOBILE_HOST + "/kjy/live/agent/potential/questions";
public static final String ANCHOR_submit = MOBILE_HOST + "/kjy/live/agent/potential/submit";
public static final String ANCHOR_agree = MOBILE_HOST + "/kjy/live/agent/potential/agree";
public static final String ANCHOR_questionSubmitted = MOBILE_HOST + "/kjy/live/agent/potential/questionSubmitted";
public static final String ANCHOR_agreeStatus = MOBILE_HOST + "/kjy/live/agent/potential/agreeStatus";
public static final String ANCHOR_ossDialogue = MOBILE_HOST + "/kjy/live/agent/potential/ossDialogue";
// *************** 预告页配置 ***************
public static final String MANAGER_preViewWelfareList = MANAGER_HOST + "/kjy/manager/preView/conf/welfareList";
public static final String MANAGER_confMainWelfare = MANAGER_HOST + "/kjy/manager/preView/conf/confMainWelfare";
......@@ -360,15 +369,17 @@ public class BasicConfig {
//客户管理
public static final String MOBILE_potentialCount = MOBILE_HOST + "/kjy/live/agent/customer/potentialCount";
public static final String MOBILE_customerList = MOBILE_HOST + "/kjy/live/agent/customer/list";
public static final String MOBILE_count = MOBILE_HOST + "/kjy/live/agent/customer/count";
public static final String MOBILE_lastLiveList = MOBILE_HOST + "/kjy/live/agent/customer/lastLiveList";
public static final String MOBILE_basicInfo = MOBILE_HOST + "/kjy/live/agent/customer/basicInfo";
public static final String MOBILE_clueInfo = MOBILE_HOST + "/kjy/live/agent/customer/clueInfo";
public static final String MOBILE_customerUpdate = MOBILE_HOST + "/kjy/live/agent/customer/update";
public static final String MOBILE_customerDetail = MOBILE_HOST + "/kjy/live/agent/customer/detail";
public static final String MOBILE_liveInfo = MOBILE_HOST + "/kjy/live/agent/customer/liveInfo";
// public static final String MOBILE_updateRemarkName = MOBILE_HOST + "/kjy/live/agent/customer/updateRemarkName";
public static final String MOBILE_followChanceList = MOBILE_HOST + "/kjy/live/agent/customer/followChanceList";
public static final String MOBILE_customerGetReplyAdvice = MOBILE_HOST + "/kjy/live/agent/customer/getReplyAdvice";
public static final String MOBILE_followChanceDetail = MOBILE_HOST + "/kjy/live/agent/customer/followChanceDetail";
// *************** 代理人 ***************
public static final String MOBILE_recycleSuccessCase = MOBILE_HOST + "/kjy/live/agent/clue/recycleSuccessCase";
public static final String MOBILE_providerInfo = MOBILE_HOST + "/kjy/live/agent/clue/providerInfo";
......@@ -459,7 +470,7 @@ public class BasicConfig {
public static final String MOBILE_pasterOn = MOBILE_HOST + "/conf/live/push/pasterOn";
public static final String MOBILE_pasterInfo = MOBILE_HOST + "/clue/paster/info";
public static final String MOBILE_pasterOff = MOBILE_HOST + "/conf/live/push/pasterOff";
public static final String MOBILE_getShortUrl = MOBILE_HOST + "/kjy/live/share/short/getShortUrl";
//投票
......
package com.kjj.utils;
package com.kjj.sql;
import java.sql.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.alibaba.fastjson.JSON;
public class MysqlUtils {
private static final String PREFIX = "dbseccode";
private static final String secret = "CNxgrtFG2nYQUfu";
import java.sql.*;
import java.util.*;
private static Map<String, MysqlUtils> pool=new HashMap<>();
public class KjyUserDB {
private static KjyUserDB user_Utils;
//数据库用户名
private String USERNAME;// = "root";
private String USERNAME = "auto_test";
//数据库密码
private String PASSWORD; //= "yanzi";
private String PASSWORD = "881QYHoGGgc09Ngv"; //= "yanzi";
//驱动信息
private String DRIVER="com.mysql.cj.jdbc.Driver";
//数据库地址
private String URL;// = "jdbc:mysql://localhost:3306/mydb";
private String USER_URL="jdbc:mysql://rm-bp11mkg584kvjr485.mysql.rds.aliyuncs.com:3306/kjy_user";
private Connection connection;
private PreparedStatement pstmt;
private ResultSet resultSet;
private MysqlUtils(String username, String password, String url){
USERNAME = username;
PASSWORD = decode(password);
URL = url;
MysqlUtils mu = pool.get(url);
if(mu!=null){
System.out.println("--------exists");
connection = mu.connection;
}else{
connection = getConnection();
pool.put(url,this);
public static synchronized KjyUserDB getInstance(){
if (Objects.nonNull(user_Utils)){
return user_Utils;
}
// if(mu!=null) {
// try {
// mu.connection.close();
// } catch (Exception e) {
// System.out.println("mysql error:" + e.getMessage());
// }
// }
//// }else {
// connection = getConnection();
// pool.put(url,this);
}
/**
*
* @param username 用户名
* @param password 密码
* @param ip 数据库ip
* @param port 端口号
* @param databaseName 数据库名
*/
public MysqlUtils(String username, String password, String ip, String port, String databaseName){
this(username,password,"jdbc:mysql://"+ip+":"+port+"/"+databaseName);
user_Utils = new KjyUserDB();
user_Utils.initConnection();
return user_Utils;
}
/**
* 阿里云数据库连接
* @param databaseName 数据库名字
*/
public MysqlUtils(String databaseName){
this("tuia_test","dbseccode2CJMouQ2xyuEXnhe4vBzGtrDpaDbuK8Lt","47.111.157.152","3306",databaseName);
}
public static MysqlUtils mysqlDuiba(String databaseName){
return new MysqlUtils("tuia_test","dbseccode2CJMouQ2xyuEXnhe4vGtrDpavyDbuK8Lt","47.111.157.152","3306",databaseName);
}
/**
* 获得数据库的连接
* @return
*/
public Connection getConnection(){
private Connection initConnection(){
try {
try {
Class.forName(DRIVER);
......@@ -86,10 +40,7 @@ public class MysqlUtils {
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
// connection = DriverManager.getConnection(URL, USERNAME, PASSWORD);
// "jdbc:mysql://"+ip+":"+port+"/"+databaseName);
String url = URL+"?autoReconnect=true&testOnBorrow=true&testWhileIdle=true";
String url = USER_URL+"?autoReconnect=true&testOnBorrow=true&testWhileIdle=true";
connection = DriverManager.getConnection(url,USERNAME,PASSWORD);
System.out.println("数据库连接成功!");
} catch (SQLException e) {
......@@ -97,36 +48,7 @@ public class MysqlUtils {
}
return connection;
}
/**
* 增加、删除、改
* @param sql sql语句
* @param params 参数,替换 ?
* @return true or false
* @throws SQLException
*/
public boolean update(String sql, Object ...params)throws SQLException{
if(!connection.isValid(3)){
System.out.println("mysql connect is not vaild,reconnect.");
connection.close();
connection = getConnection();
pool.put(URL,this);
}
boolean flag = false;
int result = -1;
pstmt = connection.prepareStatement(sql);
int index = 1;
if(params != null && !(params.length==0)){
for(int i=0; i<params.length; i++){
pstmt.setObject(index++, params[i]);
}
}
System.out.println("SQL语句"+pstmt.toString());
result = pstmt.executeUpdate();
flag = result > 0 ? true : false;
return flag;
}
/**
* 查询结果只有一行数据
* @param sql sql语句
......@@ -138,8 +60,7 @@ public class MysqlUtils {
if(!connection.isValid(3)){
System.out.println("mysql connect is not vaild,reconnect.");
connection.close();
connection = getConnection();
pool.put(URL,this);
initConnection();
}
Map<String, Object> map = new HashMap<String, Object>();
int index = 1;
......@@ -177,8 +98,7 @@ public class MysqlUtils {
if(!connection.isValid(3)){
System.out.println("mysql connect is not vaild,reconnect.");
connection.close();
connection = getConnection();
pool.put(URL,this);
initConnection();
}
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
int index = 1;
......@@ -218,22 +138,6 @@ public class MysqlUtils {
}
}
}
public static void main(String[] args) throws SQLException {
MysqlUtils jdbcUtils = new MysqlUtils("tuia_adver");
jdbcUtils.getConnection();
Map<String, Object> map = jdbcUtils.findSimpleResult("select * from account where company_name=?","兑吧科技有限公司");
jdbcUtils.releaseConn();
}
private static String decode(String value) {
if (value.startsWith(PREFIX)) {
value = value.substring(PREFIX.length());
return BlowfishUtils.decryptBlowfish(value, secret);
}
return value;
}
}
package com.kjj.sql;
public class UserSqlFactory {
private UserSqlFactory(){}
public static final String selectUserIdByUnionId = "select id from tb_users where union_id=?";
public static final String selectUserIdByOpenId = "SELECT user_id FROM `tb_users_wx_ext` WHERE `open_id` = ?";
}
package com.kjj.utils;
import com.kjj.sql.KjyUserDB;
import com.kjj.sql.UserSqlFactory;
import io.restassured.response.Response;
import org.testng.Assert;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.*;
import static com.kjj.config.BasicConfig.*;
import static com.kjj.utils.ThreadSleepUtils.sleep;
public class BaseUtils {
private static final NetworkUtils network = NetworkUtils.getInstance();
public static String tku;
/**
* 登录管理后台
......@@ -42,6 +46,102 @@ public class BaseUtils {
network.agentHeaders.put("X-Csrf-Token",ssoCookies.get("csrf_token"));
// 免登
network.agentCookies.put("sso_ticket", "autotest");
}
/**
* 小葡萄关注客集集微信公众号
*/
public static Object subscribe() throws SQLException {
//关注公众号
// network.agentHeaders.put("Content-Type","text/plain");
String str = "<xml><ToUserName><![CDATA[gh_3b9884c7b0ee]]></ToUserName><FromUserName><![CDATA[osi5w5kT-smQ42Fc-ByO4G8C-E1M]]></FromUserName><CreateTime>1628040971</CreateTime><MsgType><![CDATA[event]]></MsgType><Event><![CDATA[subscribe]]></Event></xml>";
Response response = network.postXMLResponse(str,MANAGER_oamsg);
System.out.println("关注\n"+response.body().asString());
sleep(1000);
network.agentHeaders.put("Content-Type","application/json");
Map<String, Object> result = KjyUserDB.getInstance().findSimpleResult(UserSqlFactory.selectUserIdByOpenId, "osi5w5kT-smQ42Fc-ByO4G8C-E1M");
Object userId = result.get("user_id");
Map<String, Object> params = new HashMap<String, Object>();
params.put("userId",userId);
params.put("validDays",365);
response = network.getResponse(params,MANAGER_encryptTku);
boolean success = response.jsonPath().getBoolean("success");
Assert.assertTrue(success,network.message(ROOKIEGUIDE_homeGuide,"接口返回失败",response.body().asString()));
tku = response.jsonPath().getString("data");
network.agentCookies.put("tku", tku);
System.out.println("小葡萄tku:" + tku);
return userId;
}
/**
* 小葡萄取关客集集微信公众号
*/
public static Object unsubscribe() throws SQLException {
//取关公众号
network.agentHeaders.put("Content-Type","text/plain");
String str = "<xml><ToUserName><![CDATA[gh_3b9884c7b0ee]]></ToUserName><FromUserName><![CDATA[osi5w5kT-smQ42Fc-ByO4G8C-E1M]]></FromUserName><CreateTime>1628040963</CreateTime><MsgType><![CDATA[event]]></MsgType><Event><![CDATA[unsubscribe]]></Event></xml>";
Response response = network.postXMLResponse(str,MANAGER_oamsg);
Map<String, Object> result = KjyUserDB.getInstance().findSimpleResult(UserSqlFactory.selectUserIdByOpenId, "osi5w5kT-smQ42Fc-ByO4G8C-E1M");
System.out.println("取关\n"+response.body().asString());
network.agentHeaders.put("Content-Type","application/json");
Object userId = result.get("user_id");
return userId;
}
/**
* 禁用
*/
public static void disableUser(long userId){
Map<String, Object> params = new HashMap<String, Object>();
params.put("userId",userId);
Response response = network.postResponse(params,MANAGER_disableUser);
boolean success = response.jsonPath().getBoolean("success");
boolean result = response.jsonPath().getBoolean("data");
System.out.println("禁用:"+response.body().asString());
Assert.assertTrue(success,network.message(params,MANAGER_disableUser,"接口返回失败",response.body().asString()));
Assert.assertTrue(result,network.message(params,MANAGER_disableUser,"返回数据为空",response.body().asString()));
}
/**
* 切换为会员
*/
public static void updateTypeOrDate(long userId){
//找到用户的sellerid
Map<String, Object> params = new HashMap<String, Object>();
Response response = network.getResponse(USER_INFO);
int sellerId = response.jsonPath().getInt("data.sellerId");
Assert.assertNotNull(response.jsonPath().getJsonObject("data"),network.message(USER_INFO,"获取用户信息失败",response.body().asString()));
//切换代理人公司
params.clear();
params.put("id",sellerId);
params.put("companyId",6);
response = network.getResponse(params,MANAGER_changeCompany);
System.out.println(params.toString());
boolean success = response.jsonPath().getBoolean("success");
boolean result = response.jsonPath().getBoolean("data");
System.out.println(response.body().asString());
Assert.assertTrue(success,network.message(params,MANAGER_changeCompany,"接口返回失败",response.body().asString()));
Assert.assertTrue(result,network.message(params,MANAGER_changeCompany,"返回数据为空",response.body().asString()));
//切换会员
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");//设置日期格式
Date date = new Date();// new Date()为获取当前系统时间
Calendar cal = Calendar.getInstance();
cal.setTime(date);
cal.add(Calendar.YEAR,1);
params.put("reason","测试账号");
params.put("sellerId",sellerId);
params.put("userVersion",2);
params.put("vipEndDate",df.format(date));
params.put("vipStartDate",df.format(cal.getTime()));
params.put("vipType",2);
response = network.postResponse(params,MANAGER_updateTypeOrDate);
success = response.jsonPath().getBoolean("success");
result = response.jsonPath().getBoolean("data");
Assert.assertTrue(success,network.message(params,MANAGER_updateTypeOrDate,"接口返回失败",response.body().asString()));
Assert.assertTrue(result,network.message(params,MANAGER_updateTypeOrDate,"返回数据为空",response.body().asString()));
}
}
......@@ -125,6 +125,11 @@
<class name="com.kjj.cases.live.FreeReward.FreeReward"/>
</classes>
</test>
<test preserve-order="true" name="我要咨询">
<classes>
<class name="com.kjj.cases.live.agent.Potential"/>
</classes>
</test>
<test preserve-order="true" name="访客领取资料">
<classes>
......
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