Commit 1592ebb4 authored by 张艳玲's avatar 张艳玲

Merge branch '20210412bxl' into 'master'

有奖答题

See merge request test-group/kejiji!46
parents 94b01465 9c33f7aa
package com.kjj.bean.answer;
import lombok.Data;
@Data
public class AddAnswer {
private int totalAmount;
private int showAmount;
private int totalNum;
}
package com.kjj.bean.answer;
import lombok.Data;
@Data
public class AnswerQues {
private boolean result;
private int count;
}
package com.kjj.bean.answer;
import lombok.Data;
@Data
public class Option {
private String optionDetail;
private int optionType;
private int answerLen;
}
package com.kjj.bean.answer;
import lombok.Data;
@Data
public class ParticipateInfo {
private boolean result;
private int count;
private int quesType;
private String amount;
private int redReStatus;
private int welfareStatus;
private String rewardName;
private String rewardImg;
private String winnerName;
}
package com.kjj.bean.answer;
import lombok.Data;
import java.util.List;
@Data
public class QuesConf {
private String questionDetail;
private List<Option> optionList;
private String id;
}
package com.kjj.bean.answer;
import lombok.Data;
import java.util.List;
@Data
public class QuseRewardList {
private List<QuesList> list;
@Data
public static class QuesList{
private String quesConfId;
private String question;
private int quesType;
private int num;
private int amount;
private int showAmount;
private String rewardName;
private int rewardStatus;
private int sendRedNum;
private int drawDownNum;
}
private String hasNext;
}
package com.kjj.bean.answer;
import lombok.Data;
import java.util.List;
@Data
public class RewardDetail {
private String quesConfId;
private String quesType;
private RedDetail redDetail;
@Data
public static class RedDetail{
private String redConfId;
private int showAmount;
}
private String welfareDetail;
private int quesRewardSeconds;
private String quesRewardEndTime;
private int rewardStatus;
private String quesId;
private String questionDetail;
private List<QuestionLists> questionList;
@Data
public static class QuestionLists{
private String id;
private int optionType;
private String optionDetail;
}
}
package com.kjj.bean.answer;
import lombok.Data;
import java.util.List;
@Data
public class RewardGetDetail {
private String quesConfId;
private String quesType;
private String welfareDetail;
private RedDetail redDetail;
@Data
public static class RedDetail
{
private String redConfId;
private int showAmount;
private int totalAmount;
private int totalNum;
}
private QuestionConf questionConf;
@Data
public static class QuestionConf
{
private String id;
private String questionDetail;
private List<OptionList> optionList;
}
@Data
public static class OptionList
{
private String id;
private String optionDetail;
private int optionType;
}
}
package com.kjj.bean.answer;
import lombok.Data;
@Data
public class WelfareDetail {
private String rewardId;
private String rewardNum;
}
package com.kjj.cases.live;
import com.alibaba.fastjson.JSON;
import com.kjj.bean.answer.*;
import com.kjj.config.BasicConfig;
import com.kjj.constants.LiveConstants;
import com.kjj.utils.JsonUtil;
import io.restassured.response.Response;
import org.testng.Assert;
import org.testng.annotations.Test;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class QuestionAwards implements AdminAuthorization{
public String confId_ques;
public String wronganswer;
public String rightanswer;
private QuseRewardList.QuesList getRed(List<QuseRewardList.QuesList> lists){
for (QuseRewardList.QuesList ques : lists) {
if (ques.getRewardStatus()==0){
return ques;
}
}
return null;
}
private RewardDetail.QuestionLists getwrongques(List<RewardDetail.QuestionLists> list){
for (RewardDetail.QuestionLists ques1 : list) {
if (ques1.getOptionType()==2){
return ques1;
}
}
return null;
}
private RewardDetail.QuestionLists getrightques(List<RewardDetail.QuestionLists> list){
for (RewardDetail.QuestionLists ques1 : list) {
if (ques1.getOptionType()==1){
return ques1;
}
}
return null;
}
/*主播端添加有奖答题-现金红包*/
@Test(description = "主播端添加有奖答题现金红包", priority = 1)
public void 主播端添加有奖答题现金红包()
{
adminAuth();
Map<String, Object> params = new HashMap<>();
params.put("quesType","1");
AddAnswer RedDetail = new AddAnswer();
RedDetail.setTotalAmount(100);
RedDetail.setShowAmount(100);
RedDetail.setTotalNum(3);
params.put("redDetail",RedDetail);
QuesConf quesConf=new QuesConf();
quesConf.setQuestionDetail("问题");
List<Option> optionlist=new ArrayList<>();
quesConf.setOptionList(optionlist);
Option option1=new Option();
option1.setOptionDetail("正确");
option1.setOptionType(1);
option1.setAnswerLen(2);
optionlist.add(option1);
Option option2=new Option();
option2.setOptionDetail("错误");
option2.setOptionType(2);
option2.setAnswerLen(2);
optionlist.add(option2);
params.put("questionConf",quesConf);
params.put("confId","");
params.put("liveId", LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
System.out.println("params = "+JSON.toJSONString(params));
Response response = network.postResponse(params, BasicConfig.MOBILE_QuesSaveOrUpdate);
Object data = response.jsonPath().getJsonObject("data");
System.out.println(JSON.toJSONString(data));
Assert.assertNotNull(data, network.message(params, BasicConfig.MOBILE_QuesSaveOrUpdate, "主播端添加有奖答题现金红包失败", response.body().asString()));
}
/*主播端添加有奖答题-奖品奖励*/
@Test(description = "主播端添加有奖答题奖品奖励", priority = 2)
public void 主播端添加有奖答题奖品奖励()
{
adminAuth();
Map<String, Object> params = new HashMap<>();
params.put("quesType","2");
WelfareDetail welfareDetail = new WelfareDetail();
welfareDetail.setRewardId("Kj22MTU0Mw");
welfareDetail.setRewardNum("2");
params.put("welfareDetail",welfareDetail);
QuesConf quesConf=new QuesConf();
quesConf.setQuestionDetail("盲盒锦鲤奖品");
List<Option> optionlist=new ArrayList<>();
quesConf.setOptionList(optionlist);
Option option1=new Option();
option1.setOptionDetail("正确");
option1.setOptionType(1);
option1.setAnswerLen(2);
optionlist.add(option1);
Option option2=new Option();
option2.setOptionDetail("错误1");
option2.setOptionType(2);
option2.setAnswerLen(3);
optionlist.add(option2);
params.put("questionConf",quesConf);
params.put("confId","");
params.put("liveId",LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
System.out.println("params = "+JSON.toJSONString(params));
Response response = network.postResponse(params, BasicConfig.MOBILE_QuesSaveOrUpdate);
Object data = response.jsonPath().getJsonObject("data");
System.out.println(JSON.toJSONString(data));
Assert.assertNotNull(data, network.message(params, BasicConfig.MOBILE_QuesSaveOrUpdate, "主播端添加有奖答题现金红包失败", response.body().asString()));
}
/*查询主播端有奖答题列表*/
@Test(description = "查询主播端有奖答题列表", priority = 3)
public void 主播端有奖答题列表()
{
adminAuth();
Map<String, Object> params = new HashMap<>();
params.put("liveId", LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
params.put("pageIndex", 1);
params.put("pageSize", 50);
Response response = network.getResponse(params, BasicConfig.MOBILE_QuesRewardList);
QuseRewardList Beans=JsonUtil.parseResponseToBean(response, QuseRewardList.class);
QuseRewardList.QuesList notPublishQues=getRed(Beans.getList());
confId_ques=notPublishQues.getQuesConfId();
System.out.println(JSON.toJSONString(Beans));
Assert.assertNotNull(Beans, network.message(params, BasicConfig.MOBILE_QuesRewardList, "查询主播端有奖答题列表失败", response.body().asString()));
}
/*查询主播端未上架的有奖答题配置详情*/
@Test(description = "查询主播端有奖答题配置详情", priority = 4)
public void 查询主播端有奖答题配置详情()
{
adminAuth();
Map<String, Object> params = new HashMap<>();
params.put("liveId",LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
params.put("confId",confId_ques);
Response response = network.getResponse(params, BasicConfig.MOBILE_QuesRewardGetDetail);
RewardGetDetail Beans=JsonUtil.parseResponseToBean(response, RewardGetDetail.class);
System.out.println(JSON.toJSONString(Beans));
Assert.assertNotNull(Beans, network.message(params, BasicConfig.MOBILE_QuesRewardGetDetail, "查询主播端有奖答题配置失败", response.body().asString()));
}
/*上架主播端未发放的有奖答题*/
@Test(description = "上架有奖答题查询", priority = 5)
public void 上架有奖答题()
{
adminAuth();
Map<String, Object> params = new HashMap<>();
params.put("liveId",LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
params.put("confId",confId_ques);
Response response = network.postResponse(params, BasicConfig.MOBILE_QuesRewardUp);
boolean data = response.jsonPath().getBoolean("success");
System.out.println(JSON.toJSONString(data));
Assert.assertNotNull(data, network.message(params, BasicConfig.MOBILE_QuesRewardUp, "上架答题红包失败", response.body().asString()));
}
/*主播端发放答题红包*/
@Test(description = "主播端发放普通红包", priority = 6)
public void 主播端发放普通红包()
{
adminAuth();
Map<String, Object> params = new HashMap<>();
params.put("liveId",LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
params.put("confId",confId_ques);
Response response = network.postResponse(params, BasicConfig.MOBILE_QuesRewardStart);
boolean data = response.jsonPath().getBoolean("data");
System.out.println(JSON.toJSONString(data));
Assert.assertNotNull(data, network.message(params, BasicConfig.MOBILE_QuesRewardStart, "发放答题红包失败", response.body().asString()));
}
//访客端
/*查询访客端有奖答题配置详情*/
@Test(description = "查询访客端有奖答题配置详情", priority = 7)
public void 查询访客端有奖答题配置详情()
{
visitorAuth();
Map<String, Object> params = new HashMap<>();
params.put("liveId", LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
Response response = network.getResponse(params, BasicConfig.MOBILE_QuesDetail);
RewardDetail Beans=JsonUtil.parseResponseToBean(response, RewardDetail.class);
RewardDetail.QuestionLists WrongAnswer=getwrongques(Beans.getQuestionList());
wronganswer=WrongAnswer.getId();
RewardDetail.QuestionLists RightAnswer=getrightques(Beans.getQuestionList());
rightanswer =RightAnswer.getId();
System.out.println(JSON.toJSONString(Beans));
Assert.assertNotNull(Beans, network.message(params, BasicConfig.MOBILE_QuesDetail, "查询访客端有奖答题配置详情失败", response.body().asString()));
}
/*领取答题红包-错误选项*/
@Test(description = "领取答题红包-错误选项", priority = 8)
public void 领取答题红包()
{
visitorAuth2();
Map<String, Object> params = new HashMap<>();
params.put("liveId", LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
params.put("quesConfId", confId_ques);
params.put("optionId", wronganswer);
Response response = network.postResponse(params, BasicConfig.MOBILE_QuesParticipate);
AnswerQues Beans=JsonUtil.parseResponseToBean(response, AnswerQues.class);
System.out.println(JSON.toJSONString(Beans));
Assert.assertNotNull(Beans, network.message(params, BasicConfig.MOBILE_QuesParticipate, "领取答题红包失败", response.body().asString()));
}
/*领取答题红包-选择正确选项*/
@Test(description = "领取答题红包-答题正确", priority = 9)
public void 领取答题红包成功()
{
visitorAuth();
Map<String, Object> params = new HashMap<>();
params.put("liveId", LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
params.put("quesConfId", confId_ques);
params.put("optionId", rightanswer);
Response response = network.postResponse(params, BasicConfig.MOBILE_QuesParticipate);
AnswerQues Beans=JsonUtil.parseResponseToBean(response, AnswerQues.class);
System.out.println(JSON.toJSONString(Beans));
Assert.assertNotNull(Beans, network.message(params, BasicConfig.MOBILE_QuesParticipate, "领取答题红包失败", response.body().asString()));
}
/*代理人领取答题红包*/
@Test(description = "代理人领取答题红包", priority = 10)
public void 代理人领取答题红包()
{
agentAuth();
Map<String, Object> params = new HashMap<>();
params.put("liveId", LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
params.put("quesConfId",confId_ques );
params.put("optionId", rightanswer);
Response response = network.postResponse(params, BasicConfig.MOBILE_QuesParticipate);
AnswerQues Beans=JsonUtil.parseResponseToBean(response, AnswerQues.class);
System.out.println(JSON.toJSONString(Beans));
Assert.assertNotNull(Beans, network.message(params, BasicConfig.MOBILE_QuesParticipate, "领取答题红包失败", response.body().asString()));
}
/*领取答题红包结果*/
@Test(description = "领取答题红包结果", priority = 11)
public void 领取答题红包结果()
{
visitorAuth();
Map<String, Object> params = new HashMap<>();
params.put("liveId", LiveConstants.getValue(LiveConstants.StringKeyEnum.ENCODE_LIVE_ID.getKey()));
params.put("quesConfId",confId_ques );
Response response = network.getResponse(params, BasicConfig.MOBILE_QuesParticipateInfo);
ParticipateInfo Beans=JsonUtil.parseResponseToBean(response, ParticipateInfo.class);
System.out.println(JSON.toJSONString(Beans));
Assert.assertNotNull(Beans, network.message(params, BasicConfig.MOBILE_QuesParticipateInfo, "查询答题红包结果失败", response.body().asString()));
}
}
...@@ -138,7 +138,6 @@ public class BasicConfig { ...@@ -138,7 +138,6 @@ public class BasicConfig {
public static final String MOBILE_RedStart = MOBILE_HOST + "/conf/live/red/start"; 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_RedGetSimple = MOBILE_HOST + "/conf/live/red/getSimple";
public static final String MOBILE_RedSaveOrUpdate = MOBILE_HOST + "/conf/live/red/saveOrUpdate"; public static final String MOBILE_RedSaveOrUpdate = MOBILE_HOST + "/conf/live/red/saveOrUpdate";
public static final String MOBILE_QuesSaveOrUpdate = MOBILE_HOST + "/conf/live/ques/reward/saveOrUpdate";
public static final String MOBILE_FindRedList = MOBILE_HOST + "/clue/red/findRedList"; public static final String MOBILE_FindRedList = MOBILE_HOST + "/clue/red/findRedList";
public static final String MOBILE_RedFindSimpleDetail = MOBILE_HOST + "/clue/red/findSimpleDetail"; 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_RedHelpDetail = MOBILE_HOST + "/kjy/live/user/red/help/detail";
...@@ -152,8 +151,15 @@ public class BasicConfig { ...@@ -152,8 +151,15 @@ public class BasicConfig {
public static final String MOBILE_RedGetShareSign= MOBILE_HOST + "/kjy/live/getShareSign"; 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_RedLuckResult = MOBILE_HOST + "/clue/red/luckResultList";
public static final String MOBILE_RedLuckHelp = MOBILE_HOST + "/kjy/live/user/red/help"; public static final String MOBILE_RedLuckHelp = MOBILE_HOST + "/kjy/live/user/red/help";
public static final String MOBILE_QuesRewardList = MOBILE_HOST + "/conf/live/ques/reward/list";
public static final String MOBILE_OpenState = MOBILE_HOST + "/clue/red/open/state"; 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";
public static final String MOBILE_QuesRewardUp = MOBILE_HOST + "/conf/live/ques/reward/up";
public static final String MOBILE_QuesRewardStart = MOBILE_HOST + "/conf/live/ques/reward/start";
public static final String MOBILE_QuesRewardGetDetail = MOBILE_HOST + "/conf/live/ques/reward/getDetail";
public static final String MOBILE_QuesDetail = MOBILE_HOST + "/clue/ques/reward/detail";
public static final String MOBILE_QuesParticipate = MOBILE_HOST + "/clue/ques/reward/participate";
public static final String MOBILE_QuesParticipateInfo = MOBILE_HOST + "/clue/ques/reward/participateInfo";
......
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
</classes> </classes>
</test> </test>
<test preserve-order="true" name="访客券码领取"> <test preserve-order="true" name="访客券码领取">
<classes> <classes>
<class name="com.kjj.cases.live.User"/> <class name="com.kjj.cases.live.User"/>
...@@ -64,6 +63,11 @@ ...@@ -64,6 +63,11 @@
<class name="com.kjj.cases.live.LiveVistorRed"/> <class name="com.kjj.cases.live.LiveVistorRed"/>
</classes> </classes>
</test> </test>
<test preserve-order="true" name="有奖答题">
<classes>
<class name="com.kjj.cases.live.QuestionAwards"/>
</classes>
</test>
<test preserve-order="true" name="助播-结束直播"> <test preserve-order="true" name="助播-结束直播">
<classes> <classes>
<class name="com.kjj.cases.live.CloseLive"/> <class name="com.kjj.cases.live.CloseLive"/>
......
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