Commit 66b83e56 authored by wangxiaoshuang's avatar wangxiaoshuang

Merge branch 'develop' into wxs

parents 497bbc74 75e1af1d
......@@ -318,6 +318,7 @@
<maxRetryCount>0</maxRetryCount>
<ServiceDoctor>false</ServiceDoctor>
<Server>false</Server>
<sendMiria>false</sendMiria>
</systemPropertyVariables>
</configuration>
......
......@@ -35,6 +35,7 @@ public class DingdingResult {
transient ApplicationContext context = new AnnotationConfigApplicationContext(Config.class);
transient Environment env=context.getBean(Environment.class);
public transient static String[] name;
transient GitlabProjectMerges gitlabProjectMerges;
String path=null;
public DingdingResult(int total, int passCount, int skipCount, int failCount) throws UnsupportedEncodingException {
......@@ -42,7 +43,7 @@ public class DingdingResult {
logger.info("属性:"+System.getProperties());
Map<String,String> changeMap=null;
group = duibaGroup.split(",");
changeMap = BeTested.getLatestChanges(duibaGroup.split(","));
// changeMap = BeTested.getLatestChanges(duibaGroup.split(","));
project = "duiba-service";
......@@ -53,11 +54,15 @@ public class DingdingResult {
names.addAll(Arrays.asList(getNames));
boolean sendMiria = Boolean.parseBoolean(System.getProperty("sendMiria"));
if(sendMiria){
Map<String,String> params = new HashMap<>();
params.put("jobName",getJob());
changes = Postman.sendFindTestApp(params);
}
GitlabProjectMerges gitlabProjectMerges = GitlabUtils.getMessage("credits-group",changes);
gitlabProjectMerges = GitlabUtils.getMessage("credits-group",changes);
changes = changes+" 提交者:"+gitlabProjectMerges.getAuthor().getName()+" 描述:"+gitlabProjectMerges.getDescription();
......@@ -145,6 +150,7 @@ public class DingdingResult {
// System.out.println(e);
// }
names.add(gitlabProjectMerges.getAuthor().getUsername());
}else {
names.clear();
......
......@@ -72,10 +72,10 @@ public class MysqlConnPool {
map = new HashMap<String, Object>();
int index = 1;
log.info("bds!=null");
// log.info("bds!=null");
PreparedStatement pstmt = conn.prepareStatement(sql);
log.info("conn!=null");
log.info(conn.toString());
// log.info("conn!=null");
// log.info(conn.toString());
if(params != null && !(params.length==0)){
for(int i=0; i<params.length; i++){
pstmt.setObject(index++, params[i]);
......
......@@ -22,13 +22,14 @@ import static io.restassured.RestAssured.given;
*/
public class Postman {
final static String dingdingUrl="https://shark.dui88.com/test/integration";
final static String testPlatformUrl = "http://101.37.27.82:8080/insert";
final static String testPlatformUrl = "http://test-run.duibatest.com.cn/insert";
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 miriaUrlFindTestApp = "http://miria-aliyun.duibatest.com.cn/autoTest/findTestApp";
//dingdingUrl="http://www.json.cn/";
private static Logger logger = LogManager.getLogger(Postman.class);
// private static Logger logger = LogManager.getLogger(Postman.class);
public static DuibaLog logger = DuibaLog.getLogger();
public static void send2Dingding(Map result){
System.out.println("Dingding:"+result);
RestAssuredConfig config = RestAssured.config();
......@@ -44,7 +45,7 @@ public class Postman {
String[] name = DingdingResult.name;
result.put("names",name);
response=given().contentType(ContentType.JSON).body(result).post(dingdingUrl);
System.out.println("钉钉重试响应数据:"+response.asString());
logger.info("钉钉重试响应数据:"+response.asString());
}
......@@ -52,28 +53,28 @@ public class Postman {
public static void sendTestPlatform(Map result){
Response response=given().contentType(ContentType.JSON).body(result).post(testPlatformUrl);
System.out.println("自动化数据收集平台响应数据:"+response.asString());
logger.info("自动化数据收集平台响应数据:"+response.asString());
}
public static void sendFinish(Map result){
Response response=given().params(result).get(miriaUrl);
System.out.println("jobName:"+result.get("jobName"));
System.out.println("miriaUrl:"+miriaUrl);
System.out.println("miria响应结果:"+response.asString());
logger.info("jobName:"+result.get("jobName"));
logger.info("miriaUrl:"+miriaUrl);
logger.info("miria响应结果:"+response.asString());
}
public static void sendTesting(Map result){
Response response=given().params(result).get(miriaUrlTesting);
System.out.println("jobName:"+result.get("jobName"));
System.out.println("miriaUrl:"+miriaUrlTesting);
System.out.println("miria响应结果:"+response.asString());
logger.info("jobName:"+result.get("jobName"));
logger.info("miriaUrl:"+miriaUrlTesting);
logger.info("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());
logger.info("jobName:"+result.get("jobName"));
logger.info("miriaUrl:"+miriaUrlFindTestApp);
logger.info("miria响应结果:"+response.asString());
String value = response.jsonPath().getString("value");
return value;
}
......
......@@ -14,6 +14,7 @@ public class RetryToRunCase implements IRetryAnalyzer {
retryCount++;
return true;
}
retryCount = 0;
return false;
}
......
......@@ -2,10 +2,7 @@ package base;
import java.io.UnsupportedEncodingException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.*;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
......@@ -21,25 +18,70 @@ public class TestListener implements ITestListener {
String run = System.getProperty("run");
ApplicationContext context = new AnnotationConfigApplicationContext(Config.class);
Environment env=context.getBean(Environment.class);
boolean sendMiria = Boolean.parseBoolean(System.getProperty("sendMiria"));
public TestListener() throws UnsupportedEncodingException {
}
public void onFinish(ITestContext context) {
Iterator<ITestResult> listOfFailedTests = context.getFailedTests().getAllResults().iterator();
while (listOfFailedTests.hasNext()) {
ITestResult failedTest = listOfFailedTests.next();
ITestNGMethod method = failedTest.getMethod();
if (context.getFailedTests().getResults(method).size() > 1) {
listOfFailedTests.remove();
logger.info("context.getFailedTests().getResults(method).size() > 1");
// Iterator<ITestResult> listOfFailedTests = context.getFailedTests().getAllResults().iterator();
// while (listOfFailedTests.hasNext()) {
// ITestResult failedTest = listOfFailedTests.next();
// ITestNGMethod method = failedTest.getMethod();
// if (context.getFailedTests().getResults(method).size() > 1) {
// listOfFailedTests.remove();
// logger.info("context.getFailedTests().getResults(method).size() > 1");
// } else {
// if (context.getPassedTests().getResults(method).size() > 0) {
// listOfFailedTests.remove();
// logger.info("context.getPassedTests().getResults(method).size() > 0");
// }
// }
// }
// super.onFinish(testContext);
// List of test results which we will delete later
ArrayList<ITestResult> testsToBeRemoved = new ArrayList<ITestResult>();
// collect all id's from passed test
Set<Integer> passedTestIds = new HashSet<Integer>();
for (ITestResult passedTest : context.getPassedTests().getAllResults()) {
logger.info("PassedTests = " + passedTest.getName());
passedTestIds.add(getId(passedTest));
}
Set<Integer> failedTestIds = new HashSet<Integer>();
for (ITestResult failedTest : context.getFailedTests().getAllResults()) {
logger.info("failedTest = " + failedTest.getName());
// id = class + method + dataprovider
int failedTestId = getId(failedTest);
// if we saw this test as a failed test before we mark as to be
// deleted
// or delete this failed test if there is at least one passed
// version
if (failedTestIds.contains(failedTestId) || passedTestIds.contains(failedTestId)) {
testsToBeRemoved.add(failedTest);
} else {
if (context.getPassedTests().getResults(method).size() > 0) {
listOfFailedTests.remove();
logger.info("context.getPassedTests().getResults(method).size() > 0");
failedTestIds.add(failedTestId);
}
}
// finally delete all tests that are marked
for (Iterator<ITestResult> iterator = context.getFailedTests().getAllResults().iterator(); iterator
.hasNext();) {
ITestResult testResult = iterator.next();
if (testsToBeRemoved.contains(testResult)) {
logger.info("Remove repeat Fail Test: " + testResult.getName());
iterator.remove();
}
}
}
private int getId(ITestResult result) {
int id = result.getTestClass().getName().hashCode();
id = id + result.getMethod().getMethodName().hashCode();
id = id + (result.getParameters() != null ? Arrays.hashCode(result.getParameters()) : 0);
return id;
}
// Following are all the method stubs that you do not have to implement
......@@ -88,6 +130,7 @@ public class TestListener implements ITestListener {
}
//运行开始,触发互斥功能,用于定时任务
if(sendMiria){
Map<String,String> mapJob = new HashMap<>();
try {
......@@ -98,6 +141,7 @@ public class TestListener implements ITestListener {
Postman.sendTesting(mapJob);
}
}
public void serviceDoctor(){
logger.info("duiba-server开始检测");
ServiceDoctor serviceDoctor=new ServiceDoctor("duiba-server.properties");
......
......@@ -64,6 +64,8 @@ public class TestReport implements IReporter{
boolean noticeDD=Boolean.parseBoolean(System.getProperty("noticeDD"));
boolean noticePerson=Boolean.parseBoolean(System.getProperty("noticePerson"));
boolean sendPlatform=Boolean.parseBoolean(System.getProperty("sendPlatform"));
boolean sendMiria = Boolean.parseBoolean(System.getProperty("sendMiria"));
Gson gson=new GsonBuilder().create();
......@@ -78,6 +80,7 @@ public class TestReport implements IReporter{
System.out.println("测试结果通知信息:"+gson.toJson(map));
//触发回调结束服务构建互斥
if(sendMiria){
Map<String,String> mapJob = new HashMap<>();
try {
mapJob.put("jobName",ddResult.getJob());
......@@ -85,6 +88,7 @@ public class TestReport implements IReporter{
e.printStackTrace();
}
Postman.sendFinish(mapJob);
}
//发送运行结果到自动化数据收集平台
if(sendPlatform)
Postman.sendTestPlatform(map);
......
......@@ -88,7 +88,7 @@ public class 自有活动出奖_DuibaTest extends DuibaTestBase {
j--;
}
Assert.assertEquals(flowWork,"SupplierExchange-started","数据库主订单流程节点校验失败");
Assert.assertEquals(String.valueOf(selectResult2.get("biz_params")),"胡梦新:18258853242:浙江省:杭州市:西湖区:数娱大厦","数据库主订单biz_params校验失败");
Assert.assertEquals(String.valueOf(selectResult2.get("biz_params")),"胡梦新:18258853242:浙江:杭州市:西湖区:西溪街道:数娱大厦 ","数据库主订单biz_params校验失败");
Assert.assertEquals(String.valueOf(selectResult2.get("pay_status")),"none","数据库主订单pay_status校验失败");
Assert.assertEquals(String.valueOf(selectResult2.get("status")),"consume_success","数据库主订单status校验失败");
......
......@@ -387,7 +387,7 @@ public class ActiveGroup_FloorTest extends DuibaTestBase {
}
@Test
@Test(dependsOnMethods = { "A_创建活动楼层皮肤" })
public void B_手机端活动() throws Exception {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");//设置日期格式
logger.info(df.format(new Date()));
......@@ -444,7 +444,7 @@ public class ActiveGroup_FloorTest extends DuibaTestBase {
}
@Test
@Test(dependsOnMethods = { "B_手机端活动" })
public void C_删除活动楼层皮肤() throws Exception {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");//设置日期格式
......
......@@ -154,7 +154,7 @@ public class Banner_FloorTest extends DuibaTestBase {
}
@Test
@Test(dependsOnMethods = { "A_创建banner楼层皮肤" })
public void B_banner楼层活动校验() throws Exception {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");//设置日期格式
......@@ -212,7 +212,7 @@ public class Banner_FloorTest extends DuibaTestBase {
}
@Test
@Test(dependsOnMethods = { "B_banner楼层活动校验" })
public void C_banner商品校验() throws Exception {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");//设置日期格式
......
......@@ -342,7 +342,7 @@ public class Coupon_FloorTest extends DuibaTestBase {
}
@Test
@Test(dependsOnMethods = { "A_创建优惠券楼层皮肤" })
public void B_优惠券手机端() throws Exception {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");//设置日期格式
logger.info(df.format(new Date()));
......@@ -392,7 +392,7 @@ public class Coupon_FloorTest extends DuibaTestBase {
}
@Test
@Test(dependsOnMethods = { "B_优惠券手机端" })
public void C_删除优惠券楼层皮肤() throws Exception {
......
......@@ -230,7 +230,7 @@ public class Game_FloorTest extends DuibaTestBase {
}
@Test
@Test(dependsOnMethods = { "A_创建游戏楼层皮肤" })
public void B_游戏手机端() throws Exception {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");//设置日期格式
logger.info(df.format(new Date()));
......@@ -272,7 +272,7 @@ public class Game_FloorTest extends DuibaTestBase {
}
@Test
@Test(dependsOnMethods = { "B_游戏手机端" })
public void C_删除游戏楼层皮肤() throws Exception {
......
......@@ -222,7 +222,7 @@ public class Icon_FloorTest extends DuibaTestBase {
}
@Test
@Test(dependsOnMethods = { "A_创建icon楼层皮肤" })
public void B_icon添加图标() throws Exception {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");//设置日期格式
......@@ -296,7 +296,7 @@ public class Icon_FloorTest extends DuibaTestBase {
}
@Test
@Test(dependsOnMethods = { "B_icon添加图标" })
public void C_icon编辑图标() throws Exception {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");//设置日期格式
logger.info(df.format(new Date()));
......@@ -352,7 +352,7 @@ public class Icon_FloorTest extends DuibaTestBase {
Assert.assertEquals(map.get("logo"),"//yun.dui88.com/images/201806/9lz5ifre0h.png","今日必抢logo校验错误");
}
@Test
@Test(dependsOnMethods = { "C_icon编辑图标" })
public void D_icon删除图标() throws Exception {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");//设置日期格式
logger.info(df.format(new Date()));
......@@ -388,7 +388,7 @@ public class Icon_FloorTest extends DuibaTestBase {
}
@Test
@Test(dependsOnMethods = { "D_icon删除图标" })
public void E_删除icon楼层皮肤() throws Exception {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");//设置日期格式
logger.info(df.format(new Date()));
......
......@@ -362,7 +362,7 @@ public class Item_FloorTest extends DuibaTestBase {
}
@Test
@Test(dependsOnMethods = { "A_item创建楼层皮肤" })
public void B_item手机端() throws Exception {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");//设置日期格式
......@@ -404,7 +404,7 @@ public class Item_FloorTest extends DuibaTestBase {
}
@Test
@Test(dependsOnMethods = { "B_item手机端" })
public void C_item删除楼层皮肤() throws Exception {
......
......@@ -806,7 +806,7 @@ public class Seckill_FloorTest extends DuibaTestBase {
response = floorService.switchOpenState(authorization.ssoLogin(),skinId,"true");
}
@Test
@Test(dependsOnMethods = { "A_Seckill创建楼层皮肤" })
public void B_Seckill手机端() throws Exception {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");//设置日期格式
logger.info(df.format(new Date()));
......@@ -849,7 +849,7 @@ public class Seckill_FloorTest extends DuibaTestBase {
}
@Test
@Test(dependsOnMethods = { "B_Seckill手机端" })
public void C_Seckill删除楼层皮肤() throws Exception {
......
......@@ -244,7 +244,7 @@ public class Showcase_FloorTest extends DuibaTestBase {
}
@Test
@Test(dependsOnMethods = { "A_Showcase创建楼层皮肤" })
public void B_Showcase手机端() throws Exception {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");//设置日期格式
......@@ -289,7 +289,7 @@ public class Showcase_FloorTest extends DuibaTestBase {
}
@Test
@Test(dependsOnMethods = { "B_Showcase手机端" })
public void C_Showcase删除楼层皮肤() throws Exception {
......
......@@ -510,7 +510,7 @@ public class Sign_FloorTest extends DuibaTestBase {
}
@Test
@Test(dependsOnMethods = { "A_sign创建楼层皮肤" })
public void B_sign手机端() throws Exception {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");//设置日期格式
logger.info(df.format(new Date()));
......@@ -545,7 +545,7 @@ public class Sign_FloorTest extends DuibaTestBase {
}
@Test
@Test(dependsOnMethods = { "B_sign手机端" })
public void C_sign删除楼层皮肤() throws Exception {
......
......@@ -170,7 +170,7 @@ public class 出奖订单测试_DuibaTest extends DuibaTestBase {
}
Assert.assertEquals(flowWork,"SupplierExchange-started","数据库主订单流程节点校验失败");
Assert.assertEquals(String.valueOf(selectResult2.get("item_id")),"27131","数据库主订单奖项id校验失败");
Assert.assertEquals(String.valueOf(selectResult2.get("biz_params")),"胡梦新:18258853242:浙江省:杭州市:西湖区:数娱大厦","数据库主订单biz_params校验失败");
Assert.assertEquals(String.valueOf(selectResult2.get("biz_params")),"胡梦新:18258853242:浙江:杭州市:西湖区:西溪街道:数娱大厦 ","数据库主订单biz_params校验失败");
Assert.assertEquals(String.valueOf(selectResult2.get("pay_status")),"prereduce","数据库主订单pay_status校验失败");
Assert.assertEquals(String.valueOf(selectResult2.get("status")),"consume_success","数据库主订单status校验失败");
......
/**
* Copyright (C), 2015-2018
* FileName: 新集卡_达到限制发卡异常_DuibaTest
* Author: qianwenjun
* Date: 2018/10/16 20:09
* Description:
*/
package http.cases.NewCollectActivityTest;
import base.DuibaLog;
import base.DuibaTestBase;
import http.service.Activity.NewCollectActivityService;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import utils.ExcelDataProvider;
import utils.GetDbName;
import java.lang.reflect.Method;
import java.util.Iterator;
import java.util.Map;
/**
* 〈〉
*
* @author qianwenjun
* @create 2018/10/16
* @since 1.0.0
*/
public class 新旧集卡_发卡_DuibaTest extends DuibaTestBase {
@Autowired
NewCollectActivityService newCollectActivityService;
private static DuibaLog logger = DuibaLog.getLogger();
private Integer user01 = 5123;//旧插件发集卡-免费
private String consumerId01 = "100112156";
private Integer user02 = 5124;//旧插件发集卡-扣积分
private String consumerId02 = "100112157";
private Integer user03 = 5125;//新插件发集卡-扣积分
private String consumerId03 = "100112158";
private Integer user04 = 5126;//旧活动工具发集卡-扣积分
private String consumerId04 = "100112159";
private Integer user05 = 5127;//新活动工具发集卡-扣积分
private String consumerId05 = "100112160";
@Test
public void 插件发旧集卡_免费() throws Exception{
String pluginId = "3145";
String dbName = GetDbName.getDbName("ckvtable.tb_kvtable_",consumerId01,"1");
logger.info("用户集卡存放数据库为:"+dbName);
String sql = "select * from "+dbName+" where consumer_id = ? and vkey like 'cl_good_cid_itemId_%_27158'";
Map<String,Object> beforeCard = jdbc.findSimpleResult(sql,consumerId01);
Long cardNum = Long.valueOf(beforeCard.get("int_value").toString());
logger.info("用户该集卡数量为"+beforeCard.get("int_value").toString());
Response playReasponse = this.playPlugin(pluginId,"",user01);
playReasponse.prettyPrint();
Map<String,Object> afterCard = jdbc.findSimpleResult(sql,consumerId01);
Assert.assertEquals(afterCard.get("int_value").toString(),String.valueOf(cardNum+1),"卡片发放数据库校验失败");
logger.info("用户该集卡数量为"+afterCard.get("int_value").toString());
}
@Test
public void 插件发旧集卡_扣积分() throws Exception{
String pluginId = "3146";
String dbName = GetDbName.getDbName("ckvtable.tb_kvtable_",consumerId02,"1");
logger.info("用户集卡存放数据库为:"+dbName);
String sql = "select * from "+dbName+" where consumer_id = ? and vkey like 'cl_good_cid_itemId_%_27158'";
Map<String,Object> beforeCard = jdbc.findSimpleResult(sql,consumerId02);
Long cardNum = Long.valueOf(beforeCard.get("int_value").toString());
logger.info("用户该集卡数量为"+beforeCard.get("int_value").toString());
Map<String,Object> user = jdbc.findSimpleResult("select * from dafuweng.user where id=?\n",user02);
Map<String,Object> consumer = jdbc.findSimpleResult("select * from new_consumer.consumer_0010 where id=?\n",consumerId02);
Long userCredit = Long.parseLong(user.get("credits").toString());
Long consumerCredit = Long.parseLong(consumer.get("credits").toString());
Response playReasponse = this.playPlugin(pluginId,"",user02);
playReasponse.prettyPrint();
Map<String,Object> afterCard = jdbc.findSimpleResult(sql,consumerId02);
Assert.assertEquals(afterCard.get("int_value").toString(),String.valueOf(cardNum+1),"卡片发放数据库校验失败");
logger.info("用户该集卡数量为"+afterCard.get("int_value").toString());
Map<String,Object> user1 = jdbc.findSimpleResult("select * from dafuweng.user where id=?\n",user02);
Map<String,Object> consumer1 = jdbc.findSimpleResult("select * from new_consumer.consumer_0010 where id=?\n",consumerId02);
String userCredit1 = user1.get("credits").toString();
String consumerCredit1 = consumer1.get("credits").toString();
Assert.assertEquals(userCredit1,String.valueOf(userCredit-10),"user积分扣除校验失败");
Assert.assertEquals(consumerCredit1,String.valueOf(consumerCredit-10),"consumer积分扣除校验失败");
logger.info("校验积分消耗成功,原积分值="+userCredit+",消耗后积分值为"+userCredit1);
}
@Test
public void 插件发新集卡_扣积分() throws Exception{
String pluginId = "3147";
String dbName = GetDbName.getDbName("collect_card_consumer.tb_collect_card_info_",consumerId03,"1");
logger.info("用户集卡存放数据库为:"+dbName);
String sql = "select * from "+dbName+" where consumer_id = ? and item_id = '27158'";
Map<String,Object> beforeCard = jdbc.findSimpleResult(sql,consumerId03);
Long cardNum = Long.valueOf(beforeCard.get("item_count").toString());
logger.info("用户该集卡数量为"+beforeCard.get("item_count").toString());
Map<String,Object> user = jdbc.findSimpleResult("select * from dafuweng.user where id=?\n",user03);
Map<String,Object> consumer = jdbc.findSimpleResult("select * from new_consumer.consumer_0010 where id=?\n",consumerId03);
Long userCredit = Long.parseLong(user.get("credits").toString());
Long consumerCredit = Long.parseLong(consumer.get("credits").toString());
Response playReasponse = this.playPlugin(pluginId,"",user03);
playReasponse.prettyPrint();
Map<String,Object> afterCard = jdbc.findSimpleResult(sql,consumerId03);
Assert.assertEquals(afterCard.get("item_count").toString(),String.valueOf(cardNum+1),"卡片发放数据库校验失败");
logger.info("用户该集卡数量为"+afterCard.get("item_count").toString());
Map<String,Object> user1 = jdbc.findSimpleResult("select * from dafuweng.user where id=?\n",user03);
Map<String,Object> consumer1 = jdbc.findSimpleResult("select * from new_consumer.consumer_0010 where id=?\n",consumerId03);
String userCredit1 = user1.get("credits").toString();
String consumerCredit1 = consumer1.get("credits").toString();
Assert.assertEquals(userCredit1,String.valueOf(userCredit-10),"user积分扣除校验失败");
Assert.assertEquals(consumerCredit1,String.valueOf(consumerCredit-10),"consumer积分扣除校验失败");
logger.info("校验积分消耗成功,原积分值="+userCredit+",消耗后积分值为"+userCredit1);
}
@Test
public void 活动工具发旧集卡_扣积分() throws Exception{
String activityId = "37274";
String dbName = GetDbName.getDbName("ckvtable.tb_kvtable_",consumerId04,"1");
logger.info("用户集卡存放数据库为:"+dbName);
String sql = "select * from "+dbName+" where consumer_id = ? and vkey like 'cl_good_cid_itemId_%_31627'";
Map<String,Object> beforeCard = jdbc.findSimpleResult(sql,consumerId04);
Long cardNum = Long.valueOf(beforeCard.get("int_value").toString());
logger.info("用户该集卡数量为"+beforeCard.get("int_value").toString());
Map<String,Object> user = jdbc.findSimpleResult("select * from dafuweng.user where id=?\n",user04);
Map<String,Object> consumer = jdbc.findSimpleResult("select * from new_consumer.consumer_0010 where id=?\n",consumerId04);
Long userCredit = Long.parseLong(user.get("credits").toString());
Long consumerCredit = Long.parseLong(consumer.get("credits").toString());
Response playReasponse = this.playHdtool(activityId,"",user04);
playReasponse.prettyPrint();
Map<String,Object> afterCard = jdbc.findSimpleResult(sql,consumerId04);
Assert.assertEquals(afterCard.get("int_value").toString(),String.valueOf(cardNum+1),"卡片发放数据库校验失败");
logger.info("用户该集卡数量为"+afterCard.get("int_value").toString());
Map<String,Object> user1 = jdbc.findSimpleResult("select * from dafuweng.user where id=?\n",user04);
Map<String,Object> consumer1 = jdbc.findSimpleResult("select * from new_consumer.consumer_0010 where id=?\n",consumerId04);
String userCredit1 = user1.get("credits").toString();
String consumerCredit1 = consumer1.get("credits").toString();
Assert.assertEquals(userCredit1,String.valueOf(userCredit-10),"user积分扣除校验失败");
Assert.assertEquals(consumerCredit1,String.valueOf(consumerCredit-10),"consumer积分扣除校验失败");
logger.info("校验积分消耗成功,原积分值="+userCredit+",消耗后积分值为"+userCredit1);
}
@Test
public void 活动工具发新集卡_扣积分() throws Exception{
String activityId = "37275";
String dbName = GetDbName.getDbName("collect_card_consumer.tb_collect_card_info_",consumerId05,"1");
logger.info("用户集卡存放数据库为:"+dbName);
String sql = "select * from "+dbName+" where consumer_id = ? and item_id = '31628'";
Map<String,Object> beforeCard = jdbc.findSimpleResult(sql,consumerId05);
Long cardNum = Long.valueOf(beforeCard.get("item_count").toString());
logger.info("用户该集卡数量为"+beforeCard.get("item_count").toString());
Map<String,Object> user = jdbc.findSimpleResult("select * from dafuweng.user where id=?\n",user05);
Map<String,Object> consumer = jdbc.findSimpleResult("select * from new_consumer.consumer_0010 where id=?\n",consumerId05);
Long userCredit = Long.parseLong(user.get("credits").toString());
Long consumerCredit = Long.parseLong(consumer.get("credits").toString());
Response playReasponse = this.playHdtool(activityId,"",user05);
playReasponse.prettyPrint();
Map<String,Object> afterCard = jdbc.findSimpleResult(sql,consumerId05);
Assert.assertEquals(afterCard.get("item_count").toString(),String.valueOf(cardNum+1),"卡片发放数据库校验失败");
logger.info("用户该集卡数量为"+afterCard.get("item_count").toString());
Map<String,Object> user1 = jdbc.findSimpleResult("select * from dafuweng.user where id=?\n",user05);
Map<String,Object> consumer1 = jdbc.findSimpleResult("select * from new_consumer.consumer_0010 where id=?\n",consumerId05);
String userCredit1 = user1.get("credits").toString();
String consumerCredit1 = consumer1.get("credits").toString();
Assert.assertEquals(userCredit1,String.valueOf(userCredit-10),"user积分扣除校验失败");
Assert.assertEquals(consumerCredit1,String.valueOf(consumerCredit-10),"consumer积分扣除校验失败");
logger.info("校验积分消耗成功,原积分值="+userCredit+",消耗后积分值为"+userCredit1);
}
public Response playPlugin(String activityId, String collectRuleId, int uid) throws Exception {
Response response = newCollectActivityService.doJoinPlugdraw(activityId,collectRuleId,uid);
String orderId = response.jsonPath().getString("orderId");
response = newCollectActivityService.getOrderStatusPlugdraw(orderId,uid);
String result = String.valueOf(response.jsonPath().getString("result"));
int i= 30;
while(i>0&&(result.equals("0"))){
Thread.sleep(1000);
response = newCollectActivityService.getOrderStatusPlugdraw(orderId,uid);
result = String.valueOf(response.jsonPath().getString("result"));
i--;
}
return response;
}
public Response openPrize(String collectRuleId,Integer uid) throws Exception {
Response openResponse = newCollectActivityService.openCollectGoodsPrize(collectRuleId,uid);
String orderId = openResponse.jsonPath().getString("orderId");
Response statusResponse = newCollectActivityService.getOpenOrderStatus(orderId,uid);
String playResult = String.valueOf(statusResponse.jsonPath().getString("result"));
int i = 8;
while (i > 0 && (playResult.equals("0"))) {
Thread.sleep(1000);
statusResponse = newCollectActivityService.getOpenOrderStatus(orderId,uid);
playResult = String.valueOf(statusResponse.jsonPath().getString("result"));
i--;
}
return statusResponse;
}
public Response playHdtool(String activityId, String collectRuleId, int uid) throws Exception{
Response response = newCollectActivityService.doJoin(activityId,collectRuleId,uid);
response.prettyPrint();
String orderId = response.jsonPath().getString("orderId");
Response statusResponse = newCollectActivityService.getOrderStatus(orderId,uid);
// statusResponse.prettyPrint();
String playResult = statusResponse.jsonPath().getString("result");
int i = 30;
while (i > 0 && (playResult.equals("0"))) {
Thread.sleep(1000);
statusResponse = newCollectActivityService.getOrderStatus(orderId,uid);
playResult = String.valueOf(statusResponse.jsonPath().getString("result"));
i--;
}
return statusResponse;
}
}
/**
* Copyright (C), 2015-2018
* FileName: 瓜分积分测试_AccessTest
* Author: zhaoran
* Date: 2018/12/10 19:45
* Description:
*/
package http.cases.PkMoudleTest;
import base.DuibaLog;
import base.DuibaTestBase;
import com.alibaba.fastjson.JSONObject;
import http.service.Activity.PkService;
import http.service.Manager.PkActivityService;
import http.service.hd.PkDevelopService;
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.Test;
import java.sql.SQLException;
import java.util.Map;
public class 瓜分积分_作弊瓜分_AccessTest extends DuibaTestBase {
@Autowired
PkDevelopService pkDevelopService;
@Autowired
PkService pkService;
@Autowired
PkActivityService pkActivityService;
private DuibaLog logger = DuibaLog.getLogger();
private static Integer uid1 = 5080;
private static Integer uid2 = 5081;
private static Integer uid3 = 5086;
private static String betId;
private static String optionId1;
private static String optionId2;
@Test
public void 创建PK活动() throws Exception{
Response response = pkDevelopService.betEditor("21827","4","1","1","30");
Assert.assertEquals(response.jsonPath().getString("desc"),"成功","创建组件化pk活动失败");
response = pkService.getBetList(uid1);
response.print();
int i= 30;
while(i>0&&(response.jsonPath().getString("data.unbetList").equals("[]"))){
Thread.sleep(5000);
response = pkService.getBetList(uid1);
response.print();
i--;
}
betId = response.jsonPath().getString("data.unbetList[0].betConfig.id");
optionId1 = response.jsonPath().getString("data.unbetList[0].options[0].optionId");
optionId2 = response.jsonPath().getString("data.unbetList[0].options[1].optionId");
if(betId.equals(null)){
throw new Exception("楼层查询pk组件活动失败!");
}else {
logger.info("pk活动id 为:" + betId + ",投注id1为:" + optionId1 + ",投注id2为:" + optionId2);
}
}
@Test(dependsOnMethods = { "创建PK活动" })
public void 投注() throws Exception {
//查询数据库,投注前积分(抽奖扣积分流程校验)
Map<String,Object> mapuser1 = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid1);
Map<String,Object> mapuser2 = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid2);
Map<String,Object> mapuser3 = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid3);
String credits1 = String.valueOf(mapuser1.get("credits"));
String credits2 = String.valueOf(mapuser2.get("credits"));
String credits3 = String.valueOf(mapuser3.get("credits"));
logger.info("用户1投注前积分:"+credits1);
logger.info("用户2投注前积分:"+credits2);
logger.info("用户3投注前积分:"+credits3);
//扣去1积分
credits1 = String.valueOf(Integer.valueOf(credits1)-1);
credits2 = String.valueOf(Integer.valueOf(credits2)-1);
credits3 = String.valueOf(Integer.valueOf(credits3)-1);
Response res1 = pkService.doJoin(uid1,betId,optionId1);
Response res2 = pkService.doJoin(uid2,betId,optionId1);
Response res3 = pkService.doJoin(uid3,betId,optionId2);
//查询数据库,投注前积分(抽奖扣积分流程校验)
mapuser1 = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid1);
mapuser2 = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid2);
mapuser3 = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid3);
String credits4 = String.valueOf(mapuser1.get("credits"));
String credits5 = String.valueOf(mapuser2.get("credits"));
String credits6 = String.valueOf(mapuser3.get("credits"));
logger.info("用户1投注后积分:"+credits4);
logger.info("用户2投注后积分:"+credits5);
logger.info("用户3投注后积分:"+credits6);
Assert.assertEquals(credits4,credits1);
Assert.assertEquals(credits5,credits2);
Assert.assertEquals(credits6,credits3);
}
@Test(dependsOnMethods = { "投注" })
public void 开奖() throws Exception {
//查询数据库,开奖前积分
Map<String,Object> mapuser1 = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid1);
Map<String,Object> mapuser2 = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid2);
Map<String,Object> mapuser3 = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid3);
String credits1 = String.valueOf(mapuser1.get("credits"));
String credits2 = String.valueOf(mapuser2.get("credits"));
String credits3 = String.valueOf(mapuser3.get("credits"));
logger.info("用户1开奖前积分:"+credits1);
logger.info("用户2开奖前积分:"+credits2);
logger.info("用户3开奖前积分:"+credits3);
//增加积分:设置实际每人瓜分1积分
credits1 = String.valueOf(Integer.valueOf(credits1)+1);
credits2 = String.valueOf(Integer.valueOf(credits2)+1);
//修改开奖时间
this.modifyOpenPrizeTime(betId,60);
//调用开奖接口
Response doDrowRresponse = pkActivityService.doDraw();
Assert.assertEquals(doDrowRresponse.jsonPath().getString("success"),"true","开奖结果校验失败");
Assert.assertEquals(doDrowRresponse.jsonPath().getString("data"),"开奖中。。。","开奖messag校验失败");
Thread.sleep(8000);
//查询数据库,开奖后积分
mapuser1 = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid1);
mapuser2 = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid2);
mapuser3 = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid3);
String credits4 = String.valueOf(mapuser1.get("credits"));
String credits5 = String.valueOf(mapuser2.get("credits"));
String credits6 = String.valueOf(mapuser3.get("credits"));
logger.info("用户1开奖后积分:"+credits4);
logger.info("用户2开奖后积分:"+credits5);
logger.info("用户3开奖后积分:"+credits6);
Assert.assertEquals(credits4,credits1);
Assert.assertEquals(credits5,credits2);
Assert.assertEquals(credits6,credits3);
logger.info("投注者瓜分金额校验正确");
//校验点
//1、pk活动表配置的状态更新为4;2、订单表的addCredits字段为瓜分的红包值;3、先押注 的选项为胜方,胜负的额押注人数>负方的押注人数
Map<String,Object> betConfig = jdbc.findSimpleResult("select * from act_com_conf.tb_bet_config where id = ?",betId);
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",betId);
Assert.assertEquals(betGroupRelation.get("config_status").toString(),"4","pk关系表开奖状态更新失败");
logger.info("pk活动配置表状态更新为:"+betConfig.get("config_status").toString()+",pk关系表活动状态更新为:"+betGroupRelation.get("config_status").toString());
Map<String,Object> user01_order = jdbc.findSimpleResult("select * from activity_order_con.tb_trade_center_activity_order_0723 where consumer_id = '100112083' and duiba_activity_id = ?\n",betId);
Assert.assertEquals(user01_order.get("add_credits").toString(),"1","开奖后发奖值校验失败");
Map<String,Object> user02_order = jdbc.findSimpleResult("select * from activity_order_con.tb_trade_center_activity_order_0724 where consumer_id = '100112084' and duiba_activity_id = ?\n",betId);
Assert.assertEquals(user02_order.get("add_credits").toString(),"","开奖后发奖值校验失败");
logger.info("用户01获取的积分值为:"+user01_order.get("add_credits").toString()+",用户03获取的积分值为:"+user02_order.get("add_credits").toString());
Map<String,Object> bet1Result = jdbc.findSimpleResult("select * from bet_activity.tb_bet_result where bet_id = ? and option_id = ?\n",betId,optionId1);
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 = ?\n",betId,optionId2);
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());
}
@Test(dependsOnMethods = { "开奖" })
public void 出奖弹层校验() throws Exception {
Response response = pkService.popup(uid1);
response.prettyPrint();
Assert.assertEquals(response.jsonPath().getString("data.prizeList[0].totalBonus"),"1","中奖弹窗积分校验失败");
Assert.assertEquals(response.jsonPath().getString("data.prizeList[0].bonusType"),"4","中奖弹窗类型校验失败");
Assert.assertEquals(response.jsonPath().getString("data.show"),"true","展示弹窗校验失败");
Response response2 = pkService.popup(uid3);
response.prettyPrint();
Assert.assertEquals(response2.jsonPath().getString("data.prizeList"),null,"中奖弹窗积分校验失败");
Assert.assertEquals(response2.jsonPath().getString("data.show"),"false","展示弹窗校验失败");
}
@Test(dependsOnMethods = { "出奖弹层校验" })
public void 战绩页校验() throws Exception {
Response response = pkService.list(uid1);
response.prettyPrint();
Assert.assertEquals(response.jsonPath().getString("data.list[0].userWin"),"true","中奖记录校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].betConfig.id"),betId,"活动id校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].betConfig.shareExp"),"30","活动瓜分金额校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].betConfig.configStatus"),"4","活动状态校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].betConfig.creditsValue"),"1.00","活动消耗校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].betConfig.betType"),"1","活动押注类型校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].betConfig.bonusType"),"4","活动瓜分类型校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].options[0].betId"),betId,"活动id校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].options[0].resultStatus"),"4","活动选项结果状态校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].options[0].optionId"),optionId1,"活动投注id1校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].options[0].rank"),"1","活动投注结果校验失败");
// Assert.assertEquals(response.jsonPath().getString("data.list[0].options[0].betTimes"),"4","活动投注人数校验失败");
// Assert.assertEquals(response.jsonPath().getString("data.list[0].options[0].scale"),"66.7","活动投注人数比例校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].options[1].betId"),betId,"活动id校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].options[1].resultStatus"),"4","活动选项结果状态校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].options[1].optionId"),optionId2,"活动投注id1校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].options[1].rank"),"2","活动投注结果校验失败");
// Assert.assertEquals(response.jsonPath().getString("data.list[0].options[1].betTimes"),"2","活动投注人数校验失败");
// Assert.assertEquals(response.jsonPath().getString("data.list[0].options[1].scale"),"33.3","活动投注人数比例校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].record.betId"),betId,"活动id校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].record.optionId"),optionId1,"活动id校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].record.bonus"),"0.01","活动id校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].record.exchangeStatus"),"1","兑换状态校验失败");
response = pkService.list(uid3);
response.prettyPrint();
Assert.assertEquals(response.jsonPath().getString("data.list[0].userWin"),"false","中奖记录校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].record.betId"),betId,"活动id校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].record.optionId"),optionId2,"活动id校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].record.bonus"),"0.0","活动id校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].record.exchangeStatus"),"0","兑换状态校验失败");
}
@AfterClass
public void afterclass() {
try {
Boolean result1 = jdbc.update("delete from act_com_conf.tb_bet_option where bet_id = ?",betId);
Boolean result4 = jdbc.update("delete from act_record.tb_bet_record where bet_id = ?",betId);
Boolean result5 = jdbc.update("delete from bet_activity.tb_bet_result where bet_id = ?",betId);
Boolean result2 = jdbc.update("delete from act_com_conf.tb_bet_group_relation where bet_id = ?",betId);
Boolean result3 = jdbc.update("delete from act_com_conf.tb_bet_config where id = ?",betId);
} catch (SQLException e) {
e.printStackTrace();
} catch (Exception e){
e.printStackTrace();
}
}
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);
}
}
\ No newline at end of file
/**
* Copyright (C), 2015-2018
* FileName: 瓜分积分测试_AccessTest
* Author: zhaoran
* Date: 2018/12/10 19:45
* Description: "appId": 21771
*/
package http.cases.PkMoudleTest;
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.hd.PkDevelopService;
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.Test;
import java.sql.SQLException;
import java.util.List;
import java.util.Map;
public class 瓜分积分_实际瓜分_AccessTest extends DuibaTestBase {
@Autowired
PkDevelopService pkDevelopService;
@Autowired
PkService pkService;
@Autowired
PkActivityService pkActivityService;
private DuibaLog logger = DuibaLog.getLogger();
private static Integer uid1 = 5029;
private static Integer uid2 = 5058;
private static Integer uid3 = 5059;
private static String betId;
private static String optionId1;
private static String optionId2;
@Test
public void 创建PK活动() throws Exception{
Response response = pkDevelopService.betEditor("21771","4",null,"1","30");
Assert.assertEquals(response.jsonPath().getString("desc"),"成功","创建组件化pk活动失败");
response = pkService.getBetList(uid1);
response.print();
int i= 30;
while(i>0&&(response.jsonPath().getString("data.unbetList").equals("[]"))){
Thread.sleep(5000);
response = pkService.getBetList(uid1);
response.print();
i--;
}
betId = response.jsonPath().getString("data.unbetList[0].betConfig.id");
optionId1 = response.jsonPath().getString("data.unbetList[0].options[0].optionId");
optionId2 = response.jsonPath().getString("data.unbetList[0].options[1].optionId");
if(betId.equals(null)){
throw new Exception("楼层查询pk组件活动失败!");
}else {
logger.info("pk活动id 为:" + betId + ",投注id1为:" + optionId1 + ",投注id2为:" + optionId2);
}
}
@Test(dependsOnMethods = { "创建PK活动" })
public void 投注() throws Exception {
//查询数据库,投注前积分(抽奖扣积分流程校验)
Map<String,Object> mapuser1 = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid1);
Map<String,Object> mapuser2 = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid2);
Map<String,Object> mapuser3 = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid3);
String credits1 = String.valueOf(mapuser1.get("credits"));
String credits2 = String.valueOf(mapuser2.get("credits"));
String credits3 = String.valueOf(mapuser3.get("credits"));
logger.info("用户1投注前积分:"+credits1);
logger.info("用户2投注前积分:"+credits2);
logger.info("用户3投注前积分:"+credits3);
//扣去1积分
credits1 = String.valueOf(Integer.valueOf(credits1)-1);
credits2 = String.valueOf(Integer.valueOf(credits2)-1);
credits3 = String.valueOf(Integer.valueOf(credits3)-1);
Response res1 = pkService.doJoin(uid1,betId,optionId1);
Response res2 = pkService.doJoin(uid2,betId,optionId1);
Response res3 = pkService.doJoin(uid3,betId,optionId2);
//查询数据库,投注前积分(抽奖扣积分流程校验)
mapuser1 = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid1);
mapuser2 = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid2);
mapuser3 = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid3);
String credits4 = String.valueOf(mapuser1.get("credits"));
String credits5 = String.valueOf(mapuser2.get("credits"));
String credits6 = String.valueOf(mapuser3.get("credits"));
logger.info("用户1投注后积分:"+credits4);
logger.info("用户2投注后积分:"+credits5);
logger.info("用户3投注后积分:"+credits6);
Assert.assertEquals(credits4,credits1);
Assert.assertEquals(credits5,credits2);
Assert.assertEquals(credits6,credits3);
}
@Test(dependsOnMethods = { "投注" })
public void 开奖() throws Exception {
//查询数据库,开奖前积分
Map<String,Object> mapuser1 = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid1);
Map<String,Object> mapuser2 = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid2);
Map<String,Object> mapuser3 = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid3);
String credits1 = String.valueOf(mapuser1.get("credits"));
String credits2 = String.valueOf(mapuser2.get("credits"));
String credits3 = String.valueOf(mapuser3.get("credits"));
logger.info("用户1开奖前积分:"+credits1);
logger.info("用户2开奖前积分:"+credits2);
logger.info("用户3开奖前积分:"+credits3);
//增加积分: 30/(2+2)
credits1 = String.valueOf(Integer.valueOf(credits1)+7);
credits2 = String.valueOf(Integer.valueOf(credits2)+7);
//修改开奖时间
this.modifyOpenPrizeTime(betId,60);
//调用开奖接口
Response doDrowRresponse = pkActivityService.doDraw();
Assert.assertEquals(doDrowRresponse.jsonPath().getString("success"),"true","开奖结果校验失败");
Assert.assertEquals(doDrowRresponse.jsonPath().getString("data"),"开奖中。。。","开奖messag校验失败");
Thread.sleep(8000);
//查询数据库,开奖后积分
mapuser1 = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid1);
mapuser2 = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid2);
mapuser3 = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid3);
String credits4 = String.valueOf(mapuser1.get("credits"));
String credits5 = String.valueOf(mapuser2.get("credits"));
String credits6 = String.valueOf(mapuser3.get("credits"));
logger.info("用户1开奖后积分:"+credits4);
logger.info("用户2开奖后积分:"+credits5);
logger.info("用户3开奖后积分:"+credits6);
Assert.assertEquals(credits4,credits1);
Assert.assertEquals(credits5,credits2);
Assert.assertEquals(credits6,credits3);
logger.info("投注者瓜分金额校验正确");
//校验点
//1、pk活动表配置的状态更新为4;2、订单表的addCredits字段为瓜分的红包值;3、先押注 的选项为胜方,胜负的额押注人数>负方的押注人数
Map<String,Object> betConfig = jdbc.findSimpleResult("select * from act_com_conf.tb_bet_config where id = ?",betId);
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",betId);
Assert.assertEquals(betGroupRelation.get("config_status").toString(),"4","pk关系表开奖状态更新失败");
logger.info("pk活动配置表状态更新为:"+betConfig.get("config_status").toString()+",pk关系表活动状态更新为:"+betGroupRelation.get("config_status").toString());
Map<String,Object> user01_order = jdbc.findSimpleResult("select * from activity_order_con.tb_trade_center_activity_order_0661 where consumer_id = '100112021' and duiba_activity_id = ?\n",betId);
Assert.assertEquals(user01_order.get("add_credits").toString(),"7","开奖后发奖值校验失败");
Map<String,Object> user02_order = jdbc.findSimpleResult("select * from activity_order_con.tb_trade_center_activity_order_0691 where consumer_id = '100112051' and duiba_activity_id = ?\n",betId);
Assert.assertEquals(user02_order.get("add_credits").toString(),"","开奖后发奖值校验失败");
logger.info("用户01获取的积分值为:"+user01_order.get("add_credits").toString()+",用户03获取的积分值为:"+user02_order.get("add_credits").toString());
Map<String,Object> bet1Result = jdbc.findSimpleResult("select * from bet_activity.tb_bet_result where bet_id = ? and option_id = ?\n",betId,optionId1);
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 = ?\n",betId,optionId2);
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());
}
@Test(dependsOnMethods = { "开奖" })
public void 出奖弹层校验() throws Exception {
Response response = pkService.popup(uid1);
response.prettyPrint();
Assert.assertEquals(response.jsonPath().getString("data.prizeList[0].totalBonus"),"7","中奖弹窗积分校验失败");
Assert.assertEquals(response.jsonPath().getString("data.prizeList[0].bonusType"),"4","中奖弹窗类型校验失败");
Assert.assertEquals(response.jsonPath().getString("data.show"),"true","展示弹窗校验失败");
Response response2 = pkService.popup(uid3);
response.prettyPrint();
Assert.assertEquals(response2.jsonPath().getString("data.prizeList"),null,"中奖弹窗积分校验失败");
Assert.assertEquals(response2.jsonPath().getString("data.show"),"false","展示弹窗校验失败");
}
@Test(dependsOnMethods = { "出奖弹层校验" })
public void 战绩页校验() throws Exception {
Response response = pkService.list(uid1);
response.prettyPrint();
Assert.assertEquals(response.jsonPath().getString("data.list[0].userWin"),"true","中奖记录校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].betConfig.id"),betId,"活动id校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].betConfig.shareExp"),"30","活动瓜分金额校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].betConfig.configStatus"),"4","活动状态校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].betConfig.creditsValue"),"1.00","活动消耗校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].betConfig.betType"),"1","活动押注类型校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].betConfig.bonusType"),"4","活动瓜分类型校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].options[0].betId"),betId,"活动id校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].options[0].resultStatus"),"4","活动选项结果状态校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].options[0].optionId"),optionId1,"活动投注id1校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].options[0].rank"),"1","活动投注结果校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].options[0].betTimes"),"4","活动投注人数校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].options[0].scale"),"66.7","活动投注人数比例校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].options[1].betId"),betId,"活动id校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].options[1].resultStatus"),"4","活动选项结果状态校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].options[1].optionId"),optionId2,"活动投注id1校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].options[1].rank"),"2","活动投注结果校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].options[1].betTimes"),"2","活动投注人数校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].options[1].scale"),"33.3","活动投注人数比例校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].record.betId"),betId,"活动id校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].record.optionId"),optionId1,"活动id校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].record.bonus"),"0.07","活动id校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].record.exchangeStatus"),"1","兑换状态校验失败");
response = pkService.list(uid3);
response.prettyPrint();
Assert.assertEquals(response.jsonPath().getString("data.list[0].userWin"),"false","中奖记录校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].record.betId"),betId,"活动id校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].record.optionId"),optionId2,"活动id校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].record.bonus"),"0.0","活动id校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].record.exchangeStatus"),"0","兑换状态校验失败");
}
@AfterClass
public void afterclass() {
try {
Boolean result1 = jdbc.update("delete from act_com_conf.tb_bet_option where bet_id = ?",betId);
Boolean result4 = jdbc.update("delete from act_record.tb_bet_record where bet_id = ?",betId);
Boolean result5 = jdbc.update("delete from bet_activity.tb_bet_result where bet_id = ?",betId);
Boolean result2 = jdbc.update("delete from act_com_conf.tb_bet_group_relation where bet_id = ?",betId);
Boolean result3 = jdbc.update("delete from act_com_conf.tb_bet_config where id = ?",betId);
} catch (SQLException e) {
e.printStackTrace();
} catch (Exception e){
e.printStackTrace();
}
}
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);
}
}
\ No newline at end of file
/**
* Copyright (C), 2015-2018
* FileName: 瓜分积分测试_AccessTest
* Author: zhaoran
* Date: 2018/12/10 19:45
* Description:
*/
package http.cases.PkMoudleTest;
import base.DuibaLog;
import base.DuibaTestBase;
import com.alibaba.fastjson.JSONObject;
import http.service.Activity.PkService;
import http.service.Manager.PkActivityService;
import http.service.hd.PkDevelopService;
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.Test;
import java.sql.SQLException;
import java.util.Map;
public class 瓜分积分_实际瓜分_主胜方_AccessTest extends DuibaTestBase {
@Autowired
PkDevelopService pkDevelopService;
@Autowired
PkService pkService;
@Autowired
PkActivityService pkActivityService;
private DuibaLog logger = DuibaLog.getLogger();
private static Integer uid1 = 5171;
private static Integer uid2 = 5172;
private static Integer uid3 = 5173;
private static String betId;
private static String optionId1;
private static String optionId2;
@Test
public void 创建PK活动() throws Exception{
Response response = pkDevelopService.betEditor_right("18157163293","21832","4",null,"1","30","false","true");
Assert.assertEquals(response.jsonPath().getString("desc"),"成功","创建组件化pk活动失败");
response = pkService.getBetList(uid1);
response.print();
int i= 30;
while(i>0&&(response.jsonPath().getString("data.unbetList").equals("[]"))){
Thread.sleep(5000);
response = pkService.getBetList(uid1);
response.print();
i--;
}
betId = response.jsonPath().getString("data.unbetList[0].betConfig.id");
optionId1 = response.jsonPath().getString("data.unbetList[0].options[0].optionId");
optionId2 = response.jsonPath().getString("data.unbetList[0].options[1].optionId");
if(betId.equals(null)){
throw new Exception("楼层查询pk组件活动失败!");
}else {
logger.info("pk活动id 为:" + betId + ",投注id1为:" + optionId1 + ",投注id2为:" + optionId2);
}
}
@Test(dependsOnMethods = { "创建PK活动" })
public void 投注() throws Exception {
//查询数据库,投注前积分(抽奖扣积分流程校验)
Map<String,Object> mapuser1 = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid1);
Map<String,Object> mapuser2 = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid2);
Map<String,Object> mapuser3 = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid3);
String credits1 = String.valueOf(mapuser1.get("credits"));
String credits2 = String.valueOf(mapuser2.get("credits"));
String credits3 = String.valueOf(mapuser3.get("credits"));
logger.info("用户1投注前积分:"+credits1);
logger.info("用户2投注前积分:"+credits2);
logger.info("用户3投注前积分:"+credits3);
//扣去1积分
credits1 = String.valueOf(Integer.valueOf(credits1)-1);
credits2 = String.valueOf(Integer.valueOf(credits2)-1);
credits3 = String.valueOf(Integer.valueOf(credits3)-1);
this.stake(uid1,betId,optionId1);
this.stake(uid2,betId,optionId1);
this.stake(uid3,betId,optionId2);
//查询数据库,投注前积分(抽奖扣积分流程校验)
mapuser1 = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid1);
mapuser2 = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid2);
mapuser3 = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid3);
String credits4 = String.valueOf(mapuser1.get("credits"));
String credits5 = String.valueOf(mapuser2.get("credits"));
String credits6 = String.valueOf(mapuser3.get("credits"));
logger.info("用户1投注后积分:"+credits4);
logger.info("用户2投注后积分:"+credits5);
logger.info("用户3投注后积分:"+credits6);
Assert.assertEquals(credits4,credits1);
Assert.assertEquals(credits5,credits2);
Assert.assertEquals(credits6,credits3);
}
@Test(dependsOnMethods = { "投注" })
public void 开奖() throws Exception {
//查询数据库,开奖前积分
Map<String,Object> mapuser1 = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid1);
Map<String,Object> mapuser2 = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid2);
Map<String,Object> mapuser3 = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid3);
String credits1 = String.valueOf(mapuser1.get("credits"));
String credits2 = String.valueOf(mapuser2.get("credits"));
String credits3 = String.valueOf(mapuser3.get("credits"));
logger.info("用户1开奖前积分:"+credits1);
logger.info("用户2开奖前积分:"+credits2);
logger.info("用户3开奖前积分:"+credits3);
//增加积分: 30/(1+2)
credits3 = String.valueOf(Integer.valueOf(credits3)+6);
//修改开奖时间
this.modifyOpenPrizeTime(betId,60);
//调用开奖接口
Response doDrowRresponse = pkActivityService.doDraw();
Assert.assertEquals(doDrowRresponse.jsonPath().getString("success"),"true","开奖结果校验失败");
Assert.assertEquals(doDrowRresponse.jsonPath().getString("data"),"开奖中。。。","开奖messag校验失败");
Thread.sleep(8000);
//查询数据库,开奖后积分
mapuser1 = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid1);
mapuser2 = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid2);
mapuser3 = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid3);
String credits4 = String.valueOf(mapuser1.get("credits"));
String credits5 = String.valueOf(mapuser2.get("credits"));
String credits6 = String.valueOf(mapuser3.get("credits"));
logger.info("用户1开奖后积分:"+credits4);
logger.info("用户2开奖后积分:"+credits5);
logger.info("用户3开奖后积分:"+credits6);
Assert.assertEquals(credits4,credits1);
Assert.assertEquals(credits5,credits2);
Assert.assertEquals(credits6,credits3);
logger.info("投注者瓜分金额校验正确");
//校验点
//1、pk活动表配置的状态更新为4;2、订单表的addCredits字段为瓜分的红包值;3、先押注 的选项为胜方,胜负的额押注人数>负方的押注人数
Map<String,Object> betConfig = jdbc.findSimpleResult("select * from act_com_conf.tb_bet_config where id = ?",betId);
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",betId);
Assert.assertEquals(betGroupRelation.get("config_status").toString(),"4","pk关系表开奖状态更新失败");
logger.info("pk活动配置表状态更新为:"+betConfig.get("config_status").toString()+",pk关系表活动状态更新为:"+betGroupRelation.get("config_status").toString());
Map<String,Object> user01_order = jdbc.findSimpleResult("select * from activity_order_con.tb_trade_center_activity_order_0614 where consumer_id = '100114022' and duiba_activity_id = ?\n",betId);
Assert.assertEquals(user01_order.get("add_credits").toString(),"6","开奖后发奖值校验失败");
Map<String,Object> user02_order = jdbc.findSimpleResult("select * from activity_order_con.tb_trade_center_activity_order_0623 where consumer_id = '100114031' and duiba_activity_id = ?\n",betId);
Assert.assertEquals(user02_order.get("add_credits").toString(),"","开奖后发奖值校验失败");
logger.info("用户01获取的积分值为:"+user01_order.get("add_credits").toString()+",用户03获取的积分值为:"+user02_order.get("add_credits").toString());
Map<String,Object> bet1Result = jdbc.findSimpleResult("select * from bet_activity.tb_bet_result where bet_id = ? and option_id = ?\n",betId,optionId1);
Assert.assertEquals(bet1Result.get("rank").toString(),"2","开始押注的选项获胜校验失败");
Map<String,Object> bet2Result = jdbc.findSimpleResult("select * from bet_activity.tb_bet_result where bet_id = ? and option_id = ?\n",betId,optionId2);
Assert.assertEquals(bet2Result.get("rank").toString(),"1","开始押注的选项获胜校验失败");
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());
}
@Test(dependsOnMethods = { "开奖" })
public void 出奖弹层校验() throws Exception {
Response response = pkService.popup(uid3);
response.prettyPrint();
Assert.assertEquals(response.jsonPath().getString("data.prizeList[0].totalBonus"),"6","中奖弹窗积分校验失败");
Assert.assertEquals(response.jsonPath().getString("data.prizeList[0].bonusType"),"4","中奖弹窗类型校验失败");
Assert.assertEquals(response.jsonPath().getString("data.show"),"true","展示弹窗校验失败");
Response response2 = pkService.popup(uid1);
response.prettyPrint();
Assert.assertEquals(response2.jsonPath().getString("data.prizeList"),null,"中奖弹窗积分校验失败");
Assert.assertEquals(response2.jsonPath().getString("data.show"),"false","展示弹窗校验失败");
}
@Test(dependsOnMethods = { "出奖弹层校验" })
public void 战绩页校验() throws Exception {
Response response = pkService.list(uid3);
response.prettyPrint();
Assert.assertEquals(response.jsonPath().getString("data.list[0].userWin"),"true","中奖记录校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].betConfig.id"),betId,"活动id校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].betConfig.shareExp"),"30","活动瓜分金额校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].betConfig.configStatus"),"4","活动状态校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].betConfig.creditsValue"),"1.00","活动消耗校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].betConfig.betType"),"1","活动押注类型校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].betConfig.bonusType"),"4","活动瓜分类型校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].options[0].betId"),betId,"活动id校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].options[0].resultStatus"),"4","活动选项结果状态校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].options[0].optionId"),optionId1,"活动投注id1校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].options[0].rank"),"2","活动投注结果校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].options[0].betTimes"),"3","活动投注人数校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].options[0].scale"),"37.5","活动投注人数比例校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].options[1].betId"),betId,"活动id校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].options[1].resultStatus"),"4","活动选项结果状态校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].options[1].optionId"),optionId2,"活动投注id1校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].options[1].rank"),"1","活动投注结果校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].options[1].betTimes"),"5","活动投注人数校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].options[1].scale"),"62.5","活动投注人数比例校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].record.betId"),betId,"活动id校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].record.optionId"),optionId2,"活动id校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].record.bonus"),"0.06","活动id校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].record.exchangeStatus"),"1","兑换状态校验失败");
response = pkService.list(uid1);
response.prettyPrint();
Assert.assertEquals(response.jsonPath().getString("data.list[0].userWin"),"false","中奖记录校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].record.betId"),betId,"活动id校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].record.optionId"),optionId1,"活动id校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].record.bonus"),"0.0","活动id校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].record.exchangeStatus"),"0","兑换状态校验失败");
}
@AfterClass
public void afterclass() {
try {
Boolean result1 = jdbc.update("delete from act_com_conf.tb_bet_option where bet_id = ?",betId);
Boolean result4 = jdbc.update("delete from act_record.tb_bet_record where bet_id = ?",betId);
Boolean result5 = jdbc.update("delete from bet_activity.tb_bet_result where bet_id = ?",betId);
Boolean result2 = jdbc.update("delete from act_com_conf.tb_bet_group_relation where bet_id = ?",betId);
Boolean result3 = jdbc.update("delete from act_com_conf.tb_bet_config where id = ?",betId);
} catch (SQLException e) {
e.printStackTrace();
} catch (Exception e){
e.printStackTrace();
}
}
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 stake(Integer uid,String betId,String optionId) throws Exception {
Response doJoinResponse = pkService.doJoin(uid, betId, optionId);
doJoinResponse.prettyPrint();
Assert.assertEquals(doJoinResponse.jsonPath().getString("code"), "200", "校验押注失败");
String orderId = doJoinResponse.jsonPath().getString("data");
Response statusResponse = pkService.getOrderStatus(uid, orderId);
statusResponse.prettyPrint();
String consumerStatus = statusResponse.jsonPath().getString("data.consumeStatus");
int i = 8;
while (i > 0 & consumerStatus.equals("1")) {
Thread.sleep(1000);
statusResponse = pkService.getOrderStatus(uid, orderId);
consumerStatus = statusResponse.jsonPath().getString("data.consumeStatus");
}
logger.info("用户:"+uid+"投注成功!");
}
}
\ No newline at end of file
/**
* Copyright (C), 2015-2018
* FileName: 瓜分积分测试_AccessTest
* Author: zhaoran
* Date: 2018/12/10 19:45
* Description:
*/
package http.cases.PkMoudleTest;
import base.DuibaLog;
import base.DuibaTestBase;
import com.alibaba.fastjson.JSONObject;
import http.service.Activity.PkService;
import http.service.Manager.PkActivityService;
import http.service.hd.PkDevelopService;
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.Test;
import java.math.BigDecimal;
import java.sql.SQLException;
import java.text.DecimalFormat;
import java.util.Map;
public class 瓜分红包_作弊瓜分_AccessTest extends DuibaTestBase {
@Autowired
PkDevelopService pkDevelopService;
@Autowired
PkService pkService;
@Autowired
PkActivityService pkActivityService;
private DuibaLog logger = DuibaLog.getLogger();
private static Integer uid1 = 5144;
private static Integer uid2 = 5145;
private static Integer uid3 = 5146;
private static String betId;
private static String optionId1;
private static String optionId2;
@Test
public void 创建PK活动() throws Exception{
Response response = pkDevelopService.betEditor("21829","2","0.01","0","10");
Assert.assertEquals(response.jsonPath().getString("desc"),"成功","创建组件化pk_分红包活动失败");
response = pkService.getBetList(uid1);
response.print();
int i= 30;
while(i>0&&(response.jsonPath().getString("data.unbetList").equals("[]"))){
Thread.sleep(5000);
response = pkService.getBetList(uid1);
response.print();
i--;
}
betId = response.jsonPath().getString("data.unbetList[0].betConfig.id");
optionId1 = response.jsonPath().getString("data.unbetList[0].options[0].optionId");
optionId2 = response.jsonPath().getString("data.unbetList[0].options[1].optionId");
if(betId.equals(null)){
throw new Exception("楼层查询pk组件活动失败!");
}else {
logger.info("pk活动id 为:" + betId + ",投注id1为:" + optionId1 + ",投注id2为:" + optionId2);
}
}
@Test(dependsOnMethods = { "创建PK活动" })
public void 投注() throws Exception {
//查询数据库,投注前积分(抽奖扣积分流程校验)
Map<String,Object> mapuser1 = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid1);
Map<String,Object> mapuser2 = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid2);
Map<String,Object> mapuser3 = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid3);
String credits1 = String.valueOf(mapuser1.get("credits"));
String credits2 = String.valueOf(mapuser2.get("credits"));
String credits3 = String.valueOf(mapuser3.get("credits"));
logger.info("用户1投注前积分:"+credits1);
logger.info("用户2投注前积分:"+credits2);
logger.info("用户3投注前积分:"+credits3);
Response res1 = pkService.doJoin(uid1,betId,optionId1);
Response res2 = pkService.doJoin(uid2,betId,optionId1);
Response res3 = pkService.doJoin(uid3,betId,optionId2);
//查询数据库,投注后积分(抽奖扣积分流程校验)
mapuser1 = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid1);
mapuser2 = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid2);
mapuser3 = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid3);
String credits4 = String.valueOf(mapuser1.get("credits"));
String credits5 = String.valueOf(mapuser2.get("credits"));
String credits6 = String.valueOf(mapuser3.get("credits"));
logger.info("用户1投注后积分:"+credits4);
logger.info("用户2投注后积分:"+credits5);
logger.info("用户3投注后积分:"+credits6);
Assert.assertEquals(credits4,credits1);
Assert.assertEquals(credits5,credits2);
Assert.assertEquals(credits6,credits3);
}
@Test(dependsOnMethods = { "投注" })
public void 开奖() throws Exception {
//查询数据库,开奖前红包余额
Map<String,Object> user01_account1 = jdbc.findSimpleResult("select * from consumer_accounts.tb_consumer_account_0830 where consumer_id = '100112190' and account_type = '6'\n");
String use1_Acc1 = user01_account1.get("balance_amount").toString();
Map<String,Object> user02_account1 = jdbc.findSimpleResult("select * from consumer_accounts.tb_consumer_account_0838 where consumer_id = '100112198' and account_type = '6'\n");
String use2_Acc1 = user02_account1.get("balance_amount").toString();
Map<String,Object> user03_account1 = jdbc.findSimpleResult("select * from consumer_accounts.tb_consumer_account_0839 where consumer_id = '100112199' and account_type = '6'\n");
String use3_Acc1 = user03_account1.get("balance_amount").toString();
logger.info("用户1开奖前红包余额:"+use1_Acc1);
logger.info("用户2开奖前红包余额:"+use2_Acc1);
logger.info("用户3开奖前红包余额:"+use3_Acc1);
//预期增加红包: 1
DecimalFormat decimalFormat = new DecimalFormat("###################.###########");
use1_Acc1 = decimalFormat.format(this.sub(Double.valueOf(use1_Acc1),1));
use2_Acc1 = decimalFormat.format(this.sub(Double.valueOf(use2_Acc1),1));
//修改开奖时间
this.modifyOpenPrizeTime(betId,60);
//调用开奖接口
Response doDrowRresponse = pkActivityService.doDraw();
Assert.assertEquals(doDrowRresponse.jsonPath().getString("success"),"true","开奖结果校验失败");
Assert.assertEquals(doDrowRresponse.jsonPath().getString("data"),"开奖中。。。","开奖messag校验失败");
Thread.sleep(8000);
//查询数据库,开奖后红包余额
user01_account1 = jdbc.findSimpleResult("select * from consumer_accounts.tb_consumer_account_0830 where consumer_id = '100112190' and account_type = '6'\n");
String use1_Acc2 = user01_account1.get("balance_amount").toString();
user02_account1 = jdbc.findSimpleResult("select * from consumer_accounts.tb_consumer_account_0838 where consumer_id = '100112198' and account_type = '6'\n");
String use2_Acc2 = user02_account1.get("balance_amount").toString();
user03_account1 = jdbc.findSimpleResult("select * from consumer_accounts.tb_consumer_account_0839 where consumer_id = '100112199' and account_type = '6'\n");
String use3_Acc2 = user03_account1.get("balance_amount").toString();
logger.info("用户1开奖后积分:"+use1_Acc2);
logger.info("用户2开奖后积分:"+use2_Acc2);
logger.info("用户3开奖后积分:"+use3_Acc2);
Assert.assertEquals(use1_Acc2,use1_Acc1);
Assert.assertEquals(use2_Acc2,use2_Acc1);
Assert.assertEquals(use3_Acc2,use3_Acc1);
logger.info("投注者瓜分金额校验正确");
//校验点
//1、pk活动表配置的状态更新为4;2、订单表的addCredits字段为瓜分的红包值;3、先押注 的选项为胜方,胜负的额押注人数>负方的押注人数
Map<String,Object> betConfig = jdbc.findSimpleResult("select * from act_com_conf.tb_bet_config where id = ?",betId);
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",betId);
Assert.assertEquals(betGroupRelation.get("config_status").toString(),"4","pk关系表开奖状态更新失败");
logger.info("pk活动配置表状态更新为:"+betConfig.get("config_status").toString()+",pk关系表活动状态更新为:"+betGroupRelation.get("config_status").toString());
Map<String,Object> user01_order = jdbc.findSimpleResult("select * from activity_order_con.tb_trade_center_activity_order_0830 where consumer_id = '100112190' and duiba_activity_id = ?\n",betId);
Assert.assertEquals(user01_order.get("add_credits").toString(),"1","开奖后发奖值校验失败");
Map<String,Object> user02_order = jdbc.findSimpleResult("select * from activity_order_con.tb_trade_center_activity_order_0839 where consumer_id = '100112199' and duiba_activity_id = ?\n",betId);
Assert.assertEquals(user02_order.get("add_credits").toString(),"","开奖后发奖值校验失败");
logger.info("用户01获取的积分值为:"+user01_order.get("add_credits").toString()+",用户03获取的积分值为:"+user02_order.get("add_credits").toString());
Map<String,Object> bet1Result = jdbc.findSimpleResult("select * from bet_activity.tb_bet_result where bet_id = ? and option_id = ?\n",betId,optionId1);
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 = ?\n",betId,optionId2);
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());
}
@Test(dependsOnMethods = { "开奖" })
public void 出奖弹层校验() throws Exception {
Response response = pkService.popup(uid1);
response.prettyPrint();
Assert.assertEquals(response.jsonPath().getString("data.prizeList[0].totalBonus"),"1","中奖弹窗积分校验失败");
Assert.assertEquals(response.jsonPath().getString("data.prizeList[0].bonusType"),"2","中奖弹窗类型校验失败");
Assert.assertEquals(response.jsonPath().getString("data.totalBonus"),"0.01","中奖弹窗积分校验失败");
Assert.assertEquals(response.jsonPath().getString("data.show"),"true","展示弹窗校验失败");
Response response2 = pkService.popup(uid3);
response.prettyPrint();
Assert.assertEquals(response2.jsonPath().getString("data.prizeList"),null,"中奖弹窗积分校验失败");
Assert.assertEquals(response2.jsonPath().getString("data.show"),"false","展示弹窗校验失败");
}
@Test(dependsOnMethods = { "出奖弹层校验" })
public void 战绩页校验() throws Exception {
Response response = pkService.list(uid1);
response.prettyPrint();
Assert.assertEquals(response.jsonPath().getString("data.list[0].userWin"),"true","中奖记录校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].betConfig.id"),betId,"活动id校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].betConfig.shareExp"),"10","活动瓜分金额校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].betConfig.configStatus"),"4","活动状态校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].betConfig.creditsValue"),"0","活动消耗校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].betConfig.betType"),"1","活动押注类型校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].betConfig.bonusType"),"2","活动瓜分类型校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].options[0].betId"),betId,"活动id校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].options[0].resultStatus"),"4","活动选项结果状态校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].options[0].optionId"),optionId1,"活动投注id1校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].options[0].rank"),"1","活动投注结果校验失败");
// Assert.assertEquals(response.jsonPath().getString("data.list[0].options[0].betTimes"),"544","活动投注人数校验失败");
// Assert.assertEquals(response.jsonPath().getString("data.list[0].options[0].scale"),"66.9","活动投注人数比例校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].options[1].betId"),betId,"活动id校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].options[1].resultStatus"),"4","活动选项结果状态校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].options[1].optionId"),optionId2,"活动投注id1校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].options[1].rank"),"2","活动投注结果校验失败");
// Assert.assertEquals(response.jsonPath().getString("data.list[0].options[1].betTimes"),"269","活动投注人数校验失败");
// Assert.assertEquals(response.jsonPath().getString("data.list[0].options[1].scale"),"33.1","活动投注人数比例校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].record.betId"),betId,"活动id校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].record.optionId"),optionId1,"活动id校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].record.bonus"),"0.01","活动id校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].record.exchangeStatus"),"2","兑换状态校验失败");
response = pkService.list(uid3);
response.prettyPrint();
Assert.assertEquals(response.jsonPath().getString("data.list[0].userWin"),"false","中奖记录校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].record.betId"),betId,"活动id校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].record.optionId"),optionId2,"活动id校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].record.bonus"),"0.0","活动id校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].record.exchangeStatus"),"0","兑换状态校验失败");
}
@AfterClass
public void afterclass() {
try {
Boolean result1 = jdbc.update("delete from act_com_conf.tb_bet_option where bet_id = ?",betId);
Boolean result4 = jdbc.update("delete from act_record.tb_bet_record where bet_id = ?",betId);
Boolean result5 = jdbc.update("delete from bet_activity.tb_bet_result where bet_id = ?",betId);
Boolean result2 = jdbc.update("delete from act_com_conf.tb_bet_group_relation where bet_id = ?",betId);
Boolean result3 = jdbc.update("delete from act_com_conf.tb_bet_config where id = ?",betId);
} catch (SQLException e) {
e.printStackTrace();
} catch (Exception e){
e.printStackTrace();
}
}
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);
}
/**
* 提供精确的加法运算。
* @param v1
* @param v2
* @return 两个参数的和
*/
public static double sub(double v1,double v2){
BigDecimal b1 = new BigDecimal(Double.toString(v1));
BigDecimal b2 = new BigDecimal(Double.toString(v2));
return b1.add(b2).doubleValue();
}
}
\ No newline at end of file
/**
* Copyright (C), 2015-2018
* FileName: 瓜分积分测试_AccessTest
* Author: zhaoran
* Date: 2018/12/10 19:45
* Description:
*/
package http.cases.PkMoudleTest;
import base.DuibaLog;
import base.DuibaTestBase;
import com.alibaba.fastjson.JSONObject;
import http.service.Activity.PkService;
import http.service.Manager.PkActivityService;
import http.service.hd.PkDevelopService;
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.Test;
import java.math.BigDecimal;
import java.sql.SQLException;
import java.text.DecimalFormat;
import java.util.Map;
public class 瓜分红包_实际瓜分_AccessTest extends DuibaTestBase {
@Autowired
PkDevelopService pkDevelopService;
@Autowired
PkService pkService;
@Autowired
PkActivityService pkActivityService;
private DuibaLog logger = DuibaLog.getLogger();
private static Integer uid1 = 5088;
private static Integer uid2 = 5089;
private static Integer uid3 = 5090;
private static String betId;
private static String optionId1;
private static String optionId2;
@Test
public void 创建PK活动() throws Exception{
Response response = pkDevelopService.betEditor("21828","2",null,"1","30");
Assert.assertEquals(response.jsonPath().getString("desc"),"成功","创建组件化pk_分红包活动失败");
response = pkService.getBetList(uid1);
response.print();
int i= 30;
while(i>0&&(response.jsonPath().getString("data.unbetList").equals("[]"))){
Thread.sleep(5000);
response = pkService.getBetList(uid1);
response.print();
i--;
}
betId = response.jsonPath().getString("data.unbetList[0].betConfig.id");
optionId1 = response.jsonPath().getString("data.unbetList[0].options[0].optionId");
optionId2 = response.jsonPath().getString("data.unbetList[0].options[1].optionId");
if(betId.equals(null)){
throw new Exception("楼层查询pk组件活动失败!");
}else {
logger.info("pk活动id 为:" + betId + ",投注id1为:" + optionId1 + ",投注id2为:" + optionId2);
}
}
@Test(dependsOnMethods = { "创建PK活动" })
public void 投注() throws Exception {
//查询数据库,投注前积分(抽奖扣积分流程校验)
Map<String,Object> mapuser1 = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid1);
Map<String,Object> mapuser2 = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid2);
Map<String,Object> mapuser3 = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid3);
String credits1 = String.valueOf(mapuser1.get("credits"));
String credits2 = String.valueOf(mapuser2.get("credits"));
String credits3 = String.valueOf(mapuser3.get("credits"));
logger.info("用户1投注前积分:"+credits1);
logger.info("用户2投注前积分:"+credits2);
logger.info("用户3投注前积分:"+credits3);
//扣去1积分
credits1 = String.valueOf(Integer.valueOf(credits1)-1);
credits2 = String.valueOf(Integer.valueOf(credits2)-1);
credits3 = String.valueOf(Integer.valueOf(credits3)-1);
Response res1 = pkService.doJoin(uid1,betId,optionId1);
Response res2 = pkService.doJoin(uid2,betId,optionId1);
Response res3 = pkService.doJoin(uid3,betId,optionId2);
//查询数据库,投注前积分(抽奖扣积分流程校验)
mapuser1 = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid1);
mapuser2 = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid2);
mapuser3 = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid3);
String credits4 = String.valueOf(mapuser1.get("credits"));
String credits5 = String.valueOf(mapuser2.get("credits"));
String credits6 = String.valueOf(mapuser3.get("credits"));
logger.info("用户1投注后积分:"+credits4);
logger.info("用户2投注后积分:"+credits5);
logger.info("用户3投注后积分:"+credits6);
Assert.assertEquals(credits4,credits1);
Assert.assertEquals(credits5,credits2);
Assert.assertEquals(credits6,credits3);
}
@Test(dependsOnMethods = { "投注" })
public void 开奖() throws Exception {
//查询数据库,开奖前红包余额
Map<String,Object> user01_account1 = jdbc.findSimpleResult("select * from consumer_accounts.tb_consumer_account_0788 where consumer_id = '100112148' and account_type = '6'\n");
String use1_Acc1 = user01_account1.get("balance_amount").toString();
Map<String,Object> user02_account1 = jdbc.findSimpleResult("select * from consumer_accounts.tb_consumer_account_0824 where consumer_id = '100112184' and account_type = '6'\n");
String use2_Acc1 = user02_account1.get("balance_amount").toString();
Map<String,Object> user03_account1 = jdbc.findSimpleResult("select * from consumer_accounts.tb_consumer_account_0825 where consumer_id = '100112185' and account_type = '6'\n");
String use3_Acc1 = user03_account1.get("balance_amount").toString();
logger.info("用户1开奖前红包余额:"+use1_Acc1);
logger.info("用户2开奖前红包余额:"+use2_Acc1);
logger.info("用户3开奖前红包余额:"+use3_Acc1);
//预期增加红包: 750
DecimalFormat decimalFormat = new DecimalFormat("###################.###########");
use1_Acc1 = decimalFormat.format(this.sub(Double.valueOf(use1_Acc1),750));
use2_Acc1 = decimalFormat.format(this.sub(Double.valueOf(use2_Acc1),750));
//修改开奖时间
this.modifyOpenPrizeTime(betId,60);
//调用开奖接口
Response doDrowRresponse = pkActivityService.doDraw();
Assert.assertEquals(doDrowRresponse.jsonPath().getString("success"),"true","开奖结果校验失败");
Assert.assertEquals(doDrowRresponse.jsonPath().getString("data"),"开奖中。。。","开奖messag校验失败");
Thread.sleep(8000);
//查询数据库,开奖后红包余额
user01_account1 = jdbc.findSimpleResult("select * from consumer_accounts.tb_consumer_account_0788 where consumer_id = '100112148' and account_type = '6'\n");
String use1_Acc2 = user01_account1.get("balance_amount").toString();
user02_account1 = jdbc.findSimpleResult("select * from consumer_accounts.tb_consumer_account_0824 where consumer_id = '100112184' and account_type = '6'\n");
String use2_Acc2 = user02_account1.get("balance_amount").toString();
user03_account1 = jdbc.findSimpleResult("select * from consumer_accounts.tb_consumer_account_0825 where consumer_id = '100112185' and account_type = '6'\n");
String use3_Acc2 = user03_account1.get("balance_amount").toString();
logger.info("用户1开奖后积分:"+use1_Acc2);
logger.info("用户2开奖后积分:"+use2_Acc2);
logger.info("用户3开奖后积分:"+use3_Acc2);
Assert.assertEquals(use1_Acc2,use1_Acc1);
Assert.assertEquals(use2_Acc2,use2_Acc1);
Assert.assertEquals(use3_Acc2,use3_Acc1);
logger.info("投注者瓜分金额校验正确");
//校验点
//1、pk活动表配置的状态更新为4;2、订单表的addCredits字段为瓜分的红包值;3、先押注 的选项为胜方,胜负的额押注人数>负方的押注人数
Map<String,Object> betConfig = jdbc.findSimpleResult("select * from act_com_conf.tb_bet_config where id = ?",betId);
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",betId);
Assert.assertEquals(betGroupRelation.get("config_status").toString(),"4","pk关系表开奖状态更新失败");
logger.info("pk活动配置表状态更新为:"+betConfig.get("config_status").toString()+",pk关系表活动状态更新为:"+betGroupRelation.get("config_status").toString());
Map<String,Object> user01_order = jdbc.findSimpleResult("select * from activity_order_con.tb_trade_center_activity_order_0788 where consumer_id = '100112148' and duiba_activity_id = ?\n",betId);
Assert.assertEquals(user01_order.get("add_credits").toString(),"750","开奖后发奖值校验失败");
Map<String,Object> user02_order = jdbc.findSimpleResult("select * from activity_order_con.tb_trade_center_activity_order_0825 where consumer_id = '100112185' and duiba_activity_id = ?\n",betId);
Assert.assertEquals(user02_order.get("add_credits").toString(),"","开奖后发奖值校验失败");
logger.info("用户01获取的积分值为:"+user01_order.get("add_credits").toString()+",用户03获取的积分值为:"+user02_order.get("add_credits").toString());
Map<String,Object> bet1Result = jdbc.findSimpleResult("select * from bet_activity.tb_bet_result where bet_id = ? and option_id = ?\n",betId,optionId1);
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 = ?\n",betId,optionId2);
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());
}
@Test(dependsOnMethods = { "开奖" })
public void 出奖弹层校验() throws Exception {
Response response = pkService.popup(uid1);
response.prettyPrint();
Assert.assertEquals(response.jsonPath().getString("data.prizeList[0].totalBonus"),"750","中奖弹窗积分校验失败");
Assert.assertEquals(response.jsonPath().getString("data.prizeList[0].bonusType"),"2","中奖弹窗类型校验失败");
Assert.assertEquals(response.jsonPath().getString("data.totalBonus"),"7.5","中奖弹窗积分校验失败");
Assert.assertEquals(response.jsonPath().getString("data.show"),"true","展示弹窗校验失败");
Response response2 = pkService.popup(uid3);
response.prettyPrint();
Assert.assertEquals(response2.jsonPath().getString("data.prizeList"),null,"中奖弹窗积分校验失败");
Assert.assertEquals(response2.jsonPath().getString("data.show"),"false","展示弹窗校验失败");
}
@Test(dependsOnMethods = { "出奖弹层校验" })
public void 战绩页校验() throws Exception {
Response response = pkService.list(uid1);
response.prettyPrint();
Assert.assertEquals(response.jsonPath().getString("data.list[0].userWin"),"true","中奖记录校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].betConfig.id"),betId,"活动id校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].betConfig.shareExp"),"30","活动瓜分金额校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].betConfig.configStatus"),"4","活动状态校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].betConfig.creditsValue"),"1.00","活动消耗校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].betConfig.betType"),"1","活动押注类型校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].betConfig.bonusType"),"2","活动瓜分类型校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].options[0].betId"),betId,"活动id校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].options[0].resultStatus"),"4","活动选项结果状态校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].options[0].optionId"),optionId1,"活动投注id1校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].options[0].rank"),"1","活动投注结果校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].options[0].betTimes"),"4","活动投注人数校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].options[0].scale"),"66.7","活动投注人数比例校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].options[1].betId"),betId,"活动id校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].options[1].resultStatus"),"4","活动选项结果状态校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].options[1].optionId"),optionId2,"活动投注id1校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].options[1].rank"),"2","活动投注结果校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].options[1].betTimes"),"2","活动投注人数校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].options[1].scale"),"33.3","活动投注人数比例校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].record.betId"),betId,"活动id校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].record.optionId"),optionId1,"活动id校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].record.bonus"),"7.5","活动id校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].record.exchangeStatus"),"2","兑换状态校验失败");
response = pkService.list(uid3);
response.prettyPrint();
Assert.assertEquals(response.jsonPath().getString("data.list[0].userWin"),"false","中奖记录校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].record.betId"),betId,"活动id校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].record.optionId"),optionId2,"活动id校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].record.bonus"),"0.0","活动id校验失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].record.exchangeStatus"),"0","兑换状态校验失败");
}
@AfterClass
public void afterclass() {
try {
Boolean result1 = jdbc.update("delete from act_com_conf.tb_bet_option where bet_id = ?",betId);
Boolean result4 = jdbc.update("delete from act_record.tb_bet_record where bet_id = ?",betId);
Boolean result5 = jdbc.update("delete from bet_activity.tb_bet_result where bet_id = ?",betId);
Boolean result2 = jdbc.update("delete from act_com_conf.tb_bet_group_relation where bet_id = ?",betId);
Boolean result3 = jdbc.update("delete from act_com_conf.tb_bet_config where id = ?",betId);
} catch (SQLException e) {
e.printStackTrace();
} catch (Exception e){
e.printStackTrace();
}
}
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);
}
/**
* 提供精确的加法运算。
* @param v1
* @param v2
* @return 两个参数的和
*/
public static double sub(double v1,double v2){
BigDecimal b1 = new BigDecimal(Double.toString(v1));
BigDecimal b2 = new BigDecimal(Double.toString(v2));
return b1.add(b2).doubleValue();
}
}
\ No newline at end of file
/**
* Copyright (C), 2015-2018
* FileName: 配置测试_AccessTest
* Author: zhaoran
* Date: 2018/12/10 19:45
* Description:
*/
package http.cases.PkMoudleTest;
import base.DuibaLog;
import base.DuibaTestBase;
import http.service.Activity.PkService;
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.DataProvider;
import org.testng.annotations.Test;
import utils.ExcelDataProvider;
import java.lang.reflect.Method;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import static io.restassured.RestAssured.given;
public class 配置测试_AccessTest extends DuibaTestBase {
@Value("${activity.host}")
String activityHost;
@Autowired
PkService pkService;
@Autowired
Authorization authorization;
private DuibaLog logger = DuibaLog.getLogger();
private static Integer uid = 5028;//
@DataProvider
public Object[][] providerMethod(Method method){
Object[][] result = null;
if(method.getName().equals("重复投注测试")) {
result = new Object[][]{
new Object[]{"3758"},
new Object[]{"3757"},
};
}
return result;
}
@Test
public void 配置测试() throws Exception{
Response response = pkService.getBetList(uid);
response.print();
//分积分配置获取
String betType1 = response.jsonPath().getString("data.unbetList[0].betConfig.betType");
String bonusType1 = response.jsonPath().getString("data.unbetList[0].betConfig.bonusType");
String configStatus1 = response.jsonPath().getString("data.unbetList[0].betConfig.configStatus");
String creditsValue1 = response.jsonPath().getString("data.unbetList[0].betConfig.creditsValue");
String id1 = response.jsonPath().getString("data.unbetList[0].betConfig.id");
String shareExp1 = response.jsonPath().getString("data.unbetList[0].betConfig.shareExp");
String title1 = response.jsonPath().getString("data.unbetList[0].betConfig.title");
String unitName1 = response.jsonPath().getString("data.unbetList[0].betConfig.unitName");
//分积分选项获取
String optionId1 = response.jsonPath().getString("data.unbetList[0].options[0].optionId");
String optionImg1 = response.jsonPath().getString("data.unbetList[0].options[0].optionImg");
String optionName1 = response.jsonPath().getString("data.unbetList[0].options[0].optionName");
String optionId2 = response.jsonPath().getString("data.unbetList[0].options[1].optionId");
String optionImg2 = response.jsonPath().getString("data.unbetList[0].options[1].optionImg");
String optionName2 = response.jsonPath().getString("data.unbetList[0].options[1].optionName");
Assert.assertEquals(betType1,"1","校验押注类型失败"); //'押注类型 1-单选单次,2-多选无限制'
Assert.assertEquals(bonusType1,"4","校验瓜分类型失败");//'瓜分类型1瓜分经验2瓜分红包3发奖品4瓜分积分'
Assert.assertEquals(configStatus1,"3","校验投注活动的状态失败");//'投注活动的状态:1关闭不可见2关闭可见3开启4结束'
Assert.assertEquals(creditsValue1,"2.00","校验积分价值失败");//积分价值
Assert.assertEquals(id1,"1354","校验pk id失败");
Assert.assertTrue(new BigDecimal(shareExp1).compareTo(new BigDecimal("99"))==0,"校验瓜分的经验池失败");//瓜分的经验池
Assert.assertEquals(title1,"瓜分积分","校验投注活动标题失败");//投注活动标题
Assert.assertEquals(unitName1,"元宝","校验消耗类型失败");
Assert.assertEquals(optionId1,"2867","校验选项1 id失败");
Assert.assertEquals(optionImg1,"//yun.dui88.com/images/201812/c5vo081h6h.jpg","校验选项1 图片失败");
Assert.assertEquals(optionName1,"分积分1","校验选项1 title失败");
Assert.assertEquals(optionId2,"2868","校验选项2 id失败");
Assert.assertEquals(optionImg2,"//yun.dui88.com/images/201812/5ib6ews6bw.png","校验选项2 图片失败");
Assert.assertEquals(optionName2,"分积分2","校验选项2 title失败");
//分红包配置获取
String betType2 = response.jsonPath().getString("data.unbetList[1].betConfig.betType");
String bonusType2 = response.jsonPath().getString("data.unbetList[1].betConfig.bonusType");
String configStatus2 = response.jsonPath().getString("data.unbetList[1].betConfig.configStatus");
String creditsValue2 = response.jsonPath().getString("data.unbetList[1].betConfig.creditsValue");
String id2 = response.jsonPath().getString("data.unbetList[1].betConfig.id");
String shareExp2 = response.jsonPath().getString("data.unbetList[1].betConfig.shareExp");
String title2 = response.jsonPath().getString("data.unbetList[1].betConfig.title");
String unitName2 = response.jsonPath().getString("data.unbetList[1].betConfig.unitName");
//分红包选项获取
String optionId3 = response.jsonPath().getString("data.unbetList[1].options[0].optionId");
String optionImg3 = response.jsonPath().getString("data.unbetList[1].options[0].optionImg");
String optionName3 = response.jsonPath().getString("data.unbetList[1].options[0].optionName");
String optionId4 = response.jsonPath().getString("data.unbetList[1].options[1].optionId");
String optionImg4 = response.jsonPath().getString("data.unbetList[1].options[1].optionImg");
String optionName4 = response.jsonPath().getString("data.unbetList[1].options[1].optionName");
Assert.assertEquals(betType2,"1","校验押注类型失败"); //'押注类型 1-单选单次,2-多选无限制'
Assert.assertEquals(bonusType2,"2","校验瓜分类型失败");//'瓜分类型1瓜分经验2瓜分红包3发奖品4瓜分积分'
Assert.assertEquals(configStatus2,"3","校验投注活动的状态失败");//'投注活动的状态:1关闭不可见2关闭可见3开启4结束'
Assert.assertEquals(creditsValue2,"3.00","校验积分价值失败");//积分价值
Assert.assertEquals(id2,"1355","校验pk id失败");
Assert.assertTrue(new BigDecimal(shareExp2).compareTo(new BigDecimal("199"))==0,"校验瓜分的经验池失败");//瓜分的经验池
Assert.assertEquals(title2,"瓜分红包","校验投注活动标题失败");//投注活动标题
Assert.assertEquals(unitName2,"元宝","校验消耗类型失败");
Assert.assertEquals(optionId3,"2869","校验选项1 id失败");
Assert.assertEquals(optionImg3,"//yun.dui88.com/images/201812/wfvn1m8wm0.jpg","校验选项1 图片失败");
Assert.assertEquals(optionName3,"分红包选项一","校验选项1 title失败");
Assert.assertEquals(optionId4,"2870","校验选项2 id失败");
Assert.assertEquals(optionImg4,"//yun.dui88.com/images/201812/ifh1kvaq9m.jpg","校验选项2 图片失败");
Assert.assertEquals(optionName4,"分红包选项二","校验选项2 title失败");
//已投注配置
String betType3 = response.jsonPath().getString("data.betedList[0].betConfig.betType");
String bonusType3 = response.jsonPath().getString("data.betedList[0].betConfig.bonusType");
String configStatus3 = response.jsonPath().getString("data.betedList[0].betConfig.configStatus");
String creditsValue3 = response.jsonPath().getString("data.betedList[0].betConfig.creditsValue");
String id3 = response.jsonPath().getString("data.betedList[0].betConfig.id");
String shareExp3 = response.jsonPath().getString("data.betedList[0].betConfig.shareExp");
String title3 = response.jsonPath().getString("data.betedList[0].betConfig.title");
String unitName3 = response.jsonPath().getString("data.betedList[0].betConfig.unitName");
//选项获取
String optionId5 = response.jsonPath().getString("data.betedList[0].options[0].optionId");
String optionImg5 = response.jsonPath().getString("data.betedList[0].options[0].optionImg");
String optionName5 = response.jsonPath().getString("data.betedList[0].options[0].optionName");
String chooseThisOption5 = response.jsonPath().getString("data.betedList[0].options[0].chooseThisOption");
String optionId6 = response.jsonPath().getString("data.betedList[0].options[1].optionId");
String optionImg6 = response.jsonPath().getString("data.betedList[0].options[1].optionImg");
String optionName6 = response.jsonPath().getString("data.betedList[0].options[1].optionName");
String chooseThisOption6 = response.jsonPath().getString("data.betedList[0].options[1].chooseThisOption");
Assert.assertEquals(betType3,"1","校验押注类型失败"); //'押注类型 1-单选单次,2-多选无限制'
Assert.assertEquals(bonusType3,"4","校验瓜分类型失败");//'瓜分类型1瓜分经验2瓜分红包3发奖品4瓜分积分'
Assert.assertEquals(configStatus3,"3","校验投注活动的状态失败");//'投注活动的状态:1关闭不可见2关闭可见3开启4结束'
Assert.assertEquals(creditsValue3,"0","校验积分价值失败");//积分价值
Assert.assertEquals(id3,"1799","校验pk id失败");
Assert.assertTrue(new BigDecimal(shareExp3).compareTo(new BigDecimal("50"))==0,"校验瓜分的经验池失败");//瓜分的经验池
Assert.assertEquals(title3,"待投注","校验投注活动标题失败");//投注活动标题
Assert.assertEquals(unitName3,"元宝","校验消耗类型失败");
Assert.assertEquals(optionId5,"3757","校验选项1 id失败");
Assert.assertEquals(optionImg5,"//yun.dui88.com/images/201812/2sv582lhyo.png","校验选项1 图片失败");
Assert.assertEquals(optionName5,"1","校验选项1 title失败");
Assert.assertEquals(chooseThisOption5,"false","校验选项1选择情况失败");
Assert.assertEquals(optionId6,"3758","校验选项2 id失败");
Assert.assertEquals(optionImg6,"//yun.dui88.com/images/201812/hyhd36w6be.png","校验选项2 图片失败");
Assert.assertEquals(optionName6,"2","校验选项2 title失败");
Assert.assertEquals(chooseThisOption6,"true","校验选项2选择情况失败");
logger.info("pk组件分红包、分积分配置校验正确!");
}
@Test
public void 投注积分不足(){
String url = activityHost + "/betActivity2/doJoin";
Map<String,Object> map = new HashMap<>();
map.put("betId","1355");
map.put("optionId","2869");
Response response = given().cookies(authorization.dafuwengLogin(uid)).params(map).post(url);
Assert.assertEquals(response.jsonPath().getString("success"),"false","校验success失败");
Assert.assertEquals(response.jsonPath().getString("code"),"100009","校验错误码失败");
Assert.assertEquals(response.jsonPath().getString("desc"),"积分不足","校验desc失败");
logger.info("投注积分不足校验成功!");
}
@Test(dataProvider = "providerMethod")
public void 重复投注测试(String optionId){
String url = activityHost + "/betActivity2/doJoin";
Map<String,Object> map = new HashMap<>();
map.put("betId","1799");
map.put("optionId",optionId);
Response response = given().cookies(authorization.dafuwengLogin(uid)).params(map).post(url);
response.prettyPrint();
Assert.assertEquals(response.jsonPath().getString("success"),"false","校验success失败");
Assert.assertEquals(response.jsonPath().getString("code"),"100011","校验错误码失败");
Assert.assertEquals(response.jsonPath().getString("desc"),"活动已参加","校验desc失败");
logger.info("重复投注校验成功!");
}
@Test
public void 未登录投注(){
//获取未登录场景cookie
Response responses = authorization.autoLogin();
//进行接口测试传参
Map<String,String> cookies = responses.getCookies();
String url = activityHost + "/betActivity2/doJoin";
Map<String,Object> map = new HashMap<>();
map.put("betId","1355");
map.put("optionId","2869");
Response response = given().cookies(cookies).params(map).post(url);
response.prettyPrint();
Assert.assertEquals(response.jsonPath().getString("success"),"false","校验success失败");
Assert.assertEquals(response.jsonPath().getString("code"),"00000001","校验错误码失败");
Assert.assertEquals(response.jsonPath().getString("desc"),"用户未登录","校验desc失败");
logger.info("未登录投注校验成功!");
}
}
\ No newline at end of file
/**
* Copyright (C), 2015-2018
* FileName: pk_开奖_瓜分红包_押注人数不同测试_AccessTest
* FileName: pk_开奖_瓜分红包_押注人数不同测试
* Author: qianwenjun
* Date: 2018/8/9 20:13
* Description:
......
......@@ -18,10 +18,12 @@ import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import utils.GetCookieUtil;
import utils.GetDbName;
import java.util.ArrayList;
import java.util.HashMap;
......@@ -49,17 +51,22 @@ public class pk_押注测试_AccessTest extends DuibaTestBase {
private DuibaLog logger = DuibaLog.getLogger();
private static Integer uid01 = 3416;//【勿动】pk01_测试押注
private static Integer uid01 = 3416;//【勿动】pk01_测试押注瓜分经验
private static String uid01_consumerId = "100066015";
private static Integer uid02 = 3417;//【勿动】pk02_积分不足_测试押注
private static String uid02_consumerId = "100066016";
private static Integer uid03 = 5244;//【勿动】pk02_押注0积分活动
private static String uid03_consumerId = "100117002";
private static Integer uid04 = 5247;//【勿动】pk02_测试押注瓜分红包
private static String uid04_consumerId = "100117005";
private static Integer uid05 = 5248;//【勿动】pk02_测试押注瓜分红包
private static String uid05_consumerId = "100117006";
private String consumerIds = "";
private List<String> orderIds = new ArrayList<>();
// private List<String> orderIds = new ArrayList<>();
private List<Map<String,String>> orderIds = new ArrayList<>();
@BeforeMethod
public void clearUp() {
......@@ -77,7 +84,7 @@ public class pk_押注测试_AccessTest extends DuibaTestBase {
@Test
public void 押注_红包活动测试() throws Exception{
public void 押注_瓜分经验pk活动测试() throws Exception{
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);
Long userCredit = Long.parseLong(user.get("credits").toString());
......@@ -88,7 +95,10 @@ public class pk_押注测试_AccessTest extends DuibaTestBase {
doJoinResponse.prettyPrint();
Assert.assertEquals(doJoinResponse.jsonPath().getString("code"),"200","校验押注是否成功且不是第一次押注失败");
String orderId = doJoinResponse.jsonPath().getString("data");
orderIds.add(orderId);
Map<String,String> orderIdMap = new HashMap<>();
orderIdMap.put("consumerId",uid01_consumerId);
orderIdMap.put("orderId",orderId);
orderIds.add(orderIdMap);
Response statusResponse = pkService.getOrderStatus(uid01,orderId);
statusResponse.prettyPrint();
String consumerStatus = statusResponse.jsonPath().getString("data.consumeStatus");
......@@ -114,9 +124,144 @@ public class pk_押注测试_AccessTest extends DuibaTestBase {
Assert.assertEquals(doJoinResponse1.jsonPath().getString("success"),"false","校验参加结果失败");
Assert.assertEquals(doJoinResponse1.jsonPath().getString("code"),"100011","校验参加失败错误码失败");
Assert.assertEquals(doJoinResponse1.jsonPath().getString("desc"),"活动已参加","校验参加失败描述失败");
}
@Test
public void 押注_瓜分红包pk活动测试() throws Exception{
Map<String,Object> user = jdbc.findSimpleResult("select * from dafuweng.user where id=?\n",uid04);
Map<String,Object> consumer = jdbc.findSimpleResult("select * from new_consumer.consumer_0010 where id=?\n",uid04_consumerId);
Long userCredit = Long.parseLong(user.get("credits").toString());
Long consumerCredit = Long.parseLong(consumer.get("credits").toString());
Response doJoinResponse = pkService.doJoin(uid04,"122","243");
doJoinResponse.prettyPrint();
Assert.assertEquals(doJoinResponse.jsonPath().getString("code"),"200","校验押注是否成功且不是第一次押注失败");
String orderId = doJoinResponse.jsonPath().getString("data");
Map<String,String> orderIdMap = new HashMap<>();
orderIdMap.put("consumerId",uid04_consumerId);
orderIdMap.put("orderId",orderId);
orderIds.add(orderIdMap);
Response statusResponse = pkService.getOrderStatus(uid04,orderId);
statusResponse.prettyPrint();
String consumerStatus = statusResponse.jsonPath().getString("data.consumeStatus");
int i=8;
while (i>0&consumerStatus.equals("1")){
Thread.sleep(1000);
statusResponse = pkService.getOrderStatus(uid04,orderId);
consumerStatus = statusResponse.jsonPath().getString("data.consumeStatus");
}
Assert.assertEquals(consumerStatus,"2","校验押注是否成功,扣积分是否成功失败");
Map<String,Object> user1 = jdbc.findSimpleResult("select * from dafuweng.user where id=?\n",uid04);
Map<String,Object> consumer1 = jdbc.findSimpleResult("select * from new_consumer.consumer_0010 where id=?\n",uid04_consumerId);
String userCredit1 = user1.get("credits").toString();
String consumerCredit1 = consumer1.get("credits").toString();
Assert.assertEquals(userCredit1,String.valueOf(userCredit-100),"user积分扣除校验失败");
Assert.assertEquals(consumerCredit1,String.valueOf(consumerCredit-100),"consumer积分扣除校验失败");
logger.info("校验积分消耗成功,原积分值="+userCredit+",消耗后积分值为"+userCredit1);
//参加过一次之后,不能再参加该pk活动
Response doJoinResponse1 = pkService.doJoin2(uid04,"122","243");
doJoinResponse1.prettyPrint();
Assert.assertEquals(doJoinResponse1.jsonPath().getString("success"),"false","校验参加结果失败");
Assert.assertEquals(doJoinResponse1.jsonPath().getString("code"),"100011","校验参加失败错误码失败");
Assert.assertEquals(doJoinResponse1.jsonPath().getString("desc"),"活动已参加","校验参加失败描述失败");
}
@Test
public void 押注_瓜分优惠券pk活动测试() throws Exception{
Map<String,Object> user = jdbc.findSimpleResult("select * from dafuweng.user where id=?\n",uid05);
Map<String,Object> consumer = jdbc.findSimpleResult("select * from new_consumer.consumer_0010 where id=?\n",uid05_consumerId);
Long userCredit = Long.parseLong(user.get("credits").toString());
Long consumerCredit = Long.parseLong(consumer.get("credits").toString());
Response doJoinResponse = pkService.doJoin(uid05,"83","165");
doJoinResponse.prettyPrint();
Assert.assertEquals(doJoinResponse.jsonPath().getString("code"),"200","校验押注是否成功且不是第一次押注失败");
String orderId = doJoinResponse.jsonPath().getString("data");
Map<String,String> orderIdMap = new HashMap<>();
orderIdMap.put("consumerId",uid05_consumerId);
orderIdMap.put("orderId",orderId);
orderIds.add(orderIdMap);
Response statusResponse = pkService.getOrderStatus(uid05,orderId);
statusResponse.prettyPrint();
String consumerStatus = statusResponse.jsonPath().getString("data.consumeStatus");
int i=8;
while (i>0&consumerStatus.equals("1")){
Thread.sleep(1000);
statusResponse = pkService.getOrderStatus(uid05,orderId);
consumerStatus = statusResponse.jsonPath().getString("data.consumeStatus");
}
Assert.assertEquals(consumerStatus,"2","校验押注是否成功,扣积分是否成功失败");
Map<String,Object> user1 = jdbc.findSimpleResult("select * from dafuweng.user where id=?\n",uid05);
Map<String,Object> consumer1 = jdbc.findSimpleResult("select * from new_consumer.consumer_0010 where id=?\n",uid05_consumerId);
String userCredit1 = user1.get("credits").toString();
String consumerCredit1 = consumer1.get("credits").toString();
Assert.assertEquals(userCredit1,String.valueOf(userCredit-50),"user积分扣除校验失败");
Assert.assertEquals(consumerCredit1,String.valueOf(consumerCredit-50),"consumer积分扣除校验失败");
logger.info("校验积分消耗成功,原积分值="+userCredit+",消耗后积分值为"+userCredit1);
//参加过一次之后,不能再参加该pk活动
Response doJoinResponse1 = pkService.doJoin2(uid05,"83","166");
doJoinResponse1.prettyPrint();
Assert.assertEquals(doJoinResponse1.jsonPath().getString("success"),"false","校验参加结果失败");
Assert.assertEquals(doJoinResponse1.jsonPath().getString("code"),"100011","校验参加失败错误码失败");
Assert.assertEquals(doJoinResponse1.jsonPath().getString("desc"),"活动已参加","校验参加失败描述失败");
}
@Test
public void 押注_0积分pk活动() throws Exception{
Map<String,Object> user = jdbc.findSimpleResult("select * from dafuweng.user where id=?\n",uid03);
Map<String,Object> consumer = jdbc.findSimpleResult("select * from new_consumer.consumer_0010 where id=?\n",uid03_consumerId);
Long userCredit = Long.parseLong(user.get("credits").toString());
Long consumerCredit = Long.parseLong(consumer.get("credits").toString());
Response doJoinResponse = pkService.doJoin(uid03,"82","163");
doJoinResponse.prettyPrint();
Assert.assertEquals(doJoinResponse.jsonPath().getString("code"),"200","校验押注是否成功且不是第一次押注失败");
String orderId = doJoinResponse.jsonPath().getString("data");
Map<String,String> orderIdMap = new HashMap<>();
orderIdMap.put("consumerId",uid03_consumerId);
orderIdMap.put("orderId",orderId);
orderIds.add(orderIdMap);
Response statusResponse = pkService.getOrderStatus(uid03,orderId);
statusResponse.prettyPrint();
String consumerStatus = statusResponse.jsonPath().getString("data.consumeStatus");
int i=8;
while (i>0&consumerStatus.equals("1")){
Thread.sleep(1000);
statusResponse = pkService.getOrderStatus(uid03,orderId);
consumerStatus = statusResponse.jsonPath().getString("data.consumeStatus");
}
Assert.assertEquals(consumerStatus,"2","校验押注是否成功,扣积分是否成功失败");
Map<String,Object> user1 = jdbc.findSimpleResult("select * from dafuweng.user where id=?\n",uid03);
Map<String,Object> consumer1 = jdbc.findSimpleResult("select * from new_consumer.consumer_0010 where id=?\n",uid03_consumerId);
String userCredit1 = user1.get("credits").toString();
String consumerCredit1 = consumer1.get("credits").toString();
Assert.assertEquals(userCredit1,String.valueOf(userCredit-0),"user积分扣除校验失败");
Assert.assertEquals(consumerCredit1,String.valueOf(consumerCredit-0),"consumer积分扣除校验失败");
logger.info("校验积分消耗成功,原积分值="+userCredit+",消耗后积分值为"+userCredit1);
//参加过一次之后,不能再参加该pk活动
Response doJoinResponse1 = pkService.doJoin2(uid03,"82","163");
doJoinResponse1.prettyPrint();
Assert.assertEquals(doJoinResponse1.jsonPath().getString("success"),"false","校验参加结果失败");
Assert.assertEquals(doJoinResponse1.jsonPath().getString("code"),"100011","校验参加失败错误码失败");
Assert.assertEquals(doJoinResponse1.jsonPath().getString("desc"),"活动已参加","校验参加失败描述失败");
}
@Test
public void 押注_积分不足测试() throws Exception {
......@@ -163,6 +308,7 @@ public class pk_押注测试_AccessTest extends DuibaTestBase {
Assert.assertEquals(doJoinResponse.jsonPath().getString("code").toString(),"100060");
}
public Map<String,String> createUser() throws Exception{
Map<String,String> map = new HashMap<>();
......@@ -186,14 +332,22 @@ public class pk_押注测试_AccessTest extends DuibaTestBase {
}
@AfterMethod
@AfterClass
public void tearDown() {
try {
Boolean result = jdbc.update("delete from act_record.tb_bet_record where bet_id = '124' and partner_user_id = '3416'\n");
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 act_record.tb_bet_record where bet_id = '82' and partner_user_id = '5244'\n");
Boolean result4 = jdbc.update("delete from act_record.tb_bet_record where bet_id = '122' and partner_user_id = '5247'\n");
Boolean result5 = jdbc.update("delete from act_record.tb_bet_record where bet_id = '83' and partner_user_id = '5248'\n");
for (Map<String,String> orderId:orderIds){
Map<String,Object> map = new HashMap<>();
String dbName1 = GetDbName.getDbName("activity_order_con.tb_trade_center_activity_order_",orderId.get("consumerId"),"1");
String sql1 = "delete from "+dbName1+" where order_num = ? ";
logger.info("清理的sql为:"+sql1);
Boolean result3 = jdbc.update(sql1,orderId.get("orderId"));
}
clear(consumerIds);
......
/**
* Copyright (C), 2015-2018
* FileName: pk_开奖_瓜分红包_押注人数不同测试_AccessTest
* FileName: pk_开奖_瓜分红包_押注人数不同测试
* Author: qianwenjun
* Date: 2018/8/9 20:13
* Description:
......@@ -38,7 +38,7 @@ import java.util.Map;
* @create 2018/8/9
* @since 1.0.0
*/
public class pk_开奖_瓜分优惠券_AccessTest extends DuibaTestBase {
public class pk_瓜分优惠券_AccessTest extends DuibaTestBase {
@Autowired
PkService pkService;
......@@ -50,14 +50,14 @@ public class pk_开奖_瓜分优惠券_AccessTest extends DuibaTestBase {
private static DuibaLog logger = DuibaLog.getLogger();
private String groupId = "7";
private String groupId = "147";
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
private Integer user01 = 5197;//appid=18816
private String consumerId01 = "100114055";//activity_order_con.tb_trade_center_activity_order_0794
private Integer user02 = 5198;//appid=18816
private String consumerId02 = "100114056";//activity_order_con.tb_trade_center_activity_order_0795
private Integer user03 = 5199;//appid=2239
private String consumerId03 = "100114057";//activity_order_con.tb_trade_center_activity_order_0796
List<String> wins = new ArrayList<>();
List<String> loses = new ArrayList<>();
......@@ -132,7 +132,7 @@ public class pk_开奖_瓜分优惠券_AccessTest extends DuibaTestBase {
//校验点
//1、pk活动表配置的状态更新为4;2、订单表的addCredits字段为瓜分的红包值;3、先押注 的选项为胜方,胜负的额押注人数>负方的押注人数,4、校验account表的红包值加上去
checkPKConfig();
checkPKResult("18816");
checkPKResult("21835");
checkUserOrder(wins,loses);
checkRecord(wins,loses);
......@@ -235,7 +235,7 @@ public class pk_开奖_瓜分优惠券_AccessTest extends DuibaTestBase {
}
}
// @AfterClass
@AfterClass
public void tearDown() {
try {
......
/**
* Copyright (C), 2015-2018
* FileName: pk_开奖_瓜分红包_押注人数不同测试_AccessTest
* FileName: pk_开奖_瓜分红包_押注人数不同测试
* Author: qianwenjun
* Date: 2018/8/9 20:13
* Description:
......@@ -23,9 +23,11 @@ import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import utils.GetDbName;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -37,7 +39,7 @@ import java.util.Map;
* @create 2018/8/9
* @since 1.0.0
*/
public class pk_开奖_瓜分红包_投放两个app_AccessTest extends DuibaTestBase {
public class pk_瓜分红包_投放两个app_AccessTest extends DuibaTestBase {
@Autowired
PkService pkService;
......@@ -47,16 +49,17 @@ public class pk_开奖_瓜分红包_投放两个app_AccessTest extends DuibaTest
private static DuibaLog logger = DuibaLog.getLogger();
private String groupId = "6,7";
//146-pk测试3,pk测试4
private String groupId = "146";
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
private Integer user01 = 5193;//appid=21833
private String consumerId01 = "100114050";//activity_order_con.tb_trade_center_activity_order_0848
private Integer user02 = 5194;//appid=21833
private String consumerId02 = "100114051";//activity_order_con.tb_trade_center_activity_order_0849
private Integer user03 = 5195;//appid=21834
private String consumerId03 = "100114052";//activity_order_con.tb_trade_center_activity_order_0850
private Integer user04 = 5196;//appid=21834
private String consumerId04 = "100114053";//activity_order_con.tb_trade_center_activity_order_0851
List<String> wins = new ArrayList<>();
List<String> loses = new ArrayList<>();
......@@ -90,13 +93,13 @@ public class pk_开奖_瓜分红包_投放两个app_AccessTest extends DuibaTest
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");
Map<String,Object> user01_account1 = this.accountInfo(consumerId01);
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");
Map<String,Object> user02_account1 = this.accountInfo(consumerId02);
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");
Map<String,Object> user03_account1 = this.accountInfo(consumerId03);
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");
Map<String,Object> user04_account1 = this.accountInfo(consumerId04);
Long use4_Acc1 = Long.valueOf(user04_account1.get("balance_amount").toString());
......@@ -123,21 +126,21 @@ public class pk_开奖_瓜分红包_投放两个app_AccessTest extends DuibaTest
//校验点
//1、pk活动表配置的状态更新为4;2、订单表的addCredits字段为瓜分的红包值;3、先押注 的选项为胜方,胜负的额押注人数>负方的押注人数,4、校验account表的红包值加上去
checkPKConfig();
checkPKResult("18816");
checkPKResult("2239");
checkPKResult("21833");
checkPKResult("21834");
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");
Map<String,Object> user01_account2 = this.accountInfo(consumerId01);
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");
Map<String,Object> user02_account2 = this.accountInfo(consumerId02);
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");
Map<String,Object> user03_account2 = this.accountInfo(consumerId03);
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");
Map<String,Object> user04_account2 = this.accountInfo(consumerId04);
Long use4_Acc2 = Long.valueOf(user04_account2.get("balance_amount").toString());
Assert.assertEquals(use4_Acc2,use4_Acc1,"用户4入账校验失败");
......@@ -145,6 +148,25 @@ public class pk_开奖_瓜分红包_投放两个app_AccessTest extends DuibaTest
}
public Map<String,Object> accountInfo(String consumerId) throws Exception{
Map<String,Object> map = new HashMap<>();
String dbName1 = GetDbName.getDbName("consumer_accounts.tb_consumer_account_",consumerId,"1");
String sql1 = "select * from "+dbName1+" where consumer_id = ? and account_type = '6'";
map = jdbc.findSimpleResult(sql1,consumerId);
return map;
}
public Map<String,Object> orderInfo(String consumerId,String betId) throws Exception{
Map<String,Object> map = new HashMap<>();
String dbName1 = GetDbName.getDbName("activity_order_con.tb_trade_center_activity_order_",consumerId,"1");
String sql1 = "select * from "+dbName1+" where consumer_id = ? and duiba_activity_id = ?\n";
map = jdbc.findSimpleResult(sql1,consumerId,betId);
return map;
}
public void createPk(String bounsType,String endTime,String groupId) throws Exception {
Response betResponse = pkActivityService.betForSetUp(bounsType,endTime);
......@@ -249,12 +271,17 @@ public class pk_开奖_瓜分红包_投放两个app_AccessTest extends DuibaTest
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 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 result1 = jdbc.update("delete from act_com_conf.tb_bet_option where bet_id = ?",newBetId);
Boolean result4 = jdbc.update("delete from act_record.tb_bet_record where bet_id = ?",newBetId);
Boolean result5 = jdbc.update("delete from bet_activity.tb_bet_result where bet_id = ?",newBetId);
Boolean result2 = jdbc.update("delete from act_com_conf.tb_bet_group_relation where bet_id = ?",newBetId);
Boolean result3 = jdbc.update("delete from act_com_conf.tb_bet_config where id = ?",newBetId);
} catch (SQLException e) {
......
/**
* Copyright (C), 2015-2018
* FileName: pk_开奖_瓜分红包_押注人数不同测试_AccessTest
* FileName: pk_开奖_瓜分红包_押注人数不同测试
* Author: qianwenjun
* Date: 2018/8/9 20:13
* Description:
......@@ -10,29 +10,24 @@ package http.cases.PkTest;
import base.DuibaLog;
import base.DuibaTestBase;
import com.alibaba.fastjson.JSONObject;
import http.model.BetMngVo;
import http.model.BetMobileVo;
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.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import utils.MatcherString;
import org.joda.time.format.DateTimeFormatter;
import org.joda.time.DateTime;
import utils.GetDbName;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -44,7 +39,7 @@ import java.util.Map;
* @create 2018/8/9
* @since 1.0.0
*/
public class pk_开奖_瓜分红包_押注人数不同测试_AccessTest extends DuibaTestBase {
public class pk_瓜分红包_押注人数不同测试_AccessTest extends DuibaTestBase {
@Autowired
PkService pkService;
......@@ -54,16 +49,16 @@ public class pk_开奖_瓜分红包_押注人数不同测试_AccessTest extends
private static DuibaLog logger = DuibaLog.getLogger();
private String groupId = "7";
private String groupId = "132";
private Integer user01 = 3445;
private String consumerId01 = "100066364";//activity_order_con.tb_trade_center_activity_order_0060
private Integer user02 = 3446;
private String consumerId02 = "100066365";//activity_order_con.tb_trade_center_activity_order_0061
private Integer user03 = 3447;
private String consumerId03 = "100066366";//activity_order_con.tb_trade_center_activity_order_0062
private Integer user04 = 3448;
private String consumerId04 = "100066367";//activity_order_con.tb_trade_center_activity_order_0063
private Integer user01 = 5165;
private String consumerId01 = "100114015";//activity_order_con.tb_trade_center_activity_order_0060
private Integer user02 = 5166;
private String consumerId02 = "100114016";//activity_order_con.tb_trade_center_activity_order_0061
private Integer user03 = 5167;
private String consumerId03 = "100114017";//activity_order_con.tb_trade_center_activity_order_0062
private Integer user04 = 5168;
private String consumerId04 = "100114018";//activity_order_con.tb_trade_center_activity_order_0063
private String newBetId = "";
......@@ -94,13 +89,13 @@ public class pk_开奖_瓜分红包_押注人数不同测试_AccessTest extends
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_0060 where consumer_id = '100066364' and account_type = '6'\n");
Map<String,Object> user01_account1 = this.accountInfo(consumerId01);
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_0061 where consumer_id = '100066365' and account_type = '6'\n");
Map<String,Object> user02_account1 = this.accountInfo(consumerId02);
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_0062 where consumer_id = '100066366' and account_type = '6'\n");
Map<String,Object> user03_account1 = this.accountInfo(consumerId03);
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_0063 where consumer_id = '100066367' and account_type = '6'\n");
Map<String,Object> user04_account1 = this.accountInfo(consumerId04);
Long use4_Acc1 = Long.valueOf(user04_account1.get("balance_amount").toString());
......@@ -137,13 +132,13 @@ public class pk_开奖_瓜分红包_押注人数不同测试_AccessTest extends
}
}
Map<String,Object> user01_order = jdbc.findSimpleResult("select * from activity_order_con.tb_trade_center_activity_order_0060 where consumer_id = '100066364' and duiba_activity_id = ?\n",newBetId);
Map<String,Object> user01_order = this.orderInfo(consumerId01,newBetId);
Assert.assertEquals(user01_order.get("add_credits").toString(),"","开奖后发奖值校验失败");
Map<String,Object> user02_order = jdbc.findSimpleResult("select * from activity_order_con.tb_trade_center_activity_order_0061 where consumer_id = '100066365' and duiba_activity_id = ?\n",newBetId);
Map<String,Object> user02_order = this.orderInfo(consumerId02,newBetId);
Assert.assertEquals(user02_order.get("add_credits").toString(),"10","开奖后发奖值校验失败");
Map<String,Object> user03_order = jdbc.findSimpleResult("select * from activity_order_con.tb_trade_center_activity_order_0062 where consumer_id = '100066366' and duiba_activity_id = ?\n",newBetId);
Map<String,Object> user03_order = this.orderInfo(consumerId03,newBetId);
Assert.assertEquals(user03_order.get("add_credits").toString(),"10","开奖后发奖值校验失败");
Map<String,Object> user04_order = jdbc.findSimpleResult("select * from activity_order_con.tb_trade_center_activity_order_0063 where consumer_id = '100066367' and duiba_activity_id = ?\n",newBetId);
Map<String,Object> user04_order = this.orderInfo(consumerId04,newBetId);
Assert.assertEquals(user04_order.get("add_credits").toString(),"10","开奖后发奖值校验失败");
logger.info("用户01获取的红包值为:"+user01_order.get("add_credits").toString()+",用户02获取的红包值为:"+user02_order.get("add_credits").toString());
logger.info("用户03获取的红包值为:"+user03_order.get("add_credits").toString()+",用户04获取的红包值为:"+user04_order.get("add_credits").toString());
......@@ -157,22 +152,39 @@ public class pk_开奖_瓜分红包_押注人数不同测试_AccessTest extends
Assert.assertTrue(bet1Times<bet2Times,"活动获胜人数比失败人数多校验失败");
logger.info("选项1的押注人数为:"+bet1Result.get("bet_times").toString()+",选项2的押注人数为:"+bet2Result.get("bet_times").toString());
Map<String,Object> user01_account2 = jdbc.findSimpleResult("select * from consumer_accounts.tb_consumer_account_0060 where consumer_id = '100066364' and account_type = '6'\n");
Map<String,Object> user01_account2 = this.accountInfo(consumerId01);
Long use1_Acc2 = Long.valueOf(user01_account2.get("balance_amount").toString());
Assert.assertEquals(use1_Acc2,use1_Acc1,"用户1入账校验失败");
Map<String,Object> user02_account2 = jdbc.findSimpleResult("select * from consumer_accounts.tb_consumer_account_0061 where consumer_id = '100066365' and account_type = '6'\n");
Map<String,Object> user02_account2 = this.accountInfo(consumerId02);
Long use2_Acc2 = Long.valueOf(user02_account2.get("balance_amount").toString());
Assert.assertEquals(use2_Acc2.toString(),String.valueOf(use2_Acc1+10),"用户2入账校验失败");
Map<String,Object> user03_account2 = jdbc.findSimpleResult("select * from consumer_accounts.tb_consumer_account_0062 where consumer_id = '100066366' and account_type = '6'\n");
Map<String,Object> user03_account2 = this.accountInfo(consumerId03);
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_0063 where consumer_id = '100066367' and account_type = '6'\n");
Map<String,Object> user04_account2 = this.accountInfo(consumerId04);
Long use4_Acc2 = Long.valueOf(user04_account2.get("balance_amount").toString());
Assert.assertEquals(use4_Acc2.toString(),String.valueOf(use4_Acc1+10),"用户4入账校验失败");
}
public Map<String,Object> accountInfo(String consumerId) throws Exception{
Map<String,Object> map = new HashMap<>();
String dbName1 = GetDbName.getDbName("consumer_accounts.tb_consumer_account_",consumerId,"1");
String sql1 = "select * from "+dbName1+" where consumer_id = ? and account_type = '6'";
map = jdbc.findSimpleResult(sql1,consumerId);
return map;
}
public Map<String,Object> orderInfo(String consumerId,String betId) throws Exception{
Map<String,Object> map = new HashMap<>();
String dbName1 = GetDbName.getDbName("activity_order_con.tb_trade_center_activity_order_",consumerId,"1");
String sql1 = "select * from "+dbName1+" where consumer_id = ? and duiba_activity_id = ?\n";
map = jdbc.findSimpleResult(sql1,consumerId,betId);
return map;
}
public void createPk(String bounsType,String endTime,String groupId) throws Exception {
......@@ -185,7 +197,6 @@ public class pk_开奖_瓜分红包_押注人数不同测试_AccessTest extends
Response modifyStatusResponse = pkActivityService.modifySatus(betId);
}
public void modifyOpenPrizeTime(String betId,int x) throws Exception{
DateTime time1 = new DateTime();
......@@ -232,11 +243,17 @@ public class pk_开奖_瓜分红包_押注人数不同测试_AccessTest extends
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 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 result1 = jdbc.update("delete from act_com_conf.tb_bet_option where bet_id = ?",newBetId);
Boolean result4 = jdbc.update("delete from act_record.tb_bet_record where bet_id = ?",newBetId);
Boolean result5 = jdbc.update("delete from bet_activity.tb_bet_result where bet_id = ?",newBetId);
Boolean result2 = jdbc.update("delete from act_com_conf.tb_bet_group_relation where bet_id = ?",newBetId);
Boolean result3 = jdbc.update("delete from act_com_conf.tb_bet_config where id = ?",newBetId);
......
/**
* Copyright (C), 2015-2018
* FileName: pk_开奖_瓜分红包_押注人数不同测试_AccessTest
* FileName: pk_开奖_瓜分红包_押注人数不同测试
* Author: qianwenjun
* Date: 2018/8/9 20:13
* Description:
......@@ -23,10 +23,11 @@ import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import utils.MatcherString;
import utils.GetDbName;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -38,7 +39,7 @@ import java.util.Map;
* @create 2018/8/9
* @since 1.0.0
*/
public class pk_开奖_瓜分红包_押注人数相同测试_AccessTest extends DuibaTestBase {
public class pk_瓜分红包_押注人数相同测试_AccessTest extends DuibaTestBase {
@Autowired
PkService pkService;
......@@ -48,12 +49,12 @@ public class pk_开奖_瓜分红包_押注人数相同测试_AccessTest extends
private static DuibaLog logger = DuibaLog.getLogger();
private String groupId = "7";
private String groupId = "129";//appId=21830
private Integer user01 = 4784;
private String consumerId01 = "100108068";//activity_order_con.tb_trade_center_activity_order_0804
private Integer user02 = 4785;
private String consumerId02 = "100108069";//activity_order_con.tb_trade_center_activity_order_0805
private Integer user01 = 5156;
private String consumerId01 = "100114000";//activity_order_con.tb_trade_center_activity_order_0804
private Integer user02 = 5157;
private String consumerId02 = "100114001";//activity_order_con.tb_trade_center_activity_order_0805
private String newBetId = "";
......@@ -84,9 +85,10 @@ public class pk_开奖_瓜分红包_押注人数相同测试_AccessTest extends
}
logger.info("pk活动id为:"+newBetId+",选项id为:"+ optionsIds.toString());
Map<String,Object> user01_account1 = jdbc.findSimpleResult("select * from consumer_accounts.tb_consumer_account_0804 where consumer_id = '100108068' and account_type = '6'\n");
Map<String,Object> user01_account1 = this.accountInfo(consumerId01);
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_0805 where consumer_id = '100108069' and account_type = '6'\n");
Map<String,Object> user02_account1 = this.accountInfo(consumerId02);
Long use2_Acc1 = Long.valueOf(user02_account1.get("balance_amount").toString());
......@@ -102,7 +104,7 @@ public class pk_开奖_瓜分红包_押注人数相同测试_AccessTest extends
Response doDrowRresponse = pkActivityService.doDraw();
Assert.assertEquals(doDrowRresponse.jsonPath().getString("success"),"true","开奖结果校验失败");
Assert.assertEquals(doDrowRresponse.jsonPath().getString("data"),"开奖中。。。","开奖messag校验失败");
Thread.sleep(8000);
Thread.sleep(16000);
//校验点
//1、pk活动表配置的状态更新为4;2、订单表的addCredits字段为瓜分的红包值;3、先押注 的选项为胜方,胜负的额押注人数>负方的押注人数
......@@ -121,9 +123,9 @@ public class pk_开奖_瓜分红包_押注人数相同测试_AccessTest extends
}
}
Map<String,Object> user01_order = jdbc.findSimpleResult("select * from activity_order_con.tb_trade_center_activity_order_0804 where consumer_id = '100108068' and duiba_activity_id = ?\n",newBetId);
Map<String,Object> user01_order = this.orderInfo(consumerId01,newBetId);
Assert.assertEquals(user01_order.get("add_credits").toString(),"10","开奖后发奖值校验失败");
Map<String,Object> user02_order = jdbc.findSimpleResult("select * from activity_order_con.tb_trade_center_activity_order_0805 where consumer_id = '100108069' and duiba_activity_id = ?\n",newBetId);
Map<String,Object> user02_order = this.orderInfo(consumerId02,newBetId);
Assert.assertEquals(user02_order.get("add_credits").toString(),"","开奖后发奖值校验失败");
logger.info("用户01获取的红包值为:"+user01_order.get("add_credits").toString()+",用户02获取的红包值为:"+user02_order.get("add_credits").toString());
......@@ -136,10 +138,10 @@ public class pk_开奖_瓜分红包_押注人数相同测试_AccessTest extends
Assert.assertTrue(bet1Times>bet2Times,"活动获胜人数比失败人数多校验失败");
logger.info("选项1的押注人数为:"+bet1Result.get("bet_times").toString()+",选项2的押注人数为:"+bet2Result.get("bet_times").toString());
Map<String,Object> user01_account2 = jdbc.findSimpleResult("select * from consumer_accounts.tb_consumer_account_0804 where consumer_id = '100108068' and account_type = '6'\n");
Map<String,Object> user01_account2 = this.accountInfo(consumerId01);
Long use1_Acc2 = Long.valueOf(user01_account2.get("balance_amount").toString());
Assert.assertEquals(use1_Acc2.toString(),String.valueOf(use1_Acc1+10),"用户2入账校验失败");
Map<String,Object> user02_account2 = jdbc.findSimpleResult("select * from consumer_accounts.tb_consumer_account_0805 where consumer_id = '100108069' and account_type = '6'\n");
Map<String,Object> user02_account2 = this.accountInfo(consumerId02);
Long use2_Acc2 = Long.valueOf(user02_account2.get("balance_amount").toString());
Assert.assertEquals(use2_Acc2,use2_Acc1,"用户2入账校验失败");
......@@ -147,6 +149,23 @@ public class pk_开奖_瓜分红包_押注人数相同测试_AccessTest extends
public Map<String,Object> accountInfo(String consumerId) throws Exception{
Map<String,Object> map = new HashMap<>();
String dbName1 = GetDbName.getDbName("consumer_accounts.tb_consumer_account_",consumerId,"1");
String sql1 = "select * from "+dbName1+" where consumer_id = ? and account_type = '6'";
map = jdbc.findSimpleResult(sql1,consumerId);
return map;
}
public Map<String,Object> orderInfo(String consumerId,String betId) throws Exception{
Map<String,Object> map = new HashMap<>();
String dbName1 = GetDbName.getDbName("activity_order_con.tb_trade_center_activity_order_",consumerId,"1");
String sql1 = "select * from "+dbName1+" where consumer_id = ? and duiba_activity_id = ?\n";
map = jdbc.findSimpleResult(sql1,consumerId,betId);
return map;
}
public void createPk(String bounsType,String endTime,String groupId) throws Exception {
......@@ -184,11 +203,17 @@ public class pk_开奖_瓜分红包_押注人数相同测试_AccessTest extends
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 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 result1 = jdbc.update("delete from act_com_conf.tb_bet_option where bet_id = ?",newBetId);
Boolean result4 = jdbc.update("delete from act_record.tb_bet_record where bet_id = ?",newBetId);
Boolean result5 = jdbc.update("delete from bet_activity.tb_bet_result where bet_id = ?",newBetId);
Boolean result2 = jdbc.update("delete from act_com_conf.tb_bet_group_relation where bet_id = ?",newBetId);
Boolean result3 = jdbc.update("delete from act_com_conf.tb_bet_config where id = ?",newBetId);
......
......@@ -47,9 +47,14 @@ public class pk_管理端测试_AccessTest extends DuibaTestBase {
private String endTime = "2021-12-31 23:55:00";
private Map<String,Object> betIds = new HashMap<>();
private String groupId = "5";
private String groupId = "147";
// @Test
// public void test() throws Exception{
// Response oldBetList = pkActivityService.getMngBetList();
// oldBetList.prettyPrint();
// }
@Test
......@@ -62,7 +67,7 @@ public class pk_管理端测试_AccessTest extends DuibaTestBase {
Response newBetList = pkActivityService.getMngBetList();
String newTotal = newBetList.jsonPath().getString("data.params.total");
logger.info("创建之前的列表中条数为:"+oldTotal+"创建之后的列表中条数为:"+newTotal);
Assert.assertEquals(String.valueOf(Long.valueOf(newTotal)-1L),oldTotal,"新建之后列表获取数据校验失败");
// Assert.assertEquals(String.valueOf(Long.valueOf(newTotal)-1L),oldTotal,"新建之后列表获取数据校验失败");
List<BetMngVo> betList = newBetList.jsonPath().getList("data.page",BetMngVo.class);
logger.info("betIds"+JSON.toJSONString(betIds));
......
......@@ -35,7 +35,8 @@ public class 插件_抽奖扣积分测试_pluginTest extends DuibaTestBase {
private int uid = 3982;
private String consumerId = "100092192";
private Integer user01 = 5193;//appid=21833
private String consumerId01 = "100114050";
private static DuibaLog logger = DuibaLog.getLogger();
......@@ -67,10 +68,31 @@ public class 插件_抽奖扣积分测试_pluginTest extends DuibaTestBase {
logger.info("校验积分消耗成功,原积分值="+userCredit+",消耗后积分值为"+userCredit1);
}
@Test
public void 插件_实物有奖项库存无兑换项库存测试() throws Exception{
Map<String,Object> user = jdbc.findSimpleResult("select * from dafuweng.user where id=?\n",uid);
Map<String,Object> consumer = jdbc.findSimpleResult("select * from new_consumer.consumer_0010 where id=?\n",consumerId);
Long userCredit = Long.parseLong(user.get("credits").toString());
Long consumerCredit = Long.parseLong(consumer.get("credits").toString());
}
Response playResponse = this.playPlugin(uid,"3355");
Assert.assertEquals(playResponse.jsonPath().getString("lottery.type"),"thanks","插件抽奖的奖品类型校验失败");
logger.info("插件奖品的兑换项库存不足,降级谢谢参与成功");
Map<String,Object> user1 = jdbc.findSimpleResult("select * from dafuweng.user where id=?\n",uid);
Map<String,Object> consumer1 = jdbc.findSimpleResult("select * from new_consumer.consumer_0010 where id=?\n",consumerId);
String userCredit1 = user1.get("credits").toString();
String consumerCredit1 = consumer1.get("credits").toString();
Assert.assertEquals(userCredit1,String.valueOf(userCredit-44),"user积分扣除校验失败");
Assert.assertEquals(consumerCredit1,String.valueOf(consumerCredit-44),"consumer积分扣除校验失败");
logger.info("校验积分消耗成功,原积分值="+userCredit+",消耗后积分值为"+userCredit1);
}
......
/**
* Copyright (C), 2015-2018
* FileName: 插件_插件信息获取测试_pluginTest
* Author: qianwenjun
* Date: 2018/12/20 09:48
* Description:
*/
package http.cases.PluginActivityTest;
import base.DuibaLog;
import base.DuibaTestBase;
import http.service.Activity.ActivityPlugDrawInfoService;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.Test;
/**
* 〈〉
*
* @author qianwenjun
* @create 2018/12/20
* @since 1.0.0
*/
public class 插件_插件信息获取测试_pluginTest extends DuibaTestBase {
@Autowired
ActivityPlugDrawInfoService activityPlugDrawInfoService;
private static DuibaLog logger = DuibaLog.getLogger();
private Integer user01 = 5416;//appid=21945
private Integer user02 = 5193;//appid=21833
@Test
public void 插件_人民币展示() throws Exception{
Response response = activityPlugDrawInfoService.getPrizeInfo(user01,"3354");
response.prettyPrint();
Assert.assertEquals(response.jsonPath().getString("needMonery"),"0.88","校验插件价值人民币展示错误");
Assert.assertEquals(response.jsonPath().getString("pluginLimitCount"),"2","校验插件限制次数错误");
Assert.assertEquals(response.jsonPath().getString("limitCount"),"1","校验插件免费次数错误");
Assert.assertEquals(response.jsonPath().getString("creditsPrice"),"88","校验插件限制次数错误");
Assert.assertEquals(response.jsonPath().getString("limitScope"),"1","校验插件次数维度错误");
}
@Test
public void 插件_50汇率展示展示() throws Exception{
Response response = activityPlugDrawInfoService.getPrizeInfo(user02,"3354");
response.prettyPrint();
Assert.assertEquals(response.jsonPath().getString("needMonery"),null,"校验插件价值人民币展示错误");
Assert.assertEquals(response.jsonPath().getString("pluginLimitCount"),"2","校验插件限制次数错误");
Assert.assertEquals(response.jsonPath().getString("limitCount"),"1","校验插件免费次数错误");
Assert.assertEquals(response.jsonPath().getString("creditsPrice"),"44","校验插件限制次数错误");
Assert.assertEquals(response.jsonPath().getString("limitScope"),"1","校验插件次数维度错误");
}
}
\ No newline at end of file
......@@ -112,6 +112,7 @@ public class 插件_限制次数测试_pluginTest extends DuibaTestBase {
Assert.assertEquals(freeTimes1.get("int_value").toString(),"1","免费次数记录校验失败");
Assert.assertEquals(actcommcTimes1.get("int_value").toString(),"2","限制次数记录校验失败");
Thread.sleep(3000);
Map<String,Object> user1 = jdbc.findSimpleResult("select * from dafuweng.user where id=?\n",uid_SubCredits);
Map<String,Object> consumer1 = jdbc.findSimpleResult("select * from new_consumer.consumer_0010 where id=?\n","100060071");
String userCredit1 = user1.get("credits").toString();
......
/**
* Copyright (C), 2015-2018
* FileName: 天天秒杀_秒杀详情测试_SeckillTest
* FileName: 天天秒杀_秒杀详情测试
* Author: qianwenjun
* Date: 2018/6/20 11:46
* Description:
......@@ -36,7 +36,7 @@ import static io.restassured.RestAssured.given;
* @create 2018/6/20
* @since 1.0.0
*/
public class 天天秒杀_秒杀详情测试_SeckillTest extends DuibaTestBase {
public class 天天秒杀_秒杀详情测试 extends DuibaTestBase {
@Autowired
SeckillService seckillService;
......@@ -103,16 +103,19 @@ public class 天天秒杀_秒杀详情测试_SeckillTest extends DuibaTestBase {
Assert.assertEquals(MatcherString.getString(response.asString(),"\"success\":(.*?),",1),"true","校验详情查询结果失败");
Assert.assertEquals(MatcherString.getString(response.asString(),"\"btnStatus\":(.*?),",1),"4","校验按钮状态失败");
Assert.assertEquals(MatcherString.getString(response.asString(),"\"activityStatus\":(.*?),",1),"2","校验秒杀活动状态失败");
Assert.assertEquals(MatcherString.getString(response.asString(),"\"addrName\":\"(.*?)\",",1),"胡梦新","校验秒杀活动addrName失败");
Assert.assertEquals(MatcherString.getString(response.asString(),"\"addrPhone\":\"(.*?)\",",1),"18258853242","校验秒杀活动addrPhone失败");
logger.info("校验页面详情信息成功:按钮状态btnStatus="+MatcherString.getString(response.asString(),"\"btnStatus\":(.*?),",1)+
",活动状态activityStatus="+MatcherString.getString(response.asString(),"\"activityStatus\":(.*?),",1));
logger.info("校验收货人信息成功:收货人addrName="+MatcherString.getString(response.asString(),"\"addrName\":\"(.*?)\",",1)+
"收货人电话addrPhone="+MatcherString.getString(response.asString(),"\"addrPhone\":\"(.*?)\",",1));
String addrProvince = dESCrypto.decrypt3DE(MatcherString.getString(response.asString(),"\"addrProvince\":\"(.*?)\",",1));
String addrCity = dESCrypto.decrypt3DE(MatcherString.getString(response.asString(),"\"addrCity\":\"(.*?)\",",1));
String addrArea = dESCrypto.decrypt3DE(MatcherString.getString(response.asString(),"\"addrArea\":\"(.*?)\",",1));
String addrDetail = dESCrypto.decrypt3DE(MatcherString.getString(response.asString(),"\"addrDetail\":\"(.*?)\",",1));
Response addResponse = seckillService.getDefaultAddress(uid_Nomal);
addResponse.prettyPrint();
Assert.assertEquals(MatcherString.getString(addResponse.asString(),"\"addrName\": \"(.*?)\",",1),"胡梦新","校验秒杀活动addrName失败");
Assert.assertEquals(MatcherString.getString(addResponse.asString(),"\"addrPhone\": \"(.*?)\",",1),"18258853242","校验秒杀活动addrPhone失败");
logger.info("校验收货人信息成功:收货人addrName="+MatcherString.getString(addResponse.asString(),"\"addrName\": \"(.*?)\",",1)+
"收货人电话addrPhone="+MatcherString.getString(addResponse.asString(),"\"addrPhone\": \"(.*?)\",",1));
String addrProvince = dESCrypto.decrypt3DE(MatcherString.getString(addResponse.asString(),"\"addrProvince\": \"(.*?)\",",1));
String addrCity = dESCrypto.decrypt3DE(MatcherString.getString(addResponse.asString(),"\"addrCity\": \"(.*?)\",",1));
String addrArea = dESCrypto.decrypt3DE(MatcherString.getString(addResponse.asString(),"\"addrArea\": \"(.*?)\",",1));
String addrDetail = dESCrypto.decrypt3DE(MatcherString.getString(addResponse.asString(),"\"addrDetail\": \"(.*?)\",",1));
Assert.assertEquals(addrProvince,"浙江省","校验收货地址-省信息失败");
Assert.assertEquals(addrCity,"杭州市","校验收货地址-市信息失败");
Assert.assertEquals(addrArea,"西湖区","校验收货地址-区信息失败");
......@@ -129,12 +132,15 @@ public class 天天秒杀_秒杀详情测试_SeckillTest extends DuibaTestBase {
Assert.assertEquals(MatcherString.getString(response.asString(),"\"success\":(.*?),",1),"true","校验详情查询结果失败");
Assert.assertEquals(MatcherString.getString(response.asString(),"\"btnStatus\":(.*?),",1),"8","校验按钮状态失败");
Assert.assertEquals(MatcherString.getString(response.asString(),"\"activityStatus\":(.*?),",1),"5","校验秒杀活动状态失败");
Assert.assertEquals(MatcherString.getString(response.asString(),"\"addrName\":\"(.*?)\",",1),"胡梦新","校验秒杀活动addrName失败");
Assert.assertEquals(MatcherString.getString(response.asString(),"\"addrPhone\":\"(.*?)\",",1),"18258853242","校验秒杀活动addrPhone失败");
logger.info("校验页面详情信息成功:按钮状态btnStatus="+MatcherString.getString(response.asString(),"\"btnStatus\":(.*?),",1)+
",活动状态activityStatus="+MatcherString.getString(response.asString(),"\"activityStatus\":(.*?),",1));
logger.info("校验收货人信息成功:收货人addrName="+MatcherString.getString(response.asString(),"\"addrName\":\"(.*?)\",",1)+
"收货人电话addrPhone="+MatcherString.getString(response.asString(),"\"addrPhone\":\"(.*?)\",",1));
Response addResponse = seckillService.getDefaultAddress(uid_Nomal);
addResponse.prettyPrint();
Assert.assertEquals(MatcherString.getString(addResponse.asString(),"\"addrName\": \"(.*?)\",",1),"胡梦新","校验秒杀活动addrName失败");
Assert.assertEquals(MatcherString.getString(addResponse.asString(),"\"addrPhone\": \"(.*?)\",",1),"18258853242","校验秒杀活动addrPhone失败");
logger.info("校验收货人信息成功:收货人addrName="+MatcherString.getString(addResponse.asString(),"\"addrName\": \"(.*?)\",",1)+
"收货人电话addrPhone="+MatcherString.getString(addResponse.asString(),"\"addrPhone\": \"(.*?)\",",1));
}
......@@ -146,12 +152,15 @@ public class 天天秒杀_秒杀详情测试_SeckillTest extends DuibaTestBase {
Assert.assertEquals(MatcherString.getString(response.asString(),"\"success\":(.*?),",1),"true","校验详情查询结果失败");
Assert.assertEquals(MatcherString.getString(response.asString(),"\"btnStatus\":(.*?),",1),"10","校验按钮状态失败");
Assert.assertEquals(MatcherString.getString(response.asString(),"\"activityStatus\":(.*?),",1),"7","校验秒杀活动状态失败");
Assert.assertEquals(MatcherString.getString(response.asString(),"\"addrName\":\"(.*?)\",",1),"胡梦新","校验秒杀活动addrName失败");
Assert.assertEquals(MatcherString.getString(response.asString(),"\"addrPhone\":\"(.*?)\",",1),"18258853242","校验秒杀活动addrPhone失败");
logger.info("校验页面详情信息成功:按钮状态btnStatus="+MatcherString.getString(response.asString(),"\"btnStatus\":(.*?),",1)+
",活动状态activityStatus="+MatcherString.getString(response.asString(),"\"activityStatus\":(.*?),",1));
logger.info("校验收货人信息成功:收货人addrName="+MatcherString.getString(response.asString(),"\"addrName\":\"(.*?)\",",1)+
"收货人电话addrPhone="+MatcherString.getString(response.asString(),"\"addrPhone\":\"(.*?)\",",1));
Response addResponse = seckillService.getDefaultAddress(uid_Nomal);
addResponse.prettyPrint();
Assert.assertEquals(MatcherString.getString(addResponse.asString(),"\"addrName\": \"(.*?)\",",1),"胡梦新","校验秒杀活动addrName失败");
Assert.assertEquals(MatcherString.getString(addResponse.asString(),"\"addrPhone\": \"(.*?)\",",1),"18258853242","校验秒杀活动addrPhone失败");
logger.info("校验收货人信息成功:收货人addrName="+MatcherString.getString(addResponse.asString(),"\"addrName\": \"(.*?)\",",1)+
"收货人电话addrPhone="+MatcherString.getString(addResponse.asString(),"\"addrPhone\": \"(.*?)\",",1));
}
......@@ -169,16 +178,19 @@ public class 天天秒杀_秒杀详情测试_SeckillTest extends DuibaTestBase {
Assert.assertEquals(MatcherString.getString(response.asString(),"\"success\":(.*?),",1),"true","校验详情查询结果失败");
Assert.assertEquals(MatcherString.getString(response.asString(),"\"btnStatus\":(.*?),",1),"9","校验按钮状态失败");
Assert.assertEquals(MatcherString.getString(response.asString(),"\"activityStatus\":(.*?),",1),"6","校验秒杀活动状态失败");
Assert.assertEquals(MatcherString.getString(response.asString(),"\"addrName\":\"(.*?)\",",1),"胡梦新","校验秒杀活动addrName失败");
Assert.assertEquals(MatcherString.getString(response.asString(),"\"addrPhone\":\"(.*?)\",",1),"18258853242","校验秒杀活动addrPhone失败");
logger.info("校验页面详情信息成功:按钮状态btnStatus="+MatcherString.getString(response.asString(),"\"btnStatus\":(.*?),",1)+
",活动状态activityStatus="+MatcherString.getString(response.asString(),"\"activityStatus\":(.*?),",1));
logger.info("校验收货人信息成功:收货人addrName="+MatcherString.getString(response.asString(),"\"addrName\":\"(.*?)\",",1)+
"收货人电话addrPhone="+MatcherString.getString(response.asString(),"\"addrPhone\":\"(.*?)\",",1));
Response addResponse = seckillService.getDefaultAddress(uid_Nomal);
addResponse.prettyPrint();
Assert.assertEquals(MatcherString.getString(addResponse.asString(),"\"addrName\": \"(.*?)\",",1),"胡梦新","校验秒杀活动addrName失败");
Assert.assertEquals(MatcherString.getString(addResponse.asString(),"\"addrPhone\": \"(.*?)\",",1),"18258853242","校验秒杀活动addrPhone失败");
logger.info("校验收货人信息成功:收货人addrName="+MatcherString.getString(addResponse.asString(),"\"addrName\": \"(.*?)\",",1)+
"收货人电话addrPhone="+MatcherString.getString(addResponse.asString(),"\"addrPhone\": \"(.*?)\",",1));
}
//@Test
@Test
public void 秒杀活动页面详情_马上兑换测试() {
Response response = seckillService.ajaxInitPage("24830",uid_Nomal,true);
......@@ -186,12 +198,15 @@ public class 天天秒杀_秒杀详情测试_SeckillTest extends DuibaTestBase {
Assert.assertEquals(MatcherString.getString(response.asString(),"\"success\":(.*?),",1),"true","校验详情查询结果失败");
Assert.assertEquals(MatcherString.getString(response.asString(),"\"btnStatus\":(.*?),",1),"6","校验按钮状态失败");
Assert.assertEquals(MatcherString.getString(response.asString(),"\"activityStatus\":(.*?),",1),"3","校验秒杀活动状态失败");
Assert.assertEquals(MatcherString.getString(response.asString(),"\"addrName\":\"(.*?)\",",1),"胡梦新","校验秒杀活动addrName失败");
Assert.assertEquals(MatcherString.getString(response.asString(),"\"addrPhone\":\"(.*?)\",",1),"18258853242","校验秒杀活动addrPhone失败");
logger.info("校验页面详情信息成功:按钮状态btnStatus="+MatcherString.getString(response.asString(),"\"btnStatus\":(.*?),",1)+
",活动状态activityStatus="+MatcherString.getString(response.asString(),"\"activityStatus\":(.*?),",1));
logger.info("校验收货人信息成功:收货人addrName="+MatcherString.getString(response.asString(),"\"addrName\":\"(.*?)\",",1)+
"收货人电话addrPhone="+MatcherString.getString(response.asString(),"\"addrPhone\":\"(.*?)\",",1));
Response addResponse = seckillService.getDefaultAddress(uid_Nomal);
addResponse.prettyPrint();
Assert.assertEquals(MatcherString.getString(addResponse.asString(),"\"addrName\": \"(.*?)\",",1),"胡梦新","校验秒杀活动addrName失败");
Assert.assertEquals(MatcherString.getString(addResponse.asString(),"\"addrPhone\": \"(.*?)\",",1),"18258853242","校验秒杀活动addrPhone失败");
logger.info("校验收货人信息成功:收货人addrName="+MatcherString.getString(addResponse.asString(),"\"addrName\": \"(.*?)\",",1)+
"收货人电话addrPhone="+MatcherString.getString(addResponse.asString(),"\"addrPhone\": \"(.*?)\",",1));
}
......@@ -203,12 +218,14 @@ public class 天天秒杀_秒杀详情测试_SeckillTest extends DuibaTestBase {
Assert.assertEquals(MatcherString.getString(response.asString(),"\"success\":(.*?),",1),"true","校验详情查询结果失败");
Assert.assertEquals(MatcherString.getString(response.asString(),"\"btnStatus\":(.*?),",1),"7","校验按钮状态失败");
Assert.assertEquals(MatcherString.getString(response.asString(),"\"activityStatus\":(.*?),",1),"4","校验秒杀活动状态失败");
Assert.assertEquals(MatcherString.getString(response.asString(),"\"addrName\":\"(.*?)\",",1),"胡梦新","校验秒杀活动addrName失败");
Assert.assertEquals(MatcherString.getString(response.asString(),"\"addrPhone\":\"(.*?)\",",1),"18258853242","校验秒杀活动addrPhone失败");
logger.info("校验页面详情信息成功:按钮状态btnStatus="+MatcherString.getString(response.asString(),"\"btnStatus\":(.*?),",1)+
",活动状态activityStatus="+MatcherString.getString(response.asString(),"\"activityStatus\":(.*?),",1));
logger.info("校验收货人信息成功:收货人addrName="+MatcherString.getString(response.asString(),"\"addrName\":\"(.*?)\",",1)+
"收货人电话addrPhone="+MatcherString.getString(response.asString(),"\"addrPhone\":\"(.*?)\",",1));
Response addResponse = seckillService.getDefaultAddress(uid_Nomal);
addResponse.prettyPrint();
Assert.assertEquals(MatcherString.getString(addResponse.asString(),"\"addrName\": \"(.*?)\",",1),"胡梦新","校验秒杀活动addrName失败");
Assert.assertEquals(MatcherString.getString(addResponse.asString(),"\"addrPhone\": \"(.*?)\",",1),"18258853242","校验秒杀活动addrPhone失败");
logger.info("校验收货人信息成功:收货人addrName="+MatcherString.getString(addResponse.asString(),"\"addrName\": \"(.*?)\",",1)+
"收货人电话addrPhone="+MatcherString.getString(addResponse.asString(),"\"addrPhone\": \"(.*?)\",",1));
}
......@@ -220,12 +237,14 @@ public class 天天秒杀_秒杀详情测试_SeckillTest extends DuibaTestBase {
Assert.assertEquals(MatcherString.getString(response.asString(),"\"success\":(.*?),",1),"true","校验详情查询结果失败");
Assert.assertEquals(MatcherString.getString(response.asString(),"\"btnStatus\":(.*?),",1),"2","校验按钮状态失败");
Assert.assertEquals(MatcherString.getString(response.asString(),"\"activityStatus\":(.*?),",1),"2","校验秒杀活动状态失败");
Assert.assertEquals(MatcherString.getString(response.asString(),"\"addrName\":\"(.*?)\",",1),"钱雯君","校验秒杀活动addrName失败");
Assert.assertEquals(MatcherString.getString(response.asString(),"\"addrPhone\":\"(.*?)\",",1),"18243476362","校验秒杀活动addrPhone失败");
logger.info("校验页面详情信息成功:按钮状态btnStatus="+MatcherString.getString(response.asString(),"\"btnStatus\":(.*?),",1)+
",活动状态activityStatus="+MatcherString.getString(response.asString(),"\"activityStatus\":(.*?),",1));
logger.info("校验收货人信息成功:收货人addrName="+MatcherString.getString(response.asString(),"\"addrName\":\"(.*?)\",",1)+
"收货人电话addrPhone="+MatcherString.getString(response.asString(),"\"addrPhone\":\"(.*?)\",",1));
Response addResponse = seckillService.getDefaultAddress(uid_LackIntgral);
addResponse.prettyPrint();
Assert.assertEquals(MatcherString.getString(addResponse.asString(),"\"addrName\": \"(.*?)\",",1),"钱雯君","校验秒杀活动addrName失败");
Assert.assertEquals(MatcherString.getString(addResponse.asString(),"\"addrPhone\": \"(.*?)\",",1),"18243476362","校验秒杀活动addrPhone失败");
logger.info("校验收货人信息成功:收货人addrName="+MatcherString.getString(addResponse.asString(),"\"addrName\": \"(.*?)\",",1)+
"收货人电话addrPhone="+MatcherString.getString(addResponse.asString(),"\"addrPhone\": \"(.*?)\",",1));
Response response1 = seckillService.ajaxInitPage("24796",uid_Nomal,true);
}
......@@ -249,12 +268,15 @@ public class 天天秒杀_秒杀详情测试_SeckillTest extends DuibaTestBase {
Assert.assertEquals(MatcherString.getString(response.asString(),"\"success\":(.*?),",1),"true","校验详情查询结果失败");
Assert.assertEquals(MatcherString.getString(response.asString(),"\"btnStatus\":(.*?),",1),"5","校验按钮状态失败");
Assert.assertEquals(MatcherString.getString(response.asString(),"\"activityStatus\":(.*?),",1),"2","校验秒杀活动状态失败");
Assert.assertTrue(MatcherString.getString(response.asString(),"\"addrArea\":\"(.*?)\"",1).isEmpty(),"校验地址信息为空失败");
Assert.assertTrue(MatcherString.getString(response.asString(),"\"addrCity\":\"(.*?)\"",1).isEmpty(),"校验地址信息为空失败");
Assert.assertTrue(MatcherString.getString(response.asString(),"\"addrDetail\":\"(.*?)\"",1).isEmpty(),"校验地址信息为空失败");
Assert.assertTrue(MatcherString.getString(response.asString(),"\"addrName\":\"(.*?)\"",1).isEmpty(),"校验地址信息为空失败");
Assert.assertTrue(MatcherString.getString(response.asString(),"\"addrPhone\":\"(.*?)\"",1).isEmpty(),"校验地址信息为空失败");
Assert.assertTrue(MatcherString.getString(response.asString(),"\"addrProvince\":\"(.*?)\"",1).isEmpty(),"校验地址信息为空失败");
Response addResponse = seckillService.getDefaultAddress(uid_NoAddress);
addResponse.prettyPrint();
Assert.assertTrue(MatcherString.getString(addResponse.asString(),"\"addrArea\": \"(.*?)\"",1).isEmpty(),"校验地址信息为空失败");
Assert.assertTrue(MatcherString.getString(addResponse.asString(),"\"addrCity\": \"(.*?)\"",1).isEmpty(),"校验地址信息为空失败");
Assert.assertTrue(MatcherString.getString(addResponse.asString(),"\"addrDetail\": \"(.*?)\"",1).isEmpty(),"校验地址信息为空失败");
Assert.assertTrue(MatcherString.getString(addResponse.asString(),"\"addrName\": \"(.*?)\"",1).isEmpty(),"校验地址信息为空失败");
Assert.assertTrue(MatcherString.getString(addResponse.asString(),"\"addrPhone\": \"(.*?)\"",1).isEmpty(),"校验地址信息为空失败");
Assert.assertTrue(MatcherString.getString(addResponse.asString(),"\"addrProvince\": \"(.*?)\"",1).isEmpty(),"校验地址信息为空失败");
logger.info("校验页面详情信息成功:按钮状态btnStatus="+MatcherString.getString(response.asString(),"\"btnStatus\":(.*?),",1)+
",活动状态activityStatus="+MatcherString.getString(response.asString(),"\"activityStatus\":(.*?),",1));
logger.info("校验收货人和收货地址信息为空成功");
......
......@@ -12,6 +12,7 @@ import http.service.Authorization;
import http.service.hd.SigninService;
import io.restassured.response.Response;
import org.apache.commons.lang.StringUtils;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
......@@ -38,6 +39,21 @@ public class ContractSignCommon extends DuibaTestBase{
String activityHost;
private DuibaLog logger = DuibaLog.getLogger();
public Response queryRewardResult(String ContractId, int uid) throws Exception{
Response response = ContractSignService.queryRewardStatus(ContractId, uid);;
String rewardStatus = response.jsonPath().getString("data.rewardStatus");
int num = 10;
while (rewardStatus.equals("0") && num > 0) {
response = ContractSignService.queryRewardStatus(ContractId, uid);
rewardStatus = response.jsonPath().getString("data.rewardStatus");
if (rewardStatus.equals("2")) {
break;
}
num --;
Thread.sleep(1000);
}
return response;
}
public Map<String, String> doJoinResult(String activityId, String betAmount, int uid) throws Exception {
Response doJoinRes = ContractSignService.doJoin(activityId, betAmount, uid);
String contractId = doJoinRes.jsonPath().getString("data.contractId");
......@@ -95,39 +111,6 @@ public class ContractSignCommon extends DuibaTestBase{
}
}
public void modifyJoinTime(String actId, String date, String startTime, String endTime) throws Exception{
Map<String, Object> map = new HashMap<>();
map.put("title", "自动化_报名截止时间");
map.put("betCount", "1000");
map.put("bonusType","0");
map.put("betType","2");
map.put("bankerBonus", "10000");
map.put("ruleDesc:", "<p>bao ming&nbsp;截止时间</p>");
map.put("contractCycle","7");
map.put("joinTimeLimit", false);
map.put("fakeLimit", false);
map.put("rankPeriod","1");
map.put("joinTimeStart", startTime);
map.put("joinTimeEnd", endTime);
map.put("joinDeadLine", date);
map.put("actId", actId);
map.put("openStatus", true);
map.put("gradientAmountList","");
map.put("freeJoinLimit", "0");
map.put("enableAmpifyCard",false);
map.put("openType", "0");
JSONObject jsonObject = JSONObject.parseObject(JSON.toJSONString(map));
Response response = given().contentType("application/json;charset=UTF-8").cookies(authorization.ssoLogin()).body(jsonObject).post("https://mng.duibatest.com.cn/newmanager/signContract/save");
response.prettyPrint();
try {
Assert.assertEquals(response.jsonPath().getString("success"), "true", "/signContract/save接口失败");
} catch (Exception e) {
throw new Exception("/signContract/save接口失败,返回信息:" + response.asString());
} catch (Error er) {
throw new Exception("/signContract/save接口失败,返回信息:" + response.asString());
}
}
public void modifyIssuePeriod(String issueId, int num) throws Exception{
String sql = "select start_time,end_time from credits_sign.tb_sign_contract_issue where id=" + issueId;
Map<String, Object> result = jdbc.findSimpleResult(sql);
......
......@@ -40,9 +40,11 @@ public class ContractSign_signTest extends DuibaTestBase {
ContractSignService ContractSignService;
@Autowired
ManagerService managerService;
@Autowired
ContractSignCommon ContractSignCommon;
@Value("${activity.host}")
String activityHost;
private String period;
private String period_tomorrow,period;
private String issueId;
// private static DuibaLog logger = DuibaLog.getLogger();
......@@ -102,7 +104,9 @@ public class ContractSign_signTest extends DuibaTestBase {
calendar.add(Calendar.DAY_OF_YEAR, 1);
date = calendar.getTime();
// 期次号 MMDD格式
period = format.format(date);
period_tomorrow = format.format(date);
calendar.add(Calendar.DAY_OF_YEAR,-8);
period = format.format(calendar.getTime());
Response homeInfoRes = ContractSignService.getHomeInfo(actId, uid1);
int contractCycle = homeInfoRes.jsonPath().getInt("data.contractCycle");
Assert.assertEquals(contractCycle, 7, "周期天数不正确");
......@@ -115,10 +119,10 @@ public class ContractSign_signTest extends DuibaTestBase {
int buyers = homeInfoRes.jsonPath().getInt("data.buyers");
Assert.assertEquals(buyers, 0,"报名人数不正确");
String periodShow = homeInfoRes.jsonPath().getString("data.periodShow");
Assert.assertEquals(periodShow, period, "活动期次号不正确");
Assert.assertEquals(periodShow, period_tomorrow, "活动期次号不正确");
}
@Test(description = "契约签到报名测试, 活动ID=2" ,priority = 2)
@Test(description = "契约签到报名测试, 活动ID=2" ,priority = 2,dependsOnMethods = { "签到活动信息" })
public void 固定额度报名() throws Exception {
String actId = "2";
String betAmount = "1000";
......@@ -162,7 +166,7 @@ public class ContractSign_signTest extends DuibaTestBase {
int buyers_new = Integer.valueOf(homeInfoRes.jsonPath().getString("data.buyers"));
Assert.assertEquals(buyers_new, 4,"报名人数未增加");
String periodShow = homeInfoRes.jsonPath().getString("data.periodShow");
Assert.assertEquals(periodShow, period, "参与期次号不正确");
Assert.assertEquals(periodShow, period_tomorrow, "参与期次号不正确");
String currentPeriod = homeInfoRes.jsonPath().getString("data.currentPeriod");
Assert.assertEquals(currentPeriod, "0", "当前期次进度不正确");
//0-未报名 1-报名中 2-已报名,打卡未开始 3-未打卡:打卡开始,当天未打卡 4-已打卡:当天已打卡(非最后一天) 5-失败:出现断卡(未报名新一期) 6-成功: 已成功(未报名新一期)
......@@ -173,7 +177,7 @@ public class ContractSign_signTest extends DuibaTestBase {
}
@Test(description = "活动ID=2, uid1打卡", priority = 3)
@Test(description = "活动ID=2, uid1打卡", priority = 3,dependsOnMethods = { "固定额度报名" })
public void 固定额度签到打卡() throws Exception{
String actId = "2";
//修改期次,今日为打卡日
......@@ -201,7 +205,7 @@ public class ContractSign_signTest extends DuibaTestBase {
Assert.assertEquals(status, "4", "打卡完成后状态不正确");
}
@Test(description = "活动ID=2,uid2第六天断签", priority = 4)
@Test(description = "活动ID=2,uid2第六天断签", priority = 4,dependsOnMethods = { "固定额度签到打卡" })
public void 固定额度断签() throws Exception{
String actId = "2";
//当天为周期第一天,周期往前再挪6天
......@@ -226,7 +230,7 @@ public class ContractSign_signTest extends DuibaTestBase {
}
@Test(description = "uid3 uid4打卡完成,活动ID=2",priority = 5)
@Test(description = "uid3 uid4打卡完成,活动ID=2",priority = 5,dependsOnMethods = { "固定额度断签" })
public void 固定额度_整期打卡完成() throws Exception{
String actId = "2";
//补签前6天
......@@ -249,7 +253,7 @@ public class ContractSign_signTest extends DuibaTestBase {
Assert.assertEquals(success, "true", "uid4打卡失败");
logger.info("uid4七日打卡成功");
homeInfoRes = ContractSignService.getHomeInfo(actId,uid4);
homeInfoRes.prettyPrint();
//homeInfoRes.prettyPrint();
status = homeInfoRes.jsonPath().getString("data.status");
Assert.assertEquals(status,"6","完成7日打卡状态不正确");
String hasReward = homeInfoRes.jsonPath().getString("data.hasReward");
......@@ -259,7 +263,7 @@ public class ContractSign_signTest extends DuibaTestBase {
}
@Test(description = "开奖,活动ID=2",priority = 6)
@Test(description = "开奖,活动ID=2",priority = 6,dependsOnMethods = { "固定额度_整期打卡完成" })
public void 契约开奖_固定额度() throws Exception{
String actId = "2";
modifyIssuePeriod(issueId, -1);
......@@ -270,7 +274,7 @@ public class ContractSign_signTest extends DuibaTestBase {
Response homeInfoRes = ContractSignService.getHomeInfo(actId, uid3);
//homeInfoRes.prettyPrint();
String periodShow = homeInfoRes.jsonPath().getString("data.periodShow");
Assert.assertEquals(periodShow, period, "参与期次号不正确");
Assert.assertEquals(periodShow, period_tomorrow, "参与期次号不正确");
String status = homeInfoRes.jsonPath().getString("data.status");
Assert.assertEquals(status, "6", "当前参与状态不正确");
String hasReward = homeInfoRes.jsonPath().getString("data.hasReward");
......@@ -280,28 +284,55 @@ public class ContractSign_signTest extends DuibaTestBase {
String contractId = recordRes.jsonPath().getString("data.list[0].contractId");
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, "7000", "瓜分奖励金额不正确");
// 领奖
int winCount = recordRes.jsonPath().getInt("data.list[0].winCount");
Assert.assertEquals(winCount, 7000, "瓜分奖励金额不正确");
//领奖前查询领取状态
Response rewardStatusRes = ContractSignService.queryRewardStatus(contractId, uid3);
int rewardStatus = rewardStatusRes.jsonPath().getInt("data.rewardStatus");
Assert.assertEquals(rewardStatus,0,"uid3领取奖励前状态不正确");
// uid3领奖
Response rewardRes = ContractSignService.getReward(contractId,uid3);
String rewardStatus = rewardRes.jsonPath().getString("success");
String rewardAmount = rewardRes.jsonPath().getString("data");
Assert.assertEquals(rewardStatus,"true","领取奖励结果不正确");
String rewardResult = rewardRes.jsonPath().getString("success");
int rewardAmount = rewardRes.jsonPath().getInt("data");
Assert.assertEquals(rewardResult,"true","领取奖励结果不正确");
Assert.assertEquals(rewardAmount,winCount,"领取奖励金额不正确");
//再次查询参与记录
recordRes = ContractSignService.getContracts(actId, uid3);
doneStatus = recordRes.jsonPath().getString("data.list[0].doneStatus");
Assert.assertEquals(doneStatus, "REWARD", "当前期次完成状态不正确");
winCount = recordRes.jsonPath().getString("data.list[0].winCount");
Assert.assertEquals(winCount, "7000", "显示领取金额不正确");
Response queryRewardRes = ContractSignCommon.queryRewardResult(contractId, uid3);
rewardStatus = queryRewardRes.jsonPath().getInt("data.rewardStatus");
Assert.assertEquals(rewardStatus,2,"uid3领取奖励失败");
int winCount2 = queryRewardRes.jsonPath().getInt("data.winCount");
Assert.assertEquals(winCount2, winCount,"uid3 待领取奖励积分不正确");
int betCount = queryRewardRes.jsonPath().getInt("data.betCount");
Assert.assertEquals(betCount,14000,"参与期次奖池数不正确");
int userBetCount = queryRewardRes.jsonPath().getInt("data.userBetCount");
Assert.assertEquals(userBetCount,1000,"uid3报名金额显示不正确");
int buyers = queryRewardRes.jsonPath().getInt("data.buyers");
Assert.assertEquals(buyers,4,"期次报名人数不正确");
int winners = queryRewardRes.jsonPath().getInt("data.winners");
Assert.assertEquals(winners, 2, "期次完成人数不正确");
String issueNo = queryRewardRes.jsonPath().getString("data.issueNo");
Assert.assertEquals(issueNo, period, "参与期次号不正确");
//uid4领奖
recordRes = ContractSignService.getContracts(actId, uid4);
contractId = recordRes.jsonPath().getString("data.list[0].contractId");
ContractSignService.getReward(contractId,uid4);
queryRewardRes = ContractSignCommon.queryRewardResult(contractId, uid4);
rewardStatus = queryRewardRes.jsonPath().getInt("data.rewardStatus");
Assert.assertEquals(rewardStatus,2,"uid3领取奖励失败");
//再次查询参与记录
recordRes = ContractSignService.getContracts(actId, uid3);
doneStatus = recordRes.jsonPath().getString("data.list[0].doneStatus");
Assert.assertEquals(doneStatus, "REWARD", "当前期次完成状态不正确");
winCount = recordRes.jsonPath().getInt("data.list[0].winCount");
Assert.assertEquals(winCount, 7000, "显示领取金额不正确");
}
@Test(description = "打卡/收益排行榜,活动ID=2",priority = 7)
@Test(description = "参与记录,活动ID=2",priority = 7,dependsOnMethods = { "契约开奖_固定额度" })
public void 参与记录() throws Exception{
// 查询断签用户参与记录
Response recordRes = ContractSignService.getContracts("2", uid2);
......@@ -335,7 +366,7 @@ public class ContractSign_signTest extends DuibaTestBase {
Assert.assertEquals(totalProfit, 7000,"累计收益不正确");
}
@Test(description = "打卡/收益排行榜,活动ID=2",priority = 8)
@Test(description = "打卡/收益排行榜,活动ID=2",priority = 8,dependsOnMethods = { "参与记录" })
public void 排行榜() throws Exception{
String actId = "2";
//查询签到次数排行榜
......@@ -357,20 +388,24 @@ public class ContractSign_signTest extends DuibaTestBase {
Response rewardResponse = ContractSignService.getContractRank(actId, 10, 2, uid3);
String status2 = rewardResponse.jsonPath().getString("success");
Assert.assertEquals(status2, "true", "打卡次数排行榜查询失败");
String rank2 = rewardResponse.jsonPath().getString("data.rankList[1]");
String userInfo2 = rewardResponse.jsonPath().getString("data.user");
int userRank2 = rewardResponse.jsonPath().getInt("data.user.rank");
int userAmount2 = rewardResponse.jsonPath().getInt("data.user.amount");
int userId2 = rewardResponse.jsonPath().getInt("data.user.consumerId");
String nickName2 = rewardResponse.jsonPath().getString("data.user.nickName");
Assert.assertEquals(userInfo2,rank2);
Assert.assertEquals(userRank2, 2, "用户收益排名不正确");
//Assert.assertEquals(userAmount2, 6000, "收益金额不正确");
Assert.assertEquals(userId2, 100085019, "consumerId不正确");
Assert.assertEquals(nickName2,"Auto3720","用户名不正确");
}
@Test(description = "中奖轮播",priority = 9)
int rankNum1 = rewardResponse.jsonPath().getInt("data.rankList[0].rank");
int rankNum2 = rewardResponse.jsonPath().getInt("data.rankList[1].rank");
nickName1 = rewardResponse.jsonPath().getString("data.rankList[0].nickName");
String nickName2 = rewardResponse.jsonPath().getString("data.rankList[1].nickName");
Assert.assertEquals(rankNum1,1,"排行榜第一名显示不正确");
Assert.assertEquals(rankNum2,2,"排行榜第二名显示不正确");
// String userInfo2 = rewardResponse.jsonPath().getString("data.user");
// int userRank2 = rewardResponse.jsonPath().getInt("data.user.rank");
// int userAmount2 = rewardResponse.jsonPath().getInt("data.user.amount");
// int userId2 = rewardResponse.jsonPath().getInt("data.user.consumerId");
String nickName3 = rewardResponse.jsonPath().getString("data.user.nickName");
String arr[] = {nickName1, nickName2};
Assert.assertTrue(isInArrray(arr,nickName3),"用户不在排行榜上");
}
@Test(description = "中奖轮播",priority = 9,dependsOnMethods = { "排行榜" })
public void 中奖轮播_固定额度() throws Exception{
//删除redis key
// Map<String, String> carouselMap = new HashMap<>();
......@@ -389,7 +424,13 @@ public class ContractSign_signTest extends DuibaTestBase {
Assert.assertEquals(nickname1, "Auto3721");
Assert.assertEquals(winCount1, "7000");
}
public static boolean isInArrray(String[] arr,String targetValue){
for(String s:arr){
if(s.equals(targetValue))
return true;
}
return false;
}
public Map<String, String> doJoinResult(String activityId, String betAmount, int uid) throws Exception {
Response doJoinRes = ContractSignService.doJoin(activityId, betAmount, uid);
String contractId = doJoinRes.jsonPath().getString("data.contractId");
......@@ -458,6 +499,8 @@ public class ContractSign_signTest extends DuibaTestBase {
map.put("freeJoinLimit", "0");
map.put("enableAmpifyCard",false);
map.put("openType", "0");
map.put("skinType","0");
map.put("skinId","46");
JSONObject jsonObject = JSONObject.parseObject(JSON.toJSONString(map));
Response response = given().contentType("application/json;charset=UTF-8").cookies(authorization.ssoLogin()).body(jsonObject).post("https://mng.duibatest.com.cn/newmanager/signContract/save");
//response.prettyPrint();
......
......@@ -173,7 +173,7 @@ public class SingleLottery_AccessTest extends DuibaTestBase {
}
Assert.assertEquals(flowWork,"SupplierExchange-started","数据库主订单流程节点校验失败");
Assert.assertEquals(String.valueOf(selectResult2.get("item_id")),"27131","数据库主订单奖项id校验失败");
Assert.assertEquals(String.valueOf(selectResult2.get("biz_params")),"胡梦新:18258853242:浙江省:杭州市:西湖区:数娱大厦","数据库主订单biz_params校验失败");
Assert.assertEquals(String.valueOf(selectResult2.get("biz_params")),"胡梦新:18258853242:浙江:杭州市:西湖区:西溪街道:数娱大厦 ","数据库主订单biz_params校验失败");
Assert.assertEquals(String.valueOf(selectResult2.get("pay_status")),"prereduce","数据库主订单pay_status校验失败");
Assert.assertEquals(String.valueOf(selectResult2.get("status")),"consume_success","数据库主订单status校验失败");
......
......@@ -2,7 +2,10 @@ package http.cases.SingleLotteryTest;
import base.DuibaLog;
import base.DuibaTestBase;
import http.service.Activity.SingleLotteryService;
import http.service.Authorization;
import http.service.hd.SigninService;
import io.restassured.http.Cookies;
import io.restassured.internal.assertion.Assertion;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -10,12 +13,20 @@ import org.testng.Assert;
import org.testng.annotations.Test;
import utils.MatcherString;
import java.util.Map;
import static io.restassured.RestAssured.given;
/**
* Created by zhaoran on 2018/6/8.
*/
public class 预览单品抽奖_AccessTest extends DuibaTestBase {
@Autowired
SigninService signinService;
@Autowired
SingleLotteryService singleLotteryService;
@Autowired
Authorization authorization;
private static DuibaLog logger = DuibaLog.getLogger();
@Test
......@@ -25,6 +36,14 @@ public class 预览单品抽奖_AccessTest extends DuibaTestBase {
logger.info("预览url为:"+url);
Assert.assertEquals(url.contains("http://activity.m.duibatest.com.cn/autoLogin/autologin?appKey=BDqysEMghRqpDWAaQu9S4rLihHm&uid=duiba-preview-user"), true, "校验是否展示马上使用失败");
//获取预发场景cookie
Response responses = authorization.previewLogin("BDqysEMghRqpDWAaQu9S4rLihHm","3G9A4pn8M2gVQQJbieW3CF8LRHM4");
//打开活动界面
response = singleLotteryService.index_preview("36732","preview","login",responses.getDetailedCookies());
//判断结果
Assert.assertEquals(MatcherString.getString(response.asString(),"<title>(.*?)</title>",1),"自动化_预览单抽","活动页打开异常!");
logger.info("活动页面打开成功");
}
......
/**
* Copyright (C), 2015-2018
* FileName: BetMngVo
* Author: qianwenjun
* Date: 2018/8/5 10:12
* Description:
*/
package http.model;
import java.util.List;
/**
* @author 赵然
* @create 2018/12/11
* @since 1.0.0
*/
public class BetDevelopVo {
public List<BetOptionVo> getBetOptionDtoList() {
return betOptionDtoList;
}
public void setBetOptionDtoList(List<BetOptionVo> betOptionDtoList) {
this.betOptionDtoList = betOptionDtoList;
}
private List<BetOptionVo> betOptionDtoList;
private String betType; //'押注类型 1-单选单次,2-多选无限制'
private String bonusAmount; //'每人实际分得金额'
private String bonusType; //'瓜分类型1瓜分经验2瓜分红包3发奖品4瓜分积分'
private String configStatus; //'投注活动的状态:1关闭不可见2关闭可见3开启4结束'
private String creditsValue; //'积分价值'
private String endTime; //'活动结束时间'
private String shareExp; //'瓜分的经验池'
private String startTime; // '活动开始时间'
private String title; //'投注活动标题'
// private String id; //主键
// private String pluginId; //'发奖品时需要填插件id'
// private String prizeLimit; //'发奖品时的发放上限'
// public String getPluginId() {
// return pluginId;
// }
//
// public void setPluginId(String pluginId) {
// this.pluginId = pluginId;
// }
//
// public String getPrizeLimit() {
// return prizeLimit;
// }
// public void setPrizeLimit(String prizeLimit) {
// this.prizeLimit = prizeLimit;
// }
public String getBetType() {
return betType;
}
public void setBetType(String betType) {
this.betType = betType;
}
public String getBonusAmount() {
return bonusAmount;
}
public void setBonusAmount(String bonusAmount) {
this.bonusAmount = bonusAmount;
}
public String getBonusType() {
return bonusType;
}
public void setBonusType(String bonusType) {
this.bonusType = bonusType;
}
public String getConfigStatus() {
return configStatus;
}
public void setConfigStatus(String configStatus) {
this.configStatus = configStatus;
}
public String getCreditsValue() {
return creditsValue;
}
public void setCreditsValue(String creditsValue) {
this.creditsValue = creditsValue;
}
public String getEndTime() {
return endTime;
}
public void setEndTime(String endTime) {
this.endTime = endTime;
}
public String getShareExp() {
return shareExp;
}
public void setShareExp(String shareExp) {
this.shareExp = shareExp;
}
public String getStartTime() {
return startTime;
}
public void setStartTime(String startTime) {
this.startTime = startTime;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
}
\ No newline at end of file
......@@ -19,7 +19,7 @@ public class BetOptionVo {
private String optionImg;
private String optionName;
private String rightAnswer;
public String getOptionImg() {
return optionImg;
......@@ -37,5 +37,11 @@ public class BetOptionVo {
this.optionName = optionName;
}
public String getRightAnswer() {
return rightAnswer;
}
public void setRightAnswer(String rightAnswer) {
this.rightAnswer = rightAnswer;
}
}
\ No newline at end of file
......@@ -142,4 +142,24 @@ public class ActivityPlugDrawInfoService {
return response;
}
public Response getPrizeInfo(int uid,String activityId) throws Exception {
Map<String,String> map = new HashMap<>();
map.put("activityId",activityId);
logger.info("请求getPrizeInfo接口,orderId="+activityId);
Response response = given().cookies(authorization.dafuwengLogin(uid)).params(map).post(activityHost+"/plugin/getPrizeInfo");
Assert.assertEquals(response.jsonPath().getString("success"),"true");
try{
Assert.assertEquals(response.jsonPath().getString("success"),"true");
}catch(Exception e){
throw new Exception("/activityPlugDrawInfo/getOrderStatusPlugdraw接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/activityPlugDrawInfo/getOrderStatusPlugdraw接口失败,返回信息:"+response.asString());
}
return response;
}
}
......@@ -205,7 +205,7 @@ public class ContractSignService {
public Response getReward(String ContractId, int uid) throws Exception{
Map<String, String> map = new HashMap<>();
map.put("contractId", ContractId);
logger.info("请求getReward接口,签到活动id=" + ContractId);
logger.info("请求getReward接口,契约id=" + ContractId);
Response response = given().cookies(authorization.dafuwengLogin(uid)).params(map).post(activityHost+"/sign/contract/getReward");
try{
Assert.assertEquals(response.jsonPath().getString("success"), "true", "/sign/contract/getReward接口请求失败");
......@@ -216,4 +216,26 @@ public class ContractSignService {
}
return response;
}
/**
* 针对瓜分积分的模式
* @param ContractId
* @param uid
* @return
* @throws Exception
*/
public Response queryRewardStatus(String ContractId, int uid) throws Exception{
Map<String, String> map = new HashMap<>();
map.put("contractId", ContractId);
logger.info("请求queryRewardStatus接口,契约id=" + ContractId);
Response response = given().cookies(authorization.dafuwengLogin(uid)).params(map).get(activityHost+"/sign/contract/queryRewardStatus");
try{
Assert.assertEquals(response.jsonPath().getString("success"), "true", "/sign/contract/queryRewardStatus接口请求失败");
} catch (Exception e){
throw new Exception("/sign/contract/queryRewardStatus接口失败,返回信息" + response.asString());
} catch (Error er) {
throw new Exception("/sign/contract/queryRewardStatus接口失败,返回信息" + response.asString());
}
return response;
}
}
......@@ -38,7 +38,45 @@ public class PkService {
String activityHost;
private DuibaLog logger = DuibaLog.getLogger();
public Response popup(Integer uid) throws Exception{
String url = activityHost + "/betActivity2/popup";
Map<String,Object> map = new HashMap<>();
map.put("pageNo","1");
map.put("pageSize","6");
Response response = given().cookies(authorization.dafuwengLogin(uid)).params(map).get(url);
// response.prettyPrint();
try{
Assert.assertEquals(response.jsonPath().getString("success"),"true");
}catch(Exception e){
throw new Exception("手机端获取pk结果接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("手机端获取pk结果接口失败,返回信息:"+response.asString());
}
return response;
}
public Response list(Integer uid) throws Exception{
String url = activityHost + "/betRecord2/list";
Map<String,Object> map = new HashMap<>();
map.put("pageNo","1");
map.put("pageSize","6");
Response response = given().cookies(authorization.dafuwengLogin(uid)).params(map).get(url);
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;
}
public Response getBetList(Integer uid) throws Exception{
String url = activityHost + "/betActivity2/list";
......
......@@ -89,7 +89,25 @@ public class SingleLotteryService {
}
return response;
}
public Response index_preview(String atcId,String type,String from,Cookies cookies) throws Exception {
Map<String,String> map = new HashMap<>();
map.put("id",atcId);
map.put("type",type);
map.put("from",from);
map.put("spm","18714.1.1.1");
logger.info("请求/singleLottery/index接口,id=" + atcId);
Response response = given().cookies(cookies).params(map).get("https://activity.m.duibatest.com.cn" + "/singleLottery/index");
try{
Assert.assertEquals(String.valueOf(response.getStatusCode()),"200","活动页打开异常");
}catch(Exception e){
throw new Exception("/singleLottery/index接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/singleLottery/index接口失败,返回信息:"+response.asString());
}
return response;
}
//访问开发者自有手动开奖
public Response index_sd(String atcId) throws Exception {
Map<String,String> map = new HashMap<>();
......
......@@ -56,6 +56,7 @@ public class Authorization {
private static Map<String,String> hdCookiesMabo;
private static Map<String,String> hdCookiesSaas;
private static Map<String,Map> hdCookiesSaasByApp = new ConcurrentHashMap<>();
private static Map<String,Map> hdCookiesSaasNew = new ConcurrentHashMap<>();
private static Map<String,Map> hdCookiesCommon = new ConcurrentHashMap<>();
private static Map<String,String> openbsCookies;
private Map<String,String> ssoCookies =null;
......@@ -173,6 +174,20 @@ public class Authorization {
return response;
}
public Response previewLogin(String appKey,String appSecret){
CreditTool tool=new CreditTool(appKey, appSecret);
Map params=new HashMap();
params.put("uid","duiba-preview-user");
String url=tool.buildUrlWithSign("http://activity.m.duibatest.com.cn/autoLogin/autologin?",params);
logger.info("dafuweng免登陆url为:"+url);
Response response=given().redirects().follow(false).get(url);
logger.info("dafuweng免登陆,响应数据:"+response.asString());
logger.info("dafuweng免登陆,响应状态码:"+response.getStatusCode());
return response;
}
public Map generateSignAutoLogin(String appKey, int uid){
String url = "http://activity.m.duibatest.com.cn/test/generateSign?appKey=" + appKey + "&uid=" + uid + "&vip=5";
Response response = given().get(url);
......@@ -227,6 +242,7 @@ public class Authorization {
return hdCookiesMabo;
}
//密码为wxs123456 (支持账号 wxs@duiba.com.cn,尽量不要用)
public Map hdLoginSaas(){
int i=10;
while((hdCookiesSaas==null||hdCookiesSaas.size()==0)&&i>0) {
......@@ -247,6 +263,7 @@ public class Authorization {
return hdCookiesSaas;
}
//密码为wxs123456 (支持 账号为wxs@duiba.com.cn 下的任意appId)
public Map hdLoginSaas(String appId){
int i=10;
logger.info("hdCookiesSaasByApp cookies:"+hdCookiesSaasByApp.toString());
......@@ -264,7 +281,7 @@ public class Authorization {
Map<String,String> map = response.getCookies();
logger.info("cookies:"+map.toString());
hdCookies=new HashMap<>(response.getCookies());
if(hdCookies!=null||hdCookies.size()!=0) {
if(hdCookies!=null&&hdCookies.size()!=0) {
//取消安全校验
hdCookies.remove("csrf_token");
hdCookies.put("appId", appId);
......@@ -278,7 +295,44 @@ public class Authorization {
logger.info("hdCookiesSaasByApp cookies集合:"+hdCookiesSaasByApp.toString());
return hdCookies;
}
//密码为duibaduiba123
//密码为duibaduiba123(支持任意手机账号下的任意APPId)
public Map hdLoginSaasNew(String account,String appId){
String path = "/doLoginNew";
int i=10;
logger.info("hdCookiesSaasByApp cookies:"+hdCookiesSaasNew.toString());
Map<String,String> hdCookies = hdCookiesSaasNew.get(appId);
while((hdCookies==null||hdCookies.size()==0)&&i>0) {
Response token=this.hdGetToken();
String url = PROTOCOL + hdHost + path;
Map<String,String> cookies=token.getCookies();
Map<String, String> paras = new HashMap<>();
paras.put("account", account);
paras.put("password", SecurityUtils.getMD5("Dct7xTdGPvbUL1eOtSWoB9ySZNY="+from(token.asString()).getString("data.loginsToken")));
paras.put("redirect", "/redirectApp");
paras.put("isAutoLogin", "true");
paras.put("validate","22");
Response response = given().cookies(cookies).params(paras).post(url);
response.prettyPrint();
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());
hdCookiesSaasNew.put(appId,hdCookies);
}
i--;
}
logger.info("hdCookiesSaasByApp cookies集合:"+hdCookiesSaasNew.toString());
return hdCookies;
}
//密码为duibaduiba123 (支持任意邮箱账号)
public Map hdLoginCommon(String email){
int i=10;
Map<String,String> hdCookies = hdCookiesCommon.get(email);
......@@ -293,7 +347,7 @@ public class Authorization {
paras.put("isAutoLogin", "true");
Response response = given().cookies(cookies).params(paras).post(url);
hdCookies=new HashMap<>(response.getCookies());
if(hdCookies!=null||hdCookies.size()!=0){
if(hdCookies!=null&&hdCookies.size()!=0){
hdCookies.remove("csrf_token");
hdCookiesCommon.put(email,hdCookies);
}
......@@ -323,14 +377,13 @@ public class Authorization {
Response response = given().cookies(cookies).params(paras).post(url);
response.prettyPrint();
hdCookies=new HashMap<>(response.getCookies());
if(hdCookies!=null||hdCookies.size()!=0){
if(hdCookies!=null&&hdCookies.size()!=0){
hdCookies.remove("csrf_token");
hdCookiesCommon.put(account,hdCookies);
}
i--;
}
//取消安全校验
// logger.info(hdCookies);
return hdCookies;
}
......@@ -352,6 +405,7 @@ public class Authorization {
Map<String, String> paras = new HashMap<>();
paras.put("email", ssoName);
paras.put("password", ssoPassword);
paras.put("loginTimeout", "1");
paras.put("systemId", "1");
paras.put("redirect", "http://mng.duibatest.com.cn/AItem/index.htm");
......
......@@ -25,6 +25,9 @@ public class SeckillService {
@Value("${home.host}")
private String homeHost;
@Value("${activity.host}")
String activityHost;
@Autowired
Authorization authorization;
......@@ -183,6 +186,15 @@ public class SeckillService {
}
public Response getDefaultAddress(Integer uid) {
String url = activityHost + "/gaw/address/getDefaultAddress";
Map<String,Object> map = new HashMap<>();
// map.put("id",id);
Response response = given().cookies(authorization.dafuwengLogin(uid)).params(map).get(url);
return response;
}
public Boolean checkNomal(String api,Response response) {
......
......@@ -13,7 +13,7 @@ import static io.restassured.RestAssured.given;
*/
@Service
public class SupplierExchangeTemplateService {
private String dafuwengHost = "47.97.214.108";
private String dafuwengHost = "dafuweng.duibatest.com.cn";
public Response use(String id){
String url = "http://"+dafuwengHost+"/supplierExchangeTemplate/use";
......
package http.service.hd;
import base.DuibaLog;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import http.model.BetOptionVo;
import http.model.BetDevelopVo;
import http.service.Authorization;
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.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.testng.Assert;
import utils.MatcherString;
import utils.PublicMethod;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static io.restassured.RestAssured.given;
/**
* @author zhaoran
* @create 2018/12/11
* @since 1.0.0
*/
@Service
public class PkDevelopService {
@Value("${hdserver.host}")
String hdHost;
@Value("${manager.host}")
String ManagerHost;
@Autowired
Authorization authorization;
public Response betEditor(String appId,String bonusType,String bonusAmount,String creditsValue,String shareExp) throws Exception{
String data = PublicMethod.data();
String url = "http://" + hdHost + "/visual-editor/bet/post";
//创建投注项
List<BetOptionVo> betOptionVoList = new ArrayList<>();
BetOptionVo betOptionVo1 = new BetOptionVo();
BetOptionVo betOptionVo2 = new BetOptionVo();
betOptionVo1.setOptionImg("//yun.dui88.com/images/201812/75j84chnkg.jpg");
betOptionVo1.setOptionName("1");
betOptionVo1.setRightAnswer(null);
betOptionVo2.setOptionImg("//yun.dui88.com/images/201812/4f51vmzfpu.png");
betOptionVo2.setOptionName("2");
betOptionVo2.setRightAnswer(null);
betOptionVoList.add(betOptionVo1);
betOptionVoList.add(betOptionVo2);
//创建活动配置
List<BetDevelopVo> betDevelopVoList = new ArrayList<>();
BetDevelopVo betDevelopVo = new BetDevelopVo();
betDevelopVo.setBetOptionDtoList(betOptionVoList);
betDevelopVo.setBetType("1");
betDevelopVo.setBonusType(bonusType);
if (bonusType.equals("2")){
betDevelopVo.setTitle("【自动化】组件pk_瓜分红包"+data);
}else if (bonusType.equals("4")){
betDevelopVo.setTitle("【自动化】组件pk_瓜分积分"+data);
}
betDevelopVo.setBonusAmount(bonusAmount);
betDevelopVo.setConfigStatus("3");
betDevelopVo.setCreditsValue(creditsValue);
betDevelopVo.setEndTime("2029-12-31 00:00");
betDevelopVo.setShareExp(shareExp);
betDevelopVoList.add(betDevelopVo);
Map<String,Object> para = new HashMap<>();
para.put("list",betDevelopVoList);
para.put("rules","自动化规则自动化规则");
para.put("title","组件pk自动化");
JSONObject jsonParam = JSONObject.parseObject(JSON.toJSONString(para));
Response betResponse = given().contentType("application/json;charset=UTF-8").cookies(authorization.hdLoginSaas(appId)).body(jsonParam).post(url);
betResponse.prettyPrint();
try{
Assert.assertEquals(betResponse.jsonPath().getString("success"),"true");
}catch(Exception e){
throw new Exception("创建pk活动接口失败,返回信息:"+betResponse.asString());
}catch(Error er){
throw new Exception("创建pk活动接口失败,返回信息:"+betResponse.asString());
}
return betResponse;
}
public Response betEditor_right(String account,String appId,String bonusType,String bonusAmount,String creditsValue,String shareExp,String loser,String winner) throws Exception{
String data = PublicMethod.data();
String url = "http://" + hdHost + "/visual-editor/bet/post";
//创建投注项
List<BetOptionVo> betOptionVoList = new ArrayList<>();
BetOptionVo betOptionVo1 = new BetOptionVo();
BetOptionVo betOptionVo2 = new BetOptionVo();
betOptionVo1.setOptionImg("//yun.dui88.com/images/201812/75j84chnkg.jpg");
betOptionVo1.setOptionName("1");
betOptionVo1.setRightAnswer(loser);
betOptionVo2.setOptionImg("//yun.dui88.com/images/201812/4f51vmzfpu.png");
betOptionVo2.setOptionName("2");
betOptionVo2.setRightAnswer(winner);
betOptionVoList.add(betOptionVo1);
betOptionVoList.add(betOptionVo2);
//创建活动配置
List<BetDevelopVo> betDevelopVoList = new ArrayList<>();
BetDevelopVo betDevelopVo = new BetDevelopVo();
betDevelopVo.setBetOptionDtoList(betOptionVoList);
betDevelopVo.setBetType("1");
betDevelopVo.setBonusType(bonusType);
if (bonusType.equals("2")){
betDevelopVo.setTitle("【自动化】组件pk_瓜分红包"+data);
}else if (bonusType.equals("4")){
betDevelopVo.setTitle("【自动化】组件pk_瓜分积分"+data);
}
betDevelopVo.setBonusAmount(bonusAmount);
betDevelopVo.setConfigStatus("3");
betDevelopVo.setCreditsValue(creditsValue);
betDevelopVo.setEndTime("2029-12-31 00:00");
betDevelopVo.setShareExp(shareExp);
betDevelopVoList.add(betDevelopVo);
Map<String,Object> para = new HashMap<>();
para.put("list",betDevelopVoList);
para.put("rules","自动化规则自动化规则");
para.put("title","组件pk自动化_主胜方");
JSONObject jsonParam = JSONObject.parseObject(JSON.toJSONString(para));
Response betResponse = given().contentType("application/json;charset=UTF-8").cookies(authorization.hdLoginSaasNew(account,appId)).body(jsonParam).post(url);
betResponse.prettyPrint();
try{
Assert.assertEquals(betResponse.jsonPath().getString("success"),"true");
}catch(Exception e){
throw new Exception("创建pk活动接口失败,返回信息:"+betResponse.asString());
}catch(Error er){
throw new Exception("创建pk活动接口失败,返回信息:"+betResponse.asString());
}
return betResponse;
}
public Response doDraw() throws Exception{
String url = "http://" + ManagerHost + "/newmanager/betOpenPrize/doDraw";
Map<String,Object> para = new HashMap<>();
// para.put("pageNo","1");
// para.put("pageSize","20");
Response doDrawResponse = given().cookies(authorization.ssoLogin()).params(para).get(url);
try{
Assert.assertEquals(doDrawResponse.jsonPath().getString("success"),"true");
}catch(Exception e){
throw new Exception("pk活动开奖接口失败,返回信息:"+doDrawResponse.asString());
}catch(Error er){
throw new Exception("pk活动开奖接口失败,返回信息:"+doDrawResponse.asString());
}
return doDrawResponse;
}
// public static void main(String[] args) throws Exception{
// String endTime = "2021-12-31 23:55:00";
// PkActivityService pkActivityService = new PkActivityService();
//
// Response betResponse = pkActivityService.bet("2",endTime);
// String betId = MatcherString.getString(betResponse.asString(),"\"data\":(.*?)}",1);
// Response betRelation = pkActivityService.betGroupRelation(betId,endTime);
// Response modifyStatusResponse = pkActivityService.modifySatus(betId);
//
// }
}
\ No newline at end of file
......@@ -14,7 +14,7 @@ public class 优惠券_ExchangeTest_ui extends DuibaBaseUi{
@Test
public void 优惠券兑换_正常流程() throws Exception {
open("http://dafuweng.duibatest.com.cn/user/index");
clickByTextEqual("4762");
clickByTextEqual("5074");
switchWindow();
sleep(2);
clickByClass("btn-close");
......
......@@ -11,8 +11,8 @@ import static com.codeborne.selenide.Selenide.open;
public class 实物_ExchangeTest_ui extends DuibaBaseUi{
@Test
public void 实物兑换_正常流程() throws Exception {
open("http://47.97.214.108/user/index");
clickByTextEqual("4762");
open("http://dafuweng.duibatest.com.cn/user/index");
clickByTextEqual("5074");
switchWindow();
sleep(2);
clickByClass("btn-close");
......
......@@ -11,8 +11,8 @@ import static com.codeborne.selenide.Selenide.open;
public class 支付宝_ExchangeTest_ui extends DuibaBaseUi{
@Test
public void 支付宝_正常流程() throws Exception {
open("http://47.97.214.108/user/index");
clickByTextEqual("4762");
open("http://dafuweng.duibatest.com.cn/user/index");
clickByTextEqual("5074");
switchWindow();
sleep(2);
clickByClass("btn-close");
......
package ui.cases;
import base.DuibaBaseUi;
import base.DuibaBases;
import base.DuibaLog;
import com.codeborne.selenide.WebDriverRunner;
import com.codeborne.selenide.testng.ScreenShooter;
......@@ -13,6 +14,7 @@ import org.testng.Assert;
import org.testng.ITestResult;
import org.testng.Reporter;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test;
import ui.common.ProxyFactory;
......@@ -35,72 +37,20 @@ import static com.codeborne.selenide.Selenide.open;
* Created by mabo on 2018/10/18
*/
//@Listeners({ ScreenShooter.class})
public class test extends DuibaBaseUi {
// StatusCheckor checkor=new StatusCheckor();
// WebDriver driver= WebDriverFactory.createWebDriver(WebDriverType.CHRMOE, ProxyFactory.createProxy());
@Test
public void 中文() throws IOException {
ScreenShooter.captureSuccessfulTests = true;
//StatusCheckor checkor=new StatusCheckor();
// ProxyFactory.addCheckor(checkor);
// WebDriverRunner.setWebDriver(driver);
open("https://www.baidu.com");
Reporter.log("----------------------");
screenshot();
Reporter.log("----------------------");
$(By.id("kw")).setValue("selenium");
Assert.assertEquals(1,2);
// SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss"); //转换时间格式
// String time = dateFormat.format(Calendar.getInstance().getTime()); //获取当前时间
public class test extends DuibaBases {
@Test(dataProvider = "dp")
// @Test(retryAnalyzer = MyRetryAnalyzer.class,dataProvider = "dp")
public void f(Integer n, String s) {
System.out.println("ssssss:" + s);
Assert.assertFalse(true);
}
@Test
public void test1() throws SQLException {
Map<String,Object> map = jdbc.findSimpleResult("select * from act_com_conf.tb_bet_group_relation where bet_id = 1232");
@DataProvider
public Object[][] dp() {
return new Object[][] { new Object[] { 1, "a" }, new Object[] { 2, "b" },new Object[] { 3, "c" },new Object[] { 4, "d" } };
}
@Test
public void test2(){
Reporter.log("rererfddfdfdfdfdfdf");
Reporter.log("rererfddfdfdfdfdfdf");
Reporter.log("rererfddfdfdfdfdfdf");
Reporter.log("rererfddfdfdfdfdfdf");
Reporter.log("rererfddfdfdfdfdfdf");
Reporter.log("rererfddfdfdfdfdfdf");
Assert.assertEquals(1,2);
}
// @AfterMethod(alwaysRun = true)
// public void afterMethod(ITestResult result) throws Exception {
// if (!result.isSuccess())
// catchExceptions(result);
// }
// public void catchExceptions(ITestResult result) throws IOException {
// File file = new File("C:/image");
// Reporter.setCurrentTestResult(result);
// Reporter.log(file.getAbsolutePath());
// String time = String.valueOf(System.currentTimeMillis());
// Reporter.log("<img src='" + "http://172.16.80.106" + "/" + result.getName() +"_"+time+ ".jpg' hight='600' width='600'/>");
// File srcFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE); //执行屏幕截取
// FileUtils.copyFile(srcFile, new File(file.getAbsolutePath() + "/" + result.getName() +"_"+time+ ".jpg"));
//
// }
//
// public static void main(String[] args) {
// System.out.println(System.currentTimeMillis());
// System.out.println(Calendar.getInstance().getTimeInMillis());
// System.out.println(new Date().getTime());
// }
}
......@@ -71,6 +71,9 @@ public class WebDriverFactory {
String OS = prop.getProperty("os.name");
boolean bl=OS.startsWith("Mac");
String basePath=WebDriverType.class.getClassLoader().getResource("").getPath();
basePath = basePath.replaceAll("%20"," ");//repaceAll("%20",'');
File directory = new File("");
System.out.println("-----路径:"+directory.getAbsolutePath());
RemoteWebDriver browser=null;
String driverPath=null;
switch (driverType){
......
/**
* Copyright (C), 2015-2018
* FileName: GetDbName
* Author: qianwenjun
* Date: 2018/12/12 15:47
* Description:
*/
package utils;
import base.DuibaLog;
/**
* 〈〉
*
* @author qianwenjun
* @create 2018/12/12
* @since 1.0.0
*/
public class GetDbName {
private static DuibaLog looger = DuibaLog.getLogger();
public static String getDbName(String prex,String consumerId,String type){
String dbName = "";
//type=1,%1024 ;type=2,/10000000
if (type.equals("1")){
dbName = prex + String.format("%04d", Long.parseLong(consumerId) % 1024);
}else if (type.equals("2")){
dbName = prex + String.format("%04d", Long.parseLong(consumerId) / 10000000);
}
looger.info("dbName为:"+dbName);
return dbName;
}
}
\ No newline at end of file
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