Commit 1e7f8a1b authored by qwj-github's avatar qwj-github

add

parent 98401528
/**
* Copyright (C), 2015-2018
* FileName: pk_瓜分红包_首页中奖弹层测试
* Author: qianwenjun
* Date: 2018/12/22 12:38
* Description:
*/
package http.cases.PkTest;
import base.DuibaLog;
import base.DuibaTestBase;
import com.alibaba.fastjson.JSONObject;
import http.model.PkPopPrizeVo;
import http.service.Activity.PkService;
import http.service.Manager.PkActivityService;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.Test;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* 〈〉
*
* @author qianwenjun
* @create 2018/12/22
* @since 1.0.0
*/
public class pk_瓜分红包_发券测试 extends DuibaTestBase {
@Autowired
PkService pkService;
@Autowired
PkActivityService pkActivityService;
private static DuibaLog logger = DuibaLog.getLogger();
private Integer user01 = 5447;//appid=21982
private Integer user02 = 5448;//appid=21982
// private Integer user03 = 5449;//appid=21982
//
// private Integer user04 = 5450;//appid=21982
List<String> newBetIds = new ArrayList<>();
@Test(priority = 0)
public void 瓜分红包_首页不中奖_发券() throws Exception{
String newBetId = "";
List<String> optionsIds = new ArrayList<>();
String groupId = "199";
newBetId = createPk("2","2020-08-12 00:00:00",groupId);
newBetIds.add(newBetId);
List<Map<String,Object>> pks = jdbc.findModeResult("select * from act_com_conf.tb_bet_option where bet_id = ?",newBetId);
logger.info("pk活动信息为"+JSONObject.toJSONString(pks));
for (int i=0;i<pks.size();i++){
optionsIds.add(pks.get(i).get("id").toString());
}
logger.info("pk活动id为:"+newBetId+",选项id为:"+ optionsIds.toString());
Response res1 = pkService.doJoin(user01,newBetId,optionsIds.get(0));
Response res2 = pkService.doJoin(user02,newBetId,optionsIds.get(1));
this.modifyOpenPrizeTime(newBetId,60);
//调用开奖接口
Response doDrowRresponse = pkActivityService.doDraw();
Assert.assertEquals(doDrowRresponse.jsonPath().getString("success"),"true","开奖结果校验失败");
Assert.assertEquals(doDrowRresponse.jsonPath().getString("data"),"开奖中。。。","开奖messag校验失败");
Thread.sleep(8000);
Response popRes = pkService.popup(user02);
popRes.prettyPrint();
Assert.assertEquals(popRes.jsonPath().getString("data.show"),"false","校验是否展示弹层失败");
Assert.assertEquals(popRes.jsonPath().getString("data.totalBonus"),"0.0","校验红包值失败");
Assert.assertEquals(popRes.jsonPath().getString("data.drawType"),"0","校验开奖类型失败");
Assert.assertEquals(popRes.jsonPath().getString("data.lucky"),"true","校验不发福袋失败失败");
Assert.assertEquals(popRes.jsonPath().getString("data.prizeList"),null,"校验中奖list为null");
Response popRes1 = pkService.popup(user01);
popRes1.prettyPrint();
Assert.assertEquals(popRes1.jsonPath().getString("data.show"),"true","校验是否展示弹层失败");
Assert.assertEquals(popRes1.jsonPath().getString("data.totalBonus"),"0.1","校验红包值失败");
Assert.assertEquals(popRes1.jsonPath().getString("data.drawType"),"0","校验开奖类型失败");
Assert.assertEquals(popRes1.jsonPath().getString("data.lucky"),"false","校验不发福袋失败失败");
List<PkPopPrizeVo> prizeVoList = popRes.jsonPath().getList("data.prizeList",PkPopPrizeVo.class);
logger.info("开奖结果的list为:"+JSONObject.toJSONString(prizeVoList));
for (PkPopPrizeVo prize:prizeVoList){
if (prize.getBonusType().equals("2")){
Assert.assertEquals(prize.getTotalBonus(),"10","校验list的瓜分红包金额失败");
}
}
}
public String createPk(String bounsType,String endTime,String groupId) throws Exception {
Response betResponse = pkActivityService.betForSetUp(bounsType,endTime);
logger.info("新建pk活动的结果信息为"+ JSONObject.toJSONString(betResponse.prettyPrint()));
betResponse.prettyPrint();
String betId = betResponse.jsonPath().getString("data");
logger.info("newBetId的信息为"+betId);
Response betRelation = pkActivityService.betGroupRelation(betId,endTime,groupId);
Response modifyStatusResponse = pkActivityService.modifySatus(betId);
return betId;
}
public void modifyOpenPrizeTime(String betId,int x) throws Exception{
String endTimeStr = "2018-11-26 20:24:39";
Boolean result1 = jdbc.update("update act_com_conf.tb_bet_config set end_time = ? where id = ?\n",endTimeStr,betId);
Boolean result2 = jdbc.update("update act_com_conf.tb_bet_group_relation set end_time = ? where bet_id = ?\n",endTimeStr,betId);
}
@AfterClass
public void tearDown() {
try {
for (String newBetId:newBetIds){
Boolean result1 = jdbc.update("delete from act_com_conf.tb_bet_option where bet_id = ?",newBetId);
Boolean result4 = jdbc.update("delete from act_record.tb_bet_record where bet_id = ?",newBetId);
Boolean result5 = jdbc.update("delete from bet_activity.tb_bet_result where bet_id = ?",newBetId);
Boolean result2 = jdbc.update("delete from act_com_conf.tb_bet_group_relation where bet_id = ?",newBetId);
Boolean result3 = jdbc.update("delete from act_com_conf.tb_bet_config where id = ?",newBetId);
}
} catch (SQLException e) {
e.printStackTrace();
} catch (Exception e){
e.printStackTrace();
}
}
}
\ No newline at end of file
......@@ -46,33 +46,29 @@ public class pk_瓜分红包_首页中奖弹层测试 extends DuibaTestBase {
private static DuibaLog logger = DuibaLog.getLogger();
private String newBetId = "";
private List<String> optionsIds = new ArrayList<>();
//146-pk测试3,pk测试4
private String groupId = "194";
private Integer user01 = 5434;//appid=21982
private String consumerId01 = "100122071";
private Integer user02 = 5435;//appid=21982
private String consumerId02 = "100122072";
@BeforeMethod
//注意初始化的方法不能与父类的相同,会被覆盖住
public void setUpPkActivity() {
private Integer user03 = 5449;//appid=21982
try {
createPk("2","2020-08-12 00:00:00",groupId);
}catch (Exception e){
e.printStackTrace();
}
private Integer user04 = 5450;//appid=21982
}
List<String> newBetIds = new ArrayList<>();
@Test
@Test(priority = 0)
public void 瓜分红包_首页中奖() throws Exception{
String newBetId = "";
List<String> optionsIds = new ArrayList<>();
String groupId = "194";
newBetId = createPk("2","2020-08-12 00:00:00",groupId);
newBetIds.add(newBetId);
List<Map<String,Object>> pks = jdbc.findModeResult("select * from act_com_conf.tb_bet_option where bet_id = ?",newBetId);
logger.info("pk活动信息为"+JSONObject.toJSONString(pks));
......@@ -80,7 +76,7 @@ public class pk_瓜分红包_首页中奖弹层测试 extends DuibaTestBase {
optionsIds.add(pks.get(i).get("id").toString());
}
logger.info("pk活动id为:"+newBetId+",选项id为:"+ optionsIds.toString());
Response res1 = pkService.doJoin(user01,newBetId,optionsIds.get(0));
Response res1 = pkService.doJoin(user03,newBetId,optionsIds.get(0));
this.modifyOpenPrizeTime(newBetId,60);
......@@ -91,7 +87,7 @@ public class pk_瓜分红包_首页中奖弹层测试 extends DuibaTestBase {
Thread.sleep(8000);
Response popRes = pkService.popup(user01);
Response popRes = pkService.popup(user03);
popRes.prettyPrint();
Assert.assertEquals(popRes.jsonPath().getString("data.show"),"true","校验是否展示弹层失败");
Assert.assertEquals(popRes.jsonPath().getString("data.totalBonus"),"0.1","校验是否展示弹层失败");
......@@ -109,8 +105,15 @@ public class pk_瓜分红包_首页中奖弹层测试 extends DuibaTestBase {
}
@Test
@Test(priority = 2)
public void 瓜分红包_首页不中奖() throws Exception{
String newBetId = "";
List<String> optionsIds = new ArrayList<>();
String groupId = "194";
newBetId = createPk("2","2020-08-12 00:00:00",groupId);
newBetIds.add(newBetId);
List<Map<String,Object>> pks = jdbc.findModeResult("select * from act_com_conf.tb_bet_option where bet_id = ?",newBetId);
logger.info("pk活动信息为"+JSONObject.toJSONString(pks));
......@@ -138,24 +141,64 @@ public class pk_瓜分红包_首页中奖弹层测试 extends DuibaTestBase {
Assert.assertEquals(popRes.jsonPath().getString("data.drawType"),"0","校验开奖类型失败");
Assert.assertEquals(popRes.jsonPath().getString("data.lucky"),"false","校验不发福袋失败失败");
// List<PkPopPrizeVo> prizeVoList = popRes.jsonPath().getList("data.prizeList",PkPopPrizeVo.class);
// logger.info("开奖结果的list为:"+JSONObject.toJSONString(prizeVoList));
Assert.assertEquals(popRes.jsonPath().getString("data.prizeList"),null,"校验中奖list为null");
}
@Test(priority = 1)
public void 瓜分红包_首页中_多次中奖() throws Exception{
for (int i=0;i<3;i++){
String newBetId = "";
List<String> optionsIds = new ArrayList<>();
String groupId = "194";
newBetId = createPk("2","2020-08-12 00:00:00",groupId);
newBetIds.add(newBetId);
List<Map<String,Object>> pks = jdbc.findModeResult("select * from act_com_conf.tb_bet_option where bet_id = ?",newBetId);
logger.info("pk活动信息为"+JSONObject.toJSONString(pks));
for (int j=0;j<pks.size();j++){
optionsIds.add(pks.get(j).get("id").toString());
}
logger.info("pk活动id为:"+newBetId+",选项id为:"+ optionsIds.toString());
Response res1 = pkService.doJoin(user04,newBetId,optionsIds.get(0));
this.modifyOpenPrizeTime(newBetId,60);
}
//调用开奖接口
Response doDrowRresponse = pkActivityService.doDraw();
Assert.assertEquals(doDrowRresponse.jsonPath().getString("success"),"true","开奖结果校验失败");
Assert.assertEquals(doDrowRresponse.jsonPath().getString("data"),"开奖中。。。","开奖messag校验失败");
Thread.sleep(8000);
Response popRes = pkService.popup(user04);
popRes.prettyPrint();
Assert.assertEquals(popRes.jsonPath().getString("data.show"),"true","校验是否展示弹层失败");
Assert.assertEquals(popRes.jsonPath().getString("data.totalBonus"),"0.3","校验是否展示弹层失败");
Assert.assertEquals(popRes.jsonPath().getString("data.drawType"),"0","校验开奖类型失败");
Assert.assertEquals(popRes.jsonPath().getString("data.lucky"),"false","校验不发福袋失败失败");
public void createPk(String bounsType,String endTime,String groupId) throws Exception {
List<PkPopPrizeVo> prizeVoList = popRes.jsonPath().getList("data.prizeList",PkPopPrizeVo.class);
logger.info("开奖结果的list为:"+JSONObject.toJSONString(prizeVoList));
for (PkPopPrizeVo prize:prizeVoList){
if (prize.getBonusType().equals("2")){
Assert.assertEquals(prize.getTotalBonus(),"30","校验list的瓜分红包金额失败");
}
}
}
public String createPk(String bounsType,String endTime,String groupId) throws Exception {
Response betResponse = pkActivityService.betForSetUp(bounsType,endTime);
logger.info("新建pk活动的结果信息为"+ JSONObject.toJSONString(betResponse.prettyPrint()));
betResponse.prettyPrint();
String betId = betResponse.jsonPath().getString("data");newBetId = betId;
logger.info("newBetId的信息为"+newBetId);
String betId = betResponse.jsonPath().getString("data");
logger.info("newBetId的信息为"+betId);
Response betRelation = pkActivityService.betGroupRelation(betId,endTime,groupId);
Response modifyStatusResponse = pkActivityService.modifySatus(betId);
return betId;
}
public void modifyOpenPrizeTime(String betId,int x) throws Exception{
......@@ -171,7 +214,7 @@ public class pk_瓜分红包_首页中奖弹层测试 extends DuibaTestBase {
public void tearDown() {
try {
for (String newBetId:newBetIds){
Boolean result1 = jdbc.update("delete from act_com_conf.tb_bet_option where bet_id = ?",newBetId);
Boolean result4 = jdbc.update("delete from act_record.tb_bet_record where bet_id = ?",newBetId);
Boolean result5 = jdbc.update("delete from bet_activity.tb_bet_result where bet_id = ?",newBetId);
......@@ -179,6 +222,8 @@ public class pk_瓜分红包_首页中奖弹层测试 extends DuibaTestBase {
Boolean result3 = jdbc.update("delete from act_com_conf.tb_bet_config where id = ?",newBetId);
}
} catch (SQLException e) {
e.printStackTrace();
} catch (Exception e){
......
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