Commit d4d51919 authored by xiamengchen's avatar xiamengchen

Merge branch 'master' into feature/20210805-xmc

parents 7570440f d1db4f51
......@@ -747,7 +747,7 @@ public class PersonCard implements Authorization {
Response response = network.getResponse(params, SELLERCARD_getQuestions);
boolean success = response.jsonPath().getBoolean("success");
Object data = response.jsonPath().getJsonObject("data");
questionId = response.jsonPath().getJsonObject("data.questionList.get(0).id");
questionId = response.jsonPath().getString("data.questionList.get(0).id");
Assert.assertTrue(success,network.message(params, SELLERCARD_getQuestions,"接口返回失败",response.body().asString()));
Assert.assertNotNull(data,network.message(params, SELLERCARD_getQuestions,"配置为空",response.body().asString()));
}
......
package com.kjj.cases.assistant.menu;
import com.kjj.cases.admin.Authorization;
import com.kjj.config.BasicConfig;
import com.kjj.utils.NetworkUtils;
import io.restassured.response.Response;
import org.testng.Assert;
import org.testng.annotations.*;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.HashMap;
import java.util.Map;
import static com.kjj.config.BasicConfig.*;
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 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(){
ssoLogin();
}
@Test(description = "禁用代理人小葡萄",priority = 1)
public void 禁用代理人小葡萄() throws UnsupportedEncodingException {
//取关公众号
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");
//禁用账号
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()));
}
@Test(description = "小葡萄关注公众号",priority = 2)
public void 小葡萄关注公众号(){
//关注公众号
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()));
//切换会员
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);
}
@Test(description = "进入首页唤起完善名片引导",priority = 4)
public void 进入首页唤起完善名片引导(){
Response response = network.getResponse(ROOKIEGUIDE_homeGuide);
boolean success = response.jsonPath().getBoolean("success");
int guideType = response.jsonPath().getInt("data.guideType");
Assert.assertTrue(success,network.message(ROOKIEGUIDE_homeGuide,"接口返回失败",response.body().asString()));
Assert.assertEquals(guideType,11,network.message(ROOKIEGUIDE_homeGuide,"返回数据为空",response.body().asString()));
}
@Test(description = "小葡萄保存名片基本信息",priority = 5)
public void 小葡萄保存名片基本信息() {
HashMap<String, Object> params = new HashMap<String, Object>();
//修改用户信息
params.put("phoneNumber", "13043214321");
params.put("jobPost", "测试");
Response response = network.postResponse(params, SELLERCARD_editBaseInfo);
boolean success = response.jsonPath().getBoolean("success");
Assert.assertTrue(success, network.message(params, SELLERCARD_editBaseInfo, "接口返回失败状态", response.body().asString()));
}
@Test(description = "进入名片后唤起新手引导",priority = 6)
public void 进入名片后唤起新手引导(){
Response response = network.getResponse(SELLERCARD_CARDGUIDE);
boolean success = response.jsonPath().getBoolean("success");
int guideType = response.jsonPath().getInt("data.guideType");
Assert.assertTrue(success,network.message(SELLERCARD_CARDGUIDE ,"接口返回失败",response.body().asString()));
Assert.assertEquals(guideType,21,network.message(SELLERCARD_CARDGUIDE ,"引导类型错误",response.body().asString()));
}
@Test(description = "完成名片的新手引导",priority = 7)
public void 完成名片的新手引导(){
Map<String, Object> params = new HashMap<String, Object>();
params.put("guideType", 21);
Response response = network.postResponse(params, BasicConfig.COMPLETEGUIDE);
boolean success = response.jsonPath().getBoolean("success");
boolean data = response.jsonPath().getBoolean("data");
Assert.assertTrue(success, network.message(params, BasicConfig.COMPLETEGUIDE, "接口请求失败", response.body().asString()));
Assert.assertTrue(data, network.message(params, BasicConfig.COMPLETEGUIDE, "完成该引导失败", response.body().asString()));
response = network.getResponse(SELLERCARD_CARDGUIDE);
success = response.jsonPath().getBoolean("success");
int guideType = response.jsonPath().getInt("data.guideType");
Assert.assertTrue(success,network.message(SELLERCARD_CARDGUIDE ,"接口返回失败",response.body().asString()));
Assert.assertEquals(guideType,0,network.message(SELLERCARD_CARDGUIDE ,"引导类型错误",response.body().asString()));
}
@Test(description = "再次进入首页唤起没有新手引导",priority = 8)
public void 再次进入首页唤起没有新手引导(){
Response response = network.getResponse(ROOKIEGUIDE_homeGuide);
boolean success = response.jsonPath().getBoolean("success");
int guideType = response.jsonPath().getInt("data.guideType");
Assert.assertTrue(success,network.message(ROOKIEGUIDE_homeGuide,"接口返回失败",response.body().asString()));
Assert.assertEquals(guideType,12,network.message(ROOKIEGUIDE_homeGuide,"返回数据为空",response.body().asString()));
}
@Test(description = "进入谁看过我后唤起转发引导",priority = 9)
public void 进入谁看过我后唤起转发引导(){
Response response = network.getResponse(ROOKIECLUEGUIDE);
boolean success = response.jsonPath().getBoolean("success");
int guideType = response.jsonPath().getInt("data.guideType");
Assert.assertTrue(success,network.message(ROOKIECLUEGUIDE ,"接口返回失败",response.body().asString()));
Assert.assertEquals(guideType,35,network.message(ROOKIECLUEGUIDE ,"引导类型错误",response.body().asString()));
}
@Test(description = "点击完成线索的转发引导",priority = 10)
public void 点击完成线索的转发引导(){
Response response = network.getResponse(SELLERCARD_CARDGUIDE);
Map<String, Object> params = new HashMap<String, Object>();
params.put("guideType", 35);
response = network.postResponse(params, BasicConfig.COMPLETEGUIDE);
boolean success = response.jsonPath().getBoolean("success");
boolean data = response.jsonPath().getBoolean("data");
Assert.assertTrue(success, network.message(params, BasicConfig.COMPLETEGUIDE, "接口请求失败", response.body().asString()));
Assert.assertTrue(data, network.message(params, BasicConfig.COMPLETEGUIDE, "完成该引导失败", response.body().asString()));
params.put("guideType", 36);
response = network.postResponse(params, BasicConfig.COMPLETEGUIDE);
success = response.jsonPath().getBoolean("success");
data = response.jsonPath().getBoolean("data");
Assert.assertTrue(success, network.message(params, BasicConfig.COMPLETEGUIDE, "接口请求失败", response.body().asString()));
Assert.assertTrue(data, network.message(params, BasicConfig.COMPLETEGUIDE, "完成该引导失败", response.body().asString()));
response = network.getResponse(ROOKIECLUEGUIDE);
success = response.jsonPath().getBoolean("success");
int guideType = response.jsonPath().getInt("data.guideType");
Assert.assertTrue(success,network.message(ROOKIECLUEGUIDE ,"接口返回失败",response.body().asString()));
Assert.assertEquals(guideType,0,network.message(ROOKIECLUEGUIDE ,"引导类型错误",response.body().asString()));
}
@Test(description = "代理人转发文章后访客查看文章",priority = 11)
public void 代理人转发文章(){
//获取种草素材id
Response response = network.getResponse(ARTICLE_GETEXPLOSIONCONTENTLIST);
grasscontentId = response.jsonPath().getString("data[0].contentId");
//获取素材对应的scid
Map<String, Object> params = new HashMap<>();
params.put("contentId", grasscontentId);
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);
params.put("forwardType", 1);
response = network.getResponse(params, FORWARD);
Boolean success = response.jsonPath().getBoolean("success");
Assert.assertTrue(success, network.message(params, FORWARD, "种草文章转发失败", response.body().asString()));
//tKu 切换为访客
userTku();
//访客查看文章
params.clear();
params.put("scid", scid);
params.put("fromUserId", userId); //代理人的用户id
params.put("visitPath", 1);
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 = 12)
public void 代理人点击谁看过我显示备注引导(){
network.agentCookies.put("tku", tku);
Response response = network.getResponse(ROOKIECLUEGUIDE);
boolean success = response.jsonPath().getBoolean("success");
int guideType = response.jsonPath().getInt("data.guideType");
Assert.assertTrue(success,network.message(ROOKIECLUEGUIDE ,"接口返回失败",response.body().asString()));
Assert.assertEquals(guideType,34,network.message(ROOKIECLUEGUIDE ,"引导类型错误",response.body().asString()));
}
@Test(description = "点击完成线索的备注引导",priority = 13)
public void 点击完成线索的备注引导(){
Response response = network.getResponse(SELLERCARD_CARDGUIDE);
Map<String, Object> params = new HashMap<String, Object>();
params.put("guideType", 34);
response = network.postResponse(params, BasicConfig.COMPLETEGUIDE);
boolean success = response.jsonPath().getBoolean("success");
boolean data = response.jsonPath().getBoolean("data");
Assert.assertTrue(success, network.message(params, BasicConfig.COMPLETEGUIDE, "接口请求失败", response.body().asString()));
Assert.assertTrue(data, network.message(params, BasicConfig.COMPLETEGUIDE, "完成该引导失败", response.body().asString()));
response = network.getResponse(params, ROOKIECLUEGUIDE);
success = response.jsonPath().getBoolean("success");
int guideType = response.jsonPath().getInt("data.guideType");
Assert.assertTrue(success,network.message(ROOKIECLUEGUIDE ,"接口返回失败",response.body().asString()));
Assert.assertEquals(guideType,0,network.message(ROOKIECLUEGUIDE ,"引导类型错误",response.body().asString()));
}
@Test(description = "代理人转发文章后访客领取资料包",priority = 14)
public void 代理人转发文章后访客领取资料包(){
userTku();
sleep(2000);
//查看文章问答列表
Map<String, Object> params = new HashMap<>();
params.put("scid",scid);
params.put("pageIndex",1);
params.put("pageSize",3);
Response response = network.getResponse(params,ARTICLE_ENHANCEDCOLUMN_GETFAQS);
System.out.println(response.body().asString());
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.get(0).answer");
Assert.assertNotNull(answer,network.message(params,ARTICLE_ENHANCEDCOLUMN_GETFAQS,"获取问答内容有误",response.body().asString()));
String questionId = response.jsonPath().getString("data.list.get(0).questionId");
//查看问答具体详情
params.clear();
params.put("qId",questionId);
params.put("scid",scid);
response = network.getResponse(params,SELLERCARD_GETQUESTIONDETAIL);
boolean success = response.jsonPath().getBoolean("success");
Assert.assertTrue(success,network.message(params,SELLERCARD_GETQUESTIONDETAIL,"代理人-获取个人专栏列表有误",response.body().asString()));
Object data = response.jsonPath().getString("data");
Assert.assertNotNull(data,network.message(params,SELLERCARD_GETQUESTIONDETAIL,"获取问答内容有误",response.body().asString()));
String materialId = response.jsonPath().getString("data.faqAnxietyExtVo.materialId");
//领取赠险
params.clear();
params.put("qId",questionId);
params.put("scId",scid);
params.put("clueTypeName","FAQ_VISIT_SCAN");
params.put("locationSource",2);
params.put("insuranceName","苏逸");
params.put("insurancePhone","17897238291");
params.put("materialId",materialId);
params.put("sourceId",scid);
params.put("sourceType",1);
response = network.postResponse(params,SELLERCARD_SENDPUSHFORSCAN);
success = response.jsonPath().getBoolean("success");
String result = response.jsonPath().getString("data.");
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)
public void 代理人点击谁看过我显示跟进机会引导(){
network.agentCookies.put("tku", tku);
sleep(2000);
Response response = network.getResponse(ROOKIECLUEGUIDE);
boolean success = response.jsonPath().getBoolean("success");
int guideType = response.jsonPath().getInt("data.guideType");
Assert.assertTrue(success,network.message(ROOKIECLUEGUIDE ,"接口返回失败",response.body().asString()));
Assert.assertEquals(guideType,31,network.message(ROOKIECLUEGUIDE ,"引导类型错误",response.body().asString()));
}
@Test(description = "点击完成线索的备注引导",priority = 16)
public void 点击完成线索的跟进机会引导(){
Response response = network.getResponse(SELLERCARD_CARDGUIDE);
Map<String, Object> params = new HashMap<String, Object>();
params.put("guideType", 31);
response = network.postResponse(params, BasicConfig.COMPLETEGUIDE);
boolean success = response.jsonPath().getBoolean("success");
boolean data = response.jsonPath().getBoolean("data");
Assert.assertTrue(success, network.message(params, BasicConfig.COMPLETEGUIDE, "接口请求失败", response.body().asString()));
Assert.assertTrue(data, network.message(params, BasicConfig.COMPLETEGUIDE, "完成该引导失败", response.body().asString()));
response = network.getResponse(params, ROOKIECLUEGUIDE);
success = response.jsonPath().getBoolean("success");
int guideType = response.jsonPath().getInt("data.guideType");
Assert.assertTrue(success,network.message(ROOKIECLUEGUIDE ,"接口返回失败",response.body().asString()));
Assert.assertEquals(guideType,32,network.message(ROOKIECLUEGUIDE ,"引导类型错误",response.body().asString()));
params.clear();
params.put("guideType", 32);
response = network.postResponse(params, BasicConfig.COMPLETEGUIDE);
success = response.jsonPath().getBoolean("success");
data = response.jsonPath().getBoolean("data");
Assert.assertTrue(success, network.message(params, BasicConfig.COMPLETEGUIDE, "接口请求失败", response.body().asString()));
Assert.assertTrue(data, network.message(params, BasicConfig.COMPLETEGUIDE, "完成该引导失败", response.body().asString()));
response = network.getResponse(params, ROOKIECLUEGUIDE);
success = response.jsonPath().getBoolean("success");
guideType = response.jsonPath().getInt("data.guideType");
Assert.assertTrue(success,network.message(ROOKIECLUEGUIDE ,"接口返回失败",response.body().asString()));
Assert.assertEquals(guideType,0,network.message(ROOKIECLUEGUIDE ,"引导类型错误",response.body().asString()));
}
}
......@@ -623,6 +623,7 @@ public class BasicConfig {
public static final String QRCODE_create= HOST + "/kjy/mp/qrcode/create";
public static final String UPLOAD_image= HOST + "/kjy/mp/upload/image";
public static final String DYNAMIC_addVisit= HOST + "/kjy/mp/seller/dynamic/addVisit";
public static final String ROOKIEGUIDE_homeGuide= HOST + "/kjy/mp/rookieGuide/homeGuide";
// *************** 支付 ***************
public static final String PAY_getMiddleDetail = HOST + "/kjy/mp/payMiddle/getMiddleDetail";
......@@ -986,5 +987,11 @@ public class BasicConfig {
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";
public static final String MANAGER_vipList = MANAGER_HOST + "/kjy/manager/seller/vipList";
public static final String MANAGER_disableUser = MANAGER_HOST + "/kjy/manager/testUser/disableUser";
public static final String MANAGER_updateTypeOrDate = MANAGER_HOST + "/kjy/manager/seller/updateTypeOrDate";
public static final String MANAGER_oamsg = HOST + "/kjy/notify/oamsg";
public static final String MANAGER_encryptTku = MANAGER_HOST + "/kjy/manager/testUser/encryptTku";
public static final String MANAGER_changeCompany = MANAGER_HOST + "/kjy/manager/seller/changeCompany";
public static final String MANAGER_feedBackList = MANAGER_HOST + "/kjy/manager/feedback/list";
}
......@@ -44,6 +44,4 @@ public class BaseUtils {
network.agentCookies.put("sso_ticket", "autotest");
}
}
......@@ -115,6 +115,19 @@ public class NetworkUtils {
return response;
}
// post xml请求方式
public Response postXMLResponse(String str, String path) {
Response response = given()
.cookies(agentCookies)
.headers(agentHeaders)
.body(str)
.post(path);
if (!Objects.equals(response.statusCode(),200)){
System.out.println("请求状态码错误,path=【"+path+"】 code=【"+response.statusCode()+"】");
}
return response;
}
// 管理后台
public Response getManagerCookies(String path){
Response response = given().
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="集客助手" verbose="1" thread-count="3">
<test preserve-order="true" name = "新手引导">
<classes>
<class name="com.kjj.cases.assistant.menu.NoviceGuidance"/>
</classes>
</test>
<test preserve-order="true" name="支付">
<classes>
<class name="com.kjj.cases.assistant.pay.Pay"/>
......
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