Commit 72ab0dc1 authored by 周松波's avatar 周松波

add

parent ec463e6d
...@@ -4,6 +4,8 @@ import base.DuibaLog; ...@@ -4,6 +4,8 @@ import base.DuibaLog;
import base.DuibaTestBase; import base.DuibaTestBase;
import base.MysqlConnPool; import base.MysqlConnPool;
import base.MysqlUtils; import base.MysqlUtils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import http.service.Activity.ManagerService; import http.service.Activity.ManagerService;
import http.service.Activity.ContractSignService; import http.service.Activity.ContractSignService;
import http.service.Authorization; import http.service.Authorization;
...@@ -23,6 +25,7 @@ import java.text.SimpleDateFormat; ...@@ -23,6 +25,7 @@ import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
import static io.restassured.RestAssured.given; import static io.restassured.RestAssured.given;
import static io.restassured.RestAssured.post;
/** /**
* Created by songbo on 2018/9/5. * Created by songbo on 2018/9/5.
...@@ -39,7 +42,8 @@ public class ContractSign_signTest extends DuibaTestBase { ...@@ -39,7 +42,8 @@ public class ContractSign_signTest extends DuibaTestBase {
ManagerService managerService; ManagerService managerService;
@Value("${activity.host}") @Value("${activity.host}")
String activityHost; String activityHost;
String period; private String period;
private String issueId;
// private static DuibaLog logger = DuibaLog.getLogger(); // private static DuibaLog logger = DuibaLog.getLogger();
//指定用户 //指定用户
...@@ -60,9 +64,8 @@ public class ContractSign_signTest extends DuibaTestBase { ...@@ -60,9 +64,8 @@ public class ContractSign_signTest extends DuibaTestBase {
// } // }
//@Test(description = "截止报名测试, 活动ID=3", priority = 10) @Test(description = "截止报名测试, 活动ID=3", priority = 10)
public void 截止报名测试() throws Exception{ public void 截止报名测试() throws Exception{
Map<String,String> map = new HashMap<>(); Map<String,String> map = new HashMap<>();
map.put("activityId", "3"); map.put("activityId", "3");
map.put("betAmount", "1000"); map.put("betAmount", "1000");
...@@ -111,7 +114,7 @@ public class ContractSign_signTest extends DuibaTestBase { ...@@ -111,7 +114,7 @@ public class ContractSign_signTest extends DuibaTestBase {
// 报名 // 报名
Map<String, String> map = this.doJoinResult(actId, betAmount, uid1); Map<String, String> map = this.doJoinResult(actId, betAmount, uid1);
issueId = map.get("issueId");
//int totalCount = Integer.valueOf(map.get("totalCount")); //int totalCount = Integer.valueOf(map.get("totalCount"));
//int buyers = Integer.valueOf(map.get("buyers")); //int buyers = Integer.valueOf(map.get("buyers"));
String doneStatusDesc = map.get("doneStatusDesc"); String doneStatusDesc = map.get("doneStatusDesc");
...@@ -151,7 +154,7 @@ public class ContractSign_signTest extends DuibaTestBase { ...@@ -151,7 +154,7 @@ public class ContractSign_signTest extends DuibaTestBase {
public void 签到打卡() throws Exception{ public void 签到打卡() throws Exception{
String actId = "2"; String actId = "2";
//修改期次,今日为打卡日 //修改期次,今日为打卡日
modifyIssuePeriod(actId,uid1,-1); modifyIssuePeriod(issueId,-1);
Date now = new Date(); Date now = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("MMdd"); SimpleDateFormat sdf = new SimpleDateFormat("MMdd");
String today = sdf.format(now); String today = sdf.format(now);
...@@ -179,11 +182,11 @@ public class ContractSign_signTest extends DuibaTestBase { ...@@ -179,11 +182,11 @@ public class ContractSign_signTest extends DuibaTestBase {
public void 契约签到断签() throws Exception{ public void 契约签到断签() throws Exception{
String actID = "2"; String actID = "2";
//当天为周期第一天,周期往前再挪6天 //当天为周期第一天,周期往前再挪6天
modifyIssuePeriod(actID,uid2,-6); modifyIssuePeriod(issueId,-6);
//补签前5天,第六天不签 //补签前5天,第六天不签
this.contractResign(actID, uid2, 7,true); this.contractResign(actID, uid2, 7,true);
Response homeInfoRes = ContractSignService.getHomeInfo(actID, uid2); Response homeInfoRes = ContractSignService.getHomeInfo(actID, uid2);
homeInfoRes.prettyPrint(); //homeInfoRes.prettyPrint();
String status = homeInfoRes.jsonPath().getString("data.status"); String status = homeInfoRes.jsonPath().getString("data.status");
Assert.assertEquals(status, "5", "当前签到状态不正确"); Assert.assertEquals(status, "5", "当前签到状态不正确");
Date now = new Date(); Date now = new Date();
...@@ -199,33 +202,34 @@ public class ContractSign_signTest extends DuibaTestBase { ...@@ -199,33 +202,34 @@ public class ContractSign_signTest extends DuibaTestBase {
@Test(description = "uid3 uid4打卡完成,活动ID=2",priority = 4) @Test(description = "uid3 uid4打卡完成,活动ID=2",priority = 4)
public void 契约签到整期打卡完成() throws Exception{ public void 契约签到整期打卡完成() throws Exception{
//当前为打卡第6天,周期往期挪一天 String actId = "2";
String actID = "2";
modifyIssuePeriod(actID, uid3, -1);
//补签前6天 //补签前6天
this.contractResign(actID, uid3, 7,false); this.contractResign(actId, uid3, 7,false);
this.contractResign(actID, uid4, 7,false); this.contractResign(actId, uid4, 7,false);
//今日打卡 //今日打卡
Response signRes = ContractSignService.doSign("2", uid3); Response signRes = ContractSignService.doSign("2", uid3);
String success = signRes.jsonPath().getString("success"); String success = signRes.jsonPath().getString("success");
String status = signRes.jsonPath().getString("status");
Assert.assertEquals(success, "true", "uid3打卡失败"); Assert.assertEquals(success, "true", "uid3打卡失败");
Response homeInfoRes = ContractSignService.getHomeInfo(actId,uid3);
String status = homeInfoRes.jsonPath().getString("data.status");
Assert.assertEquals(status,"6","完成7日打卡状态不正确"); Assert.assertEquals(status,"6","完成7日打卡状态不正确");
logger.info("uid3七日打卡成功"); logger.info("uid3七日打卡成功");
signRes = ContractSignService.doSign("2", uid4); signRes = ContractSignService.doSign("2", uid4);
homeInfoRes = ContractSignService.getHomeInfo(actId,uid3);
success = signRes.jsonPath().getString("success"); success = signRes.jsonPath().getString("success");
status = signRes.jsonPath().getString("status"); status = homeInfoRes.jsonPath().getString("data.status");
Assert.assertEquals(success, "true", "uid4打卡失败"); Assert.assertEquals(success, "true", "uid4打卡失败");
Assert.assertEquals(status,"6","完成7日打卡状态不正确"); Assert.assertEquals(status,"6","完成7日打卡状态不正确");
logger.info("uid4七日打卡成功"); logger.info("uid4七日打卡成功");
} }
//@Test(description = "开奖,活动ID=2",priority = 5) @Test(description = "开奖,活动ID=2",priority = 5)
public void 契约开奖() throws Exception{ public void 契约开奖() throws Exception{
modifyIssuePeriod(issueId, -1);
//修改redis的打卡日期键值 //修改redis的打卡日期键值
String actId = "2"; String actId = "2";
Response res = ContractSignService.getContracts(actId, uid2);
String issueId = res.jsonPath().getString("data.list[0].issueId");
Date now = new Date(); Date now = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yy-MM-dd"); SimpleDateFormat sdf = new SimpleDateFormat("yy-MM-dd");
String today = sdf.format(now); String today = sdf.format(now);
...@@ -244,11 +248,11 @@ public class ContractSign_signTest extends DuibaTestBase { ...@@ -244,11 +248,11 @@ public class ContractSign_signTest extends DuibaTestBase {
// 查询下期是否开始 // 查询下期是否开始
Response homeInfoRes = ContractSignService.getHomeInfo(actId, uid3); Response homeInfoRes = ContractSignService.getHomeInfo(actId, uid3);
homeInfoRes.prettyPrint(); //homeInfoRes.prettyPrint();
String periodShow = homeInfoRes.jsonPath().getString("data.periodShow"); String periodShow = homeInfoRes.jsonPath().getString("data.periodShow");
Assert.assertEquals(periodShow, period, "参与期次号不正确"); Assert.assertEquals(periodShow, period, "参与期次号不正确");
String status = homeInfoRes.jsonPath().getString("data.status"); String status = homeInfoRes.jsonPath().getString("data.status");
Assert.assertEquals(status, "0", "当前参与状态不正确"); Assert.assertEquals(status, "6", "当前参与状态不正确");
// 查询中奖信息 // 查询中奖信息
Response recordRes = ContractSignService.getContracts(actId, uid3); Response recordRes = ContractSignService.getContracts(actId, uid3);
String contractId = recordRes.jsonPath().getString("data.list[0].contractId"); String contractId = recordRes.jsonPath().getString("data.list[0].contractId");
...@@ -314,29 +318,33 @@ public class ContractSign_signTest extends DuibaTestBase { ...@@ -314,29 +318,33 @@ public class ContractSign_signTest extends DuibaTestBase {
} }
private void modifyJoinTime(String actId, String date, String startTime, String endTime) throws Exception{ private void modifyJoinTime(String actId, String date, String startTime, String endTime) throws Exception{
Map<String, String> map = new HashMap<>(); String jsonBody = String.format("{" +
map.put("title", "自动化_报名截止时间"); "\"title\":\"自动化_报名截止时间\"," +
map.put("betCount", "1000"); "\"betCount\":1000," +
map.put("bonusType","0"); "\"betType\":2," +
map.put("betType","2"); "\"openType\":0," +
map.put("bankerBonus", "10000"); "\"rangeList\":[]," +
map.put("ruleDesc:", "<p>bao ming&nbsp;截止时间</p>"); "\"enableAmpifyCard\":false," +
map.put("contractCycle","7"); "\"bonusType\":0," +
map.put("joinTimeLimit", "false"); "\"bankerBonus\":10000," +
map.put("fakeLimit", "false"); "\"ruleDesc\":null," +
map.put("rankPeriod","1"); "\"contractCycle\":7," +
map.put("joinTimeStart", startTime); "\"joinTimeLimit\":false," +
map.put("joinTimeEnd", endTime); "\"fakeLimit\":false," +
map.put("joinDeadLine", date); "\"rankPeriod\":1," +
map.put("actId", actId); "\"mockValue\":0," +
map.put("openStatus", "true"); "\"joinTimeStart\": \"%s\"," +
map.put("gradientAmountList",""); "\"joinTimeEnd\": \"%s\"," +
map.put("freeJoinLimit", "0"); "\"joinDeadLine\": \"%s\"," +
map.put("enableAmpifyCard","false"); "\"actId\":%s," +
map.put("openType", "0"); "\"openStatus\":true," +
logger.info("请求save接口"); "\"gradientAmountList\":\"\"," +
"\"freeJoinLimit\":0," +
Response response = given().contentType("application/json").cookies(authorization.ssoLogin()).params(map).post("https://mng.duibatest.com.cn/newmanager/signContract/save"); "\"fakeRatio\":0" +
"}", startTime, endTime, date, actId);
System.out.println(jsonBody);
Response response = given().contentType("application/json;charset=UTF-8").cookies(authorization.ssoLogin()).body(jsonBody).post("https://mng.duibatest.com.cn/newmanager/signContract/save");
response.prettyPrint();
try { try {
Assert.assertEquals(response.jsonPath().getString("success"), "true", "/signContract/save接口失败"); Assert.assertEquals(response.jsonPath().getString("success"), "true", "/signContract/save接口失败");
} catch (Exception e) { } catch (Exception e) {
...@@ -346,12 +354,7 @@ public class ContractSign_signTest extends DuibaTestBase { ...@@ -346,12 +354,7 @@ public class ContractSign_signTest extends DuibaTestBase {
} }
} }
private void modifyIssuePeriod(String actId, int uid, int num) throws Exception{ private void modifyIssuePeriod(String issueId, int num) throws Exception{
Response res = ContractSignService.getContracts(actId, uid);
// 接口返回的第一条信息为最近参与的记录
String issueId = res.jsonPath().getString("data.list[0].issueId");
String doneStatus = res.jsonPath().getString("data.list[0].doneStatus");
if (StringUtils.isNotBlank(issueId) && doneStatus.equals("DOING")) {
String sql = "select start_time,end_time from credits_sign.tb_sign_contract_issue where id=" + issueId; String sql = "select start_time,end_time from credits_sign.tb_sign_contract_issue where id=" + issueId;
Map<String, Object> result = jdbc.findSimpleResult(sql); Map<String, Object> result = jdbc.findSimpleResult(sql);
String issueStartTime = result.get("start_time").toString(); String issueStartTime = result.get("start_time").toString();
...@@ -382,9 +385,6 @@ public class ContractSign_signTest extends DuibaTestBase { ...@@ -382,9 +385,6 @@ public class ContractSign_signTest extends DuibaTestBase {
px.printStackTrace(); px.printStackTrace();
} }
}else{
throw new Exception("用户没有正在参与的期次");
}
} }
/** /**
......
...@@ -204,7 +204,7 @@ public class ContractSignService { ...@@ -204,7 +204,7 @@ public class ContractSignService {
public Response getReward(String ContractId, int uid) throws Exception{ public Response getReward(String ContractId, int uid) throws Exception{
Map<String, String> map = new HashMap<>(); Map<String, String> map = new HashMap<>();
map.put("activityId", ContractId); map.put("contractId", ContractId);
logger.info("请求getReward接口,签到活动id=" + ContractId); logger.info("请求getReward接口,签到活动id=" + ContractId);
Response response = given().cookies(authorization.dafuwengLogin(uid)).params(map).post(activityHost+"/sign/contract/getReward"); Response response = given().cookies(authorization.dafuwengLogin(uid)).params(map).post(activityHost+"/sign/contract/getReward");
try{ try{
......
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