Commit 6bdcbdbc authored by 吕雯燕's avatar 吕雯燕

lv

parent ca442d1f
......@@ -40,8 +40,8 @@ public class 集卡活动助力_AccessTest extends DuibaTestBase {
@Test(description = "集卡活动助力测试")
public void 集卡活动助力成功() throws Exception{
int uid1 = 7407;
int uid2 = 7402;
int uid1 = 7407; //助力用户
int uid2 = 7402; //被助力用户
String activityId = "45502";
String shareCode = "11nmxcq";
......@@ -67,7 +67,7 @@ public class 集卡活动助力_AccessTest extends DuibaTestBase {
Assert.assertEquals(helpResponse.jsonPath().getString("data.inviter"),"100164132","校验inviter失败");
Assert.assertEquals(helpResponse.jsonPath().getString("data.invitee"),"100166015","校验invitee失败");
Assert.assertEquals(resultCount,count+1,"校验助力得卡失败");
logger.info("校验集卡助力者获得助力奖励成功");
logger.info("校验集卡助力者获得助力奖励通过");
//被助力用户7402
......@@ -78,9 +78,29 @@ public class 集卡活动助力_AccessTest extends DuibaTestBase {
indexResponse2 = clcardService.activity(uid2,activityId);
int resultCount2 = Integer.parseInt(indexResponse2.jsonPath().getString("data.cards[0].count"));
logger.info("被助力后用户卡数量:" + resultCount2);
Assert.assertEquals(resultResponse.jsonPath().getString("data.cardCount"),"1","校验cardCount失败");
Assert.assertEquals(resultResponse.jsonPath().getString("desc"),"OK","校验desc失败");
Assert.assertEquals(resultCount2,count2+1,"校验被助力得卡失败");
logger.info("校验集卡被助力者获得被助力奖励成功");
logger.info("校验集卡被助力者获得被助力奖励通过");
}
@Test(description = "重复助力失败测试")
public void 集卡活动助力失败() throws Exception{
int uid1 = 7424; //助力用户
String activityId = "45502";
String shareCode = "11nmywe"; //被助力用户 7416
//助力用户 7424
//开始助力
Response helpResponse = clcardService.doHelpNew2(uid1,activityId,shareCode);
helpResponse.prettyPrint();
Assert.assertEquals(helpResponse.jsonPath().getString("success"),"false","校验success失败");
Assert.assertEquals(helpResponse.jsonPath().getString("desc"),"单个好友助力上限","校验desc失败");
logger.info("校验集卡重复助力失败测试通过");
......
......@@ -6,11 +6,14 @@ import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import java.sql.SQLException;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CopyOnWriteArrayList;
/**
* Created by lvwenyan on 2019/11/28
......@@ -21,20 +24,26 @@ public class 集卡活动领奖_AccessTest extends DuibaTestBase {
@Autowired
ClcardService clcardService;
@BeforeMethod
private List<String> resultList = new CopyOnWriteArrayList<>();
@BeforeClass
public void before(){
try {
//修改表,增加用户卡片
//修改表,增加用户卡片,"集卡领奖成功"
jdbc.update("update collect_card_consumer.tb_collect_card_info_0548 set item_count = item_count +1 , item_total_count = item_total_count +1 WHERE consumer_id = 100164132 AND item_id = 12");
jdbc.update("update collect_card_consumer.tb_collect_card_info_0548 set item_count = item_count +2 , item_total_count = item_total_count +2 WHERE consumer_id = 100164132 AND item_id = 13");
jdbc.update("update collect_card_consumer.tb_collect_card_info_0548 set item_count = item_count +3 , item_total_count = item_total_count +3 WHERE consumer_id = 100164132 AND item_id = 14");
//修改表,增加用户卡片,"A_集卡单用户并发领奖"
jdbc.update("update collect_card_consumer.tb_collect_card_info_0332 set item_count = item_count +1 , item_total_count = item_total_count +1 WHERE consumer_id = 100168012 AND item_id = 20");
jdbc.update("update collect_card_consumer.tb_collect_card_info_0332 set item_count = item_count +1 , item_total_count = item_total_count +1 WHERE consumer_id = 100168012 AND item_id = 21");
} catch (SQLException e) {
e.printStackTrace();
}
}
......@@ -45,24 +54,36 @@ public class 集卡活动领奖_AccessTest extends DuibaTestBase {
String activityId = "45501";
//集卡领奖
Response openPrizeResponse = clcardService.openPrize(uid,activityId);
openPrizeResponse.prettyPrint();
String desc = openPrizeResponse.jsonPath().getString("desc");
Response response = clcardService.openPrize(uid,activityId);
String orderNum = response.jsonPath().getString("data.orderNum");
response = clcardService.getOrderStatus(uid,orderNum);
response.prettyPrint();
String result = String.valueOf(response.jsonPath().getString("result"));
int i= 30;
while(i>0&&(result.equals("0"))){
Thread.sleep(500);
response = clcardService.getOrderStatus(uid,orderNum);
result = String.valueOf(response.jsonPath().getString("result"));
i--;
response.prettyPrint();
}
//活动首页信息
Response response = clcardService.activity(uid,activityId);
Response indexResponse = clcardService.activity(uid,activityId);
response.prettyPrint();
String cards0 = response.jsonPath().getString("data.cards[0].count");
String cards1 = response.jsonPath().getString("data.cards[1].count");
String cards2 = response.jsonPath().getString("data.cards[2].count");
String rules0 = response.jsonPath().getString("data.prizes[0].rules[0].cardCount");
String rules1 = response.jsonPath().getString("data.prizes[0].rules[1].cardCount");
String rules2 = response.jsonPath().getString("data.prizes[0].rules[2].cardCount");
Assert.assertEquals(desc,"OK","校验desc失败");
Assert.assertEquals(cards0,"0","校验card0失败");
Assert.assertEquals(cards1,"0","校验card1失败");
Assert.assertEquals(cards2,"1","校验card2失败");
String cards0 = indexResponse.jsonPath().getString("data.cards[0].count");
String cards1 = indexResponse.jsonPath().getString("data.cards[1].count");
String cards2 = indexResponse.jsonPath().getString("data.cards[2].count");
String rules0 = indexResponse.jsonPath().getString("data.prizes[0].rules[0].cardCount");
String rules1 = indexResponse.jsonPath().getString("data.prizes[0].rules[1].cardCount");
String rules2 = indexResponse.jsonPath().getString("data.prizes[0].rules[2].cardCount");
Assert.assertEquals(response.jsonPath().getString("lottery.title"),"支付宝","校验奖品title失败");
Assert.assertEquals(response.jsonPath().getString("result"),"2","校验result失败");
Assert.assertEquals(cards0,"1","校验card0失败");
Assert.assertEquals(cards1,"2","校验card1失败");
Assert.assertEquals(cards2,"4","校验card2失败");
Assert.assertEquals(rules0,"1","校验rules0失败");
Assert.assertEquals(rules1,"2","校验rules1失败");
Assert.assertEquals(rules2,"3","校验rules2失败");
......@@ -72,6 +93,82 @@ public class 集卡活动领奖_AccessTest extends DuibaTestBase {
}
@Test(description = "集卡活动领奖库存不足测试")
public void 集卡领奖库存不足() throws Exception{
int uid = 7414;
String activityId = "45530";
Response response = clcardService.openPrize(uid,activityId);
// response.prettyPrint();
String orderNum = response.jsonPath().getString("data.orderNum");
response = clcardService.getOrderStatus(uid,orderNum);
response.prettyPrint();
String result = String.valueOf(response.jsonPath().getString("result"));
int i= 30;
while(i>0&&(result.equals("0"))){
Thread.sleep(500);
response = clcardService.getOrderStatus(uid,orderNum);
result = String.valueOf(response.jsonPath().getString("result"));
i--;
response.prettyPrint();
}
//库存不足,接口会轮询处理超时
Assert.assertEquals(result,"0","校验result失败");
Assert.assertEquals(response.jsonPath().getString("takeSuccess"),"false","校验takeSuccess失败");
logger.info("集卡大奖库存不足领奖失败");
}
@Test(description = "集卡活动领奖卡片未集齐测试")
public void 集卡领奖卡片未集齐() throws Exception{
int uid = 7415;
String activityId = "45501";
Response response = clcardService.openPrize2(uid,activityId);
response.prettyPrint();
Assert.assertEquals(response.jsonPath().getString("desc"),"卡片还未集齐,请继续集卡","校验desc失败");
logger.info("集卡卡片未集齐领奖失败");
}
//同一用户并发领奖 活动:【自动化】集卡发奖3
@Test(threadPoolSize = 5, invocationCount =5)
public void A_集卡单用户并发领奖() throws Exception {
int uid = 7416;
String activityId = "45531";
//领奖(只有一次兑换机会)
Response response = clcardService.openPrize2(uid,activityId);
resultList.add(response.asString());
logger.info("请求返回结果:" + response.asString());
}
@Test(dependsOnMethods = "A_集卡单用户并发领奖")
public void checkResult(){
int fail = 0;
int success = 0;
for (String s: resultList) {
if(s.contains("desc\":\"服务器开小差了,请稍后重试")){
fail++;
}else if(s.contains("\"desc\":\"OK\"")){
success++;
}else{
System.out.println(s);
}
}
//检验 成功的只有一个。错误提示有多种
Assert.assertEquals(fail,4,"校验fail数量失败");
Assert.assertEquals(success,1,"校验success数量失败");
logger.info("校验集卡单用户并发成功");
}
......
......@@ -5,10 +5,7 @@ import http.service.Activity.HappyCodeNewService;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import org.testng.annotations.*;
import java.lang.reflect.Method;
import java.sql.SQLException;
......@@ -29,7 +26,7 @@ public class 积分夺宝开奖_AccessTest extends DuibaTestBase {
private List<String> multiResultList = new CopyOnWriteArrayList<>();
@BeforeMethod
@BeforeClass
public void before(){
try {
//修改表,phase_status=1 进行中
......
......@@ -55,6 +55,46 @@ public class ClcardService {
}
public Response openPrize2(int uid,String activityId) throws Exception{
Map<String,String> map = new HashMap<>();
map.put("id",activityId);
map.put("grade","1");
map.put("preview","false");
logger.info("请求/hdtool/clcard/openPrize接口");
Response response = given().cookies(authorization.dafuwengLogin(uid)).params(map).post(activityHost+"/hdtool/clcard/openPrize");
return response;
}
/**
* @param orderId 活动id
* @param uid 用户id
* @return
* @throws Exception
*/
public Response getOrderStatus(int uid,String orderId) throws Exception{
Map<String,String> map = new HashMap<>();
map.put("orderId",orderId);
logger.info("请求/plugin/getOrderStatus接口");
Response response = given().cookies(authorization.dafuwengLogin(uid)).params(map).post(activityHost+"/plugin/getOrderStatus");
try {
Assert.assertEquals(response.jsonPath().getString("success"), "true", "/plugin/getOrderStatus接口失败");
} catch (Exception e) {
throw new Exception("/plugin/getOrderStatus接口失败,返回信息:" + response.asString());
} catch (Error er) {
throw new Exception("/plugin/getOrderStatus接口失败,返回信息:" + response.asString());
}
return response;
}
/**
* @param activityId 活动id
* @param uid 用户id
......@@ -112,6 +152,22 @@ public class ClcardService {
}
public Response doHelpNew2(int uid,String activityId,String shareCode) {
Map<String,String> map = new HashMap<>();
map.put("activityId",activityId);
map.put("activityType","hdtool");
map.put("shareCode",shareCode);
map.put("singleLimitType","0");
map.put("subType","clcard");
logger.info("请求/activtyShareCode/doHelpNew接口");
Response response = given().cookies(authorization.dafuwengLogin(uid)).params(map).post(activityHost+"/activtyShareCode/doHelpNew");
return response;
}
/**
* @param activityId 活动id
* @param uid 用户id
......
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