Commit 5d7a149d authored by 吕雯燕's avatar 吕雯燕

lv

parent c8eddab0
package http.cases.ClcardTest;
import base.DuibaTestBase;
import http.service.Activity.ClcardService;
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.Test;
import java.sql.SQLException;
import java.util.Map;
import base.DuibaTestBase;
/**
* Created by lvwenyan on 2019/11/28
*/
public class 集卡活动助力_AccessTest extends DuibaTestBase {
@Autowired
ClcardService clcardService;
@BeforeMethod
public void before(){
try {
//删除助力表数据
jdbc.update("DELETE FROM act_com_conf.tb_share_code_record WHERE share_code = '11nmxcq'");
} catch (SQLException e) {
e.printStackTrace();
}
}
@Test(description = "集卡活动助力测试")
public void 集卡活动助力成功() throws Exception{
int uid1 = 7407;
int uid2 = 7402;
String activityId = "45502";
String shareCode = "11nmxcq";
//首页集卡信息
Response indexResponse = clcardService.activity(uid1,activityId);
int count = Integer.parseInt(indexResponse.jsonPath().getString("data.cards[1].count"));
logger.info("当前助力用户卡数量:" + count);
Response indexResponse2 = clcardService.activity(uid2,activityId);
int count2 = Integer.parseInt(indexResponse2.jsonPath().getString("data.cards[0].count"));
logger.info("当前被助力用户卡数量:" + count2);
//助力用户 7407
//开始助力
Response helpResponse = clcardService.doHelpNew(uid1,activityId,shareCode);
helpResponse.prettyPrint();
Thread.sleep(100);
//首页集卡信息
indexResponse = clcardService.activity(uid1,activityId);
int resultCount = Integer.parseInt(indexResponse.jsonPath().getString("data.cards[1].count"));
logger.info("助力后用户卡数量:" + resultCount);
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("校验集卡助力者获得助力奖励成功");
//被助力用户7402
//获得助力结果
Response resultResponse = clcardService.helpResult(uid2,activityId);
resultResponse.prettyPrint();
//首页集卡信息
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(resultCount2,count2+1,"校验被助力得卡失败");
logger.info("校验集卡被助力者获得被助力奖励成功");
}
}
......@@ -12,6 +12,9 @@ import org.testng.annotations.Test;
import java.sql.SQLException;
import java.util.Map;
/**
* Created by lvwenyan on 2019/11/28
*/
public class 集卡活动领奖_AccessTest extends DuibaTestBase {
......
......@@ -79,4 +79,64 @@ public class ClcardService {
return response;
}
/**
* @param activityId 活动id
* @param uid 用户id
* @param shareCode 邀请码
* @return
* @throws Exception
*/
public Response doHelpNew(int uid,String activityId,String shareCode) throws Exception{
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");
try {
Assert.assertEquals(response.jsonPath().getString("success"), "true", "/activtyShareCode/doHelpNew接口失败");
} catch (Exception e) {
throw new Exception("/activtyShareCode/doHelpNew接口失败,返回信息:" + response.asString());
} catch (Error er) {
throw new Exception("/activtyShareCode/doHelpNew接口失败,返回信息:" + response.asString());
}
return response;
}
/**
* @param activityId 活动id
* @param uid 用户id
* @return
* @throws Exception
*/
public Response helpResult(int uid,String activityId) throws Exception{
Map<String,String> map = new HashMap<>();
map.put("activityId",activityId);
logger.info("请求/hdtool/clcard/helpResult接口");
Response response = given().cookies(authorization.dafuwengLogin(uid)).params(map).get(activityHost+"/hdtool/clcard/helpResult");
try {
Assert.assertEquals(response.jsonPath().getString("success"), "true", "/hdtool/clcard/helpResult接口失败");
} catch (Exception e) {
throw new Exception("/hdtool/clcard/helpResult接口失败,返回信息:" + response.asString());
} catch (Error er) {
throw new Exception("/hdtool/clcard/helpResult接口失败,返回信息:" + 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