Commit a9aca101 authored by 钱雯君's avatar 钱雯君

add

parent 297dc0eb
......@@ -201,7 +201,12 @@
<artifactId>lombok</artifactId>
<version>1.16.18</version>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.9.9</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
......
/**
* Copyright (C), 2015-2018
* FileName: 新集卡_助力发集卡_DuibaTest
* Author: qianwenjun
* Date: 2018/10/27 15:01
* Description:
*/
package http.cases.NewCollectActivityTest;
import base.DuibaLog;
import base.DuibaTestBase;
import com.alibaba.fastjson.JSON;
import http.model.CollectGoodsInfo;
import http.service.Activity.NewCollectActivityService;
import http.service.Manager.EditManagerInfoService;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.Test;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static io.restassured.RestAssured.given;
/**
* 〈〉
*
* @author qianwenjun
* @create 2018/10/27
* @since 1.0.0
*/
public class 新集卡_助力发集卡_DuibaTest extends DuibaTestBase {
@Autowired
NewCollectActivityService newCollectActivityService;
@Autowired
EditManagerInfoService editManagerInfoService;
private static DuibaLog logger = DuibaLog.getLogger();
@Test
public void 助力_发集卡() throws Exception{
//助力规则
int userId = 3934;
String consumerId = "100092114";
String collectRuleId = "4795";
String collectHelpRuleId = "1594";
String activityId = "34662";
String activityType = "hdtool";
String cardDb = "collect_card_consumer.tb_collect_card_info_0210";
String itemId = "31628";
Map<String,String> user = new HashMap<>();
user = this.createUser("57","2239");
//数据库查询用户卡片的数量
String selectSql = "select * from " +cardDb+" where consumer_id = '" + consumerId + "' and item_id = '" +itemId+ "'";
logger.info("查询集卡信息的sql为:"+selectSql);
Map<String,Object> cardDbInfo = jdbc.findSimpleResult(selectSql);
String item_count = cardDbInfo.get("item_count").toString();
logger.info("cardDbInfo的信息为"+cardDbInfo+",itemId="+itemId+"的数量为:"+item_count);
checkGetCollectInfo(collectRuleId,itemId,item_count,userId,"我的集卡信息为:");
Response getShareResponse = newCollectActivityService.getShareCode(activityId,activityType,userId);
getShareResponse.prettyPrint();
String shareCode = getShareResponse.jsonPath().getString("shareCode");
logger.info("我的邀请码为:"+shareCode);
Response helpResponse = newCollectActivityService.helpShareCodeV2(collectHelpRuleId,activityId,activityType,shareCode,Integer.valueOf(user.get("uid")));
helpResponse.prettyPrint();
Thread.sleep(3000);
Map<String,Object> afterCardDbInfo = jdbc.findSimpleResult(selectSql);
Integer after_item_count = Integer.valueOf(afterCardDbInfo.get("item_count").toString());
logger.info("助力后,cardDbInfo的信息为"+afterCardDbInfo+",itemId="+itemId+"的数量为:"+after_item_count);
checkGetCollectInfo(collectRuleId,itemId,String.valueOf(after_item_count),userId,"助力之后,我的集卡信息为:");
Assert.assertEquals(item_count,String.valueOf(after_item_count-1),"集卡数量校验失败");
this.clear(user.get("uid"),user.get("consumerId"));
}
@Test
public void 邀请码助力_发集卡() throws Exception{
//邀请码规则
int userId = 3935;
String consumerId = "100092115";
String collectRuleId = "4796";
String collectHelpRuleId = "1595";
String activityId = "34663";
String activityType = "hdtool";
String cardDb = "collect_card_consumer.tb_collect_card_info_0211";
String itemId = "31630";
Map<String,String> user = new HashMap<>();
user = this.createUser("57","2239");
String helpUserCardDb = this.getDbName("collect_card_consumer.tb_collect_card_info",user.get("consumerId"));
String selectSql = "select * from " +cardDb+" where consumer_id = '" + consumerId + "' and item_id = '" +itemId+ "'";
logger.info("查询集卡信息的sql为:"+selectSql);
Map<String,Object> cardDbInfo = jdbc.findSimpleResult(selectSql);
String item_count = cardDbInfo.get("item_count").toString();
logger.info("cardDbInfo的信息为"+cardDbInfo+",itemId="+itemId+"的数量为:"+item_count);
checkGetCollectInfo(collectRuleId,itemId,item_count,userId,"我的集卡信息为:");
//助力用户的集卡信息
String selectSql1 = "select * from " +helpUserCardDb+" where consumer_id = '" + user.get("consumerId") + "' and item_id = '" +itemId+ "'";
logger.info("助力用户查询集卡信息的sql为:"+selectSql1);
Map<String,Object> cardDbInfo1 = jdbc.findSimpleResult(selectSql1);
Assert.assertEquals(cardDbInfo1.size(),0,"助力用户的卡片数量为0失败");
checkGetCollectInfo(collectRuleId,itemId,"0",Integer.valueOf(user.get("uid")),"助力用户的集卡信息为:");
Response getShareResponse = newCollectActivityService.getShareCode(activityId,activityType,userId);
getShareResponse.prettyPrint();
String shareCode = getShareResponse.jsonPath().getString("shareCode");
logger.info("我的邀请码为:"+shareCode);
Response response = newCollectActivityService.doHelpNew(activityId,activityType,shareCode,Integer.valueOf(user.get("uid")));
response.prettyPrint();
String inviterBizId = response.jsonPath().getString("data.inviterBizId");
String inviteeBizId = response.jsonPath().getString("data.inviteeBizId");
Response helpResult1 = newCollectActivityService.inviteBonusRecord(inviterBizId,Integer.valueOf(user.get("uid")));
helpResult1.prettyPrint();
Response helpResult2 = newCollectActivityService.inviteBonusRecord(inviteeBizId,Integer.valueOf(user.get("uid")));
helpResult2.prettyPrint();
Thread.sleep(3000);
Map<String,Object> afterCardDbInfo = jdbc.findSimpleResult(selectSql);
Integer after_item_count = Integer.valueOf(afterCardDbInfo.get("item_count").toString());
logger.info("助力后,afterCardDbInfo的信息为"+afterCardDbInfo+",itemId="+itemId+"的数量为:"+after_item_count);
checkGetCollectInfo(collectRuleId,itemId,String.valueOf(after_item_count),userId,"助力之后,我的集卡信息为:");
Map<String,Object> afterCardDbInfo1 = jdbc.findSimpleResult(selectSql1);
Integer after_item_count1 = Integer.valueOf(afterCardDbInfo1.get("item_count").toString());
logger.info("助力后,afterCardDbInfo1的信息为"+afterCardDbInfo1+",itemId="+itemId+"的数量为:"+after_item_count1);
Assert.assertEquals(afterCardDbInfo1.get("item_count").toString(),"1","助力用户助力之后的卡片数量为1失败");
checkGetCollectInfo(collectRuleId,itemId,String.valueOf(after_item_count1),Integer.valueOf(user.get("uid")),"助力之后,助力用户的集卡信息为:");
Assert.assertEquals(item_count,String.valueOf(after_item_count-1),"集卡数量校验失败");
this.clear(user.get("uid"),user.get("consumerId"));
}
@Test
public void 邀请码发卡_达到限制() throws Exception{
int userId = 3975;
String consumerId = "100092169";
String collectRuleId = "4803";
String collectHelpRuleId = "1598";
String activityId = "34697";
String activityType = "hdtool";
String cardDb = "collect_card_consumer.tb_collect_card_info_0265";
String itemId = "31638";
Map<String,String> user = new HashMap<>();
user = this.createUser("57","2239");
String helpUserCardDb = this.getDbName("collect_card_consumer.tb_collect_card_info",user.get("consumerId"));
String selectSql = "select * from " +cardDb+" where consumer_id = '" + consumerId + "' and item_id = '" +itemId+ "'";
logger.info("查询集卡信息的sql为:"+selectSql);
Map<String,Object> cardDbInfo = jdbc.findSimpleResult(selectSql);
String item_count = cardDbInfo.get("item_count").toString();
logger.info("cardDbInfo的信息为"+cardDbInfo+",itemId="+itemId+"的数量为:"+item_count);
checkGetCollectInfo(collectRuleId,itemId,item_count,userId,"我的集卡信息为:");
//助力用户的集卡信息
String selectSql1 = "select * from " +helpUserCardDb+" where consumer_id = '" + user.get("consumerId") + "' and item_id = '" +itemId+ "'";
logger.info("助力用户查询集卡信息的sql为:"+selectSql1);
Map<String,Object> cardDbInfo1 = jdbc.findSimpleResult(selectSql1);
Assert.assertEquals(cardDbInfo1.size(),0,"助力用户的卡片数量为0失败");
checkGetCollectInfo(collectRuleId,itemId,"0",Integer.valueOf(user.get("uid")),"助力用户的集卡信息为:");
Response getShareResponse = newCollectActivityService.getShareCode(activityId,activityType,userId);
getShareResponse.prettyPrint();
String shareCode = getShareResponse.jsonPath().getString("shareCode");
logger.info("我的邀请码为:"+shareCode);
Response response = newCollectActivityService.doHelpNew(activityId,activityType,shareCode,Integer.valueOf(user.get("uid")));
response.prettyPrint();
String inviterBizId = response.jsonPath().getString("data.inviterBizId");
String inviteeBizId = response.jsonPath().getString("data.inviteeBizId");
Response helpResult1 = newCollectActivityService.inviteBonusRecord(inviterBizId,Integer.valueOf(user.get("uid")));
helpResult1.prettyPrint();
int i=8;
while (i>0&&(helpResult1.jsonPath().getString("data.recordStatus").equals("0"))){
Thread.sleep(1000);
helpResult1 = newCollectActivityService.inviteBonusRecord(inviterBizId,Integer.valueOf(user.get("uid")));
}
Assert.assertEquals(helpResult1.jsonPath().getString("data.recordErrMsg"),"获得卡片达到上限","助力结果校验失败");
Response helpResult2 = newCollectActivityService.inviteBonusRecord(inviteeBizId,Integer.valueOf(user.get("uid")));
helpResult2.prettyPrint();
Assert.assertEquals(helpResult2.jsonPath().getString("data.bizId"),inviteeBizId,"校验bizId失败");
Assert.assertTrue(helpResult2.jsonPath().getString("data.bonusDetail").contains("31638"),"校验bonusDetail失败");
Assert.assertTrue(helpResult2.jsonPath().getString("data.ruleConfig").contains("1598"),"校验ruleConfig失败");
Assert.assertEquals(helpResult2.jsonPath().getString("data.shareCode"),shareCode,"校验shareCode失败");
logger.info("助力成功!");
Thread.sleep(3000);
Map<String,Object> afterCardDbInfo = jdbc.findSimpleResult(selectSql);
Integer after_item_count = Integer.valueOf(afterCardDbInfo.get("item_count").toString());
logger.info("助力后,afterCardDbInfo的信息为"+afterCardDbInfo+",itemId="+itemId+"的数量为:"+after_item_count);
Assert.assertEquals(item_count,String.valueOf(after_item_count),"分享用户卡片达到上限后,不发卡校验失败");
Map<String,Object> afterCardDbInfo1 = jdbc.findSimpleResult(selectSql1);
Integer after_item_count1 = Integer.valueOf(afterCardDbInfo1.get("item_count").toString());
logger.info("助力后,afterCardDbInfo1的信息为"+afterCardDbInfo1+",itemId="+itemId+"的数量为:"+after_item_count1);
Assert.assertEquals(afterCardDbInfo1.get("item_count").toString(),"1","助力用户助力之后的卡片数量为1失败");
checkGetCollectInfo(collectRuleId,itemId,String.valueOf(after_item_count1),Integer.valueOf(user.get("uid")),"助力之后,助力用户的集卡信息为:");
this.clear(user.get("uid"),user.get("consumerId"));
}
public Map<String,String> createUser(String appId,String app_id) throws Exception{
Map<String,String> map = new HashMap<>();
Response response = editManagerInfoService.createUser("新用户助力",appId);
Map<String,Object> user = jdbc.findSimpleResult("select * from dafuweng.user where name = '新用户助力' and app_id = ?\n",appId);
String uid = user.get("id").toString();
String url = "http://47.97.214.108/user/loginDuiba?uid=" + uid;
Response login = given().get(url);
Map<String,Object> consumer = jdbc.findSimpleResult("select * from new_consumer.consumer_0010 where partner_user_id =? and app_id = ?\n",uid,app_id);
String consumerId = consumer.get("id").toString();
Boolean res = jdbc.update("UPDATE new_consumer.consumer_0010 set addr_name = 'qwj' , addr_phone = '18143476563' ,addr_province = '浙江省' ,addr_city = '杭州市' " +
", addr_area = '西湖区' , addr_detail = '奖池花印' where partner_user_id = ? and app_id = ?\n",uid,app_id);
map.put("uid",uid);
map.put("consumerId",consumerId);
logger.info("用户信息为,uid="+uid+"consumerId="+consumerId);
return map;
}
public void clear(String uid,String comsumerId) throws Exception{
Boolean res = jdbc.update("delete from dafuweng.user where name = '新用户助力' and app_id = '67'");
Boolean res1 = jdbc.update("delete from new_consumer.consumer_0010 where id = ?",comsumerId);
}
public String getDbName (String dbPrex,String consumerId) {
// Long b = 10000000L;
// Long dbPostfix = Long.valueOf(consumerId)/b;
Long b = 1024L;
Long dbPostfix = Long.valueOf(consumerId)%b;
String dbName = null;
System.out.println(dbPostfix);
if (dbPostfix.intValue()<100){
dbName = dbPrex +"_00"+ dbPostfix;
}else{
dbName = dbPrex +"_0"+ dbPostfix;
}
logger.info("该用户的表名为:"+dbName);
return dbName;
}
public void checkGetCollectInfo(String collectRuleId,String itemId,String count,int uid,String message) throws Exception{
Response collectGoodsInfo = newCollectActivityService.getCollectGoodsInfo(collectRuleId,uid);
List<CollectGoodsInfo> myColInfos = collectGoodsInfo.jsonPath().getList("collectGoods",CollectGoodsInfo.class);
logger.info(message+ JSON.toJSONString(myColInfos));
for (CollectGoodsInfo info:myColInfos){
if (info.getId().equals(itemId)){
Assert.assertEquals(info.getCount(),count,"前端接口获取卡片数量接口校验是吧");
break;
}
}
}
}
\ No newline at end of file
/**
* Copyright (C), 2015-2018
* FileName: 新集卡_开奖异常_DuibaTest
* Author: qianwenjun
* Date: 2018/10/17 17:18
* Description:
*/
package http.cases.NewCollectActivityTest;
import base.DuibaLog;
import base.DuibaTestBase;
import com.alibaba.fastjson.JSON;
import http.service.Activity.NewCollectActivityService;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import utils.ExcelDataProvider;
import java.lang.reflect.Method;
import java.util.Iterator;
import java.util.Map;
/**
* 〈〉
*
* @author qianwenjun
* @create 2018/10/17
* @since 1.0.0
*/
public class 新集卡_开奖异常_DuibaTest extends DuibaTestBase {
@Autowired
NewCollectActivityService newCollectActivityService;
private static DuibaLog logger = DuibaLog.getLogger();
@DataProvider
public Iterator<Object[]> provideMethod(Method method){
Iterator<Object[]> res = null;
if (method.getName().equals("新集卡_开奖异常")){
res = new ExcelDataProvider("duiba/新集卡_开奖异常");
}
return res;
}
@Test(dataProvider = "provideMethod")
public void 新集卡_开奖异常(Map<String,String> data) throws Exception{
String casenum = data.get("casenum");
String activityId = data.get("activityId");
String collectRuleId = data.get("collectRuleId");
Integer uid = Integer.valueOf(data.get("uid"));
String consumerId = data.get("consumerId");
String gredeLevel = data.get("gradeLevel");
String cardDb = data.get("cardDb");
String itemId = data.get("itemId");
Map<String,Object> winRecord = jdbc.findSimpleResult("select * from collect_card.tb_collect_card_win_record where consumer_id = ? and rule_id = ? and grade_level = ?",consumerId,collectRuleId,gredeLevel);
logger.info("用户获奖记录为:"+ JSON.toJSONString(winRecord));
if (winRecord.size()==0&&(casenum!="5")){
Boolean res = jdbc.update("insert into collect_card.tb_collect_card_win_record (app_id,consumer_id,partner_user_id,rule_type,rule_id,grade_level,rule_info,order_num,gmt_create,gmt_modify) values (2239, 100091157, '3860', 0, 4434, 1, '[{\\\"key\\\":\\\"31252\\\",\\\"val\\\":1}]', '800731874776580277', '2018-10-10 18:34:32', '2018-10-10 18:34:32')\n");
Map<String,Object> winRecord2 = jdbc.findSimpleResult("select * from collect_card.tb_collect_card_win_record where consumer_id = ? and rule_id = ? and grade_level = ?",consumerId,collectRuleId,gredeLevel);
logger.info("添加之后的用户获奖记录为:"+ JSON.toJSONString(winRecord2));
}
String sql = "select * from "+ cardDb + " where consumer_id = '" + consumerId + "' and item_id = '"+itemId+"'";
logger.info("查询订单的sql为:"+sql);
Map<String,Object> cardInfo = jdbc.findSimpleResult(sql);
logger.info("查询这张卡的数量为:"+cardInfo.get("item_count"));
if (cardInfo.size()==0){
Boolean res = jdbc.update("INSERT INTO collect_card_consumer.tb_collect_card_info_0597 (app_id,consumer_id,partner_user_id,item_type,item_id,item_count,item_total_count,gmt_create,gmt_modify) VALUES ( 2239, 100091477, '3911', 0, 31299, 1, 1, '2018-10-24 16:42:36', '2018-10-24 16:52:41');\n");
Map<String,Object> cardInfo2 = jdbc.findSimpleResult(sql);
logger.info("更新后改用户这张卡的数量为:"+cardInfo2.get("item_count"));
} else if (cardInfo.get("item_count").toString().equals("0")){
String updateSql = "update "+ cardDb + " set item_count = '1' where consumer_id = '" + consumerId + "' and item_id = '"+itemId+"'";
Boolean res = jdbc.update(updateSql);
Map<String,Object> cardInfo2 = jdbc.findSimpleResult(sql);
logger.info("更新后改用户这张卡的数量为:"+cardInfo2.get("item_count"));
}
if (casenum.equals("1")||casenum.equals("2")){
Response response = newCollectActivityService.openCollectGoodsPrizeFalse(collectRuleId,"已领奖",uid);
logger.info("达到用户中奖限制后,再开奖的报错信息为:"+response.jsonPath().getString("message"));
}else if (casenum.equals("5")){
Response response = newCollectActivityService.openCollectGoodsPrizeFalse(collectRuleId,"未开奖,请稍后。。。。",uid);
logger.info("达到用户中奖限制后,再开奖的报错信息为:"+response.jsonPath().getString("message"));
}else {
Response openPrizeResponse = this.openPrize(collectRuleId,uid);
openPrizeResponse.prettyPrint();
Assert.assertEquals(openPrizeResponse.jsonPath().getString("result"),"2","校验开奖接口失败");
Assert.assertEquals(openPrizeResponse.jsonPath().getString("lottery.type"),"alipay","校验开奖类型object失败");
Map<String,Object> cardInfo3 = jdbc.findSimpleResult(sql);
Assert.assertEquals(cardInfo3.get("item_count").toString(),"0","校验开奖后扣卡失败");
}
}
// @Test
public void 新集卡_单接口调试() throws Exception{
// String casenum = data.get("casenum");
String activityId = "2741";
String collectRuleId = "4506";
Integer uid = 3911;
String consumerId = "100091477";
String gredeLevel = "1";
String cardDb = "collect_card_consumer.tb_collect_card_info_0597";
String itemId= "31299";
Map<String,Object> winRecord = jdbc.findSimpleResult("select * from collect_card.tb_collect_card_win_record where consumer_id = ? and rule_id = ? and grade_level = ?",consumerId,collectRuleId,gredeLevel);
logger.info("用户获奖记录为:"+ JSON.toJSONString(winRecord));
// if (winRecord.size()==0){
// Boolean res = jdbc.update("insert into collect_card.tb_collect_card_win_record (app_id,consumer_id,partner_user_id,rule_type,rule_id,grade_level,rule_info,order_num,gmt_create,gmt_modify) values (2239, 100091157, '3860', 0, 4434, 1, '[{\\\"key\\\":\\\"31252\\\",\\\"val\\\":1}]', '800731874776580277', '2018-10-10 18:34:32', '2018-10-10 18:34:32')\n");
// Map<String,Object> winRecord2 = jdbc.findSimpleResult("select * from collect_card.tb_collect_card_win_record where consumer_id = ? and rule_id = ? and grade_level = ?",consumerId,collectRuleId,gredeLevel);
// logger.info("添加之后的用户获奖记录为:"+ JSON.toJSONString(winRecord2));
// }
String sql = "select * from "+ cardDb + " where consumer_id = '" + consumerId + "' and item_id = '"+itemId+"'";
logger.info("查询订单的sql为:"+sql);
Map<String,Object> cardInfo = jdbc.findSimpleResult(sql);
logger.info("查询这张卡的数量为:"+cardInfo.get("item_count"));
if (cardInfo.size()==0){
Boolean res = jdbc.update("INSERT INTO collect_card_consumer.tb_collect_card_info_0597 (app_id,consumer_id,partner_user_id,item_type,item_id,item_count,item_total_count,gmt_create,gmt_modify) VALUES ( 2239, 100091477, '3911', 0, 31299, 1, 1, '2018-10-24 16:42:36', '2018-10-24 16:52:41');\n");
Map<String,Object> cardInfo2 = jdbc.findSimpleResult(sql);
logger.info("更新后改用户这张卡的数量为:"+cardInfo2.get("item_count"));
} else if (cardInfo.get("item_count").toString().equals("0")){
String updateSql = "update "+ cardDb + " set item_count = '1' where consumer_id = '" + consumerId + "' and item_id = '"+itemId+"'";
Boolean res = jdbc.update(updateSql);
Map<String,Object> cardInfo2 = jdbc.findSimpleResult(sql);
logger.info("更新后改用户这张卡的数量为:"+cardInfo2.get("item_count"));
}
// if (casenum.equals("1")||casenum.equals("2")){
Response response = newCollectActivityService.openCollectGoodsPrizeFalse(collectRuleId,"已领奖",uid);
logger.info("达到用户中奖限制后,再开奖的报错信息为:"+response.jsonPath().getString("message"));
// }else {
// Response openPrizeResponse = this.openPrize(collectRuleId,uid);
// openPrizeResponse.prettyPrint();
//
// Assert.assertEquals(openPrizeResponse.jsonPath().getString("result"),"2","校验开奖接口失败");
// Assert.assertEquals(openPrizeResponse.jsonPath().getString("lottery.type"),"alipay","校验开奖类型object失败");
// Map<String,Object> cardInfo3 = jdbc.findSimpleResult(sql);
// Assert.assertEquals(cardInfo3.get("item_count").toString(),"0","校验开奖后扣卡失败");
//
// }
// Response playReasponse = this.playPlugin(activityId,collectRuleId,uid);
// playReasponse.prettyPrint();
}
public Response playPlugin(String activityId, String collectRuleId, int uid) throws Exception {
Response response = newCollectActivityService.doJoinPlugdraw(activityId,collectRuleId,uid);
String orderId = response.jsonPath().getString("orderId");
response = newCollectActivityService.getOrderStatusPlugdraw(orderId,uid);
String result = String.valueOf(response.jsonPath().getString("result"));
int i= 30;
while(i>0&&(result.equals("0"))){
Thread.sleep(1000);
response = newCollectActivityService.getOrderStatusPlugdraw(orderId,uid);
result = String.valueOf(response.jsonPath().getString("result"));
i--;
}
return response;
}
public Response openPrize(String collectRuleId,Integer uid) throws Exception {
Response openResponse = newCollectActivityService.openCollectGoodsPrize(collectRuleId,uid);
String orderId = openResponse.jsonPath().getString("orderId");
Response statusResponse = newCollectActivityService.getOpenOrderStatus(orderId,uid);
String playResult = String.valueOf(statusResponse.jsonPath().getString("result"));
int i = 8;
while (i > 0 && (playResult.equals("0"))) {
Thread.sleep(1000);
statusResponse = newCollectActivityService.getOpenOrderStatus(orderId,uid);
playResult = String.valueOf(statusResponse.jsonPath().getString("result"));
i--;
}
return statusResponse;
}
}
\ No newline at end of file
/**
* Copyright (C), 2015-2018
* FileName: 新集卡_开奖流程_DuibaTest
* Author: qianwenjun
* Date: 2018/10/15 16:48
* Description:
*/
package http.cases.NewCollectActivityTest;
import base.DuibaLog;
import base.DuibaTestBase;
import cn.com.duiba.activity.center.api.dto.activity.CLRewardDto;
import com.alibaba.fastjson.JSON;
import http.model.CollectGoodsInfo;
import http.service.Activity.NewCollectActivityService;
import http.service.Manager.GetManagerInfoService;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.testng.Assert;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import utils.ExcelDataProvider;
import java.lang.reflect.Method;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
/**
* 〈〉
*
* @author qianwenjun
* @create 2018/10/15
* @since 1.0.0
*/
public class 新集卡_开奖流程_DuibaTest extends DuibaTestBase {
@Autowired
NewCollectActivityService newCollectActivityService;
@Autowired
GetManagerInfoService getManagerInfoService;
private static DuibaLog logger = DuibaLog.getLogger();
String orderNum = null;
@DataProvider
public Iterator<Object[]> provideMethod(Method method) {
Iterator<Object[]> result = null;
if (method.getName().equals("插件发卡_直接出奖")){
result = new ExcelDataProvider("duiba/新集卡_直接出奖");
}else if (method.getName().equals("集卡开奖_未满足条件")){
result = new ExcelDataProvider("duiba/新集卡_未满足条件开奖");
}else if (method.getName().equals("集卡开奖_插件出奖")){
result = new ExcelDataProvider("duiba/新集卡_插件出奖");
}
return result;
}
@Test(dataProvider = "provideMethod")
public void 插件发卡_直接出奖(Map<String,String> data) throws Exception{
logger.info(data.get("casename"));
String activityId = data.get("activityId");
String collectRuleId = data.get("collectRuleId");
Integer uid = Integer.valueOf(data.get("uid").toString());
String count = data.get("count");
String itemId = null;
for (int i=0;i<Integer.valueOf(count);i++){
Response plsyResponse = this.playPlugin(activityId,collectRuleId,uid);
plsyResponse.prettyPrint();
Assert.assertEquals(plsyResponse.jsonPath().getString("lottery.type"),"collectGoods","校验插件发集卡type失败");
itemId = plsyResponse.jsonPath().getString("lottery.itemId");
}
Response collectGoodsInfo = newCollectActivityService.getCollectGoodsInfo(collectRuleId,uid);
collectGoodsInfo.prettyPrint();
List<CollectGoodsInfo> myColInfos = collectGoodsInfo.jsonPath().getList("collectGoods",CollectGoodsInfo.class);
for (CollectGoodsInfo info:myColInfos){
if (info.getId().equals(itemId)){
Assert.assertEquals(info.getCount(),count,"集卡数量校验失败");
logger.info("校验发卡成功");
logger.info("用户卡片itemId="+itemId+"的数量为:"+info.getCount());
break;
}
}
Assert.assertEquals(collectGoodsInfo.jsonPath().getString("prizeLevel"),data.get("prizeLevel"),"集卡信息接口可开奖prizeLevel字段校验失败");
Assert.assertEquals(collectGoodsInfo.jsonPath().getString("clickFlag"),"true","是否可点击开奖clickFlag校验失败");
logger.info("获取集卡信息接口成功");
logger.info("prizeLevel="+collectGoodsInfo.jsonPath().getString("prizeLevel")+"可开奖");
//开奖
Response openPrizeResponse = this.openPrize(collectRuleId,uid,"nomal");
openPrizeResponse.prettyPrint();
Assert.assertEquals(openPrizeResponse.jsonPath().getString("result"),"2","校验开奖接口失败");
Assert.assertEquals(openPrizeResponse.jsonPath().getString("lottery.type"),data.get("type"),"校验开奖类型object失败");
logger.info("校验开奖成功,开奖的奖项类型为:"+openPrizeResponse.jsonPath().getString("lottery.type"));
Response afterCollectGoodsInfo = newCollectActivityService.getCollectGoodsInfo(collectRuleId,uid);
afterCollectGoodsInfo.prettyPrint();
List<CollectGoodsInfo> afterMyColInfos = afterCollectGoodsInfo.jsonPath().getList("collectGoods",CollectGoodsInfo.class);
for (CollectGoodsInfo info:afterMyColInfos){
if (info.getId().equals(itemId)){
Assert.assertEquals(info.getCount(),"0","集卡数量校验失败");
logger.info("校验开奖扣卡成功");
logger.info("用户开奖后,卡片itemId="+itemId+"的数量为:"+info.getCount());
break;
}
}
Assert.assertEquals(afterCollectGoodsInfo.jsonPath().getString("prizeLevel"),"0","集卡信息接口可开奖prizeLevel字段校验失败");
Assert.assertEquals(afterCollectGoodsInfo.jsonPath().getString("clickFlag"),"false","是否可点击开奖clickFlag校验失败");
}
@Test(dataProvider = "provideMethod")
public void 集卡开奖_未满足条件(Map<String,String> data) throws Exception{
String activityId = data.get("activityId");
String collectRuleId = data.get("collectRuleId");
Integer uid = Integer.valueOf(data.get("uid"));
String consumerId = data.get("consumerId");
String gredeLevel = data.get("gradeLevel");
//集卡配置的规则为
Response ruleInfo = getManagerInfoService.getCollectAwardsInfo(collectRuleId);
List<CLRewardDto> cLRewards = ruleInfo.jsonPath().getJsonObject("data.config.rewards");
logger.info("rewardsObj信息为:"+ JSON.toJSONString(cLRewards.get(0)));
//我的集卡信息为
Response collectGoodsInfo = newCollectActivityService.getCollectGoodsInfo(collectRuleId,uid);
collectGoodsInfo.prettyPrint();
List<CollectGoodsInfo> myColInfos = collectGoodsInfo.jsonPath().getList("collectGoods",CollectGoodsInfo.class);
logger.info("我的集卡信息为:"+JSON.toJSONString(myColInfos));
Response openResponse = newCollectActivityService.openCollectGoodsPrizeFalse(collectRuleId,"未满足 中奖条件",uid);
openResponse.prettyPrint();
Assert.assertEquals(openResponse.jsonPath().getString("success"),"false","开奖结果校验失败");
Assert.assertEquals(openResponse.jsonPath().getString("message"),"未满足 中奖条件","错误message校验失败");
}
// @Test
public void 集卡开奖_直接出奖_奖品库存不足() throws Exception {
String activityId = "2718";
String collectRuleId = "4444";
Integer uid = 3835;
String consumerId = "100090009";
Response playReasponse = this.playPlugin(activityId, collectRuleId, uid);
playReasponse.prettyPrint();
Response openResponse = newCollectActivityService.openCollectGoodsPrize(collectRuleId,uid);
String orderId = openResponse.jsonPath().getString("orderId");
Response statusResponse = newCollectActivityService.getOpenOrderStatus(orderId,uid);
String playResult = String.valueOf(statusResponse.jsonPath().getString("result"));
//奖品库存不足,发奖接口调用成功,订单生成,exchange_status=3,message标明扣库存失败;用户卡片扣除。
}
@Test(dataProvider = "provideMethod")
public void 集卡开奖_插件出奖(Map<String,String> data) throws Exception {
String casenum = data.get("casenum");
String activityId = data.get("activityId");
String collectRuleId = data.get("collectRuleId");
Integer uid = Integer.valueOf(data.get("uid"));
String consumerId = data.get("consumerId");
String count = data.get("count");
String afterCount = data.get("afterCount");
String prizeLevel = data.get("prizeLevel");
String afterPrizeLevel = data.get("afterPrizeLevel");
String clickFlag = data.get("clickFlag");
String afterClickFlag = data.get("afterClickFlag");
String prizeType = data.get("type");
String credits = data.get("credits");
String openResult = data.get("openResult");
String orderDb = data.get("orderDb");
String cardDb = data.get("cardDb");
String clearSql = "delete from "+ cardDb + " where consumer_id = '" + consumerId + "' and item_id in('31294','31295','31296','31297','31298','31299')";
logger.info("清理数据的sql为:"+clearSql);
Boolean res = jdbc.update(clearSql);
String itemId = null;
for (int i=0;i<Integer.valueOf(count);i++){
Response plsyResponse = this.playPlugin(activityId,collectRuleId,uid);
plsyResponse.prettyPrint();
Assert.assertEquals(plsyResponse.jsonPath().getString("lottery.type"),"collectGoods","校验插件发集卡type失败");
itemId = plsyResponse.jsonPath().getString("lottery.itemId");
}
Response collectGoodsInfo = newCollectActivityService.getCollectGoodsInfo(collectRuleId,uid);
collectGoodsInfo.prettyPrint();
List<CollectGoodsInfo> myColInfos = collectGoodsInfo.jsonPath().getList("collectGoods",CollectGoodsInfo.class);
for (CollectGoodsInfo info:myColInfos){
if (info.getId().equals(itemId)){
Assert.assertEquals(info.getCount(),count,"集卡数量校验失败");
logger.info("校验发卡成功");
logger.info("用户卡片itemId="+itemId+"的数量为:"+info.getCount());
break;
}
}
Assert.assertEquals(collectGoodsInfo.jsonPath().getString("prizeLevel"),prizeLevel,"集卡信息接口可开奖prizeLevel字段校验失败");
Assert.assertEquals(collectGoodsInfo.jsonPath().getString("clickFlag"),clickFlag,"是否可点击开奖clickFlag校验失败");
logger.info("获取集卡信息接口成功");
logger.info("prizeLevel="+collectGoodsInfo.jsonPath().getString("prizeLevel")+"可开奖");
if (casenum.equals("4")){
Response openResponse = newCollectActivityService.openCollectGoodsPrizeFalse(collectRuleId,"插件剩余限制次数为0",uid);
openResponse.prettyPrint();
Assert.assertEquals(openResponse.jsonPath().getString("success"),"false","开奖结果校验失败");
Assert.assertEquals(openResponse.jsonPath().getString("message"),"插件剩余限制次数为0","错误message校验失败");
}else if (casenum.equals("6")){
Response openResponse = newCollectActivityService.openCollectGoodsPrizeFalse(collectRuleId,"抱歉,积分不足",uid);
openResponse.prettyPrint();
Assert.assertEquals(openResponse.jsonPath().getString("success"),"false","开奖结果校验失败");
Assert.assertEquals(openResponse.jsonPath().getString("message"),"抱歉,积分不足","错误message校验失败");
}else {
//开奖
Response openPrizeResponse = this.openPrize(collectRuleId,uid,"plugin");
openPrizeResponse.prettyPrint();
Assert.assertEquals(openPrizeResponse.jsonPath().getString("result"),openResult,"校验开奖接口失败");
Assert.assertEquals(openPrizeResponse.jsonPath().getString("lottery.type"),prizeType,"校验开奖类型object失败");
logger.info("校验开奖成功,开奖的奖项类型为:"+openPrizeResponse.jsonPath().getString("lottery.type"));
String sql = "select * from "+ orderDb + " where order_num = '" + orderNum + "'";
logger.info("查询订单的sql为:"+sql);
Map<String,Object> order = jdbc.findSimpleResult(sql);
logger.info("查询结果为:"+JSON.toJSONString(order));
Assert.assertEquals(order.get("consume_credits_status").toString(),"2","订单状态校验失败");
Assert.assertEquals(order.get("activity_type").toString(),"plugin","订单来源类型校验失败");
Assert.assertEquals(order.get("consume_credits").toString(),credits,"消耗积分值校验失败");
}
Response afterCollectGoodsInfo = newCollectActivityService.getCollectGoodsInfo(collectRuleId,uid);
afterCollectGoodsInfo.prettyPrint();
List<CollectGoodsInfo> afterMyColInfos = afterCollectGoodsInfo.jsonPath().getList("collectGoods",CollectGoodsInfo.class);
for (CollectGoodsInfo info:afterMyColInfos){
if (info.getId().equals(itemId)){
Assert.assertEquals(info.getCount(),afterCount,"集卡数量校验失败");
logger.info("校验开奖扣卡成功");
logger.info("用户开奖后,卡片itemId="+itemId+"的数量为:"+info.getCount());
break;
}
}
Assert.assertEquals(afterCollectGoodsInfo.jsonPath().getString("prizeLevel"),afterPrizeLevel,"集卡信息接口可开奖prizeLevel字段校验失败");
Assert.assertEquals(afterCollectGoodsInfo.jsonPath().getString("clickFlag"),afterClickFlag,"是否可点击开奖clickFlag校验失败");
}
@Test
public void 集卡开奖_手动开奖(){
}
// @Test
public void 集卡开奖_单接口调试() throws Exception {
//手动开奖——开
String activityId = "2741";
String collectRuleId = "4505";
Integer uid = 3910;
String consumerId = "100091476";
String count = "1";
String afterCount = "0";
String prizeLevel = "1";
String afterPrizeLevel = "0";
String clickFlag = "true";
String afterClickFlag = "false";
String prizeType = "alipay";
String credits = "100";
String openResult = "2";
String orderDb = "activity_order_con.tb_trade_center_activity_order_0596";
String cardDb = "collect_card_consumer.tb_collect_card_info_0596";
//手动开关-关
// String activityId = data.get("activityId");
// String collectRuleId = data.get("collectRuleId");
// Integer uid = Integer.valueOf(data.get("uid").toString());
// String count = data.get("count");
String itemId = null;
for (int i=0;i<Integer.valueOf(count);i++){
Response plsyResponse = this.playPlugin(activityId,collectRuleId,uid);
plsyResponse.prettyPrint();
Assert.assertEquals(plsyResponse.jsonPath().getString("lottery.type"),"collectGoods","校验插件发集卡type失败");
itemId = plsyResponse.jsonPath().getString("lottery.itemId");
}
Response collectGoodsInfo = newCollectActivityService.getCollectGoodsInfo(collectRuleId,uid);
collectGoodsInfo.prettyPrint();
List<CollectGoodsInfo> myColInfos = collectGoodsInfo.jsonPath().getList("collectGoods",CollectGoodsInfo.class);
for (CollectGoodsInfo info:myColInfos){
if (info.getId().equals(itemId)){
Assert.assertEquals(info.getCount(),count,"集卡数量校验失败");
logger.info("校验发卡成功");
logger.info("用户卡片itemId="+itemId+"的数量为:"+info.getCount());
break;
}
}
Assert.assertEquals(collectGoodsInfo.jsonPath().getString("prizeLevel"),prizeLevel,"集卡信息接口可开奖prizeLevel字段校验失败");
Assert.assertEquals(collectGoodsInfo.jsonPath().getString("clickFlag"),"true","是否可点击开奖clickFlag校验失败");
logger.info("获取集卡信息接口成功");
logger.info("prizeLevel="+collectGoodsInfo.jsonPath().getString("prizeLevel")+"可开奖");
//开奖
Response openPrizeResponse = this.openPrize(collectRuleId,uid,"nomal");
openPrizeResponse.prettyPrint();
Assert.assertEquals(openPrizeResponse.jsonPath().getString("result"),"2","校验开奖接口失败");
Assert.assertEquals(openPrizeResponse.jsonPath().getString("lottery.type"),prizeType,"校验开奖类型object失败");
logger.info("校验开奖成功,开奖的奖项类型为:"+openPrizeResponse.jsonPath().getString("lottery.type"));
Response afterCollectGoodsInfo = newCollectActivityService.getCollectGoodsInfo(collectRuleId,uid);
afterCollectGoodsInfo.prettyPrint();
List<CollectGoodsInfo> afterMyColInfos = afterCollectGoodsInfo.jsonPath().getList("collectGoods",CollectGoodsInfo.class);
for (CollectGoodsInfo info:afterMyColInfos){
if (info.getId().equals(itemId)){
Assert.assertEquals(info.getCount(),"0","集卡数量校验失败");
logger.info("校验开奖扣卡成功");
logger.info("用户开奖后,卡片itemId="+itemId+"的数量为:"+info.getCount());
break;
}
}
Assert.assertEquals(afterCollectGoodsInfo.jsonPath().getString("prizeLevel"),"0","集卡信息接口可开奖prizeLevel字段校验失败");
Assert.assertEquals(afterCollectGoodsInfo.jsonPath().getString("clickFlag"),"false","是否可点击开奖clickFlag校验失败");
// String clearSql = "delete from "+ cardDb + " where consumer_id = '" + consumerId + "' and item_id in('31294','31295','31296','31297','31298','31299')";
// logger.info("清理数据的sql为:"+clearSql);
// Boolean res = jdbc.update(clearSql);
//
// String itemId = null;
// for (int i=0;i<Integer.valueOf(count);i++){
// Response plsyResponse = this.playPlugin(activityId,collectRuleId,uid);
// plsyResponse.prettyPrint();
// Assert.assertEquals(plsyResponse.jsonPath().getString("lottery.type"),"collectGoods","校验插件发集卡type失败");
// itemId = plsyResponse.jsonPath().getString("lottery.itemId");
// }
// Response collectGoodsInfo = newCollectActivityService.getCollectGoodsInfo(collectRuleId,uid);
// collectGoodsInfo.prettyPrint();
// List<CollectGoodsInfo> myColInfos = collectGoodsInfo.jsonPath().getList("collectGoods",CollectGoodsInfo.class);
// for (CollectGoodsInfo info:myColInfos){
// if (info.getId().equals(itemId)){
// Assert.assertEquals(info.getCount(),count,"集卡数量校验失败");
// logger.info("校验发卡成功");
// logger.info("用户卡片itemId="+itemId+"的数量为:"+info.getCount());
// break;
// }
// }
//
// Assert.assertEquals(collectGoodsInfo.jsonPath().getString("prizeLevel"),prizeLevel,"集卡信息接口可开奖prizeLevel字段校验失败");
// Assert.assertEquals(collectGoodsInfo.jsonPath().getString("clickFlag"),clickFlag,"是否可点击开奖clickFlag校验失败");
// logger.info("获取集卡信息接口成功");
// logger.info("prizeLevel="+collectGoodsInfo.jsonPath().getString("prizeLevel")+"可开奖");
// //开奖
// Response openPrizeResponse = this.openPrize(collectRuleId,uid,"plugin");
// openPrizeResponse.prettyPrint();
// Assert.assertEquals(openPrizeResponse.jsonPath().getString("result"),openResult,"校验开奖接口失败");
// Assert.assertEquals(openPrizeResponse.jsonPath().getString("lottery.type"),prizeType,"校验开奖类型object失败");
// logger.info("校验开奖成功,开奖的奖项类型为:"+openPrizeResponse.jsonPath().getString("lottery.type"));
// String sql = "select * from "+ orderDb + " where order_num = '" + orderNum + "'";
// logger.info("查询订单的sql为:"+sql);
// Map<String,Object> order = jdbc.findSimpleResult(sql);
// logger.info("查询结果为:"+JSON.toJSONString(order));
// Assert.assertEquals(order.get("consume_credits_status").toString(),"2","订单状态校验失败");
// Assert.assertEquals(order.get("activity_type").toString(),"plugin","订单来源类型校验失败");
// Assert.assertEquals(order.get("consume_credits").toString(),credits,"消耗积分值校验失败");
//
//// Response openResponse = newCollectActivityService.openCollectGoodsPrizeFalse(collectRuleId,"插件剩余限制次数为0",uid);
//// openResponse.prettyPrint();
//// Assert.assertEquals(openResponse.jsonPath().getString("success"),"false","开奖结果校验失败");
//// Assert.assertEquals(openResponse.jsonPath().getString("message"),"插件剩余限制次数为0","错误message校验失败");
//
//
// Response afterCollectGoodsInfo = newCollectActivityService.getCollectGoodsInfo(collectRuleId,uid);
// afterCollectGoodsInfo.prettyPrint();
// List<CollectGoodsInfo> afterMyColInfos = afterCollectGoodsInfo.jsonPath().getList("collectGoods",CollectGoodsInfo.class);
// String infoItemID = afterMyColInfos.get(0).getId();
// for (CollectGoodsInfo info:afterMyColInfos){
// String infoItemID2 = info.getId();
// if (info.getId().equals(itemId)){
// Assert.assertEquals(info.getCount(),afterCount,"集卡数量校验失败");
// logger.info("校验开奖扣卡成功");
// logger.info("用户开奖后,卡片itemId="+itemId+"的数量为:"+info.getCount());
// break;
// }
// }
// Assert.assertEquals(afterCollectGoodsInfo.jsonPath().getString("prizeLevel"),afterPrizeLevel,"集卡信息接口可开奖prizeLevel字段校验失败");
// Assert.assertEquals(afterCollectGoodsInfo.jsonPath().getString("clickFlag"),afterClickFlag,"是否可点击开奖clickFlag校验失败");
}
public Response playPlugin(String activityId,String collectRuleId,int uid) throws Exception {
Response response = newCollectActivityService.doJoinPlugdraw(activityId,collectRuleId,uid);
String orderId = response.jsonPath().getString("orderId");
response = newCollectActivityService.getOrderStatusPlugdraw(orderId,uid);
String result = String.valueOf(response.jsonPath().getString("result"));
int i= 30;
while(i>0&&(result.equals("0"))){
Thread.sleep(1000);
response = newCollectActivityService.getOrderStatusPlugdraw(orderId,uid);
result = String.valueOf(response.jsonPath().getString("result"));
i--;
}
return response;
}
public Response openPrize(String collectRuleId,Integer uid,String type) throws Exception {
Response openResponse = newCollectActivityService.openCollectGoodsPrize(collectRuleId,uid);
openResponse.prettyPrint();
String orderId = null;
if (type.equals("nomal")){
orderId = openResponse.jsonPath().getString("orderId");
}else if (type.equals("plugin")){
orderId = openResponse.jsonPath().getString("orderId.orderNum");
orderNum = orderId;
}
Response statusResponse = newCollectActivityService.getOpenOrderStatus(orderId,uid);
String playResult = String.valueOf(statusResponse.jsonPath().getString("result"));
int i = 8;
while (i > 0 && (playResult.equals("0"))) {
Thread.sleep(1000);
statusResponse = newCollectActivityService.getOpenOrderStatus(orderId,uid);
playResult = String.valueOf(statusResponse.jsonPath().getString("result"));
i--;
}
return statusResponse;
}
}
\ No newline at end of file
/**
* Copyright (C), 2015-2018
* FileName: 新集卡_达到限制发卡异常_DuibaTest
* Author: qianwenjun
* Date: 2018/10/16 20:09
* Description:
*/
package http.cases.NewCollectActivityTest;
import base.DuibaLog;
import base.DuibaTestBase;
import http.service.Activity.NewCollectActivityService;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import utils.ExcelDataProvider;
import java.lang.reflect.Method;
import java.util.Iterator;
import java.util.Map;
/**
* 〈〉
*
* @author qianwenjun
* @create 2018/10/16
* @since 1.0.0
*/
public class 新集卡_达到限制发卡异常_DuibaTest extends DuibaTestBase {
@Autowired
NewCollectActivityService newCollectActivityService;
private static DuibaLog logger = DuibaLog.getLogger();
@DataProvider
public Iterator<Object[]> providerByMthod(Method method){
Iterator<Object[]> data = null;
if (method.getName().equals("插件发卡异常")){
data = new ExcelDataProvider("duiba/新集卡_插件发卡异常");
}else if (method.getName().equals("活动工具发卡异常")){
data = new ExcelDataProvider("duiba/新集卡_活动工具发卡异常");
}
return data;
}
@Test(dataProvider = "providerByMthod")
public void 插件发卡异常(Map<String,String> data) throws Exception{
String activityId = data.get("activityId");
String collectRuleId = data.get("collectRuleId");
Integer uid = Integer.valueOf(data.get("uid"));
String consumerId = data.get("consumerId");
String gredeLevel = data.get("gradeLevel");
//清开奖记录数据
Boolean result = jdbc.update("delete from collect_card.tb_collect_card_win_record where consumer_id = ? and rule_id = ? and grade_level = ?",consumerId,collectRuleId,gredeLevel);
Response playReasponse = this.playPlugin(activityId,collectRuleId,uid);
playReasponse.prettyPrint();
Response openPrizeResponse = this.openPrize(collectRuleId,uid);
openPrizeResponse.prettyPrint();
Map<String,Object> winRecord = jdbc.findSimpleResult("select * from collect_card.tb_collect_card_win_record where consumer_id = ? and rule_id = ? and grade_level = ?\n",consumerId,collectRuleId,gredeLevel);
Assert.assertNotNull(winRecord,"开奖记录校验失败");
logger.info("用户consumerId="+winRecord.get("consumer_id")+"的中奖记录为:collectRuleId="+winRecord.get("rule_id")+",gredeLevel="+winRecord.get("grade_level"));
Response playReasponse2 = this.playPlugin(activityId,collectRuleId,uid);
playReasponse2.prettyPrint();
Assert.assertEquals(playReasponse2.jsonPath().getString("lottery.type"),"thanks","校验中奖类型失败");
logger.info("校验成功:达到限制,发卡降级谢谢参与");
}
@Test(dataProvider = "providerByMthod")
public void 活动工具发卡异常(Map<String,String> data) throws Exception{
String activityId = data.get("activityId");
String collectRuleId = data.get("collectRuleId");
Integer uid = Integer.valueOf(data.get("uid"));
String consumerId = data.get("consumerId");
String gredeLevel = data.get("gradeLevel");
//清开奖记录数据
Boolean result = jdbc.update("delete from collect_card.tb_collect_card_win_record where consumer_id = ? and rule_id = ? and grade_level = ?",consumerId,collectRuleId,gredeLevel);
Response playReasponse = this.playHdtool(activityId,collectRuleId,uid);
playReasponse.prettyPrint();
Response openPrizeResponse = this.openPrize(collectRuleId,uid);
openPrizeResponse.prettyPrint();
Map<String,Object> winRecord = jdbc.findSimpleResult("select * from collect_card.tb_collect_card_win_record where consumer_id = ? and rule_id = ? and grade_level = ?\n",consumerId,collectRuleId,gredeLevel);
Assert.assertNotNull(winRecord,"开奖记录校验失败");
Response playReasponse2 = this.playHdtool(activityId,collectRuleId,uid);
playReasponse2.prettyPrint();
Assert.assertEquals(playReasponse2.jsonPath().getString("lottery.type"),"lucky","校验中奖类型失败");
logger.info("校验成功:达到限制,发卡降级福袋");
}
// @Test
public void 单接口调试() throws Exception{
String activityId = "33547";
String collectRuleId = "4437";
Integer uid = 3829;
String consumerId = "100089384";
String gredeLevel = "1";
//清开奖记录数据
Boolean result = jdbc.update("delete from collect_card.tb_collect_card_win_record where consumer_id = ? and rule_id = ? and grade_level = ?",consumerId,collectRuleId,gredeLevel);
Response playReasponse = this.playHdtool(activityId,collectRuleId,uid);
playReasponse.prettyPrint();
Response openPrizeResponse = this.openPrize(collectRuleId,uid);
openPrizeResponse.prettyPrint();
Map<String,Object> winRecord = jdbc.findSimpleResult("select * from collect_card.tb_collect_card_win_record where consumer_id = ? and rule_id = ? and grade_level = ?\n",consumerId,collectRuleId,gredeLevel);
Assert.assertNotNull(winRecord,"开奖记录校验失败");
Response playReasponse2 = this.playHdtool(activityId,collectRuleId,uid);
playReasponse2.prettyPrint();
Assert.assertEquals(playReasponse2.jsonPath().getString("lottery.type"),"lucky","校验中奖类型失败");
logger.info("校验成功:达到限制,发卡降级谢谢参与");
}
public Response playPlugin(String activityId, String collectRuleId, int uid) throws Exception {
Response response = newCollectActivityService.doJoinPlugdraw(activityId,collectRuleId,uid);
String orderId = response.jsonPath().getString("orderId");
response = newCollectActivityService.getOrderStatusPlugdraw(orderId,uid);
String result = String.valueOf(response.jsonPath().getString("result"));
int i= 30;
while(i>0&&(result.equals("0"))){
Thread.sleep(1000);
response = newCollectActivityService.getOrderStatusPlugdraw(orderId,uid);
result = String.valueOf(response.jsonPath().getString("result"));
i--;
}
return response;
}
public Response openPrize(String collectRuleId,Integer uid) throws Exception {
Response openResponse = newCollectActivityService.openCollectGoodsPrize(collectRuleId,uid);
String orderId = openResponse.jsonPath().getString("orderId");
Response statusResponse = newCollectActivityService.getOpenOrderStatus(orderId,uid);
String playResult = String.valueOf(statusResponse.jsonPath().getString("result"));
int i = 8;
while (i > 0 && (playResult.equals("0"))) {
Thread.sleep(1000);
statusResponse = newCollectActivityService.getOpenOrderStatus(orderId,uid);
playResult = String.valueOf(statusResponse.jsonPath().getString("result"));
i--;
}
return statusResponse;
}
public Response playHdtool(String activityId, String collectRuleId, int uid) throws Exception{
Response response = newCollectActivityService.doJoin(activityId,collectRuleId,uid);
response.prettyPrint();
String orderId = response.jsonPath().getString("orderId");
Response statusResponse = newCollectActivityService.getOrderStatus(orderId,uid);
// statusResponse.prettyPrint();
String playResult = statusResponse.jsonPath().getString("result");
int i = 30;
while (i > 0 && (playResult.equals("0"))) {
Thread.sleep(1000);
statusResponse = newCollectActivityService.getOrderStatus(orderId,uid);
playResult = String.valueOf(statusResponse.jsonPath().getString("result"));
i--;
}
return statusResponse;
}
}
/**
* Copyright (C), 2015-2018
* FileName: pk_列表测试_AccessTest
* Author: qianwenjun
* Date: 2018/8/5 11:10
* Description:
*/
package http.cases.PkTest;
import base.DuibaLog;
import base.DuibaTestBase;
import http.model.BetMobileVo;
import http.service.Activity.PkService;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.testng.Assert;
import org.testng.annotations.Test;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* 〈〉
*
* @author qianwenjun
* @create 2018/8/5
* @since 1.0.0
*/
public class pk_列表测试_AccessTest extends DuibaTestBase {
@Autowired
PkService pkService;
private DuibaLog logger = DuibaLog.getLogger();
private static Integer uided_2239 = 3401;//【勿动】pk测试_已押注_2239
private static Integer uid_2239 = 3415;//【勿动】pk测试_未押注_2239
private static Integer uid_18816 = 3414;//【勿动】pk测试01_18816
private static Integer uid_2730 = 2730;//appId=1
@Test
public void 获取pk活动列表测试() throws Exception{
List<Map<String,Object>> dbBetLists = jdbc.findModeResult("select * from act_com_conf.tb_bet_group_relation where group_id = '6' and config_status = '3'");
String totalPk = String.valueOf(dbBetLists.size());
//活动组6,定向给2239好1两个app,所以这两个app的用户都可以获取到该活动组下所有开启的活动;
Response response_uid_2239 = pkService.getBetList(uid_2239);
List<BetMobileVo> betedList = response_uid_2239.jsonPath().getList("data.betedList",BetMobileVo.class);
List<BetMobileVo> unbetList = response_uid_2239.jsonPath().getList("data.unbetList",BetMobileVo.class);
// logger.info("unbetList的信息为"+ JSON.toJSONString(unbetList));
Assert.assertEquals(String.valueOf(betedList.size()),"0","已投注的活动为0校验失败");
Assert.assertEquals(String.valueOf(unbetList.size()),totalPk,"已投注的活动为6校验失败");
Response response_uid_18816 = pkService.getBetList(uid_18816);
List<BetMobileVo> betedList_uid_18816 = response_uid_18816.jsonPath().getList("data.betedList",BetMobileVo.class);
List<BetMobileVo> unbetList_uid_18816 = response_uid_18816.jsonPath().getList("data.unbetList",BetMobileVo.class);
Assert.assertEquals(String.valueOf(unbetList_uid_18816.size()),"0","已投注的活动为6校验失败");
Assert.assertEquals(String.valueOf(betedList_uid_18816.size()),"0","未投注的活动为0校验失败");
Response response_uid_2730 = pkService.getBetList(uid_2730);
List<BetMobileVo> betedList_uid_2730 = response_uid_2730.jsonPath().getList("data.betedList",BetMobileVo.class);
List<BetMobileVo> unbetList_uid_2730 = response_uid_2730.jsonPath().getList("data.unbetList",BetMobileVo.class);
Assert.assertEquals(String.valueOf(betedList_uid_2730.size()),"0","已投注的活动为0校验失败");
Assert.assertEquals(String.valueOf(unbetList_uid_2730.size()),totalPk,"已投注的活动为0校验失败");
//该用户投注过2个活动,且校验活动安装结束时间倒序排
Response response_uided_2239 = pkService.getBetList(uided_2239);
List<BetMobileVo> betedList_uided_2239 = response_uided_2239.jsonPath().getList("data.betedList",BetMobileVo.class);
List<BetMobileVo> unbetList_uided_2239 = response_uided_2239.jsonPath().getList("data.unbetList",BetMobileVo.class);
// logger.info("unbetList的信息为"+ JSON.toJSONString(unbetList));
Assert.assertEquals(String.valueOf(betedList_uided_2239.size()),"2","已投注的活动为0校验失败");
Assert.assertEquals(String.valueOf(unbetList_uided_2239.size()),"4","已投注的活动为6校验失败");
for (int i=0;i<betedList_uided_2239.size()-1;i++){
Assert.assertTrue(Long.valueOf(betedList_uided_2239.get(i).getBetConfig().getEndTime())<=Long.valueOf(betedList_uided_2239.get(i+1).getBetConfig().getEndTime()),"校验已押注活动列表倒序排列失败");
List<String> chooseThisOptions = new ArrayList<>();
for (int j=0;j<betedList_uided_2239.get(i).getOptions().size();j++){
chooseThisOptions.add(betedList_uided_2239.get(i).getOptions().get(j).getChooseThisOption());
}
Assert.assertTrue(chooseThisOptions.contains("true"),"校验已投注活动的标志失败");
}
for (int i=0;i<unbetList_uided_2239.size()-1;i++){
Assert.assertTrue(Long.valueOf(unbetList_uided_2239.get(i).getBetConfig().getEndTime())<=Long.valueOf(unbetList_uided_2239.get(i+1).getBetConfig().getEndTime()),"校验未押注活动列表倒序排列失败");
List<String> chooseThisOptions = new ArrayList<>();
for (int j=0;j<unbetList_uided_2239.get(i).getOptions().size();j++){
chooseThisOptions.add(unbetList_uided_2239.get(i).getOptions().get(j).getChooseThisOption());
}
Assert.assertFalse(chooseThisOptions.contains("true"),"校验已投注活动的标志失败");
}
}
}
\ No newline at end of file
/**
* Copyright (C), 2015-2018
* FileName: pk_开奖_瓜分红包测试
* Author: qianwenjun
* Date: 2018/8/9 20:13
* Description:
*/
package http.cases.PkTest;
import base.DuibaLog;
import base.DuibaTestBase;
import http.model.BetMobileVo;
import http.service.Activity.PkService;
import http.service.Manager.PkActivityService;
import io.restassured.response.Response;
import org.joda.time.format.DateTimeFormat;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import utils.MatcherString;
import org.joda.time.format.DateTimeFormatter;
import org.joda.time.DateTime;
import java.util.ArrayList;
import java.util.List;
/**
* 〈〉
*
* @author qianwenjun
* @create 2018/8/9
* @since 1.0.0
*/
public class pk_开奖_瓜分红包测试 extends DuibaTestBase {
@Autowired
PkService pkService;
@Autowired
PkActivityService pkActivityService;
private static DuibaLog logger = DuibaLog.getLogger();
private String groupId = "7";
private Integer user01 = 3445;
private Integer user02 = 3446;
private Integer user03 = 3447;
private Integer user04 = 3448;
private String newBetId = "";
private List<String> optionsIds = new ArrayList<>();
@BeforeMethod
public void setUp() {
try {
createPk("2","2020-08-12 00:00:00",groupId);
}catch (Exception e){
e.printStackTrace();
}
}
@Test
public void 瓜分红包_两个选项_押注人数相同_开奖测试() throws Exception{
Response betList = pkService.getBetList(3445);
List<BetMobileVo> betMobileVoList = betList.jsonPath().getList("data.unbetList",BetMobileVo.class);
for (BetMobileVo bet:betMobileVoList){
if (bet.getBetConfig().getId().equals(newBetId)){
for (int i=0;i<bet.getOptions().size();i++){
optionsIds.add(bet.getOptions().get(i).getOptionId());
}
}
}
//押注第一个选项:user01,user02
//押注第二个选项:user03,user04
Response res1 = pkService.doJoin(user01,newBetId,optionsIds.get(0));
Response res2 = pkService.doJoin(user02,newBetId,optionsIds.get(0));
Response res3 = pkService.doJoin(user03,newBetId,optionsIds.get(1));
Response res4 = pkService.doJoin(user04,newBetId,optionsIds.get(1));
//修改开奖时间
this.modifyOpenPrizeTime();
int i=8;
}
public void createPk(String bounsType,String endTime,String groupId) throws Exception {
Response betResponse = pkActivityService.bet(bounsType,endTime);
String betId = MatcherString.getString(betResponse.asString(),"\"data\": (\\w*)",1);
newBetId = betId;
logger.info("newBetId的信息为"+newBetId);
Response betRelation = pkActivityService.betGroupRelation(betId,endTime,groupId);
Response modifyStatusResponse = pkActivityService.modifySatus(betId);
}
public String modifyOpenPrizeTime() throws Exception{
DateTime time1 = new DateTime();
DateTime endTime = time1.minusMillis(10);
DateTimeFormatter format = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss");
String endTimeStr = format.print(endTime.getMillis()).toString();
logger.info("\ntime1="+ format.print(time1.getMillis())+"\n设置的开奖时间endTime="+ endTimeStr);
Boolean result1 = jdbc.update("update act_com_conf.tb_bet_config set end_time = ? where id = \"229\"\n",endTimeStr);
Boolean result2 = jdbc.update("update act_com_conf.tb_bet_group_relation set end_time = ? where bet_id = \"229\"\n",endTimeStr);
return endTimeStr;
}
public static void main(String[] args) {
DateTime time1 = DateTime.now();
DateTime time2 = time1.plusMinutes(1);
DateTimeFormatter format = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss");
logger.info("\ntime1="+ format.print(time1.getMillis())+"\ntime2="+ format.print(time2.getMillis()));
logger.info("\nendTimeStr="+format.print(time1.getMillis()).toString());
}
}
\ No newline at end of file
/**
* Copyright (C), 2015-2018
* FileName: pk_押注测试_AccessTest
* Author: qianwenjun
* Date: 2018/8/5 15:40
* Description:
*/
package http.cases.PkTest;
import base.DuibaLog;
import base.DuibaTestBase;
import http.service.Activity.PkService;
import http.service.hd.DeveloperConfigService;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.testng.Assert;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* 〈〉
*
* @author qianwenjun
* @create 2018/8/5
* @since 1.0.0
*/
public class pk_押注测试_AccessTest extends DuibaTestBase {
@Autowired
PkService pkService;
@Autowired
DeveloperConfigService developerConfigService;
private DuibaLog logger = DuibaLog.getLogger();
private static Integer uid01 = 3416;//【勿动】pk01_测试押注
private static String uid01_consumerId = "100066015";
private static Integer uid02 = 3417;//【勿动】pk02_积分不足_测试押注
private static String uid02_consumerId = "100066016";
private List<String> orderIds = new ArrayList<>();
@BeforeMethod
public void clearUp() {
try {
Boolean result = jdbc.update("delete from act_record.tb_bet_record where bet_id = '124' and partner_user_id = '3416'\n");
Boolean result2 = jdbc.update("delete from activity_order_con.tb_trade_center_activity_order_0735 where activity_type = 'bet' and duiba_activity_id = '124'\n");
}catch (Exception e){
e.printStackTrace();
}
}
@Test
public void 押注测试() throws Exception{
Map<String,Object> user = jdbc.findSimpleResult("select * from dafuweng.user where id=?\n",uid01);
Map<String,Object> consumer = jdbc.findSimpleResult("select * from new_consumer.consumer_0010 where id=?\n",uid01_consumerId);
Long userCredit = Long.parseLong(user.get("credits").toString());
Long consumerCredit = Long.parseLong(consumer.get("credits").toString());
Response doJoinResponse = pkService.doJoin(uid01,"124","248");
doJoinResponse.prettyPrint();
Assert.assertEquals(doJoinResponse.jsonPath().getString("code"),"200","校验押注是否成功且不是第一次押注失败");
String orderId = doJoinResponse.jsonPath().getString("data");
orderIds.add(orderId);
Response statusResponse = pkService.getOrderStatus(uid01,orderId);
statusResponse.prettyPrint();
String consumerStatus = statusResponse.jsonPath().getString("data.consumeStatus");
int i=8;
while (i>0&consumerStatus.equals("1")){
Thread.sleep(1000);
statusResponse = pkService.getOrderStatus(uid01,orderId);
consumerStatus = statusResponse.jsonPath().getString("data.consumeStatus");
}
Assert.assertEquals(consumerStatus,"2","校验押注是否成功,扣积分是否成功失败");
Map<String,Object> user1 = jdbc.findSimpleResult("select * from dafuweng.user where id=?\n",uid01);
Map<String,Object> consumer1 = jdbc.findSimpleResult("select * from new_consumer.consumer_0010 where id=?\n",uid01_consumerId);
String userCredit1 = user1.get("credits").toString();
String consumerCredit1 = consumer1.get("credits").toString();
Assert.assertEquals(userCredit1,String.valueOf(userCredit-200),"user积分扣除校验失败");
Assert.assertEquals(consumerCredit1,String.valueOf(consumerCredit-200),"consumer积分扣除校验失败");
logger.info("校验积分消耗成功,原积分值="+userCredit+",消耗后积分值为"+userCredit1);
//参加过一次之后,不能再参加该pk活动
Response doJoinResponse1 = pkService.doJoin2(uid01,"124","248");
doJoinResponse1.prettyPrint();
Assert.assertEquals(doJoinResponse1.jsonPath().getString("success"),"false","校验参加结果失败");
Assert.assertEquals(doJoinResponse1.jsonPath().getString("code"),"100011","校验参加失败错误码失败");
Assert.assertEquals(doJoinResponse1.jsonPath().getString("desc"),"活动已参加","校验参加失败描述失败");
}
@Test
public void 押注_积分不足测试() throws Exception {
Map<String,Object> user = jdbc.findSimpleResult("select * from dafuweng.user where id=?\n",uid02);
Map<String,Object> consumer = jdbc.findSimpleResult("select * from new_consumer.consumer_0010 where id=?\n",uid02_consumerId);
Long userCredit = Long.parseLong(user.get("credits").toString());
Long consumerCredit = Long.parseLong(consumer.get("credits").toString());
logger.info("开发者积分库积分值="+userCredit+",兑吧积分库积分值为"+consumerCredit);
Response appInfoResponse = developerConfigService.getAppInfo();
appInfoResponse.prettyPrint();
String earnCreditsUrl = appInfoResponse.jsonPath().getString("data.earnCreditsUrl");
Response doJoinResponse = pkService.doJoin2(uid02,"124","248");
doJoinResponse.prettyPrint();
Assert.assertEquals(doJoinResponse.jsonPath().getString("success"),"false","校验参加结果失败");
Assert.assertEquals(doJoinResponse.jsonPath().getString("code"),"100009","校验参加失败错误码失败");
Assert.assertEquals(doJoinResponse.jsonPath().getString("desc"),earnCreditsUrl,"校验参加失败描述失败");
}
@Test
public void 押注_未登陆测试() throws Exception{
Response doJoinResponse = pkService.doJoin3("124","248");
doJoinResponse.prettyPrint();
Assert.assertEquals(doJoinResponse.jsonPath().getString("success"),"false","校验参加结果失败");
Assert.assertEquals(doJoinResponse.jsonPath().getString("code"),"00000001","校验参加失败错误码失败");
Assert.assertEquals(doJoinResponse.jsonPath().getString("desc"),"用户未登录","校验参加失败描述失败");
}
@AfterMethod
public void tearDown() {
try {
Boolean result = jdbc.update("delete from act_record.tb_bet_record where bet_id = '124' and partner_user_id = '3416'\n");
for (String orderId:orderIds){
Boolean result2 = jdbc.update("delete from activity_order_con.tb_trade_center_activity_order_0735 where order_num = ?\n",orderId);
}
}catch (Exception e){
e.printStackTrace();
}
}
}
\ No newline at end of file
/**
* Copyright (C), 2015-2018
* FileName: pk_管理端测试_AccessTest
* Author: qianwenjun
* Date: 2018/7/31 15:46
* Description:
*/
package http.cases.PkTest;
import base.DuibaLog;
import base.DuibaTestBase;
import com.alibaba.fastjson.JSON;
import http.model.BetMngVo;
import http.service.Manager.PkActivityService;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.Test;
import utils.MatcherString;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 〈〉
*
* @author qianwenjun
* @create 2018/7/31
* @since 1.0.0
*/
public class pk_管理端测试_AccessTest extends DuibaTestBase {
@Autowired
PkActivityService pkActivityService;
private static DuibaLog logger = DuibaLog.getLogger();
private String endTime = "2021-12-31 23:55:00";
private Map<String,Object> betIds = new HashMap<>();
private String groupId = "5";
@Test
public void 创建pk活动_瓜分红包测试() {
try {
Response oldBetList = pkActivityService.getMngBetList();
// oldBetList.prettyPrint();
String oldTotal = oldBetList.jsonPath().getString("data.params.total");
createPk("2");
Response newBetList = pkActivityService.getMngBetList();
String newTotal = newBetList.jsonPath().getString("data.params.total");
logger.info("创建之前的列表中条数为:"+oldTotal+"创建之后的列表中条数为:"+newTotal);
Assert.assertEquals(String.valueOf(Long.valueOf(newTotal)-1L),oldTotal,"新建之后列表获取数据校验失败");
List<BetMngVo> betList = newBetList.jsonPath().getList("data.page",BetMngVo.class);
logger.info("betIds"+JSON.toJSONString(betIds));
for (BetMngVo bet:betList){
if (bet.getId().equals(betIds.get("2"))){
logger.info("bet的信息为="+JSON.toJSONString(bet));
Assert.assertEquals(bet.getBetType(),"1","校验pk活动单选单次类型失败");
Assert.assertEquals(bet.getBonusType(),"2","校验pk活动瓜分类型失败");
Assert.assertEquals(bet.getBonusAmount(),"0.10","校验pk活动瓜分类型失败");
Assert.assertEquals(bet.getTitle(),"【自动化】新建pk活动-瓜分红包","校验pk活动名称失败");
Assert.assertEquals(bet.getConfigStatus(),"3","校验pk活动状态失败");
Assert.assertEquals(bet.getEndTime(),"2021-12-31 23:55","校验pk活动结束时间失败");
}else{
break;
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
@Test
public void 创建pk活动_瓜分经验测试() {
try {
Response oldBetList = pkActivityService.getMngBetList();
String oldTotal = oldBetList.jsonPath().getString("data.params.total");
logger.info("创建之前的列表中条数为:"+oldTotal);
createPk("1");
Response newBetList = pkActivityService.getMngBetList();
String newTotal = newBetList.jsonPath().getString("data.params.total");
logger.info("创建之前的列表中条数为:"+oldTotal+"创建之后的列表中条数为:"+newTotal);
Assert.assertEquals(String.valueOf(Long.valueOf(newTotal)-1L),oldTotal,"新建之后列表获取数据校验失败");
List<BetMngVo> betList = newBetList.jsonPath().getList("data.page",BetMngVo.class);
logger.info("betIds"+JSON.toJSONString(betIds));
for (BetMngVo bet:betList){
if (bet.getId().equals(betIds.get("1"))){
logger.info("bet的信息为="+JSON.toJSONString(bet));
Assert.assertEquals(bet.getBetType(),"1","校验pk活动单选单次类型失败");
Assert.assertEquals(bet.getBonusType(),"1","校验pk活动瓜分类型失败");
Assert.assertEquals(bet.getBonusAmount(),"0.00","校验pk活动瓜分类型失败");
Assert.assertEquals(bet.getTitle(),"【自动化】新建pk活动-瓜分经验","校验pk活动名称失败");
Assert.assertEquals(bet.getConfigStatus(),"3","校验pk活动状态失败");
Assert.assertEquals(bet.getEndTime(),"2021-12-31 23:55","校验pk活动结束时间失败");
}else{
break;
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
public void createPk(String bounsType) throws Exception {
Response betResponse = pkActivityService.bet(bounsType,endTime);
String betId = MatcherString.getString(betResponse.asString(),"\"data\": (\\w*)",1);
logger.info("betId的信息为"+betId);
betIds.put(bounsType,betId);
Response betRelation = pkActivityService.betGroupRelation(betId,endTime,groupId);
Response modifyStatusResponse = pkActivityService.modifySatus(betId);
}
@AfterClass
public void tearDown() {
try {
Boolean result = jdbc.update("delete from act_com_conf.tb_bet_group_relation where bet_id in (select id from act_com_conf.tb_bet_config where title = \"【自动化】新建pk活动-瓜分经验\" OR title = \"【自动化】新建pk活动-瓜分红包\")\n");
Boolean result1 = jdbc.update("delete from act_com_conf.tb_bet_config where title = \"【自动化】新建pk活动-瓜分经验\" OR title = \"【自动化】新建pk活动-瓜分红包\"\n");
} catch (SQLException e) {
e.printStackTrace();
}
}
}
\ 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