Commit 190bc511 authored by xiamengchen's avatar xiamengchen

新增访客个人主页

parent c89dc69f
......@@ -451,6 +451,7 @@ public class Agent implements Authorization {
params.put("shortType",2);
Response response =null;
for (int i = 0; i < 10; i++) {
ThreadSleepUtils.sleep(1000);
response = network.postResponse(params,MOBILE_getShortUrl);
String data = response.jsonPath().getString("data");
System.out.println(data);
......
......@@ -169,6 +169,8 @@ public class LiveVisitors implements Authorization
Response response = network.getResponse(params, BasicConfig.MOBILE_Link);
boolean invite = response.jsonPath().getBoolean("success");
Assert.assertTrue(invite,network.message(params,BasicConfig.MOBILE_Link,"领取免费领资料失败",response.body().asString()));
resourceReceiveRecordId = response.jsonPath().getString("data");
}
/*访客端链接小程序资料-查询*/
......@@ -196,8 +198,6 @@ public class LiveVisitors implements Authorization
Response response = network.getResponse(params, BasicConfig.MOBILE_Link);
boolean data = response.jsonPath().getBoolean("success");
Assert.assertTrue(data,network.message(params,BasicConfig.MOBILE_Link,"领取链接资料失败",response.body().asString()));
resourceReceiveRecordId = response.jsonPath().getString("data");
}
/*代理人端权益列表查询*/
......
......@@ -4,7 +4,6 @@ import com.kjj.bean.whoSawMe.LiveList;
import com.kjj.bean.whoSawMe.ResourceList;
import com.kjj.bean.whoSawMe.WelfareList;
import com.kjj.cases.admin.Authorization;
import com.kjj.cases.live.agent.Agent;
import com.kjj.cases.live.anchor.LiveVisitors;
import com.kjj.cases.live.lottery.Lottery;
import com.kjj.config.BasicConfig;
......@@ -42,14 +41,24 @@ public class PersonalPage implements Authorization {
Response response = network.getResponse(params, BasicConfig.USER_welfareList);
System.out.println("访客福利列表:" + response.body().asString());
List<WelfareList> welfareLists = JsonUtil.parseResponseToPageBean(response, WelfareList.class);
WelfareList welfareList = welfareLists.get(0);
Assert.assertEquals(welfareList.getLiveId(), LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()), network.message(params, BasicConfig.USER_welfareList, "最新福利对应直播id不正确", response.body().asString()));
// WelfareList welfareList = welfareLists.get(0);
// Assert.assertEquals(welfareList.getLiveId(), LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()), network.message(params, BasicConfig.USER_welfareList, "最新福利对应直播id不正确", response.body().asString()));
Map<String, Object> getLotteryDetailPar = new HashMap<>();
getLotteryDetailPar.put("confId", Lottery.lotteryConfId);
Response getLotteryDetailRes = network.getResponse(getLotteryDetailPar, BasicConfig.USER_findLottryDetail);
welfareRecordId = getLotteryDetailRes.jsonPath().getString("data.recordId");
Assert.assertNotNull(welfareRecordId, network.message(getLotteryDetailPar, BasicConfig.USER_findLottryDetail, "获取福利领取记录id获取失败", getLotteryDetailRes.body().asString()));
Assert.assertEquals(welfareList.getRecordId(), welfareRecordId, network.message(params, BasicConfig.USER_welfareList, "最新福利对应领取记录id不正确", response.body().asString()));
// Assert.assertEquals(welfareList.getRecordId(), welfareRecordId, network.message(params, BasicConfig.USER_welfareList, "最新福利对应领取记录id不正确", response.body().asString()));
boolean hasRecord = false;
for (WelfareList welfareList : welfareLists){
if(welfareList.getLiveId().equals(LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()))){
System.out.println("本场直播获得福利有:" + welfareList);
if (welfareList.getRecordId().equals(welfareRecordId)){ hasRecord = true; }
}
}
Assert.assertTrue(hasRecord, network.message(params, BasicConfig.USER_welfareList, "上场直播有抽奖福利未记录", response.body().asString()));
}
@Test(description = "访客查看我的资料", priority = 5)
......@@ -70,17 +79,20 @@ public class PersonalPage implements Authorization {
@Test(description = "获取访客最近观看的公司", priority = 6)
public void 获取访客最近观看的公司() {
// 管理后台根据公司名称查询公司id
Map<String, Object> searchCompanyPar = new HashMap<>();
searchCompanyPar.put("companyName", companyName);
Response searchCompanyRes = network.getResponse(searchCompanyPar, BasicConfig.MANAGER_searchCompany);
Assert.assertTrue(searchCompanyRes.jsonPath().getBoolean("success"), network.message(searchCompanyPar, BasicConfig.MANAGER_searchCompany, "接口调用失败", searchCompanyRes.body().asString()));
long companyId = searchCompanyRes.jsonPath().getInt("data[0].id");
// 加密公司id
String companyIdEncode = IdMakeUtil.managerEncodingId(companyId);
Response response = network.getResponse(BasicConfig.USER_lastCompany);
Assert.assertTrue(response.jsonPath().getBoolean("success"), network.message(BasicConfig.USER_lastCompany, "接口请求失败", response.body().asString()));
encodeCompanyId = response.jsonPath().getString("data.companyId");
Assert.assertEquals(encodeCompanyId, IdMakeUtil.encodingId(companyId), network.message(BasicConfig.USER_lastCompany, "访客最近观看公司id错误", response.body().asString()));
Assert.assertEquals(encodeCompanyId, companyIdEncode, network.message(BasicConfig.USER_lastCompany, "访客最近观看公司id错误", response.body().asString()));
}
// 访客主页视角
......@@ -94,11 +106,8 @@ public class PersonalPage implements Authorization {
Assert.assertNotNull(data, network.message(params, BasicConfig.USER_getCompanyInfo, "查看公司详情失败", getCompanyDetailRes.body().asString()));
}
@Test(description = "查看公司正在直播列表", priority = 8)
public void 查看公司正在直播列表(){
// 管理后台对应公司创建一个演示直播
@Test(description = "查看公司直播列表", priority = 8)
public void 查看公司直播列表(){
// 访客端查看公司正在直播列表
params.clear();
params.put("companyId", encodeCompanyId);
......@@ -107,12 +116,13 @@ public class PersonalPage implements Authorization {
params.put("pageSize", 10);
Response liveOnListRes = network.getResponse(params, BasicConfig.USER_getLiveList);
Assert.assertTrue(liveOnListRes.jsonPath().getBoolean("success"), network.message(params, BasicConfig.USER_getLiveList, "接口请求失败", liveOnListRes.body().asString()));
boolean hasLiveOn = true;
try {
List liveList = liveOnListRes.jsonPath().getList("data.list");
if (liveList.size() == 0){
System.out.println("直播列表为空");
hasLiveOn = false;
}
System.out.println(liveList);
Assert.assertTrue(hasLiveOn, network.message(params, BasicConfig.USER_getLiveList, "公司无未结束直播", liveOnListRes.body().asString()));
} catch (NullPointerException e){
System.out.println("接口返回数据为空");
e.printStackTrace();
......@@ -158,8 +168,8 @@ public class PersonalPage implements Authorization {
Response response = network.getResponse(params, BasicConfig.USER_videoAgentCard);
Assert.assertTrue(response.jsonPath().getBoolean("success"), network.message(params, BasicConfig.USER_videoAgentCard, "接口请求失败", response.body().asString()));
try {
String agentId = response.jsonPath().getString("data.agentId");
Assert.assertEquals(agentId, Agent.encodeAgentId, network.message(params, BasicConfig.USER_videoAgentCard, "代理人id错误", response.body().asString()));
String agentName = response.jsonPath().getString("data.name");
Assert.assertEquals(agentName, "线索员", network.message(params, BasicConfig.USER_videoAgentCard, "代理人id错误", response.body().asString()));
}catch (NullPointerException e){
e.printStackTrace();
}
......
......@@ -342,7 +342,7 @@ public class BasicConfig {
public static final String USER_lastCompany = MOBILE_HOST + "/kjy/live/user/index/latest";
public static final String USER_getCompanyInfo = MOBILE_HOST + "/kjy/live/company/getLiveInfo";
public static final String USER_getLiveList = MOBILE_HOST + "/kjy/live/company/userLiveList";
public static final String USER_companyShareInfo = MOBILE_HOST + " /kjy/live/company/getHomeShareInfo";
public static final String USER_companyShareInfo = MOBILE_HOST + "/kjy/live/company/getHomeShareInfo";
public static final String USER_getLiveOverList = MOBILE_HOST + "/kjy/live/company/userLiveEndList";
public static final String USER_videoAgentCard = MOBILE_HOST + "/kjy/live/card/user/video";
public static final String USER_companyLiving = MOBILE_HOST + "/kjy/live/company/living";
......
package com.kjj.utils;
import com.kjj.cases.admin.Authorization;
import com.kjj.config.BasicConfig;
import io.restassured.response.Response;
import org.apache.commons.lang.StringUtils;
import org.testng.Assert;
import java.util.Base64;
import java.util.HashMap;
import java.util.Map;
/**
* Created by dugq on 2019-10-23.
......@@ -16,7 +22,7 @@ import java.util.Base64;
* base64加密效率: 加密 1 - 2千万 1s以内完成
*/
public class IdMakeUtil {
public class IdMakeUtil implements Authorization {
private static final Base64.Encoder encoder = Base64.getEncoder();
private static final Base64.Decoder decoder = Base64.getDecoder();
......@@ -46,5 +52,15 @@ public class IdMakeUtil {
}
}
public static String managerEncodingId(long id) {
BaseUtils.ssoLogin();
Map<String, Object> ids = new HashMap<>();
ids.put("code", id);
Response encodeIdRes = network.getResponse(ids, BasicConfig.MANAGER_ID_ENCODE);
String encodeId = encodeIdRes.jsonPath().getString("data");
Assert.assertNotNull(encodeId, network.message(ids, BasicConfig.MANAGER_ID_ENCODE, "加密id失败", encodeIdRes.body().asString()));
return encodeId;
}
}
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