Commit 28aab9aa authored by 龚小红's avatar 龚小红

Merge remote-tracking branch 'origin/master' into 2021072701_gxh

# Conflicts:
#	src/test/java/com/kjj/cases/assistant/card/ArticalPersonCard.java
#	src/test/java/com/kjj/cases/assistant/card/PersonCard.java
#	src/test/java/com/kjj/config/BasicConfig.java
parents 5bc303ac 80696635
package com.kjj.bean.agent;
import lombok.Data;
@Data
public class CustOrigins {
private String avatar;
private String name;
private long UserId;
}
package com.kjj.cases.basics;
package com.kjj.cases.assistant;
import static com.kjj.config.BasicConfig.*;
import static io.restassured.RestAssured.given;
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();
......@@ -25,138 +25,194 @@ public class Pay {
// 创建用户 并传到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);
BaseUtils.ssoLogin();
}
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,29 +225,38 @@ 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);
}
......
......@@ -406,10 +406,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
......@@ -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)
......@@ -891,4 +891,5 @@ public class PersonCard implements Authorization {
Assert.assertTrue(success,network.message(SELLERCARD_CARDGUIDE ,"接口返回失败",response.body().asString()));
Assert.assertEquals(guideType,0,network.message(SELLERCARD_CARDGUIDE ,"引导类型错误",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.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
......@@ -149,9 +149,4 @@ public class CircleFriends {
}
@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()));
}
//用户信息
......
......@@ -12,19 +12,7 @@ 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;
import static com.kjj.config.BasicConfig.*;
public class SellerCard {
private static final NetworkUtils network = NetworkUtils.getInstance();
......@@ -41,10 +29,10 @@ public class SellerCard {
public void 获取用户版本() throws IOException {
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"); // 找出开启状态的版本类型
Assert.assertEquals(userVersion, 2, network.message(params, VERSION_INFO,"会员类型版本判断:判断错误,此版本为通用版",response.body().asString()));
Assert.assertEquals(userVersion, 2, network.message(params, version_info,"会员类型版本判断:判断错误,此版本为通用版",response.body().asString()));
}
// @Test(description = "是否关注红号", priority = 2) //priorty 方法执行优先级
......
......@@ -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()));
......
......@@ -229,9 +229,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";
......@@ -398,7 +395,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";
......@@ -445,7 +441,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 +471,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 +483,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 +569,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 +584,14 @@ 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";
......@@ -623,15 +611,17 @@ 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";
......@@ -679,13 +669,13 @@ public class BasicConfig {
public static final String SELLERCARD_DIRECT = HOST + "/kjy/mp/user/direct";
// *************** 上传 ***************
public static final String UPLOAD = HOST + "/kjy/mp/seller/import/upload";
public static final String UPLOAD_TASKSTATUS = HOST + "/kjy/mp/seller/import/taskStatus";
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";
......@@ -701,13 +691,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";
......@@ -715,8 +712,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";
......@@ -772,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";
......@@ -852,22 +839,19 @@ public class BasicConfig {
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_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_setInternalSeller = MANAGER_HOST + "/kjy/manager/seller/setInternalSeller";
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_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"));
......@@ -84,7 +79,7 @@ public class BaseUtils {
Map<String, Object> changeParams = new HashMap<String, Object>();
changeParams.put("id",sellerId);
changeParams.put("companyId",6);
Response response = network.getResponse(changeParams,MANAGER_CHANGECOMPANY);
Response response = network.getResponse(changeParams,MANAGER_changeCompany);
response.body().prettyPrint();
// 2.切换为保险版vip
......@@ -95,11 +90,11 @@ public class BaseUtils {
switchVipParams.put("vipType",vipType);
switchVipParams.put("vipStartDate",System.currentTimeMillis());
switchVipParams.put("vipEndDate",System.currentTimeMillis() + 1000*3600*24*365L);
response = network.postResponse(switchVipParams,MANAGER_UPDATETYPEORDATE);
response = network.postResponse(switchVipParams,MANAGER_updateTypeOrDate);
// 3.切换公司为空
changeParams.remove("companyId",6); //去掉公司
response = network.getResponse(changeParams,MANAGER_CHANGECOMPANY);
response = network.getResponse(changeParams,MANAGER_changeCompany);
// 删除管理后台tku
network.agentHeaders.remove("X-Csrf-Token");
......@@ -121,7 +116,7 @@ public class BaseUtils {
Map<String, Object> params = new HashMap<String, Object>();
params.put("id",sellerId);
params.put("internalSeller",isInternalSeller);//
Response response = network.getResponse(params,MANAGER_SETINTERALSELLER);
Response response = network.getResponse(params,MANAGER_setInternalSeller);
response.body().prettyPrint();
// 删除管理后台tku
......@@ -131,65 +126,6 @@ public class BaseUtils {
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
......@@ -263,18 +199,14 @@ public class BaseUtils {
Map<String, Object> changeParams = new HashMap<String, Object>();
changeParams.put("id",sellerId);
changeParams.put("companyId",6);
response = network.getResponse(changeParams,MANAGER_CHANGECOMPANY);
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 = network.postResponse(params,MANAGER_disableUser);
response.body().prettyPrint();
}
public static void main(String[] args) throws IOException {
disableUser();
}
}
......@@ -4,7 +4,7 @@
<test preserve-order="true" name="支付">
<classes>
<class name="com.kjj.cases.basics.Pay"/>
<class name="com.kjj.cases.assistant.Pay"/>
</classes>
</test>
<test preserve-order="true" name = "首页">
......@@ -32,11 +32,21 @@
<class name="com.kjj.cases.assistant.DailyPaper"/>
</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"/>
......
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