Commit f466cb4c authored by wangxiaoshuang's avatar wangxiaoshuang

Merge branch 'develop' into wxs

parents 0ae8d1fe 84b6032d
...@@ -261,6 +261,12 @@ ...@@ -261,6 +261,12 @@
<artifactId>guava</artifactId> <artifactId>guava</artifactId>
<version>21.0</version> <version>21.0</version>
</dependency> </dependency>
<dependency>
<groupId>cn.com.duiba.tool</groupId>
<artifactId>java-gitlab-api</artifactId>
<version>1.3.8</version>
</dependency>
</dependencies> </dependencies>
<build> <build>
......
...@@ -2,6 +2,7 @@ package base; ...@@ -2,6 +2,7 @@ package base;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.gitlab.api.models.GitlabProjectMerges;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.core.env.Environment; import org.springframework.core.env.Environment;
...@@ -52,6 +53,15 @@ public class DingdingResult { ...@@ -52,6 +53,15 @@ public class DingdingResult {
names.addAll(Arrays.asList(getNames)); names.addAll(Arrays.asList(getNames));
Map<String,String> params = new HashMap<>();
params.put("jobName",getJob());
changes = Postman.sendFindTestApp(params);
GitlabProjectMerges gitlabProjectMerges = GitlabUtils.getMessage("credits-group",changes);
changes = changes+" 提交者:"+gitlabProjectMerges.getAuthor().getName()+" 描述:"+gitlabProjectMerges.getDescription();
/*从jenkins上获取项目变更
Map<String,String> resentChanges=BeTested.getChangesWithin(30,changeMap); Map<String,String> resentChanges=BeTested.getChangesWithin(30,changeMap);
System.out.println(resentChanges); System.out.println(resentChanges);
if(resentChanges!=null&&resentChanges.size()>0){ if(resentChanges!=null&&resentChanges.size()>0){
...@@ -77,7 +87,7 @@ public class DingdingResult { ...@@ -77,7 +87,7 @@ public class DingdingResult {
if(changes.length()>140){ if(changes.length()>140){
changes=changes.substring(0,141)+"……"; changes=changes.substring(0,141)+"……";
} }
//project="tuia-media"; */
this.total=total; this.total=total;
this.passCount=passCount; this.passCount=passCount;
this.skipCount=skipCount; this.skipCount=skipCount;
...@@ -125,14 +135,16 @@ public class DingdingResult { ...@@ -125,14 +135,16 @@ public class DingdingResult {
result.put("skipCount",this.total); result.put("skipCount",this.total);
result.put("failCount",0); result.put("failCount",0);
} }
result.put("changes",this.changes+"<br>"); // result.put("changes",this.changes+"<br>");
result.put("changes",this.changes);
if(this.failCount>0||exceptionServices.size()>0||exceptionMessage.size()>0){ if(this.failCount>0||exceptionServices.size()>0||exceptionMessage.size()>0){
try{ // try{
String name = this.changes.split("—")[1].split("/")[0]; // String name = this.changes.split("—")[1].split("/")[0];
names.add(name); // names.add(name);
}catch(Exception e){ // }catch(Exception e){
System.out.println(e); // System.out.println(e);
} // }
}else { }else {
names.clear(); names.clear();
......
package base;
import org.gitlab.api.GitlabAPI;
import org.gitlab.api.models.GitabProjectLatelyChangeQry;
import org.gitlab.api.models.GitlabProject;
import org.gitlab.api.models.GitlabProjectMerges;
import java.io.IOException;
import java.util.List;
/**
* Created by mabo on 2018/12/5
*/
public class GitlabUtils {
public static final String GIT_URL = "http://gitlab2.dui88.com";
public static final String SECRET = "rCyBy1sQ-JckquyFmo4c";
public static GitlabProjectMerges getMessage(String namespace,String projectname){
GitlabAPI gitlabAPI = GitlabAPI.connect(GitlabUtils.GIT_URL, GitlabUtils.SECRET);
GitlabProject gitlabProject= null;
try {
gitlabProject = gitlabAPI.getProject(namespace,projectname);
// gitlabProject = gitlabAPI.getProject("credits-group","hdtool-web");
} catch (IOException e) {
e.printStackTrace();
}
GitabProjectLatelyChangeQry qry = new GitabProjectLatelyChangeQry();
qry.setId(gitlabProject.getId());
qry.setTargetBranch("develop");
List<GitlabProjectMerges> projectMerges = null;
try {
projectMerges = gitlabAPI.getLatelyMergeInfo(qry);
} catch (IOException e) {
e.printStackTrace();
}
System.out.println(projectMerges.size());
GitlabProjectMerges gitlabProjectMerges = projectMerges.get(0);
return gitlabProjectMerges;
}
public static void main(String[] args) throws IOException {
// GitlabAPI gitlabAPI = GitlabAPI.connect(GitlabUtils.GIT_URL, GitlabUtils.SECRET);
// GitlabProject gitlabProject=gitlabAPI.getProject("credits-group","hdtool-web");
//
// GitabProjectLatelyChangeQry qry = new GitabProjectLatelyChangeQry();
// qry.setId(gitlabProject.getId());
// qry.setTargetBranch("develop");
// List<GitlabProjectMerges> projectMerges = gitlabAPI.getLatelyMergeInfo(qry);
// System.out.println(projectMerges.size());
// GitlabProjectMerges gitlabProjectMerges = projectMerges.get(0);
GitlabProjectMerges gitlabProjectMerges = getMessage("credits-group","trade-access-web");
System.out.println(gitlabProjectMerges.getDescription());
System.out.println(gitlabProjectMerges.getAuthor().getName());
System.out.println(gitlabProjectMerges.getAuthor().getUsername());
System.out.println(gitlabProjectMerges.getAuthor().getId());
}
}
...@@ -25,6 +25,7 @@ public class Postman { ...@@ -25,6 +25,7 @@ public class Postman {
final static String testPlatformUrl = "http://101.37.27.82:8080/insert"; final static String testPlatformUrl = "http://101.37.27.82:8080/insert";
final static String miriaUrl = "http://miria-aliyun.duibatest.com.cn/autoTest/finish"; final static String miriaUrl = "http://miria-aliyun.duibatest.com.cn/autoTest/finish";
final static String miriaUrlTesting = "http://miria-aliyun.duibatest.com.cn/autoTest/testing"; final static String miriaUrlTesting = "http://miria-aliyun.duibatest.com.cn/autoTest/testing";
final static String miriaUrlFindTestApp = "http://miria-aliyun.duibatest.com.cn/autoTest/findTestApp";
//dingdingUrl="http://www.json.cn/"; //dingdingUrl="http://www.json.cn/";
private static Logger logger = LogManager.getLogger(Postman.class); private static Logger logger = LogManager.getLogger(Postman.class);
...@@ -67,6 +68,15 @@ public class Postman { ...@@ -67,6 +68,15 @@ public class Postman {
System.out.println("miriaUrl:"+miriaUrlTesting); System.out.println("miriaUrl:"+miriaUrlTesting);
System.out.println("miria响应结果:"+response.asString()); System.out.println("miria响应结果:"+response.asString());
} }
public static String sendFindTestApp(Map result){
Response response=given().params(result).get(miriaUrlFindTestApp);
System.out.println("jobName:"+result.get("jobName"));
System.out.println("miriaUrl:"+miriaUrlTesting);
System.out.println("miria响应结果:"+response.asString());
String value = response.jsonPath().getString("value");
return value;
}
public static Boolean getName(){ public static Boolean getName(){
Calendar c = Calendar.getInstance(); Calendar c = Calendar.getInstance();
Date date = new Date(); Date date = new Date();
......
...@@ -253,6 +253,7 @@ public class CustomActivity_DuibaTest extends DuibaTestBase { ...@@ -253,6 +253,7 @@ public class CustomActivity_DuibaTest extends DuibaTestBase {
String orderId = response.jsonPath().getString("orderId"); String orderId = response.jsonPath().getString("orderId");
newActivityService.submit(orderId); newActivityService.submit(orderId);
Thread.sleep(1000);
response = newActivityService.getOrderStatus2(orderId, device); response = newActivityService.getOrderStatus2(orderId, device);
String result = String.valueOf(response.jsonPath().getString("result")); String result = String.valueOf(response.jsonPath().getString("result"));
int i = 8; int i = 8;
......
...@@ -61,19 +61,32 @@ public class 答题_答对题数抽奖_DuibaTest extends AbstractTestNGSpringCon ...@@ -61,19 +61,32 @@ public class 答题_答对题数抽奖_DuibaTest extends AbstractTestNGSpringCon
Assert.assertEquals(submitResponse.jsonPath().getString("message"),message); Assert.assertEquals(submitResponse.jsonPath().getString("message"),message);
} else { } else {
Assert.assertEquals(submitResponse.jsonPath().getInt("rightCount"),rightCount); Assert.assertEquals(submitResponse.jsonPath().getInt("rightCount"),rightCount);
for (int i =1; i <= 5; i++) { // for (int i =1; i <= 5; i++) {
//获取中奖结果,校验中奖结果 // //获取中奖结果,校验中奖结果
Response lotterysResponse = activityCtrlService.getOrderStatus(orderId); // Response lotterysResponse = activityCtrlService.getOrderStatus(orderId);
int result = lotterysResponse.jsonPath().getInt("result"); // int result = lotterysResponse.jsonPath().getInt("result");
if(result != 0) { // if(result != 0) {
Assert.assertTrue(lotterysResponse.jsonPath().getBoolean("success")); // Assert.assertTrue(lotterysResponse.jsonPath().getBoolean("success"));
// Assert.assertEquals(lotterysResponse.jsonPath().getString("lottery.type"),prize); // // Assert.assertEquals(lotterysResponse.jsonPath().getString("lottery.type"),prize);
Assert.assertTrue(prize.contains(lotterysResponse.jsonPath().getString("lottery.type"))); // Assert.assertTrue(prize.contains(lotterysResponse.jsonPath().getString("lottery.type")));
break; // break;
} // }
Thread.sleep(500); // Thread.sleep(500);
// }
Thread.sleep(2000);
Response lotterysResponse = activityCtrlService.getOrderStatus(orderId);
String result = lotterysResponse.jsonPath().getString("result");
int i= 30;
while(i>0&&(result.equals("0"))){
Thread.sleep(1000);
lotterysResponse = activityCtrlService.getOrderStatus(orderId);
result = lotterysResponse.jsonPath().getString("result");
i--;
lotterysResponse.prettyPrint();
} }
Assert.assertFalse(false,caseDesc+" 测试失败,轮询5次未请求到中奖结果"); Assert.assertTrue(lotterysResponse.jsonPath().getBoolean("success"));
Assert.assertTrue(prize.contains(lotterysResponse.jsonPath().getString("lottery.type")));
// Assert.assertFalse(false,caseDesc+" 测试失败,轮询5次未请求到中奖结果");
} }
} }
......
...@@ -7,6 +7,7 @@ import http.service.Activity.ManagerService; ...@@ -7,6 +7,7 @@ import http.service.Activity.ManagerService;
import http.service.Activity.NewActivityService; import http.service.Activity.NewActivityService;
import http.service.Activity.SingleLotteryService; import http.service.Activity.SingleLotteryService;
import http.service.hd.DeveloperService; import http.service.hd.DeveloperService;
import http.service.hd.LaunchService;
import http.service.hd.SigninService; import http.service.hd.SigninService;
import utils.MatcherString; import utils.MatcherString;
import base.DuibaLog; import base.DuibaLog;
...@@ -26,6 +27,8 @@ public class 新建活动测试_DuibaTest extends DuibaTestBase{ ...@@ -26,6 +27,8 @@ public class 新建活动测试_DuibaTest extends DuibaTestBase{
@Autowired @Autowired
DeveloperService developerService; DeveloperService developerService;
@Autowired
LaunchService launchService;
private static DuibaLog logger = DuibaLog.getLogger(); private static DuibaLog logger = DuibaLog.getLogger();
...@@ -61,9 +64,40 @@ public class 新建活动测试_DuibaTest extends DuibaTestBase{ ...@@ -61,9 +64,40 @@ public class 新建活动测试_DuibaTest extends DuibaTestBase{
}else }else
if(method.getName().equals("新建自有手动开奖活动")){ if(method.getName().equals("新建自有手动开奖活动")){
result = new Object[][]{ result = new Object[][]{
new Object[]{1,"10","everyday","5","everyday","//yun.duiba.com.cn/upload/mhty76ri9b.png","新建自有手动开奖--每日次数"}, new Object[]{1,"10","everyday","5","everyday","//yun.duiba.com.cn/upload/mhty76ri9b.png","新建自有手动开奖--每日次数"}, //case1
new Object[]{2,"20","forever","10","forever","//yun.dui88.com/images/201811/j90o37xiof.jpg","新建自有手动开奖--永久次数"}, //case2
};
}else
if(method.getName().equals("新建自有答题活动")){
result = new Object[][]{
new Object[]{1,"[{\"type\":\"coupon\",\"title\":\"优惠券\",\"img\":\"//yun.duiba.com.cn/upload/bust51462438317113.png\",\"valid\":true,\"probability\":\"1\",\"show\":true,\"arealimit\":false,\"pronumber\":\"1\",\"alipay\":\"\",\"description\":\"\",\"appItemId\":172178,\"name\":\"【勿动】自有优惠券审核通过测试\",\"remaind\":\"100\"},{\"type\":\"object\",\"title\":\"实物\",\"img\":\"//yun.duiba.com.cn/upload/1uF0l1462438316968.png\",\"valid\":true,\"probability\":\"2\",\"show\":true,\"arealimit\":false,\"pronumber\":\"2\",\"alipay\":\"\",\"description\":\"\",\"appItemId\":175491,\"name\":\"【自动化】自有实物19:51:09\",\"remaind\":\"90\"},{\"type\":\"virtual\",\"title\":\"虚拟商品\",\"img\":\"//yun.duiba.com.cn/developer/img/activityTool/slotMachine/virtual.png\",\"valid\":true,\"probability\":\"3\",\"show\":true,\"arealimit\":false,\"pronumber\":\"3\",\"alipay\":\"\",\"description\":\"\",\"appItemId\":178060,\"value\":\"test\",\"remaind\":\"80\"},{\"type\":\"phonebill\",\"title\":\"话费\",\"img\":\"//yun.duiba.com.cn/upload/AROxS1462438316966.png\",\"valid\":true,\"probability\":\"4\",\"show\":true,\"arealimit\":false,\"pronumber\":\"4\",\"alipay\":\"\",\"description\":\"\",\"value\":\"10\",\"remaind\":\"70\"},{\"type\":\"alipay\",\"title\":\"支付宝\",\"img\":\"//yun.duiba.com.cn/upload/KkZMp1462438317113.png\",\"valid\":true,\"probability\":\"5\",\"show\":true,\"arealimit\":false,\"pronumber\":\"5\",\"alipay\":\"\",\"description\":\"\",\"value\":\"1\",\"remaind\":\"60\"},{\"type\":\"qb\",\"title\":\"Q币\",\"img\":\"//yun.duiba.com.cn/upload/mF3wO1462438317114.png\",\"valid\":true,\"probability\":\"6\",\"show\":true,\"arealimit\":false,\"pronumber\":\"6\",\"alipay\":\"\",\"description\":\"\",\"value\":\"10\",\"remaind\":\"50\"},{\"type\":\"lucky\",\"title\":\"福袋\",\"img\":\"//yun.duiba.com.cn/webapp/img/luckynewn.png\",\"valid\":true,\"probability\":\"0\",\"show\":false,\"arealimit\":false,\"pronumber\":\"0\",\"alipay\":\"\",\"description\":\"\"}]",
"[{\"index\":null,\"type\":\"text\",\"rightAnswer\":1,\"name\":\"文字题一\",\"option1\":\"文字题一A\",\"option2\":\"文字题一B\",\"option3\":\"文字题一C\",\"option4\":\"文字题一D\"},{\"index\":null,\"type\":\"text\",\"rightAnswer\":\"2\",\"name\":\"文字题二\",\"option1\":\"文字题二A\",\"option2\":\"文字题二B\",\"option3\":\"文字题二C\",\"option4\":\"文字题二D\"},{\"index\":null,\"type\":\"text\",\"rightAnswer\":\"3\",\"name\":\"文字题三\",\"option1\":\"文字题三A\",\"option2\":\"文字题三B\",\"option3\":\"文字题三C\",\"option4\":\"文字题三D\"},{\"index\":null,\"type\":\"text\",\"rightAnswer\":\"4\",\"name\":\"文字题四\",\"option1\":\"文字题四A\",\"option2\":\"文字题四B\",\"option3\":\"文字题四C\",\"option4\":\"文字题四D\"},{\"index\":null,\"type\":\"text\",\"rightAnswer\":1,\"name\":\"文字题五\",\"option1\":\"文字题五A\",\"option2\":\"文字题五B\",\"option3\":\"文字题五C\",\"option4\":\"文字题五D\"},{\"index\":null,\"type\":\"text\",\"rightAnswer\":\"2\",\"name\":\"文字题六\",\"option1\":\"文字题六A\",\"option2\":\"文字题六B\",\"option3\":\"文字题六C\",\"option4\":\"文字题六D\"}]",
"1","10","everyday","5","everyday","6","新建自有答题活动-文字题"}, //case 1
new Object[]{2,"[{\"type\":\"coupon\",\"title\":\"优惠券1\",\"img\":\"//yun.duiba.com.cn/upload/bust51462438317113.png\",\"valid\":true,\"probability\":\"1\",\"show\":true,\"arealimit\":false,\"pronumber\":\"1\",\"alipay\":\"\",\"description\":\"\",\"appItemId\":159857,\"name\":\"【自动化勿动】自有优惠券\",\"remaind\":\"100\"},{\"type\":\"coupon\",\"title\":\"优惠券2\",\"img\":\"//yun.duiba.com.cn/upload/bust51462438317113.png\",\"valid\":true,\"probability\":\"2\",\"show\":true,\"arealimit\":false,\"pronumber\":\"2\",\"alipay\":\"\",\"description\":\"\",\"appItemId\":172163,\"name\":\"【勿动】兑吧优惠券定向库存不足\",\"remaind\":\"60\"},{\"type\":\"coupon\",\"title\":\"优惠券3\",\"img\":\"//yun.duiba.com.cn/upload/bust51462438317113.png\",\"valid\":true,\"probability\":\"3\",\"show\":true,\"arealimit\":false,\"pronumber\":\"3\",\"alipay\":\"\",\"description\":\"\",\"appItemId\":185571,\"name\":\"【自动化】自有优惠券成功页跳转链接 兑换成功后页面没有跳转按钮 以及点击入口\",\"remaind\":\"30\"}]",
"[{\"index\":null,\"type\":\"image\",\"rightAnswer\":1,\"name\":\"图片题1\",\"option1\":\"//yun.dui88.com/images/201811/0tg3occ8ft.png\",\"option2\":\"//yun.dui88.com/images/201811/7avinswhbx.png\",\"option3\":\"//yun.dui88.com/images/201811/wpivlzrt5x.png\",\"option4\":\"//yun.dui88.com/images/201811/omk617xseb.png\"},{\"index\":null,\"type\":\"image\",\"rightAnswer\":1,\"name\":\"图片题2\",\"option1\":\"//yun.dui88.com/images/201811/x7ukissn3k.png\",\"option2\":\"//yun.dui88.com/images/201811/3g81rrei8x.png\",\"option3\":\"//yun.dui88.com/images/201811/m16yaakc6u.png\",\"option4\":\"//yun.dui88.com/images/201811/kodb08cqi3.png\"},{\"index\":null,\"type\":\"image\",\"rightAnswer\":1,\"name\":\"图片题3\",\"option1\":\"//yun.dui88.com/images/201811/au84gljudk.png\",\"option2\":\"//yun.dui88.com/images/201811/vt9wfrnefk.png\",\"option3\":\"//yun.dui88.com/images/201811/tzplflmd8e.png\",\"option4\":\"//yun.dui88.com/images/201811/n5odjivu2j.png\"}]",
"1","5","forever","20","forever","3","新建自有答题活动-图片题"},//case 2
};
}else
if(method.getName().equals("新建自有答题独立活动")){
result = new Object[][]{
new Object[]{1,"[{\"type\":\"coupon\",\"title\":\"优惠券\",\"img\":\"//yun.duiba.com.cn/upload/bust51462438317113.png\",\"valid\":true,\"probability\":\"1\",\"show\":true,\"arealimit\":false,\"pronumber\":\"1\",\"alipay\":\"\",\"description\":\"\",\"appItemId\":172178,\"name\":\"【勿动】自有优惠券审核通过测试\",\"remaind\":\"100\"},{\"type\":\"object\",\"title\":\"实物\",\"img\":\"//yun.duiba.com.cn/upload/1uF0l1462438316968.png\",\"valid\":true,\"probability\":\"2\",\"show\":true,\"arealimit\":false,\"pronumber\":\"2\",\"alipay\":\"\",\"description\":\"\",\"appItemId\":175491,\"name\":\"【自动化】自有实物19:51:09\",\"remaind\":\"50\"},{\"type\":\"virtual\",\"title\":\"虚拟商品\",\"img\":\"//yun.duiba.com.cn/developer/img/activityTool/slotMachine/virtual.png\",\"valid\":true,\"probability\":\"3\",\"show\":true,\"arealimit\":false,\"pronumber\":\"3\",\"alipay\":\"\",\"description\":\"\",\"appItemId\":159849,\"value\":\"DUIBA_SELF\",\"remaind\":\"10\"}]",
"[{\"index\":null,\"type\":\"text\",\"rightAnswer\":1,\"name\":\"文字题1\",\"option1\":\"文字题1A\",\"option2\":\"文字题1B\",\"option3\":\"文字题1C\",\"option4\":\"文字题1D\"},{\"index\":null,\"type\":\"text\",\"rightAnswer\":\"2\",\"name\":\"文字题2\",\"option1\":\"文字题2A\",\"option2\":\"文字题2B\",\"option3\":\"文字题2C\",\"option4\":\"文字题2D\"},{\"index\":null,\"type\":\"text\",\"rightAnswer\":\"3\",\"name\":\"文字题3\",\"option1\":\"文字题3A\",\"option2\":\"文字题3B\",\"option3\":\"文字题3C\",\"option4\":\"文字题3D\"}]",
"0","","everyday","12","everyday","3","新建自有答题独立活动-文字题"}, //case1
new Object[]{2,"[{\"type\":\"virtual\",\"title\":\"虚拟商品\",\"img\":\"//yun.duiba.com.cn/developer/img/activityTool/slotMachine/virtual.png\",\"valid\":true,\"probability\":\"2\",\"show\":true,\"arealimit\":false,\"pronumber\":\"2\",\"alipay\":\"\",\"description\":\"\",\"appItemId\":178060,\"value\":\"test\",\"remaind\":\"200\"}]",
"[{\"index\":null,\"type\":\"image\",\"rightAnswer\":1,\"name\":\"图片题1\",\"option1\":\"//yun.dui88.com/images/201812/dbdzbihqdu.png\",\"option2\":\"//yun.dui88.com/images/201812/6uoag0r7wi.png\",\"option3\":\"//yun.dui88.com/images/201812/5ht2x4zyjn.gif\",\"option4\":\"//yun.dui88.com/images/201812/gk6pvpoabr.png\"},{\"index\":null,\"type\":\"image\",\"rightAnswer\":\"2\",\"name\":\"图片题2\",\"option1\":\"//yun.dui88.com/images/201812/c3iyatkw3u.png\",\"option2\":\"//yun.dui88.com/images/201812/stzcy6dzaf.gif\",\"option3\":\"//yun.dui88.com/images/201812/nkmpgb7jcd.png\",\"option4\":\"//yun.dui88.com/images/201812/6r5hwfet8e.png\"}]",
"0","","everyday","30","forever","2","新建自有答题独立活动-图片题"}, //case2
}; };
}else
if(method.getName().equals("新建自有签到活动")){
result = new Object[][]{
new Object[]{1,"0","[{\"type\":\"alipay\",\"description\":\"支付宝\",\"logo\":\"//yun.duiba.com.cn/developer/img/activityTool/slotMachine/alipay.png\",\"appItemId\":156493,\"arealimit\":false,\"rate\":\"50\",\"name\":\"\",\"valid\":true,\"otherUse\":5,\"remaining\":\"100\",\"winLimit\":\"1\",\"minComein\":\"10\",\"facePrice\":\"10\",\"stockAfterChange\":\"100\",\"stockBeforeChange\":0}]",
"10,20,30,40,50","新建签到活动-连续签到"}, //case1
new Object[]{2,"1","[{\"type\":\"virtual\",\"description\":\"虚拟商品\",\"logo\":\"//yun.duiba.com.cn/developer/img/activityTool/slotMachine/virtual.png\",\"appItemId\":178060,\"arealimit\":false,\"rate\":\"50\",\"name\":\"test\",\"valid\":true,\"otherUse\":1,\"remaining\":\"100\",\"winLimit\":\"1\",\"minComein\":\"\",\"facePrice\":\"\",\"stockAfterChange\":\"100\",\"stockBeforeChange\":0},{\"type\":\"phonebill\",\"description\":\"话费\",\"logo\":\"//yun.duiba.com.cn/developer/img/activityTool/slotMachine/phonebill.png\",\"appItemId\":156496,\"arealimit\":false,\"rate\":\"5\",\"name\":\"\",\"valid\":true,\"otherUse\":7,\"remaining\":\"50\",\"winLimit\":\"1\",\"minComein\":\"100\",\"facePrice\":\"10\",\"stockAfterChange\":\"50\",\"stockBeforeChange\":0}]",
"5,10,15,20,25,30,35","新建签到活动-连续周期签到"}, //case2
};
} }
return result; return result;
...@@ -104,6 +138,7 @@ public class 新建活动测试_DuibaTest extends DuibaTestBase{ ...@@ -104,6 +138,7 @@ public class 新建活动测试_DuibaTest extends DuibaTestBase{
Assert.assertEquals(editResponse.jsonPath().getString("data.freeScope"),"everyday","校验活动免费抽奖次数类型失败"); Assert.assertEquals(editResponse.jsonPath().getString("data.freeScope"),"everyday","校验活动免费抽奖次数类型失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.limitCount"),"5","校验活动限制次数失败"); Assert.assertEquals(editResponse.jsonPath().getString("data.limitCount"),"5","校验活动限制次数失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.limitScope"),"everyday","校验活动限制次数类型失败"); Assert.assertEquals(editResponse.jsonPath().getString("data.limitScope"),"everyday","校验活动限制次数类型失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.bannerImgNew"),"//yun.duiba.com.cn/upload/newHdTool/turntable_cricle/banner_750x220.png","校验活动新版banner图失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.awards[1].name"),"【自动化勿动】自有优惠券","校验活动奖品名称失败"); Assert.assertEquals(editResponse.jsonPath().getString("data.awards[1].name"),"【自动化勿动】自有优惠券","校验活动奖品名称失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.awards[1].limit"),"1","校验活动奖品中奖限制失败"); Assert.assertEquals(editResponse.jsonPath().getString("data.awards[1].limit"),"1","校验活动奖品中奖限制失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.awards[1].oldRemaind"),"100","校验活动奖品数量失败"); Assert.assertEquals(editResponse.jsonPath().getString("data.awards[1].oldRemaind"),"100","校验活动奖品数量失败");
...@@ -267,6 +302,137 @@ public class 新建活动测试_DuibaTest extends DuibaTestBase{ ...@@ -267,6 +302,137 @@ public class 新建活动测试_DuibaTest extends DuibaTestBase{
logger.info("校验新建自有手动开奖-1内容成功"); logger.info("校验新建自有手动开奖-1内容成功");
break; break;
case 2: case 2:
Assert.assertEquals(editResponse.jsonPath().getString("data.freeLimit"),"10","校验活动免费抽奖次数失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.freeLimitScope"),"forever","校验活动免费抽奖次数类型失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.consumerDrawLimit"),"20","校验用户抽奖限制次数失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.consumerDrawLimitScope"),"forever","校验用户抽奖限制类型失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.bannerImgNew"),"//yun.dui88.com/images/201811/j90o37xiof.jpg","校验活动新版banner图失败");
logger.info("校验新建自有手动开奖-2内容成功");
break;
}
//删除测试数据
this.删除自有活动(title);
}
/**
* @param caseNum 用例编号
* @param awards 奖品
* @param questionRecord 题目
* @param creditsType 活动模式
* @param freeLimit 免费次数
* @param freeScope 免费次数类型
* @param limitCount 限制次数
* @param limitScope 限制次数类型
* @param optionNum 题目数
* @param caseName 用例名称
* @throws Exception
*/
@Test(dataProvider = "providerMethod")
public void 新建自有答题活动(int caseNum,String awards,String questionRecord,String creditsType,String freeLimit,String freeScope,String limitCount,String limitScope,String optionNum,String caseName) throws Exception{
logger.info("-----------------------------"+caseName+"-----------------------------");
String data = PublicMethod.data();
String title = "【自动化】自有答题活动"+data;
//新建自有答题活动
developerService.saveQuestion(title,awards,questionRecord,creditsType,freeLimit,freeScope,limitCount,limitScope,optionNum);
//获取活动id
Response listResponse = developerService.list2(title);
String id = String.valueOf(listResponse.jsonPath().getString("data.list[0].id"));
//编辑活动,校验活动内容
Response editResponse = developerService.editQuestion(id);
switch (caseNum){
case 1:
Assert.assertEquals(editResponse.jsonPath().getString("data.credits"),"22","校验活动积分失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.freeLimit"),"10","校验活动免费次数失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.freeScope"),"everyday","校验活动免费抽奖次数类型失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.limitCount"),"5","校验活动限制次数失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.limitScope"),"everyday","校验活动限制类型失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.bannerImgNew"),"//yun.duiba.com.cn/upload/qzfsmsyo9s.png","校验活动新版banner图失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.questionRecord[0].name"),"文字题一","校验活动题目名称失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.questionRecord[0].type"),"text","校验活动题目类型失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.awards[0].name"),"【勿动】自有优惠券审核通过测试","校验活动奖品名称失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.awards[0].probability"),"1","校验活动奖品获奖资格失败");
logger.info("校验新建自有答题活动-1内容成功");
break;
case 2:
Assert.assertEquals(editResponse.jsonPath().getString("data.freeLimit"),"5","校验活动免费次数失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.freeScope"),"forever","校验活动免费抽奖次数类型失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.limitCount"),"20","校验活动限制次数失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.limitScope"),"forever","校验活动限制类型失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.questionRecord[0].name"),"图片题1","校验活动题目名称失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.questionRecord[0].type"),"image","校验活动题目类型失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.awards[1].name"),"【勿动】兑吧优惠券定向库存不足","校验活动奖品名称失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.awards[1].probability"),"2","校验活动奖品获奖资格失败");
logger.info("校验新建自有答题活动-2内容成功");
break;
}
//删除测试数据
this.删除自有活动(title);
}
/**
* @param caseNum 用例编号
* @param awards 奖品
* @param questionRecord 题目
* @param creditsType 活动模式
* @param freeLimit 免费次数
* @param freeScope 免费次数类型
* @param limitCount 限制次数
* @param limitScope 限制次数类型
* @param optionNum 题目数
* @param caseName 用例名称
* @throws Exception
*/
@Test(dataProvider = "providerMethod")
public void 新建自有答题独立活动(int caseNum,String awards,String questionRecord,String creditsType,String freeLimit,String freeScope,String limitCount,String limitScope,String optionNum,String caseName) throws Exception{
logger.info("-----------------------------"+caseName+"-----------------------------");
String data = PublicMethod.data();
String title = "【自动化】自有答题独立活动"+data;
//新建自有答题独立活动
developerService.saveQuestion(title,awards,questionRecord,creditsType,freeLimit,freeScope,limitCount,limitScope,optionNum);
//获取活动id
Response listResponse = developerService.list2(title);
String id = String.valueOf(listResponse.jsonPath().getString("data.list[0].id"));
//编辑活动,校验活动内容
Response editResponse = developerService.editQuestion(id);
switch (caseNum){
case 1:
Assert.assertEquals(editResponse.jsonPath().getString("data.creditsType"),"0","校验活动积分类型失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.freeLimit"),"12","校验活动免费次数失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.limitCount"),"12","校验活动限制次数失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.limitScope"),"everyday","校验活动限制类型失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.mode"),"free","校验活动模式失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.questionRecord[1].name"),"文字题2","校验活动题目名称失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.questionRecord[1].type"),"text","校验活动题目类型失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.awards[1].name"),"【自动化】自有实物19:51:09","校验活动奖品名称失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.awards[1].probability"),"2","校验活动奖品获奖资格失败");
logger.info("校验新建自有答题独立活动-1内容成功");
break;
case 2:
Assert.assertEquals(editResponse.jsonPath().getString("data.freeLimit"),"30","校验活动免费次数失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.limitCount"),"30","校验活动限制次数失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.limitScope"),"forever","校验活动限制类型失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.questionRecord[1].name"),"图片题2","校验活动题目名称失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.questionRecord[1].type"),"image","校验活动题目类型失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.awards[0].probability"),"2","校验活动奖品获奖资格失败");
logger.info("校验新建自有答题独立活动-2内容成功");
break; break;
} }
...@@ -277,6 +443,91 @@ public class 新建活动测试_DuibaTest extends DuibaTestBase{ ...@@ -277,6 +443,91 @@ public class 新建活动测试_DuibaTest extends DuibaTestBase{
} }
/**
* @param caseNum 用例编号
* @param signType 签到类型
* @param prizes 额外奖励
* @param signCredits 签到获得积分数
* @param caseName 用例名称
* @throws Exception
*/
@Test(dataProvider = "providerMethod")
public void 新建自有签到活动(int caseNum,String signType,String prizes,String signCredits,String caseName) throws Exception{
logger.info("-----------------------------"+caseName+"-----------------------------");
String data = PublicMethod.data();
String title = "【自动化】自有签到活动"+data;
//新建自有答题独立活动
developerService.saveSign(title,signType,prizes,signCredits);
//获取活动id
Response listResponse = developerService.signList();
String id = String.valueOf(listResponse.jsonPath().getString("datas[0].id"));
logger.info(id);
//编辑活动,校验活动内容
Response editResponse = developerService.editSign(id);
switch (caseNum){
case 1:
Assert.assertEquals(editResponse.jsonPath().getString("data.anticheatExchangeLimit"),"true","校验直充类防刷失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.signCredits"),"10,20,30,40,50","校验签到获得积分数失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.signType"),"0","校验签到类型失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.ruleDescription"),"测试活动规则","校验活动规则失败");
Assert.assertEquals(editResponse.jsonPath().getString("prizes[0].appItemId"),"156493","校验额外奖励奖品id失败");
Assert.assertEquals(editResponse.jsonPath().getString("prizes[0].type"),"alipay","校验额外奖励奖品类型失败");
Assert.assertEquals(editResponse.jsonPath().getString("prizes[0].winLimit"),"1","校验额外奖励奖品中奖限制失败");
logger.info("校验新建自有签到活动-1内容成功");
break;
case 2:
Assert.assertEquals(editResponse.jsonPath().getString("data.signCredits"),"5,10,15,20,25,30,35","校验签到获得积分数失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.signType"),"1","校验签到类型失败");
Assert.assertEquals(editResponse.jsonPath().getString("prizes[0].appItemId"),"156496","校验额外奖励奖品0id失败");
Assert.assertEquals(editResponse.jsonPath().getString("prizes[0].type"),"phonebill","校验额外奖励奖品0类型失败");
Assert.assertEquals(editResponse.jsonPath().getString("prizes[1].appItemId"),"178060","校验额外奖励奖品1id失败");
Assert.assertEquals(editResponse.jsonPath().getString("prizes[1].type"),"virtual","校验额外奖励奖品1类型失败");
logger.info("校验新建自有签到活动-2内容成功");
break;
}
//删除测试数据
this.删除自有签到活动();
}
@Test(description = "活动工具获取默认数据测试")
public void 新建活动工具获取默认数据() throws Exception{
//获取砸彩蛋活动数据配置项
Response dataResponse = launchService.getDataConfigUrl("smashg");
//添加奖品,获取默认奖品接口
Response obtainResponse = launchService.obtain();
Assert.assertEquals(dataResponse.jsonPath().getString("data.dataConfig.defaultAwardImgs.alipay"),"//yun.duiba.com.cn/upload/KkZMp1462438317113.png","校验支付宝奖品默认图片失败");
Assert.assertEquals(dataResponse.jsonPath().getString("data.dataConfig.minAwards"),"4","校验最小活动奖品数失败");
Assert.assertEquals(dataResponse.jsonPath().getString("data.dataConfig.tip"),"为保证活动效果,请为此活动配置4~8个奖品。未中奖默认为“谢谢参与”。","校验奖项配置提示语失败");
Assert.assertEquals(dataResponse.jsonPath().getString("data.dataConfig.upload.bannerImgNew.url"),"//yun.duiba.com.cn/upload/newHdTool/hitEgg/banner_750x220.png","校验展示图片新版banner图失败");
Assert.assertEquals(dataResponse.jsonPath().getString("data.dataConfig.upload.award.size.height"),"250","校验奖品图片尺寸失败");
Assert.assertEquals(dataResponse.jsonPath().getString("data.dataConfig.upload.award.size.width"),"250","校验奖品图片尺寸失败");
Assert.assertEquals(dataResponse.jsonPath().getString("data.title"),"砸彩蛋","校验title失败");
logger.info("校验新建活动工具获取图片配置项成功");
Assert.assertEquals(obtainResponse.jsonPath().getString("data.items.alipay"),"156493","校验支付宝奖品id失败");
Assert.assertEquals(obtainResponse.jsonPath().getString("data.items.phonebill"),"156496","校验话费奖品id失败");
Assert.assertEquals(obtainResponse.jsonPath().getString("data.items.qb"),"156494","校验Q币奖品id失败");
Assert.assertTrue(obtainResponse.jsonPath().getString("data.virtualList").contains("【勿动】虚拟商品"), "校验虚拟商品奖品失败");
logger.info("校验新建活动工具获取默认奖品成功");
}
//删除自有活动 //删除自有活动
public void 删除自有活动(String title) throws Exception{ public void 删除自有活动(String title) throws Exception{
//开发者删除自有活动 //开发者删除自有活动
...@@ -285,4 +536,11 @@ public class 新建活动测试_DuibaTest extends DuibaTestBase{ ...@@ -285,4 +536,11 @@ public class 新建活动测试_DuibaTest extends DuibaTestBase{
developerService.delActivity(actId); developerService.delActivity(actId);
} }
//删除自有签到活动
public void 删除自有签到活动() throws Exception{
//开发者删除自有签到活动
Response HdResponse = developerService.signList();
String id = HdResponse.jsonPath().getString("datas[0].id");
developerService.delete(id);
}
} }
...@@ -110,7 +110,8 @@ public class 自有答题测试_DuibaTest extends DuibaTestBase { ...@@ -110,7 +110,8 @@ public class 自有答题测试_DuibaTest extends DuibaTestBase {
Assert.assertEquals(response.jsonPath().getString("rightCount"),"1","校验答题数失败"); Assert.assertEquals(response.jsonPath().getString("rightCount"),"1","校验答题数失败");
logger.info("校验答题正确数成功"); logger.info("校验答题正确数成功");
response = newActivityService.getOrderStatus(uid,orderId); response = newActivityService.getOrderStatus(uid,orderId);
Assert.assertEquals(response.jsonPath().getString("result"),"0","校验抽奖结果失败"); Assert.assertEquals(response.jsonPath().getString("lottery.type"),"qb","校验奖品类型失败");
Assert.assertEquals(response.jsonPath().getString("result"),"2","校验抽奖结果失败");
break; break;
case 3: case 3:
Assert.assertEquals(response.jsonPath().getString("rightCount"),"0","校验答题数失败"); Assert.assertEquals(response.jsonPath().getString("rightCount"),"0","校验答题数失败");
......
...@@ -51,12 +51,12 @@ public class Qb_兑换流程测试_ExchangeTest extends CheckTemplet { ...@@ -51,12 +51,12 @@ public class Qb_兑换流程测试_ExchangeTest extends CheckTemplet {
private DuibaLog logger = DuibaLog.getLogger(); private DuibaLog logger = DuibaLog.getLogger();
@BeforeClass // @BeforeClass
public void beforeClass(){ // public void beforeClass(){
//模版设置成处理后成功 // //模版设置成处理后成功
supplierExchangeTemplateService.use("476"); // supplierExchangeTemplateService.use("476");
//
} // }
@BeforeMethod @BeforeMethod
public void beforeMethod() throws SQLException { public void beforeMethod() throws SQLException {
jdbc.update("DELETE FROM credits_dev.consumer_limit_record_only WHERE item_id = '2'"); jdbc.update("DELETE FROM credits_dev.consumer_limit_record_only WHERE item_id = '2'");
...@@ -69,6 +69,7 @@ public class Qb_兑换流程测试_ExchangeTest extends CheckTemplet { ...@@ -69,6 +69,7 @@ public class Qb_兑换流程测试_ExchangeTest extends CheckTemplet {
return result; return result;
} }
@Test @Test
public void qbExchange() throws Exception { public void qbExchange() throws Exception {
int uid = 3767; int uid = 3767;
......
package http.cases.ExchangeTest;
import base.DuibaLog;
import http.service.Activity.ManagerService;
import http.service.Authorization;
import http.service.app.*;
import http.service.hd.DeveloperAccountService;
import http.service.hd.DsOrderService;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import utils.ExcelDataProvider;
import utils.MatcherString;
import java.io.IOException;
import java.lang.reflect.Method;
import java.sql.SQLException;
import java.util.Iterator;
import java.util.Map;
/**
* Created by mabo on 2018/9/13
*/
public class Qb_兑换限制测试_ExchangeTest extends CheckTemplet {
@Autowired
private MobileService mobileService;
@Autowired
private Authorization authorization;
@Autowired
private CouponExchangeService couponExchangeService;
@Autowired
private CrecordService crecordService;
@Autowired
ManagerService managerService;
@Autowired
VirtualExchangeService virtualExchangeService;
@Autowired
QbExchangeService qbExchangeService;
@Autowired
DeveloperAccountService developerAccountService;
@Autowired
DsOrderService dsOrderService;
@Autowired
SupplierExchangeTemplateService supplierExchangeTemplateService;
private DuibaLog logger = DuibaLog.getLogger();
@BeforeMethod
public void beforeMethod() throws SQLException {
jdbc.update("DELETE FROM credits_dev.consumer_limit_record_only WHERE item_id = '2'");
jdbc.update("DELETE FROM credits_dev.consumer_limit_record WHERE item_id = '2'");
}
@DataProvider
public Iterator<Object[]> providerMethodQb(Method method) throws IOException {
Iterator<Object[]> result = null;
result = new ExcelDataProvider("duiba/qb兑换");
return result;
}
@Test(description = "每限日兑换制同一个用户使用同一个QQ号")
public void 每限日兑换制同一个用户兑换同一个qq() throws Exception {
logger.info("Q币每限日兑换制同一个用户兑换同一个qq开始");
int uid = 4932;
//第一次兑换
Response response = qbExchangeService.doTakePrize(authorization.dafuwengLogin(uid),"1234345554","1");
String orderId = (String)response.jsonPath().get("orderId");
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid),orderId);
String message = response.jsonPath().getString("message");
int i=10;
while(!message.equals("兑换提交成功!待处理")&&i>0){
Thread.sleep(1000);
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid),orderId);
message = response.jsonPath().getString("message");
i--;
}
//第二次兑换
response = qbExchangeService.doTakePrize1(authorization.dafuwengLogin(uid),"1234345554","1");
message = response.jsonPath().getString("message");
logger.info(message);
Assert.assertTrue(message.contains("已兑完"));
logger.info("Q币每限日兑换制同一个用户兑换同一个qq成功");
}
@Test(description = "每限日兑换制同一个用户使用不同一个QQ号")
public void 每限日兑换制同一个用户使用不同一个QQ() throws Exception {
logger.info("每限日兑换制同一个用户使用不同一个QQ号开始");
int uid = 4933;
//第一次兑换
Response response = qbExchangeService.doTakePrize(authorization.dafuwengLogin(uid),"1234345554","1");
String orderId = (String)response.jsonPath().get("orderId");
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid),orderId);
String message = response.jsonPath().getString("message");
int i=10;
while(!message.equals("兑换提交成功!待处理")&&i>0){
Thread.sleep(1000);
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid),orderId);
message = response.jsonPath().getString("message");
i--;
}
//第二次兑换
response = qbExchangeService.doTakePrize1(authorization.dafuwengLogin(uid),"12343455541","1");
response.prettyPrint();
message = response.jsonPath().getString("message");
logger.info(message);
Assert.assertTrue(message.contains("已兑完"));
// Assert.assertTrue(message.contains("\"success\":false"));
logger.info("每限日兑换制同一个用户使用不同一个QQ号成功");
}
@Test(description = "每限日兑换制不同一个用户使用同一个QQ号")
public void 每限日兑换制不同一个用户使用同一个QQ() throws Exception {
logger.info("每限日兑换制不同一个用户使用同一个QQ号开始");
int uid = 4934;
//第一次兑换
Response response = qbExchangeService.doTakePrize(authorization.dafuwengLogin(uid),"123434555412","1");
String orderId = (String)response.jsonPath().get("orderId");
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid),orderId);
String message = response.jsonPath().getString("message");
int i=10;
while(!message.equals("兑换提交成功!待处理")&&i>0){
Thread.sleep(1000);
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid),orderId);
message = response.jsonPath().getString("message");
i--;
}
//第二次兑换
//不同的用户,同一个 qq好
int uid1=4935;
response = qbExchangeService.doTakePrize1(authorization.dafuwengLogin(uid1),"123434555412","1");
response.prettyPrint();
message = response.jsonPath().getString("message");
logger.info(message);
Assert.assertTrue(message.contains("抱歉,该QQ号已达到每天充值上限,请换一个QQ号吧。"));
logger.info("每限日兑换制不同一个用户使用同一个QQ号成功");
}
}
...@@ -726,7 +726,7 @@ public class 优惠券_兑换流程测试_ExchangeTest extends CheckTemplet { ...@@ -726,7 +726,7 @@ public class 优惠券_兑换流程测试_ExchangeTest extends CheckTemplet {
* @param caseName 用例名称打印 * @param caseName 用例名称打印
* @throws Exception * @throws Exception
*/ */
@Test(dataProvider = "providerMethod") //@Test(dataProvider = "providerMethod")
public void 优惠券地区兑换限制测试(int caseNum, String appItemId, String itemId, String token,String caseName) throws Exception{ public void 优惠券地区兑换限制测试(int caseNum, String appItemId, String itemId, String token,String caseName) throws Exception{
logger.info(caseName); logger.info(caseName);
......
...@@ -393,7 +393,7 @@ public class Item_FloorTest extends DuibaTestBase { ...@@ -393,7 +393,7 @@ public class Item_FloorTest extends DuibaTestBase {
JsonPath jsonPath=from(s.substring(s.indexOf("{"),s.length()-1)); JsonPath jsonPath=from(s.substring(s.indexOf("{"),s.length()-1));
List<Map> list = jsonPath.getList("list",Map.class); List<Map> list = jsonPath.getList("list",Map.class);
Assert.assertEquals(list.size(),listDev.size(),"开发者配置和手机端展示数量不符"); // Assert.assertEquals(list.size(),listDev.size(),"开发者配置和手机端展示数量不符");
......
...@@ -62,7 +62,7 @@ public class 无积分测试_DuibaTest extends DuibaTestBase { ...@@ -62,7 +62,7 @@ public class 无积分测试_DuibaTest extends DuibaTestBase {
Assert.assertEquals(response_ajax.jsonPath().getString("element.status"),"4","校验status失败"); Assert.assertEquals(response_ajax.jsonPath().getString("element.status"),"4","校验status失败");
logger.info("ajax校验项:status成功"); logger.info("ajax校验项:status成功");
Assert.assertEquals(response.jsonPath().getString("message"),"永久次数已用完","校验message失败"); Assert.assertEquals(response.jsonPath().getString("message"),"永久次数已用完","校验message失败");
Assert.assertEquals(response.jsonPath().getString("status"),"3","校验status失败"); Assert.assertEquals(response.jsonPath().getString("status"),"4","校验status失败");
Assert.assertEquals(response.jsonPath().getString("success"),"false","校验success失败"); Assert.assertEquals(response.jsonPath().getString("success"),"false","校验success失败");
logger.info("doJoin校验项:message,status,success成功"); logger.info("doJoin校验项:message,status,success成功");
break; break;
...@@ -84,7 +84,7 @@ public class 无积分测试_DuibaTest extends DuibaTestBase { ...@@ -84,7 +84,7 @@ public class 无积分测试_DuibaTest extends DuibaTestBase {
} }
//切换回2720用户 //切换回2720用户
authorization.dafuwengLogin(2720,true); //authorization.dafuwengLogin(2720,true);
} }
......
...@@ -70,7 +70,10 @@ public class 新集卡_开奖流程_DuibaTest extends DuibaTestBase { ...@@ -70,7 +70,10 @@ public class 新集卡_开奖流程_DuibaTest extends DuibaTestBase {
String collectRuleId = data.get("collectRuleId"); String collectRuleId = data.get("collectRuleId");
Integer uid = Integer.valueOf(data.get("uid").toString()); Integer uid = Integer.valueOf(data.get("uid").toString());
String count = data.get("count"); String count = data.get("count");
String consumerId = data.get("consumerId");
String itemIdDb = data.get("itemId");
clearCardInfo(itemIdDb,consumerId);
String itemId = null; String itemId = null;
for (int i=0;i<Integer.valueOf(count);i++){ for (int i=0;i<Integer.valueOf(count);i++){
...@@ -447,4 +450,11 @@ public class 新集卡_开奖流程_DuibaTest extends DuibaTestBase { ...@@ -447,4 +450,11 @@ public class 新集卡_开奖流程_DuibaTest extends DuibaTestBase {
} }
public void clearCardInfo(String itemId ,String comsumerIds) throws Exception{
String dbName = "collect_card_consumer.tb_collect_card_info_"+ String.format("%04d", Long.parseLong(comsumerIds)%1024);
logger.info("用户的分表名dbName为"+dbName);
Boolean res1 = jdbc.update("update "+dbName+" set item_count = '0' where item_id = ? and consumer_id = ?",itemId,comsumerIds);
}
} }
\ No newline at end of file
...@@ -68,7 +68,7 @@ public class pk_列表测试_AccessTest extends DuibaTestBase { ...@@ -68,7 +68,7 @@ public class pk_列表测试_AccessTest extends DuibaTestBase {
List<BetMobileVo> unbetList_uid_18816 = response_uid_18816.jsonPath().getList("data.unbetList",BetMobileVo.class); List<BetMobileVo> unbetList_uid_18816 = response_uid_18816.jsonPath().getList("data.unbetList",BetMobileVo.class);
logger.info("unbetList_uid_188166的信息为"+ JSONObject.toJSONString(unbetList_uid_18816)); logger.info("unbetList_uid_188166的信息为"+ JSONObject.toJSONString(unbetList_uid_18816));
Assert.assertEquals(String.valueOf(unbetList_uid_18816.size()),"0","已投注的活动为0校验失败"); Assert.assertEquals(String.valueOf(unbetList_uid_18816.size()),"0","已投注的活动为0校验失败");
Assert.assertEquals(String.valueOf(betedList_uid_18816.size()),"0","未投注的活动为0校验失败"); Assert.assertEquals(String.valueOf(betedList_uid_18816.size()),"2","未投注的活动为0校验失败");
logger.info("没有添加pk楼层,用户的列表数据校验成功,均为空,betedList_uid_18816="+ JSON.toJSONString(betedList_uid_18816)+"\nunbetList_uid_18816="+ JSON.toJSONString(unbetList_uid_18816)); logger.info("没有添加pk楼层,用户的列表数据校验成功,均为空,betedList_uid_18816="+ JSON.toJSONString(betedList_uid_18816)+"\nunbetList_uid_18816="+ JSON.toJSONString(unbetList_uid_18816));
...@@ -85,7 +85,7 @@ public class pk_列表测试_AccessTest extends DuibaTestBase { ...@@ -85,7 +85,7 @@ public class pk_列表测试_AccessTest extends DuibaTestBase {
List<BetMobileVo> betedList_uided_2239 = response_uided_2239.jsonPath().getList("data.betedList",BetMobileVo.class); 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); List<BetMobileVo> unbetList_uided_2239 = response_uided_2239.jsonPath().getList("data.unbetList",BetMobileVo.class);
Assert.assertEquals(String.valueOf(betedList_uided_2239.size()),"2","已投注的活动为2校验失败"); Assert.assertEquals(String.valueOf(betedList_uided_2239.size()),"2","已投注的活动为2校验失败");
Assert.assertEquals(String.valueOf(unbetList_uided_2239.size()),"4","已投注的活动为4校验失败"); Assert.assertEquals(String.valueOf(unbetList_uided_2239.size()),"5","已投注的活动为4校验失败");
logger.info("添加pk楼层未参加活动,未押注活动列表数据校验成功,unbetList_uided_2239="+ JSON.toJSONString(unbetList_uided_2239)+"\n已押注列表为空betedList_uided_2239="+ JSON.toJSONString(betedList_uided_2239)); logger.info("添加pk楼层未参加活动,未押注活动列表数据校验成功,unbetList_uided_2239="+ JSON.toJSONString(unbetList_uided_2239)+"\n已押注列表为空betedList_uided_2239="+ JSON.toJSONString(betedList_uided_2239));
for (int i=0;i<betedList_uided_2239.size()-1;i++){ for (int i=0;i<betedList_uided_2239.size()-1;i++){
......
...@@ -221,9 +221,10 @@ public class pk_开奖_批量用户开奖测试 extends DuibaTestBase { ...@@ -221,9 +221,10 @@ public class pk_开奖_批量用户开奖测试 extends DuibaTestBase {
try { try {
Boolean result1 = jdbc.update("delete from act_com_conf.tb_bet_option where bet_id in (select id from act_com_conf.tb_bet_config where title like '【自动化】瓜分红包%')"); Boolean result1 = jdbc.update("delete from act_com_conf.tb_bet_option where bet_id in (select id from act_com_conf.tb_bet_config where title like '【自动化】瓜分红包%')");
Boolean result4 = jdbc.update("delete from act_record.tb_bet_record where bet_id in (select id from act_com_conf.tb_bet_config where title like '【自动化】瓜分红包%')");
Boolean result5 = jdbc.update("delete from bet_activity.tb_bet_result where bet_id in (select id from act_com_conf.tb_bet_config where title like '【自动化】瓜分红包%')");
Boolean result2 = 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 like '【自动化】瓜分红包%')"); Boolean result2 = 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 like '【自动化】瓜分红包%')");
Boolean result3 = jdbc.update("delete from act_com_conf.tb_bet_config where title like '【自动化】瓜分红包%'"); Boolean result3 = jdbc.update("delete from act_com_conf.tb_bet_config where title like '【自动化】瓜分红包%'");
Boolean result4 = jdbc.update("delete from act_record.tb_bet_record where bet_id in (select id from act_com_conf.tb_bet_config where title like '【自动化】瓜分红包%')");
clear(consumerIds); clear(consumerIds);
......
/**
* Copyright (C), 2015-2018
* FileName: pk_开奖_瓜分红包_押注人数不同测试_AccessTest
* Author: qianwenjun
* Date: 2018/8/9 20:13
* Description:
*/
package http.cases.PkTest;
import base.DuibaLog;
import base.DuibaTestBase;
import com.alibaba.fastjson.JSONObject;
import http.model.BetMngVo;
import http.service.Activity.PkService;
import http.service.Manager.PkActivityService;
import http.service.Manager.PluginService;
import io.restassured.response.Response;
import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* 〈〉
*
* @author qianwenjun
* @create 2018/8/9
* @since 1.0.0
*/
public class pk_开奖_瓜分优惠券_AccessTest extends DuibaTestBase {
@Autowired
PkService pkService;
@Autowired
PkActivityService pkActivityService;
@Autowired
PluginService pluginService;
private static DuibaLog logger = DuibaLog.getLogger();
private String groupId = "7";
private Integer user01 = 4907;//appid=18816
private String consumerId01 = "100109082";//activity_order_con.tb_trade_center_activity_order_0794
private Integer user02 = 4908;//appid=18816
private String consumerId02 = "100109083";//activity_order_con.tb_trade_center_activity_order_0795
private Integer user03 = 4909;//appid=2239
private String consumerId03 = "100109084";//activity_order_con.tb_trade_center_activity_order_0796
List<String> wins = new ArrayList<>();
List<String> loses = new ArrayList<>();
private String newBetId = "";
private List<String> optionsIds = new ArrayList<>();
private String pluginId = "";
@BeforeMethod
//注意初始化的方法不能与父类的相同,会被覆盖住
public void setUpPkActivity() {
try {
createPk("3","2020-08-12 00:00:00",groupId);
Response cretePlugin = pkActivityService.pluginSave(newBetId);
cretePlugin.prettyPrint();
//先定向再开启
Map<String, Object> mapId = jdbc.findSimpleResult("SELECT * FROM credits_activity.tb_activity_plugin ORDER BY gmt_create DESC LIMIT 1");
pluginId = String.valueOf(mapId.get("id"));
logger.info("pk瓜分优惠券开奖的id为"+pluginId);
pluginService.changeStatus(pluginId, "1");
Boolean res = jdbc.update("update act_com_conf.tb_bet_config set plugin_id = ? where id = ?",pluginId,newBetId);
}catch (Exception e){
e.printStackTrace();
}
}
@Test
public void 调试() throws Exception{
// Response cretePlugin = pkActivityService.pluginSave("1123");
// cretePlugin.prettyPrint();
}
@Test
public void 瓜分红包_两个选项_押注人数不同_开奖测试() throws Exception{
List<Map<String,Object>> pks = jdbc.findModeResult("select * from act_com_conf.tb_bet_option where bet_id = ?",newBetId);
logger.info("pk活动信息为"+JSONObject.toJSONString(pks));
for (int i=0;i<pks.size();i++){
optionsIds.add(pks.get(i).get("id").toString());
}
logger.info("pk活动id为:"+newBetId+",选项id为:"+ optionsIds.toString());
//押注第一个选项:user01,user02
//押注第二个选项:user03,user04
Response res1 = pkService.doJoin(user01,newBetId,optionsIds.get(0));
Response res2 = pkService.doJoin(user02,newBetId,optionsIds.get(1));
Response res3 = pkService.doJoin(user03,newBetId,optionsIds.get(0));
wins.add(consumerId01);
wins.add(consumerId03);
loses.add(consumerId02);
//修改开奖时间
this.modifyOpenPrizeTime(newBetId,60);
// 调用开奖接口
Response doDrowRresponse = pkActivityService.doDraw();
Assert.assertEquals(doDrowRresponse.jsonPath().getString("success"),"true","开奖结果校验失败");
Assert.assertEquals(doDrowRresponse.jsonPath().getString("data"),"开奖中。。。","开奖messag校验失败");
Thread.sleep(8000);
//校验点
//1、pk活动表配置的状态更新为4;2、订单表的addCredits字段为瓜分的红包值;3、先押注 的选项为胜方,胜负的额押注人数>负方的押注人数,4、校验account表的红包值加上去
checkPKConfig();
checkPKResult("18816");
checkUserOrder(wins,loses);
checkRecord(wins,loses);
}
public void createPk(String bounsType,String endTime,String groupId) throws Exception {
Response betResponse = pkActivityService.betForSetUp(bounsType,endTime);
logger.info("新建pk活动的结果信息为"+JSONObject.toJSONString(betResponse.prettyPrint()));
betResponse.prettyPrint();
String betId = betResponse.jsonPath().getString("data");newBetId = betId;
logger.info("newBetId的信息为"+newBetId);
Response betRelation = pkActivityService.betGroupRelation(betId,endTime,groupId);
Response modifyStatusResponse = pkActivityService.modifySatus(betId);
}
public void modifyOpenPrizeTime(String betId,int x) throws Exception{
DateTime time1 = new DateTime();
DateTime endTime = time1.minusMillis(x);
DateTimeFormatter format = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss");
String endTimeStr = "2018-11-26 20:24:39";
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 = ?\n",endTimeStr,betId);
Boolean result2 = jdbc.update("update act_com_conf.tb_bet_group_relation set end_time = ? where bet_id = ?\n",endTimeStr,betId);
}
public void checkPKConfig() throws Exception{
Map<String,Object> betConfig = jdbc.findSimpleResult("select * from act_com_conf.tb_bet_config where id = ?",newBetId);
logger.info("betConfig的信息为:"+ JSONObject.toJSONString(betConfig));
Assert.assertEquals(betConfig.get("config_status").toString(),"4","配置表状态更新失败");
Map<String,Object> betGroupRelation = jdbc.findSimpleResult("select * from act_com_conf.tb_bet_group_relation where bet_id = ?\n",newBetId);
Assert.assertEquals(betGroupRelation.get("config_status").toString(),"4","pk关系表开奖状态更新失败");
logger.info("pk活动配置表状态更新为:"+betConfig.get("config_status").toString()+",pk关系表活动状态更新为:"+betGroupRelation.get("config_status").toString());
Response betList = pkActivityService.getMngBetList();
// betList.prettyPrint();
List<BetMngVo> betMngVoList = betList.jsonPath().getList("data.page",BetMngVo.class);
for (BetMngVo bet:betMngVoList){
if (bet.getId().equals(newBetId)){
Assert.assertEquals(bet.getConfigStatus(),"4","开奖结果校验失败");
}
}
}
public void checkPKResult(String appId) throws Exception{
Map<String,Object> bet1Result = jdbc.findSimpleResult("select * from bet_activity.tb_bet_result where bet_id = ? and option_id = ? and app_id = ?\n",newBetId,optionsIds.get(0),appId);
Assert.assertEquals(bet1Result.get("rank").toString(),"1","开始押注的选项获胜校验失败");
Map<String,Object> bet2Result = jdbc.findSimpleResult("select * from bet_activity.tb_bet_result where bet_id = ? and option_id = ? and app_id = ?\n",newBetId,optionsIds.get(1),appId);
Assert.assertEquals(bet2Result.get("rank").toString(),"2","开始押注的选项获胜校验失败");
Long bet1Times = Long.valueOf(bet1Result.get("bet_times").toString());
Long bet2Times = Long.valueOf(bet2Result.get("bet_times").toString());
Assert.assertTrue(bet1Times>bet2Times,"活动获胜人数比失败人数多校验失败");
logger.info("选项1的押注人数为:"+bet1Result.get("bet_times").toString()+",选项2的押注人数为:"+bet2Result.get("bet_times").toString());
}
public void checkUserOrder(List<String> wins,List<String> loses) throws Exception{
for (int i=0;i<wins.size();i++){
String dbName = "activity_order_con.tb_trade_center_activity_order_"+ String.format("%04d", Long.parseLong(wins.get(i)) % 1024);
logger.info("用户的分表名dbName为"+dbName);
Map<String,Object> user_order = jdbc.findSimpleResult("select * from "+dbName+" where consumer_id = ? and duiba_activity_id = ?\n",wins.get(i),newBetId);
Long account = Long.valueOf(user_order.get("exchange_status").toString());
Assert.assertEquals(account.toString(),"1","开奖后订单更新");
logger.info("用户"+wins.get(i)+"订单状态为待领奖:"+user_order.get("exchange_status").toString());
}
for (int i=0;i<loses.size();i++){
String dbName = "activity_order_con.tb_trade_center_activity_order_"+ String.format("%04d", Long.parseLong(loses.get(i)) % 1024);
logger.info("用户的分表名dbName为"+dbName);
Map<String,Object> user_order = jdbc.findSimpleResult("select * from "+dbName+" where consumer_id = ? and duiba_activity_id = ?\n",loses.get(i),newBetId);
String account = user_order.get("exchange_status").toString();
Assert.assertEquals(account.toString(),"-1","开奖后订单更新");
logger.info("用户"+loses.get(i)+"订单状态为:"+user_order.get("add_credits").toString());
}
}
public void checkRecord(List<String> wins,List<String> loses) throws Exception{
for (int i=0;i<wins.size();i++){
Map<String,Object> useRecord = jdbc.findSimpleResult("select * from act_record.tb_bet_record where bet_id = ? and consumer_id = ? \n",newBetId,wins.get(i));
Assert.assertEquals(useRecord.get("bonus").toString(), "0", "record表的红包值校验失败");
Assert.assertEquals(useRecord.get("exchange_status").toString(), "1", "record表的发奖状态校验失败");
logger.info("用户"+wins.get(i)+"订单获取的红包值为:"+useRecord.get("bonus").toString()+"领奖状态为待领奖"+useRecord.get("exchange_status").toString());
}
for (int i=0;i<loses.size();i++){
Map<String,Object> useRecord = jdbc.findSimpleResult("select * from act_record.tb_bet_record where bet_id = ? and consumer_id = ? \n",newBetId,loses.get(i));
Assert.assertEquals(useRecord.get("bonus").toString(), "0", "record表的红包值校验失败");
Assert.assertEquals(useRecord.get("exchange_status").toString(), "0", "record表的发奖状态校验失败");
logger.info("用户"+loses.get(i)+"订单获取的红包值为:"+useRecord.get("bonus").toString()+"领奖状态为待领奖"+useRecord.get("exchange_status").toString());
}
}
// @AfterClass
public void tearDown() {
try {
Boolean result1 = jdbc.update("delete from act_com_conf.tb_bet_option where bet_id in (select id from act_com_conf.tb_bet_config where title like '【自动化】瓜分优惠券%')");
Boolean result4 = jdbc.update("delete from act_record.tb_bet_record where bet_id in (select id from act_com_conf.tb_bet_config where title like '【自动化】瓜分优惠券%')");
Boolean result5 = jdbc.update("delete from bet_activity.tb_bet_result where bet_id in (select id from act_com_conf.tb_bet_config where title like '【自动化】瓜分优惠券%')");
Boolean result2 = 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 like '【自动化】瓜分优惠券%')");
Boolean result3 = jdbc.update("delete from act_com_conf.tb_bet_config where title like '【自动化】瓜分优惠券%'");
Boolean result7 = jdbc.update("delete from credits_activity.tb_activity_center_option where activity_id in (select id from credits_activity.tb_activity_plugin where title like '【自动化】pk开奖%')\n");
Boolean result6 = jdbc.update("delete from credits_activity.tb_activity_plugin where title like '【自动化】pk开奖%'\n");
} catch (SQLException e) {
e.printStackTrace();
} catch (Exception e){
e.printStackTrace();
}
}
}
\ No newline at end of file
/**
* Copyright (C), 2015-2018
* FileName: pk_开奖_瓜分红包_押注人数不同测试_AccessTest
* Author: qianwenjun
* Date: 2018/8/9 20:13
* Description:
*/
package http.cases.PkTest;
import base.DuibaLog;
import base.DuibaTestBase;
import com.alibaba.fastjson.JSONObject;
import http.model.BetMngVo;
import http.service.Activity.PkService;
import http.service.Manager.PkActivityService;
import io.restassured.response.Response;
import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* 〈〉
*
* @author qianwenjun
* @create 2018/8/9
* @since 1.0.0
*/
public class pk_开奖_瓜分红包_投放两个app_AccessTest extends DuibaTestBase {
@Autowired
PkService pkService;
@Autowired
PkActivityService pkActivityService;
private static DuibaLog logger = DuibaLog.getLogger();
private String groupId = "6,7";
private Integer user01 = 4812;//appid=18816
private String consumerId01 = "100108112";//activity_order_con.tb_trade_center_activity_order_0848
private Integer user02 = 4813;//appid=18816
private String consumerId02 = "100108113";//activity_order_con.tb_trade_center_activity_order_0849
private Integer user03 = 4814;//appid=2239
private String consumerId03 = "100108114";//activity_order_con.tb_trade_center_activity_order_0850
private Integer user04 = 4815;//appid=2239
private String consumerId04 = "100108115";//activity_order_con.tb_trade_center_activity_order_0851
List<String> wins = new ArrayList<>();
List<String> loses = new ArrayList<>();
private String newBetId = "";
private List<String> optionsIds = new ArrayList<>();
@BeforeMethod
//注意初始化的方法不能与父类的相同,会被覆盖住
public void setUpPkActivity() {
try {
createPk("2","2020-08-12 00:00:00",groupId);
}catch (Exception e){
e.printStackTrace();
}
}
@Test
public void 瓜分红包_两个选项_押注人数不同_开奖测试() throws Exception{
List<Map<String,Object>> pks = jdbc.findModeResult("select * from act_com_conf.tb_bet_option where bet_id = ?",newBetId);
logger.info("pk活动信息为"+JSONObject.toJSONString(pks));
for (int i=0;i<pks.size();i++){
optionsIds.add(pks.get(i).get("id").toString());
}
logger.info("pk活动id为:"+newBetId+",选项id为:"+ optionsIds.toString());
Map<String,Object> user01_account1 = jdbc.findSimpleResult("select * from consumer_accounts.tb_consumer_account_0848 where consumer_id = '100108112' and account_type = '6'\n");
Long use1_Acc1 = Long.valueOf(user01_account1.get("balance_amount").toString());
Map<String,Object> user02_account1 = jdbc.findSimpleResult("select * from consumer_accounts.tb_consumer_account_0849 where consumer_id = '100108113' and account_type = '6'\n");
Long use2_Acc1 = Long.valueOf(user02_account1.get("balance_amount").toString());
Map<String,Object> user03_account1 = jdbc.findSimpleResult("select * from consumer_accounts.tb_consumer_account_0850 where consumer_id = '100108114' and account_type = '6'\n");
Long use3_Acc1 = Long.valueOf(user03_account1.get("balance_amount").toString());
Map<String,Object> user04_account1 = jdbc.findSimpleResult("select * from consumer_accounts.tb_consumer_account_0851 where consumer_id = '100108115' and account_type = '6'\n");
Long use4_Acc1 = Long.valueOf(user04_account1.get("balance_amount").toString());
//押注第一个选项:user01,user02
//押注第二个选项:user03,user04
Response res1 = pkService.doJoin(user01,newBetId,optionsIds.get(0));
Response res2 = pkService.doJoin(user02,newBetId,optionsIds.get(1));
Response res3 = pkService.doJoin(user03,newBetId,optionsIds.get(0));
Response res4 = pkService.doJoin(user04,newBetId,optionsIds.get(1));
wins.add(consumerId01);
wins.add(consumerId03);
loses.add(consumerId02);
loses.add(consumerId04);
//修改开奖时间
this.modifyOpenPrizeTime(newBetId,60);
//调用开奖接口
Response doDrowRresponse = pkActivityService.doDraw();
Assert.assertEquals(doDrowRresponse.jsonPath().getString("success"),"true","开奖结果校验失败");
Assert.assertEquals(doDrowRresponse.jsonPath().getString("data"),"开奖中。。。","开奖messag校验失败");
Thread.sleep(8000);
//校验点
//1、pk活动表配置的状态更新为4;2、订单表的addCredits字段为瓜分的红包值;3、先押注 的选项为胜方,胜负的额押注人数>负方的押注人数,4、校验account表的红包值加上去
checkPKConfig();
checkPKResult("18816");
checkPKResult("2239");
checkUserOrder(wins,loses);
checkRecord(wins,loses);
Map<String,Object> user01_account2 = jdbc.findSimpleResult("select * from consumer_accounts.tb_consumer_account_0848 where consumer_id = '100108112' and account_type = '6'\n");
Long use1_Acc2 = Long.valueOf(user01_account2.get("balance_amount").toString());
Assert.assertEquals(use1_Acc2.toString(),String.valueOf(use1_Acc1+10),"用户1入账校验失败");
Map<String,Object> user02_account2 = jdbc.findSimpleResult("select * from consumer_accounts.tb_consumer_account_0849 where consumer_id = '100108113' and account_type = '6'\n");
Long use2_Acc2 = Long.valueOf(user02_account2.get("balance_amount").toString());
Assert.assertEquals(use2_Acc2,use2_Acc1,"用户2入账校验失败");
Map<String,Object> user03_account2 = jdbc.findSimpleResult("select * from consumer_accounts.tb_consumer_account_0850 where consumer_id = '100108114' and account_type = '6'\n");
Long use3_Acc2 = Long.valueOf(user03_account2.get("balance_amount").toString());
Assert.assertEquals(use3_Acc2.toString(),String.valueOf(use3_Acc1+10),"用户3入账校验失败");
Map<String,Object> user04_account2 = jdbc.findSimpleResult("select * from consumer_accounts.tb_consumer_account_0851 where consumer_id = '100108115' and account_type = '6'\n");
Long use4_Acc2 = Long.valueOf(user04_account2.get("balance_amount").toString());
Assert.assertEquals(use4_Acc2,use4_Acc1,"用户4入账校验失败");
}
public void createPk(String bounsType,String endTime,String groupId) throws Exception {
Response betResponse = pkActivityService.betForSetUp(bounsType,endTime);
logger.info("新建pk活动的结果信息为"+JSONObject.toJSONString(betResponse.prettyPrint()));
betResponse.prettyPrint();
String betId = betResponse.jsonPath().getString("data");newBetId = betId;
logger.info("newBetId的信息为"+newBetId);
Response betRelation = pkActivityService.betGroupRelation(betId,endTime,groupId);
Response modifyStatusResponse = pkActivityService.modifySatus(betId);
}
public void modifyOpenPrizeTime(String betId,int x) throws Exception{
DateTime time1 = new DateTime();
// int x=20+(int)(Math.random()*100);
DateTime endTime = time1.minusMillis(x);
DateTimeFormatter format = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss");
// String endTimeStr = format.print(endTime.getMillis()).toString();
String endTimeStr = "2018-11-26 20:24:39";
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 = ?\n",endTimeStr,betId);
Boolean result2 = jdbc.update("update act_com_conf.tb_bet_group_relation set end_time = ? where bet_id = ?\n",endTimeStr,betId);
}
public void checkPKConfig() throws Exception{
Map<String,Object> betConfig = jdbc.findSimpleResult("select * from act_com_conf.tb_bet_config where id = ?",newBetId);
logger.info("betConfig的信息为:"+ JSONObject.toJSONString(betConfig));
Assert.assertEquals(betConfig.get("config_status").toString(),"4","配置表状态更新失败");
Map<String,Object> betGroupRelation = jdbc.findSimpleResult("select * from act_com_conf.tb_bet_group_relation where bet_id = ?\n",newBetId);
Assert.assertEquals(betGroupRelation.get("config_status").toString(),"4","pk关系表开奖状态更新失败");
logger.info("pk活动配置表状态更新为:"+betConfig.get("config_status").toString()+",pk关系表活动状态更新为:"+betGroupRelation.get("config_status").toString());
Response betList = pkActivityService.getMngBetList();
betList.prettyPrint();
List<BetMngVo> betMngVoList = betList.jsonPath().getList("data.page",BetMngVo.class);
for (BetMngVo bet:betMngVoList){
if (bet.getId().equals(newBetId)){
Assert.assertEquals(bet.getConfigStatus(),"4","开奖结果校验失败");
}
}
}
public void checkPKResult(String appId) throws Exception{
Map<String,Object> bet1Result = jdbc.findSimpleResult("select * from bet_activity.tb_bet_result where bet_id = ? and option_id = ? and app_id = ?\n",newBetId,optionsIds.get(0),appId);
Assert.assertEquals(bet1Result.get("rank").toString(),"1","开始押注的选项获胜校验失败");
Map<String,Object> bet2Result = jdbc.findSimpleResult("select * from bet_activity.tb_bet_result where bet_id = ? and option_id = ? and app_id = ?\n",newBetId,optionsIds.get(1),appId);
Assert.assertEquals(bet2Result.get("rank").toString(),"2","开始押注的选项获胜校验失败");
Long bet1Times = Long.valueOf(bet1Result.get("bet_times").toString());
Long bet2Times = Long.valueOf(bet2Result.get("bet_times").toString());
Assert.assertTrue(bet1Times>bet2Times,"活动获胜人数比失败人数多校验失败");
logger.info("选项1的押注人数为:"+bet1Result.get("bet_times").toString()+",选项2的押注人数为:"+bet2Result.get("bet_times").toString());
}
public void checkUserOrder(List<String> wins,List<String> loses) throws Exception{
for (int i=0;i<wins.size();i++){
String dbName = "activity_order_con.tb_trade_center_activity_order_"+ String.format("%04d", Long.parseLong(wins.get(i)) % 1024);
logger.info("用户的分表名dbName为"+dbName);
Map<String,Object> user_order = jdbc.findSimpleResult("select * from "+dbName+" where consumer_id = ? and duiba_activity_id = ?\n",wins.get(i),newBetId);
Long account = Long.valueOf(user_order.get("add_credits").toString());
Assert.assertEquals(account.toString(),"10","开奖后订单更新");
logger.info("用户"+wins.get(i)+"订单获取的红包值为:"+user_order.get("add_credits").toString());
}
for (int i=0;i<loses.size();i++){
String dbName = "activity_order_con.tb_trade_center_activity_order_"+ String.format("%04d", Long.parseLong(loses.get(i)) % 1024);
logger.info("用户的分表名dbName为"+dbName);
Map<String,Object> user_order = jdbc.findSimpleResult("select * from "+dbName+" where consumer_id = ? and duiba_activity_id = ?\n",loses.get(i),newBetId);
String account = user_order.get("add_credits").toString();
Assert.assertEquals(account.toString(),"","开奖后订单更新");
logger.info("用户"+loses.get(i)+"订单获取的红包值为:"+user_order.get("add_credits").toString());
}
}
public void checkRecord(List<String> wins,List<String> loses) throws Exception{
for (int i=0;i<wins.size();i++){
Map<String,Object> useRecord = jdbc.findSimpleResult("select * from act_record.tb_bet_record where bet_id = ? and consumer_id = ? \n",newBetId,wins.get(i));
Assert.assertEquals(useRecord.get("bonus").toString(), "10", "record表的红包值校验失败");
Assert.assertEquals(useRecord.get("exchange_status").toString(), "2", "record表的发奖状态校验失败");
logger.info("用户"+wins.get(i)+"订单获取的红包值为:"+useRecord.get("bonus").toString());
}
for (int i=0;i<loses.size();i++){
Map<String,Object> useRecord = jdbc.findSimpleResult("select * from act_record.tb_bet_record where bet_id = ? and consumer_id = ? \n",newBetId,loses.get(i));
Assert.assertEquals(useRecord.get("bonus").toString(), "0", "record表的红包值校验失败");
Assert.assertEquals(useRecord.get("exchange_status").toString(), "0", "record表的发奖状态校验失败");
logger.info("用户"+loses.get(i)+"订单获取的红包值为:"+useRecord.get("bonus").toString());
}
}
@AfterClass
public void tearDown() {
try {
Boolean result1 = jdbc.update("delete from act_com_conf.tb_bet_option where bet_id in (select id from act_com_conf.tb_bet_config where title like '【自动化】瓜分红包%')");
Boolean result4 = jdbc.update("delete from act_record.tb_bet_record where bet_id in (select id from act_com_conf.tb_bet_config where title like '【自动化】瓜分红包%')");
Boolean result5 = jdbc.update("delete from bet_activity.tb_bet_result where bet_id in (select id from act_com_conf.tb_bet_config where title like '【自动化】瓜分红包%')");
Boolean result2 = 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 like '【自动化】瓜分红包%')");
Boolean result3 = jdbc.update("delete from act_com_conf.tb_bet_config where title like '【自动化】瓜分红包%'");
} catch (SQLException e) {
e.printStackTrace();
} catch (Exception e){
e.printStackTrace();
}
}
}
\ No newline at end of file
...@@ -234,6 +234,7 @@ public class pk_开奖_瓜分红包_押注人数不同测试_AccessTest extends ...@@ -234,6 +234,7 @@ public class pk_开奖_瓜分红包_押注人数不同测试_AccessTest extends
Boolean result1 = jdbc.update("delete from act_com_conf.tb_bet_option where bet_id in (select id from act_com_conf.tb_bet_config where title like '【自动化】瓜分红包%')"); Boolean result1 = jdbc.update("delete from act_com_conf.tb_bet_option where bet_id in (select id from act_com_conf.tb_bet_config where title like '【自动化】瓜分红包%')");
Boolean result4 = jdbc.update("delete from act_record.tb_bet_record where bet_id in (select id from act_com_conf.tb_bet_config where title like '【自动化】瓜分红包%')"); Boolean result4 = jdbc.update("delete from act_record.tb_bet_record where bet_id in (select id from act_com_conf.tb_bet_config where title like '【自动化】瓜分红包%')");
Boolean result5 = jdbc.update("delete from bet_activity.tb_bet_result where bet_id in (select id from act_com_conf.tb_bet_config where title like '【自动化】瓜分红包%')");
Boolean result2 = 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 like '【自动化】瓜分红包%')"); Boolean result2 = 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 like '【自动化】瓜分红包%')");
Boolean result3 = jdbc.update("delete from act_com_conf.tb_bet_config where title like '【自动化】瓜分红包%'"); Boolean result3 = jdbc.update("delete from act_com_conf.tb_bet_config where title like '【自动化】瓜分红包%'");
......
...@@ -186,6 +186,7 @@ public class pk_开奖_瓜分红包_押注人数相同测试_AccessTest extends ...@@ -186,6 +186,7 @@ public class pk_开奖_瓜分红包_押注人数相同测试_AccessTest extends
Boolean result1 = jdbc.update("delete from act_com_conf.tb_bet_option where bet_id in (select id from act_com_conf.tb_bet_config where title like '【自动化】瓜分红包%')"); Boolean result1 = jdbc.update("delete from act_com_conf.tb_bet_option where bet_id in (select id from act_com_conf.tb_bet_config where title like '【自动化】瓜分红包%')");
Boolean result4 = jdbc.update("delete from act_record.tb_bet_record where bet_id in (select id from act_com_conf.tb_bet_config where title like '【自动化】瓜分红包%')"); Boolean result4 = jdbc.update("delete from act_record.tb_bet_record where bet_id in (select id from act_com_conf.tb_bet_config where title like '【自动化】瓜分红包%')");
Boolean result5 = jdbc.update("delete from bet_activity.tb_bet_result where bet_id in (select id from act_com_conf.tb_bet_config where title like '【自动化】瓜分红包%')");
Boolean result2 = 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 like '【自动化】瓜分红包%')"); Boolean result2 = 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 like '【自动化】瓜分红包%')");
Boolean result3 = jdbc.update("delete from act_com_conf.tb_bet_config where title like '【自动化】瓜分红包%'"); Boolean result3 = jdbc.update("delete from act_com_conf.tb_bet_config where title like '【自动化】瓜分红包%'");
......
...@@ -10,7 +10,9 @@ package http.cases.PkTest; ...@@ -10,7 +10,9 @@ package http.cases.PkTest;
import base.DuibaLog; import base.DuibaLog;
import base.DuibaTestBase; import base.DuibaTestBase;
import com.alibaba.fastjson.JSONObject;
import http.service.Activity.PkService; import http.service.Activity.PkService;
import http.service.Manager.EditManagerInfoService;
import http.service.hd.DeveloperConfigService; import http.service.hd.DeveloperConfigService;
import io.restassured.response.Response; import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -19,8 +21,10 @@ import org.testng.Assert; ...@@ -19,8 +21,10 @@ import org.testng.Assert;
import org.testng.annotations.AfterMethod; import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod; import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import utils.GetCookieUtil;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -38,6 +42,10 @@ public class pk_押注测试_AccessTest extends DuibaTestBase { ...@@ -38,6 +42,10 @@ public class pk_押注测试_AccessTest extends DuibaTestBase {
PkService pkService; PkService pkService;
@Autowired @Autowired
DeveloperConfigService developerConfigService; DeveloperConfigService developerConfigService;
@Autowired
EditManagerInfoService editManagerInfoService;
private DuibaLog logger = DuibaLog.getLogger(); private DuibaLog logger = DuibaLog.getLogger();
...@@ -47,6 +55,7 @@ public class pk_押注测试_AccessTest extends DuibaTestBase { ...@@ -47,6 +55,7 @@ public class pk_押注测试_AccessTest extends DuibaTestBase {
private static String uid02_consumerId = "100066016"; private static String uid02_consumerId = "100066016";
private String consumerIds = "";
private List<String> orderIds = new ArrayList<>(); private List<String> orderIds = new ArrayList<>();
...@@ -68,7 +77,7 @@ public class pk_押注测试_AccessTest extends DuibaTestBase { ...@@ -68,7 +77,7 @@ public class pk_押注测试_AccessTest extends DuibaTestBase {
@Test @Test
public void 押注测试() throws Exception{ public void 押注_红包活动测试() throws Exception{
Map<String,Object> user = jdbc.findSimpleResult("select * from dafuweng.user where id=?\n",uid01); 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); 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 userCredit = Long.parseLong(user.get("credits").toString());
...@@ -143,6 +152,40 @@ public class pk_押注测试_AccessTest extends DuibaTestBase { ...@@ -143,6 +152,40 @@ public class pk_押注测试_AccessTest extends DuibaTestBase {
} }
@Test
public void 押注_新用户首次参与测试() throws Exception{
Map<String,String> user = this.createUser();
consumerIds = user.get("consumerId");
logger.info("consumerIds的信息为"+consumerIds);
Response doJoinResponse = pkService.doJoin2(Integer.valueOf(user.get("uid")),"124","248");
doJoinResponse.prettyPrint();
Assert.assertEquals(doJoinResponse.jsonPath().getString("code").toString(),"100060");
}
public Map<String,String> createUser() throws Exception{
Map<String,String> map = new HashMap<>();
Response response = editManagerInfoService.createUser("pk活动首次参与用户");
Map<String,Object> user = jdbc.findSimpleResult("select * from dafuweng.user where name = 'pk活动首次参与用户' and app_id = '67'\n");
String uid = user.get("id").toString();
String url = GetCookieUtil.genUrl(uid,"3erv8LvBxKBSyuGK5i8FSGyYoFD1");
JSONObject cookie = GetCookieUtil.getConsumerIdFromCookie(url);
map.put("uid",uid);
map.put("consumerId",cookie.get("cid").toString());
logger.info("用户信息为,uid="+uid+"consumerId="+cookie.get("cid").toString());
return map;
}
public void clear(String comsumerIds) throws Exception{
Boolean res = jdbc.update("delete from dafuweng.user where name = 'pk活动首次参与用户' and app_id = '67'");
String dbName = "new_consumer.consumer_"+ String.format("%04d", Long.parseLong(comsumerIds)/10000000);
logger.info("用户的分表名dbName为"+dbName);
Boolean res1 = jdbc.update("delete from "+dbName+" where id = ?",comsumerIds);
}
@AfterMethod @AfterMethod
public void tearDown() { public void tearDown() {
...@@ -152,6 +195,8 @@ public class pk_押注测试_AccessTest extends DuibaTestBase { ...@@ -152,6 +195,8 @@ public class pk_押注测试_AccessTest extends DuibaTestBase {
for (String orderId:orderIds){ for (String orderId:orderIds){
Boolean result2 = jdbc.update("delete from activity_order_con.tb_trade_center_activity_order_0735 where order_num = ?\n",orderId); Boolean result2 = jdbc.update("delete from activity_order_con.tb_trade_center_activity_order_0735 where order_num = ?\n",orderId);
} }
clear(consumerIds);
}catch (Exception e){ }catch (Exception e){
e.printStackTrace(); e.printStackTrace();
......
...@@ -150,9 +150,10 @@ public class PluginDrawingtool_pluginTest extends DuibaTestBase { ...@@ -150,9 +150,10 @@ public class PluginDrawingtool_pluginTest extends DuibaTestBase {
logger.info("校验链接券码成功"); logger.info("校验链接券码成功");
break; break;
case 2: case 2:
Assert.assertTrue(response.jsonPath().getString("lottery.openUrl").contains("//activity.m.duibatest.com.cn/crecord/recordDetailNew")); // Assert.assertTrue(response.jsonPath().getString("lottery.openUrl").contains("//activity.m.duibatest.com.cn/crecord/recordDetailNew"));
Assert.assertTrue(response.jsonPath().getString("lottery.iosDownloadUrl").contains("//activity.m.duibatest.com.cn/crecord/recordDetailNew"));
Assert.assertEquals(response.jsonPath().getString("lottery.id"), "2003", "校验id失败"); Assert.assertEquals(response.jsonPath().getString("lottery.id"), "2003", "校验id失败");
Assert.assertEquals(response.jsonPath().getString("lottery.showUse"), "true", "校验是否展示马上使用失败"); Assert.assertEquals(response.jsonPath().getString("lottery.showUse"), "false", "校验是否展示马上使用失败");
Assert.assertEquals(response.jsonPath().getString("lottery.useBtnText"), "查看使用方法", "校验按钮文案展示失败"); Assert.assertEquals(response.jsonPath().getString("lottery.useBtnText"), "查看使用方法", "校验按钮文案展示失败");
logger.info("校验跳转兑换记录链接成功"); logger.info("校验跳转兑换记录链接成功");
break; break;
......
...@@ -78,7 +78,7 @@ public class 插件_优惠券测试_pluginTest extends DuibaTestBase { ...@@ -78,7 +78,7 @@ public class 插件_优惠券测试_pluginTest extends DuibaTestBase {
String androidDL = MatcherString.getString(managerResponse.asString(), "androidurl: '(.*?)',", 1); String androidDL = MatcherString.getString(managerResponse.asString(), "androidurl: '(.*?)',", 1);
String iOSDL = MatcherString.getString(managerResponse.asString(), "iosurl: '(.*?)',", 1); String iOSDL = MatcherString.getString(managerResponse.asString(), "iosurl: '(.*?)',", 1);
String usebtn = MatcherString.getString(managerResponse.asString(), "usebtn: '(.*?)',", 1); String usebtn = MatcherString.getString(managerResponse.asString(), "usebtn: '(.*?)',", 1);
String actLinkEx = "//activity.m.duibatest.com.cn/crecord/recordDetailNew/"; String actLinkEx = "//activity.m.duibatest.com.cn/crecord/recordDetailNew";
String linkUrl = MatcherString.getString(linkResponse.asString(), "target=\"_blank\" href=\"(.*?)\">", 1); String linkUrl = MatcherString.getString(linkResponse.asString(), "target=\"_blank\" href=\"(.*?)\">", 1);
//进行接口测试传参 //进行接口测试传参
......
package http.cases.SaasDeveloperTest;
import base.Config;
import base.DuibaTestBase;
import http.service.Saas.DeveloperBJZ;
import base.DuibaLog;
import http.service.Saas.DeveloperObjectService;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
import org.testng.Assert;
import org.testng.annotations.Test;
@ContextConfiguration(classes = Config.class)
public class 补给站 extends DuibaTestBase {
@Autowired
DeveloperBJZ developerBJZ;
@Autowired
DeveloperObjectService developerObjectService;
private DuibaLog logger = DuibaLog.getLogger();
String appId="19515";
//添加、上架至尊版实物
@Test
public void a_添加至尊版实物() throws Exception{
//查询列表,获取ID
Response response =developerBJZ.item("2");
String id= String.valueOf(response.jsonPath().getString("data.list[0].id"));
String title= String.valueOf(response.jsonPath().getString("data.list[0].title"));
//添加
developerBJZ.ajaxAddRepo(appId,id);
//上架
developerBJZ.ajaxDirectUp(appId,id);
//查询商品列表,验证商品是否上架成功
Response response2 =developerObjectService.appItems(appId,title);
String appItemId = String.valueOf(response2.jsonPath().getString("data.list[0].id"));
Assert.assertEquals(response2.jsonPath().getString("data.list[0].title"), "测试至尊享版-实物3", "校验实物标题失败");
Assert.assertEquals(response2.jsonPath().getString("data.list[0].status"), "1", "校验实物状态失败");
Assert.assertEquals(response2.jsonPath().getString("data.list[0].type"), "object", "校验实物类型失败");
logger.info("校验title,status成功");
//删除添加的商品
developerObjectService.ajaxDel(appItemId);
}
//添加、上架优惠券
@Test
public void b_添加至尊版优惠券() throws Exception{
//查询列表,获取ID
Response response =developerBJZ.coupons(appId,"2");
String id= String.valueOf(response.jsonPath().getString("data.list[0].id"));
String title= String.valueOf(response.jsonPath().getString("data.list[0].title"));
//添加
developerBJZ.ajaxAddRepo(appId,id);
//上架
developerBJZ.ajaxDirectUp(appId,id);
//查询商品列表,验证商品是否上架成功
Response response2 =developerObjectService.appItems(appId,title);
String appItemId = String.valueOf(response2.jsonPath().getString("data.list[0].id"));
Assert.assertEquals(response2.jsonPath().getString("data.list[0].title"), "测试至尊享版-优惠券", "校验优惠券标题名称失败");
Assert.assertEquals(response2.jsonPath().getString("data.list[0].status"), "1", "校验优惠券状态失败");
Assert.assertEquals(response2.jsonPath().getString("data.list[0].type"), "coupon", "校验优惠券类型失败");
logger.info("校验title,status成功");
//删除添加的商品
developerObjectService.ajaxDel(appItemId);
}
//添加活动
@Test
public void c_添加活动() throws Exception{
//查询热门活动-活动列表,获取商品ID
Response response=developerBJZ.saasActivitys("3");
String goodItemId= String.valueOf(response.jsonPath().getString("data.saasActivitys[0].id"));
//获取商品ID,进入商品订购页面,获取SKU
Response response2=developerBJZ.itemOrderDetail(goodItemId);
String skuId= String.valueOf(response2.jsonPath().getString("data.goodsItemSku[0].skuId"));
//点击订购,传入SKU创建订单
logger.info("kuid==="+skuId);
Response response3=developerBJZ.createAutomationOrderNew(skuId);
String orderid= String.valueOf(response3.jsonPath().getString("data"));
logger.info("kuid==="+orderid);
//下单购买
Response response4=developerBJZ.orderAccountPay(orderid);
}
}
package http.cases.SaasDeveloperTest;
import base.Config;
import http.service.Saas.DeveloperBJZ;
import base.DuibaLog;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
import org.testng.Assert;
import org.testng.annotations.Test;
@ContextConfiguration(classes = Config.class)
public class 补给站_商品_DuibaTest extends AbstractTestNGSpringContextTests {
@Autowired
DeveloperBJZ developerBJZ;
private DuibaLog logger = DuibaLog.getLogger();
//至尊版app
private static String appId = "19515";
//旗舰版app
private static String appId2 = "21695";
@Test(description = "至尊版app添加、上架至尊版实物")
public void a_添加至尊版实物() throws Exception {
//查询列表,获取ID
Response response = developerBJZ.items("2", appId);
String itemId = String.valueOf(response.jsonPath().getString("data.list[0].id"));
String itemIds = String.valueOf(response.jsonPath().getString("data.list[0].id"));
String itemName = String.valueOf(response.jsonPath().getString("data.list[0].title"));
//添加
developerBJZ.ajaxAddRepo(appId, itemId);
//上架
developerBJZ.ajaxDirectUp(appId, itemIds);
//查询商品列表,验证商品是否上架成功
Response response2 = developerBJZ.appItems(appId, itemName);
String appItemId2 = response2.jsonPath().getString("data.list[0].id");
Assert.assertEquals(response2.jsonPath().getString("data.list[0].title"), "测试至尊享版-实物3", "校验实物标题失败");
Assert.assertEquals(response2.jsonPath().getString("data.list[0].status"), "1", "校验实物状态失败");
Assert.assertEquals(response2.jsonPath().getString("data.list[0].type"), "object", "校验实物类型失败");
logger.info("校验title,status,type成功");
//删除添加的商品
developerBJZ.ajaxDel(appId, appItemId2);
}
@Test(description = "旗舰版app添加、上架至尊版实物:异常场景,提示不能上架")
public void b_旗舰版添加至尊版实物() throws Exception {
//查询列表,获取ID
Response response = developerBJZ.items("2", appId2);
String id = String.valueOf(response.jsonPath().getString("data.list[0].id"));
//上架
Response response2 = developerBJZ.ajaxDirectUp2(appId2, id);
//接口提示,至尊版专享,不能上架
Assert.assertEquals(response2.jsonPath().getString("desc"), "至尊版专享", "校验接口上架失败");
}
@Test(description = "优质好货搜索功能")
public void c_实物搜索() throws Exception {
// 根据具体的名称搜索出实物
developerBJZ.items2("2", appId);
// 输入精确的名称查询不到此实物
developerBJZ.items3("2", appId);
}
@Test(description = "//添加、上架优惠券")
public void d_添加至尊版优惠券() throws Exception {
//查询列表,获取ID
Response response = developerBJZ.coupons(appId, "2");
String itemId = String.valueOf(response.jsonPath().getString("data.list[0].id"));
String itemIds = String.valueOf(response.jsonPath().getString("data.list[0].id"));
String itemName = String.valueOf(response.jsonPath().getString("data.list[0].title"));
//添加
developerBJZ.ajaxAddRepo(appId, itemId);
//上架
developerBJZ.ajaxDirectUp(appId, itemIds);
//查询商品列表,验证商品是否上架成功
Response response2 = developerBJZ.appItems(appId, itemName);
String appItemId2 = String.valueOf(response2.jsonPath().getString("data.list[0].id"));
Assert.assertEquals(response2.jsonPath().getString("data.list[0].title"), "测试至尊享版-优惠券", "校验优惠券标题名称失败");
Assert.assertEquals(response2.jsonPath().getString("data.list[0].status"), "1", "校验优惠券状态失败");
Assert.assertEquals(response2.jsonPath().getString("data.list[0].type"), "coupon", "校验优惠券类型失败");
logger.info("校验title,status,type成功");
//删除添加的优惠券
developerBJZ.ajaxDel(appId, appItemId2);
}
@Test(description = "//旗舰版app添加、上架至尊版优惠券:异常场景,提示不能上架")
public void e_旗舰版添加至尊版优惠券() throws Exception {
//查询列表,获取ID
Response response = developerBJZ.coupons(appId2, "2");
String id = String.valueOf(response.jsonPath().getString("data.list[0].id"));
//上架
Response response2 = developerBJZ.ajaxDirectUp2(appId2, id);
//接口提示,至尊版专享,不能上架
Assert.assertEquals(response2.jsonPath().getString("desc"), "至尊版专享", "校验接口上架失败");
}
@Test(description = "//添加直冲类")
public void f_添加直冲类() throws Exception {
Response response = developerBJZ.directCharges(appId);
String itemId = String.valueOf(response.jsonPath().getString("data.list[1].id"));
String itemName = String.valueOf(response.jsonPath().getString("data.list[1].title"));
//添加直冲类
developerBJZ.ajaxAddRepo(appId, itemId);
//查询商品列表,验证商品是否添加成功
Response response2 = developerBJZ.appItems(appId, itemName);
String appItemId2 = String.valueOf(response2.jsonPath().getString("data.list[0].id"));
Assert.assertEquals(response2.jsonPath().getString("data.list[0].title"), "Q币充值", "校验标题名称失败");
Assert.assertEquals(response2.jsonPath().getString("data.list[0].status"), "0", "校验状态失败");
Assert.assertEquals(response2.jsonPath().getString("data.list[0].type"), "qb", "校验类型失败");
logger.info("校验title,status,type成功");
//删除添加的直冲类
developerBJZ.ajaxDel(appId, appItemId2);
}
}
\ No newline at end of file
package http.cases.SaasDeveloperTest;
import base.Config;
import http.service.Saas.DeveloperBJZ;
import base.DuibaLog;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
import org.testng.Assert;
import org.testng.annotations.Test;
@ContextConfiguration(classes = Config.class)
public class 补给站_活动_DuibaTest extends AbstractTestNGSpringContextTests{
@Autowired
DeveloperBJZ developerBJZ;
private DuibaLog logger = DuibaLog.getLogger();
//至尊版app
String appId="19515";
//旗舰版app
String appId2="21695";
//添加活动
@Test(description = "//添加活动")
public void a_添加活动() throws Exception{
//查询热门活动-活动列表,获取商品ID
Response response=developerBJZ.saasActivitys("3",appId);
String goodItemId= String.valueOf(response.jsonPath().getString("data.saasActivitys[0].id"));
//获取商品ID,进入商品订购页面,获取SKU
Response response2=developerBJZ.itemOrderDetail(goodItemId,appId);
String skuId= String.valueOf(response2.jsonPath().getString("data.goodsItemSku[0].skuId"));
//点击订购,传入SKU创建订单
logger.info("kuid==="+skuId);
Response response3=developerBJZ.createAutomationOrderNew(skuId,appId);
String orderid= String.valueOf(response3.jsonPath().getString("data"));
logger.info("kuid==="+orderid);
//下单购买
developerBJZ.orderAccountPay(orderid,appId);
//查询是否购买成功
Response response4=developerBJZ.findOrderById(orderid,appId);
Assert.assertEquals(response4.jsonPath().getString("data.vo.funcName"), "自动化测试活动--勿动", "校验名称失败");
Assert.assertEquals(response4.jsonPath().getString("data.vo.limitTime"), "一年", "校验购买期限失败");
logger.info("校验名称,期限成功");
}
@Test(description = "//添加签到活动")
public void b_添加签到活动() throws Exception{
//查询热门活动-活动列表,获取商品ID
Response response=developerBJZ.saasActivitys("2",appId);
String goodItemId= String.valueOf(response.jsonPath().getString("data.saasActivitys[1].id"));
//获取商品ID,进入商品订购页面,获取SKU
Response response2=developerBJZ.itemOrderDetail(goodItemId,appId);
String skuId= String.valueOf(response2.jsonPath().getString("data.goodsItemSku[0].skuId"));
//点击订购,传入SKU创建订单
logger.info("kuid==="+skuId);
Response response3=developerBJZ.createAutomationOrderNew(skuId,appId);
String orderid= String.valueOf(response3.jsonPath().getString("data"));
logger.info("kuid==="+orderid);
//下单购买
developerBJZ.orderAccountPay(orderid,appId);
//查询是否购买成功
Response response4=developerBJZ.findOrderById(orderid,appId);
Assert.assertEquals(response4.jsonPath().getString("data.vo.funcName"), "SaaS签到", "校验名称失败");
logger.info("校验名称成功");
}
@Test(description = "付款时有待处理的订单(异常场景)")
public void c_待处理的订单() throws Exception{
//查询热门活动-活动列表,获取商品ID
Response response=developerBJZ.saasActivitys("2",appId);
String goodItemId= String.valueOf(response.jsonPath().getString("data.saasActivitys[1].id"));
//获取商品ID,进入商品订购页面,获取SKU
Response response2=developerBJZ.itemOrderDetail(goodItemId,appId);
String skuId= String.valueOf(response2.jsonPath().getString("data.goodsItemSku[0].skuId"));
//点击订购,传入SKU创建订单
logger.info("kuid==="+skuId);
developerBJZ.createAutomationOrderNew(skuId,appId);
developerBJZ.createAutomationOrderNew2(skuId,appId);
Assert.assertEquals(developerBJZ.createAutomationOrderNew2(skuId,appId).jsonPath().getString("desc"), "订单未处理", "校验订单待处理成功");
//查询待处理订单
Response response3=developerBJZ.selectOrders("1",appId);
Assert.assertEquals(response3.jsonPath().getString("data.list[0].serviceName"), "SaaS签到", "校验名称失败");
logger.info("查询待处理订单成功");
}
@Test(description="查询交易关闭的订单")
public void d_交易关闭的订单() throws Exception{
//查询待付款订单
Response response=developerBJZ.selectOrders("1",appId);
String orderId=String.valueOf(response.jsonPath().getString("data.list[0].id"));
// 点击取消付款,进入到交易关闭订单
developerBJZ.cancleOrder(orderId,appId);
Response response2=developerBJZ.selectOrders("3",appId);
Assert.assertEquals(response2.jsonPath().getString("data.list[0].serviceName"), "SaaS签到", "校验名称失败");
logger.info("查询交易关闭订单成功");
}
}
...@@ -31,8 +31,9 @@ public class 设置_应用信息_DuibaTest extends AbstractTestNGSpringContextTe ...@@ -31,8 +31,9 @@ public class 设置_应用信息_DuibaTest extends AbstractTestNGSpringContextTe
String unitName = isDecimalOpen ? "元" : "积分"; String unitName = isDecimalOpen ? "元" : "积分";
updateAppInfoService.UpdateAppInfo(appId,unitName,earnCreditsUrl,creditsDetailUrl,isDecimalOpen); updateAppInfoService.UpdateAppInfo(appId,unitName,earnCreditsUrl,creditsDetailUrl,isDecimalOpen);
Thread.sleep(1000);
Response response2= updateAppInfoService.appInfo(appId); Response response2= updateAppInfoService.appInfo(appId);
Assert.assertEquals(response2.jsonPath().getString("data.name"), "(saas)接口自动化应用", "校验应用名称失败"); Assert.assertEquals(response2.jsonPath().getString("data.name"), "(saas自动化)至尊版", "校验应用名称失败");
Assert.assertEquals(response2.jsonPath().getString("data.earnCreditsLetter"), "积分文案&2", "校验积分文案失败"); Assert.assertEquals(response2.jsonPath().getString("data.earnCreditsLetter"), "积分文案&2", "校验积分文案失败");
Assert.assertEquals(response2.jsonPath().getString("data.creditsDetailUrl"), "https://www.baidu.com/s?ie=utf-8&f=8&rsv_bp=1&tn=baidu&wd=www.baidu.com", "校验积分明细链接失败"); Assert.assertEquals(response2.jsonPath().getString("data.creditsDetailUrl"), "https://www.baidu.com/s?ie=utf-8&f=8&rsv_bp=1&tn=baidu&wd=www.baidu.com", "校验积分明细链接失败");
logger.info("保存应用信息成功"); logger.info("保存应用信息成功");
......
...@@ -85,6 +85,16 @@ public class ContractSignCommon extends DuibaTestBase{ ...@@ -85,6 +85,16 @@ public class ContractSignCommon extends DuibaTestBase{
} }
} }
public void clearRecord(String contractId, MysqlConnPool jdbc){
try{
jdbc.update("update credits_sign.tb_sign_contract_bet set done_days=0, done_status=1 where id="+ contractId);
jdbc.update("delete from credits_sign.tb_sign_contract_log where contract_id=" + contractId);
}catch (SQLException e){
logger.info("数据库更新异常");
}
}
public void modifyJoinTime(String actId, String date, String startTime, String endTime) throws Exception{ public void modifyJoinTime(String actId, String date, String startTime, String endTime) throws Exception{
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
map.put("title", "自动化_报名截止时间"); map.put("title", "自动化_报名截止时间");
......
package http.cases.SignTest;
import base.DuibaTestBase;
import http.service.Activity.ManagerService;
import http.service.Authorization;
import http.service.hd.SigninService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.testng.annotations.BeforeClass;
public class ContractSign_Cash_signTest extends DuibaTestBase {
@Autowired
ContractSignCommon ContractSignCommon;
@Autowired
SigninService signinService;
@Autowired
Authorization authorization;
@Autowired
http.service.Activity.ContractSignService ContractSignService;
@Autowired
ManagerService managerService;
@Value("${activity.host}")
String activityHost;
private static int uid1,uid2,uid3,uid4,uid5;
static {
// uid1 = 4897; //100109143
// uid2 = 4888;
// uid3 = 4889;
// uid4 = 4900;
// uid5 = 4901;
uid1 = 4902; //100109140
uid2 = 4903;
uid3 = 4904;
uid4 = 4905;
uid5 = 4906;
}
private static String actId = "7";
private String issueId;
private String period, period_tomorrow, period_today;
private String contractId1,contractId2,contractId3,contractId4,contractId5,contractId6;
@BeforeClass
public void beforeclass() {
ContractSignCommon.clearIssue("100109140",actId,jdbc);
}
}
package http.cases.SignTest;
import base.DuibaTestBase;
import http.service.Activity.ManagerService;
import http.service.Authorization;
import http.service.hd.SigninService;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
public class ContractSign_CreditsCheating_signTest extends DuibaTestBase {
@Autowired
ContractSignCommon ContractSignCommon;
@Autowired
SigninService signinService;
@Autowired
Authorization authorization;
@Autowired
http.service.Activity.ContractSignService ContractSignService;
@Autowired
ManagerService managerService;
@Value("${activity.host}")
String activityHost;
private static int uid1,uid2,uid3,uid4,uid5,uid6,uid7,uid8,uid9,uid10;
static {
uid1 = 4887;//100109070
uid2 = 4888;
uid3 = 4889;
uid4 = 4890;
uid5 = 4891;
uid6 = 4892;
uid7 = 4893;
uid8 = 4894;
uid9 = 4895;
uid10 = 4896;
}
private static String actId = "6";
private String issueId;
private String period, period_tomorrow, period_today;
private String contractId1,contractId2,contractId3,contractId4,contractId5,contractId6;
@BeforeClass
public void beforeclass() {
ContractSignCommon.clearIssue("100109070",actId,jdbc);
}
@Test(description = "瓜分积分作弊报名, 活动ID=6" ,priority = 1)
public void 瓜分积分作弊报名() throws Exception {
//最大积分回收率20%,临界值48%,作弊临界人数4
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
SimpleDateFormat format2 = new SimpleDateFormat("MMdd");
Date date = new Date();
period_today = format2.format(date);
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.DAY_OF_YEAR, 1);
date = calendar.getTime();
// 期次开始的时间 yyyy-MM-dd格式
String startTime = format.format(date);
// 期次号 MMDD格式
period_tomorrow = format2.format(date);
// calendar.add(Calendar.DAY_OF_YEAR, -8);
// period = format.format(calendar.getTime());
Map<String, String> map = new HashMap<>();
String doneStatus;
//10个用户报名
for (int uid = uid1; uid <= uid10; uid++) {
map = ContractSignCommon.doJoinResult(actId, "100", uid);
doneStatus = map.get("doneStatus");
Assert.assertEquals(doneStatus,"DOING",uid+"报名失败:" + doneStatus);
}
issueId = map.get("issueId");
logger.info("issueId为:" + issueId);
Response homeInfoRes = ContractSignService.getHomeInfo(actId, uid1);
//homeInfoRes.prettyPrint();
String betCount = homeInfoRes.jsonPath().getString("data.betCount");
Assert.assertEquals(betCount,"100", "报名的额度不正确");
int buyers_new = Integer.valueOf(homeInfoRes.jsonPath().getString("data.buyers"));
Assert.assertEquals(buyers_new, 10,"报名人数未增加");
String periodShow = homeInfoRes.jsonPath().getString("data.periodShow");
Assert.assertEquals(periodShow, period_tomorrow, "参与期次号不正确");
String currentPeriod = homeInfoRes.jsonPath().getString("data.currentPeriod");
Assert.assertEquals(currentPeriod, "0", "当前期次进度不正确");
//0-未报名 1-报名中 2-已报名,打卡未开始 3-未打卡:打卡开始,当天未打卡 4-已打卡:当天已打卡(非最后一天) 5-失败:出现断卡(未报名新一期) 6-成功: 已成功(未报名新一期)
String status = homeInfoRes.jsonPath().getString("data.status");
Assert.assertEquals(status, "2", "当前参与状态不正确");
int totalCount_new = Integer.valueOf(homeInfoRes.jsonPath().getString("data.betTotalCount"));
Assert.assertEquals(totalCount_new, 11000, "报名后奖池数量不正确");
}
@Test(description = "瓜分积分作弊打卡, 活动ID=6" ,priority = 2)
public void 瓜分积分作弊打卡() throws Exception {
//修改周期为打卡第一天
ContractSignCommon.modifyIssuePeriod(issueId,-1);
//uid1打卡,今日成功打卡人数为1
Response doSignRes = ContractSignService.doSign(actId, uid1);
String success = doSignRes.jsonPath().getString("success");
Assert.assertEquals(success, "true", "打卡失败");
Response homeInfoRes = ContractSignService.getHomeInfo(actId, uid1);
String daySuccCount = homeInfoRes.jsonPath().getString("data.daySuccCount");
Assert.assertEquals(daySuccCount, "1", "打卡后,打卡成功人数不正确");
String status = homeInfoRes.jsonPath().getString("data.status");
Assert.assertEquals(status, "4", "打卡完成后状态不正确");
Response recordRes = ContractSignService.getContracts(actId, uid1);
contractId1 = recordRes.jsonPath().getString("data.list[0].contractId");
//uid2打卡,今日成功打卡人数为3
doSignRes = ContractSignService.doSign(actId, uid2);
success = doSignRes.jsonPath().getString("success");
Assert.assertEquals(success, "true", "打卡失败");
homeInfoRes = ContractSignService.getHomeInfo(actId, uid2);
daySuccCount = homeInfoRes.jsonPath().getString("data.daySuccCount");
Assert.assertEquals(daySuccCount, "3", "打卡后,打卡成功人数不正确");
recordRes = ContractSignService.getContracts(actId, uid2);
contractId2 = recordRes.jsonPath().getString("data.list[0].contractId");
//uid3打卡,今日成功打卡人数为4
doSignRes = ContractSignService.doSign(actId, uid3);
success = doSignRes.jsonPath().getString("success");
Assert.assertEquals(success, "true", "打卡失败");
homeInfoRes = ContractSignService.getHomeInfo(actId, uid3);
daySuccCount = homeInfoRes.jsonPath().getString("data.daySuccCount");
Assert.assertEquals(daySuccCount, "4", "打卡后,打卡成功人数不正确");
recordRes = ContractSignService.getContracts(actId, uid3);
contractId3 = recordRes.jsonPath().getString("data.list[0].contractId");
//uid4打卡,今日成功打卡人数为5
doSignRes = ContractSignService.doSign(actId, uid4);
success = doSignRes.jsonPath().getString("success");
Assert.assertEquals(success, "true", "打卡失败");
homeInfoRes = ContractSignService.getHomeInfo(actId, uid4);
daySuccCount = homeInfoRes.jsonPath().getString("data.daySuccCount");
Assert.assertEquals(daySuccCount, "5", "打卡后,打卡成功人数不正确");
recordRes = ContractSignService.getContracts(actId, uid4);
contractId4 = recordRes.jsonPath().getString("data.list[0].contractId");
}
@Test(description = "瓜分积分作弊整期完成, 活动ID=6" ,priority = 3)
public void 瓜分积分作弊整期完成() throws Exception {
//修改周期为打卡第七天
ContractSignCommon.modifyIssuePeriod(issueId,-6);
//清除之前的打卡记录
ContractSignCommon.clearRecord(contractId1, jdbc);
ContractSignCommon.clearRecord(contractId2, jdbc);
ContractSignCommon.clearRecord(contractId3, jdbc);
ContractSignCommon.clearRecord(contractId4, jdbc);
//uid1~uid6 补签前6天
for(int uid=uid1;uid<=uid6;uid++){
ContractSignCommon.contractResign(actId,uid,7,false);
}
//修改期次后有1分钟缓存
ContractSignService.getHomeInfo(actId, uid1);
Thread.sleep(60000);
//uid1 7日打卡完成
Response signRes = ContractSignService.doSign(actId, uid1);
String success = signRes.jsonPath().getString("success");
Assert.assertEquals(success, "true", "uid1第7日打卡失败");
Response homeInfoRes = ContractSignService.getHomeInfo(actId, uid1);
//homeInfoRes.prettyPrint();
String status = homeInfoRes.jsonPath().getString("data.status");
Assert.assertEquals(status, "6", "完成7日打卡状态不正确");
String hasReward = homeInfoRes.jsonPath().getString("data.hasReward");
String hasRewardTomorrow = homeInfoRes.jsonPath().getString("data.hasRewardTomorrow");
Assert.assertEquals(hasReward, "false", "uid1是否有奖励状态不正确");
Assert.assertEquals(hasRewardTomorrow, "true", "uid1明日是否有奖励状态不正确");
Response recordRes = ContractSignService.getContracts(actId, uid1);
String doneStatus = recordRes.jsonPath().getString("data.list[0].doneStatus");
Assert.assertEquals(doneStatus, "DONE", "uid1参与记录中完成状态不正确");
//uid2 7日打卡完成
signRes = ContractSignService.doSign(actId, uid2);
success = signRes.jsonPath().getString("success");
Assert.assertEquals(success, "true", "uid2第7日打卡失败");
//uid3 7日打卡完成
signRes = ContractSignService.doSign(actId, uid3);
success = signRes.jsonPath().getString("success");
Assert.assertEquals(success, "true", "uid3第7日打卡失败");
//uid4 7日打卡完成
signRes = ContractSignService.doSign(actId, uid4);
success = signRes.jsonPath().getString("success");
Assert.assertEquals(success, "true", "uid4第7日打卡失败");
//uid5 7日打卡完成
signRes = ContractSignService.doSign(actId, uid5);
success = signRes.jsonPath().getString("success");
Assert.assertEquals(success, "true", "uid5第7日打卡失败");
//uid6 7日打卡完成
signRes = ContractSignService.doSign(actId, uid6);
success = signRes.jsonPath().getString("success");
Assert.assertEquals(success, "true", "uid6第7日打卡失败");
}
@Test(description = "瓜分积分作弊开奖, 活动ID=6" ,priority = 4)
public void 瓜分积分作弊开奖() throws Exception {
//修改期次,今日开奖
ContractSignCommon.modifyIssuePeriod(issueId, -1);
//修改期次后有1分钟缓存
ContractSignService.getHomeInfo(actId, uid1);
Thread.sleep(60000);
Response homeInfoRes = ContractSignService.getHomeInfo(actId, uid1);
//homeInfoRes.prettyPrint();
String periodShow = homeInfoRes.jsonPath().getString("data.periodShow");
Assert.assertEquals(periodShow, period_tomorrow, "参与期次号不正确");
String status = homeInfoRes.jsonPath().getString("data.status");
Assert.assertEquals(status, "6", "当前参与状态不正确");
String hasReward = homeInfoRes.jsonPath().getString("data.hasReward");
Assert.assertEquals(hasReward, "true", "今日是否有奖励状态不正确");
//查询待领取奖励
Response recordRes = ContractSignService.getContracts(actId, uid1);
String doneStatus = recordRes.jsonPath().getString("data.list[0].doneStatus");
Assert.assertEquals(doneStatus, "WAIT_REWARD", "当前期次完成状态不正确");
String winCount = recordRes.jsonPath().getString("data.list[0].winCount");
Assert.assertEquals(winCount, "1571", "瓜分奖励金额不正确");
//领奖
Response rewardRes = ContractSignService.getReward(contractId1,uid1);
String rewardStatus = rewardRes.jsonPath().getString("success");
String rewardAmount = rewardRes.jsonPath().getString("data");
Assert.assertEquals(rewardStatus,"true","领取奖励结果不正确");
Assert.assertEquals(rewardAmount,winCount,"领取奖励金额不正确");
}
}
...@@ -7,6 +7,7 @@ import http.service.hd.SigninService; ...@@ -7,6 +7,7 @@ import http.service.hd.SigninService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.testng.Assert; import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import io.restassured.response.Response; import io.restassured.response.Response;
...@@ -54,9 +55,15 @@ public class ContractSign_Multi_signTest extends DuibaTestBase { ...@@ -54,9 +55,15 @@ public class ContractSign_Multi_signTest extends DuibaTestBase {
betAmount3 = "100"; betAmount3 = "100";
} }
private String issueId; private String issueId;
private String period; private String period, period_tomorrow, period_today;
private String contractId1,contractId2,contractId3,contractId4,contractId5,contractId6; private String contractId1,contractId2,contractId3,contractId4,contractId5,contractId6;
//@Test(description = "契约签到多梯度报名,活动id=5",priority = 1) @BeforeClass
public void beforeclass() {
ContractSignCommon.clearIssue("100104096",actId,jdbc);
}
@Test(description = "契约签到多梯度报名,活动id=5",priority = 1)
public void 多梯度报名() throws Exception{ public void 多梯度报名() throws Exception{
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
SimpleDateFormat format2 = new SimpleDateFormat("MMdd"); SimpleDateFormat format2 = new SimpleDateFormat("MMdd");
...@@ -68,7 +75,7 @@ public class ContractSign_Multi_signTest extends DuibaTestBase { ...@@ -68,7 +75,7 @@ public class ContractSign_Multi_signTest extends DuibaTestBase {
// 期次开始的时间 yyyy-MM-dd格式 // 期次开始的时间 yyyy-MM-dd格式
String startTime = format.format(date); String startTime = format.format(date);
// 期次号 MMDD格式 // 期次号 MMDD格式
period = format2.format(date); period_tomorrow = format2.format(date);
calendar.add(Calendar.DAY_OF_YEAR, 6); calendar.add(Calendar.DAY_OF_YEAR, 6);
date = calendar.getTime(); date = calendar.getTime();
// 期次结束时间 // 期次结束时间
...@@ -86,24 +93,24 @@ public class ContractSign_Multi_signTest extends DuibaTestBase { ...@@ -86,24 +93,24 @@ public class ContractSign_Multi_signTest extends DuibaTestBase {
doneStatus = map3.get("doneStatus"); doneStatus = map3.get("doneStatus");
Assert.assertEquals(doneStatus,"DOING","uid3报名失败:" + doneStatus); Assert.assertEquals(doneStatus,"DOING","uid3报名失败:" + doneStatus);
Map<String, String> map4 = ContractSignCommon.doJoinResult(actId,betAmount2,uid4); Map<String, String> map4 = ContractSignCommon.doJoinResult(actId,betAmount2,uid4);
doneStatus = map4.get("doneStatusDesc"); doneStatus = map4.get("doneStatus");
Assert.assertEquals(doneStatus,"DOING","uid4报名失败:" + doneStatus); Assert.assertEquals(doneStatus,"DOING","uid4报名失败:" + doneStatus);
//uid5 uid6 报名梯度3 //uid5 uid6 报名梯度3
Map<String, String> map5 = ContractSignCommon.doJoinResult(actId,betAmount3,uid5); Map<String, String> map5 = ContractSignCommon.doJoinResult(actId,betAmount3,uid5);
doneStatus = map5.get("doneStatusDesc"); doneStatus = map5.get("doneStatus");
Assert.assertEquals(doneStatus,"DOING","uid5报名失败:" + doneStatus); Assert.assertEquals(doneStatus,"DOING","uid5报名失败:" + doneStatus);
Map<String, String> map6 = ContractSignCommon.doJoinResult(actId,betAmount3,uid6); Map<String, String> map6 = ContractSignCommon.doJoinResult(actId,betAmount3,uid6);
doneStatus = map6.get("doneStatusDesc"); doneStatus = map6.get("doneStatus");
Assert.assertEquals(doneStatus,"DOING","uid6报名失败:" + doneStatus); Assert.assertEquals(doneStatus,"DOING","uid6报名失败:" + doneStatus);
Response homeInfoRes = ContractSignService.getHomeInfo(actId, uid1); Response homeInfoRes = ContractSignService.getHomeInfo(actId, uid1);
homeInfoRes.prettyPrint(); //homeInfoRes.prettyPrint();
String betCount = homeInfoRes.jsonPath().getString("data.betCount"); String betCount = homeInfoRes.jsonPath().getString("data.betCount");
Assert.assertEquals(betCount, betAmount1, "uid1报名额度显示不正确"); Assert.assertEquals(betCount, betAmount1, "uid1报名额度显示不正确");
int buyers = homeInfoRes.jsonPath().getInt("data.buyers"); int buyers = homeInfoRes.jsonPath().getInt("data.buyers");
Assert.assertEquals(buyers, 6, "报名后的总人数不正确"); Assert.assertEquals(buyers, 6, "报名后的总人数不正确");
String periodShow = homeInfoRes.jsonPath().getString("data.periodShow"); String periodShow = homeInfoRes.jsonPath().getString("data.periodShow");
Assert.assertEquals(periodShow, period, "参与期次号不正确"); Assert.assertEquals(periodShow, period_tomorrow, "参与期次号不正确");
String currentPeriod = homeInfoRes.jsonPath().getString("data.currentPeriod"); String currentPeriod = homeInfoRes.jsonPath().getString("data.currentPeriod");
Assert.assertEquals(currentPeriod, "0", "当前期次进度不正确"); Assert.assertEquals(currentPeriod, "0", "当前期次进度不正确");
String status = homeInfoRes.jsonPath().getString("data.status"); String status = homeInfoRes.jsonPath().getString("data.status");
...@@ -122,14 +129,14 @@ public class ContractSign_Multi_signTest extends DuibaTestBase { ...@@ -122,14 +129,14 @@ public class ContractSign_Multi_signTest extends DuibaTestBase {
Assert.assertEquals(betCount, betAmount3, "uid5报名额度显示不正确"); Assert.assertEquals(betCount, betAmount3, "uid5报名额度显示不正确");
} }
//@Test(description = "多梯度签到,uid1,uid3,uid5, 活动ID=5", priority = 2) @Test(description = "多梯度签到,uid1,uid3,uid5, 活动ID=5", priority = 2)
public void 多梯度签到() throws Exception{ public void 多梯度签到() throws Exception{
//修改期次,今日为打卡第一天 //修改期次,今日为打卡第一天
ContractSignCommon.modifyIssuePeriod(issueId, -1); ContractSignCommon.modifyIssuePeriod(issueId, -1);
Date now = new Date(); Date now = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("MMdd"); SimpleDateFormat sdf = new SimpleDateFormat("MMdd");
SimpleDateFormat sdf2 = new SimpleDateFormat("yy-MM-dd"); SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd");
period = sdf.format(now); period_today = sdf.format(now);
String today = sdf2.format(now); String today = sdf2.format(now);
// uid1打卡前请求homeInfo接口 // uid1打卡前请求homeInfo接口
Response homeInfoRes = ContractSignService.getHomeInfo(actId, uid1); Response homeInfoRes = ContractSignService.getHomeInfo(actId, uid1);
...@@ -138,11 +145,11 @@ public class ContractSign_Multi_signTest extends DuibaTestBase { ...@@ -138,11 +145,11 @@ public class ContractSign_Multi_signTest extends DuibaTestBase {
String status = homeInfoRes.jsonPath().getString("data.status"); String status = homeInfoRes.jsonPath().getString("data.status");
Assert.assertEquals(status, "3", "未打卡前打卡状态不正确"); Assert.assertEquals(status, "3", "未打卡前打卡状态不正确");
String periodShow = homeInfoRes.jsonPath().getString("data.periodShow"); String periodShow = homeInfoRes.jsonPath().getString("data.periodShow");
Assert.assertEquals(periodShow, period, "期次号不正确"); Assert.assertEquals(periodShow, period_today, "期次号不正确");
int rewardRatio = homeInfoRes.jsonPath().getInt("data.currentIssueRewardRatio"); int rewardRatio = homeInfoRes.jsonPath().getInt("data.currentIssueRewardRatio");
Assert.assertEquals(rewardRatio, 1320, "未打卡前瓜分比例不正确"); Assert.assertEquals(rewardRatio, 1320, "未打卡前瓜分比例不正确");
//uid1打卡 //uid1打卡
Response signRes = ContractSignService.doSign("2", uid1); Response signRes = ContractSignService.doSign(actId, uid1);
String success = signRes.jsonPath().getString("success"); String success = signRes.jsonPath().getString("success");
Assert.assertEquals(success, "true", "打卡失败"); Assert.assertEquals(success, "true", "打卡失败");
//查询redis打卡金额 //查询redis打卡金额
...@@ -158,7 +165,6 @@ public class ContractSign_Multi_signTest extends DuibaTestBase { ...@@ -158,7 +165,6 @@ public class ContractSign_Multi_signTest extends DuibaTestBase {
status = homeInfoRes.jsonPath().getString("data.status"); status = homeInfoRes.jsonPath().getString("data.status");
Assert.assertEquals(status, "4", "打卡完成后状态不正确"); Assert.assertEquals(status, "4", "打卡完成后状态不正确");
// uid3打卡前请求homeInfo接口 // uid3打卡前请求homeInfo接口
homeInfoRes = ContractSignService.getHomeInfo(actId, uid3); homeInfoRes = ContractSignService.getHomeInfo(actId, uid3);
status = homeInfoRes.jsonPath().getString("data.status"); status = homeInfoRes.jsonPath().getString("data.status");
...@@ -166,7 +172,7 @@ public class ContractSign_Multi_signTest extends DuibaTestBase { ...@@ -166,7 +172,7 @@ public class ContractSign_Multi_signTest extends DuibaTestBase {
rewardRatio = homeInfoRes.jsonPath().getInt("data.currentIssueRewardRatio"); rewardRatio = homeInfoRes.jsonPath().getInt("data.currentIssueRewardRatio");
Assert.assertEquals(rewardRatio, 880, "打卡后瓜分比例不正确"); Assert.assertEquals(rewardRatio, 880, "打卡后瓜分比例不正确");
//uid3打卡 //uid3打卡
signRes = ContractSignService.doSign("2", uid3); signRes = ContractSignService.doSign(actId, uid3);
success = signRes.jsonPath().getString("success"); success = signRes.jsonPath().getString("success");
Assert.assertEquals(success, "true", "打卡失败"); Assert.assertEquals(success, "true", "打卡失败");
value = Integer.valueOf(RedisUtil.getKey(K030)); value = Integer.valueOf(RedisUtil.getKey(K030));
...@@ -180,49 +186,49 @@ public class ContractSign_Multi_signTest extends DuibaTestBase { ...@@ -180,49 +186,49 @@ public class ContractSign_Multi_signTest extends DuibaTestBase {
status = homeInfoRes.jsonPath().getString("data.status"); status = homeInfoRes.jsonPath().getString("data.status");
Assert.assertEquals(status, "4", "打卡完成后状态不正确"); Assert.assertEquals(status, "4", "打卡完成后状态不正确");
// uid5打卡前请求homeInfo接口 homeInfoRes = ContractSignService.getHomeInfo(actId, uid3);
homeInfoRes = ContractSignService.getHomeInfo(actId, uid5);
status = homeInfoRes.jsonPath().getString("data.status");
Assert.assertEquals(status, "3", "未打卡前打卡状态不正确");
rewardRatio = homeInfoRes.jsonPath().getInt("data.currentIssueRewardRatio");
Assert.assertEquals(rewardRatio, 825, "打卡后瓜分比例不正确");
//uid5打卡
signRes = ContractSignService.doSign("2", uid5);
success = signRes.jsonPath().getString("success");
Assert.assertEquals(success, "true", "打卡失败");
value = Integer.valueOf(RedisUtil.getKey(K030));
Assert.assertEquals(value, 1600, "当前打卡奖池总额不正确");
homeInfoRes = ContractSignService.getHomeInfo(actId, uid5);
rewardRatio = homeInfoRes.jsonPath().getInt("data.currentIssueRewardRatio"); rewardRatio = homeInfoRes.jsonPath().getInt("data.currentIssueRewardRatio");
Assert.assertEquals(rewardRatio, 825, "打卡后前瓜分比例不正确"); Assert.assertEquals(rewardRatio, 880, "打卡后前瓜分比例不正确");
daySuccCount = homeInfoRes.jsonPath().getString("data.daySuccCount"); daySuccCount = homeInfoRes.jsonPath().getString("data.daySuccCount");
Assert.assertEquals(daySuccCount, "3", "打卡后,打卡成功人数不正确"); Assert.assertEquals(daySuccCount, "2", "打卡后,打卡成功人数不正确");
status = homeInfoRes.jsonPath().getString("data.status"); status = homeInfoRes.jsonPath().getString("data.status");
Assert.assertEquals(status, "4", "打卡完成后状态不正确"); Assert.assertEquals(status, "4", "打卡完成后状态不正确");
//删除今日打卡奖池
String key = String.format("SIGNCENTER_K030_%s_%s", issueId, today);
RedisUtil.clearKey(key);
} }
//@Test(description = "多梯度完成打卡",priority = 3) @Test(description = "多梯度完成打卡",priority = 3)
public void 多梯度完成打卡() throws Exception{ public void 多梯度完成打卡() throws Exception{
//修改期次,周期再往前移6天 //修改期次,周期再往前移6天
ContractSignCommon.modifyIssuePeriod(actId, -6); ContractSignCommon.modifyIssuePeriod(issueId, -6);
//补签前6天 //补签前6天
ContractSignCommon.contractResign(actId, uid2, 7, false); ContractSignCommon.contractResign(actId, uid2, 7, false);
ContractSignCommon.contractResign(actId, uid4, 7, false); ContractSignCommon.contractResign(actId, uid4, 7, false);
ContractSignCommon.contractResign(actId, uid6, 7, false); ContractSignCommon.contractResign(actId, uid6, 7, false);
Date now = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("MMdd");
Calendar calendar = Calendar.getInstance();
calendar.setTime(now);
calendar.add(Calendar.DAY_OF_YEAR, -7);
period = sdf.format(calendar.getTime());
//今日打卡 //今日打卡
Response signRes = ContractSignService.doSign(actId, uid2); Response signRes = ContractSignService.doSign(actId, uid2);
String success = signRes.jsonPath().getString("success"); String success = signRes.jsonPath().getString("success");
Assert.assertEquals(success, "true", "uid2第7日打卡失败"); Assert.assertEquals(success, "true", "uid2第7日打卡失败");
//修改期次后有1分钟缓存
ContractSignService.getHomeInfo(actId, uid2);
Thread.sleep(60000);
Response homeInfoRes = ContractSignService.getHomeInfo(actId, uid2); Response homeInfoRes = ContractSignService.getHomeInfo(actId, uid2);
String status = homeInfoRes.jsonPath().getString("data.status"); String status = homeInfoRes.jsonPath().getString("data.status");
Assert.assertEquals(status, "6", "完成7日打卡状态不正确"); Assert.assertEquals(status, "6", "完成7日打卡状态不正确");
String hasReward = homeInfoRes.jsonPath().getString("data.hasReward"); String hasReward = homeInfoRes.jsonPath().getString("data.hasReward");
String hasRewardTomorrow = homeInfoRes.jsonPath().getString("data.hasRewardTomorrow"); String hasRewardTomorrow = homeInfoRes.jsonPath().getString("data.hasRewardTomorrow");
Assert.assertEquals(hasReward, "false", "uid2是否有奖励状态不正确"); Assert.assertEquals(hasReward, "false", "uid2是否有奖励状态不正确");
Assert.assertEquals(hasRewardTomorrow, "true", "uid2明日是否有奖励状态不正确"); Assert.assertEquals(hasRewardTomorrow, "true", "uid2明日是否有奖励状态不正确");
Response recordRes = ContractSignService.getContracts(actId, uid2); Response recordRes = ContractSignService.getContracts(actId, uid2);
String doneStatus = recordRes.jsonPath().getString("data.list[0].doneStatus"); String doneStatus = recordRes.jsonPath().getString("data.list[0].doneStatus");
Assert.assertEquals(doneStatus, "DONE", "uid2参与记录中完成状态不正确"); Assert.assertEquals(doneStatus, "DONE", "uid2参与记录中完成状态不正确");
...@@ -256,35 +262,64 @@ public class ContractSign_Multi_signTest extends DuibaTestBase { ...@@ -256,35 +262,64 @@ public class ContractSign_Multi_signTest extends DuibaTestBase {
Assert.assertEquals(doneStatus, "DONE", "uid6参与记录中完成状态不正确"); Assert.assertEquals(doneStatus, "DONE", "uid6参与记录中完成状态不正确");
int daySuccCount = homeInfoRes.jsonPath().getInt("data.daySuccCount"); int daySuccCount = homeInfoRes.jsonPath().getInt("data.daySuccCount");
Assert.assertEquals(daySuccCount, 3, "第7日打卡完成人数不正确"); Assert.assertEquals(daySuccCount, 0, "第7日打卡完成人数不正确");
int currentPeriod = homeInfoRes.jsonPath().getInt("data.currentPeriod"); int currentPeriod = homeInfoRes.jsonPath().getInt("data.currentPeriod");
Assert.assertEquals(currentPeriod, 7, "当前期次进度天数不正确"); Assert.assertEquals(currentPeriod, 0, "当前期次进度天数不正确");
}
@Test(description = "多梯度断签,uid5",priority = 4)
public void 多梯度断签() throws Exception{
Response homeInfoRes = ContractSignService.getHomeInfo(actId, uid5);
String periodShow = homeInfoRes.jsonPath().getString("data.periodShow");
Assert.assertEquals(periodShow, period_tomorrow, "参与期次号不正确");
String status = homeInfoRes.jsonPath().getString("data.status");
Assert.assertEquals(status, "5", "当前参与状态不正确");
String hasReward = homeInfoRes.jsonPath().getString("data.hasReward");
Assert.assertEquals(hasReward, "false", "今日是否有奖励状态不正确");
Date now = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("MM-dd");
Calendar calendar = Calendar.getInstance();
calendar.setTime(now);
calendar.add(Calendar.DAY_OF_YEAR, -6);
String startTime = sdf.format(calendar.getTime());
String failDate = homeInfoRes.jsonPath().getString("data.failDate");
Assert.assertEquals(failDate,startTime,"uid5断签日期不正确");
Response recordRes = ContractSignService.getContracts(actId, uid5);
//recordRes.prettyPrint();
contractId5 = recordRes.jsonPath().getString("data.list[0].contractId");
String doneStatus = recordRes.jsonPath().getString("data.list[0].doneStatus");
Assert.assertEquals(doneStatus, "FAIL", "uid5当前期次完成状态不正确");
} }
//@Test(description = "开奖", priority = 4) @Test(description = "开奖", priority = 5)
public void 多梯度开奖() throws Exception{ public void 多梯度开奖() throws Exception{
ContractSignCommon.modifyIssuePeriod(issueId, -1); ContractSignCommon.modifyIssuePeriod(issueId, -1);
//修改期次后有1分钟缓存
ContractSignService.getHomeInfo(actId, uid2);
Thread.sleep(60000);
//修改redis的打卡日期键值 //修改redis的打卡日期键值
Date now = new Date(); Date now = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yy-MM-dd"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String today = sdf.format(now); String today = sdf.format(now);
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
calendar.setTime(now); calendar.setTime(now);
calendar.add(Calendar.DAY_OF_YEAR, -1); calendar.add(Calendar.DAY_OF_YEAR, -1);
String yestertoday = sdf.format(calendar.getTime()); String yestertoday = sdf.format(calendar.getTime());
String oldKey = String.format("SIGNCENTER_K030_%s_%s", issueId, today); String oldKey = String.format("SIGNCENTER_K030_%s_%s", issueId, today);
String newKey = String.format("SIGNCENTER_k030_%s_%s", issueId, yestertoday); String value = RedisUtil.getKey(oldKey);
Map<String, String> map = new HashMap<>(); String newKey = String.format("SIGNCENTER_K030_%s_%s", issueId, yestertoday);
map.put("key", oldKey); RedisUtil.setKey(newKey,value);
map.put("newKey", newKey);
Response response = given().params(map).get(activityHost + "/signtest/redis/renameKey");
String result = response.jsonPath().getString("success");
Assert.assertEquals(result, "true", "重命名redis键值失败");
// 查询首页信息 // 查询首页信息
Response homeInfoRes = ContractSignService.getHomeInfo(actId, uid2); Response homeInfoRes = ContractSignService.getHomeInfo(actId, uid2);
String periodShow = homeInfoRes.jsonPath().getString("data.periodShow"); String periodShow = homeInfoRes.jsonPath().getString("data.periodShow");
Assert.assertEquals(periodShow, period, "参与期次号不正确"); Assert.assertEquals(periodShow, period_tomorrow, "参与期次号不正确");
String status = homeInfoRes.jsonPath().getString("data.status"); String status = homeInfoRes.jsonPath().getString("data.status");
Assert.assertEquals(status, "6", "当前参与状态不正确"); Assert.assertEquals(status, "6", "当前参与状态不正确");
String hasReward = homeInfoRes.jsonPath().getString("data.hasReward"); String hasReward = homeInfoRes.jsonPath().getString("data.hasReward");
...@@ -314,28 +349,9 @@ public class ContractSign_Multi_signTest extends DuibaTestBase { ...@@ -314,28 +349,9 @@ public class ContractSign_Multi_signTest extends DuibaTestBase {
winCount = recordRes.jsonPath().getString("data.list[0].winCount"); winCount = recordRes.jsonPath().getString("data.list[0].winCount");
Assert.assertEquals(winCount, "825", "uid6瓜分奖励金额不正确"); Assert.assertEquals(winCount, "825", "uid6瓜分奖励金额不正确");
} }
//@Test(description = "多梯度断签",priority = 5)
public void 多梯度断签() throws Exception{
Response homeInfoRes = ContractSignService.getHomeInfo(actId, uid1);
String periodShow = homeInfoRes.jsonPath().getString("data.periodShow");
Assert.assertEquals(periodShow, period, "参与期次号不正确");
String status = homeInfoRes.jsonPath().getString("data.status");
Assert.assertEquals(status, "4", "当前参与状态不正确");
String hasReward = homeInfoRes.jsonPath().getString("data.hasReward");
Assert.assertEquals(hasReward, "false", "今日是否有奖励状态不正确");
Date now = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("MM-dd"); @Test(description = "多梯度领奖",priority = 6)
Calendar calendar = Calendar.getInstance();
calendar.setTime(now);
calendar.add(Calendar.DAY_OF_YEAR, -7);
String startTime = sdf.format(calendar.getTime());
String failDate = homeInfoRes.jsonPath().getString("data.failDate");
// todo del
logger.info(failDate);
Assert.assertEquals(failDate,startTime,"uid1断签日期不正确");
}
//@Test(description = "多梯度领奖",priority = 6)
public void 多梯度领奖() throws Exception{ public void 多梯度领奖() throws Exception{
//uid2领奖 //uid2领奖
Response rewardRes = ContractSignService.getReward(contractId2,uid2); Response rewardRes = ContractSignService.getReward(contractId2,uid2);
...@@ -349,10 +365,10 @@ public class ContractSign_Multi_signTest extends DuibaTestBase { ...@@ -349,10 +365,10 @@ public class ContractSign_Multi_signTest extends DuibaTestBase {
rewardRes = ContractSignService.getReward(contractId6,uid6); rewardRes = ContractSignService.getReward(contractId6,uid6);
rewardCount = rewardRes.jsonPath().getInt("data"); rewardCount = rewardRes.jsonPath().getInt("data");
Assert.assertEquals(rewardCount, 825, "uid6领取奖励数不正确"); Assert.assertEquals(rewardCount, 825, "uid6领取奖励数不正确");
//断签用户uid1领奖 //断签用户uid5领奖
Map<String, String> map = new HashMap<>(); Map<String, String> map = new HashMap<>();
map.put("contractId", contractId1); map.put("contractId", contractId5);
rewardRes = given().cookies(authorization.dafuwengLogin(uid1)).params(map).post(activityHost+"/sign/contract/getReward"); rewardRes = given().cookies(authorization.dafuwengLogin(uid5)).params(map).post(activityHost+"/sign/contract/getReward");
String success = rewardRes.jsonPath().getString("success"); String success = rewardRes.jsonPath().getString("success");
String desc = rewardRes.jsonPath().getString("desc"); String desc = rewardRes.jsonPath().getString("desc");
Assert.assertEquals(success, "false", "uid1领取结果不正确"); Assert.assertEquals(success, "false", "uid1领取结果不正确");
...@@ -370,6 +386,7 @@ public class ContractSign_Multi_signTest extends DuibaTestBase { ...@@ -370,6 +386,7 @@ public class ContractSign_Multi_signTest extends DuibaTestBase {
Assert.assertEquals(redisResult, "true", "删除redis键值失败"); Assert.assertEquals(redisResult, "true", "删除redis键值失败");
Response CarouselRes = ContractSignService.getRewardTodayLimit200(actId,uid2); Response CarouselRes = ContractSignService.getRewardTodayLimit200(actId,uid2);
CarouselRes.prettyPrint();
String cid2 = CarouselRes.jsonPath().getString("data[0].consumerId"); String cid2 = CarouselRes.jsonPath().getString("data[0].consumerId");
String partnerUserId2 = CarouselRes.jsonPath().getString("data[0].uid"); String partnerUserId2 = CarouselRes.jsonPath().getString("data[0].uid");
String nickname2 = CarouselRes.jsonPath().getString("data[0].nickName"); String nickname2 = CarouselRes.jsonPath().getString("data[0].nickName");
......
...@@ -208,6 +208,9 @@ public class ContractSign_signTest extends DuibaTestBase { ...@@ -208,6 +208,9 @@ public class ContractSign_signTest extends DuibaTestBase {
modifyIssuePeriod(issueId,-6); modifyIssuePeriod(issueId,-6);
//补签前5天,第六天不签 //补签前5天,第六天不签
this.contractResign(actId, uid2, 7,true); this.contractResign(actId, uid2, 7,true);
ContractSignService.getHomeInfo(actId, uid2);
//修改周期后有1分钟缓存
Thread.sleep(60000);
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");
...@@ -229,12 +232,14 @@ public class ContractSign_signTest extends DuibaTestBase { ...@@ -229,12 +232,14 @@ public class ContractSign_signTest extends DuibaTestBase {
//补签前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 homeInfoRes = ContractSignService.getHomeInfo(actId,uid3);
logger.info("签到前");
//今日打卡 //今日打卡
Response signRes = ContractSignService.doSign("2", uid3); Response signRes = ContractSignService.doSign("2", uid3);
String success = signRes.jsonPath().getString("success"); String success = signRes.jsonPath().getString("success");
Assert.assertEquals(success, "true", "uid3打卡失败"); Assert.assertEquals(success, "true", "uid3打卡失败");
Response homeInfoRes = ContractSignService.getHomeInfo(actId,uid3); homeInfoRes = ContractSignService.getHomeInfo(actId,uid3);
String status = homeInfoRes.jsonPath().getString("data.status"); String status = homeInfoRes.jsonPath().getString("data.status");
Assert.assertEquals(status,"6","完成7日打卡状态不正确"); Assert.assertEquals(status,"6","完成7日打卡状态不正确");
logger.info("uid3七日打卡成功"); logger.info("uid3七日打卡成功");
...@@ -256,25 +261,11 @@ public class ContractSign_signTest extends DuibaTestBase { ...@@ -256,25 +261,11 @@ public class ContractSign_signTest extends DuibaTestBase {
@Test(description = "开奖,活动ID=2",priority = 6) @Test(description = "开奖,活动ID=2",priority = 6)
public void 契约开奖_固定额度() throws Exception{ public void 契约开奖_固定额度() throws Exception{
modifyIssuePeriod(issueId, -1);
//修改redis的打卡日期键值
String actId = "2"; String actId = "2";
// Date now = new Date(); modifyIssuePeriod(issueId, -1);
// SimpleDateFormat sdf = new SimpleDateFormat("yy-MM-dd"); //修改期次后有1分钟缓存
// String today = sdf.format(now); ContractSignService.getHomeInfo(actId, uid3);
// Calendar calendar = Calendar.getInstance(); Thread.sleep(60000);
// calendar.setTime(now);
// calendar.add(Calendar.DAY_OF_YEAR, -1);
// String yestertoday = sdf.format(calendar.getTime());
// String oldKey = String.format("SIGNCENTER_K030_%s_%s", issueId, today);
// String newKey = String.format("SIGNCENTER_k030_%s_%s", issueId, yestertoday);
// Map<String, String> map = new HashMap<>();
// map.put("key", oldKey);
// map.put("newKey", newKey);
// Response response = given().params(map).get(activityHost + "/signtest/redis/renameKey");
// String result = response.jsonPath().getString("success");
// Assert.assertEquals(result, "true", "重命名redis键值失败");
// 查询下期是否开始 // 查询下期是否开始
Response homeInfoRes = ContractSignService.getHomeInfo(actId, uid3); Response homeInfoRes = ContractSignService.getHomeInfo(actId, uid3);
//homeInfoRes.prettyPrint(); //homeInfoRes.prettyPrint();
......
...@@ -61,15 +61,12 @@ public class 周期签到测试_signTest extends DuibaTestBase { ...@@ -61,15 +61,12 @@ public class 周期签到测试_signTest extends DuibaTestBase {
// } // }
//@Test(description = "活动id:79,规则:周期2天,签到第3天循环第一天奖励,加一次抽奖机会,加10积分") @Test(description = "活动id:79,规则:周期5天,签到第3天循环第一天奖励,加一次抽奖机会,加10积分")
public void 周期签到测试() throws Exception { public void 周期签到测试() throws Exception {
logger.info("Current Thread Id: " + Thread.currentThread().getId()); logger.info("Current Thread Id: " + Thread.currentThread().getId());
//补签前天,凑足连续签到2天 //补签前两天,凑足连续签到2天
Response response_1 = this.resign("79",-2); Response response_1 = this.resign("79",-1);
Thread.sleep(1000); Response response_2 = this.resign("79",-2);
Response response_2 = this.resign("79",-1);
response_1.prettyPrint();
response_2.prettyPrint();
//当日签到之前插件信息查询 //当日签到之前插件信息查询
Response response_plug = activityPlugDrawInfoService.getPrizeInfo(map,"1179"); Response response_plug = activityPlugDrawInfoService.getPrizeInfo(map,"1179");
...@@ -99,7 +96,6 @@ public class 周期签到测试_signTest extends DuibaTestBase { ...@@ -99,7 +96,6 @@ public class 周期签到测试_signTest extends DuibaTestBase {
String lastDays = response.jsonPath().getString("signInfoVO.lastDays");//连续签到天数 String lastDays = response.jsonPath().getString("signInfoVO.lastDays");//连续签到天数
String todaySigned = response.jsonPath().getString("signInfoVO.todaySigned"); //今日是否签到 String todaySigned = response.jsonPath().getString("signInfoVO.todaySigned"); //今日是否签到
response.prettyPrint();
Assert.assertEquals(acmDay,"2","历史累积签到次数不正确"); Assert.assertEquals(acmDay,"2","历史累积签到次数不正确");
Assert.assertEquals(acmDays,"2","周期内累计签到天数不正确"); Assert.assertEquals(acmDays,"2","周期内累计签到天数不正确");
Assert.assertEquals(activityCount,"1","今日奖励抽奖次数不正确"); Assert.assertEquals(activityCount,"1","今日奖励抽奖次数不正确");
...@@ -124,7 +120,6 @@ public class 周期签到测试_signTest extends DuibaTestBase { ...@@ -124,7 +120,6 @@ public class 周期签到测试_signTest extends DuibaTestBase {
//当日签到后的信息查询 //当日签到后的信息查询
Response response2 = signactivityService.getSignInfo(uid,"79"); Response response2 = signactivityService.getSignInfo(uid,"79");
//response.prettyPrint();
todaySigned = response2.jsonPath().getString("signInfoVO.todaySigned");//今日是否签到 todaySigned = response2.jsonPath().getString("signInfoVO.todaySigned");//今日是否签到
acmDay = response2.jsonPath().getString("signInfoVO.acmDay"); //历史累计签到 acmDay = response2.jsonPath().getString("signInfoVO.acmDay"); //历史累计签到
continueDay = response2.jsonPath().getString("signInfoVO.continueDay"); //连续签到天数 continueDay = response2.jsonPath().getString("signInfoVO.continueDay"); //连续签到天数
...@@ -305,6 +300,7 @@ public class 周期签到测试_signTest extends DuibaTestBase { ...@@ -305,6 +300,7 @@ public class 周期签到测试_signTest extends DuibaTestBase {
public Response resign(String activityId,int data) throws Exception { public Response resign(String activityId,int data) throws Exception {
//补签前天,凑足累计签到2天 //补签前天,凑足累计签到2天
Response response = signactivityService.reSign(map,activityId,null,getTime(data)); Response response = signactivityService.reSign(map,activityId,null,getTime(data));
response.prettyPrint();
//补签logid //补签logid
String logId = response.jsonPath().getString("data.logId"); String logId = response.jsonPath().getString("data.logId");
response = signactivityService.getSignResult(map,logId); response = signactivityService.getSignResult(map,logId);
......
...@@ -70,7 +70,7 @@ public class 开发者签到管理_signTest extends AbstractTestNGSpringContextT ...@@ -70,7 +70,7 @@ public class 开发者签到管理_signTest extends AbstractTestNGSpringContextT
Response response=signService.selectsignOperList(); Response response=signService.selectsignOperList();
//查看签到列表个数是否成功 //查看签到列表个数是否成功
Assert.assertEquals(response.jsonPath().getString("data.list[0].id"),"90", "校验签到id失败"); Assert.assertEquals(response.jsonPath().getString("data.list[0].id"),"90", "校验签到id失败");
Assert.assertEquals(response.jsonPath().getString("data.params.total"),"1", "校验总个数失败"); Assert.assertEquals(response.jsonPath().getString("data.params.total"),"2", "校验总个数失败");
logger.info("校验签到总个数成功"); logger.info("校验签到总个数成功");
} }
......
package http.cases.SingleLotteryTest;
import base.DuibaLog;
import base.DuibaTestBase;
import http.service.Activity.SingleLotteryService;
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.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import utils.MatcherString;
import utils.RedisUtil;
import java.lang.reflect.Method;
import java.text.SimpleDateFormat;
import java.util.*;
import static io.restassured.RestAssured.given;
/**
* Created by zhaoran on 2018/6/8.
*/
public class 自有单抽限制_AccessTest extends DuibaTestBase {
@Autowired
SingleLotteryService singleLotteryService;
@Autowired
Authorization authorization;
@Value("${activity.host}")
String activityHost;
@Value("${manager.host}")
private static DuibaLog logger = DuibaLog.getLogger();
//指定用户
private static int uid = 4881;
private static int uid2 = 4882;
private static int uid3 = 4883;
private static int uid4 = 4884;
private static int uid5 = 4885;
private static int uid6 = 4886;
@BeforeClass
public void before() {
try {
//清除每日用户抽奖限制记录
RedisUtil.clearKey("AC_K001_36686_"+getTime(0));
//清除永久用户抽奖限制记录
jdbc.update("delete from ckvtable.tb_kvtable_0804 where vkey = 'activity-centerjoinNum_100109092_36708'");
//清除每日用户免费抽奖记录
RedisUtil.clearKey("AC_K002_36685_"+getTime(0));
//清除永久用户免费抽奖记录
jdbc.update("delete from ckvtable.tb_kvtable_0830 where vkey = 'activity-centerfreeNum_100109118_36731'");
//清除永久用户中奖一次记录
jdbc.update("delete from ckvtable.tb_kvtable_0831 where vkey = 'activity-centerwinOptionNum_100109119_36687_sigleLottery1'");
jdbc.update("delete from ckvtable.tb_kvtable_0831 where vkey = 'activity-centerwinOptionNum_100109119_36687_sigleLottery0'");
//清除每日用户中奖一次记录
jdbc.update("delete from credits_dev.single_lottery_order where consumer_id = '100109120' and prize_name = '自动化单抽实物'");
} catch (Exception e) {
e.printStackTrace();
}
}
@Test
public void 每日用户抽奖限制() throws Exception{
Map<String, String> map = new HashMap<>();
map.put("operationAcitvityId", "36686");
map.put("oaId", "36686");
map.put("token", "12321");
Response response = given().cookies(authorization.dafuwengLogin(uid2)).params(map).post(activityHost + "/singleLottery/doJoin");
response.print();
Assert.assertEquals(response.jsonPath().getString("success"), "true", "校验success失败");
Thread.sleep(1000);
response = given().cookies(authorization.dafuwengLogin(uid2)).params(map).post(activityHost + "/singleLottery/doJoin");
response.print();
Assert.assertEquals(response.jsonPath().getString("success"), "false", "校验success失败");
Assert.assertEquals(response.jsonPath().getString("lotteryButtonStatus"), "8", "校验状态失败");
Assert.assertEquals(response.jsonPath().getString("message"), "今日已抽完", "校验信息失败");
logger.info("校验success、lotteryButtonStatus、message正确");
}
@Test
public void 永久用户抽奖限制() throws Exception{
Map<String, String> map = new HashMap<>();
map.put("operationAcitvityId", "36708");
map.put("oaId", "36708");
map.put("token", "12321");
Response response = given().cookies(authorization.dafuwengLogin(uid2)).params(map).post(activityHost + "/singleLottery/doJoin");
response.print();
Assert.assertEquals(response.jsonPath().getString("success"), "true", "校验success失败");
Thread.sleep(1000);
response = given().cookies(authorization.dafuwengLogin(uid2)).params(map).post(activityHost + "/singleLottery/doJoin");
response.print();
Assert.assertEquals(response.jsonPath().getString("success"), "false", "校验success失败");
Assert.assertEquals(response.jsonPath().getString("lotteryButtonStatus"), "2", "校验状态失败");
Assert.assertEquals(response.jsonPath().getString("message"), "已抽完", "校验信息失败");
logger.info("校验success、lotteryButtonStatus、message正确");
}
@Test
public void 每日免费抽奖限制() throws Exception{
//查询数据库,当前积分(抽奖扣积分流程校验)
Map<String,Object> mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid3);
String credits = String.valueOf(mapuser.get("credits"));
logger.info("第一次抽奖前积分:"+credits);
Map<String, String> map = new HashMap<>();
map.put("operationAcitvityId", "36685");
map.put("oaId", "36685");
map.put("token", "12321");
Response response = given().cookies(authorization.dafuwengLogin(uid3)).params(map).post(activityHost + "/singleLottery/doJoin");
response.print();
Assert.assertEquals(response.jsonPath().getString("success"), "true", "校验success失败");
//查询数据库,当前积分(抽奖扣积分流程校验)
mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid3);
String credits2 = String.valueOf(mapuser.get("credits"));
logger.info("第一次抽奖后积分:"+credits2);
Assert.assertEquals(credits, credits2, "校验免费抽奖失败");
credits2 = String.valueOf(Integer.valueOf(credits2)-1);
Thread.sleep(1000);
response = given().cookies(authorization.dafuwengLogin(uid3)).params(map).post(activityHost + "/singleLottery/doJoin");
response.print();
Assert.assertEquals(response.jsonPath().getString("success"), "true", "校验success失败");
//查询数据库,当前积分(抽奖扣积分流程校验)
mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid3);
String credits3 = String.valueOf(mapuser.get("credits"));
logger.info("第二次抽奖后积分:"+credits3);
Assert.assertEquals(credits3, credits2, "校验扣积分抽奖失败");
logger.info("校验每日一次免费抽奖限制正确");
}
@Test
public void 永久免费抽奖限制() throws Exception{
//查询数据库,当前积分(抽奖扣积分流程校验)
Map<String,Object> mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid4);
String credits = String.valueOf(mapuser.get("credits"));
logger.info("第一次抽奖前积分:"+credits);
Map<String, String> map = new HashMap<>();
map.put("operationAcitvityId", "36731");
map.put("oaId", "36731");
map.put("token", "12321");
Response response = given().cookies(authorization.dafuwengLogin(uid4)).params(map).post(activityHost + "/singleLottery/doJoin");
response.print();
Assert.assertEquals(response.jsonPath().getString("success"), "true", "校验success失败");
//查询数据库,当前积分(抽奖扣积分流程校验)
mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid4);
String credits2 = String.valueOf(mapuser.get("credits"));
logger.info("第一次抽奖后积分:"+credits2);
Assert.assertEquals(credits, credits2, "校验免费抽奖失败");
credits2 = String.valueOf(Integer.valueOf(credits2)-1);
Thread.sleep(1000);
response = given().cookies(authorization.dafuwengLogin(uid4)).params(map).post(activityHost + "/singleLottery/doJoin");
response.print();
Assert.assertEquals(response.jsonPath().getString("success"), "true", "校验success失败");
//查询数据库,当前积分(抽奖扣积分流程校验)
mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid4);
String credits3 = String.valueOf(mapuser.get("credits"));
logger.info("第二次抽奖后积分:"+credits3);
Assert.assertEquals(credits3, credits2, "校验扣积分抽奖失败");
logger.info("校验永久一次免费抽奖限制正确");
}
@Test
public void 每日用户中奖限制() throws Exception{
Map<String, String> map = new HashMap<>();
map.put("operationAcitvityId", "36688");
map.put("oaId", "36688");
map.put("token", "12321");
Response response = given().cookies(authorization.dafuwengLogin(uid6)).params(map).post(activityHost + "/singleLottery/doJoin");
String id =MatcherString.getString(response.asString(), "singleLotteryOrderId\":(.*?),", 1);
response = singleLotteryService.getOrderStatus(uid6,id,"iOS");
int i = 10;
while ("处理中".equals(response.jsonPath().getString("message")) && i > 0) {
Thread.sleep(500);
response = singleLotteryService.getOrderStatus(uid6,id,"iOS");
i--;
}
Assert.assertEquals(response.jsonPath().getString("descrption"),"自动化单抽实物","校验优惠券标题失败");
Assert.assertEquals(response.jsonPath().getString("lotteryType"), "object", "校验奖品类型失败");
Assert.assertEquals(response.jsonPath().getString("lotteryButtonStatus"), "1", "校验状态失败");
Assert.assertEquals(response.jsonPath().getString("message"), "成功", "校验message失败");
Thread.sleep(1000);
response = given().cookies(authorization.dafuwengLogin(uid6)).params(map).post(activityHost + "/singleLottery/doJoin");
String id2 =MatcherString.getString(response.asString(), "singleLotteryOrderId\":(.*?),", 1);
response.print();
response = singleLotteryService.getOrderStatus(uid6,id2,"iOS");
int n = 10;
while ("处理中".equals(response.jsonPath().getString("message")) && n > 0) {
Thread.sleep(500);
response = singleLotteryService.getOrderStatus(uid6,id2,"iOS");
response.print();
n--;
}
Assert.assertEquals(response.jsonPath().getString("success"), "true", "校验success失败");
Assert.assertEquals(response.jsonPath().getString("lotteryButtonStatus"), "1", "校验状态失败");
Assert.assertNull(response.jsonPath().getString("descrption"), "校验奖项失败");
logger.info("校验每日用户中奖一次限制正确");
}
@Test
public void 永久用户中奖限制() throws Exception{
Map<String, String> map = new HashMap<>();
map.put("operationAcitvityId", "36687");
map.put("oaId", "36687");
map.put("token", "12321");
Response response = given().cookies(authorization.dafuwengLogin(uid5)).params(map).post(activityHost + "/singleLottery/doJoin");
String id =MatcherString.getString(response.asString(), "singleLotteryOrderId\":(.*?),", 1);
response = singleLotteryService.getOrderStatus(uid5,id,"iOS");
int i = 10;
while ("处理中".equals(response.jsonPath().getString("message")) && i > 0) {
Thread.sleep(500);
response = singleLotteryService.getOrderStatus(uid5,id,"iOS");
i--;
}
Assert.assertEquals(response.jsonPath().getString("descrption"),"自动化单抽实物","校验优惠券标题失败");
Assert.assertEquals(response.jsonPath().getString("lotteryType"), "object", "校验奖品类型失败");
Assert.assertEquals(response.jsonPath().getString("lotteryButtonStatus"), "1", "校验状态失败");
Assert.assertEquals(response.jsonPath().getString("message"), "成功", "校验message失败");
Thread.sleep(1000);
response = given().cookies(authorization.dafuwengLogin(uid5)).params(map).post(activityHost + "/singleLottery/doJoin");
String id2 =MatcherString.getString(response.asString(), "singleLotteryOrderId\":(.*?),", 1);
response.print();
response = singleLotteryService.getOrderStatus(uid5,id2,"iOS");
int n = 10;
while ("处理中".equals(response.jsonPath().getString("message")) && n > 0) {
Thread.sleep(500);
response = singleLotteryService.getOrderStatus(uid5,id2,"iOS");
response.print();
n--;
}
Assert.assertEquals(response.jsonPath().getString("success"), "true", "校验success失败");
Assert.assertEquals(response.jsonPath().getString("lotteryButtonStatus"), "1", "校验状态失败");
Assert.assertNull(response.jsonPath().getString("descrption"), "校验奖项失败");
logger.info("校验永久用户中奖一次限制正确");
}
@Test
public void 抽奖日期限制(){
Map<String, String> map = new HashMap<>();
map.put("operationAcitvityId", "36689");
map.put("oaId", "36689");
map.put("token", "12321");
Response response = given().cookies(authorization.dafuwengLogin(uid)).params(map).post(activityHost + "/singleLottery/doJoin");
//response.prettyPeek();
Assert.assertEquals(response.jsonPath().getString("success"), "false", "校验success失败");
Assert.assertEquals(response.jsonPath().getString("lotteryButtonStatus"), "4", "校验状态失败");
Assert.assertEquals(response.jsonPath().getString("message"), "已结束", "校验信息失败");
logger.info("校验success、lotteryButtonStatus、message正确");
}
public String getTime(int amount){
SimpleDateFormat dateFormat = new SimpleDateFormat("YYYY-MM-dd", Locale.ENGLISH);
Date date = new Date();
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.MONTH, amount);
date = calendar.getTime();
// System.out.println(dateFormat.format(date));
String time = dateFormat.format(date);
// System.out.println(time);
return time;
}
}
\ No newline at end of file
package http.cases.SingleLotteryTest;
import base.DuibaLog;
import base.DuibaTestBase;
import http.service.hd.SigninService;
import io.restassured.internal.assertion.Assertion;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.Test;
import utils.MatcherString;
/**
* Created by zhaoran on 2018/6/8.
*/
public class 预览单品抽奖_AccessTest extends DuibaTestBase {
@Autowired
SigninService signinService;
private static DuibaLog logger = DuibaLog.getLogger();
@Test
public void 预览单抽() throws Exception {
Response response = signinService.preview("18714","3","2772","36732","zhaoran@duiba.com.cn");
String url = response.jsonPath().getString("data.url");
logger.info("预览url为:"+url);
Assert.assertEquals(url.contains("http://activity.m.duibatest.com.cn/autoLogin/autologin?appKey=BDqysEMghRqpDWAaQu9S4rLihHm&uid=duiba-preview-user"), true, "校验是否展示马上使用失败");
}
}
\ No newline at end of file
package http.cases.WalletTest; package http.cases.WalletTest;
import base.DuibaTestBase; import base.DuibaTestBase;
import org.testng.annotations.BeforeClass;
import utils.RedisUtil; import utils.RedisUtil;
import http.service.Activity.SeedRedPacketService; import http.service.Activity.SeedRedPacketService;
import http.service.Activity.WalletAccountService; import http.service.Activity.WalletAccountService;
...@@ -28,6 +29,15 @@ public class 种红包_AccessTest extends DuibaTestBase{ ...@@ -28,6 +29,15 @@ public class 种红包_AccessTest extends DuibaTestBase{
Authorization authorization; Authorization authorization;
private DuibaLog logger = DuibaLog.getLogger(); private DuibaLog logger = DuibaLog.getLogger();
@BeforeClass
public void beforeclass() {
try {
//前置操作,确保土地是空地状态
seedRedPacketService.updateUserLand("19380","1","1","100066444","3");
} catch (Exception e) {
logger.info("数据前后置操作异常");
}
}
@Test @Test
public void 种红包() throws Exception { public void 种红包() throws Exception {
......
...@@ -55,6 +55,7 @@ public class Authorization { ...@@ -55,6 +55,7 @@ public class Authorization {
private static Map<String,String> hdCookies; private static Map<String,String> hdCookies;
private static Map<String,String> hdCookiesMabo; private static Map<String,String> hdCookiesMabo;
private static Map<String,String> hdCookiesSaas; private static Map<String,String> hdCookiesSaas;
private static Map<String,Map> hdCookiesSaasByApp = new ConcurrentHashMap<>();
private static Map<String,Map> hdCookiesCommon = new ConcurrentHashMap<>(); private static Map<String,Map> hdCookiesCommon = new ConcurrentHashMap<>();
private static Map<String,String> openbsCookies; private static Map<String,String> openbsCookies;
private Map<String,String> ssoCookies =null; private Map<String,String> ssoCookies =null;
...@@ -247,22 +248,35 @@ public class Authorization { ...@@ -247,22 +248,35 @@ public class Authorization {
} }
public Map hdLoginSaas(String appId){ public Map hdLoginSaas(String appId){
int i=10;
logger.info("hdCookiesSaasByApp cookies:"+hdCookiesSaasByApp.toString());
Map<String,String> hdCookies = hdCookiesSaasByApp.get(appId);
while((hdCookies==null||hdCookies.size()==0)&&i>0) {
Response token=this.hdGetToken();
String url = PROTOCOL + hdHost + hdLoginPath;
Map<String,String> cookies=token.getCookies();
Map<String, String> paras = new HashMap<>();
paras.put("email", "wxs@duiba.com.cn");
paras.put("password", SecurityUtils.getMD5("dbZcFiIc5yMHcee/o/PJEfyZjug="+from(token.asString()).getString("data.loginsToken")));
paras.put("redirect", "/redirectApp");
paras.put("isAutoLogin", "true");
Response response = given().cookies(cookies).params(paras).post(url);
Map<String,String> map = response.getCookies();
logger.info("cookies:"+map.toString());
hdCookies=new HashMap<>(response.getCookies());
if(hdCookies!=null||hdCookies.size()!=0) {
//取消安全校验
hdCookies.remove("csrf_token");
hdCookies.put("appId", appId);
hdCookies.put("duibaAppId", appId);
logger.info("cookies2:"+hdCookies.toString());
hdCookiesSaasByApp.put(appId,hdCookies);
}
Response token=this.hdGetToken(); i--;
String url = PROTOCOL + hdHost + hdLoginPath; }
Map<String,String> cookies=token.getCookies(); logger.info("hdCookiesSaasByApp cookies集合:"+hdCookiesSaasByApp.toString());
Map<String, String> paras = new HashMap<>(); return hdCookies;
paras.put("email", "wxs@duiba.com.cn");
paras.put("password", SecurityUtils.getMD5("dbZcFiIc5yMHcee/o/PJEfyZjug="+from(token.asString()).getString("data.loginsToken")));
paras.put("redirect", "/redirectApp");
paras.put("isAutoLogin", "true");
Response response = given().cookies(cookies).params(paras).post(url);
Map<String,String> hdCookiesSaasByApp=new HashMap<>(response.getCookies());
//取消安全校验
hdCookiesSaasByApp.remove("csrf_token");
hdCookiesSaasByApp.put("appId",appId);
return hdCookiesSaasByApp;
} }
//密码为duibaduiba123 //密码为duibaduiba123
public Map hdLoginCommon(String email){ public Map hdLoginCommon(String email){
...@@ -279,7 +293,7 @@ public class Authorization { ...@@ -279,7 +293,7 @@ public class Authorization {
paras.put("isAutoLogin", "true"); paras.put("isAutoLogin", "true");
Response response = given().cookies(cookies).params(paras).post(url); Response response = given().cookies(cookies).params(paras).post(url);
hdCookies=new HashMap<>(response.getCookies()); hdCookies=new HashMap<>(response.getCookies());
if(hdCookies==null||hdCookies.size()==0){ if(hdCookies!=null||hdCookies.size()!=0){
hdCookies.remove("csrf_token"); hdCookies.remove("csrf_token");
hdCookiesCommon.put(email,hdCookies); hdCookiesCommon.put(email,hdCookies);
} }
...@@ -309,7 +323,7 @@ public class Authorization { ...@@ -309,7 +323,7 @@ public class Authorization {
Response response = given().cookies(cookies).params(paras).post(url); Response response = given().cookies(cookies).params(paras).post(url);
response.prettyPrint(); response.prettyPrint();
hdCookies=new HashMap<>(response.getCookies()); hdCookies=new HashMap<>(response.getCookies());
if(hdCookies==null||hdCookies.size()==0){ if(hdCookies!=null||hdCookies.size()!=0){
hdCookies.remove("csrf_token"); hdCookies.remove("csrf_token");
hdCookiesCommon.put(account,hdCookies); hdCookiesCommon.put(account,hdCookies);
} }
......
...@@ -20,6 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -20,6 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.testng.Assert; import org.testng.Assert;
import utils.MatcherString;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
...@@ -119,8 +120,14 @@ public class PkActivityService { ...@@ -119,8 +120,14 @@ public class PkActivityService {
if (bonusType.equals("2")){ if (bonusType.equals("2")){
para.put("bonusAmount","0.1");//实际瓜分红包金额 para.put("bonusAmount","0.1");//实际瓜分红包金额
para.put("title","【自动化】瓜分红包"+time); para.put("title","【自动化】瓜分红包"+time);
}else { }else if (bonusType.equals("1")){
para.put("title","【自动化】瓜分经验"+time); para.put("title","【自动化】瓜分经验"+time);
}else {
para.put("title","【自动化】瓜分优惠券");
para.put("bonusAmount","");
para.put("pluginId","12");//插件id
para.put("prizeLimit","1000");//发放上限
} }
para.put("configStatus","1"); para.put("configStatus","1");
para.put("creditsValue","1"); para.put("creditsValue","1");
...@@ -303,6 +310,82 @@ public class PkActivityService { ...@@ -303,6 +310,82 @@ public class PkActivityService {
} }
//创建pk开奖的插件活动id
public Response pluginSave(String pkActivityId) throws Exception {
String saveUrl = "http://"+ ManagerHost + "/plugin/save";
String configUrl ="http://"+ ManagerHost + "/plugin/editConfig.htm";
//获取创建活动的token
Response response=given().contentType("text/html;charset=UTF-8").cookies(authorization.ssoLogin()).get(configUrl);
String token = MatcherString.getString(response.asString(), "token: '(.*?)'", 1);
List<Map<String,String>> listPrizes = new ArrayList<>();
Map<String,String> award = new HashMap<>();
award.put("type","coupon");
award.put("description","优惠券");
award.put("logo","//yun.duiba.com.cn/developer/img/activityTool/slotMachine/coupon.png");
award.put("valid","true");
award.put("rate","100");
award.put("arealimit","false");
award.put("stockBeforeChange","0");
award.put("rewardFalg","false");
award.put("prizeTag","");
award.put("winLimitScope","1");
award.put("prizesLimitScope","daily");
award.put("itemId","27097");
award.put("name","LV优惠券自动化测试链接券");
award.put("stockAfterChange","10");
award.put("remaining","10");
listPrizes.add(award);
String prizes = JSON.toJSONString(listPrizes);
Map<String, String> map = new HashMap<>();
map.put("title", "【自动化】pk开奖插件");
map.put("brickId", "92");
map.put("ruleDescription", "自动化活动规则");
map.put("rateDescription", "自动化概率说明");
map.put("multiSkinsMode", "false");
map.put("multiSkinIds","[]");
map.put("triggerTime","[]");
map.put("limitCount","1");
map.put("exitDays", "7");
map.put("anticheatExchangeLimit", "false");
map.put("limitScope", "forever");
map.put("prizes",prizes);
map.put("tag","[]");
map.put("triggerType", "1");
map.put("hiddenForDeveloper", "false");
map.put("joinVerificy", "true");
map.put("duibaRelateMode", "false");
map.put("channelType","0");
map.put("token",token);
map.put("copy", "false");
map.put("subType","plugdraw");
map.put("joinVerificyMode","15");
map.put("pkId",pkActivityId);
map.put("scenarios", "chome");
logger.info("请求保存插件活动接口的参数为:" + JSONObject.toJSONString(map));
logger.info("请求保存插件活动接口:" + saveUrl);
Response saveResponse = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.ssoLogin()).params(map).post(saveUrl);
saveResponse.prettyPrint();
try{
Assert.assertEquals(saveResponse.jsonPath().getString("success"),"true");
}catch(Exception e){
throw new Exception("创建插件活动接口失败,返回信息:"+saveResponse.asString());
}catch(Error er){
throw new Exception("创建插件活动接口失败,返回信息:"+saveResponse.asString());
}
return saveResponse;
}
// public static void main(String[] args) throws Exception{ // public static void main(String[] args) throws Exception{
// String endTime = "2021-12-31 23:55:00"; // String endTime = "2021-12-31 23:55:00";
// PkActivityService pkActivityService = new PkActivityService(); // PkActivityService pkActivityService = new PkActivityService();
......
...@@ -2,6 +2,7 @@ package http.service.Manager; ...@@ -2,6 +2,7 @@ package http.service.Manager;
import base.DuibaLog; import base.DuibaLog;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import http.service.Authorization; import http.service.Authorization;
import io.restassured.response.Response; import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -345,9 +346,4 @@ public class PluginService { ...@@ -345,9 +346,4 @@ public class PluginService {
} }
} }
...@@ -27,156 +27,341 @@ public class DeveloperBJZ { ...@@ -27,156 +27,341 @@ public class DeveloperBJZ {
Authorization authorization; Authorization authorization;
private DuibaLog logger = DuibaLog.getLogger(); private DuibaLog logger = DuibaLog.getLogger();
//优质好货--查询至尊版特权TAB //优质好货--查询至尊版特权TAB
public Response item(String type) throws Exception{ public Response items(String type,String appId) throws Exception {
String url="http://"+hdHost+"/saasitem/items"; String url = "http://" + hdHost + "/saasitem/items";
Map<String,String> map = new HashMap<>(); Map<String,String> map = new HashMap<>();
map.put("type",type); map.put("type",type);
map.put("rowId","1"); map.put("rowId","1");
map.put("itemName",""); map.put("itemName","");
map.put("max","20"); map.put("max","20");
// logger.info("********"+url); Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas(appId)).params(map).get(url);
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas()).params(map).get(url); response.prettyPrint();
// response.prettyPrint(); try {
try{ Assert.assertEquals(response.jsonPath().getString("desc"), "成功");
Assert.assertEquals(response.jsonPath().getString("desc"),"成功"); } catch (Exception e) {
}catch(Exception e){ throw new Exception("创建接口1失败,返回信息:" + response.asString());
throw new Exception("创建接口1失败,返回信息:"+response.asString()); } catch (Error er) {
}catch(Error er){ throw new Exception("创建接口2失败,返回信息:" + response.asString());
throw new Exception("创建接口2失败,返回信息:"+response.asString());
} }
return response; return response;
} }
//至尊特权添加商品 //搜索具体的实物
public Response ajaxAddRepo(String appId,String itemId) throws Exception{ public Response items2(String type, String appId) throws Exception {
String url="http://"+hdHost+"/devRepo/ajaxAddRepo"; String url = "http://" + hdHost + "/saasitem/items";
Map<String,String> map = new HashMap<>();
map.put("type",type);
map.put("rowId","1");
map.put("itemName","测试至尊享版-实物3");
map.put("max","20");
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas(appId)).params(map).get(url);
response.prettyPrint();
try {
Assert.assertEquals(response.jsonPath().getString("desc"), "成功");
} catch (Exception e) {
throw new Exception("创建接口1失败,返回信息:" + response.asString());
} catch (Error er) {
throw new Exception("创建接口2失败,返回信息:" + response.asString());
}
return response;
}
//搜索具体的实物,查出无结果
public Response items3(String type,String appId) throws Exception {
String url = "http://" + hdHost + "/saasitem/items";
Map<String,String> map = new HashMap<>(); Map<String,String> map = new HashMap<>();
map.put("type",type);
map.put("rowId","1");
map.put("itemName","测试至尊享版-实物31");
map.put("max","20");
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas(appId)).params(map).get(url);
try {
Assert.assertEquals(response.jsonPath().getString("desc"), "成功");
} catch (Exception e) {
throw new Exception("创建接口1失败,返回信息:" + response.asString());
} catch (Error er) {
throw new Exception("创建接口2失败,返回信息:" + response.asString());
}
return response;
}
//至尊特权添加商品
public Response ajaxAddRepo(String appId, String itemId) throws Exception {
String url = "http://" + hdHost + "/devRepo/ajaxAddRepo";
Map<String, String> map = new HashMap<>();
map.put("appId",appId); map.put("appId",appId);
map.put("itemId",itemId); map.put("itemId",itemId);
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas()).params(map).post(url); Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas(appId)).params(map).post(url);
// response.prettyPrint(); // response.prettyPrint();
try{ try {
Assert.assertEquals(response.jsonPath().getString("desc"),"成功"); Assert.assertEquals(response.jsonPath().getString("desc"), "成功");
}catch(Exception e){ } catch (Exception e) {
throw new Exception("创建接口1失败,返回信息:"+response.asString()); throw new Exception("创建接口1失败,返回信息:" + response.asString());
}catch(Error er){ } catch (Error er) {
throw new Exception("创建接口2失败,返回信息:"+response.asString()); throw new Exception("创建接口2失败,返回信息:" + response.asString());
} }
return response; return response;
} }
//至尊特权上架商品 //至尊特权上架商品
public Response ajaxDirectUp(String appId,String itemIds) throws Exception{ public Response ajaxDirectUp(String appId, String itemIds) throws Exception {
String url="http://"+hdHost+"/devRepo/ajaxDirectUp"; String url = "http://" + hdHost + "/devRepo/ajaxDirectUp";
Map<String,String> map = new HashMap<>(); Map<String, String> map = new HashMap<>();
map.put("appId",appId); map.put("appId",appId);
map.put("itemIds",itemIds); map.put("itemIds",itemIds);
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas()).params(map).post(url); Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas(appId)).params(map).post(url);
response.prettyPrint(); response.prettyPrint();
try{ try {
Assert.assertEquals(response.jsonPath().getString("desc"),"直接上架成功"); Assert.assertEquals(response.jsonPath().getString("desc"), "直接上架成功");
}catch(Exception e){ } catch (Exception e) {
throw new Exception("创建接口1失败,返回信息:"+response.asString()); throw new Exception("创建接口1失败,返回信息:" + response.asString());
}catch(Error er){ } catch (Error er) {
throw new Exception("创建接口2失败,返回信息:"+response.asString()); throw new Exception("创建接口2失败,返回信息:" + response.asString());
} }
return response; return response;
} }
//大牌好券--查询至尊版特权TAB //旗舰版app上架:至尊特权商品
public Response coupons(String appId,String type) throws Exception{ public Response ajaxDirectUp2(String appId, String itemIds) throws Exception {
String url="http://"+hdHost+"/saasitem/coupons"; String url = "http://" + hdHost + "/devRepo/ajaxDirectUp";
Map<String,String> map = new HashMap<>(); Map<String,String> map = new HashMap<>();
map.put("appId",appId); map.put("appId",appId);
map.put("itemIds", itemIds);
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas(appId)).params(map).post(url);
response.prettyPrint();
try {
Assert.assertEquals(response.jsonPath().getString("desc"), "至尊版专享");
} catch (Exception e) {
throw new Exception("创建接口1失败,返回信息:" + response.asString());
} catch (Error er) {
throw new Exception("创建接口2失败,返回信息:" + response.asString());
}
return response;
}
//大牌好券--查询至尊版特权TAB
public Response coupons(String appId, String type) throws Exception {
String url = "http://" + hdHost + "/saasitem/coupons";
Map<String, String> map = new HashMap<>();
map.put("appId",appId);
map.put("type",type); map.put("type",type);
map.put("rowId","1"); map.put("rowId","1");
map.put("subType",""); map.put("subType","");
map.put("max","12"); map.put("max","12");
// logger.info("********"+url); Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas(appId)).params(map).get(url);response.prettyPrint();
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas()).params(map).get(url); try {
// response.prettyPrint(); Assert.assertEquals(response.jsonPath().getString("desc"), "成功");
try{ } catch (Exception e) {
Assert.assertEquals(response.jsonPath().getString("desc"),"成功"); throw new Exception("创建接口1失败,返回信息:" + response.asString());
}catch(Exception e){ } catch (Error er) {
throw new Exception("创建接口1失败,返回信息:"+response.asString()); throw new Exception("创建接口2失败,返回信息:" + response.asString());
}catch(Error er){
throw new Exception("创建接口2失败,返回信息:"+response.asString());
} }
return response; return response;
} }
//热门活动--查询活动 //热门活动--查询活动
public Response saasActivitys(String categoryId) throws Exception{ public Response saasActivitys(String categoryId, String appId) throws Exception {
String url="http://"+hdHost+"/saasitem/saasActivitys"; String url = "http://" + hdHost + "/saasitem/saasActivitys";
Map<String,Object> map = new HashMap<>(); Map<String,Object> map = new HashMap<>();
map.put("attrIds",""); map.put("attrIds","");
map.put("rowId","1"); map.put("rowId","1");
map.put("max","25"); map.put("max","25");
map.put("categoryId",categoryId); map.put("categoryId",categoryId);
logger.info("********"+url); logger.info("********" + url);
//json 格式转成form表单 //json 格式转成form表单
JSONObject jsonParam = JSONObject.parseObject(JSON.toJSONString(map)); JSONObject jsonParam = JSONObject.parseObject(JSON.toJSONString(map));
Response response=given().contentType("application/json;charset=UTF-8").cookies(authorization.hdLoginSaas("19515")).body(jsonParam).post(url); Response response = given().contentType("application/json;charset=UTF-8").cookies(authorization.hdLoginSaas(appId)).body(jsonParam).post(url);
// response.prettyPrint();
try{ try {
Assert.assertEquals(response.jsonPath().getString("desc"),"成功"); Assert.assertEquals(response.jsonPath().getString("desc"), "成功");
}catch(Exception e){ } catch (Exception e) {
throw new Exception("创建接口1失败,返回信息:"+response.asString()); throw new Exception("创建接口1失败,返回信息:" + response.asString());
}catch(Error er){ } catch (Error er) {
throw new Exception("创建接口2失败,返回信息:"+response.asString()); throw new Exception("创建接口2失败,返回信息:" + response.asString());
} }
return response; return response;
} }
//选中活动 //选中活动
public Response itemOrderDetail(String goodItemId) throws Exception{ public Response itemOrderDetail(String goodItemId, String appId) throws Exception {
String url="http://"+hdHost+"/saasitem/itemOrderDetail"; String url = "http://" + hdHost + "/saasitem/itemOrderDetail";
Map<String,String> map = new HashMap<>(); Map<String, String> map = new HashMap<>();
map.put("goodItemId",goodItemId); map.put("goodItemId", goodItemId);
// logger.info("********"+url); // logger.info("********"+url);
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas()).params(map).get(url); Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas(appId)).params(map).get(url);
// response.prettyPrint(); // response.prettyPrint();
try{ try {
Assert.assertEquals(response.jsonPath().getString("desc"),"成功"); Assert.assertEquals(response.jsonPath().getString("desc"), "成功");
}catch(Exception e){ } catch (Exception e) {
throw new Exception("创建接口1失败,返回信息:"+response.asString()); throw new Exception("创建接口1失败,返回信息:" + response.asString());
}catch(Error er){ } catch (Error er) {
throw new Exception("创建接口2失败,返回信息:"+response.asString()); throw new Exception("创建接口2失败,返回信息:" + response.asString());
} }
return response; return response;
} }
//订购活动--创建订单 //订购活动--创建订单
public Response createAutomationOrderNew(String skuId) throws Exception{ public Response createAutomationOrderNew(String skuId, String appId) throws Exception {
String url="http://"+hdHost+"/saas/createAutomationOrderNew"; String url = "http://" + hdHost + "/saas/createAutomationOrderNew";
Map<String,String> map = new HashMap<>(); Map<String, String> map = new HashMap<>();
map.put("skuId",skuId); map.put("skuId", skuId);
// logger.info("********"+url); // logger.info("********"+url);
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas("19515")).params(map).post(url); Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas(appId)).params(map).post(url);
// response.prettyPrint(); // response.prettyPrint();
try{ try {
Assert.assertEquals(response.jsonPath().getString("desc"),"成功"); Assert.assertEquals(response.jsonPath().getString("desc"), "成功");
}catch(Exception e){ } catch (Exception e) {
throw new Exception("创建接口1失败,返回信息:"+response.asString()); throw new Exception("创建接口1失败,返回信息:" + response.asString());
}catch(Error er){ } catch (Error er) {
throw new Exception("创建接口2失败,返回信息:"+response.asString()); throw new Exception("创建接口2失败,返回信息:" + response.asString());
}
return response;
}
//订购活动--创建订单
public Response createAutomationOrderNew2(String skuId, String appId) throws Exception {
String url = "http://" + hdHost + "/saas/createAutomationOrderNew";
Map<String, String> map = new HashMap<>();
map.put("skuId", skuId);
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas(appId)).params(map).post(url);
try {
Assert.assertEquals(response.jsonPath().getString("desc"), "订单未处理");
} catch (Exception e) {
throw new Exception("创建接口1失败,返回信息:" + response.asString());
} catch (Error er) {
throw new Exception("创建接口2失败,返回信息:" + response.asString());
} }
return response; return response;
} }
//订购--账户余额付款 //订购--账户余额付款
public Response orderAccountPay(String orderId) throws Exception{ public Response orderAccountPay(String orderId, String appId) throws Exception {
String url="http://"+hdHost+"/saas/orderAccountPay"; String url = "http://" + hdHost + "/saas/orderAccountPay";
Map<String,String> map = new HashMap<>(); Map<String, String> map = new HashMap<>();
map.put("orderId",orderId); map.put("orderId",orderId);
// logger.info("********"+url); Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas(appId)).params(map).get(url);response.prettyPrint();
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas()).params(map).get(url); try {
// response.prettyPrint(); Assert.assertEquals(response.jsonPath().getString("desc"), "成功");
try{ } catch (Exception e) {
Assert.assertEquals(response.jsonPath().getString("desc"),"成功"); throw new Exception("创建接口1失败,返回信息:" + response.asString());
}catch(Exception e){ } catch (Error er) {
throw new Exception("创建接口1失败,返回信息:"+response.asString()); throw new Exception("创建接口2失败,返回信息:" + response.asString());
}catch(Error er){ }
throw new Exception("创建接口2失败,返回信息:"+response.asString()); return response;
}
//查询购买的活动订单信息
public Response findOrderById(String orderId, String appId) throws Exception {
String url = "http://" + hdHost + "/saas/findOrderById";
Map<String, String> map = new HashMap<>();
map.put("orderId",orderId);
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas(appId)).params(map).get(url);
response.prettyPrint();
try {
Assert.assertEquals(response.jsonPath().getString("desc"), "成功");
} catch (Exception e) {
throw new Exception("创建接口1失败,返回信息:" + response.asString());
} catch (Error er) {
throw new Exception("创建接口2失败,返回信息:" + response.asString());
}
return response;
}
//查看记录是否添加购买成功
public Response selectOrders(String orderStatus, String appId) throws Exception {
String url = "http://" + hdHost + "/saas/selectOrders";
Map<String, String> map = new HashMap<>();
map.put("orderStatus",orderStatus);
map.put("appId",appId);
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas(appId)).params(map).get(url);response.prettyPrint();
try {
Assert.assertEquals(response.jsonPath().getString("desc"), "成功");
} catch (Exception e) {
throw new Exception("创建接口1失败,返回信息:" + response.asString());
} catch (Error er) {
throw new Exception("创建接口2失败,返回信息:" + response.asString());
}
return response;
}
//取消付款
public Response cancleOrder(String orderId ,String appId) throws Exception {
String url = "http://" + hdHost + "/saas/cancleOrder";
Map<String, String> map = new HashMap<>();
map.put("orderId",orderId);
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas(appId)).params(map).post(url);
response.prettyPrint();
try {
Assert.assertEquals(response.jsonPath().getString("desc"), "成功");
} catch (Exception e) {
throw new Exception("创建接口1失败,返回信息:" + response.asString());
} catch (Error er) {
throw new Exception("创建接口2失败,返回信息:" + response.asString());
}
return response;
}
//查询直冲类商品
public Response directCharges(String appId) throws Exception {
String url = "http://" + hdHost + "/saasitem/directCharges";
Map<String, String> map = new HashMap<>();
map.put("rowId","1");
map.put("max","20");
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas(appId)).params(map).get(url);
response.prettyPrint();
try {
Assert.assertEquals(response.jsonPath().getString("desc"), "成功");
} catch (Exception e) {
throw new Exception("查询直冲类商品失败,返回信息:" + response.asString());
} catch (Error er) {
throw new Exception("查询直冲类商品失败,返回信息:" + response.asString());
}
return response;
}
//查询商品管理——商品
public Response appItems(String appId, String itemName) throws Exception {
String url = "http://" + hdHost + "/devItem/appItems";
Map<String,String> map = new HashMap<>();
map.put("rowId", "1");
map.put("itemType", "");
map.put("belong", "");
map.put("status", "");
map.put("priceType", "");
map.put("itemName",itemName);
map.put("appId",appId);
map.put("classifyId", "");
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas(appId)).params(map).post(url);
response.prettyPrint();
try {
Assert.assertEquals(response.jsonPath().getString("desc"), "成功");
} catch (Exception e) {
throw new Exception("查询商品管理——商品失败,返回信息:" + response.asString());
} catch (Error er) {
throw new Exception("查询商品管理——商品失败,返回信息:" + response.asString());
}
return response;
}
//删除实物
public Response ajaxDel(String appId,String appItemId) throws Exception {
String url = "http://" + hdHost + "/devItem/ajaxDel";
Map<String, String> map = new HashMap<>();
map.put("appId",appId);
map.put("appItemId",appItemId);
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas(appId)).params(map).post(url);
response.prettyPrint();
try {
Assert.assertEquals(response.jsonPath().getString("desc"), "成功");
} catch (Exception e) {
throw new Exception("删除商品接口接口失败,返回信息:" + response.asString());
} catch (Error er) {
throw new Exception("删除商品接口接口失败,返回信息:" + response.asString());
} }
return response; return response;
} }
} }
...@@ -34,7 +34,7 @@ public class UpdateAppInfoService { ...@@ -34,7 +34,7 @@ public class UpdateAppInfoService {
Map<String,Object> map = new HashMap<>(); Map<String,Object> map = new HashMap<>();
map.put("appId",appId); map.put("appId",appId);
map.put("creditsRate","100"); map.put("creditsRate","100");
map.put("appName","(saas)接口自动化应用"); map.put("appName","(saas自动化)至尊版");
map.put("appTitle","自动化测试使用"); map.put("appTitle","自动化测试使用");
map.put("logoVal","//yun.dui88.com/images/201809/svieibjtn0.png"); map.put("logoVal","//yun.dui88.com/images/201809/svieibjtn0.png");
map.put("unitName",unitName); map.put("unitName",unitName);
......
...@@ -33,6 +33,7 @@ public class QbExchangeService { ...@@ -33,6 +33,7 @@ public class QbExchangeService {
map.put("token","0nmfgduh8"); map.put("token","0nmfgduh8");
Response response = given().params(map).cookies(cookies).post(activityHost+"/qbExchange/exchange"); Response response = given().params(map).cookies(cookies).post(activityHost+"/qbExchange/exchange");
try{ try{
Assert.assertEquals(response.jsonPath().getString("success"),"true","/qbExchange/exchange接口失败"); Assert.assertEquals(response.jsonPath().getString("success"),"true","/qbExchange/exchange接口失败");
...@@ -45,4 +46,27 @@ public class QbExchangeService { ...@@ -45,4 +46,27 @@ public class QbExchangeService {
return response; return response;
} }
public Response doTakePrize1(Map cookies, String qq, String degreeId) throws Exception {
logger.info("请求/qbExchange/exchange");
Map<String,String> map = new HashMap<>();
map.put("qq",qq);
map.put("degreeId",degreeId);
map.put("token","0nmfgduh8");
Response response = given().params(map).cookies(cookies).post(activityHost+"/qbExchange/exchange");
String message = response.jsonPath().getString("data.message");
logger .info(message);
try{
Assert.assertEquals(String.valueOf(response.getStatusCode()), "200", "/objectExchange/exchange接口返回异常");
}catch(Exception e){
throw new Exception("/qbExchange/exchange接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/qbExchange/exchange接口失败,返回信息:"+response.asString());
}
return response;
}
} }
...@@ -48,8 +48,8 @@ public class ActivityCtrlService { ...@@ -48,8 +48,8 @@ public class ActivityCtrlService {
params.put("actId",actId); params.put("actId",actId);
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.dafuwengLogin(uid)).params(params) Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.dafuwengLogin(uid)).params(params)
.post(activityHost+"/newActivity/ajaxElement"); .post(activityHost+"/hdtool/ajaxElement");
logger.info("请求/newActivity/ajaxElement接口,响应结果:"+response.asString()); logger.info("请求/hdtool/ajaxElement接口,响应结果:"+response.asString());
return response; return response;
} }
...@@ -58,8 +58,8 @@ public class ActivityCtrlService { ...@@ -58,8 +58,8 @@ public class ActivityCtrlService {
params.put("activityId",activityId); params.put("activityId",activityId);
params.put("token",token); params.put("token",token);
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.dafuwengLogin(uid)).params(params) Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.dafuwengLogin(uid)).params(params)
.post(activityHost+"/newActivity/doJoin"); .post(activityHost+"/hdtool/doJoin");
logger.info("请求/newActivity/doJoin接口,响应结果:"+response.asString()); logger.info("请求/hdtool/doJoin接口,响应结果:"+response.asString());
return response; return response;
} }
...@@ -84,8 +84,8 @@ public class ActivityCtrlService { ...@@ -84,8 +84,8 @@ public class ActivityCtrlService {
params.put("answerData",answerData); params.put("answerData",answerData);
params.put("token",token); params.put("token",token);
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.dafuwengLogin(uid)).params(params) Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.dafuwengLogin(uid)).params(params)
.post(activityHost+"/newActivity/submit"); .post(activityHost+"/hdtool/submit");
logger.info("请求/newActivity/submit接口,响应结果:"+response.asString()); logger.info("请求/hdtool/submit接口,响应结果:"+response.asString());
return response; return response;
} }
...@@ -96,14 +96,14 @@ public class ActivityCtrlService { ...@@ -96,14 +96,14 @@ public class ActivityCtrlService {
*/ */
public Response getOrderStatus(long orderId) throws Exception{ public Response getOrderStatus(long orderId) throws Exception{
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.dafuwengLogin(uid)).param("orderId",orderId) Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.dafuwengLogin(uid)).param("orderId",orderId)
.post(activityHost+"/newActivity/getOrderStatus"); .post(activityHost+"/hdtool/getOrderStatus");
logger.info("请求/newActivity/getOrderStatus接口,响应结果:"+response.asString()); logger.info("请求/hdtool/getOrderStatus接口,响应结果:"+response.asString());
try{ try{
Assert.assertEquals(response.jsonPath().getString("success"),"true"); Assert.assertEquals(response.jsonPath().getString("success"),"true");
}catch(Exception e){ }catch(Exception e){
throw new Exception("/newActivity/getOrderStatus接口失败,返回信息:"+response.asString()); throw new Exception("/hdtool/getOrderStatus接口失败,返回信息:"+response.asString());
}catch(Error er){ }catch(Error er){
throw new Exception("/newActivity/getOrderStatus接口失败,返回信息:"+response.asString()); throw new Exception("/hdtool/getOrderStatus接口失败,返回信息:"+response.asString());
} }
return response; return response;
......
...@@ -619,7 +619,7 @@ public class DeveloperService { ...@@ -619,7 +619,7 @@ public class DeveloperService {
return response; return response;
} }
//删除活动 //删除自有签到活动
public Response delete(String signId) throws Exception { public Response delete(String signId) throws Exception {
Map<String,String> map = new HashMap<>(); Map<String,String> map = new HashMap<>();
...@@ -1110,4 +1110,123 @@ public class DeveloperService { ...@@ -1110,4 +1110,123 @@ public class DeveloperService {
return response; return response;
} }
//保存自有答题活动--所有字段
public Response saveQuestion(String title,String awards,String questionRecord,String creditsType,String freeLimit,String freeScope,String limitCount,String limitScope,String optionNum) throws Exception {
String url=hdHost+"/question/save";
Map<String,String> map = new HashMap<>();
map.put("subType","question");
map.put("title",title);
map.put("anticheatExchangeLimit","true");
map.put("awards",awards);
map.put("questionRecord",questionRecord);
map.put("credits","22");
map.put("creditsType",creditsType);
map.put("banner","//yun.duiba.com.cn/upload/S2T4p1474356849960.png");
map.put("thumbnail","//yun.duiba.com.cn/upload/ljoka1474356876322.png");
map.put("bannerImgNew","//yun.duiba.com.cn/upload/qzfsmsyo9s.png");
map.put("appId","2239");
map.put("freeLimit",freeLimit);
map.put("freeScope",freeScope);
map.put("limitCount",limitCount);
map.put("limitScope",limitScope);
map.put("optionNum",optionNum);
map.put("autoOffDate","2020-12-08 00:00");
map.put("id","");
logger.info("创建自有答题活动:"+url);
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLogin()).params(map).post("http://"+url);
response.prettyPrint();
try{
Assert.assertEquals(response.jsonPath().getString("desc"),"成功");
}catch(Exception e){
throw new Exception("创建自有答题活动接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("创建自有答题活动接口失败,返回信息:"+response.asString());
}
return response;
}
//编辑自有答题活动
public Response editQuestion(String actId) throws Exception {
String url=hdHost+"/question/editData";
Map<String,String> map = new HashMap<>();
map.put("appId","2239");
map.put("actId",actId);
map.put("type","question");
logger.info("请求编辑自有答题活动url:"+url);
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLogin()).params(map).post("http://"+url);
response.prettyPrint();
try{
Assert.assertEquals(response.jsonPath().getString("desc"),"成功");
}catch(Exception e){
throw new Exception("编辑自有答题活动接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("编辑自有答题活动接口失败,返回信息:"+response.asString());
}
return response;
}
//创建自有弹层签到--所有字段
public Response saveSign(String title,String signType,String prizes,String signCredits) throws Exception {
String url=hdHost+"/signConfig/signSave";
Map<String,String> map = new HashMap<>();
map.put("title",title);
map.put("rateDescription","测试概率shuom");
map.put("ruleDescription","测试活动规则");
map.put("signType",signType);
map.put("prizes",prizes);
map.put("imageUrl","//yun.duiba.com.cn/developer_new/images/activities/sign.jpg");
map.put("triggerType","chome");
map.put("deletedPrizeIds","");
map.put("signCredits",signCredits);
map.put("status","0");
map.put("anticheatExchangeLimit","true");
map.put("appId","2239");
map.put("id","");
logger.info("创建自有签到活动:"+url);
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLogin()).params(map).post("http://"+url);
response.prettyPrint();
try{
Assert.assertEquals(response.jsonPath().getString("desc"),"成功");
}catch(Exception e){
throw new Exception("创建自有签到活动接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("创建自有签到活动接口失败,返回信息:"+response.asString());
}
return response;
}
//编辑自有弹层签到
public Response editSign(String id) throws Exception {
String url=hdHost+"/signConfig/signEdit";
Map<String,String> map = new HashMap<>();
map.put("id",id);
map.put("appId","2239");
logger.info("编辑自有签到活动:"+url);
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLogin()).params(map).post("http://"+url);
response.prettyPrint();
try{
Assert.assertEquals(response.jsonPath().getString("success"),"true");
}catch(Exception e){
throw new Exception("编辑自有签到活动接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("编辑自有签到活动接口失败,返回信息:"+response.asString());
}
return response;
}
} }
package http.service.hd;
import http.service.Authorization;
import base.DuibaLog;
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.HashMap;
import java.util.Map;
import static io.restassured.RestAssured.given;
/**
* Created by lvwenyan on 2018/12/06.
*/
@Service
public class LaunchService {
@Value("${hdserver.host}")
String hdHost;
@Autowired
Authorization authorization;
private DuibaLog logger = DuibaLog.getLogger();
//获取活动默认数据
public Response getDataConfigUrl(String type) throws Exception{
String url = hdHost + "/launch/getDataConfigUrl";
Map<String,String> map = new HashMap<>();
map.put("appId","2239");
map.put("type",type);
logger.info("请求数据配置接口:" + url);
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLogin()).params(map).post("http://"+url);
response.prettyPrint();
try{
Assert.assertEquals(response.jsonPath().getString("desc"),"成功");
}catch(Exception e){
throw new Exception("请求数据配置接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("请求数据配置接口失败,返回信息:"+response.asString());
}
return response;
}
//获取活动默认奖品
public Response obtain() throws Exception{
String url = hdHost + "/launch/obtain";
Map<String,String> map = new HashMap<>();
map.put("appId","2239");
logger.info("请求获取奖品接口:" + url);
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLogin()).params(map).post("http://"+url);
response.prettyPrint();
try{
Assert.assertEquals(response.jsonPath().getString("desc"),"成功");
}catch(Exception e){
throw new Exception("请求获取奖品接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("请求获取奖品接口失败,返回信息:"+response.asString());
}
return response;
}
}
...@@ -82,4 +82,24 @@ public class SigninService { ...@@ -82,4 +82,24 @@ public class SigninService {
} }
return response; return response;
} }
//活动预览
public Response preview(String appId,String type,String sourceId,String activityId,String email) throws Exception{
Map<String,String> map = new HashMap<>();
map.put("appId",appId);
map.put("type",type);
map.put("sourceId",sourceId);
map.put("activityId",activityId);
Response response = given().cookies(authorization.hdLoginCommon(email)).params(map).post("http://"+hdHost+"/activity/preview");
response.prettyPrint();
try{
Assert.assertEquals(response.jsonPath().getString("success"),"true");
}catch(Exception e){
throw new Exception("/activity/preview接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/activity/preview接口失败,返回信息:"+response.asString());
}
return response;
}
} }
...@@ -37,7 +37,7 @@ public class RedisUtil { ...@@ -37,7 +37,7 @@ public class RedisUtil {
map.put("value",value); map.put("value",value);
Response response = given().params(map).get("http://activity.m.duibatest.com.cn/seedRedPacket/setKey"); Response response = given().params(map).get("http://activity.m.duibatest.com.cn/seedRedPacket/setKey");
response.prettyPrint();
} }
public static void clearKey(String key){ public static void clearKey(String key){
Map<String,String> map = new HashMap<>(); Map<String,String> map = new HashMap<>();
......
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