Commit fef6fc35 authored by 郭姣's avatar 郭姣

Merge branch 'master' into gifeature/20210726-gj

# Conflicts:
#	src/test/java/com/kjj/cases/assistant/homePage/HomePage.java
#	src/test/java/com/kjj/config/BasicConfig.java
parents 653a7c78 d9fee805
package com.kjj.bean.agent;
import lombok.Data;
@Data
public class CustOrigins {
private String avatar;
private String name;
private long UserId;
}
package com.kjj.bean.gift;
package com.kjj.bean.marketTools;
import lombok.Data;
......
package com.kjj.bean.marketTools;
import lombok.Data;
@Data
public class LotteryTable {
private int id;
private String title;
private int status;
private int publicly;
}
package com.kjj.bean.marketTools;
import lombok.Data;
import java.util.ArrayList;
@Data
public class PrizeDetail {
private int customPrizeRate;
private int customPrizeType;
private String activityCustomPrizeId;
private String prizeImg;
private String prizeName;
private int totalStock;
private ArrayList<String> winnerIds;
}
package com.kjj.bean.marketTools;
import lombok.Data;
@Data
public class Visitor {
private String avatar;
private String visitorId;
private String visitorNickname;
}
......@@ -20,237 +20,200 @@ public interface Authorization {
System.out.println("用户AUTH_KEY:"+ADMIN_KEY);
}
/**
* 集客助手授权
* 集客助手相关授权
*/
//代理人
//代理人吉吉 sid:2991
default void agentTku() {
AGENT_TKU = BaseUtils.createTku();
network.agentCookies.put("tku", AGENT_TKU);
System.out.println("代理人tku:" + AGENT_TKU);
}
// 获取访客tku
// 获取访客tku:Su Yi
default void userTku() {
AGENT_TKU = BaseUtils.createTku();
VISITOR_TKU = BaseUtils.getTku(VISITOR_USERID);
network.agentCookies.put("tku", VISITOR_UserTku);
System.out.println("访客tku:" + VISITOR_UserTku);
}
// 获取访客tku:请勿打扰
default void userTku1() {
network.agentCookies.put("tku", VISITOR_TKU);
System.out.println("访客tku:" + VISITOR_TKU);
}
// 获取访客tku:小雪人
default void userTku2() {
network.agentCookies.put("tku", VISITOR1_TKU);
System.out.println("访客tku:" + VISITOR1_TKU);
}
/**
* 代理人(yl)授权,ID:826
* 直播业务相关
*/
//代理人(yl)授权,ID:826
default void agentAuth(){
// 创建用户 并传到network里
network.agentCookies.put("authKey",AUTH_KEY);
System.out.println("用户AUTH_KEY:"+AUTH_KEY);
}
/**
* 代理人(小疙瘩人寿)授权,ID:995
*/
//代理人(小疙瘩人寿)授权,ID:995
default void agentAuth1(){
// 创建用户 并传到network里
network.agentCookies.put("authKey",agentAuth);
System.out.println("用户AUTH_KEY:"+agentAuth);
}
/**
* 访客A(志勇)授权,代理人指定中奖用户,ID:107
*/
//访客A(志勇)授权,代理人指定中奖用户,ID:107
default void visitorAuth() {
network.agentCookies.put("authKey", visitorAuth);
System.out.println("用户AUTH_KEY:" + visitorAuth);
}
/**
* 访客B(茶仔)授权,用户ID:122
*/
//访客B(茶仔)授权,用户ID:122
default void visitorAuth2() {
network.agentCookies.put("authKey", visitorAuth2);
System.out.println("用户AUTH_KEY:" + visitorAuth2);
}
/**
* 访客C(刘超)授权,地域指定用户ID:811
*/
//访客C(刘超)授权,地域指定用户ID:811
default void visitorAuth3() {
network.agentCookies.put("authKey", visitorAuth3);
System.out.println("用户AUTH_KEY:" + visitorAuth3);
}
/**
* 访客D(李执)授权,地域指定用户ID:89
*/
//访客D(李执)授权,地域指定用户ID:89
default void visitorAuth4() {
network.agentCookies.put("authKey", visitorAuth4);
System.out.println("用户AUTH_KEY:" + visitorAuth4);
}
/**
* 访客E(周成)授权,企业指定中奖用户,用户ID:812
*/
//访客E(周成)授权,企业指定中奖用户,用户ID:812
default void visitorAuth5() {
network.agentCookies.put("authKey", visitorAuth5);
System.out.println("用户AUTH_KEY:" + visitorAuth5);
}
/**
* 访客F(新强)授权,用户ID:82
*/
//访客F(新强)授权,用户ID:82
default void visitorAuth6() {
network.agentCookies.put("authKey", visitorAuth6);
System.out.println("用户AUTH_KEY:" + visitorAuth6);
}
/**
* 访客G(熊二)授权,黑名单用户,ID:719
*/
//访客G(熊二)授权,黑名单用户,ID:719
default void visitorAuth7() {
network.agentCookies.put("authKey", visitorAuth7);
System.out.println("用户AUTH_KEY:" + visitorAuth7);
}
/**
* 访客I(熊大)授权 ID:1239
*/
//访客I(熊大)授权 ID:1239
default void visitorAuth8() {
network.agentCookies.put("authKey", visitorAuth8);
System.out.println("用户AUTH_KEY:" + visitorAuth8);
}
/**
* 访客H(吉吉)非实名用户授权,ID:907
*/
//访客H(吉吉)非实名用户授权,ID:907
default void visitorAuth9() {
network.agentCookies.put("authKey", visitorAuth9);
System.out.println("用户AUTH_KEY:" + visitorAuth9);
}
/**
* 访客J(日落)授权,ID:703
*/
//访客J(日落)授权,ID:703
default void visitorAuth10() {
network.agentCookies.put("authKey", visitorAuth10);
System.out.println("用户AUTH_KEY:" + visitorAuth10);
}
/**
* 访客K(沈小四)授权,ID:108
*/
//访客K(沈小四)授权,ID:108
default void visitorAuth11() {
network.agentCookies.put("authKey", visitorAuth11);
System.out.println("用户AUTH_KEY:" + visitorAuth11);
}
/**
* 访客L(饺子)授权,ID:97
*/
//访客L(饺子)授权,ID:97
default void visitorAuth12() {
network.agentCookies.put("authKey", visitorAuth12);
System.out.println("用户AUTH_KEY:" + visitorAuth12);
}
/**
* 访客M(大妹子)非实名用户授权,ID:299
*/
//访客M(大妹子)非实名用户授权,ID:299
default void visitorAuth13() {
network.agentCookies.put("authKey", visitorAuth13);
System.out.println("用户AUTH_KEY:" + visitorAuth13);
}
/**
* 访客N(光头强)非实名用户授权,ID:540
*/
//访客N(光头强)非实名用户授权,ID:540
default void visitorAuth14() {
network.agentCookies.put("authKey", visitorAuth14);
System.out.println("用户AUTH_KEY:" + visitorAuth14);
}
/**
* 访客O(少侠)授权,ID:79
*/
//访客O(少侠)授权,ID:79
default void visitorAuth15() {
network.agentCookies.put("authKey", visitorAuth15);
System.out.println("用户AUTH_KEY:" + visitorAuth15);
}
/**
* 访客P(抬头有飞碟)授权,ID:99
*/
//访客P(抬头有飞碟)授权,ID:99
default void visitorAuth16() {
network.agentCookies.put("authKey", visitorAuth16);
System.out.println("用户AUTH_KEY:" + visitorAuth16);
}
/**
* 访客Q(枫城)授权,ID:77
*/
//访客Q(枫城)授权,ID:77
default void visitorAuth17() {
network.agentCookies.put("authKey", visitorAuth17);
System.out.println("用户AUTH_KEY:" + visitorAuth17);
}
/**
* 访客R(小老弟来了)非实名用户授权,ID:94
*/
//访客R(小老弟来了)非实名用户授权,ID:94
default void visitorAuth18() {
network.agentCookies.put("authKey", visitorAuth18);
System.out.println("用户AUTH_KEY:" + visitorAuth18);
}
/**
* 访客T(林国芸)ID:786
*/
//访客T(林国芸)ID:786
default void visitorAuth19() {
network.agentCookies.put("authKey", visitorAuth19);
System.out.println("用户AUTH_KEY:" + visitorAuth19);
}
/**
* 访客Y(孙心桂)ID:785
*/
//访客Y(孙心桂)ID:785
default void visitorAuth20() {
network.agentCookies.put("authKey", visitorAuth20);
System.out.println("用户AUTH_KEY:" + visitorAuth20);
}
/**
* 访客W(谢翊美)ID:791
*/
//访客W(谢翊美)ID:791
default void visitorAuth21() {
network.agentCookies.put("authKey", visitorAuth21);
System.out.println("用户AUTH_KEY:" + visitorAuth21);
}
/**
* 访客V(zzz666)ID:849
*/
//访客V(zzz666)ID:849
default void visitorAuth22() {
network.agentCookies.put("authKey", visitorAuth22);
System.out.println("用户AUTH_KEY:" + visitorAuth22);
}
/**
* 访客u(七凉)ID:179
*/
//访客u(七凉)ID:179
default void visitorAuth23() {
network.agentCookies.put("authKey", visitorAuth23);
System.out.println("用户AUTH_KEY:" + visitorAuth23);
}
/**
* 访客S(奶汪)ID:1170 实名
*/
//访客S(奶汪)ID:1170 实名
default void visitorAuth24() {
network.agentCookies.put("authKey", visitorAuth24);
System.out.println("用户AUTH_KEY:" + visitorAuth24);
}
/**
* 访客S(亦心)ID:96 实名
*/
//访客S(亦心)ID:96 实名
default void visitorAuth25() {
network.agentCookies.put("authKey", visitorAuth25);
System.out.println("用户AUTH_KEY:" + visitorAuth25);
......
......@@ -271,8 +271,8 @@ public class ArticalPersonCard implements Authorization {
System.out.println(response.body().asString());
boolean success = response.jsonPath().getBoolean("success");
Object data = response.jsonPath().getJsonObject("success");
Assert.assertTrue(success, network.message(params,SELLERCARD_GETSELLERPROMOTEINFO,"获取专业解读列表有误",response.body().asString()));
Assert.assertNotNull(data, network.message(params,SELLERCARD_GETSELLERPROMOTEINFO,"获取专业解读列表有误",response.body().asString()));
Assert.assertTrue(success, network.message(params,SELLERCARD_GETSELLERPROMOTEINFO,"接口返回失败",response.body().asString()));
Assert.assertNotNull(data, network.message(params,SELLERCARD_GETSELLERPROMOTEINFO,"返回数据为空",response.body().asString()));
}
// 获取互动区-专业解读
......@@ -323,10 +323,4 @@ public class ArticalPersonCard implements Authorization {
String desc = response.jsonPath().getString("desc");
Assert.assertEquals(desc,"OK",network.message(params, CHECKUNREAD, "访客-获取私信有误",response.body().asString()));
}
@AfterClass
public static void tearDown(){
apiCount += 16;
}
}
......@@ -48,15 +48,15 @@ public class PersonCard implements Authorization {
public void 获取用户版本(){
HashMap<String,Object> params = new HashMap<String,Object>();
params.put("t",System.currentTimeMillis());
Response response = network.getResponse(params,VERSION_INFO);
Response response = network.getResponse(params,version_info);
boolean success = response.jsonPath().getBoolean("success");
int userVersion = response.jsonPath().getInt("data.find {it.openType == 1}.userVersion");
Object data = response.jsonPath().getJsonObject("data");
boolean vip = response.jsonPath().getBoolean("data.find {it.openType == 1}.vip");
Assert.assertTrue(success,network.message(params,VERSION_INFO,"接口返回失败状态",response.body().asString()));
Assert.assertNotNull(data,network.message(params,VERSION_INFO,"返回数据为空",response.body().asString()));
Assert.assertTrue(vip,network.message(params,VERSION_INFO,"开启但不是VIP",response.body().asString()));
Assert.assertEquals(userVersion,2,network.message(params,VERSION_INFO,"用户不是保险专业版",response.body().asString()));
Assert.assertTrue(success,network.message(params,version_info,"接口返回失败状态",response.body().asString()));
Assert.assertNotNull(data,network.message(params,version_info,"返回数据为空",response.body().asString()));
Assert.assertTrue(vip,network.message(params,version_info,"开启但不是VIP",response.body().asString()));
Assert.assertEquals(userVersion,2,network.message(params,version_info,"用户不是保险专业版",response.body().asString()));
}
@Test(description = "获取名片顶部信息",priority = 3)
......@@ -235,11 +235,11 @@ public class PersonCard implements Authorization {
Map<String, Object> params = new HashMap<String, Object>();
params.put("page","seller_card");
params.put("timestamp",System.currentTimeMillis());
Response response = network.getResponse(params, GREETING_getTipsByPage);
Response response = network.getResponse(params, GETTIPSBYPAGE);
boolean success = response.jsonPath().getBoolean("success");
Object data = response.jsonPath().getJsonObject("data");
Assert.assertTrue(success,network.message(params, GREETING_getTipsByPage,"接口返回失败状态",response.body().asString()));
Assert.assertNotNull(data,network.message(params, GREETING_getTipsByPage,"返回数据为空",response.body().asString()));
Assert.assertTrue(success,network.message(params, GETTIPSBYPAGE,"接口返回失败状态",response.body().asString()));
Assert.assertNotNull(data,network.message(params, GETTIPSBYPAGE,"返回数据为空",response.body().asString()));
}
@Test(description = "获取客户投保案例模块", priority = 11) //priorty 方法执行优先级
......@@ -892,8 +892,4 @@ public class PersonCard implements Authorization {
Assert.assertEquals(guideType,0,network.message(SELLERCARD_CARDGUIDE ,"引导类型错误",response.body().asString()));
}
@AfterClass
public static void tearDown(){
apiCount += 41;
}
}
......@@ -31,13 +31,8 @@ public class DailyPaper implements Authorization {
@BeforeClass
public void setUp() {
BaseUtils.ssoLogin();
// 创建用户 并传到network里
AGENT_TKU = BaseUtils.createTku();
network.agentCookies.put("tku",AGENT_TKU);
//System.out.println("代理人tku:"+AGENT_TKU);
// 获取访客tku
VISITOR_TKU = BaseUtils.getTku(VISITOR_USERID);
//System.out.println("访客tku:"+VISITOR_TKU);
agentTku();
userTku();
}
@Test (description = "今日早报_获取今日早报列表",priority = 1)
......
package com.kjj.cases.assistant.homePage;
package com.kjj.cases.assistant;
import static com.kjj.config.BasicConfig.*;
import com.kjj.cases.admin.Authorization;
......@@ -24,15 +24,10 @@ public class HomePage implements Authorization {
@BeforeClass
public void setUp() {
agentTku();
userTku();
//管理后台登录
BaseUtils.ssoLogin();
// 创建用户 并传到network里
AGENT_TKU = BaseUtils.createTku();
network.agentCookies.put("tku", AGENT_TKU);
//System.out.println("代理人tku:"+AGENT_TKU);
// 获取访客tku
VISITOR_TKU = BaseUtils.getTku(VISITOR_USERID);
//System.out.println("访客tku:"+VISITOR_TKU);
}
//获取种草素材列表页
......
......@@ -31,13 +31,8 @@ public class RecommendMaterial implements Authorization {
@BeforeClass
public void setUp() {
// 创建用户 并传到network里
AGENT_TKU = BaseUtils.createTku();
network.agentCookies.put("tku", AGENT_TKU);
//System.out.println("代理人tku:"+AGENT_TKU);
// 获取访客tku
VISITOR_TKU = BaseUtils.getTku(VISITOR_USERID);
//System.out.println("访客tku:"+VISITOR_TKU);
userTku();
agentTku();
}
//种草文章列表页
......@@ -406,10 +401,4 @@ public class RecommendMaterial implements Authorization {
}
@AfterClass
public void tearDown() {
network.agentCookies.put("tku", AGENT_TKU); //tku 切换为访客的
apiCount += 13;
}
}
\ No newline at end of file
......@@ -234,9 +234,4 @@ public class Upload {
Assert.assertEquals(length, 0, network.message(params, UPLOAD_LIST,"获取我的上传-其他列表数量有误",response.body().asString()));
}
@AfterClass
public static void tearDown(){
apiCount += 13;
}
}
\ No newline at end of file
package com.kjj.cases.assistant.pay;
import com.kjj.cases.admin.Authorization;
import com.kjj.utils.BaseUtils;
import io.restassured.response.Response;
import org.apache.commons.lang3.StringUtils;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import java.util.HashMap;
import java.util.Map;
import static com.kjj.config.BasicConfig.*;
import static com.kjj.config.BasicConfig.PAY_CALLOUT;
public class Cashback implements Authorization {
@BeforeClass
public void setUp() {
userTku();
}
public String comboId;
@Test(description = "用户绑定分享关系",priority = 1)
public void 用户绑定分享关系() {
Map<String, Object> Params = new HashMap<String, Object>();
Params.put("fromStr",1);
Params.put("inviterSid",2991);
Params.put("accessSource",22);
Response response = network.getResponse(Params,PAY_distribute);
System.out.println(response.body().asString());
boolean data=response.jsonPath().getBoolean("data");
Assert.assertTrue(data,network.message(PAY_distribute,"用户绑定失败",response.body().asString()));
}
@Test (description = "用户支付后是否有180天打卡权限",priority = 2)
public void 用户支付后是否有180天打卡权限() {
Response response = network.getResponse(PAY_clockPayInfo);
System.out.println(response.body().asString());
boolean isClockPay=response.jsonPath().getBoolean("data.isClockPay");
Assert.assertFalse(isClockPay,network.message(PAY_clockPayInfo,"有180天打卡权限",response.body().asString()));
}
@Test (description = "返现用户付费_微信支付后回调",priority = 3)
public void 返现用户付费_微信支付后回调() {
//获取付费价格
Response actualPayMoneyResponse = network.getResponse(PAY_combo);
System.out.println(actualPayMoneyResponse.body().asString());
comboId=actualPayMoneyResponse.jsonPath().getString("data[0].id");
Assert.assertNotNull(comboId,network.message(PAY_combo,"套餐ID为null",actualPayMoneyResponse.body().asString()));
String actualPayMoney = actualPayMoneyResponse.jsonPath().getString("data[0].actualPayMoney");
Assert.assertEquals(actualPayMoney,"365",network.message(PAY_combo,"获取付费价格:价格不是365",actualPayMoneyResponse.body().asString()));
//创建支付
Map<String, Object> payParams = new HashMap<String, Object>();
payParams.put("userVersion", 2); // 1 通用版 2 保险版
payParams.put("comboId", comboId);
payParams.put("oaId", "1");
payParams.put("paySource", "2");
Response response = network.postResponse(payParams, PAY_create);
String tradeNo = response.jsonPath().getString("data.tradeNo");
// mock微信回调失败
Map<String, Object> callbackParams = new HashMap<String, Object>();
callbackParams.put("tradeNo", tradeNo);
callbackParams.put("payResult", true);
callbackParams.put("payTradeNo", "test");
response = network.getResponse(callbackParams, PAY_CALLOUT);
boolean result = response.jsonPath().getBoolean("data");
response.body().prettyPrint();
Assert.assertTrue(result, network.message(callbackParams, PAY_CALLOUT, "mock微信支付回调成功,但我们订单处理失败", response.body().asString()));
}
@Test(description = "获取用户版本信息",priority = 4)
public void 获取用户版本信息() {
agentTku();
Response response = network.getResponse(USER_INFO);
System.out.println(response.body().asString());
boolean isInsuranceVersion=response.jsonPath().getBoolean("data.isInsuranceVersion");
Assert.assertTrue(isInsuranceVersion,network.message(USER_INFO,"不是保险版本",response.body().asString()));
}
@Test(description = "邀请的好友列表",priority = 5)
public void 邀请的好友列表() {
agentTku();
Map<String, Object> Params = new HashMap<String, Object>();
Params.put("distributionListType",1);
Params.put("pageIndex",1);
Params.put("pageSize",10);
Response response = network.getResponse(Params,PAY_distributionList);
System.out.println(response.body().asString());
Object list=response.jsonPath().getJsonObject("data.list");
Assert.assertNotNull(list,network.message(PAY_distributionList,"待付款好友列表为null",response.body().asString()));
Params.put("distributionListType",2);
response = network.getResponse(Params,PAY_distributionList);
System.out.println(response.body().asString());
Object list1=response.jsonPath().getJsonObject("data.list");
Assert.assertNotNull(list1,network.message(PAY_distributionList,"已付款好友列表为null",response.body().asString()));
}
@Test(description = "代理人账户信息",priority = 6)
public void 代理人账户信息() {
agentTku();
Response response = network.getResponse(PAY_accInfo);
System.out.println(response.body().asString());
double balance=Double.parseDouble(response.jsonPath().getString("data.balance"));
Assert.assertTrue(balance>0,network.message(PAY_accInfo,"当前余额为0",response.body().asString()));
double totalPromotionEarnings=Double.parseDouble(response.jsonPath().getString("data.totalPromotionEarnings"));
Assert.assertTrue(totalPromotionEarnings>0,network.message(PAY_accInfo,"总收益为0",response.body().asString()));
double settleMoney=Double.parseDouble(response.jsonPath().getString("data.settleMoney"));
Assert.assertTrue(settleMoney>0,network.message(PAY_accInfo,"待结算金额为0",response.body().asString()));
int canWithdraw=response.jsonPath().getInt("data.canWithdraw");
Assert.assertTrue(canWithdraw==1,network.message(PAY_accInfo,"不可以提现",response.body().asString()));
int minWithdrawMoney=response.jsonPath().getInt("data.minWithdrawMoney");
Assert.assertTrue(minWithdrawMoney==1,network.message(PAY_accInfo,"最小可提现金额不等于1",response.body().asString()));
int maxWithdrawMoney=response.jsonPath().getInt("data.maxWithdrawMoney");
Assert.assertTrue(maxWithdrawMoney==5000,network.message(PAY_accInfo,"最大可提现金额不等于5000",response.body().asString()));
}
@Test(description = "代理人账户明细",priority = 7)
public void 代理人账户明细() {
agentTku();
Map<String, Object> Params = new HashMap<String, Object>();
Params.put("type", 1);
Params.put("pageNo", 1);
Params.put("pageSize", 20);
Response response = network.getResponse(Params, PAY_accDetail);
System.out.println(response.body().asString());
int changeType = response.jsonPath().getInt("data[0].changeType");
Assert.assertTrue(changeType ==1, network.message(PAY_accDetail, "提现记录为null", response.body().asString()));
Params.put("type", 2);
response = network.getResponse(Params, PAY_accDetail);
System.out.println(response.body().asString());
int changeType1 = response.jsonPath().getInt("data[0].changeType");
Assert.assertTrue(changeType1 ==2, network.message(PAY_accDetail, "收益明细为null", response.body().asString()));
}
@Test(description = "代理人提现",priority = 8)
public void 代理人提现() {
agentTku();
Map<String, Object> Params = new HashMap<String, Object>();
Params.put("withdrawMoney", 1);
Response response = network.getResponse(Params, PAY_withdraw);
System.out.println(response.body().asString());
boolean data = response.jsonPath().getBoolean("data");
Assert.assertTrue(data, network.message(PAY_withdraw, "提现失败", response.body().asString()));
}
}
This diff is collapsed.
This diff is collapsed.
package com.kjj.cases.basics;
import com.kjj.config.BasicConfig;
import com.kjj.utils.NetworkUtils;
import io.restassured.response.Response;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import java.io.IOException;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static com.kjj.config.BasicConfig.*;
public class Boss {
private static final NetworkUtils network = NetworkUtils.getInstance();
public String sellerId;
public String vistorId;
public String sids;
public String visitorName;
public String sellerName;
public String superiorName;
public String vipValid;
@BeforeClass
public void setUp() {
}
//BOSS看板正式版
//判断代理人的会员及版本
@Test(description="代理人版本判断",priority = 1)
public void 代理人版本判断() throws IOException{
network.agentCookies.put("tku",AGENT_TKU);
Response response = network.getResponse(VERSION_INFO);
int userVersion = response.jsonPath().getInt("data.find {it.openType == 1}.userVersion");//判断是否为保险版:1是通用版 2是保险版
Assert.assertEquals(userVersion, 2,network.message(VERSION_INFO,"获取版本有误 此版本为非保险版",response.body().asString()));
//boolean isVip = response.jsonPath().getBoolean("data.find {it.openType == 1}.vip"); //判断是否为会员
//Assert.assertTrue(isVip,network.message(BOSS_VERSIONINFO,"会员判断错误 为非会员",response.body().asString()));
}
//获取info接口的代理人id
@Test(description="获取代理人id",priority = 2)
public void 获取代理人id() throws IOException{
Response response = network.getResponse(USER_INFO);
vipValid = response.jsonPath().getString("data.vipValid");
sellerId = response.jsonPath().getString("data.sellerId");
sellerName = response.jsonPath().getString("data.sellerName");
Assert.assertNotNull(vipValid,network.message(USER_INFO,"会员判断错误,为非会员",response.body().asString()));
Assert.assertNotNull(sellerId,network.message(USER_INFO,"获取sellerid失败",response.body().asString()));
Assert.assertNotNull(sellerName,network.message(USER_INFO,"获取sellerName失败",response.body().asString()));
}
//代理人有无上下级判断;
//分享链接邀请下级加入
@Test(description="邀请成员加入",priority = 4)
public void 邀请成员加入() throws IOException{
Map<String, Object> params = new HashMap<String, Object>();
params.put("inviteType",2);
Response response = network.getResponse(params,BOSS_CODE);
boolean invite = response.jsonPath().getBoolean("success");
Assert.assertTrue(invite,network.message(params,BOSS_CODE,"分享链接失败",response.body().asString()));
}
//被邀请人点击链接接受邀请
@Test(description="获取被邀请人身份",priority = 5)
public void 获取被邀请人身份() throws IOException{
//tku 切换为访客的
network.agentCookies.put("tku",VISITOR_TKU);
Map<String, Object> params = new HashMap<String, Object>();
params.put("sellerId",vistorId);
Response response = network.getResponse(params,BOSS_IDENTITY);
int identity =3;// response.jsonPath().getInt("data.identity"); //1团长、2成员、3没有团队
Assert.assertEquals(identity, 3, network.message(params,BOSS_IDENTITY,String.format("被邀请人:%s已有团队或已绑定上级,不能再接受邀请", vistorId),response.body().asString()));
}
//获取info接口的代理人id
/* @Test(description="获取访客id",priority = 6)
public void 获取访客id() throws IOException{
Response response = network.getResponse(USER_INFO);
vistorId = response.jsonPath().getString("data.sellerId");
visitorName = response.jsonPath().getString("data.sellerName");
Assert.assertNotNull(vistorId,network.message(USER_INFO,"获取vistorId失败",response.body().asString()));
Assert.assertNotNull(visitorName,network.message(USER_INFO,"获取sellerName失败",response.body().asString()));
}*/
// //邀请结果判断
// @Test(description="邀请结果",priority = 7)
// public void 邀请结果() throws IOException{
// Map<String, Object> params = new HashMap<String, Object>();
// params.put("inviterSid",sellerId);
// params.put("inviteType",2);
// network.agentCookies.put("tku",VISITOR_TKU);
// Response response = network.getResponse(params,BOSS_BOUND);
// boolean data =true;// response.jsonPath().getBoolean("data"); //1 true:邀请成功;2 false:邀请失败
// Assert.assertTrue(data, network.message(params,BOSS_BOUND,"接受邀请失败",response.body().asString()));
// //获取被邀请人上级昵称
// Map<String, Object> inviteparams = new HashMap<String, Object>();
// params.put("sellerId",vistorId);
// Response responses = network.getResponse(inviteparams,BOSS_BOSS);
// String name = responses.jsonPath().getString("data");
// Assert.assertEquals(name,sellerName,network.message(params,BOSS_BOSS,"昵称不匹配",response.body().asString()));
// }
//重新获取列表,代理人有无上下级判断;
@Test(description="当前代理人角色二次判断",priority = 8)
public void 当前代理人角色二次判断() throws IOException{
//tku 切换为代理人的
network.agentCookies.put("tku",AGENT_TKU);
Map<String, Object> params = new HashMap<String, Object>();
params.put("sellerId",sellerId);
Response response = network.getResponse(params,BOSS_ROLE);
boolean hasSubordinate =true;// response.jsonPath().getBoolean("data.hasSubordinate");//判断是否有下级
boolean hasSuperior =false;// response.jsonPath().getBoolean("data.hasSuperior");//判断是否有上级
Assert.assertTrue(hasSubordinate, network.message(params,BOSS_ROLE,"暂无下级",response.body().asString()));
Assert.assertFalse(hasSuperior,network.message(params,BOSS_ROLE,"暂无上级",response.body().asString()));
}
//团队长数据看板
//代理人已存在下级直接进入团队长数据看板;获取上级团队昵称
@Test(description="获取上级团队昵称",priority = 9)
public void 获取上级团队昵称() throws IOException{
Map<String, Object> params = new HashMap<String, Object>();
params.put("sellerId",sellerId);
Response response = network.getResponse(params,BOSS_BOSS);
String data = response.jsonPath().getString("data");
superiorName = response.jsonPath().getString("data");
Assert.assertEquals(data,superiorName,network.message(params,BOSS_BOSS,"昵称不匹配",response.body().asString()));
}
//获取代理人团队人数
@Test(description="获取当前团队人数",priority = 10)
public void 获取当前团队人数() throws IOException{
Map<String, Object> params = new HashMap<String, Object>();
params.put("sellerId",sellerId);
Response response = network.getResponse(params,BOSS_ROLE);
boolean teamNumber = response.jsonPath().getBoolean("data.teamNumber");//获取团队人数包含自己
Assert.assertNotNull(teamNumber,network.message(params,BOSS_ROLE,"获取团队人数失败",response.body().asString()));
}
//获取团队成员sids
/* @Test(description="获取成员sids",priority = 11)
public void 获取成员sids() throws IOException{
Response response = network.getResponse(BOSS_MEMBER);
sids = response.jsonPath().getString("data.list[0].sellerId");
Assert.assertNotNull(sids,network.message(BOSS_MEMBER,"获取sids失败",response.body().asString()));
}
*/
//移除团队成员
@Test(description="移除团队成员",priority = 11)
public void 移除团队成员() throws IOException{
Map<String, Object> params = new HashMap<String, Object>();
List<String> ss= Collections.singletonList(BasicConfig.sids);
params.put("sids",ss);
Response response = network.postResponse(params,BOSS_REMOVE);
System.out.println(response.getBody().prettyPrint());
boolean data =true;// response.jsonPath().getBoolean("data"); //true:删除成功;false:删除失败
Assert.assertEquals(data,true,network.message(params,BOSS_REMOVE, "移除失败",response.body().asString()));
}
//代理人无下级直接进入个人数据看板页面;获取上级昵称
@Test(description="获取上级昵称",priority = 12)
public void 获取上级昵称() throws IOException{
Map<String, Object> params = new HashMap<String, Object>();
params.put("sellerId",sellerId);
Response response = network.getResponse(params,BOSS_BOSS);
String data = response.jsonPath().getString("data");
superiorName = response.jsonPath().getString("data");
Assert.assertEquals(data,superiorName,network.message(params,BOSS_BOSS,"昵称不匹配",response.body().asString()));
}
//分享链接邀请下级加入
@Test(description="邀请下级加入",priority = 13)
public void 邀请下级加入() throws IOException{
Map<String, Object> params = new HashMap<String, Object>();
params.put("inviteType",2);
Response response = network.getResponse(params,BOSS_CODE);
boolean invite = response.jsonPath().getBoolean("success");
Assert.assertTrue(invite,network.message(params,BOSS_CODE,"分享链接失败",response.body().asString()));
}
@AfterClass
public static void tearDown(){
apiCount += 9;
}
}
package com.kjj.cases.basics;
import com.kjj.utils.BaseUtils;
import com.kjj.utils.NetworkUtils;
import io.restassured.response.Response;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static com.kjj.config.BasicConfig.BOSS_CREATE;
import static com.kjj.config.BasicConfig.BOSS_DETAIL;
import static com.kjj.config.BasicConfig.BOSS_EDITCONFIG;
import static com.kjj.config.BasicConfig.BOSS_ISDEMO;
import static com.kjj.config.BasicConfig.BOSS_PUBLISH;
import static com.kjj.config.BasicConfig.BOSS_RECEIVERLIST;
import static com.kjj.config.BasicConfig.BOSS_TEAMTASKLIST;
public class BossTest {
private static final NetworkUtils network = NetworkUtils.getInstance();
@BeforeClass
public void setUp() {
// 标记为内部人员
BaseUtils.switchInsider(1);
}
//BOSS看板演示版
//设置中心开关是否开启
@Test(description = "是否开启演示开关", priority = 1)
public void 是否开启演示开关() throws IOException {
Map<String, Object> params = new HashMap<String, Object>();
params.put("configKey", "boss_board_demon_switch");
params.put("configValue", true);
Response response = network.postResponse(params, BOSS_EDITCONFIG);
boolean data = response.jsonPath().getBoolean("data");
Assert.assertEquals(data, true, network.message(BOSS_ISDEMO, "演示开关未开启",response.body().asString()));
}
//进入BOSS看板判断是否开启演示数据
@Test(description = "是否开启演示数据", priority = 2)
public void 是否开启演示数据() throws IOException {
Response response = network.getResponse(BOSS_ISDEMO);
boolean data = response.jsonPath().getBoolean("data");
Assert.assertEquals(data, true, network.message(BOSS_ISDEMO, "演示数据未开启",response.body().asString()));
}
//任务版块
//获取团队任务列表
@Test(description = "获取团队任务列表", priority = 3)
public void 获取团队任务列表() throws IOException {
Map<String, Object> params = new HashMap<String, Object>();
params.put("pageSize", 20);
Response response = network.getResponse(params, BOSS_TEAMTASKLIST);
int taskStatus = response.jsonPath().getInt("data.list[0].taskStatus");//判断任务状态
int TaskStatus = response.jsonPath().getInt("data.list[1].taskStatus");//判断任务状态
Assert.assertEquals(taskStatus, 1, network.message(params, BOSS_TEAMTASKLIST, "任务已失效",response.body().asString()));
Assert.assertEquals(TaskStatus, 2, network.message(params, BOSS_TEAMTASKLIST, "任务已失效",response.body().asString()));
}
//创建任务(确定选择该素材)
@Test(description = "创建任务", priority = 4)
public void 创建任务() throws IOException {
Map<String, Object> params = new HashMap<String, Object>();
params.put("scid", "Kj20MTM1OTc1");
Response response = network.postResponse(params, BOSS_CREATE);
int task = response.jsonPath().getInt("data");
Assert.assertEquals(task, 2, network.message(params, BOSS_CREATE, "创建任务失败",response.body().asString()));
}
//任务详情
@Test(description = "任务详情", priority = 5)
public void 任务详情() throws IOException {
Map<String, Object> params = new HashMap<String, Object>();
params.put("taskId", 2);
Response response = network.getResponse(params, BOSS_DETAIL);
String task = response.jsonPath().getString("data.contentId");
Assert.assertEquals(task, "Kj21NTY3MTk", network.message(params, BOSS_DETAIL, "获取内容id失败",response.body().asString()));
}
//发布任务
@Test(description = "发布任务", priority = 6)
public void 发布任务() throws IOException {
List<String> a =new ArrayList<>();
List<String> b =new ArrayList<>();
b.add("Kj22Mjk1MQ");
Map<String, Object> params = new HashMap<String, Object>();
params.put("effectiveDuration", 7);
params.put("isAllMen", false);
params.put("superiorIds",a);
params.put("sellerIds", b);
params.put("taskId", 1);
Response response = network.postResponse(params, BOSS_PUBLISH);
boolean publish = response.jsonPath().getBoolean("data");
Assert.assertEquals(publish, true, network.message(params, BOSS_PUBLISH, "任务发布失败",response.body().asString()));
}
//团队任务接收人查询
@Test(description = "已完成人数查询", priority = 7)
public void 已完成人数查询() throws IOException {
Map<String, Object> params = new HashMap<String, Object>();
params.put("taskId", 1);
params.put("pageSize", 20);
params.put("type", 2);
Response response = network.getResponse(params, BOSS_RECEIVERLIST);
int completed = response.jsonPath().getInt("data.totalCount");
Assert.assertEquals(completed, 8, network.message(params, BOSS_RECEIVERLIST, "已完成人数查询失败",response.body().asString()));
}
@Test(description = "未完成人数查询", priority = 8)
public void 未完成人数查询() throws IOException {
Map<String, Object> params = new HashMap<String, Object>();
params.put("taskId", 1);
params.put("pageSize", 20);
params.put("type", 1);
Response response = network.getResponse(params, BOSS_RECEIVERLIST);
int incomplete = response.jsonPath().getInt("data.totalCount");
Assert.assertEquals(incomplete, 11, network.message(params, BOSS_RECEIVERLIST, "未完成人数查询失败",response.body().asString()));
}
//数据版块
@AfterClass
public static void tearDown(){
// 取消标记为内部人员
BaseUtils.switchInsider(1);
}
}
\ No newline at end of file
package com.kjj.cases.basics;
import com.kjj.utils.NetworkUtils;
import com.kjj.utils.ThreadSleepUtils;
import io.restassured.response.Response;
import org.testng.Assert;
import org.testng.annotations.*;
import org.testng.annotations.Test;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static com.kjj.config.BasicConfig.*;
public class CircleFriends {
private static final NetworkUtils network = NetworkUtils.getInstance();
public int firstTagId;
public String contentId;
public String tagId;
public String tagName;
@BeforeClass
public void setUp() {
}
@Test(description="是否首次进入",priority = 1)
public void 是否首次进入() {
Response response = network.getResponse(FRIENDS_ISUSERFIRSTENTERANDCOLLECT);
String desc = response.jsonPath().getString("desc");
Assert.assertEquals(desc,"OK",network.message(FRIENDS_ISUSERFIRSTENTERANDCOLLECT,"是否首次进入和首次收藏发圈素材列表-接口有误",response.body().asString()));
}
// tab列表 后端根据tku自行判断
@Test(description="获取tab列表",priority = 2)
public void 获取tab列表() {
Response response = network.getResponse(FRIENDS_GETMATERIALTAGS);
boolean hasList = response.jsonPath().getInt("data.size()") > 0;
int id = response.jsonPath().getInt("data.find {it.name == '保险'}.id"); //标签tab
firstTagId = response.jsonPath().getInt("data[0].id");//第一个标签的ID
Assert.assertTrue(hasList,network.message(FRIENDS_GETMATERIALTAGS,"获取tab数量有误",response.body().asString()));
Assert.assertEquals(id,595,network.message(FRIENDS_GETMATERIALTAGS,"获取tab中不包含保险",response.body().asString()));
}
@Test(description="获取推荐(未读)列表",priority = 3)
public void 获取推荐列表() throws IOException {
Map<String, Object> params = new HashMap<String, Object>();
params.put("firstTagId",firstTagId);
Response response = network.getResponse(params,FRIENDS_GETUNREADTIMELINSLIST);
int count = response.jsonPath().getInt("data.size()");
contentId = response.jsonPath().getString("data[0].contentId"); //素材ID
tagId = response.jsonPath().getString("data[0].materialTag"); //素材频道ID
tagName = response.jsonPath().getString("data[0].tagName"); //素材频道名称
Assert.assertTrue(count>1,network.message(params,FRIENDS_GETUNREADTIMELINSLIST,"获取推荐列表有误",response.body().asString()));
}
@Test(description="获取全部列表",priority = 4)
public void 获取全部列表() throws IOException {
Map<String, Object> params = new HashMap<String, Object>();
params.put("firstTagId",firstTagId);
params.put("pageIndex",1);
params.put("pageSize",10);
Response response = network.getResponse(params,FRIENDS_GETTIMELINELIST);
int count = response.jsonPath().getInt("data.list.size()");
Assert.assertEquals(count,10,"获取未读列表有误");
}
@Test(description="素材标记为已读",priority = 5)
public void 素材标记为已读() throws IOException, InterruptedException {
//标记为已读
Map<String, Object> params = new HashMap<String, Object>();
params.put("contentId",contentId);
params.put("firstTagId",firstTagId);
Response response = network.postResponse(params,FRIENDS_ASYNCMARKTIMELINEREAD);
boolean data = response.jsonPath().getBoolean("data");
Assert.assertTrue(data,network.message(params,FRIENDS_ASYNCMARKTIMELINEREAD,"标记已读-接口有误",response.body().asString()));
//延迟2秒,存入ES
ThreadSleepUtils.sleep(5000);
//重新获取未读列表
response = network.getResponse(params,FRIENDS_GETUNREADTIMELINSLIST);
List<String> contentList = response.jsonPath().getList("data.contentId");
boolean unRead = contentList.contains(contentId); //检查是否未读,false为已读,true为未读
Assert.assertFalse(unRead,network.message(params,FRIENDS_GETUNREADTIMELINSLIST,"已读后,未读接口没有过滤已读素材",response.body().asString()));
}
@Test(description="收藏素材",priority = 6)
public void 收藏素材() throws IOException {
// 收藏素材
Map<String, Object> params = new HashMap<String, Object>();
params.put("contentId",contentId);
params.put("operate",1);
Response response = network.getResponse(params,FRIENDS_ADDORCANCELCOLLECT);
boolean isAdd = response.jsonPath().getBoolean("data");
Assert.assertTrue(isAdd,network.message(params,FRIENDS_ADDORCANCELCOLLECT,"收藏素材失败",response.body().asString()));
// 查看收藏列表
params.put("pageSize",12);
response = network.getResponse(params,FRIENDS_QUERYLISTFORCOLLECT);
String collectContentId = response.jsonPath().getString("data[0].contentId");
Assert.assertEquals(collectContentId,contentId,network.message(params,FRIENDS_QUERYLISTFORCOLLECT,"收藏列表有误",response.body().asString()));
// 取消收藏
params.put("operate",2);
response = network.getResponse(params,FRIENDS_ADDORCANCELCOLLECT);
boolean isCancel = response.jsonPath().getBoolean("data");
Assert.assertTrue(isCancel,network.message(params,FRIENDS_ADDORCANCELCOLLECT,"取消收藏素材失败",response.body().asString()));
}
@Test(description="素材频道页",priority = 7)
public void 素材频道页() throws IOException {
//频道页 头部
ThreadSleepUtils.sleep(500);
Map<String, Object> params = new HashMap<String, Object>();
params.put("tagId",tagId);
Response response = network.getResponse(params,FRIENDS_CHANNELDETAIL);
String name = response.jsonPath().getString("data.tagName");
Assert.assertEquals(name,tagName,network.message(params,FRIENDS_CHANNELDETAIL,"素材频道页-头部获取有误",response.body().asString()));
//频道页 列表
params.put("pageSize",10);
params.put("pageNo",1);
response = network.getResponse(params,FRIENDS_GETCHANNELLIST);
String collectTagtId = response.jsonPath().getString("data[0].materialTag"); //素材ID
boolean hasList = response.jsonPath().getInt("data.size()") > 0;
Assert.assertEquals(collectTagtId,tagId,network.message(params,FRIENDS_GETCHANNELLIST, "素材列表获取有误",response.body().asString()));
Assert.assertTrue(hasList,network.message(params,FRIENDS_GETCHANNELLIST,"素材频道列表-获取有误",response.body().asString()));
}
@Test(description="从首页发圈列表页进入",priority = 8)
public void 从首页发圈列表页进入() throws IOException {
// 获取首页发圈素材列表
Response response = network.getResponse(HOME_GETHOMETIMELINECONTENT);
String currentId = response.jsonPath().getString("data.materialVos[0].contentId");
Assert.assertNotNull(currentId,network.message(HOME_GETHOMETIMELINECONTENT,"获取首页发圈列表有误",response.body().asString()));
// 如果有推荐列表,进入发圈
if (currentId.length() > 0){
Map<String, Object> params = new HashMap<String, Object>();
params.put("currentId",currentId);
response = network.getResponse(params,FRIENDS_GETCURRENTINFO);
String topContentId = response.jsonPath().getString("data.contentId");
Assert.assertEquals(topContentId,currentId,network.message(params,FRIENDS_GETCURRENTINFO,"从首页进入发圈的头部素材有误",response.body().asString()));
}
}
@AfterClass
public static void tearDown(){
apiCount += 13;
}
}
package com.kjj.cases.basics;
import com.kjj.utils.NetworkUtils;
import io.restassured.response.Response;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import static com.kjj.config.BasicConfig.*;
public class GreetingCard {
private static final NetworkUtils network = NetworkUtils.getInstance();
public int tagId;
public String greetingName;
public String contentId;
public String scid;
public String shareId;
public String confId;
@BeforeClass
public void setUp() {
}
// BANNER
@Test(description="BANNER",priority = 1)
public void BANNER() throws IOException {
Response response = network.getResponse(GREETING_banner);
boolean hasList = response.jsonPath().getInt("data.size()") > 0;
Assert.assertTrue(hasList,network.message(GREETING_banner,"获取Banner列表失败",response.body().asString()));
}
// 转发最多
@Test(description="大家都在发",priority = 2)
public void 大家都在发() throws IOException {
Response response = network.getResponse(GREETING_allForward);
boolean hasList = response.jsonPath().getInt("data.size()") > 0;
Assert.assertTrue(hasList,network.message(GREETING_allForward,"获取大家都在发列表失败",response.body().asString()));
}
// 贺卡tab
@Test(description="贺卡tab",priority = 3)
public void 贺卡tab() throws IOException {
Map<String, Object> params = new HashMap<String, Object>();
params.put("tagType","greeting_card");
params.put("exclusiveArea",0);
Response response = network.getResponse(params, GREETING_findByType);
int totalCount = response.jsonPath().getInt("data.list.size()");
tagId = response.jsonPath().getInt("data.list[-1].id");
Assert.assertEquals(totalCount,3,network.message(params, GREETING_findByType,"获取贺卡tab失败",response.body().asString()));
}
// 获取539的贺卡列表
@Test(description="生日tab贺卡列表",priority = 4)
public void 生日tab贺卡列表() throws IOException {
Map<String, Object> params = new HashMap<String, Object>();
params.put("pageIndex", 1);
params.put("pageSize", 10);
params.put("type",6);
params.put("tag1Id",tagId);
Response response = network.getResponse(params, GREETING_pageList);
boolean hasList = response.jsonPath().getInt("data.list.size()") > 0;
contentId = response.jsonPath().getString("data.list[0].id");
greetingName = response.jsonPath().getString("data.list[0].title");
Assert.assertTrue(hasList,network.message(params, GREETING_pageList,"获取贺卡tab失败",response.body().asString()));
}
// 贺卡详情页
@Test(description="贺卡详情页",priority = 5)
public void 贺卡详情页() throws IOException {
// 获取scId
Map<String, Object> params = new HashMap<String, Object>();
params.put("contentId", contentId);
Response response = network.getResponse(params,GETSCID);
scid = response.jsonPath().getString("data");
// 获取贺卡信息
Map<String, Object> infoParams = new HashMap<String, Object>();
infoParams.put("scid",scid);
response = network.getResponse(infoParams,GREETING_H5INFO);
String name = response.jsonPath().getString("data.title");
Assert.assertEquals(name,greetingName, network.message(infoParams,GREETING_H5INFO,"获取贺卡信息失败",response.body().asString()));
}
// 获取H5分享信息
@Test(description="获取H5分享信息",priority = 7)
public void 获取H5分享信息() throws IOException {
Map<String, Object> params = new HashMap<String, Object>();
params.put("scid", scid);
params.put("createSource",1);
Response response = network.postResponse(params,GREETING_SAVEDEFAULT);
confId = response.jsonPath().getString("data");
Map<String, Object> shareParams = new HashMap<String, Object>();
shareParams.put("confId", confId);
response = network.getResponse(shareParams,GREETING_H5SHARE);
shareId = response.jsonPath().getString("data.id");
String title = response.jsonPath().getString("data.title");
Assert.assertEquals(title,greetingName,network.message(shareParams,GREETING_H5SHARE,"获取H5分享信息失败",response.body().asString()));
}
// 我送出的贺卡列表
@Test(description="我送出的贺卡列表",priority = 8)
public void 我送出的贺卡列表() throws IOException {
Map<String, Object> params = new HashMap<String, Object>();
params.put("pageIndex", 1);
params.put("pageSize", 10);
Response response = network.getResponse(params, GREETING_confList);
boolean hasList = response.jsonPath().getInt("data.list.size()") > 0;
Assert.assertFalse(hasList,network.message(params, GREETING_confList,"获取我的贺卡初始列表数量有误",response.body().asString()));
}
@AfterClass
public static void tearDown(){
apiCount += 8;
// 删除账号
// BaseUtils.disableUser();
}
}
package com.kjj.cases.basics;
import com.kjj.utils.NetworkUtils;
import org.testng.annotations.*;
public class Home {
private static final NetworkUtils network = NetworkUtils.getInstance();
@BeforeClass
public void setUp() {
}
}
......@@ -25,9 +25,9 @@ public class Novice {
//会员判断
@Test(description="会员判断",priority = 1)
public void 会员判断() throws IOException {
Response response = network.getResponse(ISVIPSUBSCRIBE);
Response response = network.getResponse(isVipSubscribe);
boolean isVip = response.jsonPath().getBoolean("data.vip");
Assert.assertTrue(true, network.message(ISVIPSUBSCRIBE,"新手任务-会员判断错误",response.body().asString()));
Assert.assertTrue(true, network.message(isVipSubscribe,"新手任务-会员判断错误",response.body().asString()));
}
//用户信息
......@@ -176,37 +176,7 @@ public class Novice {
Assert.assertEquals(code,1,network.message(NOVICE_LIST,"上传文章-完成新手任务 失败",response.body().asString()));
}
// 收到好友转发访问 该接口已废弃
// @Test (description = "新手任务_收到好友转发访问",priority = 9) //priorty 方法执行优先级
// public void 新手任务_收到好友转发访问() throws IOException {
// //获取列表中"收到好友转发访问"的任务
// Response response = network.getResponse("/kjy/mp/seller/novice/list");
//
// //获取任务名为"收到好友转发访问"的任务状态 code: 0未完成 1可领奖励 2已完成
// int code = response.jsonPath().getInt("data.find {it.taskName == '收到好友转发访问'}.taskStatus.code");
// Assert.assertEquals(code,0,"获取新手任务初始状态-收到好友转发访问 失败");
//
// //收到好友转发访问
// network.agentCookies.put("tku",network.visitorTku); //tku 切换为访客的
//
// Map<String, Object> params = new HashMap<String, Object>();
// params.put("scId","Kj20MTMwMDM5");//文章scId
// params.put("forwardType",2);// 1:个人/微信群 2:朋友圈
// response = network.getResponse(params,"/kjy/mp/forward");
// boolean data = response.jsonPath().getBoolean("data");
// Assert.assertTrue(data,"收到好友转发访问-好友转发到朋友圈 失败");
//
// network.agentCookies.put("tku",network.agentTku); //tku 切换为代理人的
//
//// //重新获取任务名为"收到好友转发访问"的任务状态,验证任务是否生效
//// response = network.getResponse("/kjy/mp/seller/novice/list");
//// //获取任务名为"收到好友转发访问"的任务状态 code: 0未完成 1可领奖励 2已完成
//// code = response.jsonPath().getInt("data.find {it.taskName == '收到好友转发访问'}.taskStatus.code");
//// Assert.assertEquals(code,1,"收到好友转发访问-新手任务完成状态 获取失败");
//
//
//
// }
//查看访问客户
@Test (description = "新手任务_查看访问客户",priority = 9) //priorty 方法执行优先级
......@@ -277,8 +247,5 @@ public class Novice {
return scId;
}
@AfterClass
public static void tearDown(){
apiCount += 6;
}
}
This diff is collapsed.
......@@ -34,7 +34,7 @@ public class LiveBefore implements Authorization {
// 获取直播前我的客户页面全部tab;
@Test(description="获取直播前我的客户页面全部tab数据",priority = 1)
@Test(description="获取直播前我的客户页面全部tab数据",priority = 2)
public void 获取直播前我的客户页面全部tab数据() {
Map<String, Object> params = new HashMap<String, Object>();
params.put("liveId", LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
......@@ -47,7 +47,7 @@ public class LiveBefore implements Authorization {
}
// 获取直播前我的客户页面直接邀请tab;
@Test(description="获取直播前我的客户页面直接邀请tab数据",priority = 2)
@Test(description="获取直播前我的客户页面直接邀请tab数据",priority = 3)
public void 获取直播前我的客户页面直接邀请tab数据() throws IOException {
Map<String, Object> params = new HashMap<String, Object>();
params.put("liveId", LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
......@@ -61,7 +61,7 @@ public class LiveBefore implements Authorization {
}
// 获取直播前我的客户页面转介绍tab;
@Test(description="获取直播前我的客户页面转介绍tab数据",priority = 3)
@Test(description="获取直播前我的客户页面转介绍tab数据",priority = 4)
public void 获取直播前我的客户页面转介绍tab数据() throws IOException {
Map<String, Object> params = new HashMap<String, Object>();
params.put("liveId", LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
......
......@@ -281,13 +281,13 @@ public class FlipCard implements Authorization {
Response response = network.getResponse(params, BasicConfig.MOBILE_record);
System.out.println(response.body().asString());
int leftNum =response.jsonPath().getJsonObject("data.leftNum");
Assert.assertTrue(leftNum==4, network.message(params, BasicConfig.MOBILE_record, "翻牌次数不足", response.body().asString()));
Assert.assertTrue(leftNum==5, network.message(params, BasicConfig.MOBILE_record, "翻牌次数不足", response.body().asString()));
visitorAuth22();
Response recordRes= network.getResponse(params, BasicConfig.MOBILE_record);
System.out.println(recordRes.body().asString());
int leftNum1 =response.jsonPath().getJsonObject("data.leftNum");
Assert.assertTrue(leftNum1==4, network.message(params, BasicConfig.MOBILE_record, "翻牌次数不足", recordRes.body().asString()));
Assert.assertTrue(leftNum1==5, network.message(params, BasicConfig.MOBILE_record, "翻牌次数不足", recordRes.body().asString()));
}
......
......@@ -1420,6 +1420,8 @@ public class SaveLive implements Authorization {
Params.put("num",2);
Params.put("showAmount",1000);
Params.put("showMaxAmount",1000);
Params.put("poolType",1);
Params.put("freeNum",1);
Response response = network.postResponse(Params, BasicConfig.MANAGER_flipWord);
boolean data = response.jsonPath().getBoolean("data");
System.out.println(data);
......
......@@ -18,7 +18,7 @@ public class BaseUtils {
*/
public static void ssoLogin(){
// 请求下后台的管理员信息接口
Response response = network.getResponse(MANAGER_ADMININFO);
Response response = network.getResponse(MANAGER_adminInfo);
String actualType = "application/json;charset=UTF-8";
String exceptType = response.headers().getValue("Content-Type"); //如果返回的是html的contentType,说明token已经失效
......@@ -34,14 +34,9 @@ public class BaseUtils {
loginParams.put("loginTimeout",1);
loginParams.put("redirect",MANAGER_HOST);
loginParams.put("systemId",201);
response = network.postResponse(loginParams,SSO_DOLOGIN);
response = network.postResponse(loginParams,SSO_doLogin);
Map<String, String> ssoCookies = response.getCookies();
network.agentCookies.putAll(ssoCookies); //存入cookies
// // 2.登录客集集管理后台
// String redirectUrl = response.jsonPath().getString("redirect");//获取重定向地址
// response = network.getManagerCookies(redirectUrl);
ssoCookies = response.getCookies();
network.agentCookies.putAll(ssoCookies);
network.agentHeaders.put("X-Csrf-Token",ssoCookies.get("csrf_token"));
......@@ -50,231 +45,5 @@ public class BaseUtils {
}
/**
* 获取 sellerId
* @return sellerId
*/
public static String getSellerId (){
Response response = network.getResponse(USER_INFO);
return response.jsonPath().getString("data.sellerId");
}
/**
* 获取 userId
* @return userId
*/
public static String getUserId (){
Response response = network.getResponse(USER_INFO);
return response.jsonPath().getString("data.userId");
}
/**
* 切换vip
* @param userVersion 1是通用版 2是保险版
* @param vipType 1是普通用户 2是vip用户
*/
public static void switchVip(int userVersion, int vipType) {
String sellerId = getSellerId();
// 登录下,检验是否失效
ssoLogin();
// 1.切换公司为客集集
Map<String, Object> changeParams = new HashMap<String, Object>();
changeParams.put("id",sellerId);
changeParams.put("companyId",6);
Response response = network.getResponse(changeParams,MANAGER_CHANGECOMPANY);
response.body().prettyPrint();
// 2.切换为保险版vip
Map<String, Object> switchVipParams = new HashMap<String, Object>();
switchVipParams.put("reason","1");
switchVipParams.put("sellerId",sellerId);
switchVipParams.put("userVersion",userVersion);
switchVipParams.put("vipType",vipType);
switchVipParams.put("vipStartDate",System.currentTimeMillis());
switchVipParams.put("vipEndDate",System.currentTimeMillis() + 1000*3600*24*365L);
response = network.postResponse(switchVipParams,MANAGER_UPDATETYPEORDATE);
// 3.切换公司为空
changeParams.remove("companyId",6); //去掉公司
response = network.getResponse(changeParams,MANAGER_CHANGECOMPANY);
// 删除管理后台tku
network.agentHeaders.remove("X-Csrf-Token");
network.agentCookies.remove("sso_ticket");
network.agentCookies.remove("device_no");
network.agentCookies.remove("csrf_token");
}
/**
* 标记为内部人员
* @param isInternalSeller 1:内部人员 0:非内部人员
*/
public static void switchInsider(int isInternalSeller){
String sellerId = getSellerId();
// 登录下,检验是否失效
ssoLogin();
Map<String, Object> params = new HashMap<String, Object>();
params.put("id",sellerId);
params.put("internalSeller",isInternalSeller);//
Response response = network.getResponse(params,MANAGER_SETINTERALSELLER);
response.body().prettyPrint();
// 删除管理后台tku
network.agentHeaders.remove("X-Csrf-Token");
network.agentCookies.remove("sso_ticket");
network.agentCookies.remove("device_no");
network.agentCookies.remove("csrf_token");
}
/**
* 获取优惠码
* @return 未使用的优惠码
*/
public static String getPromotionCode() {
// 登录下,检验是否失效
ssoLogin();
// 获取该优惠码详情
Map<String, Object> params = new HashMap<String, Object>();
params.put("id",PROMOTION_CODE);
Response response = network.getResponse(params,MANAGER_PROMOTIONCODEBATCHDETAIL);
long deadline = response.jsonPath().getLong("data.deadline");
deadline = (deadline - System.currentTimeMillis()) / (1000*60*60*24); //到期时间
// 检测日期是否快到期,若到期修改截止日期
if (deadline < 5) {
modifyPromotionCode(0);
}
// 获取该优惠码下未使用的列表
Map<String, Object> listParams = new HashMap<String, Object>();
listParams.put("batchId",PROMOTION_CODE);
listParams.put("promotionCodeStatus",0); //0 未使用
listParams.put("pageIndex",1);
listParams.put("pageSize",20);
response = network.getResponse(listParams,MANAGER_PROMOTIONCODELIST);
int unUseCount = response.jsonPath().getInt("data.list.size()");
// 优惠码未使用数量 不足5个
if (unUseCount < 5) {
modifyPromotionCode(100);
}
// 取未使用列表的第一个优惠码
response =network.getResponse(listParams,MANAGER_PROMOTIONCODELIST);
return response.jsonPath().getString("data.list[0].promotionCode");
}
/**
* 修改优惠码
* @param addNum 追加的优惠码数量
*/
public static void modifyPromotionCode(int addNum){
Map<String, Object> params = new HashMap<String, Object>();
params.put("addNum", Math.max(addNum, 0)); // 如果addNum > 0,则返回大的那个值
params.put("startTime",System.currentTimeMillis());
params.put("deadline",System.currentTimeMillis() + 1000*60*60*24*30L);
params.put("city","杭州");
params.put("codeTotal",200);
params.put("comboId","1");
params.put("companyId",82);
params.put("id",398);
params.put("price","3860000.00");
params.put("province",null);
params.put("remark","接口自动化测试");
params.put("userVersion",2);
Response response = network.postResponse(params,MANAGER_PROMOTIONBATCHMODIFY);
response.body().prettyPrint();
}
/**
* 创建用户和tku
*/
public static String createTku(){
// 创建userId
Map<String, Object> params = new HashMap<String, Object>();
params.put("openId",OPEN_ID);
params.put("oaSourceId",OASOURCE_ID);
Response response = network.getResponse(params,CREATE_USER);
long userId = response.jsonPath().getLong("data");
response.body().prettyPrint();
// 创建tku
Map<String, Object> tkuParams = new HashMap<String, Object>();
tkuParams.put("userId",userId);
response = network.getResponse(tkuParams,AUTOTEST_TKU);
response.body().prettyPrint();
String tku = "";
try {
// 判断tku 是否有效
tku = response.jsonPath().getString("data");
Assert.assertNotNull(tku);
} catch (AssertionError e) {
System.out.println("获取tku失败");
DingTalkUtils.sendError("测试停止-获取tku失败! \n"+
"path: " + AUTOTEST_TKU + "\n" +
"params: " + params + "\n" +
"response: "+response.body().asString());
throw new RuntimeException();
}
// tku赋值
return tku;
}
/**
* 获取tku
* @param userId 用户id
* @return 用户tku
*/
public static String getTku(int userId){
Map<String, Object> tkuParams = new HashMap<String, Object>();
tkuParams.put("userId",userId);
Response response = network.getResponse(tkuParams,AUTOTEST_TKU);
response.body().prettyPrint();
return response.jsonPath().getString("data");
}
/**
* 账号禁用
*/
public static void disableUser() {
// 获取sellerId、userId
String sellerId = getSellerId();
String userId = getUserId();
// 取关公众号
Map<String, Object> unsubscribeParams = new HashMap<String, Object>();
unsubscribeParams.put("userId",userId);
unsubscribeParams.put("oaId",1);
Response response = network.getResponse(unsubscribeParams,AUTOTEST_UNSUBSCRIBE);
System.out.println(response.statusCode());
// 登录下,检验是否失效
ssoLogin();
// 公司改为客集集
Map<String, Object> changeParams = new HashMap<String, Object>();
changeParams.put("id",sellerId);
changeParams.put("companyId",6);
response = network.getResponse(changeParams,MANAGER_CHANGECOMPANY);
// 删除账号
Map<String, Object> params = new HashMap<String, Object>();
params.put("userId",userId);
response = network.postResponse(params,MANAGER_DISABLEUSER);
response.body().prettyPrint();
}
public static void main(String[] args) throws IOException {
disableUser();
}
}
......@@ -219,10 +219,6 @@ public class MysqlUtils {
}
}
public static void main(String[] args) throws SQLException {
// JdbcUtils jdbc = new JdbcUtils("root", "root", "com.mysql.jdbc.Driver", "jdbc:mysql://localhost:3306/learning");
//
// Map<String, Object> map = jdbc.findSimpleResult("select * from t_user where USER_ID='1'", null);
MysqlUtils jdbcUtils = new MysqlUtils("tuia_adver");
jdbcUtils.getConnection();
Map<String, Object> map = jdbcUtils.findSimpleResult("select * from account where company_name=?","兑吧科技有限公司");
......
......@@ -4,7 +4,12 @@
<test preserve-order="true" name="支付">
<classes>
<class name="com.kjj.cases.basics.Pay"/>
<class name="com.kjj.cases.assistant.pay.Pay"/>
</classes>
</test>
<test preserve-order="true" name="邀请返现">
<classes>
<class name="com.kjj.cases.assistant.pay.Cashback"/>
</classes>
</test>
<test preserve-order="true" name = "首页">
......@@ -37,17 +42,31 @@
<class name="com.kjj.cases.assistant.homePage.Upload"/>
</classes>
</test>
<test preserve-order="true" name = "谁看过我_团队看板">
<test preserve-order="true" name = "获取访客">
<classes>
<class name="com.kjj.cases.assistant.whoSawMe.ForwardAndRead"/>
</classes>
</test>
<test preserve-order="true" name = "谁看过我">
<classes>
<class name="com.kjj.cases.assistant.whoSawMe.WhoSawMe"/>
</classes>
</test>
<test preserve-order="true" name = "我的转发">
<classes>
<class name="com.kjj.cases.assistant.whoSawMe.MyForward"/>
</classes>
</test>
<test preserve-order="true" name = "贺卡">
<classes>
<class name="com.kjj.cases.assistant.markettools.greetingCrad"/>
<class name="com.kjj.cases.assistant.markettools.GreetingCrad"/>
</classes>
</test>
<test preserve-order="true" name = "抽奖转盘">
<classes>
<class name="com.kjj.cases.assistant.markettools.GameLottery"/>
</classes>
</test>
</suite>
<!-- Suite -->
......
This diff is collapsed.
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