Commit cef0e30b authored by 赵然's avatar 赵然

Merge branch 'master' of gitlab2.dui88.com:mabo/test-platform

parents 3c1e80ee 1bcc531a
package http.cases.ExchangeTest;
import base.DuibaBase;
import base.DuibaBases;
import http.service.Activity.ManagerService;
import http.service.Authorization;
import http.service.app.MobileService;
import http.service.app.gawService;
import http.service.app.tawService;
import http.service.hd.DeveloperAccountService;
import http.service.hd.DappConfigService;
import org.apache.logging.log4j.core.pattern.AbstractStyleNameConverter;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import utils.MatcherString;
import base.DuibaLog;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.Test;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import utils.RedisUtil;
import static io.restassured.RestAssured.given;
/**
* Created by lvwenyan on 2019/3/19.
*/
public class 兑吧新实物_兑换流程测试_ExchangeTest extends CheckTemplet {
@Autowired
gawService gawService;
@Autowired
tawService tawService;
@Autowired
MobileService mobileService;
@Autowired
Authorization authorization;
int uid = 6866;
@Test(description = "兑吧新实物每人限购每日限制")
public void 每人限购每日限制测试() throws Exception {
String appItemId = "192950";
String itemId = "32439";
String message = "";
try{
//第一次兑换
Response response = gawService.objectExchange(uid,appItemId,itemId);
String orderId = response.jsonPath().getString("data.orderId");
//获取兑换结果
response = tawService.orderStatus(orderId,uid);
response.prettyPrint();
String status = response.jsonPath().getString("data.status");
Assert.assertEquals(status,"wait_delivery");
Response detailResponse = mobileService.detail(authorization.dafuwengLogin(uid),itemId);
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
logger.info("商品兑换按钮:" + exchangeText);
//第二次兑换
Thread.sleep(3000);
try{
response = gawService.objectExchange(uid,appItemId,itemId);
response.prettyPrint();
}catch (Exception e){
message = e.toString();
}
logger.info(message);
Assert.assertTrue(message.contains("今日已达兑换上限"),"校验message失败");
Assert.assertTrue(message.contains("\"success\":false"),"校验success失败");
Assert.assertEquals(exchangeText,"今日已达兑换上限","校验兑换按钮失败");
logger.info("校验实物用户每日限制消费成功");
}catch (Exception e){
throw new Exception("异常信息打印:" + e);
}finally {
jdbc.update("DELETE FROM credits_dev.consumer_limit_record WHERE item_id = '"+itemId+"'");
}
}
}
......@@ -111,7 +111,7 @@ public class 新集卡_助力发集卡_DuibaTest extends DuibaTestBase {
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+ "'";
String selectSql = "select * from " +cardDb+" where consumer_id = '" + consumerId + "' and item_id = '" +itemId+ "'" +" and item_type = '0'" ;
logger.info("查询集卡信息的sql为:"+selectSql);
Map<String,Object> cardDbInfo = jdbc.findSimpleResult(selectSql);
String item_count = cardDbInfo.get("item_count").toString();
......@@ -120,7 +120,7 @@ public class 新集卡_助力发集卡_DuibaTest extends DuibaTestBase {
//助力用户的集卡信息
String selectSql1 = "select * from " +helpUserCardDb+" where consumer_id = '" + user.get("consumerId") + "' and item_id = '" +itemId+ "'";
String selectSql1 = "select * from " +helpUserCardDb+" where consumer_id = '" + user.get("consumerId") + "' and item_id = '" +itemId+ "'" +" and item_type = '0'";
logger.info("助力用户查询集卡信息的sql为:"+selectSql1);
Map<String,Object> cardDbInfo1 = jdbc.findSimpleResult(selectSql1);
Assert.assertEquals(cardDbInfo1.size(),0,"助力用户的卡片数量为0失败");
......
......@@ -12,6 +12,7 @@ import base.DuibaTestBase;
import cn.com.duiba.activity.center.api.dto.activity.CLRewardDto;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import http.model.CollectGoodsInfo;
import http.service.Activity.NewCollectActivityService;
import http.service.Manager.GetManagerInfoService;
......@@ -47,6 +48,7 @@ public class 新集卡_开奖流程_DuibaTest extends DuibaTestBase {
private static DuibaLog logger = DuibaLog.getLogger();
String orderNum = null;
String nomalOrderId = null;
@DataProvider
public Iterator<Object[]> provideMethod(Method method) {
......@@ -151,22 +153,60 @@ public class 新集卡_开奖流程_DuibaTest extends DuibaTestBase {
}
// @Test
@Test
public void 集卡开奖_直接出奖_奖品库存不足() throws Exception {
String activityId = "2718";
String collectRuleId = "4444";
Integer uid = 3835;
String consumerId = "100090009";
String activityId = "3610";
String collectRuleId = "5182";
Integer uid = 6921;
String consumerId = "100144018";
Response playReasponse = this.playPlugin(activityId, collectRuleId, uid);
playReasponse.prettyPrint();
// Response playReasponse = this.playPlugin(activityId, collectRuleId, uid);
// playReasponse.prettyPrint();
Response collectGoodsInfo = newCollectActivityService.getCollectGoodsInfo(collectRuleId,uid);
collectGoodsInfo.prettyPrint();
Integer count = null;
List<CollectGoodsInfo> MyColInfos = collectGoodsInfo.jsonPath().getList("collectGoods",CollectGoodsInfo.class);
for (CollectGoodsInfo info:MyColInfos){
if (info.getId().equals("32472")){
count = Integer.valueOf(info.getCount());
logger.info("用户卡片itemId="+"32472"+"的数量为:"+count);
break;
Response openResponse = newCollectActivityService.openCollectGoodsPrize(collectRuleId,uid);
String orderId = openResponse.jsonPath().getString("orderId");
}
}
Assert.assertEquals(collectGoodsInfo.jsonPath().getString("prizeLevel"),"4","集卡信息接口可开奖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"),"0","校验开奖接口失败");
Assert.assertEquals(openPrizeResponse.jsonPath().getString("lotteryCode"),"0","校验开奖类型lotteryCode失败");
Response afterCollectGoodsInfo = newCollectActivityService.getCollectGoodsInfo(collectRuleId,uid);
afterCollectGoodsInfo.prettyPrint();
Integer afterCount = null;
List<CollectGoodsInfo> afterMyColInfos = afterCollectGoodsInfo.jsonPath().getList("collectGoods",CollectGoodsInfo.class);
for (CollectGoodsInfo info:afterMyColInfos){
if (info.getId().equals(32472)){
afterCount = Integer.valueOf(info.getCount());
Assert.assertEquals(count,afterCount);
logger.info("用户卡片itemId=32472"+"的数量为:"+count);
logger.info("校验卡片返回成功");
break;
}
}
Map<String,Object> openOrder = jdbc.findSimpleResult("SELECT * FROM activity_order_con.tb_trade_center_activity_order_0914 WHERE order_num = ?\n",nomalOrderId);
logger.info(JSON.toJSONString(openOrder));
Assert.assertEquals(openOrder.get("exchange_status").toString(),"3","开奖订单状态校验失败");
Assert.assertEquals(openOrder.get("error4consumer").toString(),"item 扣库存失败","开奖失败错误信息校验失败");
Assert.assertEquals(openOrder.get("item_id").toString(),"32474","库存不足的兑换项id校验失败");
Response statusResponse = newCollectActivityService.getOpenOrderStatus(orderId,uid);
String playResult = String.valueOf(statusResponse.jsonPath().getString("result"));
//奖品库存不足,发奖接口调用成功,订单生成,exchange_status=3,message标明扣库存失败;用户卡片扣除。
}
......@@ -432,6 +472,7 @@ public class 新集卡_开奖流程_DuibaTest extends DuibaTestBase {
String orderId = null;
if (type.equals("nomal")){
orderId = openResponse.jsonPath().getString("orderId");
nomalOrderId = orderId;
}else if (type.equals("plugin")){
orderId = openResponse.jsonPath().getString("orderId.orderNum");
orderNum = orderId;
......@@ -439,7 +480,7 @@ public class 新集卡_开奖流程_DuibaTest extends DuibaTestBase {
Response statusResponse = newCollectActivityService.getOpenOrderStatus(orderId,uid);
String playResult = String.valueOf(statusResponse.jsonPath().getString("result"));
int i = 8;
int i = 16;
while (i > 0 && (playResult.equals("0"))) {
Thread.sleep(1000);
statusResponse = newCollectActivityService.getOpenOrderStatus(orderId,uid);
......
/**
* Copyright (C), 2015-2019
* FileName: 新集卡_插件开奖异常返卡_DuibaTest
* Author: qianwenjun
* Date: 2019/3/20 14:12
* Description:
*/
package http.cases.NewCollectActivityTest;
import base.DuibaBase;
import base.DuibaLog;
import base.DuibaTestBase;
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.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 2019/3/20
* @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/新集卡_插件出奖异常返卡");
}
return result;
}
@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 itemId = data.get("itemId");
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");
Response collectGoodsInfo = newCollectActivityService.getCollectGoodsInfo(collectRuleId,uid);
collectGoodsInfo.prettyPrint();
Integer count = null;
List<CollectGoodsInfo> MyColInfos = collectGoodsInfo.jsonPath().getList("collectGoods",CollectGoodsInfo.class);
for (CollectGoodsInfo info:MyColInfos){
if (info.getId().equals(itemId)){
count = Integer.valueOf(info.getCount());
logger.info("用户卡片itemId="+itemId+"的数量为:"+count);
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"),"1","校验开奖接口失败");
Assert.assertEquals(openPrizeResponse.jsonPath().getString("lottery.type"),prizeType,"校验开奖类型object失败");
logger.info("校验开奖成功,开奖的奖项类型为:"+openPrizeResponse.jsonPath().getString("lottery.type"));
Response afterCollectGoodsInfo = newCollectActivityService.getCollectGoodsInfo(collectRuleId,uid);
afterCollectGoodsInfo.prettyPrint();
Integer afterCount = null;
List<CollectGoodsInfo> afterMyColInfos = afterCollectGoodsInfo.jsonPath().getList("collectGoods",CollectGoodsInfo.class);
for (CollectGoodsInfo info:afterMyColInfos){
if (info.getId().equals(itemId)){
afterCount = Integer.valueOf(info.getCount());
Assert.assertEquals(count,afterCount);
logger.info("用户卡片itemId="+itemId+"的数量为:"+count);
logger.info("校验卡片返回成功");
break;
}
}
Assert.assertEquals(afterCollectGoodsInfo.jsonPath().getString("prizeLevel"),afterPrizeLevel,"集卡信息接口可开奖prizeLevel字段校验失败");
Assert.assertEquals(afterCollectGoodsInfo.jsonPath().getString("clickFlag"),afterClickFlag,"是否可点击开奖clickFlag校验失败");
}
// @Test
public void 集卡开奖_单接口调试() throws Exception {
//手动开奖——开
String activityId = "2741";
String collectRuleId = "5182";
Integer uid = 6922;
String consumerId = "100091476";
String count = "1";
String afterCount = "0";
String prizeLevel = "5";
String afterPrizeLevel = "0";
String clickFlag = "true";
String afterClickFlag = "false";
String prizeType = "thanks";
String openResult = "2";
this.playPlugin("3612","5182",6922);
consumerId = "100143586";
Response collectGoodsInfo = newCollectActivityService.getCollectGoodsInfo(collectRuleId,uid);
collectGoodsInfo.prettyPrint();
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,"nomal");
openPrizeResponse.prettyPrint();
Assert.assertEquals(openPrizeResponse.jsonPath().getString("result"),"1","校验开奖接口失败");
Assert.assertEquals(openPrizeResponse.jsonPath().getString("lottery.type"),prizeType,"校验开奖类型object失败");
logger.info("校验开奖成功,开奖的奖项类型为:"+openPrizeResponse.jsonPath().getString("lottery.type"));
Response afterCollectGoodsInfo = newCollectActivityService.getCollectGoodsInfo(collectRuleId,uid);
afterCollectGoodsInfo.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,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 = 16;
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
......@@ -77,6 +77,17 @@ public class pk_押注测试_AccessTest extends DuibaTestBase {
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");
Boolean result3 = jdbc.update("delete from act_record.tb_bet_record where bet_id = '82' and partner_user_id = '5244'\n");
Boolean result6 = jdbc.update("delete from activity_order_con.tb_trade_center_activity_order_0522 where activity_type = 'bet' and duiba_activity_id = '82'\n");
Boolean result4 = jdbc.update("delete from act_record.tb_bet_record where bet_id = '122' and partner_user_id = '5247'\n");
Boolean result7 = jdbc.update("delete from activity_order_con.tb_trade_center_activity_order_0525 where activity_type = 'bet' and duiba_activity_id = '122'\n");
Boolean result5 = jdbc.update("delete from act_record.tb_bet_record where bet_id = '83' and partner_user_id = '5248'\n");
Boolean result8 = jdbc.update("delete from activity_order_con.tb_trade_center_activity_order_0526 where activity_type = 'bet' and duiba_activity_id = '83'\n");
}catch (Exception e){
e.printStackTrace();
}
......
package http.service.app;
import base.DuibaLog;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import http.service.Authorization;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.testng.Assert;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static io.restassured.RestAssured.given;
@Service
public class gawService {
@Value("${goods.host}")
private String goodsHost;
@Autowired
Authorization authorization;
private DuibaLog logger = DuibaLog.getLogger();
//普通实物兑换接口
public Response objectExchange(int uid, String appItemId,String itemId) throws Exception {
Map<String,Object> map = new HashMap<>();
Map<String,Object> mapList = new HashMap<>();
List<Map> list = new ArrayList<>();
mapList.put("itemId",itemId);
mapList.put("skuId",16);
mapList.put("appItemId",appItemId);
mapList.put("credits","100");
mapList.put("price",0);
list.add(mapList);
map.put("remark",""); //买家留言
map.put("degreeId","");
map.put("actualPrice","0"); //总金额
map.put("actualCredits","100"); //总积分
map.put("itemParam",list.toArray());
map.put("payType","3");
map.put("expressPrice","0");
map.put("validate","");
map.put("token","yrJRr7Cddp2YeQd");
JSONObject jsonParam = JSONObject.parseObject(JSON.toJSONString(map));
logger.info("请求实物兑换接口:"+ "/gaw/objectExchange/create");
Response response = given().contentType("application/json; charset=UTF-8").cookies(authorization.dafuwengLogin(uid)).body(jsonParam).post("http://"+goodsHost+"/gaw/objectExchange/create");
// Response saveResponse = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.dafuwengLogin(uid)).params(map).post("http://"+goodsHost+"/gaw/objectExchange/create");
// response.prettyPrint();
try{
Assert.assertEquals(response.jsonPath().getString("success"),"true");
}catch(Exception e){
throw new Exception("/gaw/objectExchange/create接口返回异常,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/gaw/objectExchange/create接口返回异常,返回信息:"+response.asString());
}
return response;
}
}
......@@ -45,4 +45,28 @@ public class tawService {
}
//订单轮询接口
public Response orderStatus(String orderId,int uid) throws Exception{
Map<String,String> map = new HashMap<>();
map.put("orderId",orderId);
Response response = given().cookies(authorization.dafuwengLogin(uid)).params(map).get("http://"+tradeHost+"/taw/h5/orderStatus");
try{
Assert.assertEquals(response.jsonPath().getString("success"),"true","/taw/h5/orderStatus接口失败");
}catch(Exception e){
throw new Exception("/taw/h5/orderStatus接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/taw/h5/orderStatus接口失败,返回信息:"+response.asString());
}
return response;
}
}
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