Commit d592ef14 authored by 龚小红's avatar 龚小红

Merge branch 'gifeature/20210902-gj' into 'master'

代理人邀约奖励接口用例

See merge request test-group/kejiji!122
parents 6c66e503 472cc865
package com.kjj.cases.live.inviteReward;
import com.kjj.cases.admin.Authorization;
import com.kjj.constants.LiveConstants;
import com.kjj.utils.ThreadSleepUtils;
import io.restassured.response.Response;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import com.kjj.config.BasicConfig;
import java.util.HashMap;
import java.util.Map;
import static com.kjj.config.BasicConfig.*;
public class InviteReward implements Authorization {
@BeforeClass
public void setUp() { agentAuth(); }
@Test(description = "获取预告页代理人邀约奖励是否配置",priority = 1)
public void 获取预告页代理人邀约奖励是否配置(){
Map<String,Object> params = new HashMap<>();
params.put("liveId", LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
Response response = network.getResponse(params,MOBILE_allLottery);
try{
int on = response.jsonPath().getInt("data.on");
System.out.println(on);
String confStr = Integer.toBinaryString(on);
char confStatus = confStr.charAt(confStr.length()-3);
Assert.assertEquals(confStatus, '1',network.message(params,MOBILE_allLottery, "代理人邀约未开启", response.body().asString()));
}catch (Exception e){
e.printStackTrace();
Assert.fail(network.message(params, MOBILE_allLottery, "未获取到数据", response.body().asString()));
}
}
@Test(description = "获取代理人邀约奖励配置详情",priority = 2)
public void 获取代理人邀约奖励配置详情(){
Map<String,Object> params = new HashMap<>();
params.put("liveId", LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
Response response = network.getResponse(params,MOBILE_rewardConfAll);
int inviteNum = response.jsonPath().getJsonObject("data.confDetail.inviteNum");
boolean hasEnoughInvite = response.jsonPath().getBoolean("data.userDetail.hasEnoughInvite");
Assert.assertEquals(inviteNum,2, network.message(params,MOBILE_rewardConfAll,"获取邀约人数错误",response.body().asString()));
Assert.assertTrue(hasEnoughInvite,network.message(params,MOBILE_rewardConfAll,"邀约条件判断错误",response.body().asString()));
}
@Test(description = "获取排行榜页用户详情",priority = 3)
public void 获取排行榜页用户详情(){
ThreadSleepUtils.sleep(1000);
Map<String,Object> params = new HashMap<>();
params.put("liveId", LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
Response response = network.getResponse(params,MOBILE_rewardRankDetail);
boolean hasEnoughInvite = response.jsonPath().getBoolean("data.hasEnoughInvite");
Assert.assertTrue(hasEnoughInvite, network.message(params,MOBILE_rewardRankDetail,"排行榜页判断是否达到邀约条件错误",response.body().asString()));
int surplusInviteNum = response.jsonPath().getInt("data.surplusInviteNum");
Assert.assertTrue(surplusInviteNum<1, network.message(params,MOBILE_rewardRankDetail,"统计还需邀约的人数错误",response.body().asString()));
}
@Test(description = "代理人开红包",priority = 4)
public void 代理人开红包(){
ThreadSleepUtils.sleep(720000);
Map<String,Object> params = new HashMap<>();
params.put("liveId", LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
Response response = network.postResponse(params,MOBILE_rewardUserOpen);
String desc = response.jsonPath().getString("desc");
Assert.assertEquals(desc,"OK", network.message(params,MOBILE_rewardUserOpen,"代理人开红包失败",response.body().asString()));
}
@Test(description = "代理人开红包详情",priority = 5)
public void 代理人开红包详情(){
Map<String,Object> params = new HashMap<>();
params.put("liveId", LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
Response response = network.getResponse(params,MOBILE_rewardOpenState);
Object data = response.jsonPath().getJsonObject("data");
Assert.assertNotNull(data, network.message(params,MOBILE_rewardOpenState,"获取代理人开红包详情失败",response.body().asString()));
}
@Test(description = "代理人B开红包",priority = 6)
public void 代理人B开红包() {
agentAuth1();
Map<String,Object> params = new HashMap<>();
params.put("liveId", LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
Response response = network.postResponse(params,MOBILE_rewardUserOpen);
String desc = response.jsonPath().getString("desc");
Assert.assertEquals(desc,"OK", network.message(params,MOBILE_rewardUserOpen,"代理人B开红包失败",response.body().asString()));
}
//未满足邀约条件领取红包失败
@Test(description = "代理人B开红包详情",priority = 7)
public void 代理人B开红包详情(){
agentAuth1();
ThreadSleepUtils.sleep(1000);
Map<String,Object> params = new HashMap<>();
params.put("liveId", LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
Response response = network.getResponse(params,MOBILE_rewardOpenState);
int redStatus = response.jsonPath().getInt("data.redStatus");
Assert.assertEquals(redStatus,3, network.message(params,MOBILE_rewardOpenState,"获取代理人开红包详情失败",response.body().asString()));
}
@Test(description = "获取代理人邀约排名",priority = 8)
public void 获取代理人邀约排名(){
Map<String,Object> params = new HashMap<>();
params.put("liveId", LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
Response response = network.getResponse(params,MOBILE_rewardStatDetail);
Object data = response.jsonPath().getJsonObject("data");
System.out.println(data);
Assert.assertNotNull(data, network.message(params,MOBILE_rewardStatDetail,"获取邀约排名失败",response.body().asString()));
}
}
package com.kjj.cases.live.inviteReward;
import com.kjj.cases.admin.Authorization;
import com.kjj.config.BasicConfig;
import com.kjj.constants.LiveConstants;
import com.kjj.utils.ThreadSleepUtils;
import io.restassured.response.Response;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import static com.kjj.utils.BaseUtils.ssoLogin;
public class ManagerRewardConf implements Authorization {
@BeforeClass
public void setUp() { ssoLogin();}
@Test(description = "获取直播配置详情",priority = 1)
public void 获取直播配置详情(){
Map<String,Object> params = new HashMap<>();
params.put("liveId", LiveConstants.getValue(LiveConstants.StringKeyEnum.LIVE_ID.getKey()));
System.out.println( LiveConstants.getValue(LiveConstants.StringKeyEnum.LIVE_ID.getKey()));
Response response = network.getResponse(params, BasicConfig.MANAGER_getConfDetail);
Boolean agentInviteRewardConfStatus = response.jsonPath().getBoolean("data.agentInviteRewardConfStatus");
Boolean agentInviteRewardConfBuildStatus = response.jsonPath().getBoolean("data.agentInviteRewardConfBuildStatus");
Assert.assertFalse(agentInviteRewardConfStatus, network.message(params,BasicConfig.MANAGER_getConfDetail,"获取邀约奖励配置开关状态失败",response.body().asString()));
Assert.assertFalse(agentInviteRewardConfBuildStatus, network.message(params,BasicConfig.MANAGER_getConfDetail,"获取邀约奖励配置失败",response.body().asString()));
}
@Test(description = "邀约奖励配置",priority = 2)
public void 邀约奖励配置(){
Map<String,Object> params = new HashMap<>();
params.put("inviteNum",3);
params.put("liveId",LiveConstants.getValue(LiveConstants.StringKeyEnum.LIVE_ID.getKey()));
params.put("redNum",3);
params.put("redSendType",1); //1-随机金额,2-固定金额
params.put("redTotalAmount",100);
params.put("showAmount",100);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date now = new Date();
Date afterDate = new Date(now.getTime() + 720000);
Calendar cal = Calendar.getInstance();
cal.setTime(afterDate);
long timestamp = cal.getTimeInMillis();
System.out.println(timestamp);
params.put("startTime",timestamp);
Response response = network.postResponse(params,BasicConfig.MANAGER_rewardSaveOrUpdate);
String desc = response.jsonPath().getString("desc");
Assert.assertEquals(desc,"OK", network.message(params,BasicConfig.MANAGER_rewardSaveOrUpdate,"首次配置邀约奖励失败",response.body().asString()));
//验证代理人邀约配置成功
params.clear();
ThreadSleepUtils.sleep(2000);
params.put("liveId",LiveConstants.getValue(LiveConstants.StringKeyEnum.LIVE_ID.getKey()));
Response confDetailRes = network.getResponse(params, BasicConfig.MANAGER_getConfDetail);
Boolean agentInviteRewardConfBuildStatus = confDetailRes.jsonPath().getBoolean("data.agentInviteRewardConfBuildStatus");
Assert.assertTrue(agentInviteRewardConfBuildStatus, network.message(params,BasicConfig.MANAGER_getConfDetail,"获取邀约奖励配置失败",confDetailRes.body().asString()));
//获取邀约奖励配置详情
params.clear();
params.put("liveId",LiveConstants.getValue(LiveConstants.StringKeyEnum.LIVE_ID.getKey()));
Response redIdRes = network.getResponse(params, BasicConfig.MANAGER_rewardDetail);
String redConfId = redIdRes.jsonPath().getString("data.redConfId");
Assert.assertNotNull(redConfId, network.message(params,BasicConfig.MANAGER_rewardDetail,"获取红包配置id失败",redIdRes.body().asString()));
//修改红包类型为固定金额
params.clear();
params.put("inviteNum",2);
params.put("liveId",LiveConstants.getValue(LiveConstants.StringKeyEnum.LIVE_ID.getKey()));
params.put("openStatus",0);
params.put("redAmount",30);
params.put("redConfId",redConfId);
params.put("redNum",3);
params.put("redSendType",2); //1-随机金额,2-固定金额
params.put("showAmount",100);
params.put("startTime",timestamp);
Response updateRes = network.postResponse(params,BasicConfig.MANAGER_rewardSaveOrUpdate);
Boolean updateData = updateRes.jsonPath().getBoolean("data");
Assert.assertTrue(updateData, network.message(params,BasicConfig.MANAGER_rewardSaveOrUpdate,"修改邀约奖励失败",updateRes.body().asString()));
}
@Test(description = "开启邀约奖励配置",priority = 3)
public void 开启邀约奖励配置() {
Map<String,Object> params = new HashMap<>();
params.put("liveId",LiveConstants.getValue(LiveConstants.StringKeyEnum.LIVE_ID.getKey()));
params.put("openStatus",1); //开启代理人邀约配置
Response response = network.postResponse(params,BasicConfig.MANAGER_rewardSwitchStatus);
String desc = response.jsonPath().getString("desc");
Assert.assertEquals(desc,"OK", network.message(params,BasicConfig.MANAGER_rewardSwitchStatus,"开启代理人邀约奖励失败",response.body().asString()));
}
}
...@@ -214,6 +214,17 @@ public class BasicConfig { ...@@ -214,6 +214,17 @@ public class BasicConfig {
public static final String ANCHOR_tasks = MOBILE_HOST + "/kjy/live/time/red/tasks"; public static final String ANCHOR_tasks = MOBILE_HOST + "/kjy/live/time/red/tasks";
public static final String MANAGER_deleteTask = MANAGER_HOST + "/kjy/manager/live/time/red/deleteTask"; public static final String MANAGER_deleteTask = MANAGER_HOST + "/kjy/manager/live/time/red/deleteTask";
//*************** 代理人邀约奖励 *************
public static final String MANAGER_rewardSaveOrUpdate = MANAGER_HOST +"/kjy/manager/live/agent/invite/reward/saveOrUpdate";
public static final String MANAGER_rewardSwitchStatus = MANAGER_HOST + "/kjy/manager/live/agent/invite/reward/switchStatus";
public static final String MANAGER_rewardDetail = MANAGER_HOST + "/kjy/manager/live/agent/invite/reward/detail";
public static final String MOBILE_rewardConfAll = MOBILE_HOST + "/kjy/live/agent/invite/reward/conf/all";
public static final String MOBILE_rewardUserOpen = MOBILE_HOST + "/kjy/live/agent/invite/reward/user/open";
public static final String MOBILE_rewardOpenState = MOBILE_HOST + "/kjy/live/agent/invite/reward/user/open/state";
public static final String MOBILE_rewardStatDetail = MOBILE_HOST + "/kjy/live/agent/stat/detail";
public static final String MOBILE_rewardRankDetail = MOBILE_HOST + "/kjy/live/agent/invite/reward/user/rank/detail";
// *************** 成功案例库 *************** // *************** 成功案例库 ***************
public static final String MANAGER_caseTemp = MANAGER_HOST + "/kjy/manager/live/caseTemp/list"; public static final String MANAGER_caseTemp = MANAGER_HOST + "/kjy/manager/live/caseTemp/list";
public static final String MANAGER_caseAdd = MANAGER_HOST + "/kjy/manager/live/case/add"; public static final String MANAGER_caseAdd = MANAGER_HOST + "/kjy/manager/live/case/add";
......
...@@ -35,6 +35,11 @@ ...@@ -35,6 +35,11 @@
<class name="com.kjj.cases.live.secondKill.ConfSecondKill"/> <class name="com.kjj.cases.live.secondKill.ConfSecondKill"/>
</classes> </classes>
</test> </test>
<test preserve-order="true" name="配置代理人邀约奖励">
<classes>
<class name="com.kjj.cases.live.inviteReward.ManagerRewardConf"/>
</classes>
</test>
<test preserve-order="true" name="成功案例"> <test preserve-order="true" name="成功案例">
<classes> <classes>
...@@ -92,6 +97,11 @@ ...@@ -92,6 +97,11 @@
<class name="com.kjj.cases.live.lottery.RelativeLottery"/> <class name="com.kjj.cases.live.lottery.RelativeLottery"/>
</classes> </classes>
</test> </test>
<test preserve-order="true" name="代理人邀约奖励">
<classes>
<class name="com.kjj.cases.live.inviteReward.InviteReward"/>
</classes>
</test>
<test preserve-order="true" name="直播前-我的客户页"> <test preserve-order="true" name="直播前-我的客户页">
<classes> <classes>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment