Commit 98401528 authored by qwj-github's avatar qwj-github

add

parent 75e1af1d
/**
* 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.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeMethod;
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 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() {
try {
createPk("2","2020-08-12 00:00:00",groupId);
}catch (Exception e){
e.printStackTrace();
}
}
@Test
public void 瓜分红包_首页中奖() throws Exception{
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));
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(user01);
popRes.prettyPrint();
Assert.assertEquals(popRes.jsonPath().getString("data.show"),"true","校验是否展示弹层失败");
Assert.assertEquals(popRes.jsonPath().getString("data.totalBonus"),"0.1","校验是否展示弹层失败");
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));
for (PkPopPrizeVo prize:prizeVoList){
if (prize.getBonusType().equals("2")){
Assert.assertEquals(prize.getTotalBonus(),"10","校验list的瓜分红包金额失败");
}
}
}
@Test
public void 瓜分红包_首页不中奖() throws Exception{
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"),"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");
}
public void 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);
Response betRelation = pkActivityService.betGroupRelation(betId,endTime,groupId);
Response modifyStatusResponse = pkActivityService.modifySatus(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 {
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
/**
* Copyright (C), 2015-2018
* FileName: PkPopPrizeVo
* Author: qianwenjun
* Date: 2018/12/22 14:07
* Description:
*/
package http.model;
import lombok.Getter;
import lombok.Setter;
/**
* 〈〉
*
* @author qianwenjun
* @create 2018/12/22
* @since 1.0.0
*/
@Getter
@Setter
public class PkPopPrizeVo {
private String bonusType;
private String pluginId;
private String title;
private String totalBonus;
}
\ No newline at end of file
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