Commit 25b03f92 authored by wangxiaoshuang's avatar wangxiaoshuang

Merge branch 'master' into wxs

parents 2df71183 e9e4dfc8
......@@ -66,7 +66,7 @@ public class MysqlConnPool {
* @throws SQLException
*/
public Map<String, Object> findSimpleResult(String sql, Object ...params) throws SQLException {
log.info("findSimpleResult开始~~~~~~~~~~~~~~~~~~~~~");
log.info("findSimpleResult开始~~~~~~~~~~~~~~~~~~~~~"+sql);
Map<String, Object> map = null;
try(Connection conn = bds.getConnection()){
......@@ -107,6 +107,7 @@ public class MysqlConnPool {
log.info("findSimpleResult"+e.toString());
log.info("test");
log.info("bds"+bds.toString());
throw e;
}
log.info("findSimpleResult结束~~~~~~~~~~~~~~~~~~~~~");
......@@ -120,6 +121,7 @@ public class MysqlConnPool {
* @throws SQLException
*/
public boolean update(String sql, Object ...params) throws SQLException{
log.info("update开始~~~~~~~~~~~~~~~~~~~~~"+sql);
Connection conn=null;
boolean flag = false;
try{
......@@ -136,6 +138,7 @@ public class MysqlConnPool {
flag = result > 0 ? true : false;
}catch(Exception e){
e.printStackTrace();
throw e;
}finally {
if(conn!=null) conn.close();
}
......@@ -150,6 +153,8 @@ public class MysqlConnPool {
* @throws SQLException
*/
public List<Map<String, Object>> findModeResult(String sql, Object ...params) throws SQLException{
log.info("findModeResult开始~~~~~~~~~~~~~~~~~~~~~"+sql);
Connection conn=null;
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
try{
......@@ -178,6 +183,7 @@ public class MysqlConnPool {
}
}catch (Exception e){
e.printStackTrace();
throw e;
}finally {
if(conn!=null) conn.close();
}
......
......@@ -104,7 +104,7 @@ public class 集卡_助力集卡测试_DuibaTest extends DuibaTestBase {
break;
case 4:
response = newActivityService.helpShareCodeV2(userId,"780","25902","hdtool",shareCode);
//logger.info("XXXXXXXXX"+response.asString());
logger.info("XXXXXXXXX"+response.asString());
Assert.assertEquals(response.jsonPath().getString("itmeId"),"29085","校验itmeId失败");
Assert.assertEquals(response.jsonPath().getString("success"),"true","校验success失败");
Assert.assertEquals(response.jsonPath().getString("message"),"请求成功","校验message失败");
......
......@@ -237,8 +237,6 @@ public class 自有活动出奖_DuibaTest extends DuibaTestBase {
Assert.assertEquals(remaining-1,remainingNew,"扣库存失败");
}
@Test
......
......@@ -210,6 +210,7 @@ public class ObjectExchange_ExchangeTest extends CheckTemplet {
//多档位话费兑换_10元话费
@Test(dataProvider = "providerMethod")
public void 多档位兑换(Map<String,String> data) throws Exception {
Thread.sleep(4000);
Map<String, Object> mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
String credits = String.valueOf(mapuser.get("credits"));
logger.info("兑换前积分:" + credits);
......
package http.cases.ExchangeTest;
package http.cases.ExchangeTest.兑吧_直充类商品兑换;
import base.DuibaBase;
import base.DuibaBases;
import http.cases.ExchangeTest.CheckTemplet;
import http.service.Activity.ManagerService;
import http.service.Authorization;
import http.service.app.*;
......@@ -108,6 +109,8 @@ public class Qb_兑换流程测试_ExchangeTest extends CheckTemplet {
Assert.assertTrue(status.equals("success"),"校验订单状态失败");
logger.info("校验兑换订单状态正确");
}
@Test
public void qbExchange_积分不足() throws Exception {
int uid = 3086;
......@@ -130,6 +133,8 @@ public class Qb_兑换流程测试_ExchangeTest extends CheckTemplet {
}
@Test
public void 开发者余额不足测试() throws Exception{
int uid = 3490;
......
package http.cases.ExchangeTest;
package http.cases.ExchangeTest.兑吧_直充类商品兑换;
import base.DuibaLog;
import http.cases.ExchangeTest.CheckTemplet;
import http.service.Activity.ManagerService;
import http.service.Authorization;
import http.service.app.*;
......
package http.cases.ExchangeTest;
package http.cases.ExchangeTest.兑吧_直充类商品兑换;
import http.cases.ExchangeTest.CheckTemplet;
import http.service.Authorization;
import http.service.app.CouponExchangeService;
import http.service.app.CrecordService;
......
package http.cases.ExchangeTest;
package http.cases.ExchangeTest.兑吧_直充类商品兑换;
import base.DuibaBase;
import base.DuibaBases;
import http.cases.ExchangeTest.CheckTemplet;
import http.cases.ExchangeTest.Database;
import http.service.Authorization;
import http.service.Manager.ADeveloperService;
import http.service.app.AlipayExchangeService;
......@@ -87,8 +89,9 @@ public class 支付宝_兑换流程测试_ExchangeTest extends CheckTemplet {
logger.info("订单号:" + orderId);
//订单审核,判断是否在待审核节点
Map<String,Object> mapOrder = jdbc.findSimpleResult("SELECT * FROM "+Database.orders_consumer+"."+Database.orders9+" WHERE id = " + orderId);
Map<String,Object> mapOrder = jdbc.findSimpleResult("SELECT * FROM "+ Database.orders_consumer+"."+Database.orders9+" WHERE id = " + orderId);
String flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
Thread.sleep(300);
logger.info("数据库订单节点:" + flowWork);
Assert.assertEquals(flowWork,"Audit-started","校验订单审核节点失败");
String orderIdmain = String.valueOf(mapOrder.get("order_num"));
......
package http.cases.ExchangeTest.兑吧_直充类商品兑换;
import http.cases.ExchangeTest.CheckTemplet;
import http.service.Authorization;
import http.service.app.gawService;
import http.service.app.MobileService;
import http.service.app.tawService;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import utils.MatcherString;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Map;
/**
* Created by lvwenyan on 2019/5/30
*/
public class 新多档位话费_兑换流程测试_ExchangeTest extends CheckTemplet {
@Autowired
gawService gawService;
@Autowired
Authorization authorization;
@Autowired
tawService tawService;
@Autowired
MobileService mobileService;
// @Test(description = "1元话费用户兑换限制永久1次")
public void 话费用户永久兑换限制测试() throws Exception{
int uid = 7280;
String actualCredits = "10";
String degreeId = "1";
String appItemId = "195998";
String credits = "10";
String message = "";
try{
//支付宝兑换
Response response = this.话费兑换(uid,actualCredits,degreeId,appItemId,credits);
Assert.assertEquals(response.jsonPath().getString("data.payCreditsStatus"),"1","校验兑换失败");
logger.info("用户成功兑换一次");
//再次兑换
Thread.sleep(3000);
try{
response = gawService.phonebillExchange(uid,actualCredits,degreeId,appItemId,credits);
response.prettyPrint();
}catch (Exception e){
message = e.toString();
}
logger.info(message);
//获取按钮状态
Response detailResponse = mobileService.detail(authorization.dafuwengLogin(uid),"1");
String btnText = MatcherString.getString(detailResponse.asString(), "\"1\":\\{\"btnText\":\"(.*?)\",", 1);
logger.info("再次兑换按钮:" + btnText);
Assert.assertTrue(message.contains("\"desc\":\"已兑完\""),"校验用户兑换限制失败");
Assert.assertEquals(btnText,"已兑换","校验马上兑换按钮状态失败");
logger.info("校验话费1元用户永久兑换限制成功");
}catch (Exception e){
throw new Exception("异常信息打印:" + e);
}finally {
jdbc.update("DELETE FROM credits_dev.consumer_limit_record_only WHERE item_id = 1 and consumer_id = 100147134 and sub_key = 1");
jdbc.update("DELETE FROM credits_dev.consumer_limit_record WHERE item_id = 1 and consumer_id = 100147134 and sub_key = 1");
}
}
// @Test(description = "2元话费用户兑换限制每天1次")
public void 话费用户每天兑换限制测试() throws Exception{
int uid = 7281;
String actualCredits = "20";
String degreeId = "2";
String appItemId = "195998";
String credits = "20";
String message = "";
try{
//支付宝兑换
Response response = this.话费兑换(uid,actualCredits,degreeId,appItemId,credits);
Assert.assertEquals(response.jsonPath().getString("data.payCreditsStatus"),"1","校验兑换失败");
logger.info("用户成功兑换一次");
//再次兑换
Thread.sleep(3000);
try{
response = gawService.phonebillExchange(uid,actualCredits,degreeId,appItemId,credits);
response.prettyPrint();
}catch (Exception e){
message = e.toString();
}
logger.info(message);
//获取按钮状态
Response detailResponse = mobileService.detail(authorization.dafuwengLogin(uid),"1");
String btnText = MatcherString.getString(detailResponse.asString(), "\"2\":\\{\"btnText\":\"(.*?)\",", 1);
logger.info("再次兑换按钮:" + btnText);
Assert.assertTrue(message.contains("\"desc\":\"已兑完\""),"校验用户兑换限制失败");
Assert.assertEquals(btnText,"今日已兑换","校验马上兑换按钮状态失败");
logger.info("校验话费2元用户每天兑换限制成功");
}catch (Exception e){
throw new Exception("异常信息打印:" + e);
}finally {
//获取当前日期时间,再减一天
Date date=new Date();
Calendar calendar=Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.DAY_OF_MONTH, -1);
SimpleDateFormat dateFormat=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
logger.info("当前时间-1天:" + dateFormat.format(calendar.getTime()));
//更新表记录,修改记录为前一天
String sql = "UPDATE credits_dev.consumer_limit_record SET gmt_create = '" + dateFormat.format(calendar.getTime()) +"' WHERE item_id = 1 and consumer_id = 100147136 ORDER BY id DESC LIMIT 1";
jdbc.update(sql);
}
}
// @Test(description = "10元话费用户兑换限制每月1次")
public void 话费用户每月兑换限制测试() throws Exception{
int uid = 7282;
String actualCredits = "50";
String degreeId = "10";
String appItemId = "195998";
String credits = "50";
String message = "";
try{
//支付宝兑换
Thread.sleep(3000);
Response response = this.话费兑换(uid,actualCredits,degreeId,appItemId,credits);
Assert.assertEquals(response.jsonPath().getString("data.payCreditsStatus"),"1","校验兑换失败");
logger.info("用户成功兑换一次");
//再次兑换
Thread.sleep(3000);
try{
response = gawService.phonebillExchange(uid,actualCredits,degreeId,appItemId,credits);
response.prettyPrint();
}catch (Exception e){
message = e.toString();
}
logger.info(message);
//获取按钮状态
Response detailResponse = mobileService.detail(authorization.dafuwengLogin(uid),"1");
String btnText = MatcherString.getString(detailResponse.asString(), "\"10\":\\{\"btnText\":\"(.*?)\",", 1);
logger.info("再次兑换按钮:" + btnText);
Assert.assertTrue(message.contains("\"desc\":\"已兑完\""),"校验用户兑换限制失败");
Assert.assertEquals(btnText,"已兑换","校验马上兑换按钮状态失败");
logger.info("校验话费10元用户每月兑换限制成功");
}catch (Exception e){
throw new Exception("异常信息打印:" + e);
}finally {
//获取当前日期时间,再减30天
Date date=new Date();
Calendar calendar=Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.DAY_OF_MONTH, -30);
SimpleDateFormat dateFormat=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
logger.info("当前时间-30天:" + dateFormat.format(calendar.getTime()));
//更新表记录,修改记录为前一个月
String sql = "UPDATE credits_dev.consumer_limit_record SET gmt_create = '" + dateFormat.format(calendar.getTime()) +"' WHERE item_id = 1 and consumer_id = 100147137 ORDER BY id DESC LIMIT 1";
jdbc.update(sql);
}
}
// @Test(description = "话费会员等级限制LV5")
public void 话费会员等级测试() throws Exception{
int uid = 7282;
String actualCredits = "20";
String degreeId = "20";
String appItemId = "195998";
String credits = "20";
String message = "";
//用户登录, vip=5
Map cookies = authorization.generateSignAutoLogin("SvSQyVi2iLSoXgaRutJgK1UCkWb",7273);
//会员符合条件,兑换
Response response = this.话费兑换(uid,actualCredits,degreeId,appItemId,credits);
Assert.assertEquals(response.jsonPath().getString("data.payCreditsStatus"),"1","校验兑换失败");
logger.info("用户等级LV0成功兑换一次");
//会员不符合条件,兑换,vip=5
try{
response = gawService.phonebillExchange(cookies,actualCredits,degreeId,appItemId,credits);
response.prettyPrint();
}catch (Exception e){
message = e.toString();
}
logger.info(message);
Assert.assertTrue(message.contains("\"desc\":\"未达到会员等级要求\""),"校验message失败");
logger.info("校验话费会员等级兑换成功");
}
public Response 话费兑换(int uid, String actualCredits, String degreeId, String appItemId, String credits) throws Exception {
Response response = gawService.phonebillExchange(uid,actualCredits,degreeId,appItemId,credits);
response.prettyPrint();
String orderId = response.jsonPath().getString("data.orderId");
//查看兑换结果
response = tawService.orderStatus(orderId,uid);
response.prettyPrint();
String status = response.jsonPath().getString("data.status");
//异步接口
int i = 10;
while (i > 0 && status.equals("processing")) {
Thread.sleep(1000);
response = tawService.orderStatus(orderId,uid);
response.prettyPrint();
status = response.jsonPath().getString("data.status");
i--;
}
return response;
}
}
package http.cases.ExchangeTest;
package http.cases.ExchangeTest.兑吧_直充类商品兑换;
import http.cases.ExchangeTest.CheckTemplet;
import http.service.Authorization;
import http.service.app.CouponExchangeService;
import http.service.app.CrecordService;
......@@ -22,7 +23,7 @@ import static io.restassured.RestAssured.given;
/**
* Created by mabo on 2019/2/28
*/
public class 话费_兑换限制测试_ExchangeTest extends CheckTemplet{
public class 话费_兑换限制测试_ExchangeTest extends CheckTemplet {
@Autowired
private MobileService mobileService;
@Autowired
......
......@@ -158,7 +158,7 @@ public class 兑吧卡密_兑换流程测试_ExchangeTest extends CheckTemplet {
logger.info("商品兑换按钮:" + exchangeText);
//第二次兑换
Thread.sleep(3000);
Thread.sleep(5000);
try{
response = gawService.couponExchange(cookies,appItemId,itemId,skuId);
response.prettyPrint();
......@@ -221,7 +221,7 @@ public class 兑吧卡密_兑换流程测试_ExchangeTest extends CheckTemplet {
logger.info("商品兑换按钮:" + exchangeText);
//第二次兑换
Thread.sleep(3000);
Thread.sleep(5000);
try{
response = gawService.couponExchange(cookies,appItemId,itemId,skuId);
response.prettyPrint();
......@@ -231,11 +231,11 @@ public class 兑吧卡密_兑换流程测试_ExchangeTest extends CheckTemplet {
}
logger.info(message);
Assert.assertTrue(message.contains("已达兑换次数上限"),"校验message失败");
Assert.assertTrue(message.contains("该批次已达兑换上限"),"校验message失败");
Assert.assertTrue(message.contains("\"success\":false"),"校验success失败");
//按钮文案不变
Assert.assertEquals(exchangeText,"马上兑换","校验兑换按钮失败");
Assert.assertEquals(exchangeText,"该批次已达兑换上限","校验兑换按钮失败");
logger.info("校验卡密每人限购批次限制成功");
}catch (Exception e){
......@@ -285,7 +285,7 @@ public class 兑吧卡密_兑换流程测试_ExchangeTest extends CheckTemplet {
logger.info("商品兑换按钮:" + exchangeText);
//第二次兑换
Thread.sleep(3000);
Thread.sleep(5000);
try{
response = gawService.couponExchange(cookies,appItemId,itemId,skuId);
response.prettyPrint();
......
......@@ -237,11 +237,11 @@ public class 兑吧新优惠券_兑换流程测试_ExchangeTest extends CheckTem
}
logger.info(message);
Assert.assertTrue(message.contains("已达兑换次数上限"),"校验message失败");
Assert.assertTrue(message.contains("该批次已达兑换上限"),"校验message失败");
Assert.assertTrue(message.contains("\"success\":false"),"校验success失败");
//按钮文案不变
Assert.assertEquals(exchangeText,"马上兑换","校验兑换按钮失败");
Assert.assertEquals(exchangeText,"该批次已达兑换上限","校验兑换按钮失败");
logger.info("校验优惠券每人限购批次限制成功");
}catch (Exception e){
......
......@@ -446,6 +446,30 @@ public class 兑吧新实物_兑换流程测试_ExchangeTest extends CheckTemple
}
@Test(description = "新实物确认下单页面")
public void 实物确认下单测试() throws Exception{
String appItemId = "196218";
String appSkuId = "145";
Response response = gawService.confirmItemDetail(uid,appItemId,appSkuId);
response.prettyPrint();
Assert.assertEquals(response.jsonPath().getString("data.items[0].sku.attr[0].value"),"白色","校验sku信息颜色失败");
Assert.assertEquals(response.jsonPath().getString("data.items[0].sku.attr[1].value"),"S","校验sku信息尺寸失败");
Assert.assertEquals(response.jsonPath().getString("data.items[0].sku.credits"),"100","校验sku商品积分失败");
Assert.assertEquals(response.jsonPath().getString("data.items[0].multiImage"),"//yun.dui88.com/images/201906/9p72lmu1qn.jpg","校验图片信息失败");
Assert.assertEquals(response.jsonPath().getString("data.items[0].title"),"【自动化勿动】自有实物sku","校验实物名称失败");
Assert.assertEquals(response.jsonPath().getString("data.orderCredits"),"100","校验订单积分失败");
Assert.assertEquals(response.jsonPath().getString("data.expressPrice"),"500","校验订单运费金额失败");
Assert.assertEquals(response.jsonPath().getString("data.consumerPayPrice"),"500","校验订单支付金额失败");
logger.info("校验新实物确认下单页正确");
}
......
......@@ -287,6 +287,7 @@ public class 兑吧老优惠券_兑换流程测试_ExchangeTest extends CheckTem
public void 优惠券积分不足测试() throws Exception{
//获取按钮状态
Thread.sleep(4000);
Response detailResponse = mobileService.detail(authorization.dafuwengLogin(3086,true),"29164");
detailResponse.prettyPrint();
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
......@@ -468,7 +469,7 @@ public class 兑吧老优惠券_兑换流程测试_ExchangeTest extends CheckTem
Assert.assertEquals(response.jsonPath().getString("status"),"success","校验兑换失败");
//再次兑换
Thread.sleep(3000);
Thread.sleep(5000);
response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.dafuwengLogin(uid)).params(map).post(url + "/couponExchange/exchange");
response.prettyPrint();
......@@ -477,8 +478,8 @@ public class 兑吧老优惠券_兑换流程测试_ExchangeTest extends CheckTem
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
logger.info("兑换按钮:"+ exchangeText);
Assert.assertEquals(response.jsonPath().getString("message"),"已达兑换次数上限","校验用户兑换限制失败");
Assert.assertEquals(exchangeText,"已达兑换次数上限","校验马上兑换按钮状态失败");
Assert.assertEquals(response.jsonPath().getString("message"),"该批次已达兑换上限","校验用户兑换限制失败");
Assert.assertEquals(exchangeText,"该批次已达兑换上限","校验马上兑换按钮状态失败");
logger.info("校验优惠券用户批次兑换限制成功");
}catch (Exception e){
......
......@@ -158,6 +158,7 @@ public class 商品订单失败测试_ExchangeTest extends CheckTemplet {
@Test
public void 实物发货撤销测试() throws Exception{
Thread.sleep(3000);
//实物兑换【勿动】自动化兑吧实物
String orderId = this.实物兑换订单(uid,"166813","28430");
logger.info("订单号:" + orderId);
......
......@@ -105,13 +105,14 @@ public class 自有新优惠券_兑换限制测试_ExchangeTest extends CheckTem
i--;
}
Thread.sleep(4000);
Response detailResponse = mobileService.appItemDetail(authorization.dafuwengLogin(uid),appItemId);
detailResponse.prettyPrint();
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
logger.info("商品兑换按钮:" + exchangeText);
//第二次兑换
Thread.sleep(4000);
try{
response = gawService.couponExchange(uid, appItemId,38);
response.prettyPrint();
......@@ -225,13 +226,14 @@ public class 自有新优惠券_兑换限制测试_ExchangeTest extends CheckTem
i--;
}
Thread.sleep(4000);
Response detailResponse = mobileService.appItemDetail(authorization.dafuwengLogin(uid),appItemId);
detailResponse.prettyPrint();
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
logger.info("商品兑换按钮:" + exchangeText);
//第二次兑换
Thread.sleep(4000);
try{
response = gawService.couponExchange(uid, appItemId,42);
response.prettyPrint();
......@@ -325,6 +327,7 @@ public class 自有新优惠券_兑换限制测试_ExchangeTest extends CheckTem
}
//获取按钮状态
Thread.sleep(4000);
Response detailResponse = mobileService.appItemDetail(authorization.dafuwengLogin(uid),appItemId);
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
logger.info("商品兑换按钮:" + exchangeText);
......@@ -411,13 +414,14 @@ public class 自有新优惠券_兑换限制测试_ExchangeTest extends CheckTem
i--;
}
Thread.sleep(4000);
Response detailResponse = mobileService.appItemDetail(authorization.dafuwengLogin(uid),appItemId);
detailResponse.prettyPrint();
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
logger.info("商品兑换按钮:" + exchangeText);
//第二次兑换
Thread.sleep(4000);
try{
response = gawService.couponExchange(uid, appItemId,41);
response.prettyPrint();
......
......@@ -42,7 +42,6 @@ public class 自有新实物_兑换流程测试_ExchangeTest extends CheckTemple
return result;
}
@BeforeMethod
public void beforeMethod(){
try {
......@@ -91,11 +90,12 @@ public class 自有新实物_兑换流程测试_ExchangeTest extends CheckTemple
}
Assert.assertEquals(status,"wait_delivery","校验轮询结果status失败");
Thread.sleep(5000);
Response detailResponse = mobileService.appItemDetail(authorization.dafuwengLogin(uid),appItemId);
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
logger.info("商品兑换按钮:" + exchangeText);
//第二次兑换
Thread.sleep(3000);
try{
response = gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits);
response.prettyPrint();
......@@ -143,11 +143,12 @@ public class 自有新实物_兑换流程测试_ExchangeTest extends CheckTemple
i--;
}
Assert.assertEquals(status,"wait_delivery","校验轮询结果status失败");
Thread.sleep(5000);
Response detailResponse = mobileService.appItemDetail(authorization.dafuwengLogin(uid),appItemId);
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
logger.info("商品兑换按钮:" + exchangeText);
//第二次兑换
Thread.sleep(3000);
try{
response = gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits);
logger.info("********2");
......@@ -195,11 +196,11 @@ public class 自有新实物_兑换流程测试_ExchangeTest extends CheckTemple
i--;
}
Assert.assertEquals(status,"wait_delivery","校验轮询结果status失败");
Thread.sleep(5000);
Response detailResponse = mobileService.appItemDetail(authorization.dafuwengLogin(uid),appItemId);
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
// logger.info("商品兑换按钮:" + exchangeText);
//第二次兑换
Thread.sleep(3000);
try{
response = gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits);
response.prettyPrint();
......@@ -247,11 +248,11 @@ public class 自有新实物_兑换流程测试_ExchangeTest extends CheckTemple
i--;
}
Assert.assertEquals(status,"wait_delivery","校验轮询结果status失败");
Thread.sleep(5000);
Response detailResponse = mobileService.appItemDetail(authorization.dafuwengLogin(uid),appItemId);
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
// logger.info("商品兑换按钮:" + exchangeText);
//第二次兑换
Thread.sleep(3000);
try{
response = gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits);
response.prettyPrint();
......@@ -293,6 +294,7 @@ public class 自有新实物_兑换流程测试_ExchangeTest extends CheckTemple
}
logger.info(message);
//获取按钮状态
Thread.sleep(5000);
Response detailResponse = mobileService.appItemDetail(authorization.dafuwengLogin(uid),appItemId);
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
logger.info("商品兑换按钮:" + exchangeText);
......@@ -378,4 +380,51 @@ public class 自有新实物_兑换流程测试_ExchangeTest extends CheckTemple
logger.info("校验自有新实物---会员兑换制成功");
}
//测试使用
//@Test(enabled=true, dataProvider="testdp", threadPoolSize=1, invocationCount=100)
@DataProvider(name = "testdp", parallel = true)
public static Object[][]testdp(){
return new Object[][]{
{1},
{2},
{3},
{4},
{162},
{6},
{8},
{10},
{157},
{158}
};
}
// @Test(enabled=true, dataProvider="testdp", threadPoolSize=1, invocationCount=100)
public void test(int uid) throws Exception {
// System.out.println("Current Thread Id: " + Thread.currentThread().getId() + ". Dataprovider number: "+ dpNumber);
// Thread.sleep(5000);
String appItemId = "159040";
String itemId = "null";
String message = "";
String skuId="144";
String actualCredits="8";
String credits="100";
Thread.sleep(4000);
Response response = gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits);
response.prettyPrint();
//(enabled=true, dataProvider="testdp", threadPoolSize=1, invocationCount=2)
String orderId = response.jsonPath().getString("data.orderId");
response = tawService.orderStatus(orderId,uid);
response.prettyPrint();
}
}
......@@ -95,6 +95,8 @@ public class 自有新虚拟商品_充值_兑换限制_ExchangeTest extends Chec
i--;
}
Thread.sleep(4000);
Response detailResponse = mobileService.appItemDetail(authorization.dafuwengLogin(uid),appItemId);
detailResponse.prettyPrint();
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
......@@ -153,6 +155,8 @@ public class 自有新虚拟商品_充值_兑换限制_ExchangeTest extends Chec
i--;
}
Thread.sleep(4000);
Response detailResponse = mobileService.appItemDetail(authorization.dafuwengLogin(uid),appItemId);
detailResponse.prettyPrint();
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
......@@ -214,6 +218,8 @@ public class 自有新虚拟商品_充值_兑换限制_ExchangeTest extends Chec
i--;
}
Thread.sleep(4000);
Response detailResponse = mobileService.appItemDetail(authorization.dafuwengLogin(uid),appItemId);
detailResponse.prettyPrint();
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
......@@ -313,6 +319,8 @@ public class 自有新虚拟商品_充值_兑换限制_ExchangeTest extends Chec
}
Thread.sleep(4000);
//获取按钮状态
Response detailResponse = mobileService.appItemDetail(authorization.dafuwengLogin(uid),appItemId);
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
......@@ -382,7 +390,7 @@ public class 自有新虚拟商品_充值_兑换限制_ExchangeTest extends Chec
try{
//第一次兑换
Thread.sleep(4000);
Thread.sleep(5000);
Response response = gawService.virtualExchange(cookie, appItemId,59);
response.prettyPrint();
String orderId = response.jsonPath().getString("data.orderId");
......@@ -400,6 +408,8 @@ public class 自有新虚拟商品_充值_兑换限制_ExchangeTest extends Chec
i--;
}
Thread.sleep(4000);
Response detailResponse = mobileService.appItemDetail(cookie,appItemId);
detailResponse.prettyPrint();
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
......
/**
* Copyright (C), 2015-2018
* FileName: 游戏_新建无大奖游戏_AccessTest
* FileName: 游戏_新建无大奖游戏
* Author: qianwenjun
* Date: 2018/5/27 09:29
* Description: 新建无大奖游戏
......@@ -34,7 +34,7 @@ import static io.restassured.RestAssured.given;
* @create 2018/5/27
* @since 1.0.0
*/
public class 游戏_新建无大奖游戏_AccessTest extends DuibaTestBase {
public class 游戏_新建无大奖游戏 extends DuibaTestBase {
private DuibaLog logger = DuibaLog.getLogger();
......
......@@ -42,7 +42,7 @@ public class 瓜分积分_实际瓜分_主胜方_AccessTest extends DuibaTestBas
private static Integer uid1 = 5171;
private static Integer uid2 = 5172;
private static Integer uid3 = 5173;
private static String betId;
private static String betId = "4791";
private static String optionId1;
private static String optionId2;
......@@ -207,7 +207,7 @@ public class 瓜分积分_实际瓜分_主胜方_AccessTest extends DuibaTestBas
Assert.assertEquals(response.jsonPath().getString("data.unitName"),"金币","积分单位校验失败");
Response response2 = pkService.popup(uid1);
response.prettyPrint();
response2.prettyPrint();
Assert.assertEquals(response2.jsonPath().getString("data.prizeList"),null,"中奖弹窗积分校验失败");
Assert.assertEquals(response2.jsonPath().getString("data.show"),"false","展示弹窗校验失败");
}
......
......@@ -239,7 +239,6 @@ public class 插件场景测试_pluginTest extends DuibaTestBase {
int uid = 6552;
String appId = "22475";
String signType = "0";
String url = "chome";
//创建插件活动
......@@ -255,9 +254,9 @@ public class 插件场景测试_pluginTest extends DuibaTestBase {
Response ajaxResponse = activityPlugin.ajaxBanners(uid,url);
ajaxResponse.prettyPrint();
int i =40;
while(!ajaxResponse.jsonPath().getString("default.activityId").equals(id) && i > 0){
while(!ajaxResponse.jsonPath().getString("success").equals("true") && i > 0){
Thread.sleep(3000);
Thread.sleep(5000);
ajaxResponse = activityPlugin.ajaxBanners(uid,url);
i--;
}
......
......@@ -55,7 +55,7 @@ public class 补给站_商品_DuibaTest extends AbstractTestNGSpringContextTests
//上架
Response response2 = developerBJZ.ajaxDirectUp2(appId2, id);
//接口提示,至尊版专享,不能上架
Assert.assertEquals(response2.jsonPath().getString("desc"), "至尊版专享", "校验接口上架失败");
Assert.assertEquals(response2.jsonPath().getString("desc"), "您暂无使用权限哦,若想获得使用权限,请与您的商务联系", "校验接口上架失败");
}
......@@ -100,7 +100,7 @@ public class 补给站_商品_DuibaTest extends AbstractTestNGSpringContextTests
//上架
Response response2 = developerBJZ.ajaxDirectUp2(appId2, id);
//接口提示,至尊版专享,不能上架
Assert.assertEquals(response2.jsonPath().getString("desc"), "至尊版专享", "校验接口上架失败");
Assert.assertEquals(response2.jsonPath().getString("desc"), "您暂无使用权限哦,若想获得使用权限,请与您的商务联系", "校验接口上架失败");
}
@Test(description = "//添加直冲类")
......
......@@ -28,8 +28,8 @@ public class 开发者签到编辑_signTest extends AbstractTestNGSpringContextT
Response response = signService.selectsignOperList("19515");
response.print();
Assert.assertEquals(response.jsonPath().getString("data.list[0].openToDev"),"false","来自Duiba的签到编辑权限失败");
Assert.assertEquals(response.jsonPath().getString("data.list[1].openToDev"),"true","来自开发者自有的签到编辑权限失败");
Assert.assertEquals(response.jsonPath().getString("data.list[1].openToDev"),"false","来自Duiba的签到编辑权限失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].openToDev"),"true","来自开发者自有的签到编辑权限失败");
Assert.assertEquals(response.jsonPath().getString("data.list[2].openToDev"),"true","来自开发者自有的签到编辑权限失败");
logger.info("开发者签到编辑权限校验成功");
......
......@@ -198,38 +198,57 @@ public class 补签测试_signTest extends DuibaTestBase {
}
//@Test(description = "补签失败场景——积分不足")
// public void 补签_积分不足() throws Exception {
//
// //补签前一天(前2天-2,当天0,后一天+1)
// Response response = signactivityService.reSign(authorization.dafuwengLogin(uid), "80", null, getTime(-1));
// response.prettyPrint();
// //response.prettyPrint();
// String hasConsume = response.jsonPath().getString("data.hasConsume");
// //补签消耗数量
// String reSignConsumeCount = response.jsonPath().getString("data.reSignConsumeCount");
// //补签消耗类型
// String reSignConsumeTypeStr = response.jsonPath().getString("data.reSignConsumeTypeStr");
// Assert.assertEquals(hasConsume, "true", "补签是否消耗");
// Assert.assertEquals(reSignConsumeCount, "999999999", "补签消耗数量不正确");
// Assert.assertEquals(reSignConsumeTypeStr,"积分","补签消耗类型是否为积分");
// //补签logid
// String logId = response.jsonPath().getString("data.logId");
// response = signactivityService.getSignResult(authorization.dafuwengLogin(uid), logId);
// //签到状态
// String status = response.jsonPath().getString("status");
// //接口异步处理
// int i=10;
// while(status.equals("0")&&i>0){
// Thread.sleep(1000);
// response = signactivityService.getSignResult(authorization.dafuwengLogin(uid),logId);
// status = response.jsonPath().getString("status");
// i--;
// }
// String message = response.jsonPath().getString("message");
// //response.prettyPrint();
// //判断结果
// Assert.assertEquals(status,"1","补签失败状态不正确");
// Assert.assertEquals(message,"签到失败,用户积分余额不足","签到失败,用户积分余额不足");
//
// logger.info("补签失败用例成功,原因——积分不足");
//
// }
@Test(description = "补签失败场景——积分不足")
public void 补签_积分不足() throws Exception {
//补签前一天(前2天-2,当天0,后一天+1)
Response response = signactivityService.reSign(authorization.dafuwengLogin(uid), "80", null, getTime(-1));
response.prettyPrint();
//response.prettyPrint();
String hasConsume = response.jsonPath().getString("data.hasConsume");
//补签消耗数量
String reSignConsumeCount = response.jsonPath().getString("data.reSignConsumeCount");
//补签消耗类型
String reSignConsumeTypeStr = response.jsonPath().getString("data.reSignConsumeTypeStr");
Assert.assertEquals(hasConsume, "true", "补签是否消耗");
Assert.assertEquals(reSignConsumeCount, "999999999", "补签消耗数量不正确");
Assert.assertEquals(reSignConsumeTypeStr,"积分","补签消耗类型是否为积分");
//补签logid
String logId = response.jsonPath().getString("data.logId");
response = signactivityService.getSignResult(authorization.dafuwengLogin(uid), logId);
//签到状态
String status = response.jsonPath().getString("status");
//接口异步处理
int i=10;
while(status.equals("0")&&i>0){
Thread.sleep(1000);
response = signactivityService.getSignResult(authorization.dafuwengLogin(uid),logId);
status = response.jsonPath().getString("status");
i--;
}
String message = response.jsonPath().getString("message");
//response.prettyPrint();
String success = response.jsonPath().getString("success");
//判断结果
Assert.assertEquals(status,"1","补签失败状态不正确");
Assert.assertEquals(message,"签到失败,用户积分余额不足","签到失败,用户积分余额不足");
Assert.assertEquals(message,"您的积分不足","补签失败提示不正确");
Assert.assertEquals(success,"false","补签失败状态不正确");
logger.info("补签失败用例成功,原因——积分不足");
......
......@@ -4,6 +4,7 @@ import base.DuibaLog;
import base.DuibaTestBase;
import http.cases.ExchangeTest.Database;
import http.service.hd.DevItemNewService;
import http.service.app.ChwVisualEditorService;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
......@@ -28,6 +29,8 @@ public class 商品分组组件_DuibaTest extends DuibaTestBase {
DevItemNewService devItemNewService;
@Autowired
Authorization authorization;
@Autowired
ChwVisualEditorService chwVisualEditorService;
@DataProvider
public Object[][] providerMethod(Method method) {
......@@ -44,6 +47,12 @@ public class 商品分组组件_DuibaTest extends DuibaTestBase {
new Object[]{2, "2125", "22542", "商品分组-自有老商品"}, //case2
};
}
if (method.getName().equals("手机端商品分组组件新商品展示")) {
result = new Object[][]{
new Object[]{1, "2102", "商品分组-兑吧新商品"}, //case1
new Object[]{2, "2104", "商品分组-自有新商品"}, //case2
};
}
return result;
}
......@@ -166,4 +175,69 @@ public class 商品分组组件_DuibaTest extends DuibaTestBase {
}
/**
* @param caseNum 用例编号
* @param classifyId 商品分组Id
* @param caseName 用例名称打印
* @throws Exception
*/
@Test(dataProvider = "providerMethod")
public void 手机端商品分组组件新商品展示(int caseNum, String classifyId, String caseName) throws Exception{
logger.info("---" + caseName + "---");
Map cookies = authorization.dafuwengLogin(7126);
Response response = chwVisualEditorService.itemsList(cookies,classifyId);
response.prettyPrint();
switch (caseNum){
case 1:
//手机端接口排序与前端不一致
Assert.assertEquals(response.jsonPath().getString("data.list[0].title"),"【自动化勿动】兑吧新优惠券普通券码跳转","校验第一个商品title失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].titleDownTxt"),"100积分","校验第一个商品credits失败");
Assert.assertEquals(response.jsonPath().getString("data.list[1].title"),"【自动化勿动】兑吧卡密跳转按钮","校验第二个商品title失败");
Assert.assertEquals(response.jsonPath().getString("data.list[1].titleDownTxt"),"200积分","校验第二个商品credits失败");
Assert.assertEquals(response.jsonPath().getString("data.list[2].title"),"【自动化勿动】兑吧新实物","校验第三个商品title失败");
Assert.assertEquals(response.jsonPath().getString("data.list[2].titleDownTxt"),"300积分","校验第三个商品credits失败");
Assert.assertEquals(response.jsonPath().getString("data.list[3].title"),"支付宝充值","校验第四个商品title失败");
Assert.assertEquals(response.jsonPath().getString("data.list[3].titleDownTxt"),"10万积分","校验第四个商品credits失败");
Assert.assertEquals(response.jsonPath().getString("data.list[4].title"),"10元话费","校验第五个商品title失败");
Assert.assertEquals(response.jsonPath().getString("data.list[4].titleDownTxt"),"1000积分","校验第五个商品credits失败");
logger.info("校验商品分组1-兑吧新商品成功");
break;
case 2:
Assert.assertEquals(response.jsonPath().getString("data.list[0].title"),"【自动化勿动】自有新优惠券跳转链接","校验第一个商品title失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].titleDownTxt"),"100积分","校验第一个商品credits失败");
Assert.assertEquals(response.jsonPath().getString("data.list[1].title"),"【自动化勿动】自有新实物加钱购","校验第二个商品title失败");
Assert.assertEquals(response.jsonPath().getString("data.list[1].titleDownTxt"),"150积分&nbsp;+&nbsp;10.00元","校验第二个商品credits失败");
Assert.assertEquals(response.jsonPath().getString("data.list[2].title"),"【自动化勿动】自有充值商品","校验第三个商品title失败");
Assert.assertEquals(response.jsonPath().getString("data.list[2].titleDownTxt"),"300积分","校验第三个商品credits失败");
Assert.assertEquals(response.jsonPath().getString("data.list[3].title"),"【自动化勿动】自有卡密","校验第四个商品title失败");
Assert.assertEquals(response.jsonPath().getString("data.list[3].titleDownTxt"),"550积分","校验第四个商品credits失败");
logger.info("校验商品分组2-自有新商品成功");
break;
}
}
}
......@@ -70,18 +70,21 @@ public class 种红包_AccessTest extends DuibaTestBase{
Assert.assertNotNull(orderId,"订单号为空");
//生长时间
String grownNeedTime = response.jsonPath().getString("data.grownNeedTime");
logger.info("生长时间为:"+grownNeedTime);
Assert.assertEquals(grownNeedTime,"1","获取红包时间间隔异常");
Thread.sleep(2000);
//获取种植结果状态getOrderStatus,异步接口,while循环,status为2处理完成,1处理中
response = seedRedPacketService.getOrderStatus(cookies,orderId);
String status = response.jsonPath().getString("data");
int i =5;
int i =50;
while(i>0&&status.equals("1")){
response = seedRedPacketService.getOrderStatus(cookies,orderId);
status = response.jsonPath().getString("data");
i--;
logger.info("获取种植结果状态:"+response.asString());
i--;
Thread.sleep(2000);
}
//获取种植获得金额
response = seedRedPacketService.reap(cookies,"1",orderId);
......
......@@ -14,6 +14,8 @@ import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Map;
import static io.restassured.RestAssured.given;
......@@ -57,6 +59,9 @@ public class 种红包新用户_AccessTest extends DuibaTestBase{
@Test
public void a_新人收红包() throws Exception {
// String date=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(Calendar.getInstance().getTime());
// logger.info("服务器当前时间为:"+date);
logger.info("用户信息为,uid="+uid+",consumerId="+consumerId);
tag = String.format("%04d", Long.parseLong(consumerId) % 1024);
......@@ -69,7 +74,7 @@ public class 种红包新用户_AccessTest extends DuibaTestBase{
Assert.assertEquals(landStatus,"4","新人第一块土地状态校验失败");
Thread.sleep(1000);
Thread.sleep(5000);
//获取新人红包订单号
Map<String,Object> sqlResult = jdbc.findSimpleResult("select * from activity_order_con.tb_trade_center_activity_order_"+tag+" where consumer_id ="+consumerId+" and activity_type = 'seedRedPacket'");
String orderId = sqlResult.get("order_num").toString();
......@@ -142,7 +147,7 @@ public class 种红包新用户_AccessTest extends DuibaTestBase{
Response response = editManagerInfoService.createUser("种红包新用户","68");
Map<String,Object> user = jdbc.findSimpleResult("select * from dafuweng.user where name = '种红包新用户' and app_id = '68'");
uid = Integer.valueOf(user.get("id").toString());
String url = "http://dafuweng.duibatest.com.cn/user/loginDuiba?uid=" + uid;
String url = "http://autotest-dafuweng.duibatest.com.cn/user/loginDuiba?uid=" + uid;
Response login = given().get(url);
Map<String,Object> consumer = jdbc.findSimpleResult("select * from new_consumer.consumer_0010 where partner_user_id =? and app_id = '19380'",uid);
consumerId = consumer.get("id").toString();
......
......@@ -159,7 +159,7 @@ public class 账户异常提现_AccessTest extends DuibaTestBase{
this.checkRecord(uid3,"100");
}
@Test
//@Test
public void 兑吧账户余额不足() throws Exception {
Response responses = managerService.adminDuibaBalance();
String balanceManager = MatcherString.getString(responses.asString(), "type=\"hidden\" value=\"(.*?)\"", 1);
......
......@@ -258,6 +258,7 @@ public class ActivityPlugin {
Map<String,String> map = new HashMap<>();
map.put("url",url);
map.put("preview","false");
logger.info("请求ajaxbanners接口,url="+url);
Response response = given().cookies(authorization.dafuwengLogin(uid,true)).params(map).post(activityHost+"/activityPlugin/ajaxBanners");
......
......@@ -99,6 +99,43 @@ public class Authorization {
return dafuwengCookiesMap.get(uid);
}
//大富翁登录
public Map dafuwengLoginTest(int uid){
int i=10;
Map<String,String> dafuwengCookies = null;
while((dafuwengCookiesMap.get(uid)==null||dafuwengCookiesMap.get(uid).size()==0)&&i>0) {
String url = PROTOCOL + "dafuweng.duibatest.com.cn" + ":" + dafuwengPort + dafuwengLoginPath;
Response response=given().redirects().follow(false).param("uid",uid).get(url);
String location = response.getHeader("location");
dafuwengCookies =response.getCookies();
//logger.info(location);
URL url1=null;
try {
url1= new URL(location);
} catch (MalformedURLException e) {
e.printStackTrace();
}
if(url1!=null&&url1.getProtocol().equals("http")) {
response=given().cookies(dafuwengCookies).redirects().follow(false).get(location);
}else if(url1!=null&&url1.getProtocol().equals("https")){
response=given().cookies(dafuwengCookies).relaxedHTTPSValidation().redirects().follow(false).get(location);
}
dafuwengCookies=response.getCookies();
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
dafuwengCookiesMap.put(uid,dafuwengCookies);
i--;
}
if((dafuwengCookiesMap.get(uid)==null||dafuwengCookiesMap.get(uid).size()==0)){
logger.info("dafuweng登陆app失败,cookies为null");
}
return dafuwengCookiesMap.get(uid);
}
/**
* 大富翁登陆
* @param uid
......
......@@ -449,7 +449,7 @@ public class EditManagerInfoService {
public Response createUser(String name){
String url = "http://dafuweng.duibatest.com.cn" + "/user/create";
String url = "http://autotest-dafuweng.duibatest.com.cn" + "/user/create";
Map<String,Object> map = new HashMap<>();
map.put("appId","67");
map.put("name",name);
......@@ -464,7 +464,7 @@ public class EditManagerInfoService {
public Response createUser(String name,String appId){
String url = "http://dafuweng.duibatest.com.cn" + "/user/create";
String url = "http://autotest-dafuweng.duibatest.com.cn" + "/user/create";
Map<String,Object> map = new HashMap<>();
map.put("appId",appId);
map.put("name",name);
......
......@@ -104,7 +104,7 @@ public class PluginService {
String configUrl = ManagerHost + "/plugin/editConfig.htm";
//获取创建活动的token
Response response=given().contentType("text/html;charset=UTF-8").cookies(authorization.ssoLogin()).get("http://"+configUrl);
Response response=given().contentType("text/html;charset=UTF-8").cookies(authorization.ssoLogin()).get("https://"+configUrl);
String token = MatcherString.getString(response.asString(), "token: '(.*?)'", 1);
List<Map<String,String>> listPrizes = new ArrayList<>();
......
......@@ -132,7 +132,7 @@ public class DeveloperBJZ {
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas(appId)).params(map).post(url);
response.prettyPrint();
try {
Assert.assertEquals(response.jsonPath().getString("desc"), "至尊版专享");
Assert.assertEquals(response.jsonPath().getString("desc"), "您暂无使用权限哦,若想获得使用权限,请与您的商务联系");
} catch (Exception e) {
throw new Exception("创建接口1失败,返回信息:" + response.asString());
} catch (Error er) {
......
package http.service.app;
import base.DuibaLog;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
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.springframework.stereotype.Service;
import org.testng.Assert;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static io.restassured.RestAssured.given;
@Service
public class ChwVisualEditorService {
@Value("${home.host}")
private String homeHost;
private DuibaLog logger = DuibaLog.getLogger();
@Autowired
Authorization authorization;
//手机端商品分组组件
public Response itemsList(Map cookies, String classifyId) throws Exception{
String url = "http://" + homeHost + "/chw/visual-editor/items/list";
Map<String,String> map = new HashMap<>();
map.put("classifyId",classifyId);
map.put("pageNo","1");
map.put("pageSize","300");
map.put("sort","custom");
logger.info("请求/chw/visual-editor/items/list接口");
Response response = given().contentType("application/json; charset=UTF-8").cookies(cookies).params(map).get( url);
try{
Assert.assertEquals(response.jsonPath().getString("success"),"true");
}catch(Exception e){
throw new Exception("/chw/visual-editor/items/list接口返回异常,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/chw/visual-editor/items/list接口返回异常,返回信息:"+response.asString());
}
return response;
}
}
......@@ -13,7 +13,7 @@ import static io.restassured.RestAssured.given;
*/
@Service
public class SupplierExchangeTemplateService {
private String dafuwengHost = "dafuweng.duibatest.com.cn";
private String dafuwengHost = "autotest-dafuweng.duibatest.com.cn";
public Response use(String id){
String url = "http://"+dafuwengHost+"/supplierExchangeTemplate/use";
......
package http.service;
import base.AbstractTestNGSpringContextTestsDuiba;
import base.Config;
import base.DuibaBase;
import http.service.app.MobileService;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.test.context.ContextConfiguration;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import java.lang.reflect.Method;
/**
* Created by mabo on 2018/10/9
*/
@Service
public class testservice {
@ContextConfiguration(classes = Config.class)
public class testservice extends AbstractTestNGSpringContextTestsDuiba {
//数据库用户名
@Value("${db.name}")
String USERNAME;
// @Value("${db.name}")
// String USERNAME;
//
// public void test(){
// System.out.println(USERNAME);
// Method method;
//
//
//
// }
@Autowired
http.service.app.gawService gawService;
@Autowired
http.service.app.tawService tawService;
@Autowired
MobileService mobileService;
@Autowired
Authorization authorization;
@DataProvider(name = "testdp", parallel = true)
public static Object[][]testdp(){
return new Object[][]{
{"1"},
{"2"},
{"3"},
{"4"},
{"5"},
{"6"},
{"8"},
{"10"},
{"157"},
{"158"}
};
}
@Test
public void test() throws Exception {
// System.out.println("Current Thread Id: " + Thread.currentThread().getId() + ". Dataprovider number: "+ dpNumber);
// Thread.sleep(5000);
String appItemId = "159040";
String itemId = "null";
String message = "";
String skuId="33";
String actualCredits="8";
String credits="8";
Thread.sleep(3000);
Response response = gawService.objectExchange(1,appItemId,itemId,skuId,credits,actualCredits);
response.prettyPrint();
//(enabled=true, dataProvider="testdp", threadPoolSize=1, invocationCount=2)
}
@Test
public void tesss(){
public void test(){
System.out.println(USERNAME);
}
}
package ui.cases.cms;
import base.DuibaBaseUi;
import http.service.Authorization;
import org.openqa.selenium.Cookie;
import org.openqa.selenium.Keys;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.Test;
import ui.common.WebDriverFactory;
import ui.service.CmsLoginPage;
import ui.service.DafuwengLogin;
import java.util.Map;
import static com.codeborne.selenide.Selenide.open;
import static ui.common.WebDriverType.CHRMOE;
/**
* Created by mabo on 2019/4/10
*/
public class 双列图_Cms_ui extends DuibaBaseUi{
@Autowired
Authorization authorization;
@Autowired
CmsLoginPage cmsLoginPage;
@Autowired
DafuwengLogin dafuwengLogin;
@Test(description = "组件配置")
public void A() throws Exception {
cmsLoginPage.init("15968831723",this);
clickByTextEqual("test");
sleep(2);
clickByTextEqual("双列图");
sleep(2);
clickByTextEqual("添加图片",0);
clickByTextEqual("1.png");
clickByTextEqual("保存");
System.out.println("ok");
clickByTextEqual("添加图片",1);
clickByTextEqual("1.png");
clickByTextEqual("保存");
System.out.println("ok");
clickByTextEqual("添加跳转链接",0);
inputByContainsAttribut("placeholder","请输入无线链接","input","http://www.baidu.com");
sleep(2);
clickByXpath("//*[@class='decoration-link-footer']/button[@class='el-button el-button--primary el-button--medium']");
clickByTextEqual("添加跳转链接",0);
sleep(2);
clickByXpath("//*[@class='decoration-link-footer']/button[@class='el-button el-button--primary el-button--medium']");
sleep(1);
inputByXpath("//*[@placeholder=\"请输入文本,20字以内\"]","test1",0);
inputByXpath("//*[@placeholder=\"请输入文本,20字以内\"]","test2",1);
clickByTextEqual("保存",1);
sleep(4);
scrollToTop();
clickByTextEqual("发布");
sleep(10);
}
@Test(description = "手机端")
public void B() throws Exception {
String url = "http://wechat.duiba.com.cn/dbredirect/dafuweng?dbredirect=%2F%2Factivity.m.duibatest.com.cn%2Fchw%2Fvisual-editor%2Fskins%3Fid%3D134";
dafuwengLogin.init(6926,url,this);
sleep(2);
clickByClass("double-row-item_image");
sleep(3);
String title = driver.getTitle();
Assert.assertEquals(title,"百度一下,你就知道");
driver.navigate().back();
sleep(2);
clickByClass("double-row-item_image",1);
sleep(2);
title = driver.getTitle();
Assert.assertEquals(title,"百度一下,你就知道");
url = driver.getCurrentUrl();
driver.navigate().back();
Assert.assertTrue(isExistByText("test1"));
Assert.assertTrue(isExistByText("test2"));
}
@Test(description = "删除楼层")
public void C() throws Exception {
cmsLoginPage.init("15968831723",this);
clickByTextEqual("test");
sleep(2);
//选中组件
clickByClass("plugin-content-hover",1);
sleep(1);
//点击删除
clickByClass("plugin-delete-icon common-cursor-pointer iconfont-handle handle-guanbi el-popover__reference",1);
sleep(1);
clickByTextEqual("确定",1);
sleep(1);
clickByTextContains("保存");
sleep(4);
scrollToTop();
clickByTextEqual("发布");
sleep(2);
}
}
package ui.cases.cms;
import base.DuibaBaseUi;
import http.service.Authorization;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.Test;
import ui.service.CmsLoginPage;
import ui.service.DafuwengLogin;
/**
* Created by mabo on 2019/4/15
*/
public class 商品分组_Cms_ui extends DuibaBaseUi{
@Autowired
Authorization authorization;
@Autowired
CmsLoginPage cmsLoginPage;
@Autowired
DafuwengLogin dafuwengLogin;
@Test
public void A() throws Exception {
cmsLoginPage.init("15968831723",this);
clickByTextEqual("test");
sleep(2);
clickByTextEqual("商品分组",1);
sleep(3);
clickByTextContains("选择分组",1);
clickByXpath("//*[@class=\"el-table__row\"]//label");
clickByTextEqual("确 定");
clickByTextContains("选择分组",1);
clickByXpath("//*[@class=\"el-table__row\"]//label");
// clickByXpath("//*[@class=\"el-table__row el-table__row--striped \"]//label");
clickByTextEqual("确 定");
inputByXpath("//*[@class=\"el-input el-input--medium\"]//input","test1",0);
inputByXpath("//*[@class=\"el-input el-input--medium\"]//input","test2",1);
clickByTextEqual("保存",1);
sleep(5);
scrollToTop();
clickByTextEqual("发布");
sleep(10);
}
@Test
public void B() throws Exception {
String url = "http://wechat.duiba.com.cn/dbredirect/dafuweng?dbredirect=%2F%2Factivity.m.duibatest.com.cn%2Fchw%2Fvisual-editor%2Fskins%3Fid%3D134";
dafuwengLogin.init(6926,url,this);
Assert.assertTrue(isExistByText("test1"));
Assert.assertTrue(isExistByText("test2"));
Assert.assertTrue(isExistContainsText("(勿动)新优惠券日期进行中"));
Assert.assertTrue(isExistContainsText("(勿动)新优惠券日期已结束"));
clickByTextContains("(勿动)新优惠券日期已结束");
sleep(2);
String title = driver.getTitle();
Assert.assertEquals(title,"(勿动)新优惠券日期已结束");
driver.navigate().back();
clickByTextEqual("test2");
clickByTextContains("(勿动)新优惠券日期进行中",1);
sleep(2);
title = driver.getTitle();
Assert.assertEquals(title,"(勿动)新优惠券日期进行中");
}
@Test(description = "删除楼层")
public void C() throws Exception {
cmsLoginPage.init("15968831723",this);
clickByTextEqual("test");
sleep(2);
//选中组件
clickByClass("plugin-content-hover",1);
sleep(1);
//点击删除
clickByClass("plugin-delete-icon common-cursor-pointer iconfont-handle handle-guanbi el-popover__reference",1);
sleep(1);
clickByTextEqual("确定",1);
scrollToTop();
clickByTextContains("保存");
sleep(5);
scrollToTop();
clickByTextEqual("发布");
sleep(10);
}
}
package ui.cases.cms;
import base.DuibaBaseUi;
import http.service.Authorization;
import org.openqa.selenium.Cookie;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.Test;
import ui.service.CmsLoginPage;
import ui.service.DafuwengLogin;
import java.util.Map;
import static com.codeborne.selenide.Selenide.open;
/**
* Created by mabo on 2019/4/15
*/
public class 活动分组_Cms_ui extends DuibaBaseUi{
@Autowired
Authorization authorization;
@Autowired
CmsLoginPage cmsLoginPage;
@Autowired
DafuwengLogin dafuwengLogin;
@Test(description = "组件配置")
public void A() throws Exception {
cmsLoginPage.init("15968831723",this);
clickByTextEqual("test");
sleep(2);
clickByTextEqual("活动分组");
sleep(3);
clickByTextEqual("选择分组",0);
clickByXpath("//*[@class=\"el-table__row\"]");
clickByTextEqual("确 定");
clickByTextEqual("选择分组",0);
clickByXpath("//*[@class=\"el-table__row\"]");
clickByTextEqual("确 定");
inputByXpath("//*[@class=\"el-input__inner\"]","test1",1);
inputByXpath("//*[@class=\"el-input__inner\"]","test2",3);
clickByTextEqual("保存",1);
sleep(5);
scrollToTop();
clickByTextEqual("发布");
sleep(10);
}
@Test(description = "手机端")
public void B() throws Exception {
String url = "http://wechat.duiba.com.cn/dbredirect/dafuweng?dbredirect=%2F%2Factivity.m.duibatest.com.cn%2Fchw%2Fvisual-editor%2Fskins%3Fid%3D134";
dafuwengLogin.init(6926,url,this);
Assert.assertTrue(isExistByText("test1"));
Assert.assertTrue(isExistByText("test2"));
Assert.assertTrue(isExistByText("活动组测试1"));
Assert.assertTrue(isExistByText("活动组测试2"));
clickByTextEqual("活动组测试1");
sleep(2);
String title = driver.getTitle();
Assert.assertEquals(title,"活动组测试1");
driver.navigate().back();
clickByTextEqual("test2");
clickByTextEqual("活动组测试2",1);
sleep(2);
title = driver.getTitle();
Assert.assertEquals(title,"活动组测试2");
}
@Test(description = "删除楼层")
public void C() throws Exception {
cmsLoginPage.init("15968831723",this);
clickByTextEqual("test");
sleep(2);
//选中组件
clickByClass("plugin-content-hover",1);
sleep(1);
//点击删除
clickByClass("plugin-delete-icon common-cursor-pointer iconfont-handle handle-guanbi el-popover__reference",1);
sleep(1);
clickByTextEqual("确定",1);
scrollToTop();
clickByTextContains("保存");
sleep(5);
clickByTextEqual("发布");
sleep(10);
}
}
This diff is collapsed.
package ui.service;
import base.DuibaBaseUi;
import http.service.Authorization;
import org.openqa.selenium.Cookie;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import java.util.Map;
import static com.codeborne.selenide.Selenide.open;
/**
* Created by mabo on 2019/4/16
*/
@Service
public class CmsLoginPage {
@Autowired
Authorization authorization;
public void init(String account, DuibaBaseUi father) throws Exception {
father.open("http://hd.dlp.duibatest.com.cn");
father.switchChrome();
open("http://hd.dlp.duibatest.com.cn");
Map<String,String> map = authorization.hdLoginCommonNew(account);
for (String key:map.keySet()
) {
father.driver.manage().addCookie(new Cookie(key,map.get(key)));
}
open("http://hd.dlp.duibatest.com.cn/static/index?appId=22563#/creditShop/creditShopSub/creditShopRenovation/renovation");
father.clickByClass("el-dialog__headerbtn");
father.clickByClass("iconfont-handle handle-xiangxiazhankai");
father.sleep(2);
}
}
package ui.service;
import base.DuibaBaseUi;
import http.service.Authorization;
import org.openqa.selenium.Cookie;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Map;
/**
* Created by mabo on 2019/4/17
*/
@Service
public class DafuwengLogin {
@Autowired
Authorization authorization;
public void init(int uid,String url,DuibaBaseUi father){
father.switchChrome();
father.open(url);
Map<String,String> map = authorization.dafuwengLogin(uid);
for (String key:map.keySet()
) {
father.driver.manage().addCookie(new Cookie(key,map.get(key)));
}
father.open(url);
}
}
......@@ -10,7 +10,7 @@ import static java.lang.Thread.sleep;
* Created by mabo on 2018/12/17
*/
public class MoblieLogin{
private String dafuwengUrl="http://dafuweng.duibatest.com.cn/user/index";
private String dafuwengUrl="http://autotest-dafuweng.duibatest.com.cn/user/index";
public MoblieLogin(String uid, DuibaBaseUi father) throws Exception {
open(dafuwengUrl);
father.clickByTextEqual(uid);
......
......@@ -4,7 +4,7 @@ proxyserver.ip=172.16.80.203
proxyserver.port=22
proxyserver.user=dev
proxyserver.prvkey=key/hzlId_rsa
dafuweng.host=dafuweng.duibatest.com.cn
dafuweng.host=autotest-dafuweng.duibatest.com.cn
dafuweng.port=80
uid=2707
appId=2239
......@@ -21,10 +21,13 @@ home.host = activity.m.duibatest.com.cn
manager.host = mng.duibatest.com.cn
trade.host = activity.m.duibatest.com.cn
//\u6570\u636E\u5E93\u914D\u7F6E
//数据库
db.name = FjrtzzH
db.password= 2Fe36uDap8TMqtfzob3f1u8r2aK8qjdnwPP
db.url = jdbc:mysql://47.97.127.67:13001/?tinyInt1isBit=false
//db.url = jdbc:mysql://47.97.127.67:13001/?tinyInt1isBit=false
db.url = jdbc:mysql://autotest-config.duibatest.com.cn:3306/?tinyInt1isBit=false&connectTimeout=10000&socketTimeout=10000
db.driver= com.mysql.cj.jdbc.Driver
db.maxtotal = 6
......@@ -32,48 +35,49 @@ db.maxtotal = 6
pluginTest.project=插件
pluginTest.names=zhaoran,qianwenjun
pluginTest.group=插件-接口自动化
pluginTest.resultUrl=http://tst-idc.deploy.dui88.com/view/duibaTest/job/duibaPlugin_interface/HTML_20Report/suite1_test1_results.html
pluginTest.resultUrl=http://10.254.187.25/view/duibaTest/job/duibaPlugin_interface/HTML_20Report/suite1_test1_results.html
pluginTest.job=duibaPlugin_interface
signTest.project=签到
signTest.names=zhousongbo
signTest.group=签到-接口自动化
signTest.resultUrl=http://tst-idc.deploy.dui88.com/view/duibaTest/job/duibaSign_interface/HTML_20Report/suite1_test1_results.html
signTest.resultUrl=http://10.254.187.25/view/duibaTest/job/duibaSign_interface/HTML_20Report/suite1_test1_results.html
signTest.job=duibaSign_interface
FloorTest.project=楼层
FloorTest.names=zhaoran,qianwenjun
FloorTest.group=楼层-接口自动化
FloorTest.resultUrl=http://tst-idc.deploy.dui88.com/view/duibaTest/job/duibaFloor_interface/HTML_20Report/suite1_test1_results.html
FloorTest.resultUrl=http://10.254.187.25/view/duibaTest/job/duibaFloor_interface/HTML_20Report/suite1_test1_results.html
FloorTest.job=duibaFloor_interface
DuibaTest.project=活动工具
DuibaTest.names=zhaoran,qianwenjun
DuibaTest.group=活动工具-接口自动化
DuibaTest.resultUrl=http://tst-idc.deploy.dui88.com/view/duibaTest/job/duiba_interface/HTML_20Report/suite1_test1_results.html
DuibaTest.resultUrl=http://10.254.187.25/view/duibaTest/job/duiba_interface/HTML_20Report/suite1_test1_results.html
DuibaTest.job=duiba_interface
AccessTest.project=综合业务(单品抽奖/秒杀/游戏)
AccessTest.names=zhaoran,qianwenjun
AccessTest.group=综合业务-接口自动化
AccessTest.resultUrl=http://tst-idc.deploy.dui88.com/view/duibaTest/job/duibaAccess_interface/HTML_20Report/suite1_test1_results.html
AccessTest.resultUrl=http://10.254.187.25/view/duibaTest/job/duibaAccess_interface/HTML_20Report/suite1_test1_results.html
AccessTest.job=duibaAccess_interface
JenkinsTest.project=综合业务(单品抽奖/秒杀/游戏)
JenkinsTest.names=zhaoran,qianwenjun
JenkinsTest.group=综合业务-接口自动化
JenkinsTest.resultUrl=http://tst-idc.deploy.dui88.com/view/duibaTest/job/duibaAccess_interface/HTML_20Report/suite1_test1_results.html
JenkinsTest.resultUrl=http://10.254.187.25/view/duibaTest/job/duibaAccess_interface/HTML_20Report/suite1_test1_results.html
ExchangeTest.project=普兑业务
ExchangeTest.names=panyuli
ExchangeTest.group=普兑业务-接口自动化
ExchangeTest.resultUrl=http://tst-idc.deploy.dui88.com/view/duibaTest/job/duibaExchange_interface/HTML_20Report/suite1_test1_results.html
ExchangeTest.resultUrl=http://10.254.187.25/view/duibaTest/job/duibaExchange_interface/HTML_20Report/suite1_test1_results.html
ExchangeTest.job=duibaExchange_interface
SeckillTest.project=秒杀业务
SeckillTest.names=qianwenjun
SeckillTest.group=秒杀业务-接口自动化
SeckillTest.resultUrl=http://tst-idc.deploy.dui88.com/view/duibaTest/job/Seckill_interface/HTML_20Report/suite1_test1_results.html
SeckillTest.resultUrl=http://10.254.187.25/view/duibaTest/job/Seckill_interface/HTML_20Report/suite1_test1_results.html
SeckillTest.job=Seckill_interface
ui.project=界面自动化核心业务
......
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