Commit d6af2220 authored by 周松波's avatar 周松波

Merge branch 'develop' into songbo

parents b11ff4ea 38101db6
......@@ -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));
Map<String,String> params = new HashMap<>();
params.put("jobName",getJob());
changes = Postman.sendFindTestApp(params);
boolean sendMiria = Boolean.parseBoolean(System.getProperty("sendMiria"));
GitlabProjectMerges gitlabProjectMerges = GitlabUtils.getMessage("credits-group",changes);
if(sendMiria){
Map<String,String> params = new HashMap<>();
params.put("jobName",getJob());
changes = Postman.sendFindTestApp(params);
}
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,15 +130,17 @@ public class TestListener implements ITestListener {
}
//运行开始,触发互斥功能,用于定时任务
Map<String,String> mapJob = new HashMap<>();
if(sendMiria){
Map<String,String> mapJob = new HashMap<>();
try {
mapJob.put("jobName",getJob());
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
try {
mapJob.put("jobName",getJob());
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
Postman.sendTesting(mapJob);
Postman.sendTesting(mapJob);
}
}
public void serviceDoctor(){
logger.info("duiba-server开始检测");
......
......@@ -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,13 +80,15 @@ public class TestReport implements IReporter{
System.out.println("测试结果通知信息:"+gson.toJson(map));
//触发回调结束服务构建互斥
Map<String,String> mapJob = new HashMap<>();
try {
mapJob.put("jobName",ddResult.getJob());
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
if(sendMiria){
Map<String,String> mapJob = new HashMap<>();
try {
mapJob.put("jobName",ddResult.getJob());
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
Postman.sendFinish(mapJob);
}
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: pk_开奖_瓜分红包_押注人数不同测试_AccessTest
* FileName: pk_开奖_瓜分红包_押注人数不同测试
* Author: qianwenjun
* Date: 2018/8/9 20:13
* Description:
......
/**
* 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,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,7 +47,7 @@ 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";
......@@ -62,7 +62,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));
......
......@@ -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
......@@ -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