Commit d02e8686 authored by 钱雯君's avatar 钱雯君

Merge branch 'develop' of http://gitlab2.dui88.com/mabo/test-platform into develop

parents d226090e 8130659d
......@@ -47,6 +47,11 @@ public class TestReport implements IReporter{
}
}
total=passCount+skipCount+failCount;
System.out.println("~~~~~~~~~~~~~~~~~~~~~total:"+total);
System.out.println("~~~~~~~~~~~~~~~~~~~~~failCount:"+failCount);
System.out.println("~~~~~~~~~~~~~~~~~~~~~skipCount:"+skipCount);
System.out.println("~~~~~~~~~~~~~~~~~~~~~passCount"+passCount);
DingdingResult ddResult=null;
try{
ddResult=new DingdingResult(total,passCount,skipCount,failCount);
......
package http.cases.ExchangeTest;
public class Database {
//主订单库
public static String orders_consumer = "orders_consumer";
//主订单分表
public static String orders = "orders_0614";
public static String orders2 = "orders_0874";
public static String orders3 = "orders_0693";
public static String orders4 = "orders_0208";
public static String orders5 = "orders_0209";
public static String orders6 = "orders_0210";
public static String orders7 = "orders_0211";
public static String orders8 = "orders_0090";
}
package http.cases.ExchangeTest;
import base.DuibaTestBase;
import http.service.Activity.ManagerService;
import http.service.Authorization;
import http.service.app.CouponExchangeService;
import http.service.app.MobileService;
import http.service.app.SeckillService;
import http.service.hd.PlatformCouponService;
import base.DuibaLog;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.testng.Assert;
import org.testng.annotations.Test;
import java.util.Map;
//@ContextConfiguration(classes = DuibaConfig.class)
public class Exchange_ExchangeTest extends DuibaTestBase{
@Value("${manager.host}")
String ManagerHost;
@Autowired
private MobileService mobileService;
@Autowired
private Authorization authorization;
@Autowired
private CouponExchangeService couponExchangeService;
@Autowired
private PlatformCouponService platformCouponService;
@Autowired
private SeckillService SeckillService;
@Autowired
ManagerService managerService;
private DuibaLog logger = DuibaLog.getLogger();
// private MysqlUtils jdbc;
//指定用户
private static int uid = 3766;
// @BeforeClass
// public void before(){
// jdbc = MysqlUtils.mysqlDuiba("dafuweng");
// }
// @AfterClass
// public void after(){
// jdbc.releaseConn();
//
// }
//实物兑换并发货
@Test(description = "实物兑换")
public void goods() throws Exception {
//查询数据库,当前积分
Map<String,Object> mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
String credits = String.valueOf(mapuser.get("credits"));
logger.info("兑换前积分:"+credits);
//扣去100积分
credits = String.valueOf(Integer.valueOf(credits)-100);
//活动详情页
Response response =mobileService.detail(authorization.dafuwengLogin(uid),"26762");
Map<String,String> map = authorization.dafuwengLogin(uid);
Assert.assertEquals(String.valueOf(response.getStatusCode()),"200","活动详情页请求异常");
//实物兑换
response = couponExchangeService.objectExchange(map,"159143","2619","null","z9sydmcs","null");
// response.prettyPrint();
//校验兑换成功
// Assert.assertEquals(response.jsonPath().getString("success"),"true");
//获取orderId
String orderId = response.jsonPath().getString("orderId");
//获取兑换结果
response = mobileService.orderAmbStatusQuery(uid,orderId);
response.prettyPrint();
String message = response.jsonPath().getString("data.message");
int i=10;
//异步接口,直到兑换成功
while(i>0&&"兑换正在处理中...".equals(message)){
Thread.sleep(1000);
response = mobileService.orderAmbStatusQuery(uid,orderId);
response.prettyPrint();
message = response.jsonPath().getString("data.message");
i--;
}
//查询数据库,获取当前积分
Thread.sleep(3000);
mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
String creditsNew = String.valueOf(mapuser.get("credits"));
logger.info("兑换后积分:"+creditsNew);
//校验比较,兑换前后积分
Assert.assertEquals(credits,creditsNew);
logger.info("校验兑换前后积分正确");
//兑吧管理后台发货
managerService.expressSend(orderId);
logger.info("实物兑换订单成功");
}
//秒杀
@Test(description = "秒杀兑换")
public void seckill(){
Response response = SeckillService.ajaxSubmit("18556");
response.prettyPrint();
Assert.assertEquals(response.jsonPath().getString("success"),"true");
}
//优惠券兑换
@Test(description = "优惠券兑换")
public void coupon() throws Exception {
//查询数据库,当前积分
Map<String,Object> mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
String credits = String.valueOf(mapuser.get("credits"));
logger.info("兑换前积分:"+credits); //扣去100积分
credits = String.valueOf(Integer.valueOf(credits)-100);
//优惠券兑换
Response response = couponExchangeService.couponExchange(authorization.dafuwengLogin(uid),"157070","27050");
String orderId = response.jsonPath().getString("orderId");
//查看兑换结果
response = mobileService.orderStatusQuery(response.getDetailedCookies(),uid,orderId);
String status = response.jsonPath().getString("status");
//异步接口
int i=10;
while(i>0&&"processing".equals(status)){
Thread.sleep(1000);
response = mobileService.orderStatusQuery(response.getDetailedCookies(),uid,orderId);
response.prettyPrint();
status = response.jsonPath().getString("status");
i--;
}
//查询数据库,获取当前积分
Thread.sleep(3000);
mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
String creditsNew = String.valueOf(mapuser.get("credits"));
logger.info("兑换后积分:"+creditsNew);
//校验比较,兑换前后积分
Assert.assertEquals(credits.trim(),creditsNew,"优惠券兑换后积分扣除异常");
logger.info("校验兑换前后积分正确");
}
}
package http.cases.ExchangeTest;
import base.DuibaTestBase;
import http.service.Activity.ManagerService;
import http.service.Authorization;
import http.service.app.*;
import utils.ExcelDataProvider;
import base.DuibaLog;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import java.io.IOException;
import java.lang.reflect.Method;
import java.util.Iterator;
import java.util.Map;
/**
* Created by yeqinqin on 2018/4/24.
*/
public class ObjectExchange_ExchangeTest extends DuibaTestBase{
@Autowired
private MobileService mobileService;
@Autowired
private Authorization authorization;
@Autowired
private CouponExchangeService couponExchangeService;
@Autowired
private CrecordService crecordService;
@Autowired
ManagerService managerService;
@Autowired
VirtualExchangeService virtualExchangeService;
@Autowired
QbExchangeService qbExchangeService;
private DuibaLog logger = DuibaLog.getLogger();
//指定用户
private static int uid = 2707;
@BeforeClass
public void before() {
managerService.update(uid,"5555555");
// jdbc = MysqlUtils.mysqlDuiba("orders_consumer");
try {
jdbc.update("delete from orders_consumer.orders_0614 where consumer_id = 100011622 and biz_params = 'DUIBA_SELF'", null);
} catch (Exception e) {
e.printStackTrace();
}
}
// @AfterClass
// public void after() {
// jdbc.releaseConn();
//
// }
//实物兑换并发货
//@Test(description = "实物兑换")
public void goods() throws Exception {
//查询数据库,当前积分
Map<String, Object> mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
String credits = String.valueOf(mapuser.get("credits"));
logger.info("兑换前积分:" + credits);
//扣去100积分
credits = String.valueOf(Integer.valueOf(credits) - 100);
//活动详情页
Response response = mobileService.detail(authorization.dafuwengLogin(uid), "26762");
Map<String, String> map = authorization.dafuwengLogin(uid);
Assert.assertEquals(String.valueOf(response.getStatusCode()), "200", "活动详情页请求异常");
//实物兑换
response = couponExchangeService.objectExchange(map, "159143", "2619", "null", "z9sydmcs", "null");
// response.prettyPrint();
//校验兑换成功
// Assert.assertEquals(response.jsonPath().getString("success"),"true");
//获取orderId
String orderId = response.jsonPath().getString("orderId");
//获取兑换结果
response = mobileService.orderAmbStatusQuery(uid,orderId);
response.prettyPrint();
String message = response.jsonPath().getString("data.message");
int i = 10;
//异步接口,直到兑换成功
while (i > 0 && "兑换正在处理中...".equals(message)) {
Thread.sleep(1000);
response = mobileService.orderAmbStatusQuery(uid,orderId);
response.prettyPrint();
message = response.jsonPath().getString("data.message");
i--;
}
//查询数据库,获取当前积分
mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
String creditsNew = String.valueOf(mapuser.get("credits"));
logger.info("兑换后积分:" + creditsNew);
//校验比较,兑换前后积分
Assert.assertEquals(credits, creditsNew);
logger.info("校验兑换前后积分正确");
//兑吧管理后台发货
managerService.expressSend(orderId);
logger.info("实物兑换订单成功");
}
//优惠券兑换
//@Test(description = "优惠券兑换")
public void coupon() throws Exception {
//查询数据库,当前积分
Map<String, Object> mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
String credits = String.valueOf(mapuser.get("credits"));
logger.info("兑换前积分:" + credits); //扣去100积分
credits = String.valueOf(Integer.valueOf(credits) - 100);
//优惠券兑换
Response response = couponExchangeService.couponExchange(authorization.dafuwengLogin(uid), "157070", "27050");
String orderId = response.jsonPath().getString("orderId");
//查看兑换结果
response = mobileService.orderStatusQuery(response.getDetailedCookies(), uid,orderId);
String status = response.jsonPath().getString("status");
//异步接口
int i = 10;
while (i > 0 && "processing".equals(status)) {
Thread.sleep(1000);
response = mobileService.orderStatusQuery(response.getDetailedCookies(),uid, orderId);
response.prettyPrint();
status = response.jsonPath().getString("status");
i--;
}
//查询数据库,获取当前积分
mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
Map<String,Object> mapConsumer = jdbc.findSimpleResult("SELECT * FROM new_consumer.consumer_0010 WHERE `app_id` = 2239 AND id = 100011622");
String creditsNew = String.valueOf(mapuser.get("credits"));
String creditsCon = String.valueOf(mapConsumer.get("credits"));
logger.info("兑换后积分:" + creditsNew);
//校验比较,兑换前后积分
Assert.assertEquals(credits.trim(), creditsNew, "优惠券兑换后积分扣除异常");
Assert.assertEquals(creditsCon,creditsNew,"本地积分与用户积分不符");
logger.info("校验兑换前后积分正确");
}
//直充类单档话费兑换_1元话费
@Test(description = "直充类单档话费兑换")
public void phonebillDingzhi() throws Exception {
Thread.sleep(2000);
Map<String, Object> mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
String credits = String.valueOf(mapuser.get("credits"));
logger.info("兑换前积分:" + credits);
//扣去100积分
credits = String.valueOf(Integer.valueOf(credits) - 100);
//兑换详情页
Response response = mobileService.detail(authorization.dafuwengLogin(uid), "1660");
Map<String, String> map = authorization.dafuwengLogin(uid);
Assert.assertEquals(String.valueOf(response.getStatusCode()), "200", "活动详情页请求异常");
//1元话费兑换
response = couponExchangeService.phonebillExchange(authorization.dafuwengLogin(uid), "156497", "1660");
response.prettyPrint();
//获取orderId
String orderId = response.jsonPath().getString("orderId");
//获取提交结果
response = mobileService.orderStatusQuery(response.getDetailedCookies(), uid,orderId);
response.prettyPrint();
String message = response.jsonPath().getString("message");
int i = 10;
//异步接口,兑换提交成功!待处理
while (i > 0 && "兑换正在处理中...".equals(message)) {
Thread.sleep(1000);
response = mobileService.orderStatusQuery(response.getDetailedCookies(),uid, orderId);
response.prettyPrint();
message = response.jsonPath().getString("message");
i--;
}
//获取兑换结果
response = crecordService.recordFresh(uid,orderId);
response.prettyPrint();
String isProcess = response.jsonPath().getString("isProcess");
int j = 10;
//异步接口,兑换成功
while (j > 0 && "兑换正在处理中...".equals(isProcess)) {
Thread.sleep(1000);
response = crecordService.recordFresh(uid,orderId);
response.prettyPrint();
isProcess = response.jsonPath().getString("isProcess");
j--;
}
//查询数据库,获取当前积分
Thread.sleep(2000);
mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
String creditsNew = String.valueOf(mapuser.get("credits"));
logger.info("兑换后积分:" + creditsNew);
//校验比较,兑换前后积分
Assert.assertEquals(credits.trim(), creditsNew, "话费兑换后积分扣除异常");
logger.info("校验兑换前后积分正确");
}
//多档位话费兑换_10元话费
@Test(dataProvider = "providerMethod")
public void 多档位兑换(Map<String,String> data) throws Exception {
Map<String, Object> mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
String credits = String.valueOf(mapuser.get("credits"));
logger.info("兑换前积分:" + credits);
//扣去100积分
credits = String.valueOf(Integer.valueOf(credits) - Integer.valueOf(data.get("credits")));
//兑换详情页
Response response = mobileService.detail(authorization.dafuwengLogin(uid), "1");
Map<String, String> map = authorization.dafuwengLogin(uid);
Assert.assertEquals(String.valueOf(response.getStatusCode()), "200", "活动详情页请求异常");
//10元话费兑换
response = couponExchangeService.phonebillExchange(authorization.dafuwengLogin(uid), data.get("degreeId"));
response.prettyPrint();
//获取orderId
String orderId = response.jsonPath().getString("orderId");
//获取提交结果
response = mobileService.orderStatusQuery(response.getDetailedCookies(),uid, orderId);
response.prettyPrint();
String message = response.jsonPath().getString("message");
int i = 10;
//异步接口,兑换提交成功!待处理
while (i > 0 && "兑换正在处理中...".equals(message)) {
Thread.sleep(1000);
response = mobileService.orderStatusQuery(response.getDetailedCookies(),uid, orderId);
response.prettyPrint();
message = response.jsonPath().getString("message");
i--;
}
//获取兑换结果
response = crecordService.recordFresh(uid,orderId);
response.prettyPrint();
String isProcess = response.jsonPath().getString("isProcess");
int j = 10;
//异步接口,兑换成功
while (j > 0 && "兑换正在处理中...".equals(isProcess)) {
Thread.sleep(1000);
response = crecordService.recordFresh(uid,orderId);
response.prettyPrint();
isProcess = response.jsonPath().getString("isProcess");
j--;
}
//查询数据库,获取当前积分
Thread.sleep(3000);
mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
String creditsNew = String.valueOf(mapuser.get("credits"));
logger.info("兑换后积分:" + creditsNew);
//校验比较,兑换前后积分
Assert.assertEquals(credits.trim(), creditsNew, "话费兑换后积分扣除异常");
logger.info("校验兑换前后积分正确");
}
//自有实物兑换并发货
@Test(description = "实物兑换")
public void 自有实物兑换() throws Exception {
//查询数据库,当前积分
Map<String, Object> mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
Map<String, Object> mapStock = jdbc.findSimpleResult("select * from stock.tb_stock where stock_id = 674900860200090332");
String credits = String.valueOf(mapuser.get("credits"));
logger.info("兑换前积分:" + credits);
//扣去100积分
credits = String.valueOf(Integer.valueOf(credits) - 1);
String stock = String.valueOf(mapStock.get("stock"));
logger.info("兑换前库存:" + stock);
//扣去1
stock = String.valueOf(Integer.valueOf(stock) - 1);
//活动详情页
Response response = mobileService.detail(authorization.dafuwengLogin(uid), "27970");
Map<String, String> map = authorization.dafuwengLogin(uid);
Assert.assertEquals(String.valueOf(response.getStatusCode()), "200", "活动详情页请求异常");
//实物兑换
response = couponExchangeService.objectExchange(map, "161100", null, "null", "z9sydmcs", "null");
// response.prettyPrint();
//校验兑换成功
// Assert.assertEquals(response.jsonPath().getString("success"),"true");
//获取orderId
String orderId = response.jsonPath().getString("orderId");
//获取兑换结果
response = mobileService.orderAmbStatusQuery(uid,orderId);
response.prettyPrint();
String message = response.jsonPath().getString("data.message");
int i = 10;
//异步接口,直到兑换成功
while (i > 0 && "兑换正在处理中...".equals(message)) {
Thread.sleep(1000);
response = mobileService.orderAmbStatusQuery(uid,orderId);
response.prettyPrint();
message = response.jsonPath().getString("data.message");
i--;
}
//查询数据库,获取当前积分
mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
String creditsNew = String.valueOf(mapuser.get("credits"));
logger.info("兑换后积分:" + creditsNew);
//校验比较,兑换前后库存
Assert.assertEquals(credits, creditsNew,"积分校验失败");
logger.info("校验兑换前后积分正确");
mapStock = jdbc.findSimpleResult("select * from stock.tb_stock where stock_id = 674900860200090332");
String stockNew = String.valueOf(mapStock.get("stock"));
logger.info("兑换后库存:" + stockNew);
//校验比较,兑换前后积分
Assert.assertEquals(stock, stockNew,"库存校验失败");
logger.info("校验兑换前后库存正确");
//兑吧管理后台发货
// response = managerService.expressSend(orderId);
// logger.info("实物兑换订单成功");
}
//自有优惠券兑换_重复券
@Test(description = "自有优惠券兑换")
public void 自有优惠券() throws Exception {
//查询数据库,当前积分
Map<String, Object> mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
//select * from goods.tb_goods_batch where gid=159857 查询库存id gid=itemid
Map<String, Object> mapStock = jdbc.findSimpleResult("select * from stock.tb_stock where stock_id = 607824566024920113");
String stock = String.valueOf(mapStock.get("stock"));
logger.info("兑换前库存:" + stock);
//扣去1
stock = String.valueOf(Integer.valueOf(stock) - 1);
String credits = String.valueOf(mapuser.get("credits"));
logger.info("兑换前积分:" + credits); //扣去100积分
credits = String.valueOf(Integer.valueOf(credits) - 1);
//优惠券兑换
Response response = couponExchangeService.couponExchange(authorization.dafuwengLogin(uid), "159857", null);
String orderId = response.jsonPath().getString("orderId");
//查看兑换结果
response = mobileService.orderStatusQuery(response.getDetailedCookies(), uid,orderId);
String status = response.jsonPath().getString("status");
//异步接口
int i = 10;
while (i > 0 && "processing".equals(status)) {
Thread.sleep(1000);
response = mobileService.orderStatusQuery(response.getDetailedCookies(),uid, orderId);
response.prettyPrint();
status = response.jsonPath().getString("status");
i--;
}
response.prettyPrint();
//查询数据库,获取当前积分
mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
String creditsNew = String.valueOf(mapuser.get("credits"));
logger.info("兑换后积分:" + creditsNew);
//校验比较,兑换前后积分
Assert.assertEquals(credits.trim(), creditsNew, "优惠券兑换后积分扣除异常");
logger.info("校验兑换前后积分正确");
mapStock = jdbc.findSimpleResult("select * from stock.tb_stock where stock_id = 607824566024920113");
String stockNew = String.valueOf(mapStock.get("stock"));
logger.info("兑换后库存:" + stockNew);
//校验比较,兑换前后积分
Assert.assertEquals(stock, stockNew,"库存校验失败");
logger.info("校验兑换前后库存正确");
}
//自有虚拟商品单档兑换
@Test(description = "自有虚拟商品单档兑换")
public void 自有虚拟商品单档兑换() throws Exception {
//查询数据库,当前积分
Map<String, Object> mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
String credits = String.valueOf(mapuser.get("credits"));
logger.info("兑换前积分:" + credits); //扣去100积分
credits = String.valueOf(Integer.valueOf(credits) - 1);
Map<String, Object> mapStock = jdbc.findSimpleResult("select * from stock.tb_stock where stock_id = 674900860200070105");
String stock = String.valueOf(mapStock.get("stock"));
logger.info("兑换前库存:" + stock);
//扣去1
stock = String.valueOf(Integer.valueOf(stock) - 1);
//优惠券兑换
Response response = virtualExchangeService.exchange(authorization.dafuwengLogin(uid), "159849", "DUIBA_SELF");
String orderId = response.jsonPath().getString("orderId");
//查看兑换结果
response = mobileService.orderStatusQuery(response.getDetailedCookies(), uid,orderId);
String status = response.jsonPath().getString("status");
//异步接口
int i = 10;
while (i > 0 && "processing".equals(status)) {
Thread.sleep(1000);
response = mobileService.orderStatusQuery(response.getDetailedCookies(), uid,orderId);
response.prettyPrint();
status = response.jsonPath().getString("status");
i--;
}
Thread.sleep(1000);
//查询数据库,获取当前积分
mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
String creditsNew = String.valueOf(mapuser.get("credits"));
logger.info("兑换后积分:" + creditsNew);
//校验比较,兑换前后积分
Assert.assertEquals(credits.trim(), creditsNew, "优惠券兑换后积分扣除异常");
logger.info("校验兑换前后积分正确");
mapStock = jdbc.findSimpleResult("select * from stock.tb_stock where stock_id = 674900860200070105");
String stockNew = String.valueOf(mapStock.get("stock"));
logger.info("兑换后库存:" + stockNew);
//校验比较,兑换前后积分
Assert.assertEquals(stock, stockNew,"库存校验失败");
logger.info("校验兑换前后库存正确");
Thread.sleep(2000);
Map<String, Object> selectResult = jdbc.findSimpleResult("select * from orders_consumer.orders_0614 where consumer_id = 100011622 and biz_params = 'DUIBA_SELF' ",null);
//logger.info("selectResult结果为:"+selectResult);
Assert.assertEquals( selectResult.get("biz_params"),"DUIBA_SELF","虚拟商品出奖标识DUIBA_SELF校验失败");
logger.info("数据库存储虚拟商品标记结果为:"+selectResult.get("biz_params"));
}
//直充类流量兑换
@Test(description = "直充类流量兑换")
public void 流量兑换() throws Exception {
int uid = 4376;
Thread.sleep(2000);
Map<String, Object> mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
String credits = String.valueOf(mapuser.get("credits"));
logger.info("兑换前积分:" + credits);
//扣去100积分
credits = String.valueOf(Integer.valueOf(credits) - 600);
//兑换详情页
Response response = mobileService.detail(authorization.dafuwengLogin(uid), "3");
//Map<String, String> map = authorization.dafuwengLogin(uid);
Assert.assertEquals(String.valueOf(response.getStatusCode()), "200", "活动详情页请求异常");
//流量兑换
response = couponExchangeService.phoneflowExchange(authorization.dafuwengLogin(uid), "51200", "3","13193354550","中国联通","陕西");
response.prettyPrint();
//获取orderId
String orderId = response.jsonPath().getString("orderId");
//获取提交结果
response = mobileService.orderStatusQuery(response.getDetailedCookies(),uid, orderId);
response.prettyPrint();
String message = response.jsonPath().getString("message");
int i = 10;
//异步接口,兑换提交成功!待处理
while (i > 0 && "兑换正在处理中...".equals(message)) {
Thread.sleep(1000);
response = mobileService.orderStatusQuery(response.getDetailedCookies(),uid, orderId);
response.prettyPrint();
message = response.jsonPath().getString("message");
i--;
}
//获取兑换结果
response = crecordService.recordFresh(uid,orderId);
response.prettyPrint();
String isProcess = response.jsonPath().getString("isProcess");
int j = 10;
//异步接口,兑换成功
while (j > 0 && "兑换正在处理中...".equals(isProcess)) {
Thread.sleep(1000);
response = crecordService.recordFresh(uid,orderId);
response.prettyPrint();
isProcess = response.jsonPath().getString("isProcess");
j--;
}
//查询数据库,获取当前积分
Thread.sleep(2000);
mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
String creditsNew = String.valueOf(mapuser.get("credits"));
logger.info("兑换后积分:" + creditsNew);
//校验比较,兑换前后积分
Assert.assertEquals(credits.trim(), creditsNew, "话费兑换后积分扣除异常");
logger.info("校验兑换前后积分正确");
}
//直充类支付宝兑换
@Test(description = "直充类支付宝兑换")
public void 支付宝兑换() throws Exception {
Map<String, Object> mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
String credits = String.valueOf(mapuser.get("credits"));
logger.info("兑换前积分:" + credits);
//扣去100积分
credits = String.valueOf(Integer.valueOf(credits) - 100);
//兑换详情页
Response response = mobileService.detail(authorization.dafuwengLogin(uid), "55");
Map<String, String> map = authorization.dafuwengLogin(uid);
Assert.assertEquals(String.valueOf(response.getStatusCode()), "200", "活动详情页请求异常");
//支付宝(1元)兑换
response = couponExchangeService.alipayExchange(uid,"55");
response.prettyPrint();
//获取orderId
String orderId = response.jsonPath().getString("orderId");
//获取提交结果
response = mobileService.orderStatusQuery(response.getDetailedCookies(), uid,orderId);
response.prettyPrint();
String message = response.jsonPath().getString("message");
int i = 10;
//异步接口,兑换提交成功!待处理
while (i > 0 && "兑换正在处理中...".equals(message)) {
Thread.sleep(1000);
response = mobileService.orderStatusQuery(response.getDetailedCookies(),uid, orderId);
response.prettyPrint();
message = response.jsonPath().getString("message");
i--;
}
//获取兑换结果
response = crecordService.recordFresh(uid,orderId);
response.prettyPrint();
String isProcess = response.jsonPath().getString("isProcess");
int j = 10;
//异步接口,兑换成功
while (j > 0 && "兑换正在处理中...".equals(isProcess)) {
Thread.sleep(1000);
response = crecordService.recordFresh(uid,orderId);
response.prettyPrint();
isProcess = response.jsonPath().getString("isProcess");
j--;
}
//查询数据库,获取当前积分
mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
String creditsNew = String.valueOf(mapuser.get("credits"));
logger.info("兑换后积分:" + creditsNew);
//校验比较,兑换前后积分
Assert.assertEquals(credits.trim(), creditsNew, "支付宝兑换后积分扣除异常");
logger.info("校验兑换前后积分正确");
}
// @Test(description = "qb 兑换",dataProvider = "providerMethodQb")
public void qbExchange(Map<String,String> data) throws Exception {
Map<String, Object> mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
String credits = String.valueOf(mapuser.get("credits"));
logger.info("兑换前积分:" + credits);
Response response = qbExchangeService.doTakePrize(authorization.dafuwengLogin(uid),"1234345554",data.get("degreeId"));
// response.prettyPrint();
String orderId = (String)response.jsonPath().get("orderId");
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid),orderId);
String message = response.jsonPath().getString("message");
int i=10;
while(!message.equals("兑换提交成功!待处理")&&i>0){
Thread.sleep(1000);
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid),orderId);
message = response.jsonPath().getString("message");
i--;
}
//查询数据库,获取当前积分
Thread.sleep(3000);
mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
logger.info("兑换后积分:" + mapuser.get("credits"));
String creditsNew = String.valueOf((Long)mapuser.get("credits")+Integer.valueOf(data.get("credits")));
//校验比较,兑换前后积分
Assert.assertEquals(credits.trim(), creditsNew, "qb兑换后积分扣除异常");
logger.info("校验兑换前后积分正确");
//订单状态校验
Thread.sleep(5000);
Map<String, Object> orderMap = jdbc.findSimpleResult("SELECT * from orders_consumer.orders_0614 where id ="+orderId);
String status = (String)orderMap.get("status");
Assert.assertTrue(status.equals("success"),"校验订单状态失败");
logger.info("校验兑换订单状态正确");
}
@DataProvider
public Iterator<Object[]> providerMethod(Method method) throws IOException {
Iterator<Object[]> result = null;
result = new ExcelDataProvider("duiba/多档位兑换");
return result;
}
@DataProvider
public Iterator<Object[]> providerMethodQb(Method method) throws IOException {
Iterator<Object[]> result = null;
result = new ExcelDataProvider("duiba/qb兑换");
return result;
}
}
package http.cases.ExchangeTest;
import base.DuibaTestBase;
import http.service.Activity.ManagerService;
import http.service.Authorization;
import http.service.app.*;
import http.service.hd.DeveloperAccountService;
import http.service.hd.DsOrderService;
import utils.MatcherString;
import utils.ExcelDataProvider;
import base.DuibaLog;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import java.io.IOException;
import java.lang.reflect.Method;
import java.sql.SQLException;
import java.util.Iterator;
import java.util.Map;
/**
* Created by mabo on 2018/9/13
*/
public class Qb_兑换流程测试_ExchangeTest extends DuibaTestBase {
@Autowired
private MobileService mobileService;
@Autowired
private Authorization authorization;
@Autowired
private CouponExchangeService couponExchangeService;
@Autowired
private CrecordService crecordService;
@Autowired
ManagerService managerService;
@Autowired
VirtualExchangeService virtualExchangeService;
@Autowired
QbExchangeService qbExchangeService;
@Autowired
DeveloperAccountService developerAccountService;
@Autowired
DsOrderService dsOrderService;
@Autowired
SupplierExchangeTemplateService supplierExchangeTemplateService;
private DuibaLog logger = DuibaLog.getLogger();
@BeforeClass
public void beforeClass(){
//模版设置成处理后成功
supplierExchangeTemplateService.use("476");
}
@BeforeMethod
public void beforeMethod() throws SQLException {
jdbc.update("DELETE FROM credits_dev.consumer_limit_record_only WHERE item_id = '2'");
jdbc.update("DELETE FROM credits_dev.consumer_limit_record WHERE item_id = '2'");
}
@DataProvider
public Iterator<Object[]> providerMethodQb(Method method) throws IOException {
Iterator<Object[]> result = null;
result = new ExcelDataProvider("duiba/qb兑换");
return result;
}
@Test
public void qbExchange() throws Exception {
int uid = 3767;
Map<String, Object> mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
String credits = String.valueOf(mapuser.get("credits"));
logger.info("兑换前积分:" + credits);
Response response = qbExchangeService.doTakePrize(authorization.dafuwengLogin(uid),"1234345554","3");
String orderId = (String)response.jsonPath().get("orderId");
logger.info("订单号:"+orderId);
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid),orderId);
String message = response.jsonPath().getString("message");
int i=10;
while(!message.equals("兑换提交成功!待处理")&&i>0){
Thread.sleep(1000);
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid),orderId);
message = response.jsonPath().getString("message");
i--;
}
//查询数据库,获取当前积分
Thread.sleep(3000);
mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
logger.info("兑换后积分:" + mapuser.get("credits"));
String creditsNew = String.valueOf((Long)mapuser.get("credits")+30);
//校验比较,兑换前后积分
Assert.assertEquals(credits.trim(), creditsNew, "qb兑换后积分扣除异常");
logger.info("校验兑换前后积分正确");
//订单状态校验
Thread.sleep(5000);
Map<String, Object> orderMap = jdbc.findSimpleResult("SELECT * from orders_consumer.orders_0207 where id ="+orderId);
String status = (String)orderMap.get("status");
logger.info("订单状态:"+status);
Assert.assertTrue(status.equals("success"),"校验订单状态失败");
logger.info("校验兑换订单状态正确");
}
@Test
public void qbExchange_积分不足() throws Exception {
int uid = 3086;
Response response = qbExchangeService.doTakePrize(authorization.dafuwengLogin(uid),"1234345554","5");
String orderId = (String)response.jsonPath().get("orderId");
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid),orderId);
String message = response.jsonPath().getString("message");
int i=10;
while(!message.equals("兑换失败,用户积分余额不足")&&i>0){
Thread.sleep(1000);
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid),orderId);
message = response.jsonPath().getString("message");
i--;
}
Map<String, Object> orderMap = jdbc.findSimpleResult("SELECT * from orders_consumer.orders_0693 where id ="+orderId);
String orderStatus = String.valueOf(orderMap.get("status"));
Assert.assertEquals(message,"兑换失败,用户积分余额不足","校验message失败");
Assert.assertEquals(orderStatus,"fail","校验订单状态失败");
logger.info("积分不足兑换校验成功");
}
@Test
public void 开发者余额不足测试() throws Exception{
int uid = 3490;
//开发者余额, 开发者账户:xuyan_8707@163.com
Response accountResponse = developerAccountService.accountInfoCommon("xuyan_8707@163.com");
String remainMoney = accountResponse.jsonPath().getString("data.remainMoney");
logger.info("兑换前的开发者账户余额:" + remainMoney);
Response detailResponse = mobileService.detail(authorization.dafuwengLogin(uid),"2");
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
String message=null;
String succcess = null;
try{
Response response = qbExchangeService.doTakePrize(authorization.dafuwengLogin(uid),"1234345554","1");
}catch (Exception e){
message = e.toString();
}
logger.info(message);
Assert.assertTrue(message.contains("没有兑换成功"));
Assert.assertTrue(message.contains("\"success\":false"));
}
@Test
public void 每日兑换限制() throws Exception {
int uid = 3767;
//第一次兑换
Response response = qbExchangeService.doTakePrize(authorization.dafuwengLogin(uid),"1234345554","1");
String orderId = (String)response.jsonPath().get("orderId");
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid),orderId);
String message = response.jsonPath().getString("message");
int i=10;
while(!message.equals("兑换提交成功!待处理")&&i>0){
Thread.sleep(1000);
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid),orderId);
message = response.jsonPath().getString("message");
i--;
}
//第二次兑换
try{
response = qbExchangeService.doTakePrize(authorization.dafuwengLogin(uid),"1234345554","1");
}catch (Exception e){
message = e.toString();
}
logger.info(message);
Assert.assertTrue(message.contains("已兑完"));
Assert.assertTrue(message.contains("\"success\":false"));
}
@Test
public void 永久兑换限制() throws Exception {
int uid = 3767;
//第一次兑换
Response response = qbExchangeService.doTakePrize(authorization.dafuwengLogin(uid),"1234345554","2");
String orderId = (String)response.jsonPath().get("orderId");
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid),orderId);
String message = response.jsonPath().getString("message");
int i=10;
while(!message.equals("兑换提交成功!待处理")&&i>0){
Thread.sleep(1000);
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid),orderId);
message = response.jsonPath().getString("message");
i--;
}
//第二次兑换
try{
response = qbExchangeService.doTakePrize(authorization.dafuwengLogin(uid),"1234345554","2");
}catch (Exception e){
message = e.toString();
}
logger.info(message);
Assert.assertTrue(message.contains("已兑完"));
Assert.assertTrue(message.contains("\"success\":false"));
}
//@Test
public void 审核通过测试() throws Exception {
//查询兑换前的开发者账户余额
// Response accountResponse = developerAccountService.accountInfo();
// String remainMoney = accountResponse.jsonPath().getString("data.remainMoney");
// logger.info("兑换前的开发者账户余额:" + remainMoney);
// String remainMoneyNew =String.valueOf(Integer.valueOf(remainMoney) - 9600) ;
int uid = 2709;
Response response = qbExchangeService.doTakePrize(authorization.dafuwengLogin(uid),"1234345554","100");
String orderId = (String)response.jsonPath().get("orderId");
response.prettyPrint();
//订单审核,判断是否在待审核节点
Map<String,Object> mapOrder = jdbc.findSimpleResult("SELECT * from orders_consumer.orders_0616 where id ="+orderId);
String flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
logger.info("数据库订单节点:" + flowWork);
String orderIdmain = String.valueOf(mapOrder.get("order_num"));
logger.info("兑吧订单号为:" + orderIdmain);
int i =10;
while (i > 0 && !flowWork.equals("Audit-started")) {
Thread.sleep(300);
mapOrder = jdbc.findSimpleResult("SELECT * from orders_consumer.orders_0616 where id ="+orderId);
flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
logger.info("数据库订单节点:" + flowWork);
i--;
}
Response auditResponse = dsOrderService.submitAudit(orderId,"pass");
auditResponse.prettyPrint();
//判断订单是否审核成功,如果订单没有成功则继续审核
int j =10;
while (j > 0 && !flowWork.equals("Success-complete")) {
Thread.sleep(1000);
auditResponse = dsOrderService.submitAudit(orderId,"pass");
mapOrder = jdbc.findSimpleResult("SELECT * from orders_consumer.orders_0616 where id ="+orderId);
flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
logger.info("数据库订单节点:" + flowWork);
j--;
}
String status = String.valueOf(mapOrder.get("status"));
//兑换后的开发者账户余额
// accountResponse = developerAccountService.accountInfo();
// remainMoney = accountResponse.jsonPath().getString("data.remainMoney");
// logger.info("兑换后的开发者账户余额:" + remainMoney);
// Assert.assertEquals(remainMoney,remainMoneyNew,"校验开发者账户余额失败");
//校验开发者账户余额变动
Response accountResponse = developerAccountService.cashDetail(orderIdmain);
String remainMoney = String.valueOf(Integer.valueOf(accountResponse.jsonPath().getString("data.list[0].balance"))+Integer.valueOf(accountResponse.jsonPath().getString("data.list[0].moneyChange")));
logger.info("兑换前的开发者账户余额:" + remainMoney);
remainMoney =String.valueOf(Integer.valueOf(remainMoney) - 9600) ;
String remainMoneyNew = accountResponse.jsonPath().getString("data.list[0].balance");
logger.info("兑换后的开发者账户余额:" + remainMoneyNew);
Assert.assertEquals(remainMoneyNew,remainMoney,"校验开发者账户余额失败");
Assert.assertEquals(status,"success","校验订单状态失败");
logger.info("校验支付宝扣费订单成功");
}
//@Test
public void 审核不通过测试() throws Exception{
//查询兑换前的开发者账户余额
// Response accountResponse = developerAccountService.accountInfo();
// String remainMoney = accountResponse.jsonPath().getString("data.remainMoney");
// logger.info("兑换前的开发者账户余额:" + remainMoney);
//qb兑换
int uid = 2709;
Response response = qbExchangeService.doTakePrize(authorization.dafuwengLogin(uid),"1234345554","100");
String orderId = (String)response.jsonPath().get("orderId");
//订单审核,判断是否在待审核节点
Map<String,Object> mapOrder = jdbc.findSimpleResult("SELECT * from orders_consumer.orders_0616 where id ="+orderId);
String flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
logger.info("数据库订单节点:" + flowWork);
String orderIdmain = String.valueOf(mapOrder.get("order_num"));
logger.info("兑吧订单号为:" + orderIdmain);
int i =10;
while (i > 0 && !flowWork.equals("Audit-started")) {
Thread.sleep(300);
mapOrder = jdbc.findSimpleResult("SELECT * from orders_consumer.orders_0616 where id ="+orderId);
flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
logger.info("数据库订单节点:" + flowWork);
i--;
}
//订单审核
Response auditResponse = dsOrderService.submitAudit(orderId,"reject");
auditResponse.prettyPrint();
//判断订单是否审核失败
int j =10;
while (j > 0 && !flowWork.equals("Fail-complete")) {
Thread.sleep(1000);
auditResponse = dsOrderService.submitAudit(orderId,"reject");
mapOrder = jdbc.findSimpleResult("SELECT * from orders_consumer.orders_0616 where id ="+orderId);
flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
logger.info("当前订单节点:" + flowWork);
j--;
}
String status = String.valueOf(mapOrder.get("status"));
//兑换后的开发者账户余额
// accountResponse = developerAccountService.accountInfo();
// String remainMoneyNew = accountResponse.jsonPath().getString("data.remainMoney");
// logger.info("兑换后的开发者账户余额:" + remainMoneyNew);
// Assert.assertEquals(remainMoneyNew,remainMoney,"校验开发者账户余额失败");
Assert.assertEquals(status,"fail","校验订单状态失败");
//校验开发者账户余额变动
Response accountResponse = developerAccountService.cashDetail(orderIdmain);
String remainMoney = String.valueOf(Integer.valueOf(accountResponse.jsonPath().getString("data.list[1].balance"))+Integer.valueOf(accountResponse.jsonPath().getString("data.list[1].moneyChange")));
logger.info("兑换前的开发者账户余额:" + remainMoney);
String remainMoneyNew = accountResponse.jsonPath().getString("data.list[0].balance");
logger.info("兑换后的开发者账户余额:" + remainMoneyNew);
Assert.assertEquals(remainMoneyNew,remainMoney,"校验开发者账户余额失败");
logger.info("校验支付宝审核订单失败返还金额成功");
}
}
package http.cases.ExchangeTest;
import base.DuibaTestBase;
import utils.RedisUtil;
import http.service.Activity.ManagerService;
import http.service.Authorization;
import http.service.app.*;
import http.service.hd.DeveloperAccountService;
import http.service.hd.DsOrderService;
import utils.MatcherString;
import base.DuibaLog;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import java.lang.reflect.Method;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import static io.restassured.RestAssured.given;
/**
* Created by lvwenyan on 2018/07/06.
*/
public class 优惠券_兑换流程测试_ExchangeTest extends DuibaTestBase {
@Autowired
private MobileService mobileService;
@Autowired
private Authorization authorization;
@Autowired
private CouponExchangeService couponExchangeService;
@Autowired
private DsOrderService dsOrderService;
@Autowired
ManagerService managerService;
@Autowired
DeveloperAccountService developerAccountService;
@Autowired
CrecordService crecordService;
private DuibaLog logger = DuibaLog.getLogger();
// private MysqlUtils jdbc;
private String url = "http://activity.m.duibatest.com.cn";
//指定用户
private static int uid = 3768;
// @BeforeClass
// public void before(){
//
// jdbc = MysqlUtils.mysqlDuiba("");
//
// }
//
// @AfterClass
// public void after(){
//
// jdbc.releaseConn();
// }
@DataProvider
public Object[][] providerMethod(Method method) {
Object[][] result = null;
if (method.getName().equals("优惠券日期兑换限制测试")) {
result = new Object[][]{
new Object[]{1, "171479", "29538", "69xjl0a", "优惠券日期兑换限制未开始"}, //case1
new Object[]{2, "171480", "29539", "z9sydmcs", "优惠券日期兑换限制进行中"}, //case2
new Object[]{3, "171481", "29540", "cmixdqn", "优惠券日期兑换限制已结束"}, //case2
};
}
if (method.getName().equals("优惠券库存不足测试")) {
result = new Object[][]{
new Object[]{"169775", "29180", "69xjl0a", "优惠券商品库存不足测试"}, //case1
new Object[]{"172163", "29677", "z9sydmcs", "优惠券定向库存不足测试"}, //case2
new Object[]{"174773","30286","qyarwreq","优惠券预分配库存不足测试"},
};
}
if (method.getName().equals("优惠券审核通过测试")) {
result = new Object[][]{
new Object[]{1,"169698", "29156", "兑吧优惠券审核通过测试"}, //case1
new Object[]{2,"172178", "", "自有优惠券审核通过测试"}, //case2
};
}
if (method.getName().equals("优惠券马上使用按钮测试")){
result = new Object[][]{
new Object[]{1,"172292", "29708", "优惠券商家落地页下载按钮测试"}, //case1
new Object[]{2,"172293", "29709", "优惠券兑换记录页下载按钮测试"}, //case2
new Object[]{3,"172294","29710","优惠券链接券按钮测试"}, //case3
};
}
if (method.getName().equals("自有优惠券会员等级测试")){
result = new Object[][]{
new Object[]{1,"172713","pmqy9","优惠券会员等级范围测试"}, //case1
new Object[]{2,"172715","3bam907y", "优惠券会员特定等级测试"}, //case2
};
}
if (method.getName().equals("优惠券地区兑换限制测试")){
result = new Object[][]{
new Object[]{1,"175459","30434","pmqy9","优惠券地区黑名单不可兑测试"}, //case1
new Object[]{2,"175603","30435","3bam907y", "优惠券地区黑名单可兑测试"}, //case2
new Object[]{3,"175604","30436","6dc8ntp", "优惠券地区白名单可兑测试"}, //case3
new Object[]{4,"175605","30437","tvtgya6","优惠券地区白名单不可兑测试"}, //case4
};
}
return result;
}
@Test
public void 优惠券扣库存测试() throws Exception {
//查询优惠券兑换前的库存
Map<String,Object> mapStock = jdbc.findSimpleResult("SELECT * FROM stock.tb_stock WHERE stock_id ='705804724784620492'");
String stock = String.valueOf(mapStock.get("stock")) ;
logger.info("兑换前的优惠券库存:" + stock);
stock = String.valueOf(Integer.parseInt(stock) - 1) ;
//优惠券兑换
this.优惠券兑换("169713","29164",uid);
//查询优惠券兑换后的库存
mapStock = jdbc.findSimpleResult("SELECT * FROM stock.tb_stock WHERE stock_id ='705804724784620492'");
String stockNew = String.valueOf(mapStock.get("stock")) ;
logger.info("兑换后的优惠券库存:" + stockNew);
Assert.assertEquals(stockNew,stock,"校验优惠券库存失败");
logger.info("优惠券兑换扣库存校验成功");
}
@Test
public void 优惠券预分配库存测试() throws Exception{
Map<String,Object> mapStock = jdbc.findSimpleResult("SELECT * FROM goods.pre_stock WHERE point_id = '584'");
String stock = String.valueOf(mapStock.get("stock")) ;
logger.info("兑换前的优惠券预分配库存:" + stock);
stock = String.valueOf(Integer.valueOf(stock)-1);
//查询优惠券兑换前的积分,增加等待时间,同步更新积分
Thread.sleep(1000);
Map<String,Object> mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
String credits = String.valueOf(mapuser.get("credits"));
logger.info("兑换前的积分:"+credits);
credits = String.valueOf(Integer.valueOf(credits)-10);
//优惠券兑换
this.优惠券兑换("174797","30290",uid);
//查询优惠券兑换后的预分配库存和积分
mapStock = jdbc.findSimpleResult("SELECT * FROM goods.pre_stock WHERE point_id = '584'");
String stockNew = String.valueOf(mapStock.get("stock")) ;
logger.info("兑换后的优惠券预分配库存:" + stockNew);
Thread.sleep(1000);
mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
String creditsNew = String.valueOf(mapuser.get("credits"));
logger.info("兑换后积分:"+creditsNew);
Assert.assertEquals(stockNew,stock,"校验优惠券预分配库存失败");
Assert.assertEquals(creditsNew,credits,"校验优惠券预分配最小兑换价格失败");
logger.info("校验惠券预分配库存和最小兑换积分成功");
}
@Test
public void 优惠券共享库存测试() throws Exception{
Map<String,Object> mapStock = jdbc.findSimpleResult("SELECT * FROM goods.pre_stock WHERE point_id = '586'");
String stock = String.valueOf(mapStock.get("stock")) ;
logger.info("兑换前的优惠券共享库存:" + stock);
stock = String.valueOf(Integer.valueOf(stock)-1);
//优惠券兑换
this.优惠券兑换("174923","30318",uid);
//查询优惠券兑换后的共享库存
mapStock = jdbc.findSimpleResult("SELECT * FROM goods.pre_stock WHERE point_id = '586'");
String stockNew = String.valueOf(mapStock.get("stock")) ;
logger.info("兑换后的优惠券共享库存:" + stockNew);
Assert.assertEquals(stockNew,stock,"校验优惠券共享库存库存失败");
logger.info("校验优惠券共享库存扣除成功");
}
@Test
public void 优惠券预分配每日限额测试() throws Exception{
//获取当前的时间
Date dNow = new Date();
SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd");
String ftDate = ft.format(dNow);
try {
//优惠券第一次兑换
this.优惠券兑换("174928","30319",uid);
//每日限额用完,无法再次兑换
Thread.sleep(3000);
Map<String,String> map = new HashMap<>();
map.put("appItemId","174928");
map.put("itemId","30319");
map.put("token","uvbhjc");
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.dafuwengLogin(uid)).params(map).post(url + "/couponExchange/exchange");
response.prettyPrint();
//获取按钮状态
Response detailResponse = mobileService.detail(authorization.dafuwengLogin(uid),"30319");
detailResponse.prettyPrint();
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
Assert.assertEquals(response.jsonPath().getString("message"),"今日已兑完,明天再来哦(14)","校验message失败");
Assert.assertEquals(exchangeText,"今日已兑完","校验马上兑换按钮状态失败");
logger.info("校验优惠券预分配每日限额兑换成功");
}catch (Exception e){
throw new Exception("异常信息打印:" + e);
}finally {
//清除兑换数据和 redis
jdbc.update("DELETE FROM goods.pre_stock_consume_detail WHERE point_id = 588");
RedisUtil.clearObjectKey("121-588");
RedisUtil.clearKey("everydayStock" + ftDate + "588");
}
}
/**
* @param appItemId 商品入库Id
* @param itemId 商品id
* @param token 活动token
* @param caseName 用例名称打印
* @throws Exception
*/
@Test(dataProvider = "providerMethod")
public void 优惠券库存不足测试( String appItemId, String itemId, String token, String caseName) throws Exception{
logger.info(caseName);
Map<String,String> map = new HashMap<>();
map.put("appItemId",appItemId);
map.put("itemId",itemId);
map.put("token",token);
//优惠券兑换
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.dafuwengLogin(uid)).params(map).post(url + "/couponExchange/exchange");
response.prettyPrint();
//获取按钮状态
Response detailResponse = mobileService.detail(authorization.dafuwengLogin(uid),"29180");
detailResponse.prettyPrint();
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
Assert.assertEquals(response.jsonPath().getString("message"),"今日已兑完,明天再来哦(14)","校验message失败");
Assert.assertEquals(exchangeText,"已兑完","校验马上兑换按钮状态失败");
logger.info("校验优惠券商品库存不足和预分配库存不足场景成功");
}
@Test
public void 优惠券积分不足测试() throws Exception{
//获取按钮状态
Response detailResponse = mobileService.detail(authorization.dafuwengLogin(3086,true),"29164");
detailResponse.prettyPrint();
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
//优惠券兑换
Response response = this.优惠券兑换("169713","29164",3086);
Assert.assertEquals(exchangeText,"积分不足","校验马上兑换按钮状态失败");
Assert.assertEquals(response.jsonPath().getString("message"),"兑换失败,用户积分余额不足","校验message失败");
logger.info("校验优惠券商品积分不足场景成功");
}
/**
* @param caseNum 用例id
* @param appItemId 商品入库Id
* @param itemId 商品id
* @param caseName 用例名称打印
* @throws Exception
*/
//@Test(dataProvider = "providerMethod")
public void 优惠券审核通过测试(int caseNum, String appItemId, String itemId, String caseName) throws Exception{
logger.info(caseName);
//查询兑换前的开发者余额
// Response accountResponse = developerAccountService.accountInfo();
// String remainMoney = accountResponse.jsonPath().getString("data.remainMoney");
// logger.info("兑换前的开发者余额:" + remainMoney);
// String remainMoneyNew =String.valueOf(Integer.valueOf(remainMoney) - 1000) ;
//优惠券兑换
String orderId = this.优惠券兑换订单(appItemId,itemId,uid);
logger.info("订单号:" + orderId);
//订单审核,判断是否在待审核节点
Map<String,Object> mapOrder = jdbc.findSimpleResult("SELECT * FROM "+Database.orders_consumer+"."+Database.orders4+" WHERE id = " + orderId);
String flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
logger.info("数据库订单节点:" + flowWork);
String orderIdmain = String.valueOf(mapOrder.get("order_num"));
logger.info("兑吧订单号为:" + orderIdmain);
int i =10;
while (i > 0 && !flowWork.equals("Audit-started")) {
Thread.sleep(300);
mapOrder = jdbc.findSimpleResult("SELECT * FROM "+Database.orders_consumer+"."+Database.orders4+" WHERE id = " + orderId);
flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
logger.info("数据库订单节点:" + flowWork);
i--;
}
Response auditResponse = dsOrderService.submitAudit(orderId,"pass");
auditResponse.prettyPrint();
//判断订单是否审核成功,如果订单没有成功则继续审核
int j =10;
while (j > 0 && !flowWork.equals("Success-complete")) {
Thread.sleep(1000);
auditResponse = dsOrderService.submitAudit(orderId,"pass");
mapOrder = jdbc.findSimpleResult("SELECT * FROM "+Database.orders_consumer+"."+Database.orders4+" WHERE id = " + orderId);
flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
logger.info("数据库订单节点:" + flowWork);
j--;
}
String status = String.valueOf(mapOrder.get("status"));
switch (caseNum){
case 1:
//查询兑换后的开发者余额
// accountResponse = developerAccountService.accountInfo();
// remainMoney = accountResponse.jsonPath().getString("data.remainMoney");
// logger.info("兑换后的开发者余额:" + remainMoney);
Assert.assertEquals(status,"success","订单状态校验失败");
//校验开发者账户余额变动
Response accountResponse = developerAccountService.cashDetail(orderIdmain);
String remainMoney = String.valueOf(Integer.valueOf(accountResponse.jsonPath().getString("data.list[0].balance"))+Integer.valueOf(accountResponse.jsonPath().getString("data.list[0].moneyChange")));
logger.info("兑换前的开发者账户余额:" + remainMoney);
remainMoney =String.valueOf(Integer.valueOf(remainMoney) - 1000) ;
String remainMoneyNew = accountResponse.jsonPath().getString("data.list[0].balance");
logger.info("兑换后的开发者账户余额:" + remainMoneyNew);
Assert.assertEquals(remainMoneyNew,remainMoney,"校验开发者账户余额失败");
logger.info("校验兑吧优惠券审核通过扣费成功");
break;
case 2:
Assert.assertEquals(status,"success","订单状态校验失败");
logger.info("校验自有优惠券审核通过成功");
}
}
@Test
public void 优惠券用户永久兑换限制测试() throws Exception{
Map<String,String> map = new HashMap<>();
map.put("appItemId","170294");
map.put("itemId","29293");
map.put("token","69xjl0a");
try{
//优惠券兑换,用户兑换限制次数1次
Response response = this.优惠券兑换("170294","29293",uid);
Assert.assertEquals(response.jsonPath().getString("status"),"success","校验兑换失败");
logger.info("用户成功兑换一次");
//再次兑换
Thread.sleep(3000);
response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.dafuwengLogin(uid)).params(map).post(url + "/couponExchange/exchange");
response.prettyPrint();
//获取按钮状态
Response detailResponse = mobileService.detail(authorization.dafuwengLogin(uid),"29293");
detailResponse.prettyPrint();
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
Assert.assertEquals(response.jsonPath().getString("message"),"已兑换","校验用户兑换限制失败");
Assert.assertEquals(exchangeText,"已兑换","校验马上兑换按钮状态失败");
logger.info("校验优惠券用户永久兑换限制成功");
}catch (Exception e){
throw new Exception("异常信息打印:" + e);
}finally {
jdbc.update("DELETE FROM credits_dev.consumer_limit_record_only WHERE item_id = '29293'");
jdbc.update("DELETE FROM credits_dev.consumer_limit_record WHERE item_id = '29293'");
}
}
@Test
public void 优惠券用户每日兑换限制测试() throws Exception{
Map<String,String> map = new HashMap<>();
map.put("appItemId","171478");
map.put("itemId","29531");
map.put("token","69xjl0a");
try{
//优惠券兑换,用户兑换限制次数1次
Response response = this.优惠券兑换("171478","29531", uid);
Assert.assertEquals(response.jsonPath().getString("status"),"success","校验兑换失败");
logger.info("用户成功兑换一次");
//再次兑换
Thread.sleep(3000);
response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.dafuwengLogin(uid)).params(map).post(url + "/couponExchange/exchange");
response.prettyPrint();
//获取按钮状态
Response detailResponse = mobileService.detail(authorization.dafuwengLogin(uid),"29531");
detailResponse.prettyPrint();
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
Assert.assertEquals(response.jsonPath().getString("message"),"今日已兑换","校验用户兑换限制失败");
Assert.assertEquals(exchangeText,"今日已兑换","校验马上兑换按钮状态失败");
logger.info("校验优惠券用户每天兑换限制成功");
}catch (Exception e){
throw new Exception("异常信息打印:" + e);
}finally {
jdbc.update("DELETE FROM credits_dev.consumer_limit_record WHERE item_id = '29531'");
}
}
@Test
public void 优惠券每日兑换上限测试() throws Exception{
Map<String,String> map = new HashMap<>();
map.put("appItemId","170295");
map.put("itemId","29294");
map.put("token","69xjl0a");
try{
//优惠券兑换,用户兑换限制次数1次
Response response= this.优惠券兑换("170295","29294", uid);
Assert.assertEquals(response.jsonPath().getString("status"),"success","校验兑换失败");
logger.info("用户成功兑换一次");
//再次兑换
Thread.sleep(3000);
response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.dafuwengLogin(uid)).params(map).post(url + "/couponExchange/exchange");
response.prettyPrint();
//获取按钮状态
Response detailResponse = mobileService.detail(authorization.dafuwengLogin(uid),"29294");
detailResponse.prettyPrint();
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
Assert.assertEquals(response.jsonPath().getString("message"),"今日已兑完,明天再来哦(14)","校验每日兑换上限失败");
Assert.assertEquals(exchangeText,"今日已兑完","校验马上兑换按钮状态失败");
logger.info("校验优惠券每日兑换上限成功");
}catch (Exception e){
throw new Exception("异常信息打印:" + e);
}finally {
jdbc.update("DELETE FROM goods.tb_everyday_limit WHERE item_id = '29294'");
}
}
/**
* @param caseNum 用例编号
* @param appItemId 商品入库Id
* @param itemId 商品id
* @param token 活动token
* @param caseName 用例名称打印
* @throws Exception
*/
@Test(dataProvider = "providerMethod")
public void 优惠券日期兑换限制测试(int caseNum, String appItemId, String itemId, String token, String caseName) throws Exception{
logger.info(caseName);
Map<String,String> map = new HashMap<>();
map.put("appItemId",appItemId);
map.put("itemId",itemId);
map.put("token",token);
//兑换
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.dafuwengLogin(uid)).params(map).post(url + "/couponExchange/exchange");
response.prettyPrint();
//获取按钮状态
Response detailResponse = mobileService.detail(authorization.dafuwengLogin(uid),itemId);
detailResponse.prettyPrint();
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
switch (caseNum){
case 1:
Assert.assertEquals(response.jsonPath().getString("message"),"请在限定时间内兑换哦(13)","校验日期兑换限制失败");
Assert.assertEquals(exchangeText,"即将开始","校验马上兑换按钮状态失败");
logger.info("校验优惠券日期兑换限制未开始成功");
break;
case 2:
Assert.assertEquals(response.jsonPath().getString("success"),"true","校验日期兑换限制失败");
Assert.assertEquals(exchangeText,"马上兑换","校验马上兑换按钮状态失败");
logger.info("校验优惠券日期兑换限制进行中成功");
break;
case 3:
Assert.assertEquals(response.jsonPath().getString("message"),"已结束","校验日期兑换限制失败");
Assert.assertEquals(exchangeText,"已结束","校验马上兑换按钮状态失败");
logger.info("校验优惠券日期兑换限制已结束成功");
break;
}
}
@Test
public void 优惠券限时兑换测试() throws Exception{
Map<String,String> map = new HashMap<>();
map.put("appItemId","172079");
map.put("itemId","29667");
map.put("token","69xjl0a");
//兑换
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.dafuwengLogin(uid)).params(map).post(url + "/couponExchange/exchange");
response.prettyPrint();
//获取按钮状态
Response detailResponse = mobileService.detail(authorization.dafuwengLogin(uid),"29667");
detailResponse.prettyPrint();
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
Calendar cal = Calendar.getInstance();
int hour = cal.get(Calendar.HOUR_OF_DAY);
logger.info("当前时间是:" + hour + "时");
if(hour >= 0 && hour < 15 ){
//限时兑换未开始
Assert.assertEquals(response.jsonPath().getString("message"),"请在限定时间内兑换哦(13)","校验限时兑换失败");
Assert.assertEquals(exchangeText,"即将开始","校验马上兑换按钮状态失败");
logger.info("校验优惠券限时兑换未开始场景成功");
}else if(hour >= 15 && hour < 19){
Assert.assertEquals(response.jsonPath().getString("success"),"true","校验限时兑换失败");
Assert.assertEquals(exchangeText,"马上兑换","校验马上兑换按钮状态失败");
logger.info("校验优惠券限时兑换进行中场景成功");
}else{
Assert.assertEquals(response.jsonPath().getString("message"),"今日已兑完,明天再来哦(14)","校验日期兑换限制失败");
Assert.assertEquals(exchangeText,"今日已结束","校验马上兑换按钮状态失败");
logger.info("校验优惠券限时兑换结束场景成功");
}
}
/**
* @param caseNum 用例编号
* @param appItemId 商品入库Id
* @param itemId 商品id
* @param caseName 用例名称打印
* @throws Exception
*/
@Test(dataProvider = "providerMethod")
public void 优惠券马上使用按钮测试(int caseNum, String appItemId, String itemId, String caseName)throws Exception{
logger.info(caseName);
//优惠券兑换
String orderId = this.优惠券兑换订单(appItemId,itemId,uid);
//优惠券兑换结果页
Response resultResponse = crecordService.recordDetail(orderId,uid);
resultResponse.prettyPrint();
String btnText = MatcherString.getString(resultResponse.asString(),"\"btnText\":\"(.*?)\",",1);
String actualPay = MatcherString.getString(resultResponse.asString(),"\"actualPay\":\"(.*?)\",",1);
String androidDownload = MatcherString.getString(resultResponse.asString(),"\"androidDownload\":\"(.*?)\",",1);
String androidDownloadUrl = MatcherString.getString(resultResponse.asString(),"\"androidDownloadUrl\":\"(.*?)\",",1);
//优惠券兑换记录页
Thread.sleep(3000);
Response recordResponse = crecordService.recordDetailNew(orderId,uid);
recordResponse.prettyPrint();
String useButtonText = MatcherString.getString(recordResponse.asString(),"\"useButtonText\":\"(.*?)\",",1);
String androidDownloadUrl2 = MatcherString.getString(recordResponse.asString(),"\"androidDownloadUrl\":\"(.*?)\",",1);
switch (caseNum){
case 1:
Assert.assertEquals(btnText,"马上使用","校验结果页按钮文案失败");
Assert.assertEquals(actualPay,"10积分","校验结果页积分文案失败");
Assert.assertEquals(androidDownload,"https://m2.mobike.com/active/fission_packet_joint/index.html","校验结果页按钮链接失败");
Assert.assertEquals(useButtonText,"马上使用","校验兑换记录页按钮文案失败");
Assert.assertEquals(androidDownloadUrl2,"//activity.m.duibatest.com.cn/log/redirect?url=https%3A%2F%2Fm2.mobike.com%2Factive%2Ffission_packet_joint%2Findex.html&amp;dpm=2239.25.2.0&amp;dcm=101.29708.172292.0","校验兑换记录页按钮跳转链接失败");
logger.info("校验优惠券商家落地页下载链接页面成功");
break;
case 2:
Assert.assertEquals(btnText,"马上领取","校验结果页按钮文案失败");
Assert.assertEquals(actualPay,"20积分","校验结果页积分文案失败");
Assert.assertEquals(androidDownload,"https://u.163.com/aoshzxiaoshouxiaoshou4","校验结果页按钮链接失败");
Assert.assertEquals(useButtonText,"马上领取","校验兑换记录页按钮文案失败");
Assert.assertEquals(androidDownloadUrl2,"//activity.m.duibatest.com.cn/log/redirect?url=https%3A%2F%2Fu.163.com%2Faoshzxiaoshouxiaoshou4&amp;dpm=2239.25.2.0&amp;dcm=101.29709.172293.0","校验兑换记录页按钮跳转链接失败");
logger.info("校验优惠券兑换记录页下载链接页面成功");
break;
case 3:
Assert.assertEquals(btnText,"马上下载","校验结果页按钮文案失败");
Assert.assertEquals(actualPay,"30积分","校验结果页积分文案失败");
Assert.assertEquals(androidDownloadUrl,"//activity.m.duibatest.com.cn/log/redirect?url=https%3A%2F%2Fm.wkzuche.com%2Fh5%2F%23%2Factivity%2Fshare%3Fchannel%3Ddb%402018&amp;dpm=2239.25.1.0&amp;dcm=101.29710.172294.0","校验结果页按钮链接失败");
Assert.assertEquals(useButtonText,"马上下载","校验兑换记录页按钮文案失败");
Assert.assertEquals(androidDownloadUrl2,"//activity.m.duibatest.com.cn/log/redirect?url=https%3A%2F%2Fm.wkzuche.com%2Fh5%2F%23%2Factivity%2Fshare%3Fchannel%3Ddb%402018&amp;dpm=2239.25.2.0&amp;dcm=101.29710.172294.0","校验兑换记录页按钮跳转链接失败");
logger.info("校验优惠券链接券页面成功");
break;
}
}
/**
* @param caseNum 用例编号
* @param appItemId 商品入库Id
* @param token token
* @param caseName 用例名称打印
* @throws Exception
*/
@Test(dataProvider = "providerMethod")
public void 自有优惠券会员等级测试(int caseNum, String appItemId, String token,String caseName) throws Exception{
logger.info(caseName);
Map<String,String> map = new HashMap<>();
map.put("appItemId",appItemId);
map.put("token",token);
//会员等级不符,详情页按钮“如何获得兑换资格”
Response detailResponse = mobileService.appItemDetail(appItemId,uid);
detailResponse.prettyPrint();
//会员等级不符,兑换
Response failResponse = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.dafuwengLogin(uid)).params(map).post(url + "/couponExchange/exchange");
failResponse.prettyPrint();
//会员等级符合条件,兑换,vip=5
Response response = couponExchangeService.couponExchange(authorization.generateSignAutoLogin("2wGQc3MZaQsqYFWcX4gguya5PnnS",3402),appItemId,"");
response.prettyPrint();
switch (caseNum){
case 1:
Assert.assertEquals(detailResponse.asString().contains("如何获得兑换资格"),true);
Assert.assertEquals(failResponse.jsonPath().getString("success"),"false","校验兑换结果失败");
Assert.assertEquals(failResponse.jsonPath().getString("message"),"会员等级不符,请挑选其他吧(15)","校验兑换结果消息失败");
Assert.assertEquals(response.jsonPath().getString("success"),"true","校验兑换结果失败");
logger.info("校验优惠券会员等级范围成功");
break;
case 2:
Assert.assertEquals(detailResponse.asString().contains("如何获得兑换资格"),true);
Assert.assertEquals(failResponse.jsonPath().getString("success"),"false","校验兑换结果失败");
Assert.assertEquals(failResponse.jsonPath().getString("message"),"会员等级不符,请挑选其他吧(15)","校验兑换结果消息失败");
Assert.assertEquals(response.jsonPath().getString("success"),"true","校验兑换结果失败");
logger.info("校验优惠券会员特定等级成功");
break;
}
}
/**
* @param caseNum 用例编号
* @param appItemId 商品入库Id
* @param itemId 商品id
* @param token token
* @param caseName 用例名称打印
* @throws Exception
*/
@Test(dataProvider = "providerMethod")
public void 优惠券地区兑换限制测试(int caseNum, String appItemId, String itemId, String token,String caseName) throws Exception{
logger.info(caseName);
Map<String,String> map = new HashMap<>();
map.put("appItemId",appItemId);
map.put("itemId",itemId);
map.put("token",token);
//商品详情页兑换按钮
Response detailResponse = mobileService.detail(authorization.dafuwengLogin(uid),itemId);
detailResponse.prettyPrint();
String exchangeText = MatcherString.getString(detailResponse.asString(),"\"exchangeText\":\"(.*?)\"",1);
//优惠券兑换
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.dafuwengLogin(uid)).params(map).post(url + "/couponExchange/exchange");
response.prettyPrint();
switch (caseNum){
case 1:
Assert.assertEquals(exchangeText,"所处区域不可兑换","校验兑换按钮失败");
Assert.assertEquals(response.jsonPath().getString("message"),"不在可兑换区域哦,请挑选其他吧(30)","校验兑换结果失败");
logger.info("校验优惠券地区黑名单不可兑换成功");
break;
case 2:
Assert.assertEquals(exchangeText,"马上兑换","校验兑换按钮失败");
Assert.assertEquals(response.jsonPath().getString("success"),"true","校验兑换结果失败");
logger.info("校验优惠券地区黑名单以外可兑换成功");
break;
case 3:
Assert.assertEquals(exchangeText,"马上兑换","校验兑换按钮失败");
Assert.assertEquals(response.jsonPath().getString("success"),"true","校验兑换结果失败");
logger.info("校验优惠券地区白名单可兑换成功");
break;
case 4:
Assert.assertEquals(exchangeText,"所处区域不可兑换","校验兑换按钮失败");
Assert.assertEquals(response.jsonPath().getString("message"),"不在可兑换区域哦,请挑选其他吧(30)","校验兑换结果失败");
logger.info("校验优惠券地区白名单以外不可兑换成功");
break;
}
}
//优惠券兑换接口抽离
public Response 优惠券兑换(String appItemId,String itemId,int uid) throws Exception {
Response response = couponExchangeService.couponExchange(authorization.dafuwengLogin(uid),appItemId,itemId);
String orderId = response.jsonPath().getString("orderId");
logger.info("订单号:" + orderId);
//查看兑换结果
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid), orderId);
response.prettyPrint();
String status = response.jsonPath().getString("status");
//异步接口
int i = 10;
while (i > 0 && status.equals("processing")) {
Thread.sleep(1000);
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid), orderId);
response.prettyPrint();
status = response.jsonPath().getString("status");
i--;
}
return response;
}
public String 优惠券兑换订单(String appItemId,String itemId,int uid) throws Exception {
Response response = couponExchangeService.couponExchange(authorization.dafuwengLogin(uid),appItemId,itemId);
String orderId = response.jsonPath().getString("orderId");
//查看兑换结果
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid), orderId);
response.prettyPrint();
String status = response.jsonPath().getString("status");
//异步接口
int i = 10;
while (i > 0 && status.equals("processing")) {
Thread.sleep(1000);
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid), orderId);
response.prettyPrint();
status = response.jsonPath().getString("status");
i--;
}
return orderId;
}
}
package http.cases.ExchangeTest;
import base.DuibaTestBase;
import http.service.Activity.ManagerService;
import http.service.Authorization;
import http.service.app.AlipayExchangeService;
import http.service.app.ConfirmService;
import http.service.app.CouponExchangeService;
import http.service.app.MobileService;
import http.service.hd.DeveloperAccountService;
import http.service.hd.DsOrderService;
import base.DuibaLog;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.Test;
import java.util.Map;
/**
* Created by lvwenyan on 2018/06/08.
*/
public class 商品订单失败测试_ExchangeTest extends DuibaTestBase {
@Autowired
private CouponExchangeService couponExchangeService;
@Autowired
private ManagerService managerService;
@Autowired
private MobileService mobileService;
@Autowired
private DsOrderService dsOrderService;
@Autowired
private ConfirmService confirmService;
@Autowired
private AlipayExchangeService alipayExchangeService;
@Autowired
private Authorization authorization;
@Autowired
private DeveloperAccountService developerAccountService;
private DuibaLog logger = DuibaLog.getLogger();
//指定用户
private static int uid = 3769;
@Test
public void 实物扣积分失败测试() throws Exception{
managerService.index();
try {
//修改活动扣积分模板 consumeTemplateId: 1-扣积分成功;2-扣积分失败
managerService.doEdit2("2");
//实物兑换
//Response response= this.实物兑换("166813","28430");
Response response= this.实物兑换("170875","27970");
Assert.assertEquals(response.jsonPath().getString("data.message"),"兑换失败,扣积分-失败测试","校验message失败");
Assert.assertEquals(response.jsonPath().getString("data.status"),"fail","校验status失败");
Map<String,Object> mapOrderId = jdbc.findSimpleResult("SELECT * FROM "+Database.orders_consumer+"."+ Database.orders2 + " ORDER BY finish_time DESC LIMIT 1;");
String orderStatus = String.valueOf(mapOrderId.get("status"));
String orderError = String.valueOf(mapOrderId.get("error4consumer"));
Assert.assertEquals(orderStatus,"fail","校验数据库status失败");
Assert.assertEquals(orderError,"兑换失败,扣积分-失败测试","校验数据库error失败");
logger.info("校验实物扣积分失败成功");
}catch (Exception e){
throw new Exception("异常信息打印:" + e);
}finally {
//还原活动扣积分模板 consumeTemplateId: 1-扣积分成功;2-扣积分失败
managerService.doEdit2("1");
}
}
@Test
public void 实物审核不通过测试() throws Exception{
//获取当前库存和积分
Map<String,Object> mapStock = jdbc.findSimpleResult("SELECT * FROM stock.tb_stock WHERE stock_id =683671791616420831");
String stock = String.valueOf(mapStock.get("stock"));
logger.info("当前商品库存:" + stock);
Map<String,Object> mapCredits = jdbc.findSimpleResult("SELECT user.id,user.credits,consumer.credits FROM dafuweng.`user` as user , new_consumer.consumer_0010 as consumer WHERE consumer.partner_user_id=user.id and user.id="+uid);
String userCredits = String.valueOf(mapCredits.get("credits"));
String conCredits = String.valueOf(mapCredits.get("credits(2)"));
logger.info("当前用户积分: " + userCredits);
//实物兑换
String orderId = this.实物兑换订单(uid,"167007","28479");
logger.info("订单号:" + orderId);
//订单审核,判断是否在待审核节点
Map<String,Object> mapOrder = jdbc.findSimpleResult("SELECT * FROM "+Database.orders_consumer+"."+Database.orders5+" WHERE id = " + orderId);
String flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
logger.info("数据库订单节点:" + flowWork);
int i =10;
while (i > 0 && !flowWork.equals("Audit-started")) {
Thread.sleep(300);
mapOrder = jdbc.findSimpleResult("SELECT * FROM "+Database.orders_consumer+"."+Database.orders5+" WHERE id = " + orderId);
flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
logger.info("数据库订单节点:" + flowWork);
i--;
}
//订单审核
Response auditResponse = dsOrderService.submitAudit(orderId,"reject");
auditResponse.prettyPrint();
//判断订单是否审核失败
int j =10;
while (j > 0 && !flowWork.equals("Fail-complete")) {
Thread.sleep(1000);
auditResponse = dsOrderService.submitAudit(orderId,"reject");
mapOrder = jdbc.findSimpleResult("SELECT * FROM "+Database.orders_consumer+"."+Database.orders5+" WHERE id = " + orderId);
flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
logger.info("当前订单节点:" + flowWork);
j--;
}
String orderStatus = String.valueOf(mapOrder.get("status"));
String orderError = String.valueOf(mapOrder.get("error4consumer"));
//再次获取当前库存和积分
Thread.sleep(1000);
mapStock = jdbc.findSimpleResult("SELECT * FROM stock.tb_stock WHERE stock_id =683671791616420831");
String stockNew = String.valueOf(mapStock.get("stock"));
mapCredits = jdbc.findSimpleResult("SELECT user.id,user.credits,consumer.credits FROM dafuweng.`user` as user , new_consumer.consumer_0010 as consumer WHERE consumer.partner_user_id=user.id and user.id="+uid);
String userCreditsNew = String.valueOf(mapCredits.get("credits"));
String conCreditsNew = String.valueOf(mapCredits.get("credits(2)"));
//校验订单状态,校验返回库存和积分
Assert.assertEquals(orderStatus,"fail","校验数据库status失败");
Assert.assertEquals(orderError,"审核不通过(备注:测试订单审核不通过)","校验数据库error失败");
logger.info("校验实物订单审核不通过成功");
Assert.assertEquals(stockNew,stock,"校验stock失败");
Assert.assertEquals(userCreditsNew,userCredits,"校验userCredits失败");
Assert.assertEquals(conCreditsNew,conCredits,"校验conCredits失败");
logger.info("校验实物订单失败返还库存和积分成功");
}
@Test
public void 实物发货撤销测试() throws Exception{
//实物兑换【勿动】自动化兑吧实物
String orderId = this.实物兑换订单(uid,"166813","28430");
logger.info("订单号:" + orderId);
//管理端订单发货撤销
Response response = managerService.cancelOrder(orderId);
response.prettyPrint();
//获取数据库订单状态
Map<String,Object> mapOrder = jdbc.findSimpleResult("SELECT * FROM "+Database.orders_consumer+"."+Database.orders5+" WHERE id = " + orderId);
String flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
int i =10;
while (i > 0 && !flowWork.equals("Fail-complete")) {
Thread.sleep(300);
mapOrder = jdbc.findSimpleResult("SELECT * FROM "+Database.orders_consumer+"."+Database.orders5+" WHERE id = " + orderId);
flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
logger.info("数据库订单节点:" + flowWork);
i--;
}
String orderStatus = String.valueOf(mapOrder.get("status"));
String orderError = String.valueOf(mapOrder.get("error4consumer"));
Assert.assertEquals(response.jsonPath().getString("success"),"true","校验管理端订单发货撤销失败");
Assert.assertEquals(orderStatus,"fail","校验数据库status失败");
Assert.assertEquals(orderError,"测试订单发货撤销","校验数据库error失败");
logger.info("校验实物订单发货撤销成功");
}
@Test
public void 实物加钱购取消订单测试() throws Exception{
//实物兑换
Response objectResponse = couponExchangeService.objectExchange(uid,"167080","null");
String orderId = objectResponse.jsonPath().getString("orderId");
logger.info("订单id:" + orderId);
//手机端取消订单,需等待订单流程到付款节点
Map<String,Object> mapOrder = jdbc.findSimpleResult("SELECT * FROM "+Database.orders_consumer+"."+Database.orders5+" WHERE id = " + orderId);
String flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
logger.info("数据库订单节点: "+ flowWork);
int i =10;
while (i > 0 && !flowWork.equals("ConsumerPay-started")) {
Thread.sleep(300);
mapOrder = jdbc.findSimpleResult("SELECT * FROM "+Database.orders_consumer+"."+Database.orders5+" WHERE id = " + orderId);
flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
logger.info("数据库订单节点:" + flowWork);
i--;
}
Response cancelResponse = confirmService.cancelOrder(uid,orderId);
cancelResponse.prettyPrint();
//获取数据库订单最终状态j
int j =10;
while (j > 0 && !flowWork.equals("Fail-complete")) {
Thread.sleep(300);
mapOrder = jdbc.findSimpleResult("SELECT * FROM "+Database.orders_consumer+"."+Database.orders5+" WHERE id = " + orderId);
flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
logger.info("数据库订单节点:" + flowWork);
j--;
}
String orderStatus = String.valueOf(mapOrder.get("status"));
String orderError = String.valueOf(mapOrder.get("error4consumer"));
Assert.assertEquals(cancelResponse.jsonPath().getString("success"),"true","校验取消订单操作失败");
Assert.assertEquals(orderStatus,"fail","校验数据库status失败");
Assert.assertEquals(orderError,"取消订单","校验数据库error失败");
logger.info("校验实物加钱购取消订单成功");
}
@Test
public void 支付宝兑换失败测试() throws Exception{
//支付宝兑换,使用异常的支付宝账户
Response alipayResponse = alipayExchangeService.exchange(uid,"fail_acctunusual@126.com","测试","1");
String orderId = alipayResponse.jsonPath().getString("orderId");
logger.info("订单id:" + orderId);
Response statusResponse = mobileService.orderStatusQuery(uid,orderId);
statusResponse.prettyPrint();
String message = statusResponse.jsonPath().getString("message");
int i = 30;
//异步接口,直到兑换成功
while (i > 0 && message.equals("兑换正在处理中...")) {
Thread.sleep(1000);
statusResponse = mobileService.orderStatusQuery(uid,orderId);
statusResponse.prettyPrint();
message = statusResponse.jsonPath().getString("message");
i--;
}
//异步接口,判断订单状态,直到处理完成
while (i > 0 && message.equals("兑换提交成功!待处理")) {
Thread.sleep(1000);
statusResponse = mobileService.orderStatusQuery(uid,orderId);
statusResponse.prettyPrint();
message = statusResponse.jsonPath().getString("message");
i--;
}
//获取数据库订单数据
Map<String,Object> mapOrder = jdbc.findSimpleResult("SELECT * FROM "+Database.orders_consumer+"."+Database.orders5+" WHERE id = " + orderId);
String flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
logger.info("数据库订单节点:" + flowWork);
int j =10;
while (j > 0 && !flowWork.equals("Fail-complete")) {
Thread.sleep(300);
mapOrder = jdbc.findSimpleResult("SELECT * FROM "+Database.orders_consumer+"."+Database.orders5+" WHERE id = " + orderId);
flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
logger.info("数据库订单节点:" + flowWork);
j--;
}
String orderStatus = String.valueOf(mapOrder.get("status"));
String orderError = String.valueOf(mapOrder.get("error4consumer"));
Assert.assertEquals(statusResponse.jsonPath().getString("message"),"40004:Business Failed_PAYEE_NOT_EXIST:收款账号不存在","校验message失败");
Assert.assertEquals(orderStatus,"fail","校验数据库status失败");
Assert.assertEquals(orderError,"40004:Business Failed_PAYEE_NOT_EXIST:收款账号不存在","校验数据库error失败");
logger.info("校验支付宝异常账户兑换失败成功");
}
//@Test
public void 支付宝审核不通过测试() throws Exception{
//查询兑换前的开发者账户余额
// Response accountResponse = developerAccountService.accountInfo();
// String remainMoney = accountResponse.jsonPath().getString("data.remainMoney");
// logger.info("兑换前的开发者账户余额:" + remainMoney);
//支付宝兑换
String orderId = this.支付宝兑换订单(uid,"peeulk6392@sandbox.com","沙箱环境","10");
logger.info("订单号:" + orderId);
//订单审核,判断是否在待审核节点
Map<String,Object> mapOrder = jdbc.findSimpleResult("SELECT * FROM "+Database.orders_consumer+"."+Database.orders5+" WHERE id = " + orderId);
String flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
logger.info("数据库订单节点:" + flowWork);
String orderIdmain = String.valueOf(mapOrder.get("order_num"));
logger.info("兑吧订单号为:" + orderIdmain);
int i =10;
while (i > 0 && !flowWork.equals("Audit-started")) {
Thread.sleep(300);
mapOrder = jdbc.findSimpleResult("SELECT * FROM "+Database.orders_consumer+"."+Database.orders5+" WHERE id = " + orderId);
flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
logger.info("数据库订单节点:" + flowWork);
i--;
}
//订单审核
Response auditResponse = dsOrderService.submitAudit(orderId,"reject");
auditResponse.prettyPrint();
//判断订单是否审核失败
int j =10;
while (j > 0 && !flowWork.equals("Fail-complete")) {
Thread.sleep(1000);
auditResponse = dsOrderService.submitAudit(orderId,"reject");
mapOrder = jdbc.findSimpleResult("SELECT * FROM "+Database.orders_consumer+"."+Database.orders5+" WHERE id = " + orderId);
flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
logger.info("当前订单节点:" + flowWork);
j--;
}
String status = String.valueOf(mapOrder.get("status"));
//兑换后的开发者账户余额
// accountResponse = developerAccountService.accountInfo();
// String remainMoneyNew = accountResponse.jsonPath().getString("data.remainMoney");
// logger.info("兑换后的开发者账户余额:" + remainMoneyNew);
//校验开发者账户余额变动
Response accountResponse = developerAccountService.cashDetail(orderIdmain);
String remainMoney = String.valueOf(Integer.valueOf(accountResponse.jsonPath().getString("data.list[1].balance"))+Integer.valueOf(accountResponse.jsonPath().getString("data.list[1].moneyChange")));
logger.info("兑换前的开发者账户余额:" + remainMoney);
String remainMoneyNew = accountResponse.jsonPath().getString("data.list[0].balance");
logger.info("兑换后的开发者账户余额:" + remainMoneyNew);
Assert.assertEquals(remainMoneyNew,remainMoney,"校验开发者账户余额失败");
Assert.assertEquals(status,"fail","校验订单状态失败");
logger.info("校验支付宝审核订单失败返还金额成功");
}
// 上游不稳定,暂时关闭
// 上游不稳定,暂时关闭
// @Test
// public void 话费上游兑换失败测试() throws Exception{
//
// try {
// //修改大富翁上游兑换模板(phonebill-oufei)
// managerService.use("104");
// Thread.sleep(500);
// //话费兑换
// Response phoneResponse= couponExchangeService.phonebillExchange(authorization.dafuwengLogin(uid),"156497","1660");
// String orderId = phoneResponse.jsonPath().getString("orderId");
// logger.info("订单id:" + orderId);
//
// Response statusResponse = mobileService.orderStatusQuery(uid,orderId);
// statusResponse.prettyPrint();
// String message = statusResponse.jsonPath().getString("message");
// int i = 10;
// //异步接口,直到兑换成功
// while (i > 0 && message.equals("兑换正在处理中...")) {
// Thread.sleep(1000);
// statusResponse = mobileService.orderStatusQuery(uid,orderId);
// statusResponse.prettyPrint();
// message = statusResponse.jsonPath().getString("message");
// i--;
// }
//
// //获取数据库订单数据,上游订单处理失败需增加等待时间
// Map<String,Object> mapOrder = jdbc.findSimpleResult("SELECT * FROM "+Database.orders_consumer+"."+Database.orders+" WHERE id = " + orderId);
// String flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
// logger.info("数据库订单节点:" + flowWork);
// int j =10;
// while (j > 0 && !flowWork.equals("Fail-complete")) {
// Thread.sleep(1000);
// mapOrder = jdbc.findSimpleResult("SELECT * FROM "+Database.orders_consumer+"."+Database.orders+" WHERE id = " + orderId);
// flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
// logger.info("数据库订单节点:" + flowWork);
// j--;
// }
// String orderStatus = String.valueOf(mapOrder.get("status"));
// String orderError = String.valueOf(mapOrder.get("error4consumer"));
// String orderErrorDev = String.valueOf(mapOrder.get("error4developer"));
//
// Assert.assertEquals(statusResponse.jsonPath().getString("message"),"兑换提交成功!待处理");
// Assert.assertEquals(orderStatus,"fail","校验数据库status失败");
// Assert.assertEquals(orderError,"兑换失败,请稍后重试","校验数据库error4consumer失败");
// Assert.assertEquals(orderErrorDev,"上游兑换失败","校验数据库error4developer失败");
//
// logger.info("校验话费上游兑换失败成功");
//
//
// }catch (Exception e){
// throw new Exception("异常信息打印:" + e);
//
// }finally {
// //还原活动扣积分模板 consumeTemplateId: 1-扣积分成功;2-扣积分失败
// managerService.use("102");
//
// }
//
// }
public Response 实物兑换(String appItemId, String itemId) throws Exception{
Response objectResponse = couponExchangeService.objectExchange(3268,appItemId,itemId);
objectResponse.prettyPrint();
String orderId = objectResponse.jsonPath().getString("orderId");
Response statusResponse = mobileService.orderAmbStatusQuery(3268,orderId);
statusResponse.prettyPrint();
String message = statusResponse.jsonPath().getString("data.message");
int i = 10;
//异步接口,直到兑换成功
while (i > 0 && message.equals("兑换正在处理中...")) {
Thread.sleep(1000);
statusResponse = mobileService.orderAmbStatusQuery(3268,orderId);
statusResponse.prettyPrint();
message = statusResponse.jsonPath().getString("data.message");
i--;
}
return statusResponse;
}
public String 实物兑换订单(int uid, String appItemId, String itemId) throws Exception{
Response objectResponse = couponExchangeService.objectExchange(uid,appItemId,itemId);
objectResponse.prettyPrint();
String orderId = objectResponse.jsonPath().getString("orderId");
Response statusResponse = mobileService.orderAmbStatusQuery(uid,orderId);
statusResponse.prettyPrint();
String message = statusResponse.jsonPath().getString("data.message");
int i = 10;
//异步接口,直到兑换成功
while (i > 0 && message.equals("兑换正在处理中...")) {
Thread.sleep(1000);
statusResponse = mobileService.orderAmbStatusQuery(uid,orderId);
statusResponse.prettyPrint();
message = statusResponse.jsonPath().getString("data.message");
i--;
}
return orderId;
}
//支付宝兑换接口抽离
public String 支付宝兑换订单(int uid,String alipay,String realname,String degreeId) throws Exception {
Response response = alipayExchangeService.exchange(uid,alipay,realname,degreeId);
String orderId = response.jsonPath().getString("orderId");
//查看兑换结果
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid), orderId);
response.prettyPrint();
String status = response.jsonPath().getString("status");
//异步接口
int i = 10;
while (i > 0 && status.equals("processing")) {
Thread.sleep(1000);
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid), orderId);
response.prettyPrint();
status = response.jsonPath().getString("status");
i--;
}
return orderId;
}
}
package http.cases.ExchangeTest;
import base.DuibaTestBase;
import http.service.Activity.ManagerService;
import http.service.Authorization;
import http.service.app.CouponExchangeService;
import http.service.app.CrecordService;
import http.service.app.MobileService;
import http.service.app.VirtualExchangeService;
import http.service.hd.DeveloperAccountService;
import utils.MatcherString;
import base.DuibaLog;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.Test;
import java.util.Map;
/**
* Created by yeqinqin on 2018/6/11.
*/
public class 实物_兑换异常测试_ExchangeTest extends DuibaTestBase {
@Autowired
private MobileService mobileService;
@Autowired
private Authorization authorization;
@Autowired
private CouponExchangeService couponExchangeService;
@Autowired
private CrecordService crecordService;
@Autowired
ManagerService managerService;
@Autowired
VirtualExchangeService virtualExchangeService;
@Autowired
DeveloperAccountService developerAccountService;
private DuibaLog logger = DuibaLog.getLogger();
//指定用户
private static int uid = 3770;
//实物兑换积分不足
@Test(description = "实物兑换积分不足")
public void 积分不足() throws Exception {
//活动详情页
Response response = mobileService.detail(authorization.dafuwengLogin(3086), "28515");
Map<String, String> map = authorization.dafuwengLogin(3086);
Assert.assertEquals(String.valueOf(response.getStatusCode()), "200", "活动详情页请求异常");
//实物兑换
response = couponExchangeService.objectExchange(map, "167141", "28515", "null", "z9sydmcs", "null");
response.prettyPrint();
//校验兑换成功
// Assert.assertEquals(response.jsonPath().getString("success"),"true");
//获取orderId
String orderId = response.jsonPath().getString("orderId");
//获取兑换结果
response = mobileService.orderAmbStatusQuery(3086,orderId);
response.prettyPrint();
String message = response.jsonPath().getString("data.message");
int i = 10;
//异步接口,直到兑换成功
while (i > 0 && "兑换正在处理中...".equals(message)) {
Thread.sleep(1000);
response = mobileService.orderAmbStatusQuery(3086,orderId);
response.prettyPrint();
message = response.jsonPath().getString("data.message");
i--;
}
//校验messaga字段返回值
String message2 = response.jsonPath().getString("data.message");
Assert.assertEquals(message2,"兑换失败,用户积分余额不足","message字段校验失败-期望是积分不足");
// authorization.dafuwengLogin(2720,true);
}
//实物兑换限制消费
@Test(description = "实物兑换已兑换")
public void 已兑换() throws Exception {
//活动详情页
Response response = mobileService.detail(authorization.dafuwengLogin(uid), "28633");
// response.prettyPrint();
Map<String, String> map = authorization.dafuwengLogin(uid);
Assert.assertEquals(String.valueOf(response.getStatusCode()), "200", "活动详情页请求异常");
//实物兑换
Response response1 = couponExchangeService.objectExchange1(map, "167611", "28633", "null", "z9sydmcs", "null");
response1.prettyPrint();
//校验兑换成功
// Assert.assertEquals(response.jsonPath().getString("success"),"true");
//获取orderId
// String orderId = response1.jsonPath().getString("orderId");
// //获取兑换结果
// Response response3 = mobileService.orderAmbStatusQuery(orderId);
// response3.prettyPrint();
// String message = response3.jsonPath().getString("data.message");
// int i = 10;
// //异步接口,直到兑换成功
// while (i > 0 && "兑换正在处理中...".equals(message)) {
// Thread.sleep(1000);
// response3 = mobileService.orderAmbStatusQuery(orderId);
// response3.prettyPrint();
// message = response3.jsonPath().getString("data.message");
// i--;
// }
//校验messaga字段返回值
String message2 = response1.jsonPath().getString("message");
Assert.assertEquals(message2,"已兑换","message字段校验失败-期望是已兑换");
}
@Test
public void 开发者余额不足测试() throws Exception{
int uid = 3490;
//开发者余额, 开发者账户:xuyan_8707@163.com
Response accountResponse = developerAccountService.accountInfoCommon("xuyan_8707@163.com");
String remainMoney = accountResponse.jsonPath().getString("data.remainMoney");
logger.info("兑换前的开发者账户余额:" + remainMoney);
Response detailResponse = mobileService.detail(authorization.dafuwengLogin(uid),"31050");
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
logger.info("~~~"+exchangeText);
Assert.assertTrue(exchangeText.contains("已兑完"));
String message=null;
String succcess = null;
try{
Response response = couponExchangeService.objectExchange1(authorization.dafuwengLogin(uid), "178880", "31050", "null", "z9sydmcs", "null");
message = response.jsonPath().getString("message");
}catch (Exception e){
message = e.toString();
}
logger.info(message);
Assert.assertTrue(message.contains("没有兑换成功"));
}
// @Test
public void 每日兑换限制() throws Exception {
int uid = 3490;
//第一次兑换
Response response = couponExchangeService.objectExchange(authorization.dafuwengLogin(uid), "178879", "31049", "null", "z9sydmcs", "null");
response.prettyPrint();
String orderId = response.jsonPath().getString("orderId");
//获取兑换结果
response = mobileService.orderAmbStatusQuery(uid,orderId);
response.prettyPrint();
String message = response.jsonPath().getString("data.message");
int i = 10;
//异步接口,直到兑换成功
while (i > 0 && "兑换正在处理中...".equals(message)) {
Thread.sleep(1000);
response = mobileService.orderAmbStatusQuery(uid,orderId);
response.prettyPrint();
message = response.jsonPath().getString("data.message");
i--;
}
//第二次兑换
try{
response = couponExchangeService.objectExchange(authorization.dafuwengLogin(uid), "178879", "31049", "null", "z9sydmcs", "null");
response.prettyPrint();
}catch (Exception e){
// message = e.toString();
}
// logger.info(message);
// Assert.assertTrue(message.contains("已兑完"));
// Assert.assertTrue(message.contains("\"success\":false"));
}
}
package http.cases.ExchangeTest;
import base.DuibaTestBase;
import http.service.Authorization;
import http.service.app.AppPlatformCouponService;
import http.service.app.CrecordService;
import utils.MatcherString;
import base.DuibaLog;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import static io.restassured.RestAssured.given;
/**
* Created by lvwenyan on 2018/08/09.
*/
//@ContextConfiguration(classes = DuibaConfig.class)
public class 平台券_兑换流程测试_ExchangeTest extends DuibaTestBase {
@Autowired
AppPlatformCouponService appPlatformCouponService;
@Autowired
Authorization authorization;
@Autowired
CrecordService crecordService;
private DuibaLog logger = DuibaLog.getLogger();
private static int uid = 3770;
private String url = "http://activity.m.duibatest.com.cn";
// private MysqlUtils jdbc;
// @BeforeClass
// public void before(){
//
// jdbc = MysqlUtils.mysqlDuiba("");
//
// }
//
// @AfterClass
// public void after(){
//
// jdbc.releaseConn();
// }
@DataProvider
public Object[][] providerMethod(Method method) {
Object[][] result = null;
if (method.getName().equals("平台券库存不足测试")) {
result = new Object[][]{
new Object[]{"73734759122009","n990y8dac","平台券商品库存不足测试"}, //case1
new Object[]{"73734793724984", "s4c0zy","平台券预分配库存不足测试"}, //case2
};
}
if(method.getName().equals("平台券预分配库存测试")){
result = new Object[][]{
new Object[]{"73734759122009","n990y8dac","平台券商品库存不足测试"}, //case1
};
}
if(method.getName().equals("平台券马上使用按钮测试")){
result = new Object[][]{
new Object[]{1,"74372992121534","平台券商家落地页链接测试"}, //case1
new Object[]{2,"74922024942959","平台券兑换记录页链接测试"}, //case2
new Object[]{3,"74378122799009","平台券链接券测试"}, //case3
};
}
return result;
}
@Test
public void 平台券扣积分和库存测试() throws Exception {
//查询平台券兑换前的库存和积分
Map<String,Object> mapStock = jdbc.findSimpleResult("SELECT * FROM stock.tb_stock WHERE stock_id =737253124770670925");
String stock = String.valueOf(mapStock.get("stock")) ;
logger.info("兑换前的平台券库存:" + stock);
stock = String.valueOf(Integer.parseInt(stock) - 1) ;
Map<String,Object> mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
String credits = String.valueOf(mapuser.get("credits"));
logger.info("兑换前积分:"+credits); //扣去100积分
credits = String.valueOf(Integer.valueOf(credits)-10);
//平台券兑换
String orderId = this.平台券兑换订单(uid,"73725292586909");
logger.info("订单号:" + orderId);
//查询优惠券兑换后的库存和积分
mapStock = jdbc.findSimpleResult("SELECT * FROM stock.tb_stock WHERE stock_id =737253124770670925");
String stockNew = String.valueOf(mapStock.get("stock")) ;
logger.info("兑换后的优惠券库存:" + stockNew);
Thread.sleep(3000);
mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
String creditsNew = String.valueOf(mapuser.get("credits"));
logger.info("兑换后积分:"+creditsNew);
//查询订单状态
Map<String,Object> mapOrder = jdbc.findSimpleResult("SELECT * FROM "+Database.orders_consumer+"."+Database.orders6+" WHERE id = " + orderId);
String status = String.valueOf(mapOrder.get("status"));
Assert.assertEquals(stockNew,stock,"校验平台券库存失败");
Assert.assertEquals(creditsNew,credits,"校验平台券扣积分失败");
Assert.assertEquals(status,"success","校验订单状态失败");
logger.info("平台券兑换扣库存和积分校验成功");
}
/**
* @param pcgId 平台券Id
* @param token token
* @param caseName 用例名称打印
* @throws Exception
*/
@Test(dataProvider = "providerMethod")
public void 平台券库存不足测试(String pcgId, String token, String caseName) throws Exception{
logger.info(caseName);
Map<String,String> map = new HashMap<>();
map.put("pcgId",pcgId);
map.put("token",token);
//平台券兑换
Response response = given().contentType("application/x-www-form-urlencoded").cookies(authorization.dafuwengLogin(uid)).params(map).post(url + "/platformCoupon/takeOrder");
response.prettyPrint();
//平台券页面兑换按钮
Response detailResponse = appPlatformCouponService. platformDetail(uid,pcgId);
detailResponse.prettyPrint();
Assert.assertEquals(response.jsonPath().getString("message"),"库存不足","校验message失败");
Assert.assertEquals(detailResponse.asString().contains("已兑完"),true);
logger.info("校验平台券库存不足成功");
}
@Test
public void 平台券积分不足测试() throws Exception{
Map<String,String> map = new HashMap<>();
map.put("pcgId","73725292586909");
map.put("token","dnsog");
//获取按钮状态
Response detailResponse = appPlatformCouponService.platformDetail(3086,true,"73725292586909");
detailResponse.prettyPrint();
String exchangeText = MatcherString.getString(detailResponse.asString(),"exchangeText: '(.*?)',",1);
//平台券兑换
Response response = given().contentType("application/x-www-form-urlencoded").cookies(authorization.dafuwengLogin(3086)).params(map).post(url + "/platformCoupon/takeOrder");
response.prettyPrint();
//exchangetext=2: 积分不足
Assert.assertEquals(exchangeText,"2","校验按钮状态失败");
Assert.assertEquals(response.jsonPath().getString("success"),"false","校验success失败");
logger.info("校验平台券商品积分不足场景成功");
//切换回正常用户
//authorization.dafuwengLogin(uid,true);
}
@Test
public void 平台券预分配库存测试() throws Exception{
Map<String,Object> mapStock = jdbc.findSimpleResult("SELECT * FROM stock.tb_stock WHERE stock_id = 741004276004170604");
String stock = String.valueOf(mapStock.get("stock")) ;
logger.info("兑换前的平台券预分配库存:" + stock);
stock = String.valueOf(Integer.valueOf(stock)-1);
Map<String,Object> mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
String credits = String.valueOf(mapuser.get("credits"));
logger.info("兑换前的积分:"+credits);
credits = String.valueOf(Integer.valueOf(credits)-10);
//平台券兑换
this.平台券兑换(uid,"74100364718684");
//查询兑换后的库存和积分
mapStock = jdbc.findSimpleResult("SELECT * FROM stock.tb_stock WHERE stock_id = 741004276004170604");
String stockNew = String.valueOf(mapStock.get("stock")) ;
logger.info("兑换后的平台券预分配库存:" + stockNew);
Thread.sleep(3000);
mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
String creditsNew = String.valueOf(mapuser.get("credits"));
logger.info("兑换后积分:"+creditsNew);
Assert.assertEquals(stockNew,stock,"校验平台券预分配库存失败");
Assert.assertEquals(creditsNew,credits,"校验平台券预分配最小兑换价格失败");
logger.info("校验平台券预分配库存和最小兑换积分成功");
}
@Test
public void 平台券共享库存测试() throws Exception{
Map<String,Object> mapStock = jdbc.findSimpleResult("SELECT * FROM stock.tb_stock WHERE stock_id = 743716478156171001");
String stock = String.valueOf(mapStock.get("stock")) ;
logger.info("兑换前的平台券共享库存:" + stock);
stock = String.valueOf(Integer.valueOf(stock)-1);
//优惠券兑换
this.平台券兑换(uid,"74371604856809");
//查询兑换后的库存
mapStock = jdbc.findSimpleResult("SELECT * FROM stock.tb_stock WHERE stock_id = 743716478156171001");
String stockNew = String.valueOf(mapStock.get("stock")) ;
logger.info("兑换后的平台券共享库存:" + stockNew);
Assert.assertEquals(stockNew,stock,"校验平台券共享库存库存失败");
logger.info("校验平台券共享库存扣除成功");
}
@Test
public void 平台券预分配每日限额测试() throws Exception{
try {
//平台券第一次兑换
this.平台券兑换(uid,"74735076603359");
//每日限额用完,无法再次兑换
Map<String,String> map = new HashMap<>();
map.put("pcgId","74735076603359");
map.put("token","dnsog");
//获取按钮状态
Response detailResponse = appPlatformCouponService.platformDetail(uid,"74735076603359");
detailResponse.prettyPrint();
String exchangeText = MatcherString.getString(detailResponse.asString(),"exchangeText: '(.*?)',",1);
//平台券兑换
Response response = given().contentType("application/x-www-form-urlencoded").cookies(authorization.dafuwengLogin(uid)).params(map).post(url + "/platformCoupon/takeOrder");
response.prettyPrint();
//exchangetext=3: 已兑完
Assert.assertEquals(exchangeText,"3","校验按钮状态失败");
Assert.assertEquals(response.jsonPath().getString("message"),"库存不足","校验message失败");
logger.info("校验平台券预分配每日限额兑换成功");
}catch (Exception e){
throw new Exception("异常信息打印:" + e);
}finally {
//清除兑换数据和 redis
jdbc.update("DELETE FROM stock.tb_sales_volume WHERE relation_id = 74735076603359");
}
}
@Test
public void 平台券用户兑换限制测试() throws Exception{
try{
//平台券第一次兑换
this.平台券兑换(uid,"74371944595109");
//用户限制次数用完,无法兑换
Map<String,String> map = new HashMap<>();
map.put("pcgId","74371944595109");
map.put("token","dnsog");
//获取按钮状态
Response detailResponse = appPlatformCouponService.platformDetail(uid,"74371944595109");
detailResponse.prettyPrint();
String exchangeText = MatcherString.getString(detailResponse.asString(),"exchangeText: '(.*?)',",1);
Response response = given().contentType("application/x-www-form-urlencoded").cookies(authorization.dafuwengLogin(uid)).params(map).post(url + "/platformCoupon/takeOrder");
response.prettyPrint();
//exchangetext=1: 已兑换
Assert.assertEquals(exchangeText,"1","校验按钮状态失败");
Assert.assertEquals(response.jsonPath().getString("message"),"用户已兑换","校验message失败");
logger.info("校验平台券用户兑换限制成功");
}catch (Exception e){
throw new Exception("异常信息打印:" + e);
}finally {
jdbc.update("DELETE FROM goods.tb_goods_limit_record WHERE gid = 74371944595109 AND consumer_id = 100088018");
}
}
/**
* @param caseNum 用例编号
* @param pcgId 平台券id
* @param caseName 用例名称打印
* @throws Exception
*/
@Test(dataProvider = "providerMethod")
public void 平台券马上使用按钮测试(int caseNum, String pcgId, String caseName)throws Exception{
logger.info(caseName);
String orderId = this.平台券兑换订单(uid,pcgId);
logger.info("订单号: "+ orderId);
//平台券兑换结果页,需要等待订单刷新成功
Thread.sleep(3000);
Response resultResponse = crecordService.recordDetail(orderId,uid);
resultResponse.prettyPrint();
String btnText = MatcherString.getString(resultResponse.asString(),"\"btnText\":\"(.*?)\",",1);
String androidDownloadUrl = MatcherString.getString(resultResponse.asString(),"\"androidDownloadUrl\":\"(.*?)\",",1);
//平台券兑换记录页
Thread.sleep(3000);
Response recordResponse = crecordService.recordDetailNew(orderId,uid);
recordResponse.prettyPrint();
String useButtonText = MatcherString.getString(recordResponse.asString(),"\"useButtonText\":\"(.*?)\",",1);
String androidDownloadUrl2 = MatcherString.getString(recordResponse.asString(),"\"androidDownloadUrl\":\"(.*?)\",",1);
switch (caseNum){
case 1:
Assert.assertEquals(btnText,"马上使用","校验结果页按钮文案失败");
Assert.assertEquals(androidDownloadUrl,"//activity.m.duibatest.com.cn/log/redirect?url=https%3A%2F%2Fm.aomygod.com%2Fact-richang-meidehuierwaitui.html&amp;dpm=2239.25.1.0&amp;dcm=103.74372992121534.0.0","校验结果页按钮链接失败");
Assert.assertEquals(useButtonText,"马上使用","校验兑换记录页按钮文案失败");
Assert.assertEquals(androidDownloadUrl2,"//activity.m.duibatest.com.cn/log/redirect?url=https%3A%2F%2Fm.aomygod.com%2Fact-richang-meidehuierwaitui.html&amp;dpm=2239.25.2.0&amp;dcm=103.74372992121534.0.0","校验兑换记录页按钮跳转链接失败");
logger.info("校验平台券商家落地页下载链接页面成功");
break;
case 2:
Assert.assertEquals(btnText,"马上下载","校验结果页按钮文案失败");
Assert.assertEquals(androidDownloadUrl,"//activity.m.duibatest.com.cn/log/redirect?url=http%3A%2F%2Fm.lrts.me%2Fapp&amp;dpm=2239.25.1.0&amp;dcm=103.74922024942959.0.0","校验结果页按钮链接失败");
Assert.assertEquals(useButtonText,"马上下载","校验兑换记录页按钮文案失败");
Assert.assertEquals(androidDownloadUrl2,"//activity.m.duibatest.com.cn/log/redirect?url=http%3A%2F%2Fm.lrts.me%2Fapp&amp;dpm=2239.25.2.0&amp;dcm=103.74922024942959.0.0","校验兑换记录页按钮跳转链接失败");
logger.info("校验平台券兑换记录页下载链接页面成功");
break;
case 3:
Assert.assertEquals(btnText,"马上使用","校验结果页按钮文案失败");
Assert.assertEquals(androidDownloadUrl,"//activity.m.duibatest.com.cn/log/redirect?url=https%3A%2F%2Fm.4008123123.com%2F&amp;dpm=2239.25.1.0&amp;dcm=103.74378122799009.0.0","校验结果页按钮链接失败");
Assert.assertEquals(useButtonText,"马上使用","校验兑换记录页按钮文案失败");
Assert.assertEquals(androidDownloadUrl2,"//activity.m.duibatest.com.cn/log/redirect?url=https%3A%2F%2Fm.4008123123.com%2F&amp;dpm=2239.25.2.0&amp;dcm=103.74378122799009.0.0","校验兑换记录页按钮跳转链接失败");
logger.info("校验平台券链接券页面成功");
break;
}
}
//平台券兑换接口抽离
public Response 平台券兑换(int uid,String pcgId) throws Exception {
Response response = appPlatformCouponService.takeOrder(uid,pcgId);
String orderId = response.jsonPath().getString("orderId");
logger.info("订单号:" + orderId);
//查看兑换结果
response = appPlatformCouponService.getOrderStatus(uid,orderId);
response.prettyPrint();
return response;
}
public String 平台券兑换订单(int uid,String pcgId) throws Exception {
Response response = appPlatformCouponService.takeOrder(uid,pcgId);
String orderId = response.jsonPath().getString("orderId");
//查看兑换结果
response = appPlatformCouponService.getOrderStatus(uid,orderId);
response.prettyPrint();
return orderId;
}
}
package http.cases.ExchangeTest;
import base.DuibaLog;
import base.DuibaTestBase;
import http.service.Activity.ManagerService;
import http.service.Authorization;
import http.service.app.*;
import http.service.hd.DeveloperAccountService;
import http.service.hd.DsOrderService;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import java.lang.reflect.Method;
import java.util.Map;
/**
* Created by zhaoran on 2018/11/03.
* Mark : 涉及到开发者账户余额校验的普兑case,都需写在此类下面。
* 测试开发者账号:zhaoran@duiba.com.cn , 用户uid:4386
*/
public class 开发者账户余额校验测试_ExchangeTest extends DuibaTestBase {
@Autowired
private CouponExchangeService couponExchangeService;
@Autowired
private ManagerService managerService;
@Autowired
private MobileService mobileService;
@Autowired
private DsOrderService dsOrderService;
@Autowired
QbExchangeService qbExchangeService;
@Autowired
private AlipayExchangeService alipayExchangeService;
@Autowired
private Authorization authorization;
@Autowired
private DeveloperAccountService developerAccountService;
private DuibaLog logger = DuibaLog.getLogger();
//指定用户
//private static int uid = 3769;
private static int uid = 4386;
@DataProvider
public Object[][] providerMethod(Method method) {
Object[][] result = null;
if (method.getName().equals("优惠券兑换审核通过测试")) {
result = new Object[][]{
new Object[]{1,"184936", "29156", "兑吧优惠券审核通过测试"}, //case1
new Object[]{2,"184937", "", "自有优惠券审核通过测试"}, //case2
};
}
return result;
}
@Test
public void 支付宝兑换审核不通过测试() throws Exception{
//查询兑换前的开发者账户余额
// Response accountResponse = developerAccountService.accountInfo();
// String remainMoney = accountResponse.jsonPath().getString("data.remainMoney");
// logger.info("兑换前的开发者账户余额:" + remainMoney);
//支付宝兑换
String orderId = this.支付宝兑换订单(uid,"peeulk6392@sandbox.com","沙箱环境","10");
logger.info("订单号:" + orderId);
//订单审核,判断是否在待审核节点
Map<String,Object> mapOrder = jdbc.findSimpleResult("SELECT * FROM "+Database.orders_consumer+"."+Database.orders8+" WHERE id = " + orderId);
String flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
logger.info("数据库订单节点:" + flowWork);
String orderIdmain = String.valueOf(mapOrder.get("order_num"));
logger.info("兑吧订单号为:" + orderIdmain);
int i =10;
while (i > 0 && !flowWork.equals("Audit-started")) {
Thread.sleep(300);
mapOrder = jdbc.findSimpleResult("SELECT * FROM "+Database.orders_consumer+"."+Database.orders8+" WHERE id = " + orderId);
flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
logger.info("数据库订单节点:" + flowWork);
i--;
}
//订单审核
Response auditResponse = dsOrderService.submitAudit(orderId,"reject","zhaoran@duiba.com.cn");
auditResponse.prettyPrint();
//判断订单是否审核失败
int j =10;
while (j > 0 && !flowWork.equals("Fail-complete")) {
Thread.sleep(1000);
auditResponse = dsOrderService.submitAudit(orderId,"reject","zhaoran@duiba.com.cn");
mapOrder = jdbc.findSimpleResult("SELECT * FROM "+Database.orders_consumer+"."+Database.orders8+" WHERE id = " + orderId);
flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
logger.info("当前订单节点:" + flowWork);
j--;
}
String status = String.valueOf(mapOrder.get("status"));
//兑换后的开发者账户余额
// accountResponse = developerAccountService.accountInfo();
// String remainMoneyNew = accountResponse.jsonPath().getString("data.remainMoney");
// logger.info("兑换后的开发者账户余额:" + remainMoneyNew);
//校验开发者账户余额变动
Response accountResponse = developerAccountService.cashDetail(orderIdmain);
String remainMoney = String.valueOf(Integer.valueOf(accountResponse.jsonPath().getString("data.list[1].balance"))+Integer.valueOf(accountResponse.jsonPath().getString("data.list[1].moneyChange")));
logger.info("兑换前的开发者账户余额:" + remainMoney);
String remainMoneyNew = accountResponse.jsonPath().getString("data.list[0].balance");
logger.info("兑换后的开发者账户余额:" + remainMoneyNew);
Assert.assertEquals(remainMoneyNew,remainMoney,"校验开发者账户余额失败");
Assert.assertEquals(status,"fail","校验订单状态失败");
logger.info("校验支付宝审核订单失败返还金额成功");
}
@Test
public void Qb兑换审核通过测试() throws Exception {
//查询兑换前的开发者账户余额
// Response accountResponse = developerAccountService.accountInfo();
// String remainMoney = accountResponse.jsonPath().getString("data.remainMoney");
// logger.info("兑换前的开发者账户余额:" + remainMoney);
// String remainMoneyNew =String.valueOf(Integer.valueOf(remainMoney) - 9600) ;
// int uid = 2709;
Response response = qbExchangeService.doTakePrize(authorization.dafuwengLogin(uid),"1234345554","100");
String orderId = (String)response.jsonPath().get("orderId");
response.prettyPrint();
//订单审核,判断是否在待审核节点
Map<String,Object> mapOrder = jdbc.findSimpleResult("SELECT * FROM "+Database.orders_consumer+"."+Database.orders8+" where id ="+orderId);
String flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
logger.info("数据库订单节点:" + flowWork);
String orderIdmain = String.valueOf(mapOrder.get("order_num"));
logger.info("兑吧订单号为:" + orderIdmain);
int i =10;
while (i > 0 && !flowWork.equals("Audit-started")) {
Thread.sleep(300);
mapOrder = jdbc.findSimpleResult("SELECT * FROM "+Database.orders_consumer+"."+Database.orders8+" where id ="+orderId);
flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
logger.info("数据库订单节点:" + flowWork);
i--;
}
Response auditResponse = dsOrderService.submitAudit(orderId,"pass","zhaoran@duiba.com.cn");
auditResponse.prettyPrint();
//判断订单是否审核成功,如果订单没有成功则继续审核
int j =10;
while (j > 0 && !flowWork.equals("Success-complete")) {
Thread.sleep(1000);
auditResponse = dsOrderService.submitAudit(orderId,"pass","zhaoran@duiba.com.cn");
mapOrder = jdbc.findSimpleResult("SELECT * FROM "+Database.orders_consumer+"."+Database.orders8+" where id ="+orderId);
flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
logger.info("数据库订单节点:" + flowWork);
j--;
}
String status = String.valueOf(mapOrder.get("status"));
//兑换后的开发者账户余额
// accountResponse = developerAccountService.accountInfo();
// remainMoney = accountResponse.jsonPath().getString("data.remainMoney");
// logger.info("兑换后的开发者账户余额:" + remainMoney);
// Assert.assertEquals(remainMoney,remainMoneyNew,"校验开发者账户余额失败");
//校验开发者账户余额变动
Response accountResponse = developerAccountService.cashDetail(orderIdmain);
String remainMoney = String.valueOf(Integer.valueOf(accountResponse.jsonPath().getString("data.list[0].balance"))+Integer.valueOf(accountResponse.jsonPath().getString("data.list[0].moneyChange")));
logger.info("兑换前的开发者账户余额:" + remainMoney);
remainMoney =String.valueOf(Integer.valueOf(remainMoney) - 9600) ;
String remainMoneyNew = accountResponse.jsonPath().getString("data.list[0].balance");
logger.info("兑换后的开发者账户余额:" + remainMoneyNew);
Assert.assertEquals(remainMoneyNew,remainMoney,"校验开发者账户余额失败");
Assert.assertEquals(status,"success","校验订单状态失败");
logger.info("校验支付宝扣费订单成功");
}
@Test
public void Qb兑换审核不通过测试() throws Exception{
//查询兑换前的开发者账户余额
// Response accountResponse = developerAccountService.accountInfo();
// String remainMoney = accountResponse.jsonPath().getString("data.remainMoney");
// logger.info("兑换前的开发者账户余额:" + remainMoney);
//qb兑换
//int uid = 2709;
Response response = qbExchangeService.doTakePrize(authorization.dafuwengLogin(uid),"1234345554","100");
String orderId = (String)response.jsonPath().get("orderId");
//订单审核,判断是否在待审核节点
Map<String,Object> mapOrder = jdbc.findSimpleResult("SELECT * FROM "+Database.orders_consumer+"."+Database.orders8+" where id ="+orderId);
String flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
logger.info("数据库订单节点:" + flowWork);
String orderIdmain = String.valueOf(mapOrder.get("order_num"));
logger.info("兑吧订单号为:" + orderIdmain);
int i =10;
while (i > 0 && !flowWork.equals("Audit-started")) {
Thread.sleep(300);
mapOrder = jdbc.findSimpleResult("SELECT * FROM "+Database.orders_consumer+"."+Database.orders8+" where id ="+orderId);
flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
logger.info("数据库订单节点:" + flowWork);
i--;
}
//订单审核
Response auditResponse = dsOrderService.submitAudit(orderId,"reject","zhaoran@duiba.com.cn");
auditResponse.prettyPrint();
//判断订单是否审核失败
int j =10;
while (j > 0 && !flowWork.equals("Fail-complete")) {
Thread.sleep(1000);
auditResponse = dsOrderService.submitAudit(orderId,"reject","zhaoran@duiba.com.cn");
mapOrder = jdbc.findSimpleResult("SELECT * FROM "+Database.orders_consumer+"."+Database.orders8+" where id ="+orderId);
flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
logger.info("当前订单节点:" + flowWork);
j--;
}
String status = String.valueOf(mapOrder.get("status"));
//兑换后的开发者账户余额
// accountResponse = developerAccountService.accountInfo();
// String remainMoneyNew = accountResponse.jsonPath().getString("data.remainMoney");
// logger.info("兑换后的开发者账户余额:" + remainMoneyNew);
// Assert.assertEquals(remainMoneyNew,remainMoney,"校验开发者账户余额失败");
Assert.assertEquals(status,"fail","校验订单状态失败");
//校验开发者账户余额变动
Response accountResponse = developerAccountService.cashDetail(orderIdmain);
String remainMoney = String.valueOf(Integer.valueOf(accountResponse.jsonPath().getString("data.list[1].balance"))+Integer.valueOf(accountResponse.jsonPath().getString("data.list[1].moneyChange")));
logger.info("兑换前的开发者账户余额:" + remainMoney);
String remainMoneyNew = accountResponse.jsonPath().getString("data.list[0].balance");
logger.info("兑换后的开发者账户余额:" + remainMoneyNew);
Assert.assertEquals(remainMoneyNew,remainMoney,"校验开发者账户余额失败");
logger.info("校验支付宝审核订单失败返还金额成功");
}
/**
* @param caseNum 用例id
* @param appItemId 商品入库Id
* @param itemId 商品id
* @param caseName 用例名称打印
* @throws Exception
*/
@Test(dataProvider = "providerMethod")
public void 优惠券兑换审核通过测试(int caseNum, String appItemId, String itemId, String caseName) throws Exception{
// int uid = 3768;
logger.info(caseName);
//查询兑换前的开发者余额
// Response accountResponse = developerAccountService.accountInfo();
// String remainMoney = accountResponse.jsonPath().getString("data.remainMoney");
// logger.info("兑换前的开发者余额:" + remainMoney);
// String remainMoneyNew =String.valueOf(Integer.valueOf(remainMoney) - 1000) ;
//优惠券兑换
String orderId = this.优惠券兑换订单(appItemId,itemId,uid);
logger.info("订单号:" + orderId);
//订单审核,判断是否在待审核节点
Map<String,Object> mapOrder = jdbc.findSimpleResult("SELECT * FROM "+Database.orders_consumer+"."+Database.orders8+" WHERE id = " + orderId);
String flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
logger.info("数据库订单节点:" + flowWork);
String orderIdmain = String.valueOf(mapOrder.get("order_num"));
logger.info("兑吧订单号为:" + orderIdmain);
int i =10;
while (i > 0 && !flowWork.equals("Audit-started")) {
Thread.sleep(300);
mapOrder = jdbc.findSimpleResult("SELECT * FROM "+Database.orders_consumer+"."+Database.orders8+" WHERE id = " + orderId);
flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
logger.info("数据库订单节点:" + flowWork);
i--;
}
Response auditResponse = dsOrderService.submitAudit(orderId,"pass","zhaoran@duiba.com.cn");
auditResponse.prettyPrint();
//判断订单是否审核成功,如果订单没有成功则继续审核
int j =10;
while (j > 0 && !flowWork.equals("Success-complete")) {
Thread.sleep(1000);
auditResponse = dsOrderService.submitAudit(orderId,"pass","zhaoran@duiba.com.cn");
mapOrder = jdbc.findSimpleResult("SELECT * FROM "+Database.orders_consumer+"."+Database.orders8+" WHERE id = " + orderId);
flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
logger.info("数据库订单节点:" + flowWork);
j--;
}
String status = String.valueOf(mapOrder.get("status"));
switch (caseNum){
case 1:
//查询兑换后的开发者余额
// accountResponse = developerAccountService.accountInfo();
// remainMoney = accountResponse.jsonPath().getString("data.remainMoney");
// logger.info("兑换后的开发者余额:" + remainMoney);
Assert.assertEquals(status,"success","订单状态校验失败");
//校验开发者账户余额变动
Response accountResponse = developerAccountService.cashDetail(orderIdmain);
String remainMoney = String.valueOf(Integer.valueOf(accountResponse.jsonPath().getString("data.list[0].balance"))+Integer.valueOf(accountResponse.jsonPath().getString("data.list[0].moneyChange")));
logger.info("兑换前的开发者账户余额:" + remainMoney);
remainMoney =String.valueOf(Integer.valueOf(remainMoney) - 1000) ;
String remainMoneyNew = accountResponse.jsonPath().getString("data.list[0].balance");
logger.info("兑换后的开发者账户余额:" + remainMoneyNew);
Assert.assertEquals(remainMoneyNew,remainMoney,"校验开发者账户余额失败");
logger.info("校验兑吧优惠券审核通过扣费成功");
break;
case 2:
Assert.assertEquals(status,"success","订单状态校验失败");
logger.info("校验自有优惠券审核通过成功");
}
}
@Test
public void 支付宝兑换审核通过测试() throws Exception{
// int uid = 3771;
//查询兑换前的开发者账户余额
// Response accountResponse = developerAccountService.accountInfo();
// String remainMoney = accountResponse.jsonPath().getString("data.remainMoney");
// logger.info("兑换前的开发者账户余额:" + remainMoney);
// String remainMoneyNew =String.valueOf(Integer.valueOf(remainMoney) - 1020) ;
//支付宝兑换
String orderId = this.支付宝兑换订单(uid,"peeulk6392@sandbox.com","沙箱环境","10");
logger.info("订单号:" + orderId);
//订单审核,判断是否在待审核节点
Map<String,Object> mapOrder = jdbc.findSimpleResult("SELECT * FROM "+Database.orders_consumer+"."+Database.orders8+" WHERE id = " + orderId);
String flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
logger.info("数据库订单节点:" + flowWork);
String orderIdmain = String.valueOf(mapOrder.get("order_num"));
logger.info("兑吧订单号为:" + orderIdmain);
int i =10;
while (i > 0 && !flowWork.equals("Audit-started")) {
Thread.sleep(300);
mapOrder = jdbc.findSimpleResult("SELECT * FROM "+Database.orders_consumer+"."+Database.orders8+" WHERE id = " + orderId);
flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
logger.info("数据库订单节点:" + flowWork);
i--;
}
Response auditResponse = dsOrderService.submitAudit(orderId,"pass","zhaoran@duiba.com.cn");
auditResponse.prettyPrint();
//判断订单是否审核成功,如果订单没有成功则继续审核
int j =10;
while (j > 0 && !flowWork.equals("Success-complete")) {
Thread.sleep(1000);
auditResponse = dsOrderService.submitAudit(orderId,"pass","zhaoran@duiba.com.cn");
mapOrder = jdbc.findSimpleResult("SELECT * FROM "+Database.orders_consumer+"."+Database.orders8+" WHERE id = " + orderId);
flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
logger.info("数据库订单节点:" + flowWork);
j--;
}
String status = String.valueOf(mapOrder.get("status"));
//兑换后的开发者账户余额
// accountResponse = developerAccountService.accountInfo();
// remainMoney = accountResponse.jsonPath().getString("data.remainMoney");
// logger.info("兑换后的开发者账户余额:" + remainMoney);
//校验开发者账户余额变动
Response accountResponse = developerAccountService.cashDetail(orderIdmain);
String remainMoney = String.valueOf(Integer.valueOf(accountResponse.jsonPath().getString("data.list[0].balance"))+Integer.valueOf(accountResponse.jsonPath().getString("data.list[0].moneyChange")));
logger.info("兑换前的开发者账户余额:" + remainMoney);
remainMoney =String.valueOf(Integer.valueOf(remainMoney) - 1020) ;
String remainMoneyNew = accountResponse.jsonPath().getString("data.list[0].balance");
logger.info("兑换后的开发者账户余额:" + remainMoneyNew);
Assert.assertEquals(remainMoneyNew,remainMoney,"校验开发者账户余额失败");
Assert.assertEquals(status,"success","校验订单状态失败");
logger.info("校验支付宝扣费订单成功");
}
//支付宝兑换接口抽离
public String 支付宝兑换订单(int uid,String alipay,String realname,String degreeId) throws Exception {
Response response = alipayExchangeService.exchange(uid,alipay,realname,degreeId);
String orderId = response.jsonPath().getString("orderId");
//查看兑换结果
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid), orderId);
response.prettyPrint();
String status = response.jsonPath().getString("status");
//异步接口
int i = 10;
while (i > 0 && status.equals("processing")) {
Thread.sleep(1000);
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid), orderId);
response.prettyPrint();
status = response.jsonPath().getString("status");
i--;
}
return orderId;
}
public String 优惠券兑换订单(String appItemId,String itemId,int uid) throws Exception {
Response response = couponExchangeService.couponExchange(authorization.dafuwengLogin(uid),appItemId,itemId);
String orderId = response.jsonPath().getString("orderId");
//查看兑换结果
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid), orderId);
response.prettyPrint();
String status = response.jsonPath().getString("status");
//异步接口
int i = 10;
while (i > 0 && status.equals("processing")) {
Thread.sleep(1000);
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid), orderId);
response.prettyPrint();
status = response.jsonPath().getString("status");
i--;
}
return orderId;
}
}
package http.cases.ExchangeTest;
import base.DuibaTestBase;
import http.service.Authorization;
import http.service.Manager.ADeveloperService;
import http.service.app.AlipayExchangeService;
import http.service.app.MobileService;
import http.service.hd.DeveloperAccountService;
import http.service.hd.DsOrderService;
import utils.MatcherString;
import base.DuibaLog;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import static io.restassured.RestAssured.given;
/**
* Created by lvwenyan on 2018/08/24.
*/
public class 支付宝_兑换流程测试_ExchangeTest extends DuibaTestBase {
@Autowired
AlipayExchangeService alipayExchangeService;
@Autowired
MobileService mobileService;
@Autowired
Authorization authorization;
@Autowired
DsOrderService dsOrderService;
@Autowired
DeveloperAccountService developerAccountService;
@Autowired
ADeveloperService aDeveloperService;
private static int uid = 3771;
private DuibaLog logger = DuibaLog.getLogger();
// private MysqlUtils jdbc;
private String url = "http://activity.m.duibatest.com.cn";
// @BeforeClass
// public void before(){
//
// jdbc = MysqlUtils.mysqlDuiba("");
//
// }
//
// @AfterClass
// public void after(){
//
// jdbc.releaseConn();
// }
@DataProvider
public Object[][] providerMethod(Method method) {
Object[][] result = null;
if (method.getName().equals("支付宝用户兑换限制测试")) {
result = new Object[][]{
new Object[]{1, "peeulk6392@sandbox.com", "沙箱环境", "2", "支付宝用户永久兑换限制测试"}, //case1
new Object[]{2, "peeulk6392@sandbox.com", "沙箱环境", "3", "支付宝用户每日兑换限制测试"}, //case2
};
}
return result;
}
//@Test
public void 支付宝审核通过测试() throws Exception{
//查询兑换前的开发者账户余额
// Response accountResponse = developerAccountService.accountInfo();
// String remainMoney = accountResponse.jsonPath().getString("data.remainMoney");
// logger.info("兑换前的开发者账户余额:" + remainMoney);
// String remainMoneyNew =String.valueOf(Integer.valueOf(remainMoney) - 1020) ;
//支付宝兑换
String orderId = this.支付宝兑换订单(uid,"peeulk6392@sandbox.com","沙箱环境","10");
logger.info("订单号:" + orderId);
//订单审核,判断是否在待审核节点
Map<String,Object> mapOrder = jdbc.findSimpleResult("SELECT * FROM "+Database.orders_consumer+"."+Database.orders7+" WHERE id = " + orderId);
String flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
logger.info("数据库订单节点:" + flowWork);
String orderIdmain = String.valueOf(mapOrder.get("order_num"));
logger.info("兑吧订单号为:" + orderIdmain);
int i =10;
while (i > 0 && !flowWork.equals("Audit-started")) {
Thread.sleep(300);
mapOrder = jdbc.findSimpleResult("SELECT * FROM "+Database.orders_consumer+"."+Database.orders7+" WHERE id = " + orderId);
flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
logger.info("数据库订单节点:" + flowWork);
i--;
}
Response auditResponse = dsOrderService.submitAudit(orderId,"pass");
auditResponse.prettyPrint();
//判断订单是否审核成功,如果订单没有成功则继续审核
int j =10;
while (j > 0 && !flowWork.equals("Success-complete")) {
Thread.sleep(1000);
auditResponse = dsOrderService.submitAudit(orderId,"pass");
mapOrder = jdbc.findSimpleResult("SELECT * FROM "+Database.orders_consumer+"."+Database.orders7+" WHERE id = " + orderId);
flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
logger.info("数据库订单节点:" + flowWork);
j--;
}
String status = String.valueOf(mapOrder.get("status"));
//兑换后的开发者账户余额
// accountResponse = developerAccountService.accountInfo();
// remainMoney = accountResponse.jsonPath().getString("data.remainMoney");
// logger.info("兑换后的开发者账户余额:" + remainMoney);
//校验开发者账户余额变动
Response accountResponse = developerAccountService.cashDetail(orderIdmain);
String remainMoney = String.valueOf(Integer.valueOf(accountResponse.jsonPath().getString("data.list[0].balance"))+Integer.valueOf(accountResponse.jsonPath().getString("data.list[0].moneyChange")));
logger.info("兑换前的开发者账户余额:" + remainMoney);
remainMoney =String.valueOf(Integer.valueOf(remainMoney) - 1020) ;
String remainMoneyNew = accountResponse.jsonPath().getString("data.list[0].balance");
logger.info("兑换后的开发者账户余额:" + remainMoneyNew);
Assert.assertEquals(remainMoneyNew,remainMoney,"校验开发者账户余额失败");
Assert.assertEquals(status,"success","校验订单状态失败");
logger.info("校验支付宝扣费订单成功");
}
@Test
public void 支付宝积分不足测试() throws Exception{
//获取按钮状态
Response detailResponse = mobileService.detail(authorization.dafuwengLogin(3086,true),"55");
detailResponse.prettyPrint();
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
//支付宝兑换
Response response = alipayExchangeService.exchange(3086,"peeulk6392@sandbox.com","沙箱环境","10");
String orderId = response.jsonPath().getString("orderId");
logger.info("订单号:" + orderId);
//查看兑换结果
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(3086), orderId);
response.prettyPrint();
String status = response.jsonPath().getString("status");
//异步接口
int i = 10;
while (i > 0 && !status.equals("fail")) {
Thread.sleep(1000);
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(3086), orderId);
response.prettyPrint();
status = response.jsonPath().getString("status");
i--;
}
//订单状态
Map<String,Object> mapOrder = jdbc.findSimpleResult("SELECT * FROM "+Database.orders_consumer+"."+Database.orders3+" WHERE id = " + orderId);
String flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
logger.info("数据库订单节点:" + flowWork);
int j =10;
while (j > 0 && !flowWork.equals("Fail-complete")) {
Thread.sleep(300);
mapOrder = jdbc.findSimpleResult("SELECT * FROM "+Database.orders_consumer+"."+Database.orders3+" WHERE id = " + orderId);
flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
logger.info("数据库订单节点:" + flowWork);
j--;
}
String orderStatus = String.valueOf(mapOrder.get("status"));
Assert.assertEquals(exchangeText,"积分不足","校验马上兑换按钮状态失败");
Assert.assertEquals(response.jsonPath().getString("message"),"兑换失败,用户积分余额不足","校验message失败");
Assert.assertEquals(orderStatus,"fail","校验订单状态失败");
logger.info("校验支付宝商品积分不足场景成功");
}
@Test
public void 支付宝余额不足测试() throws Exception{
//开发者余额, 开发者账户:xuyan_8707@163.com
Response accountResponse = developerAccountService.accountInfoCommon("xuyan_8707@163.com");
String remainMoney = accountResponse.jsonPath().getString("data.remainMoney");
logger.info("兑换前的开发者账户余额:" + remainMoney);
//兑换按钮状态
Response detailResponse = mobileService.detail(authorization.dafuwengLogin(3490),"55");
detailResponse.prettyPrint();
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
//支付宝兑换
Map<String,String> map = new HashMap<>();
map.put("alipay","peeulk6392@sandbox.com");
map.put("realname","沙箱环境");
map.put("degreeId","10");
map.put("itemId","55");
map.put("token","fw7qga0");
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.dafuwengLogin(3490)).params(map).post(url+"/alipayExchange/exchange");
response.prettyPrint();
accountResponse = developerAccountService.accountInfoCommon("xuyan_8707@163.com");
String remainMoneyNew = accountResponse.jsonPath().getString("data.remainMoney");
logger.info("兑换后的开发者账户余额:" + remainMoneyNew);
Assert.assertEquals(exchangeText,"已兑完","校验马上兑换按钮状态失败");
Assert.assertEquals(response.jsonPath().getString("message"),"对不起,没有兑换成功,请挑选其他吧(2)","校验message失败");
Assert.assertEquals(remainMoneyNew,remainMoney,"校验开发者账户余额失败");
logger.info("校验支付宝商品余额不足成功");
}
@Test
public void 支付宝自定义档位扣积分测试() throws Exception{
//兑换前的积分
Map<String,Object> mapCredits = jdbc.findSimpleResult("SELECT * FROM dafuweng.`user` WHERE id = "+uid);
String credits = String.valueOf(mapCredits.get("credits"));
logger.info("兑换前的用户积分:" + credits);
credits = String.valueOf(Integer.valueOf(credits)-10);
this.支付宝兑换(uid,"peeulk6392@sandbox.com","沙箱环境","10");
//兑换后的积分
mapCredits = jdbc.findSimpleResult("SELECT * FROM dafuweng.`user` WHERE id = "+uid);
String creditsNew = String.valueOf(mapCredits.get("credits"));
logger.info("兑换后的用户积分:" + creditsNew);
Assert.assertEquals(creditsNew,credits,"校验支付宝扣积分失败");
logger.info("校验支付宝自定义档位扣积分成功");
}
@Test
public void 支付宝会员等级测试() throws Exception{
//开发者账号马博专用,appId=18740
Map<String,String> map = new HashMap<>();
map.put("alipay","peeulk6392@sandbox.com");
map.put("realname","沙箱环境");
map.put("degreeId","1");
map.put("itemId","55");
map.put("token","fw7qga0");
//会员符合条件,兑换
Response successResponse = this.支付宝兑换(3574,"peeulk6392@sandbox.com","沙箱环境","1");
//会员不符合条件,兑换,vip=5
Response failResponse = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.generateSignAutoLogin("3nG61oCgKyPNcHCyxwSmxsF6tNfj",3575)).params(map).post(url + "/alipayExchange/exchange");
failResponse.prettyPrint();
Assert.assertEquals(successResponse.jsonPath().getString("status"),"success","校验支付宝兑换状态失败");
Assert.assertEquals(failResponse.jsonPath().getString("message"),"会员等级不符,请挑选其他吧(15)","校验支付宝兑换状态失败");
logger.info("校验支付宝会员等级兑换成功");
}
/**
* @param caseNum 用例编号
* @param alipay 支付宝账号
* @param realName 支付宝姓名
* @param degreeId 档位
* @param caseName 用例名称打印
* @throws Exception
*/
@Test(dataProvider = "providerMethod")
public void 支付宝用户兑换限制测试(int caseNum, String alipay, String realName, String degreeId, String caseName) throws Exception{
Map<String,String> map = new HashMap<>();
map.put("alipay",alipay);
map.put("realname",realName);
map.put("degreeId",degreeId);
map.put("itemId","55");
map.put("token","fw7qga0");
try{
//支付宝兑换
Response response = this.支付宝兑换(uid,alipay,realName,degreeId);
Assert.assertEquals(response.jsonPath().getString("status"),"success","校验兑换失败");
logger.info("用户成功兑换一次");
//再次兑换
Thread.sleep(3000);
response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.dafuwengLogin(uid)).params(map).post(url + "/alipayExchange/exchange");
response.prettyPrint();
//获取按钮状态
Response detailResponse = mobileService.detail(authorization.dafuwengLogin(uid),"55");
// detailResponse.prettyPrint();
String btnText2 = MatcherString.getString(detailResponse.asString(), "\"2\":\\{\"btnText\":\"(.*?)\",", 1);
String btnText3 = MatcherString.getString(detailResponse.asString(), "\"3\":\\{\"btnText\":\"(.*?)\",", 1);
switch (caseNum){
case 1:
logger.info("再次兑换按钮:" + btnText2);
Assert.assertEquals(response.jsonPath().getString("message"),"已兑完","校验用户兑换限制失败");
Assert.assertEquals(btnText2,"已兑换","校验马上兑换按钮状态失败");
logger.info("校验支付宝用户永久兑换限制成功");
break;
case 2:
logger.info("再次兑换按钮:" + btnText3);
Assert.assertEquals(response.jsonPath().getString("message"),"已兑完","校验用户兑换限制失败");
Assert.assertEquals(btnText3,"今日已兑换","校验马上兑换按钮状态失败");
logger.info("校验支付宝用户每日兑换限制成功");
break;
}
}catch (Exception e){
throw new Exception("异常信息打印:" + e);
}finally {
jdbc.update("DELETE FROM credits_dev.consumer_limit_record_only WHERE item_id = '55'");
jdbc.update("DELETE FROM credits_dev.consumer_limit_record WHERE item_id = '55'");
}
}
//支付宝兑换接口抽离
public String 支付宝兑换订单(int uid,String alipay,String realname,String degreeId) throws Exception {
Response response = alipayExchangeService.exchange(uid,alipay,realname,degreeId);
String orderId = response.jsonPath().getString("orderId");
//查看兑换结果
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid), orderId);
response.prettyPrint();
String status = response.jsonPath().getString("status");
//异步接口
int i = 10;
while (i > 0 && status.equals("processing")) {
Thread.sleep(1000);
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid), orderId);
response.prettyPrint();
status = response.jsonPath().getString("status");
i--;
}
return orderId;
}
public Response 支付宝兑换(int uid,String alipay,String realname,String degreeId) throws Exception {
Response response = alipayExchangeService.exchange(uid,alipay,realname,degreeId);
String orderId = response.jsonPath().getString("orderId");
//查看兑换结果
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid), orderId);
response.prettyPrint();
String status = response.jsonPath().getString("status");
//异步接口
int i = 10;
while (i > 0 && status.equals("processing")) {
Thread.sleep(1000);
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid), orderId);
response.prettyPrint();
status = response.jsonPath().getString("status");
i--;
}
return response;
}
}
package http.cases.ExchangeTest;
import base.DuibaTestBase;
import http.service.Activity.ManagerService;
import http.service.Authorization;
import http.service.app.MobileService;
import http.service.app.VirtualExchangeService;
import base.DuibaLog;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.Test;
import java.util.Map;
/**
* Created by yeqinqin on 2018/6/11.
*/
public class 虚拟商品_兑换异常测试 extends DuibaTestBase {
@Autowired
private MobileService mobileService;
@Autowired
private Authorization authorization;
@Autowired
ManagerService managerService;
@Autowired
VirtualExchangeService virtualExchangeService;
private DuibaLog logger = DuibaLog.getLogger();
//指定用户
private static int uid = 0;
//实物兑换积分不足
@Test(description = "自有虚拟商品积分不足")
public void 积分不足() throws Exception {
//活动详情页
Response response = mobileService.appItemDetail(authorization.dafuwengLogin(uid), "181159");
Map<String, String> map = authorization.dafuwengLogin(uid,true);
Assert.assertEquals(String.valueOf(response.getStatusCode()), "200", "商品详情页面");
response.prettyPrint();
System.out.println(response.asString());
System.out.println("女汉子");
//自有虚拟商品兑换
response = virtualExchangeService.exchange(authorization.dafuwengLogin(uid), "181159", "123");
//获取orderId
String orderId = response.jsonPath().getString("orderId");
response = mobileService.orderAmbStatusQuery(uid,orderId);
response.prettyPrint();
String message = response.jsonPath().getString("data.message");
//异步接口,直到兑换成功
int i=10;
//异步接口,直到兑换成功
while(i>0&&"兑换正在处理中...".equals(message)){
Thread.sleep(1000);
response = mobileService.orderAmbStatusQuery(uid,orderId);
response.prettyPrint();
message = response.jsonPath().getString("data.message");
i--;
}
Assert.assertEquals(message.trim(),"兑换失败,用户积分余额不足","校验自有虚拟商品积分不足");
}
}
package http.cases.FloorTest;
import base.DuibaLog;
import base.DuibaTestBase;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import http.service.Authorization;
import http.service.Manager.FloorService;
import http.service.app.HomeService;
import http.service.hd.ActivityService;
import http.service.hd.DevFloorBannerService;
import http.service.hd.DevItemService;
import http.service.hd.DevSkinService;
import io.restassured.path.json.JsonPath;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import utils.MatcherString;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;
import static io.restassured.path.json.JsonPath.from;
/**
* Created by mabo on 2018/6/8
*/
public class ActiveGroup_FloorTest extends DuibaTestBase {
@Autowired
HomeService homeService;
@Autowired
FloorService floorService;
@Autowired
Authorization authorization;
@Autowired
DevSkinService devSkinService;
@Autowired
DevFloorBannerService devFloorBannerService;
@Autowired
DevItemService devItemService;
@Autowired
ActivityService activityService;
private DuibaLog logger = DuibaLog.getLogger();
private String skinId=null;
private String floorId=null;
@BeforeClass
public void beforeClass(){
try{
Map map = jdbc.findSimpleResult("select * from credits_dev.tb_credits_floor_skin where skin_name = ?","mabo楼层皮肤ActiveGroup");
skinId = String.valueOf(map.get("id"));
map = jdbc.findSimpleResult("select * from credits_dev.tb_credits_floor_code WHERE floor_name= ?","maboActiveGroup");
floorId = String.valueOf(map.get("id"));
Response response = devSkinService.saveSkin(authorization.hdLoginmabo(),"18740","198");
response = floorService.deleteSkin(authorization.ssoLogin(),skinId,"1");
response = floorService.deleteFloor(authorization.ssoLogin(),floorId);
}catch(Exception e){
}
}
@Test
public void A_创建活动楼层皮肤() throws Exception {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");//设置日期格式
logger.info(df.format(new Date()));
String type = "5";
String dataType = "2";
String name = "maboActiveGroup";
String skinWidth = "640";
String html = " <section class=\"subpage-item a-fadeinT\">\n" +
" <div class=\"plays-warp\">\n" +
" <div class=\"plays-title\"></div>\n" +
" <div class=\"plays\" id=\"plays\">\n" +
" {@each list as item, index}\n" +
" {@if index == 0}\n" +
" <a href=\"${item.link}\" class=\"play\" db-log=\"${item.stInfo}\" style=\"top:0rem\">\n" +
" {@/if}\n" +
" {@if index == 1}\n" +
" <a href=\"${item.link}\" class=\"play\" db-log=\"${item.stInfo}\" d style=\"top:0.35rem\">\n" +
" {@/if}\n" +
" {@if index == 2}\n" +
" <a href=\"${item.link}\" class=\"play\" db-log=\"${item.stInfo}\" style=\"top:1.625rem\">\n" +
" {@/if}\n" +
" {@if index == 3}\n" +
" <a href=\"${item.link}\" class=\"play\" db-log=\"${item.stInfo}\" style=\"top:1.975rem\">\n" +
" {@/if}\n" +
" <img src=\"${!!item.whitethumb?item.whitethumb:item.thumb}\" class=\"play-img\">\n" +
" <p class=\"play-title\">${item.title}</p>\n" +
" <div class=\"play-btn\">抽奖</div>\n" +
" </a>\n" +
" {@/each}\n" +
" <div class=\"retry\">加载更多</div>\n" +
" <!--<div class=\"loading\" style=\"display: block\">\n" +
" <div></div>\n" +
" </div>-->\n" +
" <div class=\"nomore\" display>没有更多了</div>\n" +
" </div>\n" +
" </div>\n" +
" </section>";
String css = ".plays-warp {\n" +
" position: relative;\n" +
" width: 3.2rem;\n" +
" margin-top: 0.05rem;\n" +
"}\n" +
".plays-warp .plays {\n" +
" width: 100%;\n" +
" height: 100%;\n" +
"}\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ZfIObpu9xPbZ94hLNTUADpUm0J3DD6sn5oaN4yQgYsbAh+HhFZ0k+K+rgnLBt6HY3REDtDRY1t6H07Wk5BcslSpYKblbe/DlVr34cJa78OpWWqiVKkkuQMQGnAfTnfMk1QDc46ZwmE7SXk4XaViJlJ5z8BgvW7f6nctoKEiupnXG2PJUI/FHptJhirooGYAdF9O9a3rNmRIt2AARyVDE+/Djdj2iiL3ygjTUDkwpKkq9SK5OKpSM+z24SikrpPq3n4fbkwb+3BUM2RbDJUdXNBxSz/p1i1JRcTBUXWv+kkHWW9teDUH14/+yMHv+ChjQ90Tq9B5x81EZPtOCrrQboSOf7XIkFf5gTeq7yH5HbFtP+ruFaQ3Yj71k3ZaHtuieFrMDzVQDqdXzHmpS0KqT+k99uECrftwMqNR+3C62lKCk+H9HEvZoCPqTV1skYO7h1uzv360vePfLXOds5DhjaC2PetnxqVuncqGyugqKugX2QwJDpZfLbJaHmmg4n7EK8IN0enfZlNo5iKygpmRoRq/Znlv7sNxmaq45RE5WhfBoiHQsg+XaLcPt8RmH84upK5R1dbNm6r1Kw1MLlNNgVXaVazm9aO//Hn7dm3+TqP/BzvlhJ7D8dyXAAAAAElFTkSuQmCC\");\n" +
" background-repeat: no-repeat;\n" +
" background-size: 100% 100%;\n" +
"}\n" +
".plays-warp .play {\n" +
" position: absolute;\n" +
" z-index: 1;\n" +
" width: 1.575rem;\n" +
" height: 1.575rem;\n" +
" background-color: #fff;\n" +
"}\n" +
".plays-warp .play .play-img {\n" +
" width: 1.475rem;\n" +
" height: 0.92rem;\n" +
" margin: 0.05rem 0.05rem 0 0.05rem;\n" +
"}\n" +
".plays-warp .play .play-title {\n" +
" width: 1.2rem;\n" +
" margin: 0.1rem auto 0;\n" +
" font-size: 0.12rem;\n" +
" text-align: center;\n" +
" padding: 0.01rem;\n" +
" text-overflow: ellipsis;\n" +
" white-space: nowrap;\n" +
" overflow: hidden;\n" +
"}\n" +
".plays-warp .play .play-btn {\n" +
" display: block;\n" +
" margin: 0.075rem auto 0;\n" +
" width: 0.42rem;\n" +
" height: 0.19rem;\n" +
" background-color: #ee2b0f;\n" +
" text-align: center;\n" +
" line-height: 0.2rem;\n" +
" color: #ffffff;\n" +
" font-size: 0.11rem;\n" +
" border-radius: 0.095rem;\n" +
"}\n" +
".plays-warp .play:nth-child(2n) {\n" +
" position: absolute;\n" +
" top: 0.35rem;\n" +
" width: 1.575rem;\n" +
" height: 1.575rem;\n" +
"}\n" +
".plays-warp .play:nth-child(2n+1) {\n" +
" position: absolute;\n" +
" width: 1.575rem;\n" +
" height: 1.575rem;\n" +
" left: 1.625rem;\n" +
"}\n" +
".plays-warp .play:nth-child(5)::after {\n" +
" position: absolute;\n" +
" z-index: 1;\n" +
" content: '';\n" +
" display: inline-block;\n" +
" width: 0.235rem;\n" +
" height: 0.26rem;\n" +
" right: 0.1rem;\n" +
" top: 0.1rem;\n" +
" background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAC8AAAA0CAMAAAAt6JHGAAAABGdBTUEAALGPC/xhBQAAAhlQTFRF/0ND/0JC/0ND/0RE/0JC/0ND/0RE/2Bg/0ND/0ND/0RE/0VF/0RE/0ND/0JC/0JC/0ZG/0JC/0JC/0ND/0JC/0ND/0ND/0lJ/0ND/0JC/0JC/0RE/0ND/0ND/0RE/0JC/0RE/0VF/0JC/0RE/0ND/0ZG/0ZG/0ND/0ND/0ND/0hI/0JC/////0JC/0JC/0ND/0JC/0JC/0ND/0ND/0ND/0lJ/0ND/0ND/0ND/0ND/0ND/0RE/0ND/0ND/0ND/0ND/0RE/0RE/0ND/0ND/0RE/0VF/0JC/1BQ/05O/0RE/0JC/0ND/0JC/0JC/0RE/0RE/0RE/0VF/0pK/0ND/0JC/0RE/0ND/0ND/0RE/0JC/0ND/0VF/0VF/0ND/0ZG/0ND/0ND/0ND/1VV/0RE/0JC/0ND/0RE/0ZG/0ND/0ND/0ND/0ZG/0ND/0ND/2Zm/0RE/0lJ/0ZG/0RE/0ND/0ND/0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828ElnrVx0XAVo3fC7ZZ59vmAFvU/G0H1mrmUwS2Rr/+CUBSRyulLAYWujTjjyr5Oanz1l3KeyfN56eQSN4pf/ig4hP1+eDfJtZqwXrS+Hye/047+dzuPLWjwO32iJXftGFF7hJTII3z3e4U3laq+7dPNvt7RX3e75D09wP1vECOP5iq/915UpvXEjwv0nskis/jsPP3Y3w/gPDz+mk8XgiNx4A3Js/oj/B4FqPqWh8Ft0fofGwfj8Yf1sDAY+hJtZFuM2fD0AMV185F6rKbdzQ3gIj7Q3/NmbMhbCupHIm4XxjcT2rPm4vqk48NHHUaXHH+AWsCTuVQ6BInAAAAAElFTkSuQmCC\");\n" +
" background-repeat: no-repeat;\n" +
" background-size: 100% 100%;\n" +
"}\n" +
".plays-warp .play:nth-child(6)::after {\n" +
" position: absolute;\n" +
" content: '';\n" +
" display: inline-block;\n" +
" width: 0.26rem;\n" +
" height: 0.28rem;\n" +
" right: 0.1rem;\n" +
" top: 0.1rem;\n" +
" background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADQAAAA4CAMAAACFZCuiAAAABGdBTUEAALGPC/xhBQAAAYxQTFRFz2D/zlL/z1j/zVH/zlP/zFL/zlL/zFD/zVP/zFH/zlH/zVH/zFH/zFD/zFH/zVH/zFD/zlH/zVP/zFH/zFH/zFD/z1P/zFH/zVH/zFH/zVD/0VX/zlP/zVT/zVH/zVD/zFD/0lr/zFH/zlH/zVP/zVD/z1L/zVD/zFD/0VX/zFH/zFD/zGb/zFH/zFH/zFL/zVD/zFD/zlL/zFH/z1L/zFL/zFP/zVD/zlL/zFH/zVH/zVD/zVH/zlH/zFL/zVH/zVH/0VH/zFH/zVD/zVH//4D/zlX/0VH/zVH/zFH/////zVH/zVD/zFH/zFH/zVL/zFH/zVH/zFX/0FX/1VX//1X/1VX/0V3/zVD/zlL/zVL/zVH/zVD/zVH/zFH/zVH/zFH/z1H/zFH/0FH/01n/zVH/zVH/0FD/zFH/0FP/zFH/zFD/zFH/zFD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VcpR37cvK4ufB0THSN+SKb3cRaqD+9ULIb1Wk4C3Ij+MqUrA1pu8uoT+BbvxDyUHlVFU5Tj1AAAAAElFTkSuQmCC\");\n" +
" background-repeat: no-repeat;\n" +
" background-size: 100% 100%;\n" +
"}\n" +
".plays-warp .retry,\n" +
".plays-warp .loading,\n" +
".plays-warp .nomore {\n" +
" position: absolute;\n" +
" z-index: 0;\n" +
" display: none;\n" +
" width: 1.575rem;\n" +
" height: 0.3rem;\n" +
" bottom: 0.05rem;\n" +
" right: 0;\n" +
" color: #888888;\n" +
" font-size: 0.12rem;\n" +
" text-align: center;\n" +
" line-height: 0.3rem;\n" +
"}";
String js = " if(data && data.list && data.list.length > 1) {\n" +
"\t// 爱奇艺定制去掉游戏\n" +
"\tif (global.appId == 31819) {\n" +
"\t \tvar _list = [];\n" +
"\t\tdata.list.forEach(function(item, index) {\n" +
"\t\t if(item.activityType !== 28 && item.activityType !== 46 && item.activityType !== 47) {\n" +
"\t\t\t_list.push(item)\n" +
"\t\t }\n" +
"\t\t});\n" +
"\t \tdata.list = _list;\n" +
"\t}\n" +
"\t//初次显示的数据\n" +
" var showData = {};\n" +
" var isFirst = true;\n" +
" //点击更多显示的数据\n" +
" var dat = [];\n" +
" //数据索引\n" +
" var pageIndex = 4;\n" +
" //计算高度,top\n" +
" var playHeight = 315;\n" +
" var initHeight = [3.25, 3.6];\n" +
" showData.list = data.list.splice(0,4);\n" +
" if (showData.list.length == 3 ) {\n" +
" showData.list.splice(2,1); \n" +
" }\n" +
" dat = showData.list;\n" +
" // yangzuo.extend(data, global);\n" +
"\t console.log(showData);\n" +
" $(\"#renderRoot\").append(juicer(html, showData));\n" +
" // 显示是否还有\n" +
" var $retry = $('.retry');\n" +
" var $nomore = $('.nomore');\n" +
" var $plays = $('#plays');\n" +
"\t var $retry = $('.retry');\n" +
" var showDataLen = data.list.length;\n" +
" var totalLen = data.list.length;\n" +
" //容器高度\n" +
" function warpPlayHeight() {\n" +
" totalLen = 4 * (pageIndex / 4 - 1) + dat.length; \n" +
" if (totalLen < 3) {\n" +
" $plays.height('1.925rem'); \n" +
" } else if (totalLen < 5) {\n" +
" $plays.height('3.55rem'); \n" +
" } else {\n" +
" if (dat.length == 0){\n" +
" $plays.height((totalLen/4-1) * 3.25 + 3.55 - 1.625+\"rem\");\n" +
" } else {\n" +
" $plays.height((totalLen /4-1) * 3.25 + 3.55+ \"rem\"); \n" +
" }\n" +
" if (dat.length < 4 && data.list.length < 4) {\n" +
" $retry.hide();\n" +
" $nomore.show();\n" +
" console.log('没有更多了');\n" +
" return false;\n" +
" }\n" +
" }\n" +
" }\n" +
" warpPlayHeight();\n" +
" // 显示更多 或者 没有更多\n" +
" function hasMore() {\n" +
" console.log(data.list.length);\n" +
" if (isFirst){\n" +
" console.log(showData.list, isFirst);\n" +
" if (showData.list.length < 4){\n" +
" $retry.hide();\n" +
" $nomore.show();\n" +
" isFirst = false;\n" +
" return false;\n" +
" } else {\n" +
" $nomore.hide();\n" +
" $retry.show();\n" +
" isFirst = false;\n" +
" return false;\n" +
" }\n" +
" }\n" +
" if (dat.length < 4 || data.list.length == 1 || data.list.length == 0){\n" +
" $retry.hide();\n" +
" $nomore.show();\n" +
" } else {\n" +
" $nomore.hide();\n" +
" $retry.show();\n" +
" }\n" +
" }\n" +
" hasMore();\n" +
" function getMore() {\n" +
" dat = data.list.splice(0, 4);\n" +
" pageIndex += 4; \n" +
" if (dat.length == 3){\n" +
" dat.length = 2;\n" +
" dat.splice(2,1);\n" +
" } \n" +
" if (dat.length == 1) {\n" +
" dat.length = 0;\n" +
" dat.splice(0, 1);\n" +
" return false;\n" +
" }\n" +
" warpPlayHeight();\n" +
" for(var i = 0; i < dat.length; i++) {\n" +
"\t\t\t \t\t var _img = dat[i].whitethumb ? dat[i].whitethumb : dat[i].thumb;\n" +
" $newPlay = $(\"<a href='\" + dat[i].link + \"' class='play' db-log='\" + dat[i].stInfo + \"' db-buttonType='20025'>\" +\n" +
" \"<img src='\" + _img + \"' class='play-img'>\" +\n" +
" \"<p class='play-title'>\" + dat[i].title + \"</p>\" +\n" +
" \"<div class='play-btn'>抽奖</div>\" +\n" +
" \"</a>\");\n" +
" $retry.before($newPlay);\n" +
" var itemNum = i % 2;\n" +
" if(i < 2){\n" +
" var playTop = initHeight[itemNum];\n" +
" } else {\n" +
" var playTop = initHeight[itemNum] + 1.625;\n" +
" }\n" +
" $newPlay.css('top', playTop+'rem');\n" +
"\t\t\t window.DB && window.DB.statistics && window.DB.statistics.initLog();\n" +
" }\n" +
" hasMore();\n" +
" initHeight[0] = initHeight[0] +3.25;\n" +
" initHeight[1] = initHeight[1] + 3.25;\n" +
" }\n" +
" $('.retry').on('click', function(){\n" +
" getMore();\n" +
" });\n" +
"\tvar show = false;\n" +
" function isShow() {\n" +
" var st = $('.retry').offset().top;\n" +
" var wt = $('body').scrollTop();\n" +
" var wh = $(window).height();\n" +
" show = wt > (st - wh - 20) ? true : false;\n" +
" };\n" +
" $(document).scroll(function(){\n" +
" isShow();\n" +
" if (show && $('.retry').width() > 0){\n" +
" getMore();\n" +
" show = false;\n" +
" } \n" +
" });\n" +
" }";
//新建banner楼层
Response response = floorService.createFloor(authorization.ssoLogin(),type,dataType,name,html,css,js,skinWidth);
response.prettyPrint();
Map<String,Object> map = jdbc.findSimpleResult("select * from credits_dev.tb_credits_floor_code where floor_name=?",name);
floorId = String.valueOf(map.get("id"));
String nameSkin = "mabo楼层皮肤ActiveGroup";
String image = "//yun.dui88.com/images/201805/nlkmslg0t0.png";
// 验证码
String stoke="1";
// String floors = "[{\"id\":190,\"name\":\"maboTest\",\"type\":1,\"dataType\":0,\"needSyn\":false,\"syn\":false}]";
String ower = "0";
JSONObject json = new JSONObject();
json.put("id",map.get("id"));
json.put("name",name);
json.put("type","5");
json.put("dataType",map.get("data_type"));
json.put("needSyn",false);
json.put("syn",false);
JSONArray jsonArray = new JSONArray();
jsonArray.add(json);
String floors = jsonArray.toJSONString();
//新建皮肤
response = floorService.insertSkin(authorization.ssoLogin(),nameSkin,image,stoke,floors,ower,skinWidth);
response.prettyPrint();
map = jdbc.findSimpleResult("select * from credits_dev.tb_credits_floor_skin where skin_name = ?",nameSkin);
skinId = String.valueOf(map.get("id"));
response = floorService.switchOpenState(authorization.ssoLogin(),skinId,"true");
response.prettyPrint();
}
@Test
public void B_手机端活动() throws Exception {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");//设置日期格式
logger.info(df.format(new Date()));
Response response = devSkinService.saveSkin(authorization.hdLoginmabo(),"18740",skinId);
Thread.sleep(60000);
JsonPath jsonCfg = homeService.getCFG(2753);
Assert.assertEquals(jsonCfg.getList("").size(),1,"banner展示数量和配置不符");
String floorId = MatcherString.getString(jsonCfg.getList("").get(0).toString(),"floorId=(.*?),",1);
String dataType = MatcherString.getString(jsonCfg.getList("").get(0).toString(),"dataType=(.*?),",1);
String floorType = MatcherString.getString(jsonCfg.getList("").get(0).toString(),"floorType=(.*?),",1);
response = homeService.floor(authorization.dafuwengLogin(2753),floorType,dataType,"3",floorId);
String s = response.asString();
JsonPath jsonPath=from(s.substring(s.indexOf("{"),s.length()-1));
List<Map> list = jsonPath.getList("list",Map.class);
// response = devItemService.appItems(authorization.hdLoginmabo(),"18740");
response = activityService.list2(authorization.hdLoginmabo(),"18740");
response.prettyPrint();
List<Map> maplist = response.jsonPath().getList("data.list",Map.class);
int size = maplist.size();
for(int i=0;i<maplist.size();i++){
if(maplist.get(i).get("status").toString().equals("1")){
size--;
}
}
JSONObject jsonObject = JSONObject.parseObject(response.asString());
String data = jsonObject.getString("data");
List listDev = JSONObject.parseObject(data).getJSONArray("list");
Assert.assertEquals(list.size(),size,"活动数量不正确");
}
@Test
public void C_删除活动楼层皮肤() throws Exception {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");//设置日期格式
logger.info(df.format(new Date()));
Response response = devSkinService.saveSkin(authorization.hdLoginmabo(),"18740","198");
try{
Assert.assertEquals(response.jsonPath().getString("success"),"true");
}catch(Exception e){
throw new Exception("/devSkin/saveSkin接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/devSkin/saveSkin接口失败,返回信息:"+response.asString());
}
response = floorService.deleteSkin(authorization.ssoLogin(),skinId,"1");
response = floorService.deleteFloor(authorization.ssoLogin(),floorId);
}
}
package http.cases.FloorTest;
import base.DuibaLog;
import base.DuibaTestBase;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import http.service.Authorization;
import http.service.Manager.FloorService;
import http.service.app.HomeService;
import http.service.hd.DevFloorBannerService;
import http.service.hd.DevSkinService;
import io.restassured.path.json.JsonPath;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import utils.MatcherString;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;
import static io.restassured.path.json.JsonPath.from;
public class Banner_FloorTest extends DuibaTestBase {
@Autowired
HomeService homeService;
@Autowired
FloorService floorService;
@Autowired
Authorization authorization;
@Autowired
DevSkinService devSkinService;
@Autowired
DevFloorBannerService devFloorBannerService;
private String skinId=null;
private String floorId=null;
private DuibaLog logger = DuibaLog.getLogger();
@BeforeClass
public void beforeClass(){
try{
List<Map> list = devFloorBannerService.selectedList(authorization.hdLoginmabo(),"18740");
for(int i=0;i<list.size();i++){
Map map = list.get(i);
String bannerId = String.valueOf(map.get("bannerId"));
devFloorBannerService.delBanner(authorization.hdLoginmabo(),"18740",bannerId);
}
Map map = jdbc.findSimpleResult("select * from credits_dev.tb_credits_floor_skin where skin_name = ?","mabo楼层皮肤banner");
skinId = String.valueOf(map.get("id"));
map = jdbc.findSimpleResult("select * from credits_dev.tb_credits_floor_code WHERE floor_name= ?","maboTest楼层banner");
floorId = String.valueOf(map.get("id"));
Response response = devSkinService.saveSkin(authorization.hdLoginmabo(),"18740","198");
response = floorService.deleteSkin(authorization.ssoLogin(),skinId,"1");
response = floorService.deleteFloor(authorization.ssoLogin(),floorId);
}catch(Exception e){
}
}
@Test
public void A_创建banner楼层皮肤() throws Exception {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");//设置日期格式
logger.info(df.format(new Date()));
String type = "1";
String dataType = "0";
String name = "maboTest楼层banner";
String skinWidth = "640";
String html = "<section class=\"floor-banner a-fadeinT\">\n" +
" <div class=\"J_bannerSwiper swiper-container\">\n" +
" <div id=\"J_bannerList\" class=\"swiper-wrapper\">\n" +
" {@each list as item}\n" +
" \t<div class=\"swiper-slide\">\n" +
" <a href=\"${item.link}\" target=\"_top\">\n" +
" <img alt=\"${item.title}\" data-src=\"${item.image}\" class=\"swiper-lazy\"/>\n" +
" <div class=\"swiper-lazy-preloader swiper-lazy-preloader-white\"></div>\n" +
" </a>\n" +
" \t</div>\n" +
" {@/each}\n" +
" </div>\n" +
" <div class=\"swiper-pagination\"></div>\n" +
" </div>\n" +
"</section>";
String css = ".floor-banner {\n" +
" width: 3.2rem;\n" +
" height: 1.4rem;\n" +
" overflow: hidden;\n" +
"}\n" +
".swiper-container {\n" +
" height: 100%;\n" +
"}\n" +
".swiper-container-horizontal > .swiper-pagination {\n" +
" bottom: 0.05rem;\n" +
"}";
String js = "if (data && data.list && data.list.length) {\n" +
"\t$(\"#renderRoot\").append(juicer(html, data));\n" +
"\tnew Swiper('.J_bannerSwiper', {\n" +
"\t\tloop: true,\n" +
"\t\tautoplay: 3000,\n" +
"\t\tautoplayDisableOnInteraction: false,\n" +
"\t\tpagination: '.J_bannerSwiper .swiper-pagination',\n" +
"\t\tpaginationClickable: true,\n" +
"\t\tpreloadImages: false,\n" +
"\t\tlazyLoading: true\n" +
"\t});\n" +
"}";
//新建banner楼层
Response response = floorService.createFloor(authorization.ssoLogin(),type,dataType,name,html,css,js,skinWidth);
Map<String,Object> map = jdbc.findSimpleResult("select * from credits_dev.tb_credits_floor_code where floor_name=?",name);
floorId = String.valueOf(map.get("id"));
String nameSkin = "mabo楼层皮肤banner";
String image = "//yun.dui88.com/images/201805/nlkmslg0t0.png";
String stoke="1";
// String floors = "[{\"id\":190,\"name\":\"maboTest\",\"type\":1,\"dataType\":0,\"needSyn\":false,\"syn\":false}]";
String ower = "0";
JSONObject json = new JSONObject();
json.put("id",map.get("id"));
json.put("name",name);
json.put("type",map.get("floor_type"));
json.put("dataType",map.get("data_type"));
json.put("needSyn",false);
json.put("syn",false);
JSONArray jsonArray = new JSONArray();
jsonArray.add(json);
String floors = jsonArray.toJSONString();
//新建皮肤
response = floorService.insertSkin(authorization.ssoLogin(),nameSkin,image,stoke,floors,ower,skinWidth);
map = jdbc.findSimpleResult("select * from credits_dev.tb_credits_floor_skin where skin_name = ?",nameSkin);
skinId = String.valueOf(map.get("id"));
response = floorService.switchOpenState(authorization.ssoLogin(),skinId,"true");
}
@Test
public void B_banner楼层活动校验() throws Exception {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");//设置日期格式
logger.info(df.format(new Date()));
Response response = devSkinService.saveSkin(authorization.hdLoginmabo(),"18740",skinId);
response = devFloorBannerService.activityList(authorization.hdLoginmabo(),"18740","");
response.prettyPrint();
JSONObject json = new JSONObject();
json.putAll(getByName(response.jsonPath().getList("data"),"【自动化】出奖虚拟商品"));
json.put("appId", 18740);
json.put("new", false);
json.put("selected", false);
json.put("show", true);
devFloorBannerService.saveActivityBanner(authorization.hdLoginmabo(),json.toJSONString()).prettyPrint();
Thread.sleep(60000);
JsonPath jsonCfg = homeService.getCFG(2753);
Assert.assertEquals(jsonCfg.getList("").size(),1,"banner展示数量和配置不符");
String floorId = MatcherString.getString(jsonCfg.getList("").get(0).toString(),"floorId=(.*?),",1);
String dataType = MatcherString.getString(jsonCfg.getList("").get(0).toString(),"dataType=(.*?),",1);
String floorType = MatcherString.getString(jsonCfg.getList("").get(0).toString(),"floorType=(.*?),",1);
response = homeService.floor(authorization.dafuwengLogin(2753),floorType,dataType,"3",floorId);
String s = response.asString();
JsonPath jsonPath=from(s.substring(s.indexOf("{"),s.length()-1));
List<Map> list = jsonPath.getList("list",Map.class);
Map map = getByName(list,"【自动化】出奖虚拟商品");
Assert.assertNotNull(map,"banner里没有该商品");
String title = (String)map.get("title");
String activityId = String.valueOf(map.get("activityId"));
String link = (String)map.get("link");
String image = (String)map.get("image");
String sourceType = String.valueOf(map.get("sourceType"));
Assert.assertEquals(image,"//yun.duiba.com.cn/h5/activity/drawLot/drawLot/assets/640-280.png","");
// Assert.assertEquals(link,"//activity.m.duibatest.com.cn/newtools/index?id=21344&dbnewopen&dpm=18740.5.231.3&dcm=202.21344.0.0","");
Assert.assertEquals(title,"【自动化】出奖虚拟商品","");
Assert.assertEquals(sourceType,"13","");
Assert.assertEquals(activityId,"21344","");
}
@Test
public void C_banner商品校验() throws Exception {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");//设置日期格式
logger.info(df.format(new Date()));
Response response = devFloorBannerService.itemList(authorization.hdLoginmabo(),"18740","");
response.prettyPrint();
JSONObject json = new JSONObject();
json.putAll(getByName(response.jsonPath().getList("data"),"mabo自动化实物"));
json.put("appId", 18740);
json.put("new", false);
json.put("selected", false);
json.put("show", true);
devFloorBannerService.saveItemBanner(authorization.hdLoginmabo(),json.toJSONString()).prettyPrint();
Thread.sleep(62000);
JsonPath jsonCfg = homeService.getCFG(2753);
Assert.assertEquals(jsonCfg.getList("").size(),1,"banner展示数量和配置不符");
String floorId = MatcherString.getString(jsonCfg.getList("").get(0).toString(),"floorId=(.*?),",1);
String dataType = MatcherString.getString(jsonCfg.getList("").get(0).toString(),"dataType=(.*?),",1);
String floorType = MatcherString.getString(jsonCfg.getList("").get(0).toString(),"floorType=(.*?),",1);
response = homeService.floor(authorization.dafuwengLogin(2753),floorType,dataType,"3",floorId);
response.prettyPrint();
String s = response.asString();
JsonPath jsonPath=from(s.substring(s.indexOf("{"),s.length()-1));
List<Map> list = jsonPath.getList("list",Map.class);
Map map = getByName(list,"mabo自动化实物");
Assert.assertNotNull(map,"banner里没有该商品");
String title = (String)map.get("title");
String appItemId = String.valueOf(map.get("appItemId"));
String link = (String)map.get("link");
String image = (String)map.get("image");
String sourceType = String.valueOf(map.get("sourceType"));
Assert.assertEquals(image,"//yun.dui88.com/images/201805/7mwt22vdfu.jpg","");
// Assert.assertEquals(link,"//goods.m.duibatest.com.cn/mobile/appItemDetail?appItemId=163948&dbnewopen&dpm=18740.5.231.2&dcm=102.163948.0.0","");
Assert.assertEquals(title,"mabo自动化实物","");
Assert.assertEquals(sourceType,"0","");
Assert.assertEquals(appItemId,"163948","");
}
@Test
public void D_banner自定义外链接() throws Exception {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");//设置日期格式
logger.info(df.format(new Date()));
String appId = "18740";
String bannerImgNew = "";
String img = "//yun.dui88.com/images/201805/hdgasav66e.jpg";
String title = "banner上传自动化测试";
String url = "http://www.baidu.com";
JSONObject json = new JSONObject();
json.put("appId",appId);
json.put("bannerImgNew",bannerImgNew);
json.put("img",img);
json.put("title",title);
json.put("url",url);
devFloorBannerService.uploadBanner(authorization.hdLoginmabo(),json.toJSONString()).prettyPrint();
Thread.sleep(60000);
JsonPath jsonCfg = homeService.getCFG(2753);
Assert.assertEquals(jsonCfg.getList("").size(),1,"banner展示数量和配置不符");
String floorId = MatcherString.getString(jsonCfg.getList("").get(0).toString(),"floorId=(.*?),",1);
String dataType = MatcherString.getString(jsonCfg.getList("").get(0).toString(),"dataType=(.*?),",1);
String floorType = MatcherString.getString(jsonCfg.getList("").get(0).toString(),"floorType=(.*?),",1);
Response response = homeService.floor(authorization.dafuwengLogin(2753),floorType,dataType,"3",floorId);
String s = response.asString();
JsonPath jsonPath=from(s.substring(s.indexOf("{"),s.length()-1));
List<Map> list = jsonPath.getList("list",Map.class);
Map map = getByName(list,"banner上传自动化测试");
Assert.assertNotNull(map,"banner里没有该商品");
title = (String)map.get("title");
String sourceType = String.valueOf(map.get("sourceType"));
String link = (String)map.get("link");
String image = (String)map.get("image");
Assert.assertEquals(image,"//yun.dui88.com/images/201805/hdgasav66e.jpg","");
// Assert.assertEquals(link,"//home.m.duibatest.com.cn/log/redirect?url=http%3A%2F%2Fwww.baidu.com%3Fdbtodeveloper%26uid%3D2753%26dbnewopen&dpm=18740.5.231.1&dcm=","");
Assert.assertEquals(title,"banner上传自动化测试","");
Assert.assertEquals(sourceType,"2","");
}
// @Test
public void banner重新上传图片(){
}
// @Test
public void banner删除第一个(){
}
// @Test
public void banner展示(){
}
@Test
public void E_删除banner皮肤和楼层() throws Exception {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");//设置日期格式
logger.info(df.format(new Date()));
List<Map> list = devFloorBannerService.selectedList(authorization.hdLoginmabo(),"18740");
for(int i=0;i<list.size();i++){
Map map = list.get(i);
String bannerId = String.valueOf(map.get("bannerId"));
devFloorBannerService.delBanner(authorization.hdLoginmabo(),"18740",bannerId);
}
Response response = devSkinService.saveSkin(authorization.hdLoginmabo(),"18740","198");
response.prettyPrint();
response = floorService.deleteSkin(authorization.ssoLogin(),skinId,"1");
response.prettyPrint();
response = floorService.deleteFloor(authorization.ssoLogin(),floorId);
response.prettyPrint();
}
public Map getByName (List<Map> list,String name){
// String s = response.toString();
// JsonPath jsonPath=from(s.substring(s.indexOf("{"),s.length()-1));
// List<Map> list = jsonPath.getList("list",Map.class);
for (Map map:list
) {
if(map.get("title").equals(name))return map;
}
return null;
}
//@Test
public void test1(){
Response response = homeService.index(2753);
String html = response.asString();
// System.out.println(html);
String find = "var CfG={(.*?)";
System.out.println(MatcherString.getString(html,find,1));
}
}
package http.cases.FloorTest;
import base.DuibaLog;
import base.DuibaTestBase;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import http.service.Authorization;
import http.service.Manager.FloorService;
import http.service.app.HomeService;
import http.service.hd.DevFloorBannerService;
import http.service.hd.DevFloorChildPageService;
import http.service.hd.DevSkinService;
import io.restassured.path.json.JsonPath;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import utils.MatcherString;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;
import static io.restassured.path.json.JsonPath.from;
/**
* Created by mabo on 2018/6/8
* 优惠券
*/
public class Coupon_FloorTest extends DuibaTestBase {
@Autowired
HomeService homeService;
@Autowired
FloorService floorService;
@Autowired
Authorization authorization;
@Autowired
DevSkinService devSkinService;
@Autowired
DevFloorBannerService devFloorBannerService;
@Autowired
DevFloorChildPageService devFloorChildPageService;
private String skinId=null;
private String floorId=null;
private DuibaLog logger = DuibaLog.getLogger();
@BeforeClass
public void beforeClass(){
try{
Map map = jdbc.findSimpleResult("select * from credits_dev.tb_credits_floor_skin where skin_name = ?","mabo楼层皮肤conpon");
skinId = String.valueOf(map.get("id"));
map = jdbc.findSimpleResult("select * from credits_dev.tb_credits_floor_code WHERE floor_name= ?","maboConpon");
floorId = String.valueOf(map.get("id"));
Response response = devSkinService.saveSkin(authorization.hdLoginmabo(),"18740","198");
response = floorService.deleteSkin(authorization.ssoLogin(),skinId,"1");
response = floorService.deleteFloor(authorization.ssoLogin(),floorId);
}catch(Exception e){
}
}
@Test
public void A_创建优惠券楼层皮肤() throws Exception {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");//设置日期格式
logger.info(df.format(new Date()));
String type = "6";
String dataType = "0";
String name = "maboConpon";
String skinWidth = "750";
String html = "<div class=\"floor-coupon a-fadeinT\">\n" +
" <div class=\"title\">\n" +
" <div class=\"name\"><i></i>优惠券</div>\n" +
" <a class=\"more\" href=\"${moreLink}\">更多<i></i></a>\n" +
" </div>\n" +
" <div class=\"item-con\">\n" +
" <div class=\"scroll\">\n" +
" <div class=\"scroll-x\" id =\"floor-coupon-scroll\">\n" +
" {@each list as item}\n" +
" <a class=\"item\" href=\"${item.link}\">\n" +
" <div class=\"fl-a\" db-log=\"${item.stInfo}\">\n" +
" <div class=\"img-warp\"> \n" +
" <img src=\"${item.iconImage}\">\n" +
" </div>\n" +
" <div class=\"info-warp\">\n" +
" <p class=\"des\">${item.interestDesc}</p>\n" +
" <p class=\"subtitle\">${item.subtitle}</p>\n" +
" </div> \n" +
" </div>\n" +
" </a> \n" +
" {@/each}\n" +
" <a href=\"${moreLink}\" class=\"more view-more\">\n" +
" <span>查看更多</span>\n" +
" </a>\n" +
" <div class=\"pd-space\"></div>\n" +
" </div> \n" +
" </div>\n" +
" </div>\n" +
"</div>";
String css = ".floor-coupon {\n" +
" padding: 0.125rem 0 0.1rem 0;\n" +
" margin-bottom: 0.05rem;\n" +
" background: #ffffff;\n" +
" display: block;\n" +
"}\n" +
".floor-coupon .title {\n" +
" position: relative;\n" +
" height: 0.15rem;\n" +
" line-height: 0.15rem;\n" +
" margin-bottom: 0.1rem;\n" +
" margin-left: 0.1rem;\n" +
" text-align: left;\n" +
"}\n" +
".floor-coupon .title .name {\n" +
" display: inline-block;\n" +
" font-size: 0.14rem;\n" +
" color: #444;\n" +
" line-height: 0.15rem;\n" +
" margin-right: 0.15rem;\n" +
"}\n" +
".floor-coupon .title .name i {\n" +
" display: inline-block;\n" +
" vertical-align: top;\n" +
" margin-right: 0.035rem;\n" +
" width: 0.15rem;\n" +
" height: 0.15rem;\n" +
" background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAeCAMAAAAM7l6QAAAAaVBMVEUAAAD/pQL/sBL/pQL/pQP/pAL/pgT/pQT/pgT/xTH/pQL/pAL/pQP/pAP/pAP/pQL/pQP/pgP/pAT/qQf/rQn/pQT/pQP/pAP/pQP/pQL/pgP/pgT/pAL/pQP/pgL/pQL/pQP/pQX/pAJMiN/XAAAAInRSTlMA+w7srvONhTkF2djGual3WlA7JhxHwKOYZmJI4cx+cVgzt7mU+wAAAQNJREFUKM+FU9m2wiAMTApl6Upr1bbu+f+PvIAVUK+HeYCQORkSSCCiGGTXtp0cCviG4khYN01tN64+yIkTE6N2ph4FIz6l7ImVfSJZ9CXbx6PBaveutqvQvOw9Hr6yKQ64xU+simzkK/a8n5dROdUvua+IevgXPSkXzJz0kd5wdPKM2wUFWNAHnE9gAQONgS79EuiRBpCoAz2vROscaI0SuhocFh8kjZFeYfHOuoO2AQ8bSNeH1o+rNe5PX9MG+m6958vtdjlbwwR6EzfM3b0otcxOfN3EX6kheQhBlKYWC/NgViQtLPMsmUfNfEnmQ/PtAKcfzZRpxUwjZ8YgP0SZEfwDHggf9l4buUIAAAAASUVORK5CYII=');\n" +
" background-size: 100% auto;\n" +
"}\n" +
".floor-coupon .title .more {\n" +
" position: absolute;\n" +
" font-size: 0.1rem;\n" +
" top: 0.01rem;\n" +
" right: 0.1rem;\n" +
" color: #888;\n" +
"}\n" +
".floor-coupon .title .more i {\n" +
" display: inline-block;\n" +
" margin-left: 0.02rem;\n" +
" width: 0.045rem;\n" +
" height: 0.075rem;\n" +
" background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAkAAAAOCAYAAAD9lDaoAAAAAXNSR0IArs4c6QAAAMJJREFUKBWFj0EKwjAQRZOQ7rMUQUGxnqMLN124zAWy6ZlSaG8hbnsPQUF3XqHB+KeQkrYYB4YZ8l9m/vC6ri+MsYOUsjTG3NEvQnjvV8hj3/dd27b7BYEHgQln1Bty8wvk9LNpmrVzrkObI19ZlhXx6gGCkARHKAVOoDnIOX8opXJBQhzwJiFKesPVTmvtJ5C1dgugg7ijKeBOqJ9x3RwAWFRV9aSJA5QCBugfQBB5ugYP8QoSQ9Alb4h0SRk8BDHUL2r8gjSPuiqVAAAAAElFTkSuQmCC') no-repeat;\n" +
" background-size: 100% auto!important;\n" +
"}\n" +
".floor-coupon .fl {\n" +
" float: left;\n" +
"}\n" +
".floor-coupon .fr {\n" +
" float: right;\n" +
"}\n" +
".floor-coupon .item-con {\n" +
" height: 0.6rem;\n" +
" overflow: hidden;\n" +
" *zoom: 1;\n" +
"}\n" +
".floor-coupon .item-con .item {\n" +
" float: left;\n" +
" position: relative;\n" +
" display: block;\n" +
" width: 1.85rem;\n" +
" height: 0.6rem;\n" +
" border-radius: 0.04rem;\n" +
" background: #06cfb0;\n" +
" overflow: hidden;\n" +
" margin-left: 0.1rem;\n" +
"}\n" +
".floor-coupon .item-con .item::before {\n" +
" position: absolute;\n" +
" top: 0;\n" +
" left: -0.035rem;\n" +
" display: block;\n" +
" width: 0.065rem;\n" +
" height: 100%;\n" +
" content: '';\n" +
" background: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAATBAMAAAC5GZqkAAAAGFBMVEUAAAD///////////////////////////8jfp1fAAAAB3RSTlMA19COPPlcVP4jQQAAADlJREFUCNdjIAhYjIJMQHRieXlhApArXl5eLsLAwFwOBMUMDEwguoiBgRVEl8L4MHmYeph+mHkEAQAVvxR725Dx8AAAAABJRU5ErkJggg==\") repeat-y;\n" +
" background-size: 0.065rem 0.095rem;\n" +
"}\n" +
".floor-coupon .item-con .item::after {\n" +
" position: absolute;\n" +
" top: 0;\n" +
" right: -0.04rem;\n" +
" display: block;\n" +
" width: 0.065rem;\n" +
" height: 100%;\n" +
" content: '';\n" +
" background: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAATBAMAAAC5GZqkAAAAGFBMVEUAAAD///////////////////////////8jfp1fAAAAB3RSTlMA19COPPlcVP4jQQAAADlJREFUCNdjIAhYjIJMQHRieXlhApArXl5eLsLAwFwOBMUMDEwguoiBgRVEl8L4MHmYeph+mHkEAQAVvxR725Dx8AAAAABJRU5ErkJggg==\") repeat-y;\n" +
" background-size: 0.065rem 0.095rem;\n" +
"}\n" +
".floor-coupon .item-con .item .fl-a {\n" +
" display: inline-block;\n" +
" height: 0.6rem;\n" +
" width: 100%;\n" +
"}\n" +
".floor-coupon .item-con .item .img-warp {\n" +
" position: relative;\n" +
" display: inline-block;\n" +
" width: 0.5rem;\n" +
" height: 0.5rem;\n" +
" margin: 0.05rem 0 0 0.075rem;\n" +
" border-radius: 0.02rem;\n" +
" background-color: #fff;\n" +
"}\n" +
".floor-coupon .item-con .item .img-warp img {\n" +
" position: absolute;\n" +
" top: 50%;\n" +
" -webkit-transform: translateY(-50%);\n" +
" transform: translateY(-50%);\n" +
" width: 0.5rem;\n" +
" height: auto;\n" +
"}\n" +
".floor-coupon .item-con .item .info-warp {\n" +
" position: absolute;\n" +
" display: inline-block;\n" +
" //height: 0.25rem;\n" +
" width: 1rem;\n" +
" color: #FFF;\n" +
" text-align: left;\n" +
" overflow: hidden;\n" +
" white-space: nowrap;\n" +
" text-overflow: ellipsis;\n" +
" left: 0.65rem;\n" +
" top: 50%;\n" +
" -webkit-transform: translateY(-50%);\n" +
" transform: translateY(-50%);\n" +
"}\n" +
".floor-coupon .item-con .item .info-warp .des {\n" +
" overflow: hidden;\n" +
" white-space: nowrap;\n" +
" text-overflow: ellipsis;\n" +
" display: inline-block;\n" +
" font-size: 0.12rem;\n" +
"}\n" +
".floor-coupon .item-con .item .info-warp .subtitle {\n" +
" overflow: hidden;\n" +
" white-space: nowrap;\n" +
" text-overflow: ellipsis;\n" +
" font-size: 0.1rem;\n" +
" padding-top: 0.03rem;\n" +
"}\n" +
".floor-coupon .item-con:before,\n" +
".floor-coupon .item-con:after {\n" +
" display: table;\n" +
" content: \"\";\n" +
"}\n" +
".floor-coupon .item-con:after {\n" +
" clear: both;\n" +
"}\n" +
".floor-coupon .view-more {\n" +
" float: left;\n" +
" font-size: 0.1rem;\n" +
" height: 0.59rem;\n" +
" padding: 0 0.2rem 0 0.1rem;\n" +
" background-color: rgba(216, 216, 216, 0.1);\n" +
" border: 1px solid rgba(151, 151, 151, 0.1);\n" +
" color: #444;\n" +
" margin-left: 0.1rem;\n" +
" cursor: pointer;\n" +
" display: table;\n" +
" position: relative;\n" +
"}\n" +
".floor-coupon .view-more::before {\n" +
" content: '';\n" +
" position: absolute;\n" +
" width: 0;\n" +
" height: 0;\n" +
" border: 0.045rem solid transparent;\n" +
" border-left-color: #444;\n" +
" right: 10px;\n" +
" top: 50%;\n" +
" margin-top: -0.045rem;\n" +
"}\n" +
".floor-coupon .view-more span {\n" +
" display: table-cell;\n" +
" vertical-align: middle;\n" +
" line-height: 1.5;\n" +
" width: 0.225rem;\n" +
"}\n" +
".floor-coupon .pd-space {\n" +
" height: 0.6rem;\n" +
" float: left;\n" +
" width: 0.1rem;\n" +
"}\n" +
".scroll {\n" +
" width: 100%;\n" +
" height: 1rem;\n" +
" overflow: auto;\n" +
" box-sizing: border-box;\n" +
" -webkit-overflow-scrolling: touch;\n" +
"}\n" +
".scroll .scroll-x {\n" +
" width: 300rem;\n" +
"}";
String js = "if ( data && data.list && data.list.length) {\n" +
" \tyangzuo.extend(data,global);\n" +
" $(\"#renderRoot\").append(juicer(html, data));\n" +
" var len = (data.list.length*390 + 20 + 158)/200;\n" +
" $(\"#floor-coupon-scroll\").css(\"width\",len+\"rem\");\n" +
"}";
//新建banner楼层
Response response = floorService.createFloor(authorization.ssoLogin(),type,dataType,name,html,css,js,skinWidth);
Map<String,Object> map = jdbc.findSimpleResult("select * from credits_dev.tb_credits_floor_code where floor_name=?",name);
floorId = String.valueOf(map.get("id"));
String nameSkin = "mabo楼层皮肤conpon";
String image = "//yun.dui88.com/images/201805/nlkmslg0t0.png";
// 验证码
String stoke="1";
// String floors = "[{\"id\":190,\"name\":\"maboTest\",\"type\":1,\"dataType\":0,\"needSyn\":false,\"syn\":false}]";
String ower = "0";
JSONObject json = new JSONObject();
json.put("id",map.get("id"));
json.put("name",name);
json.put("type","6");
json.put("dataType",map.get("data_type"));
json.put("needSyn",false);
json.put("syn",false);
JSONArray jsonArray = new JSONArray();
jsonArray.add(json);
String floors = jsonArray.toJSONString();
//新建皮肤
response = floorService.insertSkin(authorization.ssoLogin(),nameSkin,image,stoke,floors,ower,skinWidth);
map = jdbc.findSimpleResult("select * from credits_dev.tb_credits_floor_skin where skin_name = ?",nameSkin);
skinId = String.valueOf(map.get("id"));
response = floorService.switchOpenState(authorization.ssoLogin(),skinId,"true");
}
@Test
public void B_优惠券手机端() throws Exception {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");//设置日期格式
logger.info(df.format(new Date()));
Response response = devSkinService.saveSkin(authorization.hdLoginmabo(),"18740",skinId);
int showNum = 5;
JSONObject json = new JSONObject();
json.put("appId","18740");
json.put("floorId",floorId);
json.put("floorTitle","优惠券");
json.put("showNum",String.valueOf(showNum));
json.put("target","childPage");
response = devFloorChildPageService.couponPageConfig(authorization.hdLoginmabo(),json.toJSONString());
Thread.sleep(70000);
JsonPath jsonCfg = homeService.getCFG(2753);
Assert.assertEquals(jsonCfg.getList("").size(),1,"banner展示数量和配置不符");
String floorId = MatcherString.getString(jsonCfg.getList("").get(0).toString(),"floorId=(.*?),",1);
String dataType = MatcherString.getString(jsonCfg.getList("").get(0).toString(),"dataType=(.*?),",1);
String floorType = MatcherString.getString(jsonCfg.getList("").get(0).toString(),"floorType=(.*?),",1);
response = homeService.floor(authorization.dafuwengLogin(2753),floorType,dataType,"3",floorId);
String s = response.asString();
JsonPath jsonPath=from(s.substring(s.indexOf("{"),s.length()-1));
List<Map> list = jsonPath.getList("list",Map.class);
Assert.assertEquals(list.size(),showNum,"配置数量和展示数量不相符");
}
@Test
public void C_删除优惠券楼层皮肤() throws Exception {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");//设置日期格式
logger.info(df.format(new Date()));
Response response = devSkinService.saveSkin(authorization.hdLoginmabo(),"18740","198");
response.prettyPrint();
response = floorService.deleteSkin(authorization.ssoLogin(),skinId,"1");
response.prettyPrint();
response = floorService.deleteFloor(authorization.ssoLogin(),floorId);
response.prettyPrint();
}
}
package http.cases.FloorTest;
import base.DuibaLog;
import base.DuibaTestBase;
import http.service.Activity.NewtoolsService;
import http.service.Authorization;
import http.service.app.AerosolService;
import http.service.app.HomeService;
import http.service.hd.ActivityService;
import http.service.hd.DevFloorService;
import http.service.hd.PlatformCouponService;
import io.restassured.path.json.JsonPath;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
import org.testng.Assert;
import org.testng.annotations.Test;
import utils.MatcherString;
import java.util.List;
import java.util.Map;
import static io.restassured.path.json.JsonPath.from;
/**
* Created by hanzhanli on 2017/7/18.
*/
public class Floor_FloorTest extends DuibaTestBase {
private static DuibaLog logger=DuibaLog.getLogger();
@Value("${uid}")
int uid;
@Value("${appId}")
int appId;
@Autowired
Authorization authorization;
@Autowired
HomeService homeService;
@Autowired
DevFloorService devFloorService;
@Autowired
ActivityService activityService;
@Autowired
PlatformCouponService platformCouponService;
@Autowired
NewtoolsService newtoolsService;
@Autowired
AerosolService aerosolService;
// @Test
public void indexTest() throws Exception {
/* Map<String,String> cookies=authorization.dafuwengLogin();
logger.info(cookies);
Response response=given().cookies(cookies).get("http://home.m.duibatest.com.cn/chome/index?from=login&spm=2278.1.1.1");
logger.info(response.asString());*/
//authorization.hdLogin();
//JsonPath json=homeService.getCFG(2727);
//List<Map> list=json.getList("",Map.class);
//logger.info(list);
homeService.floor("2","0","3","3");
//logger.info(Base64.encodeBase64(DigestUtils.sha1Hex("123456duiba").getBytes()));
//logger.info(SecurityUtils.getMD5("OhvdP1tOTMmqJv7Go4xi/CuZkCo=971eec6e-19db-4c7b-beb9-5db32f41a42b"));
}
@Test(description = "楼层icon")
public void iconTest() throws Exception {
Response response=devFloorService.iconSelectedList(Integer.toString(appId));
//response.print();
// logger.info("hd:"+response.asString());
List<Map> configList= from(response.asString()).getList("data", Map.class);
//path:/floor/2/0,duibaPageId=3,floorId=3
response=homeService.floor("2","0","3","3");
//response.prettyPrint();
String s = new String(response.asByteArray(),"UTF-8");
// logger.info("floor:"+s);
//logger.info(s.substring(s.indexOf("{"),s.length()-1));
List<Map> iconList= from(s.substring(s.indexOf("{"),s.length()-1)).getList("list", Map.class);
//logger.info(s.substring(s.indexOf("{"),s.length()-1));
for(int i=0;i<iconList.size();i++){
Map configMap=configList.get(i);
Map iconMap=iconList.get(i);
String dcm=(String)iconMap.get("dcm");
String[] dcms=dcm.split(".");
Assert.assertEquals(dcm.split("\\.")[1],configMap.get("bannerId").toString(),"dcm与配置bannerId不一致,dcm:"+dcm+",配置bannerId:"+configMap.get("bannerId"));
String dpm=(String)iconMap.get("dpm");
Assert.assertEquals(dpm.split("\\.")[0],String.valueOf(appId),"dpm与预期不一致,dpm:"+dpm+",appId:"+appId);
Assert.assertEquals(iconMap.get("id"),configMap.get("bannerId"),"id与配置的bannerId不一致,ID:"+iconMap.get("id")+",bannerId:"+configMap.get("bannerId"));
Assert.assertEquals(iconMap.get("logo"),configMap.get("img"),"logo与配置img不一致,logo:"+iconMap.get("logo")+",配置img:"+configMap.get("img"));
Assert.assertEquals(iconMap.get("name"),configMap.get("title"),"name与配置title不一致,name:"+iconMap.get("name")+",配置title:"+configMap.get("title"));
String link=(String)iconMap.get("link");
Assert.assertTrue(link.contains(dcm),"link中未包含正确的dcm,link:"+link+",dcm:"+dcm);
Assert.assertTrue(link.contains(dpm),"link中未包含正确的dpm,link:"+link+",dcm:"+dpm);
logger.info("校验正确:"+iconMap.get("name"));
}
}
@Test(description = "楼层banner")
public void bannerTest() throws Exception {
Response response=devFloorService.bannerSelectedList(Integer.toString(appId));
// logger.info("hd:"+response.asString());
JsonPath jsonPath=from(response.asString());
List<Map> activityList=jsonPath.getList("data",Map.class);
response=homeService.floor("1","0","3","2");
String s=response.asString();
s = new String(response.asByteArray(),"UTF-8");
// logger.info("floor:"+s);
jsonPath=from(s.substring(s.indexOf("{"),s.length()-1));
List<Map> bannerList=jsonPath.getList("list",Map.class);
for(int i=0;i<bannerList.size();i++){
Map banner=bannerList.get(i);
Map activity = activityList.get(i);
Assert.assertEquals(activity.get("title"),banner.get("title"));
Assert.assertEquals(activity.get("img"),banner.get("image"));
logger.info("校验正确:"+activity.get("title"));
}
}
@Test(description = "楼层商品区")
public void itemTest() throws Exception {
Response response=devFloorService.itemSelectedList(Integer.toString(appId));
// response.prettyPrint();
List<Map> configList= from(response.asString()).getList("data", Map.class);
response=homeService.floor("3","0","3","64");
String s = new String(response.asByteArray(),"UTF-8");;
//logger.info(s.substring(s.indexOf("{"),s.length()-1));
List<Map> itemList= from(s.substring(s.indexOf("{"),s.length()-1)).getList("list", Map.class);
//开发者配置展示20个,校验手机端个数
//Assert.assertEquals(itemList.size(),20);
//校验前四个具体内容
for(int i=0;i<2;i++){
Map configMap=configList.get(i);
Map itemMap=itemList.get(i);
Assert.assertEquals(itemMap.get("appItemId"),configMap.get("appItemId"),"appItemId与配置的appItemId不一致,image:"+itemMap.get("appItemId")+",image:"+configMap.get("appItemId"));
Assert.assertEquals(itemMap.get("title"),configMap.get("title"),"title与配置title不一致,title:"+itemMap.get("title")+",配置title:"+configMap.get("title"));
Assert.assertEquals(itemMap.get("image"),configMap.get("img"),"image与配置img不一致,image:"+itemMap.get("image")+",配置img:"+configMap.get("img"));
logger.info("校验正确:"+itemMap.get("title"));
}
}
@Test(description = "楼层默认橱窗")
public void showcaseTest() throws Exception {
Response response=devFloorService.getShowcaseContent(Integer.toString(appId));
logger.info(response.asString());
List<Map> configList= from(response.asString()).getList("data", Map.class);
int i=3;
while(configList.size()==0&&i>0){
response=devFloorService.getShowcaseContent(Integer.toString(appId));
configList= from(response.asString()).getList("data", Map.class);
Thread.sleep(1000);
i--;
}
if(configList.size()==0){
throw new Exception("devFloorItem/selectedList接口异常,返回内容"+response.asString());
}
response=homeService.floor("8","0","3","186");
response.prettyPrint();
String s = new String(response.asByteArray(),"UTF-8");;
//logger.info(s.substring(s.indexOf("{"),s.length()-1));
List<Map> showcaseList= from(s.substring(s.indexOf("{"),s.length()-1)).getList("list", Map.class);
for(i=0;i<showcaseList.size();i++){
Map configMap=configList.get(i);
Map showcaseMap=showcaseList.get(i);
String dcm=(String)showcaseMap.get("dcm");
// String[] dcms=dcm.split(".");
// Assert.assertEquals(dcm.split("\\.")[1],configMap.get("relationId").toString(),"dcm与配置bannerId不一致,dcm:"+dcm+",配置relationId:"+configMap.get("relationId"));
String dpm=(String)showcaseMap.get("dpm");
Assert.assertEquals(dpm.split("\\.")[0],String.valueOf(appId),"dpm与预期不一致,dpm:"+dpm+",appId:"+appId);
Assert.assertEquals(showcaseMap.get("image"),configMap.get("image"),"image与配置的image不一致,image:"+showcaseMap.get("image")+",image:"+configMap.get("image"));
Assert.assertEquals(showcaseMap.get("relationTitle"),configMap.get("relationTitle"),"relationTitle与配置relationTitle不一致,relationTitle:"+showcaseMap.get("relationTitle")+",配置img:"+configMap.get("relationTitle"));
Assert.assertEquals(showcaseMap.get("relationImage"),configMap.get("relationImage"),"relationImage与配置relationImage不一致,name:"+showcaseMap.get("relationImage")+",配置relationImage:"+configMap.get("relationImage"));
String link=(String)showcaseMap.get("btnLink");
// Assert.assertTrue(link.contains(dcm),"btnLink中未包含正确的dcm,btnLink:"+link+",dcm:"+dcm);
Assert.assertTrue(link.contains(dpm),"btnLink中未包含正确的dpm,btnLink:"+link+",dcm:"+dpm);
logger.info("校验正确:"+showcaseMap.get("relationTitle"));
}
}
@Test(description = "楼层优惠券")
public void PlatFormCouponTest() throws Exception {
Response response=homeService.floor("6","0","3","199");
String s = response.asString();
List<Map> list= from(s.substring(s.indexOf("{"),s.length()-1)).getList("list", Map.class);
String floorTitle =from(s.substring(s.indexOf("{"),s.length()-1)).getString("floorTitle");
Assert.assertEquals(floorTitle,"优惠券");
for(int i=0;i<list.size();i++){
Map<String,Object> map = list.get(i);
String dcm = map.get("dcm").toString();
String dpm = map.get("dpm").toString();
String pcgId = map.get("pcgId").toString();
String title = map.get("title").toString();
String html = platformCouponService.platformDetail(dcm,dpm,pcgId).asString();
boolean bl = html.contains(title);
Assert.assertTrue(bl);
logger.info("校验正确:"+title);
}
}
// @Test(description = "楼层秒杀")
// public void seckillTest() throws Exception {
// Response response=homeService.floor("10","0","3","100");
// response.prettyPrint();
// String s=response.asString();
// //List<Map> list= from(s.substring(s.indexOf("{"),s.length()-1)).getList("list", Map.class);
// s = MatcherString.getString(s,"\"url\":\"(.*?)\"}",1);
//// System.out.println(s);
// logger.info("请求秒杀url:"+s);
// response = given().cookies(authorization.dafuwengLogin(2720)).get("http:"+s);
// response.prettyPrint();
//
// s = MatcherString.getString(response.asString(),"<title>(.*?)</title>",1);
// Assert.assertEquals(s,"【勿动接口自动化】秒杀专题","校验title失败");
// logger.info("校验成功");
//
// }
// @Test(description = "楼层热门活动")
// public void actfloorTest() throws Exception {
// //获取楼层热门活动内容
// Response response=homeService.floor("5","0","3","148","28");
// response.prettyPrint();
// String s = new String(response.asByteArray(),"UTF-8");
//// logger.info(s);
// List<Map> list= from(s.substring(s.indexOf("{"),s.length()-1)).getList("list", Map.class);
//
// Map<String,Object> map = list.get(0);
// Assert.assertEquals(map.get("title"),"(13兑吧活动)自动化测试勿动","校验title失败");
// Assert.assertEquals(map.get("dcm"),"202.18543.0.0","校验dcm失败");
// Assert.assertEquals(String.valueOf(map.get("operatingId")),"18543","校验operatingId失败");
// Assert.assertEquals(map.get("dpm"),"2239.5.148.1","校验dpm失败");
// Assert.assertEquals(String.valueOf(map.get("credits")),"100","校验credits失败");
// Assert.assertEquals(String.valueOf(map.get("id")),"5277","校验id失败");
// Assert.assertEquals(map.get("banner"),"//yun.duiba.com.cn/h5/activity/turnCard/2.0/images/banner.jpg","校验banner失败");
// Assert.assertEquals(map.get("link"),"//activity.m.duibatest.com.cn/hdtool/index?id=18543&amp;dbnewopen&amp;dpm=2239.5.148.1&amp;dcm=202.18543.0.0","校验banner失败");
// logger.info("校验成功");
//
//
//
//
//
//
// }
@Test(description = "浮标")
public void 浮标() throws Exception {
Response response = aerosolService.data("3","jsonp10");
logger.info(response.asString());
String exceptUrl = "http://www.duiba.com.cn";
String actUrl = MatcherString.getString(response.asString(),"\"link\":\"(.*?)\",",1);
logger.info("浮标配置url:"+actUrl);
Assert.assertTrue(actUrl.contains(exceptUrl),"浮标url与配置的url不匹配");
logger.info("校验浮标链接url正确");
}
// private Map<Object,Map> trasformate(String key,List<Map> toBeFiltered){
// Map<Object,Map> result=new HashedMap();
// for(int i=0;i<toBeFiltered.size();i++){
// Map map=toBeFiltered.get(i);
// result.put(map.get(key),map);
// }
// return result;
// }
public static void main(String[] args) {
System.out.println("1234");
}
}
package http.cases.FloorTest;
import base.DuibaLog;
import base.DuibaTestBase;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import http.service.Authorization;
import http.service.Manager.FloorService;
import http.service.app.HomeService;
import http.service.hd.DevFloorBannerService;
import http.service.hd.DevSkinService;
import io.restassured.path.json.JsonPath;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import utils.MatcherString;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;
import static io.restassured.path.json.JsonPath.from;
/**
* Created by mabo on 2018/6/8
*/
public class Game_FloorTest extends DuibaTestBase {
@Autowired
HomeService homeService;
@Autowired
FloorService floorService;
@Autowired
Authorization authorization;
@Autowired
DevSkinService devSkinService;
@Autowired
DevFloorBannerService devFloorBannerService;
private String skinId=null;
private String floorId=null;
private DuibaLog logger = DuibaLog.getLogger();
@BeforeClass
public void beforeClass(){
try{
Map map = jdbc.findSimpleResult("select * from credits_dev.tb_credits_floor_skin where skin_name = ?","mabo楼层皮肤Game");
skinId = String.valueOf(map.get("id"));
map = jdbc.findSimpleResult("select * from credits_dev.tb_credits_floor_code WHERE floor_name= ?","maboGame");
floorId = String.valueOf(map.get("id"));
Response response = devSkinService.saveSkin(authorization.hdLoginmabo(),"18740","198");
response = floorService.deleteSkin(authorization.ssoLogin(),skinId,"1");
response = floorService.deleteFloor(authorization.ssoLogin(),floorId);
}catch(Exception e){
}
}
@Test
public void A_创建游戏楼层皮肤() throws Exception {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");//设置日期格式
logger.info(df.format(new Date()));
String type = "9";
String dataType = "0";
String name = "maboGame";
String skinWidth = "750";
String html = "<div class=\"floor-game a-fadeinT\">\n" +
" <div class=\"title\">\n" +
" <div class=\"name\"><i></i>${floorTitle}</div>\n" +
" <a href=\"${moreLink}\" class=\"more\">更多<i></i></a>\n" +
" </div>\n" +
" <div class=\"item-con\">\n" +
" <div class=\"scroll\">\n" +
" <div class=\"scroll-x\" id=\"floor-game-scroll\">\n" +
" {@each list as item}\n" +
" <a class=\"m-layout\" href=\"${item.link}\" db-log=\"${item.stInfo}\">\n" +
" <img src=\"${item.bannerImg}\">\n" +
" <div class=\"game-name\">${item.title}</div>\n" +
" </a>\n" +
" {@/each}\n" +
" <div class=\"pd-space\"></div>\n" +
" </div>\n" +
" </div>\n" +
" </div>\n" +
"</div>";
String css = ".floor-game {\n" +
" display: block;\n" +
" padding: 0.1rem 0 0.1rem 0;\n" +
" margin-bottom: 0.05rem;\n" +
" border-top: 1px solid #dddddd;\n" +
" border-bottom: 1px solid #dddddd;\n" +
" background: #ffffff;\n" +
"}\n" +
".floor-game .title {\n" +
" position: relative;\n" +
" height: 0.15rem;\n" +
" line-height: 0.15rem;\n" +
" margin-left: 0.1rem;\n" +
" margin-bottom: 0.11rem;\n" +
" text-align: left;\n" +
"}\n" +
".floor-game .title .name {\n" +
" display: inline-block;\n" +
" font-size: 0.14rem;\n" +
" color: #444;\n" +
" line-height: 0.15rem;\n" +
" margin-right: 0.15rem;\n" +
"}\n" +
".floor-game .title .name i {\n" +
" display: inline-block;\n" +
" vertical-align: top;\n" +
" margin-right: 0.035rem;\n" +
" width: 0.15rem;\n" +
" height: 0.15rem;\n" +
" background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAeCAMAAAAM7l6QAAAAdVBMVEUAAABdQNZdQddfQthgT99dQdddQdZdQNddQddeQddeQNdeQNdfQddfQtlgQthkSNxsYv9eQddeQNZlTeReQddeQdZdQNdeQddeQddgQthdQddeQddeQNdeQNddQNdfQ9lfQddfQthfRdldQddeQNdgQ9ZdQNZr1CtdAAAAJnRSTlMA+9k6EPn0sKzt6saMUCcbBYV3CrmpzcBaSEdu49SjMF9EIb2TWLqDnUIAAAEvSURBVCjPhVNZdoMwDLQMttl3SAgB0rSd+x+xsbFL05Bn/SDPPKTRxnYL87rvur7OQ/ZqQSRAPE05QUTBP7JUSLKg0m4VZAlU+ZcdY9m0+7NtZHzZn2fixXO0gtPZ+Rc6vagJT2T/L2N+oDXk8ZZfyYIdWCGVqQgNO7QGur4oaY/pNokeOURm5SfDaqKlw8eGZCJkObYWrQTIB34TgNjEBMhZTZXxP6Ft4OajDFRRzXpu3DuANDdcfAXuBuQ961IrE/yrmmMAtxWYDJh2jlZAodUAuM6AsrQLzgGKKiKIfABgwd5JEwDmCYAcNS2tNFeYwJNJW5hriynoNH1Pi4TOb9vimpoBybiNqiZgsU11I2mXqPxdO2X8BoFvoP51YOObZfKsomeRPWfgPyLPCf4Azfkcffc9FNsAAAAASUVORK5CYII=');\n" +
" background-size: 100% auto;\n" +
"}\n" +
".floor-game .title .more {\n" +
" position: absolute;\n" +
" font-size: 0.1rem;\n" +
" top: 0.01rem;\n" +
" right: 0.1rem;\n" +
" color: #888;\n" +
"}\n" +
".floor-game .title .more i {\n" +
" display: inline-block;\n" +
" margin-left: 0.02rem;\n" +
" width: 0.045rem;\n" +
" height: 0.075rem;\n" +
" background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAkAAAAOCAYAAAD9lDaoAAAAAXNSR0IArs4c6QAAAMJJREFUKBWFj0EKwjAQRZOQ7rMUQUGxnqMLN124zAWy6ZlSaG8hbnsPQUF3XqHB+KeQkrYYB4YZ8l9m/vC6ri+MsYOUsjTG3NEvQnjvV8hj3/dd27b7BYEHgQln1Bty8wvk9LNpmrVzrkObI19ZlhXx6gGCkARHKAVOoDnIOX8opXJBQhzwJiFKesPVTmvtJ5C1dgugg7ijKeBOqJ9x3RwAWFRV9aSJA5QCBugfQBB5ugYP8QoSQ9Alb4h0SRk8BDHUL2r8gjSPuiqVAAAAAElFTkSuQmCC') no-repeat;\n" +
" background-size: 100% auto!important;\n" +
"}\n" +
".floor-game .item-con {\n" +
" height: 0.8rem;\n" +
" overflow: hidden;\n" +
" *zoom: 1;\n" +
"}\n" +
".floor-game .item-con .m-layout {\n" +
" display: block;\n" +
" float: left;\n" +
" position: relative;\n" +
" width: 1.425rem;\n" +
" height: 0.625rem;\n" +
" margin-right: 0.065rem;\n" +
"}\n" +
".floor-game .item-con .m-layout:first-child {\n" +
" margin-left: 0.1rem;\n" +
"}\n" +
".floor-game .item-con .m-layout img {\n" +
" width: 1.425rem;\n" +
" height: 0.625rem;\n" +
" border-radius: 0.1rem;\n" +
" background-size: 100% auto!important;\n" +
"}\n" +
".floor-game .item-con .game-name {\n" +
" margin-top: 0.05rem;\n" +
" font-size: 0.12rem;\n" +
" color: #666666;\n" +
"}\n" +
".floor-game .item-con:before,\n" +
".floor-game .item-con:after {\n" +
" display: table;\n" +
" content: \"\";\n" +
"}\n" +
".floor-game .item-con:after {\n" +
" clear: both;\n" +
"}\n" +
".floor-game .item-con .scroll {\n" +
" height: 1rem !important;\n" +
"}\n" +
".floor-game .pd-space {\n" +
" height: 0.6rem;\n" +
" float: left;\n" +
" width: 0.1rem;\n" +
"}";
String js = "if ( data && data.list && data.list.length) {\n" +
" if (typeof ''.ossimg === 'function') {\n" +
"\tdata.list = data.list.imgWebpArray('bannerImg');\n" +
" }\n" +
" yangzuo.extend(data,global);\n" +
" if(data.list.length>5) {\n" +
" data.list = data.list.slice(0,5);\n" +
" }\n" +
" $(\"#renderRoot\").append(juicer(html, data));\n" +
" var len = (data.list.length*305 + 20)/200;\n" +
" $(\"#floor-game-scroll\").css(\"width\",len+\"rem\");\n" +
" //lazyload().getLazyImg();\n" +
"}";
//新建banner楼层
Response response = floorService.createFloor(authorization.ssoLogin(),type,dataType,name,html,css,js,skinWidth);
Map<String,Object> map = jdbc.findSimpleResult("select * from credits_dev.tb_credits_floor_code where floor_name=?",name);
floorId = String.valueOf(map.get("id"));
String nameSkin = "mabo楼层皮肤game";
String image = "//yun.dui88.com/images/201805/nlkmslg0t0.png";
// 验证码
String stoke="1";
// String floors = "[{\"id\":190,\"name\":\"maboTest\",\"type\":1,\"dataType\":0,\"needSyn\":false,\"syn\":false}]";
String ower = "0";
JSONObject json = new JSONObject();
json.put("id",map.get("id"));
json.put("name",name);
json.put("type",type);
json.put("dataType",map.get("data_type"));
json.put("needSyn",false);
json.put("syn",false);
JSONArray jsonArray = new JSONArray();
jsonArray.add(json);
String floors = jsonArray.toJSONString();
//新建皮肤
response = floorService.insertSkin(authorization.ssoLogin(),nameSkin,image,stoke,floors,ower,skinWidth);
map = jdbc.findSimpleResult("select * from credits_dev.tb_credits_floor_skin where skin_name = ?",nameSkin);
skinId = String.valueOf(map.get("id"));
response = floorService.switchOpenState(authorization.ssoLogin(),skinId,"true");
}
@Test
public void B_游戏手机端() throws Exception {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");//设置日期格式
logger.info(df.format(new Date()));
Response response = devSkinService.saveSkin(authorization.hdLoginmabo(),"18740",skinId);
Thread.sleep(60000);
JsonPath jsonCfg = homeService.getCFG(2753);
Assert.assertEquals(jsonCfg.getList("").size(),1,"banner展示数量和配置不符");
String floorId = MatcherString.getString(jsonCfg.getList("").get(0).toString(),"floorId=(.*?),",1);
String dataType = MatcherString.getString(jsonCfg.getList("").get(0).toString(),"dataType=(.*?),",1);
String floorType = MatcherString.getString(jsonCfg.getList("").get(0).toString(),"floorType=(.*?),",1);
response = homeService.floor(authorization.dafuwengLogin(2753),floorType,dataType,"3",floorId);
String s = response.asString();
response.prettyPrint();
System.out.println(s);
JsonPath jsonPath=from(s.substring(s.indexOf("{"),s.length()-1));
String floorTitle = jsonPath.getString("floorTitle");
Assert.assertEquals(floorTitle,"趣味游戏","楼层title校验失败");
}
@Test
public void C_删除游戏楼层皮肤() throws Exception {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");//设置日期格式
logger.info(df.format(new Date()));
Response response = devSkinService.saveSkin(authorization.hdLoginmabo(),"18740","198");
response.prettyPrint();
response = floorService.deleteSkin(authorization.ssoLogin(),skinId,"1");
response.prettyPrint();
response = floorService.deleteFloor(authorization.ssoLogin(),floorId);
response.prettyPrint();
}
}
package http.cases.FloorTest;
import base.DuibaLog;
import base.DuibaTestBase;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import http.service.Authorization;
import http.service.Manager.FloorService;
import http.service.app.HomeService;
import http.service.hd.DevFloorBannerService;
import http.service.hd.DevFloorIconService;
import http.service.hd.DevSkinService;
import io.restassured.path.json.JsonPath;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import utils.MatcherString;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;
import static io.restassured.path.json.JsonPath.from;
/**
* Created by mabo on 2018/6/7
*/
public class Icon_FloorTest extends DuibaTestBase {
@Autowired
HomeService homeService;
@Autowired
FloorService floorService;
@Autowired
Authorization authorization;
@Autowired
DevSkinService devSkinService;
@Autowired
DevFloorBannerService devFloorBannerService;
@Autowired
DevFloorIconService devFloorIconService;
private DuibaLog logger = DuibaLog.getLogger();
private String skinId=null;
private String floorId=null;
private String bannerId = null;
@BeforeClass
public void beforeClass(){
try{
Map map = jdbc.findSimpleResult("select * from credits_dev.tb_credits_floor_skin where skin_name = ?","mabo楼层皮肤icon");
skinId = String.valueOf(map.get("id"));
map = jdbc.findSimpleResult("select * from credits_dev.tb_credits_floor_code WHERE floor_name= ?","maboicon");
floorId = String.valueOf(map.get("id"));
Response response = devFloorIconService.selectedList(authorization.hdLoginmabo(),"18740");
List<Map> list = response.jsonPath().getList("data",Map.class);
map = getByName(list,"今日必抢");
if(map!=null){
JSONObject json = new JSONObject();
json.put("appId","18740");
json.put("bannerId",map.get("bannerId").toString());
response = devFloorIconService.delIcon(authorization.hdLoginmabo(),json.toJSONString());
}
response = devSkinService.saveSkin(authorization.hdLoginmabo(),"18740","198");
response = floorService.deleteSkin(authorization.ssoLogin(),skinId,"1");
response = floorService.deleteFloor(authorization.ssoLogin(),floorId);
}catch(Exception e){
}catch(Error e){
}
}
@Test
public void A_创建icon楼层皮肤() throws Exception {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");//设置日期格式
logger.info(df.format(new Date()));
String type = "2";
String dataType = "0";
String name = "maboicon";
String skinWidth = "750";
String html = "<section class=\"floor-icon a-fadeinT\">\n" +
" <div class=\"scroll\">\n" +
" <div class=\"scroll-x\"> \n" +
" <div id=\"J_iconList\">\n" +
" \t {@each list as item,index}\n" +
" <a href=\"${item.link}\" db-log=\"${item.stInfo}\" class=\"icon-a icon${list.length} {@if list.length > 4 }icon-large{@/if}\" >\n" +
" <img src=\"${item.logo}\" alt=\"\"/> \n" +
" <p>${item.name}</p>\n" +
" </a>\n" +
" {@/each}\n" +
" </div>\n" +
" </div> \n" +
" </div>\n" +
"</section>";
String css = ".floor-icon {\n" +
" position: relative;\n" +
" background: #FFF;\n" +
" width: 100%;\n" +
" margin-bottom: 0.21333333rem;\n" +
" padding-top: 0.62666667rem;\n" +
" height: 4.04266667rem;\n" +
" overflow: hidden;\n" +
"}\n" +
".floor-icon .icon-a {\n" +
" float: left;\n" +
" text-align: center;\n" +
"}\n" +
".floor-icon .icon-a.icon3 {\n" +
" width: 4.50133333rem;\n" +
"}\n" +
".floor-icon .icon-a.icon4 {\n" +
" width: 3.41333333rem;\n" +
"}\n" +
".floor-icon .icon-a.icon5 {\n" +
" width: 2.73066667rem;\n" +
"}\n" +
".floor-icon .icon-a.icon6,\n" +
".floor-icon .icon-a.icon7 {\n" +
" width: 2.47466667rem;\n" +
"}\n" +
".floor-icon .icon-a.icon-large {\n" +
" width: 3.02933333rem;\n" +
" margin-bottom: 0.42666667rem;\n" +
"}\n" +
".floor-icon .icon-a img {\n" +
" width: 1.83466667rem;\n" +
" height: 1.83466667rem;\n" +
" margin-bottom: 0.41333333rem;\n" +
" border-radius: 33%;\n" +
"}\n" +
".floor-icon .icon-a p {\n" +
" font-family: PingFangSC-Regular;\n" +
" font-size: 0.55466667rem;\n" +
" color: #333;\n" +
" letter-spacing: 0;\n" +
" margin-bottom: 1rem;\n" +
"}\n" +
".scroll {\n" +
" width: 100%;\n" +
" height: 3.416rem;\n" +
" overflow: auto;\n" +
" box-sizing: border-box;\n" +
" -webkit-overflow-scrolling: touch;\n" +
"}\n" +
".scroll .scroll-x {\n" +
" width: 426.66666667rem;\n" +
" height: 3.94266667rem;\n" +
" padding: 0 0.53333333rem;\n" +
" overflow: hidden;\n" +
"}\n" +
".scroll .scroll-x > div.large {\n" +
" width: 90%;\n" +
" margin: 0 auto;\n" +
" display: -webkit-box;\n" +
" display: -ms-flexbox;\n" +
" display: flex;\n" +
" -webkit-box-pack: justify;\n" +
" -ms-flex-pack: justify;\n" +
" justify-content: space-between;\n" +
"}";
String js = "if (data && data.list && data.list.length > 2) {\n" +
" \t$(\"#renderRoot\").append(juicer(html, data));\n" +
"\tif ( data.list.length > 4) {\n" +
" var needWidth = (data.list.length) * 20;\n" +
"\t var $iconLarge = $('.floor-icon').find('.icon-large');\n" +
"\t $iconLarge.closest('.scroll-x').css('width', needWidth+'%');\n" +
"\t $iconLarge.closest('.scroll').css('height', 'auto');\n" +
"\t} else {\n" +
"\t var $iconLarge = $('.floor-icon').find('.icon-a');\n" +
"\t $iconLarge.closest('.scroll-x').css({width: '100%',height: '100%'});\n" +
" $iconLarge.closest('.scroll-x>div').addClass('large');\n" +
"\t}\n" +
"}";
//新建banner楼层
Response response = floorService.createFloor(authorization.ssoLogin(),type,dataType,name,html,css,js,skinWidth);
Map<String,Object> map = jdbc.findSimpleResult("select * from credits_dev.tb_credits_floor_code where floor_name=?",name);
floorId = String.valueOf(map.get("id"));
String nameSkin = "mabo楼层皮肤icon";
String image = "//yun.dui88.com/images/201805/nlkmslg0t0.png";
// 验证码
String stoke="1";
// String floors = "[{\"id\":190,\"name\":\"maboTest\",\"type\":1,\"dataType\":0,\"needSyn\":false,\"syn\":false}]";
String ower = "0";
JSONObject json = new JSONObject();
json.put("id",map.get("id"));
json.put("name",name);
json.put("type","2");
json.put("dataType",map.get("data_type"));
json.put("needSyn",false);
json.put("syn",false);
JSONArray jsonArray = new JSONArray();
jsonArray.add(json);
String floors = jsonArray.toJSONString();
//新建皮肤
response = floorService.insertSkin(authorization.ssoLogin(),nameSkin,image,stoke,floors,ower,skinWidth);
map = jdbc.findSimpleResult("select * from credits_dev.tb_credits_floor_skin where skin_name = ?",nameSkin);
skinId = String.valueOf(map.get("id"));
response = floorService.switchOpenState(authorization.ssoLogin(),skinId,"true");
}
@Test
public void B_icon添加图标() throws Exception {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");//设置日期格式
logger.info(df.format(new Date()));
//应用皮肤
Response response = devSkinService.saveSkin(authorization.hdLoginmabo(),"18740",skinId);
JSONObject json = new JSONObject();
json.put("appId","18740");
json.put("classifySwitch","false");
json.put("iconType","list");
json.put("img","//yun.dui88.com/duibaManagerWeb/dnb7ivbsjr.png");
json.put("listType","iconDuiba");
json.put("selected","false");
json.put("show","true");
json.put("sourceRelationId","2");
json.put("target","今日必抢");
json.put("title","今日必抢");
json.put("appItemId","null");
json.put("bannerId","null");
json.put("classifyImage","null");
json.put("payload","null");
response = devFloorIconService.saveIcon(authorization.hdLoginmabo(),json.toJSONString());
response.prettyPrint();
Thread.sleep(70000);
JsonPath jsonCfg = homeService.getCFG(2753);
Assert.assertEquals(jsonCfg.getList("").size(),1,"banner展示数量和配置不符");
String floorId = MatcherString.getString(jsonCfg.getList("").get(0).toString(),"floorId=(.*?),",1);
String dataType = MatcherString.getString(jsonCfg.getList("").get(0).toString(),"dataType=(.*?),",1);
String floorType = MatcherString.getString(jsonCfg.getList("").get(0).toString(),"floorType=(.*?),",1);
response = homeService.floor(authorization.dafuwengLogin(2753),floorType,dataType,"3",floorId);
response.prettyPrint();
String s = response.asString();
JsonPath jsonPath=from(s.substring(s.indexOf("{"),s.length()-1));
List<Map> list = jsonPath.getList("list",Map.class);
Map map = getByName(list,"今日必抢");
Assert.assertNotNull(map,"icon里没有今日必抢图标");
Assert.assertTrue(map.get("link").toString().contains("//test-todayrob.m.dui88.com/todayrob/index?"),"今日必抢link校验错误");
Assert.assertEquals(map.get("logo"),"//yun.dui88.com/duibaManagerWeb/dnb7ivbsjr.png","今日必抢logo校验错误");
map = getByName(list,"所有商品");
Assert.assertNotNull(map,"icon里没有所有商品图标");
Assert.assertTrue(map.get("link").toString().contains("//activity.m.duibatest.com.cn/button/items?"),"所有商品link校验错误");
Assert.assertEquals(map.get("logo"),"//yun.dui88.com/duibaManagerWeb/ispnglsd3n.png","所有商品logo校验错误");
map = getByName(list,"用户定制");
Assert.assertNotNull(map,"icon里没有用户定制图标");
Assert.assertTrue(map.get("link").toString().contains("www.duiba.com.cn?"),"用户定制link校验错误");
Assert.assertEquals(map.get("logo"),"//yun.dui88.com/duibaManagerWeb/912v0pc812.png","用户定制logo校验错误");
}
@Test
public void C_icon编辑图标() throws Exception {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");//设置日期格式
logger.info(df.format(new Date()));
Response response = devFloorIconService.selectedList(authorization.hdLoginmabo(),"18740");
List<Map> list = response.jsonPath().getList("data",Map.class);
Map map = getByTitle(list,"今日必抢");
Assert.assertNotNull(map,"icon里没有今日必抢图标");
bannerId = map.get("bannerId").toString();
JSONObject json = new JSONObject();
json.put("appId","18740");
json.put("bannerId",bannerId);
json.put("classifyImage","null");
json.put("classifySwitch","false");
json.put("iconType","list");
json.put("img","//yun.dui88.com/images/201806/9lz5ifre0h.png");
json.put("listType","iconDuiba");
json.put("sourceRelationId","2");
json.put("title","今日必抢1");
response = devFloorIconService.updateIcon(authorization.hdLoginmabo(),json.toJSONString());
response.prettyPrint();
Thread.sleep(60000);
JsonPath jsonCfg = homeService.getCFG(2753);
Assert.assertEquals(jsonCfg.getList("").size(),1,"banner展示数量和配置不符");
String floorId = MatcherString.getString(jsonCfg.getList("").get(0).toString(),"floorId=(.*?),",1);
String dataType = MatcherString.getString(jsonCfg.getList("").get(0).toString(),"dataType=(.*?),",1);
String floorType = MatcherString.getString(jsonCfg.getList("").get(0).toString(),"floorType=(.*?),",1);
response = homeService.floor(authorization.dafuwengLogin(2753),floorType,dataType,"3",floorId);
response.prettyPrint();
String s = response.asString();
JsonPath jsonPath=from(s.substring(s.indexOf("{"),s.length()-1));
list = jsonPath.getList("list",Map.class);
map = getByName(list,"今日必抢1");
Assert.assertNotNull(map,"icon里没有今日必抢1图标");
// Assert.assertEquals(map.get("link"),"//test-todayrob.m.dui88.com/todayrob/index?dbnewopen=&dpm=18740.5.293.1&dcm=203.23044.0.0","今日必抢link校验错误");
Assert.assertEquals(map.get("logo"),"//yun.dui88.com/images/201806/9lz5ifre0h.png","今日必抢logo校验错误");
}
@Test
public void D_icon删除图标() throws Exception {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");//设置日期格式
logger.info(df.format(new Date()));
JSONObject json = new JSONObject();
json.put("appId","18740");
json.put("bannerId",bannerId);
Response response = devFloorIconService.delIcon(authorization.hdLoginmabo(),json.toJSONString());
response.prettyPrint();
JsonPath jsonCfg = homeService.getCFG(2753);
Assert.assertEquals(jsonCfg.getList("").size(),1,"banner展示数量和配置不符");
String floorId = MatcherString.getString(jsonCfg.getList("").get(0).toString(),"floorId=(.*?),",1);
String dataType = MatcherString.getString(jsonCfg.getList("").get(0).toString(),"dataType=(.*?),",1);
String floorType = MatcherString.getString(jsonCfg.getList("").get(0).toString(),"floorType=(.*?),",1);
response = homeService.floor(floorType,dataType,"3",floorId);
response.prettyPrint();
String s = response.asString();
JsonPath jsonPath=from(s.substring(s.indexOf("{"),s.length()-1));
List<Map> list = jsonPath.getList("list",Map.class);
Map map = getByName(list,"今日必抢");
Assert.assertNull(map,"icon里删除今日必抢图标失败");
}
@Test
public void E_删除icon楼层皮肤() throws Exception {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");//设置日期格式
logger.info(df.format(new Date()));
Response response = devSkinService.saveSkin(authorization.hdLoginmabo(),"18740","198");
response.prettyPrint();
response = floorService.deleteSkin(authorization.ssoLogin(),skinId,"1");
response.prettyPrint();
response = floorService.deleteFloor(authorization.ssoLogin(),floorId);
response.prettyPrint();
}
public Map getByName (List<Map> list,String name){
if(list==null)return null;
for (Map map:list
) {
if(map.get("name").equals(name))return map;
}
return null;
}
public Map getByTitle (List<Map> list,String name){
for (Map map:list
) {
if(map.get("title").equals(name))return map;
}
return null;
}
}
package http.cases.FloorTest;
import base.DuibaLog;
import base.DuibaTestBase;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import http.service.Authorization;
import http.service.Manager.FloorService;
import http.service.app.HomeService;
import http.service.hd.DevFloorBannerService;
import http.service.hd.DevFloorService;
import http.service.hd.DevSkinService;
import io.restassured.path.json.JsonPath;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import utils.MatcherString;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;
import static io.restassured.path.json.JsonPath.from;
/**
* Created by mabo on 2018/6/7
* 商品区
*/
public class Item_FloorTest extends DuibaTestBase {
@Autowired
HomeService homeService;
@Autowired
FloorService floorService;
@Autowired
Authorization authorization;
@Autowired
DevSkinService devSkinService;
@Autowired
DevFloorBannerService devFloorBannerService;
@Autowired
DevFloorService devFloorService;
private String skinId=null;
private String floorId=null;
private DuibaLog logger = DuibaLog.getLogger();
@BeforeClass
public void beforeClass(){
try{
Map map = jdbc.findSimpleResult("select * from credits_dev.tb_credits_floor_skin where skin_name = ?","mabo楼层皮肤Item");
skinId = String.valueOf(map.get("id"));
map = jdbc.findSimpleResult("select * from credits_dev.tb_credits_floor_code WHERE floor_name= ?","maboItem");
floorId = String.valueOf(map.get("id"));
Response response = devSkinService.saveSkin(authorization.hdLoginmabo(),"18740","198");
response = floorService.deleteSkin(authorization.ssoLogin(),skinId,"1");
response = floorService.deleteFloor(authorization.ssoLogin(),floorId);
}catch(Exception e){
}
}
@Test
public void A_item创建楼层皮肤() throws Exception {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");//设置日期格式
logger.info(df.format(new Date()));
String type = "3";
String dataType = "0";
String name = "maboItem";
String skinWidth = "750";
String html = "\n" +
"<section class=\"floor-item a-fadeinT\">\n" +
"\t<div class=\"floor-item-header\">\n" +
"\t\t<div class=\"floor-item-title\"><span class=\"title-txt\">限量抢兑</span></div>\n" +
"\t\t<div class=\"floor-item-title1\"><span class=\"title-txt1\"></span></div>\n" +
" \n" +
"\t</div>\n" +
"\t<div id=\"J_itemList\" class=\"item-con\">\n" +
"\t\t{@each list as item}\n" +
"\t\t<a href=\"${item.link}\" db-log=\"${item.stInfo}\" class=\"item\">\n" +
"\t\t\t<div class=\"img-wrap\">\n" +
"\t\t\t\t{@if item.whiteImage}\n" +
"\t\t\t\t<img src=\"${item.whiteImage}\"> {@else}\n" +
"\t\t\t\t<img src=\"${item.image}\"> {@/if}\n" +
"\t\t\t</div>\n" +
"\t\t\t<div class=\"theme-color info-wrap\">\n" +
"\t\t\t\t<h3 class=\"item-title\">${item.title}</h3>\n" +
"\t\t\t\t<p>\n" +
" \t{@if item.salePrice}\n" +
"\t\t\t\t\t<span class=\"item-credits\">${item.credits} + ${item.salePrice}元</span>\n" +
" \t{@else}\n" +
" \t<span class=\"item-credits\">${item.credits}</span>\n" +
" \t{@/if}\n" +
"\t\t\t\t</p>\n" +
" \t<p class=\"original-price\">\n" +
" {@if !!item.tagText}\n" +
" <span>原价</span>\n" +
" <span class=\"corner\">${item.tagText}</span>\n" +
" {@/if}\n" +
" </p>\n" +
"\t\t\t</div>\n" +
"\t\t</a>\n" +
"\t\t{@/each}\n" +
"\t</div>\n" +
"\t{@if moreUrl}\n" +
"\t<a class=\"btn-more\" href=\"${moreUrl}\"><span class=\"more-txt\">全部商品</span><i></i></a>\n" +
"\t{@/if}\n" +
" <div class=\"tianchong\"></div>\n" +
"\t<!--<p class=\"no-more\">已经没有更多啦!</p>-->\n" +
"</section>";
String css = "\n" +
".floor-item {\n" +
" background-color: #FFFFFF;\n" +
"}\n" +
".floor-item .tianchong {\n" +
" width: 100%;\n" +
" height: 0.512rem;\n" +
" background: #F4F5F7;\n" +
"}\n" +
".floor-item .btn-more {\n" +
" display: block;\n" +
" text-align: center;\n" +
" margin-top: 0.21333333rem;\n" +
" height: 0.59733333rem;\n" +
" line-height: 0.59733333rem;\n" +
" padding-bottom: 1.28rem;\n" +
"}\n" +
".floor-item .btn-more .more-txt {\n" +
" font-size: 0.512rem;\n" +
" vertical-align: middle;\n" +
" color: #333;\n" +
" margin-bottom: 0.32rem;\n" +
" height: 0.59733333rem;\n" +
" line-height: 0.59733333rem;\n" +
" text-align: center;\n" +
" color: #767A81;\n" +
" margin-top: 0.04266667rem;\n" +
" font-family: PingFangSC-Regular;\n" +
"}\n" +
".floor-item .btn-more i {\n" +
" display: inline-block;\n" +
" margin-left: 0.17066667rem;\n" +
" vertical-align: middle;\n" +
" line-height: 0.59733333rem;\n" +
" width: 0.512rem;\n" +
" height: 0.512rem;\n" +
" background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACQAAAAkBAMAAAATLoWrAAAAJFBMVEUAAAC6vL7///+5vL+70dG5vL66vMC6vL68vMC/v7++vsS5u76JD15jAAAAC3RSTlMAwQOkCqGBcj0oJ/6LF+EAAABCSURBVCjPY6A6YElXQBdi3G2ELrR692YFDFUYylikMZU5Dh5lWxkwlTXgFUJoxDQe0xF0VkQwOmZjizQjbAmAJgAAqKUu42A7d8UAAAAASUVORK5CYII=');\n" +
" background-size: 100% 100%;\n" +
"}\n" +
".floor-item .floor-item-header {\n" +
" position: relative;\n" +
"}\n" +
".floor-item .floor-item-header .floor-item-title1 {\n" +
" margin-top: 0.42666667rem;\n" +
" height: 0.64rem;\n" +
" margin-bottom: 0.32rem;\n" +
" text-align: center;\n" +
" margin-bottom: 0.85333333rem;\n" +
"}\n" +
".floor-item .floor-item-header .floor-item-title1 .title-txt1 {\n" +
" font-family: PingFangSC-Regular;\n" +
" font-size: 0.512rem;\n" +
" color: #B9BBBE;\n" +
" line-height: 0.64rem;\n" +
"}\n" +
".floor-item .floor-item-header .floor-item-title {\n" +
" height: 1.06666667rem;\n" +
" margin-top: 0.42666667rem;\n" +
" padding-top: 0.64rem;\n" +
" padding-bottom: 0.64rem;\n" +
" text-align: center;\n" +
"}\n" +
".floor-item .floor-item-header .floor-item-title i {\n" +
" display: inline-block;\n" +
" vertical-align: middle;\n" +
" margin-right: 0.14933333rem;\n" +
" width: 0.64rem;\n" +
" height: 0.64rem;\n" +
" background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAeCAMAAAAM7l6QAAAAeFBMVEUAAADvK1HvMF/vLFDxK1LuLFHwLFHvK1HvLFHvK1HvK1DuLFDuLFHwLFHvLFDuLFDuLFHwLVPxLFLyLVH2LlL/M2b/M2bvLFHzLlTyL1HvK1HvK1DwLFHuLVLxK1DvK1DvK1DvLFLzM1XuLFHwLFLvLFHvK1HuK1DpUsVBAAAAJ3RSTlMA+RCuPLl37urajNiphfv0xlBHORwKBcAoJePPZlpXy55NFJeGbi9ZcP/rAAABI0lEQVQoz4WT2XKDMAxFvWKbnbAGSNKki/7/DwsCFdzMgF5s5qDra0lmW4giibWOk0Kw9yglBx7leTQtsvwHKwk2VM28bVRoQVZ7ejFZUG+fdZCZy/Z5S93VV+tcevvLTds3N6JN1/zKuI1u3JnlfJmRsq+fSbwRBPNy74HCjsgDKOdkO3t+cdgFytV2Shc8nPcK9nHH9JALVoBCbYAwQdQ+ARZ1BQVLONZqBNAd4u8AFjes4QmLo9UHgBo5wMern4QW81HMdI67rwmbp1DXboDpnwXnmvAnCjv9wFUSJvHYc96SOFnTHh7IGl3s4eGeLkZlcR42VBYqqgUvqKjUEu5jsbaEGjr4Z1NDaRx+9jxSNA5Hw3Q8iseDfPoMzh/RyRP8BeV2K8kLQfm+AAAAAElFTkSuQmCC');\n" +
" background-size: 100% 100%;\n" +
"}\n" +
".floor-item .floor-item-header .floor-item-title .title-txt {\n" +
" font-size: 0.68266667rem;\n" +
" color: #333;\n" +
" font-weight: 600;\n" +
" line-height: 0.64rem;\n" +
" font-family: PingFangSC-Medium;\n" +
"}\n" +
".floor-item .floor-item-header .floor-item-title .title-txt-y {\n" +
" font-weight: normal;\n" +
" font-size: 0.68266667rem;\n" +
" color: #ff2f2f;\n" +
"}\n" +
".floor-item .item-con {\n" +
" width: 100%;\n" +
" height: 18rem;\n" +
" overflow: hidden;\n" +
" *zoom: 1;\n" +
"}\n" +
".floor-item .item-con > .item {\n" +
" float: left;\n" +
" width: 6.656rem;\n" +
" position: relative;\n" +
" background: #fff;\n" +
" margin-left: 0.85333333rem;\n" +
" margin-bottom: 0.42666667rem;\n" +
" overflow: hidden;\n" +
" height: 8.8rem;\n" +
"}\n" +
".floor-item .item-con > .item:nth-child(2n) {\n" +
" margin-right: 0.85333333rem;\n" +
"}\n" +
".floor-item .item-con .img-wrap {\n" +
" width: 6.656rem;\n" +
" padding: 0;\n" +
" position: relative;\n" +
"}\n" +
".floor-item .item-con .img-wrap img {\n" +
" width: 100%;\n" +
"}\n" +
".floor-item .item-con .img-wrap .corner {\n" +
" position: absolute;\n" +
" bottom: 0.21333333rem;\n" +
" left: 0.46933333rem;\n" +
" font-size: 0.55466667rem;\n" +
" color: #fff;\n" +
" padding: 0 0.17066667rem;\n" +
" height: 0.85333333rem;\n" +
" line-height: 0.85333333rem;\n" +
" text-align: center;\n" +
" vertical-align: top;\n" +
" -webkit-transform: scale(0.9);\n" +
" transform: scale(0.9);\n" +
" -webkit-transform-origin: 0 0;\n" +
" transform-origin: 0 0;\n" +
" display: inline-block;\n" +
" background-color: #ff2f2f;\n" +
"}\n" +
".floor-item .item-con .info-wrap {\n" +
" min-height: 3.84rem;\n" +
"}\n" +
".floor-item .item-con .info-wrap p {\n" +
" line-height: 0.68266667rem;\n" +
"}\n" +
".floor-item .item-con .info-wrap p .item-credits {\n" +
" font-size: 0.55466667rem;\n" +
" position: relative;\n" +
" display: inline-block;\n" +
" vertical-align: top;\n" +
" color: #191D21;\n" +
" line-height: 0.85333333rem;\n" +
" font-family: DIN-Medium;\n" +
"}\n" +
".floor-item .item-con .info-wrap p .mb12 {\n" +
" display: inline-block;\n" +
" background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACQAAAAkCAYAAADhAJiYAAAACXBIWXMAAAsTAAALEwEAmpwYAAAFFmlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgNS42LWMxNDAgNzkuMTYwNDUxLCAyMDE3LzA1LzA2LTAxOjA4OjIxICAgICAgICAiPiA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPiA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtbG5zOmRjPSJodHRwOi8vcHVybC5vcmcvZGMvZWxlbWVudHMvMS4xLyIgeG1sbnM6cGhvdG9zaG9wPSJodHRwOi8vbnMuYWRvYmUuY29tL3Bob3Rvc2hvcC8xLjAvIiB4bWxu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mWZq71ebP2gqntzwbIsa7WPm2tgsh6LYzrSXJwtt9ob885twRSZCIyntlRGj2c2zd0PXWh9rujh0kHzekgEJmph/UQxfpXmN3vgdvZDtbE3RUqMuFHmGpgcS8PcwK2+kvdILpBMnb2EOC+JyNqWQO6rhjXjRCEE8cF9Sxrnfs6NW3Tq0M7CXjT4VJXZkRDXbobpcU0CIgbTBfOGPNT+OKG/pWPQ5ed34a2/P7KmRh2DjPxGRY7K3OKPQ9rbOiguLzyHtSczp4Ssg6KYv8CclObX7+VqbgdoILJy6GECjoA9CMwmjtLCVayzhNEzMr/4RaFWEdCdtrvu3497QEX2LxvhkdCpk54YAAAAAElFTkSuQmCC');\n" +
" width: 0.85333333rem;\n" +
" height: 0.85333333rem;\n" +
" background-size: 100% 100%;\n" +
"}\n" +
".floor-item .item-con .original-price {\n" +
" font-size: 0.5rem;\n" +
" line-height: 1rem;\n" +
" color: #666;\n" +
"}\n" +
".floor-item .item-con .original-price .corner {\n" +
" text-decoration:line-through;\n" +
"}\n" +
".floor-item .item-con .item-title {\n" +
" padding-top: 0.21333333rem;\n" +
" font-weight: 400;\n" +
" font-size: 0.59733333rem;\n" +
" line-height: 0.93866667rem;\n" +
" margin-bottom: 0.29866667rem;\n" +
" display: -webkit-box;\n" +
" -webkit-box-orient: vertical;\n" +
" -webkit-line-clamp: 2;\n" +
" overflow: hidden;\n" +
" font-family: PingFangSC-Medium;\n" +
" color: #191D21;\n" +
"}\n" +
".floor-item .item-con:before,\n" +
".floor-item .item-con:after {\n" +
" display: table;\n" +
" content: \"\";\n" +
"}\n" +
".floor-item .item-con:after {\n" +
" clear: both;\n" +
"}\n" +
".floor-item .no-more {\n" +
" margin-top: 0.55466667rem;\n" +
" text-align: center;\n" +
" font-size: 0.512rem;\n" +
" color: #999;\n" +
"}\n" +
".apple {\n" +
" width: 100% !important;\n" +
" height: 100% !important;\n" +
" margin-top: 0 !important;\n" +
" margin-bottom: 0 !important;\n" +
" border-radius: 0 !important;\n" +
" padding-top: 0.21333333rem !important;\n" +
" padding-bottom: 0.21333333rem !important;\n" +
" background: #F4F5F7 !important;\n" +
"}\n" +
".apple p {\n" +
" padding-top: 0;\n" +
" font-size: 0.46933333rem;\n" +
" color: #bbb;\n" +
" text-align: center;\n" +
"}\n" +
"body {\n" +
" background: #FFFFFF;\n" +
"}";
String js = "if(data && data.list && data.list.length) {\n" +
"\tyangzuo.extend(data,global);\n" +
" \tyangzuo.element(\"#renderRoot\").append(juicer(html, data));\n" +
"}";
//新建banner楼层
Response response = floorService.createFloor(authorization.ssoLogin(),type,dataType,name,html,css,js,skinWidth);
Map<String,Object> map = jdbc.findSimpleResult("select * from credits_dev.tb_credits_floor_code where floor_name=?",name);
floorId = String.valueOf(map.get("id"));
String nameSkin = "mabo楼层皮肤item";
String image = "//yun.dui88.com/images/201805/nlkmslg0t0.png";
// 验证码
String stoke="1";
// String floors = "[{\"id\":190,\"name\":\"maboTest\",\"type\":1,\"dataType\":0,\"needSyn\":false,\"syn\":false}]";
String ower = "0";
JSONObject json = new JSONObject();
json.put("id",map.get("id"));
json.put("name",name);
json.put("type","3");
json.put("dataType",map.get("data_type"));
json.put("needSyn",false);
json.put("syn",false);
JSONArray jsonArray = new JSONArray();
jsonArray.add(json);
String floors = jsonArray.toJSONString();
//新建皮肤
response = floorService.insertSkin(authorization.ssoLogin(),nameSkin,image,stoke,floors,ower,skinWidth);
map = jdbc.findSimpleResult("select * from credits_dev.tb_credits_floor_skin where skin_name = ?",nameSkin);
skinId = String.valueOf(map.get("id"));
response = floorService.switchOpenState(authorization.ssoLogin(),skinId,"true");
}
@Test
public void B_item手机端() throws Exception {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");//设置日期格式
logger.info(df.format(new Date()));
Response response = devSkinService.saveSkin(authorization.hdLoginmabo(),"18740",skinId);
Thread.sleep(70000);
JsonPath jsonCfg = homeService.getCFG(2753);
Assert.assertEquals(jsonCfg.getList("").size(),1,"banner展示数量和配置不符");
String floorId = MatcherString.getString(jsonCfg.getList("").get(0).toString(),"floorId=(.*?),",1);
String dataType = MatcherString.getString(jsonCfg.getList("").get(0).toString(),"dataType=(.*?),",1);
String floorType = MatcherString.getString(jsonCfg.getList("").get(0).toString(),"floorType=(.*?),",1);
response = homeService.floor(authorization.dafuwengLogin(2753),floorType,dataType,"3",floorId);
String s = response.asString();
response = devFloorService.itemSelectedList("18740");
List<Map> listDev = response.jsonPath().getList("data",Map.class);
JsonPath jsonPath=from(s.substring(s.indexOf("{"),s.length()-1));
List<Map> list = jsonPath.getList("list",Map.class);
Assert.assertEquals(list.size(),listDev.size(),"开发者配置和手机端展示数量不符");
}
@Test
public void C_item删除楼层皮肤() throws Exception {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");//设置日期格式
logger.info(df.format(new Date()));
Response response = devSkinService.saveSkin(authorization.hdLoginmabo(),"18740","198");
response.prettyPrint();
response = floorService.deleteSkin(authorization.ssoLogin(),skinId,"1");
response.prettyPrint();
response = floorService.deleteFloor(authorization.ssoLogin(),floorId);
response.prettyPrint();
}
}
package http.cases.FloorTest;
import base.DuibaLog;
import base.DuibaTestBase;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import http.service.Authorization;
import http.service.Manager.FloorService;
import http.service.app.HomeService;
import http.service.hd.DevFloorBannerService;
import http.service.hd.DevSkinService;
import io.restassured.path.json.JsonPath;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import utils.MatcherString;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;
import static io.restassured.path.json.JsonPath.from;
import static utils.StringUtil.getMatcher;
/**
* Created by mabo on 2018/6/8
*/
public class Seckill_FloorTest extends DuibaTestBase {
@Autowired
HomeService homeService;
@Autowired
FloorService floorService;
@Autowired
Authorization authorization;
@Autowired
DevSkinService devSkinService;
@Autowired
DevFloorBannerService devFloorBannerService;
private String skinId=null;
private String floorId=null;
private DuibaLog logger = DuibaLog.getLogger();
@BeforeClass
public void beforeClass(){
try{
Map map = jdbc.findSimpleResult("select * from credits_dev.tb_credits_floor_skin where skin_name = ?","mabo楼层皮肤Sckill");
skinId = String.valueOf(map.get("id"));
map = jdbc.findSimpleResult("select * from credits_dev.tb_credits_floor_code WHERE floor_name= ?","maboSckill");
floorId = String.valueOf(map.get("id"));
Response response = devSkinService.saveSkin(authorization.hdLoginmabo(),"18740","198");
response = floorService.deleteSkin(authorization.ssoLogin(),skinId,"1");
response = floorService.deleteFloor(authorization.ssoLogin(),floorId);
}catch(Exception e){
}
}
//免单秒杀
@Test
public void A_Seckill创建楼层皮肤() throws Exception {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");//设置日期格式
logger.info(df.format(new Date()));
String type = "10";
String dataType = "0";
String name = "maboSckill";
String skinWidth = "640";
String html = "<section class=\"floor-seckill a-fadeinT\">\n" +
" <div class=\"rob-seconds-kill\">\n" +
" <div class=\"seconds-kill-header\">\n" +
" <i class=\"seconds-kill-icon\"></i>\n" +
" <ul class=\"seconds-kill-list\">\n" +
" {@each list as item,index}\n" +
" {@if item.startTime}\n" +
" <li>\n" +
" <a href=\"javascript:void(0)\" class=\"seconds-title\" data-index=\"${index}\">\n" +
" <span class=\"countdown-title\">${item.title}</span>\n" +
" </a>\n" +
" </li>\n" +
" {@/if}\n" +
" {@/each}\n" +
" </ul>\n" +
" </div>\n" +
" <div class=\"seconds-kill-content\">\n" +
" {@each list as item,index}\n" +
" <div class=\"seconds-kill-goods seconds-kill-goods-${index}\" style=\"display: none;\">\n" +
" <div class=\"swiper-wrapper\">\n" +
" {@if item.secondType === 'secondSubject'}\n" +
" {@each item.seckillList as subject}\n" +
" <div class=\"swiper-slide subject-slide\" db-log=\"${subject.stInfo}\">\n" +
" <a href=\"${subject.url}\">\n" +
" <img src=\"${subject.image}\" alt=\"\" class=\"subject-img\">\n" +
" </a>\n" +
" </div>\n" +
" {@/each}\n" +
" {@else if item.secondType === 'secondActivity'}\n" +
" {@each item.seckillList as activity}\n" +
" <div class=\"swiper-slide activity-slide\">\n" +
" <a href=\"${activity.url}\">\n" +
" <img src=\"${activity.image}\" alt=\"\" class=\"activity-img\">\n" +
" </a>\n" +
" <div class=\"activity-info\">\n" +
" <h3 class=\"activity-title\">\n" +
" <a href=\"${activity.url}\">${activity.title}</a>\n" +
" </h3>\n" +
" <p class=\"activity-credits\">${activity.credits + cCreditsUnitName}</p>\n" +
" <p class=\"j-seconds-btn-wrapper\">\n" +
" </p>\n" +
" </div>\n" +
" </div>\n" +
" {@/each}\n" +
" {@/if}\n" +
" </div>\n" +
" </div>\n" +
" {@/each}\n" +
" </div>\n" +
" </div>\n" +
"</section>";
String css = ".floor-seckill {\n" +
" margin-bottom: 0.05rem;\n" +
"}\n" +
".floor-seckill .rob-seconds-kill {\n" +
" overflow: hidden;\n" +
" background-color: #f1f1f1;\n" +
" border: solid #e6e6e6;\n" +
" border-width: 1px 0;\n" +
"}\n" +
".floor-seckill .seconds-kill-header {\n" +
" background-color: #fff;\n" +
" height: 0.33rem;\n" +
" padding: 0.04rem 0 0.08rem 0;\n" +
" overflow: hidden;\n" +
" position: relative;\n" +
"}\n" +
".floor-seckill .seconds-kill-list {\n" +
" position: relative;\n" +
" left: 0.45rem;\n" +
"}\n" +
".floor-seckill .seconds-kill-list li {\n" +
" float: left;\n" +
" font-size: 0.12rem;\n" +
" line-height: 0.215rem;\n" +
" padding: 0 0.15rem;\n" +
" position: relative;\n" +
"}\n" +
".floor-seckill .seconds-kill-list li::after {\n" +
" content: '';\n" +
" position: absolute;\n" +
" right: 0;\n" +
" top: 0.03rem;\n" +
" height: 0.12rem;\n" +
" width: 0;\n" +
" border-left: 1px dotted #ccc;\n" +
"}\n" +
".floor-seckill .seconds-kill-list li:last-child {\n" +
" padding-right: 0;\n" +
"}\n" +
".floor-seckill .seconds-kill-list li:last-child::after {\n" +
" display: none;\n" +
"}\n" +
".floor-seckill .seconds-kill-list li:first-child .seconds-title {\n" +
" padding-left: 0.2rem;\n" +
"}\n" +
".floor-seckill .seconds-kill-list .seconds-title {\n" +
" color: #333;\n" +
" display: block;\n" +
" padding: 0 0.11rem;\n" +
"}\n" +
".floor-seckill .seconds-kill-list .seconds-title.active {\n" +
" background-color: #efefef;\n" +
" border-radius: 0.11rem;\n" +
" padding: 0 0.1rem;\n" +
"}\n" +
".floor-seckill .seconds-kill-list .seconds-title.active .countdown-title {\n" +
" color: #333;\n" +
" font-weight: bold;\n" +
"}\n" +
".floor-seckill .seconds-kill-list .countdown {\n" +
" display: inline-block;\n" +
" font-size: 0.1rem;\n" +
" color: #666;\n" +
"}\n" +
".floor-seckill .seconds-kill-list .countdown-item {\n" +
" display: inline-block;\n" +
" width: 0.15rem;\n" +
" height: 0.15rem;\n" +
" line-height: 0.15rem;\n" +
" margin-top: 0.015rem;\n" +
" margin-left: 0.02rem;\n" +
" border: 1px solid #9e9e9e;\n" +
" background-color: #fff;\n" +
" text-align: center;\n" +
" color: #333;\n" +
"}\n" +
".floor-seckill .seconds-kill-list .split {\n" +
" margin-left: 0.02rem;\n" +
"}\n" +
".floor-seckill .seconds-kill-icon {\n" +
" position: absolute;\n" +
" left: 0;\n" +
" width: 0.73rem;\n" +
" height: 0.215rem;\n" +
" background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJMAAAArCAMAAABLoko/AAABOFBMVEUAAAD/Ojr/Ozv/Ozv/OTn/OTn/OTn/PDz/Ojr/Pj7/OTn/Ozv/Ozv/Ozv/Ozv/Ozv/Ozv/OTn/OTn/OTn/Ojr/Ojr/Ojr/Ozv/Ojr/OTn/Ozv/OTn/OTn/OTn/PDz/OTn/////6xH/a2v/zc3/6BL/Ojn/4xP/RUX/Pj7/8/P/2BX/lCT/VTP/hIT/miP/3BT/PTj/YDD/0Bf/2tr/UlL/eir/rR//0xb/Pzf/Qzb/nyL/sR7/zRf/5RL/SDX/TDT/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gptdHniPtaQH0E2HhQCLOU8w2AAAAAElFTkSuQmCC) no-repeat;\n" +
" background-size: 0.73rem 0.215rem;\n" +
" z-index: 2;\n" +
"}\n" +
".floor-seckill .seconds-kill-content {\n" +
" background-color: #fff;\n" +
" padding: 0 0.1rem 0.08rem 0.1rem;\n" +
"}\n" +
".floor-seckill .seconds-kill-content .activity-info {\n" +
" margin-left: 1.225rem;\n" +
"}\n" +
".floor-seckill .seconds-kill-content .activity-img {\n" +
" float: left;\n" +
" height: auto;\n" +
" width: 1.125rem;\n" +
"}\n" +
".floor-seckill .seconds-kill-content .subject-img {\n" +
" float: left;\n" +
" width: auto;\n" +
" height: 0.7rem;\n" +
"}\n" +
".floor-seckill .seconds-kill-content .activity-title {\n" +
" color: #444;\n" +
" font-size: 0.14rem;\n" +
" line-height: 1.2;\n" +
" overflow: hidden;\n" +
" text-overflow: ellipsis;\n" +
" white-space: nowrap;\n" +
" margin-top: 0.02rem;\n" +
"}\n" +
".floor-seckill .seconds-kill-content .activity-credits {\n" +
" color: #ff3e3e;\n" +
" font-size: 0.12rem;\n" +
" margin: 0.04rem 0 0.1rem 0;\n" +
"}\n" +
".floor-seckill .seconds-kill-goods .swiper-slide {\n" +
" height: 0.7rem;\n" +
"}\n" +
".floor-seckill .seconds-kill-goods .swiper-slide.activity-slide {\n" +
" overflow: hidden;\n" +
" width: 2.3rem;\n" +
" white-space: nowrap;\n" +
"}\n" +
".floor-seckill .seconds-kill-goods .swiper-slide.subject-slide {\n" +
" width: auto;\n" +
"}\n" +
".floor-seckill .activity-btn {\n" +
" line-height: 0.22rem;\n" +
" border-radius: 0.125rem;\n" +
" font-size: 0.12rem;\n" +
" display: inline-block;\n" +
" padding: 0 0.125rem;\n" +
"}\n" +
".floor-seckill .activity-btn.btn-red {\n" +
" background-color: #ff3e3e;\n" +
" border: 1px solid #ff3e3e;\n" +
" color: #fff;\n" +
"}\n" +
".floor-seckill .activity-btn.btn-border-red {\n" +
" border: 1px solid #ff3e3e;\n" +
" background-color: #fff;\n" +
" color: #ff3e3e;\n" +
"}\n" +
".floor-seckill .activity-btn.btn-gray {\n" +
" border: 1px solid #ccc;\n" +
" background-color: #ccc;\n" +
" color: #fff;\n" +
"}";
String js = ";(function(window){\n" +
" 'use strict';\n" +
"\n" +
" var defaultConfig = {\n" +
" // bengin-time && end-time\n" +
" gmt_begin: null,\n" +
" gmt_end: null,\n" +
"\n" +
" // default countdown container element\n" +
" selector: '.countdown',\n" +
" // messages\n" +
" msgPattern :'剩{days}天{hours}时{minutes}分{seconds}秒',\n" +
" msgBefore: '距开团仅剩{beginremain}分钟',\n" +
" msgAfter: '特卖已经结束',\n" +
" msgStartPatternBegin: '剩',\n" +
" msgPrePatternBegin: '剩',\n" +
" msgDayPattern : '{days}天',\n" +
" msgHourPattern : '{hours}时',\n" +
" msgMinPattern : '{minutes}分',\n" +
" msgSecondPattern : '{seconds}秒',\n" +
" msgStartPatternEnd: '',\n" +
" msgPrePatternEnd: '',\n" +
" leadingZeros: false,\n" +
" currentTime: 0,\n" +
" patternType:{//为1时使用原来的msgPattern或msgBefore,为2时使用pattern拼接\n" +
" pre:1,\n" +
" start:1\n" +
" }, \n" +
" hidePattern:[],//可传参数如'{days}',与patternType为2时配合使用,表示取值为0时,要省略的pattern\n" +
" finishCallback: function() {},//倒计时已结束\n" +
" startCallback :function() {},//进行时的倒计时运行前的回调\n" +
" preCallback :function(){}//未开始的倒计时运行前的回调\n" +
" };\n" +
"\n" +
" var Countdown = function(conf) {\n" +
" var cf = $.extend({}, defaultConfig, conf),\n" +
" started = false,\n" +
" interval = 1000,\n" +
" container = $(cf.selector),\n" +
" patterns = [{\n" +
" pattern: '{years}',\n" +
" secs: 31536000\n" +
" }, {\n" +
" pattern: '{months}',\n" +
" secs: 2628000\n" +
" }, {\n" +
" pattern: '{weeks}',\n" +
" secs: 604800\n" +
" }, {\n" +
" pattern: '{days}',\n" +
" secs: 86400\n" +
" }, {\n" +
" pattern: '{hours}',\n" +
" secs: 3600\n" +
" }, {\n" +
" pattern: '{minutes}',\n" +
" secs: 60\n" +
" }, {\n" +
" pattern: '{seconds}',\n" +
" secs: 1\n" +
" }, {\n" +
" pattern: '{secfixedtoten}',\n" +
" secs: 1\n" +
" }, {\n" +
" pattern: '{secfixedtohun}',\n" +
" secs: 1\n" +
" }, {\n" +
" pattern: '{secfixedtothus}',\n" +
" secs: 1\n" +
" }\n" +
"\n" +
" ],\n" +
" patternMap={\n" +
" '{years}':cf.msgYearPattern||'',\n" +
" '{months}':cf.msgMonPattern||'',\n" +
" '{weeks}':cf.msgWeekPattern||'',\n" +
" '{days}':cf.msgDayPattern||'',\n" +
" '{hours}':cf.msgHourPattern||'',\n" +
" '{minutes}':cf.msgMinPattern||'',\n" +
" '{seconds}':cf.msgSecondPattern||'',\n" +
" '{secfixedtoten}':cf.msgSecondFixtotenPattern||'',\n" +
" '{secfixedtohun}':cf.msgSecondFixtohunPattern||'',\n" +
" '{secfixedtothus}':cf.msgSecondFixtothusPattern||''\n" +
" },\n" +
" output,\n" +
" timer,\n" +
"\n" +
"\n" +
" defineInterval = function() {\n" +
" for (var e = patterns.length; e > 0; e--) {\n" +
" var currentPattern = patterns[e - 1];\n" +
"\n" +
" if (cf.msgPattern.indexOf(currentPattern.pattern) !== -1) {\n" +
" interval = currentPattern.secs * 1000;\n" +
" return;\n" +
" }\n" +
" }\n" +
" },\n" +
"\n" +
" outOfInterval = function(beginremain,type) {\n" +
" var tpl = beginremain > 0 ? cf.msgBefore : cf.msgAfter;\n" +
" var minTimer;\n" +
" if (beginremain > 0) {\n" +
" if(type==1){\n" +
" minTimer = setInterval(function() {\n" +
"\n" +
" beginremain -= 1;\n" +
" var number = Math.floor(beginremain / 60);\n" +
" var displayed = cf.leadingZeros && number <= 9 ? \"0\" + number : number;\n" +
" if (beginremain < 0) {\n" +
" window.clearInterval(minTimer);\n" +
" } \n" +
" output = tpl.replace('{beginremain}', displayed);\n" +
"\n" +
" if (container.html() != output) {\n" +
" container.html(output);\n" +
" }\n" +
"\n" +
" }, 1000); \n" +
" }\n" +
"\n" +
"\n" +
" } else {\n" +
" cf.finishCallback(container,output);\n" +
" }\n" +
" },\n" +
"\n" +
" display = function(sec,patternType,isStart,pattern) { \n" +
"\n" +
" var output= (pattern||cf.msgPattern);//默认模板\n" +
"\n" +
" if(isStart){//如果已经开始\n" +
" patternType=patternType.start;\n" +
" }else{//未开始\n" +
" patternType=patternType.pre;\n" +
" }\n" +
" if(patternType==2){//如果要省略0,使用拼接式的模板\n" +
" output=isStart?cf.msgStartPatternBegin:cf.msgPrePatternBegin;\n" +
" }\n" +
" \n" +
" for (var i = 0, len = patterns.length; i < len; i++) {\n" +
" var currentPattern = patterns[i];\n" +
" //获取当前模板,如果patternType不为2,用默认模板\n" +
" var currentTpl=patternType==2?(patternMap[currentPattern.pattern]||''):output;\n" +
" var currentPatternSecs = currentPattern.secs * 10;\n" +
" if (currentTpl.indexOf(currentPattern.pattern) !== -1) {\n" +
" if (currentPattern.pattern === '{secfixedtoten}') {\n" +
" var number = new Number(sec / currentPatternSecs).toFixed(1);\n" +
"\n" +
" } else if (currentPattern.pattern === '{secfixedtohun}') {\n" +
" var number = new Number(sec / currentPatternSecs).toFixed(2);\n" +
"\n" +
" } else if (currentPattern.pattern === '{secfixedtothus}') {\n" +
" var number = new Number(sec / currentPatternSecs).toFixed(3);\n" +
"\n" +
" } else {\n" +
" var number = Math.floor(sec / currentPatternSecs);\n" +
"\n" +
" }\n" +
" var displayed = cf.leadingZeros && number <= 9 ? \"0\" + number : number;\n" +
" sec -= number * currentPatternSecs;\n" +
" // 省略值为0的pattern\n" +
" if(patternType==2){\n" +
" if(cf.hidePattern && Number(displayed)==0 && cf.hidePattern.indexOf(currentPattern.pattern)!==-1){\n" +
" output+='';\n" +
" }else{\n" +
" output+=currentTpl.replace(currentPattern.pattern, displayed);\n" +
" } \n" +
" }else{\n" +
" output = output.replace(currentPattern.pattern, displayed);\n" +
" }\n" +
"\n" +
" }\n" +
" }\n" +
" if(patternType==2){\n" +
" output+= isStart?cf.msgStartPatternEnd:cf.msgPrePatternEnd;\n" +
" }\n" +
" container.html(output);\n" +
" },\n" +
"\n" +
" run = function() {\n" +
" //var sec = Math.abs(cf.gmt_end - (+new Date / 1000)),\n" +
" var newDate = cf.currentTime * 1000 || new Date;\n" +
" var sec = Math.abs(cf.gmt_end * 10 - (+newDate / 100));\n" +
" var beginremain = cf.gmt_begin - (+newDate / 1000);\n" +
" //msgBefore的类型,它可以是默认的分钟倒计时,也可以是天时分秒倒计时\n" +
" var type=cf.msgBefore.indexOf('{beginremain}')!==-1?1:2;\n" +
" if (isStarted(cf.gmt_begin)) {\n" +
" started = true;\n" +
" cf.startCallback(container);\n" +
" display(sec,cf.patternType,started);\n" +
" } else if (beginremain > 0) {\n" +
" cf.preCallback(container);\n" +
"\n" +
" if(type==2 || cf.patternType.pre==2){\n" +
" sec=beginremain*10;\n" +
" display(sec,cf.patternType,started,cf.msgBefore);\n" +
" }else{\n" +
" outOfInterval(beginremain,type);\n" +
" }\n" +
" \n" +
" } else {\n" +
" outOfInterval();\n" +
" }\n" +
"\n" +
" // Vanilla JS alternative to $.proxy\n" +
" timer = window.setInterval(function() {\n" +
" sec--;\n" +
" \n" +
" if (isStarted(cf.gmt_begin) && !isOver(cf.gmt_end)) {\n" +
" if (!started) {\n" +
" sec=Math.abs(cf.gmt_end * 10 - (+newDate / 100));\n" +
" started = true;\n" +
" cf.startCallback(container);\n" +
" }\n" +
" display(sec,cf.patternType,started);\n" +
" \n" +
" }else if(sec>0){\n" +
" if(type==2 || cf.patternType.pre==2){\n" +
" display(sec,cf.patternType,started,cf.msgBefore);\n" +
" }\n" +
" }else if(sec <= 0){// Time over\n" +
" window.clearInterval(timer);\n" +
" outOfInterval(); \n" +
" }\n" +
" }, interval / 10);\n" +
" },\n" +
"\n" +
" init = function() {\n" +
" defineInterval();\n" +
" // Already over\n" +
" if (isOver(cf.gmt_end)) {\n" +
" return outOfInterval();\n" +
" }\n" +
"\n" +
" run();\n" +
" };\n" +
"\n" +
" init();\n" +
"\n" +
" return output;\n" +
" };\n" +
"\n" +
" function isStarted(startTime) {\n" +
" return +new Date() / 1000 >= startTime;\n" +
" }\n" +
"\n" +
" function isOver(endTime) {\n" +
" return +new Date() / 1000 >= endTime;\n" +
" }\n" +
" window.Countdown = Countdown;\n" +
"})(window);\n" +
"\n" +
"\n" +
"// 秒杀\n" +
"var robSecondsKillWrap = $('.rob-seconds-kill-wrap');\n" +
"var robSecondsKillTemplate = $('#j-seconds-kill');\n" +
"var robCountdownTemplate = $('#j-count-down');\n" +
"var robSecondsKillBtnTemplate = $('#j-seconds-kill-btn');\n" +
"var countdown = Countdown;\n" +
"\n" +
"var sendApi = function(url, data, done, noDialog) {\n" +
"\t$.ajax({\n" +
"\t\turl: url,\n" +
"\t\ttype: 'POST',\n" +
"\t\tdataType: 'json',\n" +
"\t\tdata: data,\n" +
"\t\tsuccess: done,\n" +
"\t\tnoDialog: noDialog,\n" +
"\t\terror: function(e) {\n" +
"\t\t\tconsole.log(e.message || '数据异常,请稍后重试');\n" +
"\t\t},\n" +
"\t\tcomplete: function(e) {\n" +
"\t\t\t// do sth\n" +
"\t\t}\n" +
"\t});\n" +
"};\n" +
"\n" +
"var robSecondsKill = {\n" +
"\t list: null,\n" +
"\t swiper: null,\n" +
"\t /**\n" +
"\t * 初始化秒杀\n" +
"\t *\n" +
"\t * @param {Number} index 索引\n" +
"\t */\n" +
"\t initSecondsKill: function(index) {\n" +
"\t\t var titles = $('.seconds-title');\n" +
"\t\t var currTitle = $(titles[+index]);\n" +
"\t\t var contents = $('.seconds-kill-goods');\n" +
"\t\t var currContent = $(contents[+index]);\n" +
"\t\t var startTime = this.list[+index] && this.list[+index].startTime;\n" +
"\t\t var startCountdown = parseInt(startTime / 1000, 10);\n" +
"\t\t \n" +
"\n" +
"\t\t // 只有一个秒杀区间时,结束时间为24:00\n" +
"\t\t // 有两个秒杀区间时,第一个秒杀结束时间为第二个秒杀开始时间,第二个秒杀结束时间为24:00\n" +
"\t\t var endCountdown = startCountdown;\n" +
"\t\t if (this.list.length === 2 && +index === 0) {\n" +
"\t\t\t endCountdown = parseInt(this.list[+index + 1].startTime / 1000, 10);\n" +
"\t\t }\n" +
"\n" +
"\t\t // 重置倒计时\n" +
"\t\t titles.removeClass('active');\n" +
"\t\t currTitle.addClass('active');\n" +
"\t\t titles.find('.countdown').remove();\n" +
"\t\t contents.hide();\n" +
"\t\t currContent.show();\n" +
"\n" +
"\t\t this.swiper && this.swiper.destroy();\n" +
"\t\t this.swiper = new Swiper('.seconds-kill-goods-' + index, {\n" +
"\t\t\t slidesPerView: 'auto',\n" +
"\t\t\t spaceBetween: 10,\n" +
"\t\t\t freeMode: true\n" +
"\t\t });\n" +
"\n" +
"\t\t var countdownTpl = '<div class=\"countdown\"></div>';\n" +
"\t\t var countdownHtml = juicer(countdownTpl, {});\n" +
"\n" +
"\t\t var _this = this;\n" +
"\n" +
"\t\t currTitle.append(countdownHtml);\n" +
"\t\t countdown({\n" +
"\t\t\t selector: $('.countdown', currTitle),\n" +
"\t\t\t leadingZeros: true,\n" +
"\t\t\t gmt_begin: startCountdown,\n" +
"\t\t\t gmt_end: endCountdown,\n" +
"\t\t\t patternType: {\n" +
"\t\t\t\t start: 2,\n" +
"\t\t\t\t pre: 2\n" +
"\t\t\t },\n" +
"\t\t\t msgPrePatternBegin: '距开始',\n" +
"\t\t\t msgStartPatternBegin: '距结束',\n" +
"\t\t\t msgDayPattern: '',\n" +
"\t\t\t msgHourPattern: '<span class=\"countdown-item\">{hours}</span><span class=\"split\">:</span>',\n" +
"\t\t\t msgMinPattern: '<span class=\"countdown-item\">{minutes}</span><span class=\"split\">:</span>',\n" +
"\t\t\t msgSecondPattern: '<span class=\"countdown-item\">{seconds}</span>'\n" +
" });\n" +
"\n" +
" this.checkLogin(this, index);\n" +
" },\n" +
"\n" +
" /**\n" +
" * 检查登录\n" +
" *\n" +
" * @param {Object} _this 传入的this对象\n" +
" * @param {Number} index 当前index值\n" +
" */\n" +
" checkLogin: function(_this, index) {\n" +
" // 如果秒杀类型为秒杀专题则不检查登录和按钮状态并检查埋点\n" +
" if (_this.list[+index].secondType === 'secondSubject') {\n" +
" if(!_this.list[+index].hasShowLog) {\n" +
" _this.list[index].hasShowLog = true;\n" +
" setTimeout(function() {\n" +
" window.DB && window.DB.statistics && window.DB.statistics.initLog();\n" +
" }, 200);\n" +
" }\n" +
" } else {\n" +
" // 监听请先登录按钮事件\n" +
" if (global.uid === 'not_login') {\n" +
" $('.j-seconds-btn-wrapper').html('<a href=\"javascript:void(0)\" class=\"activity-btn btn-border-red j-login-btn\" db-log=\"${stInfo}\">请先登录</a>')\n" +
" $(document).off('click', '.j-login-btn');\n" +
" $(document).on('click', '.j-login-btn', function(e) {\n" +
" e.stopPropagation();\n" +
" // 执行第三方APP登录\n" +
" window.requirelogin();\n" +
" return false;\n" +
" });\n" +
" } else {\n" +
" // 获取并更新按钮状态\n" +
" _this.renderBtnStatus(+index, _this.getActivityIds(_this.list[+index].seckillList));\n" +
" }\n" +
" }\n" +
" },\n" +
"\n" +
"\n" +
"\t /**\n" +
"\t * 获取秒杀按钮状态,并更新\n" +
"\t *\n" +
"\t * @param {String} ids 需要查询的id\n" +
"\t */\n" +
"\t renderBtnStatus: function(index, ids) {\n" +
"\t\t var _this = this;\n" +
"\t\t sendApi('/seckill/getSeckillBtn', {\n" +
"\t\t\t strSeckillIds: ids,\n" +
"\t\t\t firstTime: this.list[+index].startTime\n" +
"\t\t }, function(resp) {\n" +
"\t\t\t var goodsWrap = $('.seconds-kill-goods-' + index);\n" +
"\t\t\t var btnWrap = $('.j-seconds-btn-wrapper', goodsWrap);\n" +
"\t\t\t var btnTpl = '{@if buttonType === 1}'+\n" +
"\t\t\t\t\t\t\t'<a href=\"${creditsUrl}\" class=\"activity-btn btn-border-red\" db-log=\"${stInfo}\">赚'+global.cCreditsUnitName+'</a>'+\n" +
"\t\t\t\t\t\t'{@else if buttonType === 2}'+\n" +
"\t\t\t\t\t\t\t'<a href=\"javascript:void(0)\" class=\"activity-btn btn-gray\" db-log=\"${stInfo}\">'+global.cCreditsUnitName+'不足</a>'+\n" +
"\t\t\t\t\t\t'{@else if buttonType === 3}'+\n" +
"\t\t\t\t\t\t\t'<a href=\"${buttonLink}\" class=\"activity-btn btn-border-red\" db-log=\"${stInfo}\">即将开始</a>'+\n" +
"\t\t\t\t\t\t'{@else if buttonType === 4}'+\n" +
"\t\t\t\t\t\t\t'<a href=\"${buttonLink}\" class=\"activity-btn btn-gray\" db-log=\"${stInfo}\">已抢完</a>'+\n" +
"\t\t\t\t\t\t'{@else if buttonType === 5}'+\n" +
"\t\t\t\t\t\t\t'<a href=\"${buttonLink}\" class=\"activity-btn btn-red\" db-log=\"${stInfo}\">立即抢</a>'+\n" +
"\t\t\t\t\t\t'{@/if}';\n" +
"\t\t\t var btns;\n" +
"\t\t\t var btnHtml;\n" +
"\t\t\t var btnData;\n" +
"\n" +
"\t\t\t if (resp && resp.success) {\n" +
"\t\t\t\t btns = resp.buts;\n" +
"\t\t\t\t // render\n" +
"\t\t\t\t for (var i = 0; i < btns.length; i++) {\n" +
"\t\t\t\t\t btnData = btns[i];\n" +
"\t\t\t\t\t btnData.creditsUrl = resp.creditsUrl;\n" +
"\t\t\t\t\t btnHtml = juicer(btnTpl, btns[i]);\n" +
"\n" +
"\t\t\t\t\t $(btnWrap[i]).html('');\n" +
"\t\t\t\t\t $(btnWrap[i]).append(btnHtml);\n" +
"\t\t\t\t }\n" +
"\t\t\t\t\n" +
"\t\t\t\t if (!_this.list[index].hasShowLog) {\n" +
"\t\t\t\t\t _this.list[index].hasShowLog = true;\n" +
"\t\t\t\t\t window.DB && window.DB.statistics && window.DB.statistics.initLog();\n" +
"\t\t\t\t }\n" +
"\t\t\t }\n" +
"\t\t });\n" +
"\t },\n" +
"\n" +
"\t /**\n" +
"\t * 获取秒杀活动id,拼成类似`1,2`的格式返回\n" +
"\t */\n" +
"\t getActivityIds: function(activities) {\n" +
"\t\t activities = activities || [];\n" +
"\n" +
"\t\t var result = [];\n" +
"\t\t result = activities.map(function(item) {\n" +
"\t\t\t return {\n" +
"\t\t\t\t duibaActivityId: item.activityId,\n" +
"\t\t\t\t operatingActivityId: item.operatingActivityId\n" +
"\t\t\t };\n" +
"\t\t });\n" +
"\t\t return JSON.stringify(result);\n" +
"\t },\n" +
"\n" +
"\t /**\n" +
"\t * 获取秒杀列表\n" +
"\t */\n" +
"\t renderSecondsKillList: function() {\n" +
" var _this = this;\n" +
"\n" +
" if (data && data.length !== 0) {\n" +
"\n" +
" \n" +
"\n" +
" // 秒杀区间数据存下来,方便后面引用\n" +
" _this.list = data.list;\n" +
"\n" +
" // 计算秒杀开始时间标题\n" +
" for (var i = 0; i < _this.list.length; i++) {\n" +
" var date = new Date(_this.list[i].startTime);\n" +
" _this.list[i].title = date.getHours() + '点场';\n" +
" if (_this.list[i].seckillList.length === 0) {\n" +
" _this.list.splice(i, 1);\n" +
" }\n" +
" }\n" +
"\n" +
" if (_this.list.length === 0) {\n" +
" return;\n" +
" }\n" +
"\t\t\t\n" +
"\t\t\t\t // Webp图片优化\n" +
"\t\t\t\t if (typeof ''.ossimg === 'function') {\n" +
" \t\tfor (var i = 0;i < data.list.length;i++){\n" +
"\t\t\t\t\tdata.list[i].seckillList = data.list[i].seckillList.imgWebpArray('image');\n" +
"\t\t\t\t }\n" +
" \t\t\t}\n" +
"\n" +
" // 渲染秒杀区间列表\n" +
" $(\"#renderRoot\").append(juicer(html, yangzuo.extend(data, global)));\n" +
"\n" +
" // 每次切换秒杀区间重新初始化倒计时、按钮状态等\n" +
" $('.seconds-title').on('click', function() {\n" +
" var $target = $(this);\n" +
" _this.initSecondsKill($target.data('index'));\n" +
" });\n" +
"\n" +
" // 初始化第一个秒杀区间\n" +
" _this.initSecondsKill(0);\n" +
" } else {\n" +
" $('.rob-seconds-kill-wrap').hide();\n" +
" $('.top-bar').addClass('top-bar-border');\n" +
" }\n" +
" }\n" +
" };\n" +
"\n" +
"robSecondsKill.renderSecondsKillList();";
//新建banner楼层
Response response = floorService.createFloor(authorization.ssoLogin(),type,dataType,name,html,css,js,skinWidth);
Map<String,Object> map = jdbc.findSimpleResult("select * from credits_dev.tb_credits_floor_code where floor_name=?",name);
floorId = String.valueOf(map.get("id"));
String nameSkin = "mabo楼层皮肤sckill";
String image = "//yun.dui88.com/images/201805/nlkmslg0t0.png";
// 验证码
String stoke="1";
// String floors = "[{\"id\":190,\"name\":\"maboTest\",\"type\":1,\"dataType\":0,\"needSyn\":false,\"syn\":false}]";
String ower = "0";
JSONObject json = new JSONObject();
json.put("id",map.get("id"));
json.put("name",name);
json.put("type",type);
json.put("dataType",map.get("data_type"));
json.put("needSyn",false);
json.put("syn",false);
JSONArray jsonArray = new JSONArray();
jsonArray.add(json);
String floors = jsonArray.toJSONString();
//新建皮肤
response = floorService.insertSkin(authorization.ssoLogin(),nameSkin,image,stoke,floors,ower,skinWidth);
map = jdbc.findSimpleResult("select * from credits_dev.tb_credits_floor_skin where skin_name = ?",nameSkin);
skinId = String.valueOf(map.get("id"));
response = floorService.switchOpenState(authorization.ssoLogin(),skinId,"true");
}
@Test
public void B_Seckill手机端() throws Exception {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");//设置日期格式
logger.info(df.format(new Date()));
Response response = devSkinService.saveSkin(authorization.hdLoginmabo(),"18740",skinId);
Thread.sleep(60000);
JsonPath jsonCfg = homeService.getCFG(2753);
Assert.assertEquals(jsonCfg.getList("").size(),1,"banner展示数量和配置不符");
String floorId = MatcherString.getString(jsonCfg.getList("").get(0).toString(),"floorId=(.*?),",1);
String dataType = MatcherString.getString(jsonCfg.getList("").get(0).toString(),"dataType=(.*?),",1);
String floorType = MatcherString.getString(jsonCfg.getList("").get(0).toString(),"floorType=(.*?),",1);
response = homeService.floor(authorization.dafuwengLogin(2753),floorType,dataType,"3",floorId);
String s = response.asString();
String source = s.substring(s.indexOf("{"),s.length()-1);
JsonPath jsonPath=from(s.substring(s.indexOf("{"),s.length()-1));
String operatingActivityId = "\"operatingActivityId\":(.*?),";
operatingActivityId = getMatcher(operatingActivityId,source,1);
String activityId = "\"activityId\":(.*?),";
activityId = getMatcher(activityId,source,1);
String image = "\"image\":\"(.*?)\",";
image = getMatcher(image,source,1);
String url = "\"url\":\"(.*?)\"}";
url = getMatcher(url,source,1);
Assert.assertEquals(activityId,"820","");
Assert.assertEquals(image,"//yun.dui88.com/images/201801/7de9zo957y.png","");
Assert.assertEquals(operatingActivityId,"25550","");
Assert.assertTrue(url.contains("//activity.m.duibatest.com.cn/SecondsKillActivity/index?id=25550"));
}
@Test
public void C_Seckill删除楼层皮肤() throws Exception {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");//设置日期格式
logger.info(df.format(new Date()));
Response response = devSkinService.saveSkin(authorization.hdLoginmabo(),"18740","198");
response.prettyPrint();
response = floorService.deleteSkin(authorization.ssoLogin(),skinId,"1");
response.prettyPrint();
response = floorService.deleteFloor(authorization.ssoLogin(),floorId);
response.prettyPrint();
}
}
package http.cases.FloorTest;
import base.DuibaLog;
import base.DuibaTestBase;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import http.service.Authorization;
import http.service.Manager.FloorService;
import http.service.app.HomeService;
import http.service.hd.DevFloorBannerService;
import http.service.hd.DevFloorShowcaseService;
import http.service.hd.DevSkinService;
import io.restassured.path.json.JsonPath;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import utils.MatcherString;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;
import static io.restassured.path.json.JsonPath.from;
/**
* Created by mabo on 2018/6/7
* 橱窗楼层
*/
public class Showcase_FloorTest extends DuibaTestBase {
@Autowired
HomeService homeService;
@Autowired
FloorService floorService;
@Autowired
Authorization authorization;
@Autowired
DevSkinService devSkinService;
@Autowired
DevFloorBannerService devFloorBannerService;
@Autowired
DevFloorShowcaseService devFloorShowcaseService;
private String skinId=null;
private String floorId=null;
private DuibaLog logger = DuibaLog.getLogger();
@BeforeClass
public void beforeClass(){
try{
Map map = jdbc.findSimpleResult("select * from credits_dev.tb_credits_floor_skin where skin_name = ?","mabo楼层皮肤Showcase");
skinId = String.valueOf(map.get("id"));
map = jdbc.findSimpleResult("select * from credits_dev.tb_credits_floor_code WHERE floor_name= ?","maboShowcase");
floorId = String.valueOf(map.get("id"));
Response response = devSkinService.saveSkin(authorization.hdLoginmabo(),"18740","198");
response = floorService.deleteSkin(authorization.ssoLogin(),skinId,"1");
response = floorService.deleteFloor(authorization.ssoLogin(),floorId);
}catch(Exception e){
}
}
@Test
public void A_Showcase创建楼层皮肤() throws Exception {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");//设置日期格式
logger.info(df.format(new Date()));
String type = "8";
String dataType = "0";
String name = "maboShowcase";
String skinWidth = "640";
String html = "<section class=\"floor-showcase a-fadeinT\">\n" +
" <a class=\"main-showcase\" href=\"${list[0].btnLink}\" db-log=\"${list[0].stInfo}\">\n" +
" <img src=\"${list[0].image}\" alt=\"\">\n" +
" {@if list[0].countDownTime}\n" +
" <div class=\"showcase-countdown\">\n" +
" <span>距开始</span><span class=\"countdown-time\">00:00:00</span>\n" +
" </div>\n" +
" {@/if}\n" +
" </a>\n" +
" <div class=\"side-showcase\">\n" +
" <a href=\"${list[1].btnLink}\" db-log=\"${list[1].stInfo}\">\n" +
" <div class=\"top-showcase\">\n" +
" <img src=\"${list[1].image}\" alt=\"\">\n" +
" </div>\n" +
" </a>\n" +
" <a href=\"${list[2].btnLink}\" db-log=\"${list[2].stInfo}\">\n" +
" <div class=\"bottom-showcase\">\n" +
" <img src=\"${list[2].image}\" alt=\"\">\n" +
" </div>\n" +
" </a>\n" +
" </div>\n" +
"</section>";
String css = ".floor-showcase {\n" +
" width: 100%;\n" +
" margin: 0.042666666666666665rem 0;\n" +
" background: #fff;\n" +
" position: relative;\n" +
" border: solid #EEE;\n" +
" border-width: 1px 0 ;\n" +
" min-height: 1.0752rem;\n" +
"}\n" +
".floor-showcase a {\n" +
" display: block;\n" +
"}\n" +
".floor-showcase img {\n" +
" width: 100%;\n" +
" height: 100%;\n" +
"}\n" +
".floor-showcase .main-showcase {\n" +
" position: absolute;\n" +
" left: 0;\n" +
" top: 0;\n" +
" bottom: 0;\n" +
" width: 1.6042666666666667rem;\n" +
" height: 1.0666666666666667rem;\n" +
" overflow: hidden;\n" +
" border-right: 1px solid #EEE;\n" +
"}\n" +
".floor-showcase .main-showcase .showcase-countdown {\n" +
" display: none;\n" +
" font-size: 0.1024rem;\n" +
" position: absolute;\n" +
" top: 0.49493333333333334rem;\n" +
" left: 0.09386666666666667rem;\n" +
" background: rgba(51, 51, 51, 0.9);\n" +
" border-radius: 0.017066666666666667rem;\n" +
" min-width: 0.6997333333333333rem;\n" +
" height: 0.14933333333333335rem;\n" +
" line-height: 0.14933333333333335rem;\n" +
" padding: 0 0.021333333333333333rem;\n" +
" text-align: center;\n" +
" color: #FFF;\n" +
" white-space: nowrap;\n" +
" -webkit-transform: scale(0.9);\n" +
" transform: scale(0.9);\n" +
" -webkit-transform-origin: 0 0;\n" +
" transform-origin: 0 0;\n" +
" color: #979797;\n" +
"}\n" +
".floor-showcase .main-showcase .showcase-countdown .countdown-time {\n" +
" margin-left: 0.017066666666666667rem;\n" +
" color: #FFF;\n" +
"}\n" +
".floor-showcase .side-showcase {\n" +
" padding-left: 1.6085333333333334rem;\n" +
" overflow: hidden;\n" +
"}\n" +
".floor-showcase .side-showcase .top-showcase {\n" +
" width: 1.5957333333333332rem;\n" +
" height: 0.5333333333333333rem;\n" +
" border-bottom: 1px solid #EEE;\n" +
"}\n" +
".floor-showcase .side-showcase .bottom-showcase {\n" +
" width: 1.5957333333333332rem;\n" +
" height: 0.5333333333333333rem;\n" +
"}";
String js = "if (data && data.list && data.list.length) {\n" +
" if (data.list.length !== 3) return; // 橱窗位数据不为3不显示\n" +
" var _list =[];\n" +
" for (var i = 0; i < data.list.length; i++) {\n" +
" _list[data.list[i].place - 1] = data.list[i];\n" +
" }\n" +
" data.list = _list;\n" +
" $(\"#renderRoot\").append(juicer(html, data));\n" +
" /**\n" +
" * 橱窗倒计时\n" +
" */\n" +
" var caseCountDownTime = data.list[0].countDownTime;\n" +
"\n" +
" if (caseCountDownTime) {\n" +
"\t$('.showcase-countdown').show();\n" +
"\tvar date = new Date();\n" +
"\tvar endTime = date.getFullYear() + '/' + (date.getMonth() + 1) + '/' +date.getDate() + ' ' + caseCountDownTime;\n" +
"\tcountDown((new Date(endTime)).getTime()); \n" +
" }\n" +
"\n" +
" function countDown(endTime) {\n" +
"\tvar countDownTime = '';\n" +
"\tcount();\n" +
"\tfunction count() {\n" +
"\t var now = (new Date()).getTime();\n" +
"\t var t = endTime - now;\n" +
"\t if (t <= 0) {\n" +
"\t\t$('.showcase-countdown').hide();\n" +
"\t\treturn;\n" +
"\t }\n" +
"\t var hour = Math.floor(t / 1000 / 60 / 60 % 24);\n" +
"\t var min = Math.floor(t / 1000 / 60 % 60);\n" +
"\t var second = Math.floor(t / 1000 % 60);\n" +
"\t hour = hour < 10 ? '0' + hour : hour;\n" +
"\t min = min < 10 ? '0' + min : min;\n" +
"\t second = second < 10 ? '0' + second : second;\n" +
"\t countDownTime = hour + ':' + min + ':' + second;\n" +
"\t $('.showcase-countdown .countdown-time').text(countDownTime);\n" +
"\t timer = setTimeout(function() {\n" +
"\t\tcount();\n" +
"\t }, 1000);\n" +
"\t}\n" +
" }\n" +
"}";
//新建banner楼层
Response response = floorService.createFloor(authorization.ssoLogin(),type,dataType,name,html,css,js,skinWidth);
Map<String,Object> map = jdbc.findSimpleResult("select * from credits_dev.tb_credits_floor_code where floor_name=?",name);
floorId = String.valueOf(map.get("id"));
String nameSkin = "mabo楼层皮肤showcase";
String image = "//yun.dui88.com/images/201805/nlkmslg0t0.png";
// 验证码
String stoke="1";
// String floors = "[{\"id\":190,\"name\":\"maboTest\",\"type\":1,\"dataType\":0,\"needSyn\":false,\"syn\":false}]";
String ower = "0";
JSONObject json = new JSONObject();
json.put("id",map.get("id"));
json.put("name",name);
json.put("type","8");
json.put("dataType",map.get("data_type"));
json.put("needSyn",false);
json.put("syn",false);
JSONArray jsonArray = new JSONArray();
jsonArray.add(json);
String floors = jsonArray.toJSONString();
//新建皮肤
response = floorService.insertSkin(authorization.ssoLogin(),nameSkin,image,stoke,floors,ower,skinWidth);
map = jdbc.findSimpleResult("select * from credits_dev.tb_credits_floor_skin where skin_name = ?",nameSkin);
skinId = String.valueOf(map.get("id"));
response = floorService.switchOpenState(authorization.ssoLogin(),skinId,"true");
}
@Test
public void B_Showcase手机端() throws Exception {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");//设置日期格式
logger.info(df.format(new Date()));
Response response = devSkinService.saveSkin(authorization.hdLoginmabo(),"18740",skinId);
Thread.sleep(60000);
JsonPath jsonCfg = homeService.getCFG(2753);
Assert.assertEquals(jsonCfg.getList("").size(),1,"banner展示数量和配置不符");
String floorId = MatcherString.getString(jsonCfg.getList("").get(0).toString(),"floorId=(.*?),",1);
String dataType = MatcherString.getString(jsonCfg.getList("").get(0).toString(),"dataType=(.*?),",1);
String floorType = MatcherString.getString(jsonCfg.getList("").get(0).toString(),"floorType=(.*?),",1);
response = homeService.floor(authorization.dafuwengLogin(2753),floorType,dataType,"3",floorId);
String s = response.asString();
JsonPath jsonPath=from(s.substring(s.indexOf("{"),s.length()-1));
List<Map> list = jsonPath.getList("list",Map.class);
response = devFloorShowcaseService.getShowcaseContent(authorization.hdLoginmabo(),"18740");
List<Map> listDev = response.jsonPath().getList("data",Map.class);
//开发者配置和手机端配置校验
for (int i = 0; i < listDev.size(); i++) {
Assert.assertEquals(listDev.get(i).get("relationTitle"),list.get(i).get("relationTitle"),"relationTitle开发者配置和手机端展示不符");
Assert.assertEquals(listDev.get(i).get("image"),list.get(i).get("image"),"image开发者配置和手机端展示不符");
Assert.assertEquals(listDev.get(i).get("relationImage"),list.get(i).get("relationImage"),"relationImage开发者配置和手机端展示不符");
}
}
@Test
public void C_Showcase删除楼层皮肤() throws Exception {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");//设置日期格式
logger.info(df.format(new Date()));
Response response = devSkinService.saveSkin(authorization.hdLoginmabo(),"18740","198");
response.prettyPrint();
response = floorService.deleteSkin(authorization.ssoLogin(),skinId,"1");
response.prettyPrint();
response = floorService.deleteFloor(authorization.ssoLogin(),floorId);
response.prettyPrint();
}
}
package http.cases.FloorTest;
import base.DuibaLog;
import base.DuibaTestBase;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import http.service.Authorization;
import http.service.Manager.FloorService;
import http.service.app.HomeService;
import http.service.hd.DevFloorBannerService;
import http.service.hd.DevSkinService;
import io.restassured.path.json.JsonPath;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import utils.MatcherString;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;
import static io.restassured.path.json.JsonPath.from;
/**
* Created by mabo on 2018/6/8
* 签到楼层
*/
public class Sign_FloorTest extends DuibaTestBase {
@Autowired
HomeService homeService;
@Autowired
FloorService floorService;
@Autowired
Authorization authorization;
@Autowired
DevSkinService devSkinService;
@Autowired
DevFloorBannerService devFloorBannerService;
private String skinId=null;
private String floorId=null;
private DuibaLog logger = DuibaLog.getLogger();
@BeforeClass
public void beforeClass(){
try{
Map map = jdbc.findSimpleResult("select * from credits_dev.tb_credits_floor_skin where skin_name = ?","mabo楼层皮肤Sign");
skinId = String.valueOf(map.get("id"));
map = jdbc.findSimpleResult("select * from credits_dev.tb_credits_floor_code WHERE floor_name= ?","maboSign");
floorId = String.valueOf(map.get("id"));
Response response = devSkinService.saveSkin(authorization.hdLoginmabo(),"18740","198");
response = floorService.deleteSkin(authorization.ssoLogin(),skinId,"1");
response = floorService.deleteFloor(authorization.ssoLogin(),floorId);
}catch(Exception e){
}
}
@Test
public void A_sign创建楼层皮肤() throws Exception {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");//设置日期格式
logger.info(df.format(new Date()));
String type = "11";
String dataType = "0";
String name = "maboSign";
String skinWidth = "750";
String html = "<section class=\"floor-top-floorsign\">\n" +
" <div class=\"sign-box\">\n" +
" <div class=\"add-credits\">{@if sign.canSign}今日签到可获得<span class=\"price\">${sign.credits}</span>元转豆{@else}明日签到可获得<span class=\"price\">${sign.nextCredits}</span>元转豆{@/if}</div>\n" +
" {@if sign.canSign}\n" +
" <div class=\"sign-text\" db-log=\"${sign.stInfo}\" id=\"sign-action\" data-can-sign=\"1\">签到</div>\n" +
" {@else}\n" +
" <div class=\"sign-text done\" db-log=\"${sign.stInfo}\" id=\"sign-action\" data-can-sign=\"0\">已签到</div>\n" +
" {@/if}\n" +
" </div>\n" +
"\n" +
" <div class=\"model\" style=\"display:none;\">\n" +
" <div class=\"model-box\">\n" +
" <div class=\"model-head\">\n" +
" <div class=\"icon\"></div>\n" +
" <div class=\"close-but\"></div>\n" +
" </div>\n" +
" <div class=\"model-body\">\n" +
" <div class=\"model-title\">签到成功</div>\n" +
" <div class=\"model-prompt\">明天签到可领取6转豆哦~</div>\n" +
" </div>\n" +
" <div class=\"model-footer\">\n" +
" <div class=\"model-confirm\">确认</div>\n" +
" </div>\n" +
" </div>\n" +
" </div>\n" +
"\n" +
" </section> ";
String css = ".floor-top-floorsign {\n" +
" width: 100%;\n" +
" display: -webkit-box;\n" +
" display: -ms-flexbox;\n" +
" display: flex;\n" +
" -webkit-box-orient: horizontal;\n" +
" -webkit-box-direction: normal;\n" +
" -ms-flex-direction: row;\n" +
" flex-direction: row;\n" +
" -webkit-box-pack: center;\n" +
" -ms-flex-pack: center;\n" +
" justify-content: center;\n" +
"}\n" +
".floor-top-floorsign .sign-box {\n" +
" width: 13.952rem;\n" +
" height: 3.41333333rem;\n" +
" background-image: url('//yun.duiba.com.cn/h5/floor/sign/sign-in.png');\n" +
" background-size: 100% 100%;\n" +
" display: -webkit-box;\n" +
" display: -ms-flexbox;\n" +
" display: flex;\n" +
" -webkit-box-orient: horizontal;\n" +
" -webkit-box-direction: normal;\n" +
" -ms-flex-direction: row;\n" +
" flex-direction: row;\n" +
" -webkit-box-pack: justify;\n" +
" -ms-flex-pack: justify;\n" +
" justify-content: space-between;\n" +
"}\n" +
".floor-top-floorsign .sign-box .add-credits {\n" +
" margin-left: 3.15733333rem;\n" +
" margin-top: 1.28rem;\n" +
" font-size: 0.68266667rem;\n" +
" font-weight: bold;\n" +
" color: #fff;\n" +
" letter-spacing: 0.04266667rem;\n" +
" text-indent: 0.04266667rem;\n" +
"}\n" +
".floor-top-floorsign .sign-box .add-credits .price {\n" +
" font-size: 1.06666667rem;\n" +
" position: relative;\n" +
" top: 0.08533333rem;\n" +
" color: #fff16a;\n" +
"}\n" +
".floor-top-floorsign .sign-box .sign-text {\n" +
" width: 2.00533333rem;\n" +
" height: 2.00533333rem;\n" +
" font-size: 0.59733333rem;\n" +
" color: #ff5b5b;\n" +
" font-weight: bold;\n" +
" margin-right: 0.34133333rem;\n" +
" margin-top: 0.832rem;\n" +
" text-align: center;\n" +
" line-height: 2.00533333rem;\n" +
" letter-spacing: 0.08533333rem;\n" +
" text-indent: 0.08533333rem;\n" +
"}\n" +
".floor-top-floorsign .sign-box .sign-text.done {\n" +
" font-size: 0.46933333rem;\n" +
" opacity: .7;\n" +
"}\n" +
"/*模态框*/\n" +
".model {\n" +
" width: 100%;\n" +
" position: fixed;\n" +
" top: 0;\n" +
" bottom: 0;\n" +
" background-color: rgba(0, 0, 0, 0.5);\n" +
" z-index: 9999;\n" +
" display: -webkit-box;\n" +
" display: -ms-flexbox;\n" +
" display: flex;\n" +
" -webkit-box-pack: center;\n" +
" -ms-flex-pack: center;\n" +
" justify-content: center;\n" +
" -webkit-box-align: center;\n" +
" -ms-flex-align: center;\n" +
" align-items: center;\n" +
"}\n" +
".model .model-box {\n" +
" width: 13.65333333rem;\n" +
" height: 8.61866667rem;\n" +
" background-color: #fff;\n" +
" border-radius: 8px;\n" +
"}\n" +
".model .model-box .model-head {\n" +
" width: 100%;\n" +
" height: 2.688rem;\n" +
" display: -webkit-box;\n" +
" display: -ms-flexbox;\n" +
" display: flex;\n" +
" -webkit-box-orient: horizontal;\n" +
" -webkit-box-direction: normal;\n" +
" -ms-flex-direction: row;\n" +
" flex-direction: row;\n" +
" -webkit-box-pack: end;\n" +
" -ms-flex-pack: end;\n" +
" justify-content: flex-end;\n" +
" position: relative;\n" +
"}\n" +
".model .model-box .model-head .icon {\n" +
" width: 4.11733333rem;\n" +
" height: 4.20266667rem;\n" +
" position: absolute;\n" +
" left: 50%;\n" +
" background-image: url('img/xiong-icon.png');\n" +
" margin-left: -2.05866667rem;\n" +
" margin-top: -2.32533333rem;\n" +
" background-size: 100% 100%;\n" +
"}\n" +
".model .model-box .model-head .close-but {\n" +
" width: 0.512rem;\n" +
" height: 0.512rem;\n" +
" margin: 0.512rem 0.512rem 0 0;\n" +
" background-size: 100% 100%;\n" +
" background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAMAAADXqc3KAAAAOVBMVEUAAACqrrmqrrmqrrmqrrmqrrmqrrmqrrmqrrmqrrmqrrmqrrmqrrmqrrmqrrmqrrmqrrmqrrmqrrm/77LuAAAAEnRSTlMAKPLA5jwKmwyeOemfYUSgYxqFJioEAAAAcklEQVQoz23RSQ7AIAxDUUNHSqFt7n/YEgnJksGLLN5fBkDFsN3Pa4/6uRztXtFudVu/XtQDwCLeS1JnGZ2Fzm1e6FLoUrL7uGpmM9+XFtLU1xLtmHnA1os6WMR7UWehZ3cWdRZ1FrqUghDpLMlf4T7uB2WsBggrQzA4AAAAAElFTkSuQmCC');\n" +
"}\n" +
".model .model-box .model-body {\n" +
" width: 100%;\n" +
" height: 3.84rem;\n" +
" text-align: center;\n" +
"}\n" +
".model .model-box .model-body .model-title {\n" +
" font-size: 0.64rem;\n" +
" color: #44484c;\n" +
" padding: 0.42666667rem 0;\n" +
"}\n" +
".model .model-box .model-body .model-prompt {\n" +
" font-size: 0.512rem;\n" +
" color: #a9afb8;\n" +
" padding: 0.42666667rem 0;\n" +
"}\n" +
".model .model-box .model-footer {\n" +
" width: 100%;\n" +
" height: 2.048rem;\n" +
" line-height: 2.048rem;\n" +
" text-align: center;\n" +
" border-top: 0.02133333rem solid #e7e7e7;\n" +
"}\n" +
".model .model-box .model-footer .model-confirm {\n" +
" width: 100%;\n" +
" height: 100%;\n" +
" font-size: 0.64rem;\n" +
" color: #6da6fe;\n" +
"}\n" +
"/***弹出层***/\n" +
".report-modal-sign {\n" +
" display: none;\n" +
" position: fixed;\n" +
" top: 0;\n" +
" right: 0;\n" +
" bottom: 0;\n" +
" left: 0;\n" +
" background-color: rgba(0, 0, 0, 0) !important;\n" +
" z-index: 999;\n" +
"}\n" +
".report-modal-sign .dialog-sign {\n" +
" position: absolute;\n" +
" top: 7.5rem;\n" +
" left: 50%;\n" +
" -webkit-transform: translate(-50%, 0);\n" +
" transform: translate(-50%, 0);\n" +
" width: 7.175rem;\n" +
" height: 8.225rem;\n" +
" background-size: 100% 100%;\n" +
" text-align: center;\n" +
" -webkit-background-position-y: -0.5rem;\n" +
" background-position-y: -0.5rem;\n" +
" background-color: rgba(0, 0, 0, 0.6);\n" +
" border-radius: 0.25rem;\n" +
"}\n" +
"/**签到服务**/\n" +
".report-modal-sign .signSuccess {\n" +
" background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAR8AAAFJCAMAAACVXtmVAAAC9FBMVEUAAAD///+QwaMr4Th2mMWBsNzujbXujbTvkb3g+M+Kw+/ujbTujbTujbR2mMWKw+8r4TiKw++Kw+/ujbQr4Tgr4Tilu9nV4O7zrcrujbR2mMYr4TiKw++Kw+92mMX8/aqp/cn8/ap2mMXujbR2mMX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pblPh/8QoPJs82Hnt+o2rlYnmpalTe/Yd6gwRLSHBRDz29Y66YIlqK1jnjzG8OUberFG+e7uUQSYeY3/Pm0OPMbBqc538/CC3cByXItFmp+w//54sxvPKdM30yAl26xksih3/35HmUZMQCg5lZriRzCzW/49nfO/EaGMoyCbcwtE0QOfT4fNpmrB6bVqEuSM+JfXV/kW608//qiQLt76fzVGypZA5oBfVWhXY25a+6pbEfEPuej0W7GbzsrsHqfUrlOQH3OZ5R6ON26AtMe1WjHGSKFQa6fTNWYXi81A2wF+8rjP18/FfrLjVbxZ78efwS2yhT93Uk53uLp7f2U4P1rfMQE20tKv3a9Lvu0icigt/nn4PPPi5tOzxnPmE5j8np/lsigl/dTeDKdBVQE20gFLC3q812O5dPL+yls3uuvsQJYTDumKvU7dI5IoYf3U7ie046pEcPpSlPU7xSRQy/vp7D57//UTLA8ekB/kf7+T4j+zDXpvSV2E8B0Ds0Snn56ez+Fx3//eawJ9+J1//lf5ak3oHy8nl/8M6NGgxwj0pgBfdeM9fPTYPj8Hec3cP4H58einA8YeZw/5DMncX6Vz/iM889BmoXK5OhkjObnByQ271+4MB/MB/PBfLwwHyH2bJ+J+bAdWN/eivmwbWm3d2E+TLva7S3Yf9i2ttcfwHzYZm7fg/tXSKeB47UiyiISUdz180ERJUkiaidwrFNEWUIiajlwPFNEmUMi6qAOTPW7iigrSFQdB6bHiijJ6N565XzA7iiiLCXRtREYFiqiJGeR6NqnM7qPuOWzjEQZY4tfoLD9J5sX74z4RBFlW3Sbs2MH+Kni4pkT+XgIWX4EPC4LOxkmo917XLN3bIBf0k9EHQyTS6O8c3nMXD5j4wZdfXXp9TMh6SxKLpmzQoKPFkIIIYQQQgghhBBCCCGEEEII/WgPDgQAAAAABPlbrzBABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAT3kZS0gfutqiAAAAAElFTkSuQmCC');\n" +
"}\n" +
".report-modal-sign .signFail {\n" +
" background-image: url('data:image/png;base64,iVBORw0KGg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ZeV//M5H1E7tVEfF4E0rkc1375z3xdT62f7m5PuNU3zTrehKIp1oRD1NnmmI2tc3yj67+z5oHyvibioEW/p7rBNPFGVB4xKNo1VCt1uJB61g6HQSFrzyS2Yeo8nCW/2MFS6fDoLCGR/PmoSqdN/xf+1k6jYHCAx7RbA1larM8xFKWTovWgtS1uzyq1icM96nFw6xmKXUq1pVZmPuM//o8x0OtWMJSaizeuSW87NSC86rzkofbwFJrH0hc5Av17mNNZPPxHZfZvIml1o61kpXnCY9B6+1cp9OZe9viCltZioXv7V/W8KTosm25zkKIZ3xYDqR2XXYdgiBjNx+WpWlPh7Gx49An94APyebUdjx+yw7thZ78s7t8ONZvSPGe1Wfx2MF9e28a9y89ej6UcNat3790dfrnFSGEEEIIIYQQQgghhBBCyK/24EAAAAAAQJC/9SBXAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADATNYG1mx06Yo4AAAAASUVORK5CYII=');\n" +
"}\n" +
".report-modal-sign .signAgain {\n" +
" background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAR8AAAFJCAMAAACVXtmVAAAC8VBMVEUAAAD////kloOSwNt2mMWlubr/ZgHxqMDujbR2mMXujbTujbTujbSKw+//ZgHujbSSrdGKw++Kw+/ujbT/ZgF2mMX/ZgGyxd+mvNrzr8t2mMaKw+/l5eWKw+/ujbTwqv3/3T92mMX////ujbTujbSKw+/P2+vyqMbxnsDujbT09/r+///zqsiKw++p/cn8/ar/ZgGKw+////+Kw+92mMX/ZgH/ZgHl5eWKw++Kw+/09PT/ZgHwqv2p/cl/n8n8/arl5eX/ZgHujbT////ujbSKw+92mMV2mMXujbTujbSKw+/ujbR2mMX/ZgHwqv2p/cn8/arl5eXwqv2p/cn8/aqKw+/zr8v/3T/ujbTwqv2p/cn8/ar/3T/////y8vLwqv2p/cn8/ar/ZgH/3T/s8PXujbTnkbj/3T//3T////+xxN7b5PDl5eX8/aqp/cn////l5eX+awvl5eX/3T//3T/l5eXl5eX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7iAu7nIUwxFULB9fa/LWvATAtMo2t4fCjzDD8VgBAS7/aSzlvyEoFQgu/3keJYfmtkIBnb7eWPRzwoEA7v9PLboJ4RgYLOfep7th2Y4AoHNfnKW/cxBILDZzz0TPyBbRJv9CGw/MDsgm/1cDPwE4yeoP8H65Zn+pxZ3Uxv0P4z++eYdjPGdm0H/zLj+4pvuX7jfxAfXX1QB0gHr+n3T4f6O3/+hAXX/Z8eu4ji37h/yTbUXaptAdT9l44rF9fb6Yd9/vvmtpz5Duv+8vlgcV+aUH5wyXN8hNYfjijt3IMf8iI8M+sMLkJ5/9T+0ycn9LfXZPsZPCEhv2KefB1xJtHeZ9odd7ZyO0cijzHTAD9fRZdIfdnVwesqRR5mATRjJlUh7I8+isZ0zYCnyKJuxCUO4Uml7x9Dzro0zYiDyKPNEzOQ29w90NhoNnk7OmGHIq+zDTCZx/8Kr1sY/7bS+4owp74+8yklbpxfN67fveY33b19zTMYjz1K2BDM4z9lAW0dna2trZ0cbZ0K5l//7b4vIqD53ObeYhbzMBNbi7hRgFi+zHnEE5xbLvVucVcr0I4i4p2egty9Wezi1G1OcHcK5RLl3Ox+qTZwwFf8i6trgKR/v5ZWLov/mmUumiuRD5YPnnBuMLl86cJjXK09AQEBAQMCP9uBAAAAAAECQv/UgVwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAsBTowPWa7HE1pQAAAABJRU5ErkJggg==');\n" +
"}\n" +
"/*******/\n" +
".report-modal-sign .dialog-sign p {\n" +
" display: block;\n" +
" text-align: center;\n" +
" color: #fff;\n" +
"}\n" +
".report-modal-sign .dialog-sign p.signTip-sign {\n" +
" font-size: 0.65rem;\n" +
" margin-top: 5.25rem;\n" +
" margin-bottom: 0.25rem;\n" +
"}\n" +
".report-modal-sign .dialog-sign p.nextText-sign {\n" +
" font-size: 0.7rem;\n" +
"}\n" +
".report-modal-sign .dialog-sign p.nextTextColor {\n" +
" color: #e97883;\n" +
"}\n" +
".ddmx {\n" +
" color: #cecece;\n" +
" font-size: 0.45rem;\n" +
" padding-top: 0.25rem;\n" +
"}";
String js = ";(function(window,undefined){\n" +
" 'use strict';\n" +
"\n" +
" var modelBox = {\n" +
" init:function(){\n" +
" var _this = this;\n" +
" this.modelEle = $('.model');\n" +
" this.prompt = $('.model-prompt');\n" +
" this.title = $('.model-title');\n" +
"\n" +
" $('.model-confirm').on('click',function(){\n" +
" _this.hide();\n" +
" });\n" +
"\n" +
" $('.close-but').on('click',function(){\n" +
" _this.hide();\n" +
" });\n" +
"\n" +
" },\n" +
" show:function(){\n" +
" this.modelEle.show();\n" +
" return this;\n" +
" },\n" +
" hide:function(){\n" +
" this.modelEle.hide();\n" +
" return this;\n" +
" },\n" +
" closeModel:function(callback,time){\n" +
" var times,\n" +
" _this = this;\n" +
"\n" +
" if(typeof callback === 'number')\n" +
" time = callback;\n" +
" time = time || 1500;\n" +
" //定时关闭模态框\n" +
" times = setTimeout(function(){\n" +
" _this.hide();\n" +
" },time);\n" +
"\n" +
" return this;\n" +
" },\n" +
" setTitle:function(text){\n" +
" this.title.text(text);\n" +
" return this;\n" +
" },\n" +
" setPrompt:function(text){\n" +
" this.prompt.text(text);\n" +
" return this;\n" +
" }\n" +
" };\n" +
"\n" +
" modelBox.init();\n" +
" /**\n" +
" * 签到服务\n" +
" */\n" +
" SignService.$inject = [\"$q\", \"$http\", \"$Interval\"];\n" +
" function SignService($q, $http, $Interval) {\n" +
" var SIGN_URL = \"/sign/doSign\";\n" +
" var GET_SIGN_RESULT_URL = \"/sign/signResult\";\n" +
" var TIME = 8; //重复获取次数\n" +
"\n" +
" var SIGN_STATUE_WITE = 0;\n" +
" var SIGN_STATUE_SUCCESS = 1;\n" +
" var SIGN_STATUE_ERROR = 2;\n" +
"\n" +
" function doSign() {\n" +
" var promiss = $q.defer();\n" +
" $http.jsonp(SIGN_URL).then(resolve, reject);\n" +
" function resolve(result) {\n" +
" if (result.success) {\n" +
" getSignResult(promiss);\n" +
" } else {\n" +
" promiss.reject(result.message);\n" +
" }\n" +
" }\n" +
" function reject(message) {\n" +
" promiss.reject(message);\n" +
" }\n" +
" return promiss.promise;\n" +
" }\n" +
"\n" +
" function getSignResult(promiss) {\n" +
" var i = 1;\n" +
" var hasResult = false;\n" +
" var p = $Interval(function () {\n" +
" $http.jsonp(GET_SIGN_RESULT_URL).then(function (result) {\n" +
" if (hasResult) {\n" +
" return;\n" +
" }\n" +
" if (result.state != SIGN_STATUE_WITE) {\n" +
" $Interval.cancel(p);\n" +
" }\n" +
" if (result.state == SIGN_STATUE_SUCCESS) {\n" +
" hasResult = true;\n" +
" var ru = {};\n" +
" yangzuo.extend(ru, result);\n" +
" promiss.resolve(ru);\n" +
" return;\n" +
" }\n" +
" if (result.state == SIGN_STATUE_ERROR) {\n" +
" hasResult = true;\n" +
" promiss.reject(result.message);\n" +
" return;\n" +
" }\n" +
" promiss.notify(i);\n" +
" i++;\n" +
" }, function (message) {\n" +
" promiss.reject(message);\n" +
" $Interval.cancel(p);\n" +
" });\n" +
" }, 400, TIME);\n" +
" }\n" +
" return {\n" +
" doSign: doSign\n" +
" }\n" +
" }\n" +
" yangzuo.service(\"NewSignService\", SignService);\n" +
" var sign = data;\n" +
" var timer;\n" +
" var model = {};\n" +
" model.sign = sign;\n" +
" yangzuo.extend(model, global);\n" +
" $(\"#renderRoot\").append(juicer(html, model));\n" +
"\n" +
" yangzuo.on(\"updateCreditsAndRecord\", function (event) {\n" +
" if (event.credits == 0 || event.credits) {\n" +
" $(\"#db-credits-num\").text(event.credits);\n" +
" }\n" +
" if (event.status) {\n" +
" $('#db-new-record,#db-new-tip').show();\n" +
" } else {\n" +
" $('#db-new-record,#db-new-tip').hide();\n" +
" }\n" +
" });\n" +
"\n" +
" if (data.canSign) {\n" +
" yangzuo.element(\"#sign-action\").on(\"click\", function () {\n" +
" yangzuo.injectExecute(Dosign);\n" +
" })\n" +
" }\n" +
" Dosign.$inject = [\"NewSignService\"]\n" +
" function Dosign(SignService) {\n" +
" var signText = $('.sign-text');\n" +
" //如果data-can-sign等于0那么将不能签到\n" +
" if (signText.data('canSign') === '0') {\n" +
" console.log('已签到!');\n" +
" return;\n" +
" }\n" +
" SignService.doSign().then(function (result) {\n" +
" console.log(\"签到成功:\" + yangzuo.toJson(result));\n" +
"\n" +
" $('.add-credits').html('<p>明日签到可获得<span class=\"price\">'+ sign.nextCredits + '</span>元转豆</p>');\n" +
" signText.text('已签到');\n" +
" signText.addClass('done');\n" +
" yangzuo.post(\"$onDBNewOpenBack\");\n" +
" \n" +
" //设置model参数和状态\n" +
" modelBox.setTitle('签到成功')\n" +
" .setPrompt('明日签到可获得' + sign.nextCredits + '元转豆')\n" +
" .show();\n" +
" }, function (message) {\n" +
" console.log(\"签到失败:\",message);\n" +
" $('.add-credits').html('<p>明日签到可获得<span class=\"price\">'+ sign.nextCredits + '</span>元转豆</p>');\n" +
" modelBox.setTitle('签到失败')\n" +
" .setPrompt('网络不通畅')\n" +
" .show();\n" +
"\n" +
" })\n" +
" }\n" +
"\n" +
"})(window,void 0);";
//新建banner楼层
Response response = floorService.createFloor(authorization.ssoLogin(),type,dataType,name,html,css,js,skinWidth);
Map<String,Object> map = jdbc.findSimpleResult("select * from credits_dev.tb_credits_floor_code where floor_name=?",name);
floorId = String.valueOf(map.get("id"));
String nameSkin = "mabo楼层皮肤sign";
String image = "//yun.dui88.com/images/201805/nlkmslg0t0.png";
// 验证码
String stoke="1";
// String floors = "[{\"id\":190,\"name\":\"maboTest\",\"type\":1,\"dataType\":0,\"needSyn\":false,\"syn\":false}]";
String ower = "0";
JSONObject json = new JSONObject();
json.put("id",map.get("id"));
json.put("name",name);
json.put("type",type);
json.put("dataType",map.get("data_type"));
json.put("needSyn",false);
json.put("syn",false);
JSONArray jsonArray = new JSONArray();
jsonArray.add(json);
String floors = jsonArray.toJSONString();
//新建皮肤
response = floorService.insertSkin(authorization.ssoLogin(),nameSkin,image,stoke,floors,ower,skinWidth);
map = jdbc.findSimpleResult("select * from credits_dev.tb_credits_floor_skin where skin_name = ?",nameSkin);
skinId = String.valueOf(map.get("id"));
response = floorService.switchOpenState(authorization.ssoLogin(),skinId,"true");
}
@Test
public void B_sign手机端() throws Exception {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");//设置日期格式
logger.info(df.format(new Date()));
Response response = devSkinService.saveSkin(authorization.hdLoginmabo(),"18740",skinId);
Thread.sleep(60000);
JsonPath jsonCfg = homeService.getCFG(2753);
Assert.assertEquals(jsonCfg.getList("").size(),1,"banner展示数量和配置不符");
String floorId = MatcherString.getString(jsonCfg.getList("").get(0).toString(),"floorId=(.*?),",1);
String dataType = MatcherString.getString(jsonCfg.getList("").get(0).toString(),"dataType=(.*?),",1);
String floorType = MatcherString.getString(jsonCfg.getList("").get(0).toString(),"floorType=(.*?),",1);
response = homeService.floor(authorization.dafuwengLogin(2753),floorType,dataType,"3",floorId);
String s = response.asString();
JsonPath jsonPath=from(s.substring(s.indexOf("{"),s.length()-1));
String credits = jsonPath.getString("credits");
Assert.assertEquals(credits,"1","积分与期望不符");
}
@Test
public void C_sign删除楼层皮肤() throws Exception {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");//设置日期格式
logger.info(df.format(new Date()));
Response response = devSkinService.saveSkin(authorization.hdLoginmabo(),"18740","198");
response.prettyPrint();
response = floorService.deleteSkin(authorization.ssoLogin(),skinId,"1");
response.prettyPrint();
response = floorService.deleteFloor(authorization.ssoLogin(),floorId);
response.prettyPrint();
}
}
package http.cases.GameTest;
import base.Config;
import base.DuibaLog;
import http.service.Activity.ManagerService;
import http.service.Activity.NgapiService;
......@@ -33,6 +34,7 @@ import static org.hamcrest.Matchers.equalTo;
* case3:游戏测试:马上使用跳转优惠券兑换记录页的链接
* case4:游戏测试:马上使用跳转福袋的链接
*/
@ContextConfiguration(classes = Config.class)
public class Game_AccessTest extends AbstractTestNGSpringContextTests {
@Autowired
......
......@@ -34,9 +34,10 @@ public class 游戏_中奖优惠券_AccessTest extends DuibaTestBase {
private static DuibaLog logger = DuibaLog.getLogger();
private String virtualOrderIds = null;
private static final Integer uid_Nomal = 2708;
private static final String consumerId = "100011623";
// private static final Integer uid_Nomal = 2708;
// private static final String consumerId = "100011623";
private static final Integer uid_Nomal = 4390;
private static final String consumerId = "100094047";
......
......@@ -33,7 +33,8 @@ public class 游戏_中奖异常流程测试_AccessTest extends DuibaTestBase {
NewGameService newGameService;
private static DuibaLog logger = DuibaLog.getLogger();
private static final Integer uid_Nomal = 2708;
//private static final Integer uid_Nomal = 2708;
private static final Integer uid_Nomal = 4389;
//ok
......
......@@ -36,8 +36,10 @@ public class 游戏_中奖限制测试_AccessTest extends DuibaTestBase {
NewGameService newGameService;
private static final Integer uid_Nomal = 2708;
private static final String consumerId_Nomal = "100011623";
// private static final Integer uid_Nomal = 2708;
// private static final String consumerId_Nomal = "100011623";
private static final Integer uid_Nomal = 4388;
private static final String consumerId_Nomal = "100094045";
private static DuibaLog logger = DuibaLog.getLogger();
......
......@@ -35,9 +35,10 @@ public class 游戏_奖项限制测试_AccessTest extends DuibaTestBase {
NewGameService newGameService;
private static DuibaLog logger = DuibaLog.getLogger();
private static final Integer uid_Nomal = 2708;
private static final String consumerId = "100011623";
// private static final Integer uid_Nomal = 2708;
// private static final String consumerId = "100011623";
private static final Integer uid_Nomal = 4387;
private static final String consumerId = "100094044";
......
package http.cases.PluginActivityTest;
import base.DuibaLog;
import base.SFExpress;
import base.ServiceDoctor;
import org.testng.SkipException;
import org.testng.annotations.BeforeSuite;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Created by hanzhanli on 2017/9/21.
*/
public class Server {
private DuibaLog logger = DuibaLog.getLogger();
private Map<String,String> fromMap=new HashMap<>();
private Map<String,List<String>> logMap=new HashMap<>();
@BeforeSuite
public void onStart() {
//logger.info("job-name:"+System.getProperty("JOB_NAME"));
//logger.info("属性:"+System.getProperties());
logger.info("duiba-server开始检测");
ServiceDoctor serviceDoctor=new ServiceDoctor("duiba-server.properties");
SFExpress.addToBeTestedServices(serviceDoctor.getToBeTestedServices());
//fromMap.putAll(serviceDoctor.getLogLenth());
SFExpress.addExceptionService(serviceDoctor.getExceptionService(60*2));
logger.info("duiba-server检测完毕");
logger.info("duiba-server-center开始检测");
serviceDoctor=new ServiceDoctor("duiba-server-center.properties");
SFExpress.addToBeTestedServices(serviceDoctor.getToBeTestedServices());
//fromMap.putAll(serviceDoctor.getLogLenth());
SFExpress.addExceptionService(serviceDoctor.getExceptionService(60*2));
logger.info("duiba-server-center检测完毕");
if(SFExpress.getExceptionServices().size()>0){
logger.info("服务未启动:"+SFExpress.getExceptionServices().toString());
throw new SkipException("被测服务未全部启动");
}
}
public static void main(String[] args) {
// String s = "最近变更:2018-1-3 13:48:07-activity-access-web:疯狂打气球—jiangxixi/疯狂打气球—jiangxixi/\n";
// String name = s.split("—")[1].split("/")[0];
// System.out.println(name);
// List<String> list = new ArrayList<>();
// list.clear();
// Map<String,Object> map = new HashMap<>();
// map.put("name",list);
ServiceDoctor serviceDoctor=new ServiceDoctor("duiba-server.properties");
}
}
......@@ -19,7 +19,7 @@ import java.util.List;
* Created by humengxin on 2018/8/21.
*/
@ContextConfiguration(classes = Config.class)
public class 自定义分类 extends AbstractTestNGSpringContextTests {
public class 自定义分类_DuibaTest extends AbstractTestNGSpringContextTests {
@Autowired
ZdyflService zdyflService;
......
package http.cases.SingleLotteryTest;
import base.DuibaTestBase;
import http.service.Activity.ManagerService;
import http.service.Activity.NewActivityService;
import http.service.Activity.SingleLotteryService;
import http.service.hd.ActivityService;
import utils.MatcherString;
import base.DuibaLog;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import java.lang.reflect.Method;
import java.util.Map;
/**
* Created by zhaoran on 2018/3/13.
*/
public class SingleLottery_AccessTest extends DuibaTestBase {
@Autowired
SingleLotteryService singleLotteryService;
@Autowired
ActivityService activityService;
@Autowired
NewActivityService newActivityService;
@Autowired
ManagerService managerService;
private static DuibaLog logger = DuibaLog.getLogger();
//指定用户
private static int uid = 3775;
// private static String consumer_id = "100088034";
private static String tag = "0226";
@DataProvider
public Object[][] providerMethod(Method method){
Object[][] result = null;
if(method.getName().equals("积分抽奖")) {
result = new Object[][]{
new Object[]{1, "18873", "ix18rh", "单品抽奖之iOS商家落地优惠券","iOS"},
new Object[]{1, "18873", "ix18rh", "单品抽奖之android商家落地优惠券","android"},
new Object[]{2, "18874", "zqwwq", "单品抽奖之实物","iOS"},
new Object[]{3, "19952", "40g83xb5", "单品抽奖之话费充值","iOS"},
new Object[]{4, "19954", "40g83xb5", "单品抽奖之支付宝充值","iOS"},
new Object[]{5, "19955", "9fm5ohz", "单品抽奖之Q币充值","iOS"},
new Object[]{6, "19958", "x62stnum", "单品抽奖之兑换记录页优惠券","iOS"},
new Object[]{7, "19959", "zpgcr", "单品抽奖之链接优惠券","iOS"},
};
}
return result;
}
@Test(dataProvider = "providerMethod" )
public void 积分抽奖(int caseNum,String activityId,String token,String casename,String device) throws Exception {
logger.info("-------------------------------------"+casename+"-------------------------------------");
//查询数据库,当前积分(抽奖扣积分流程校验)
Map<String,Object> mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
String credits = String.valueOf(mapuser.get("credits"));
logger.info("抽奖前积分:"+credits);
//扣去1积分
credits = String.valueOf(Integer.valueOf(credits)-1);
Response response =singleLotteryService.doJoin(uid,activityId,activityId,token);
//response.prettyPrint();
String id =MatcherString.getString(response.asString(), "singleLotteryOrderId\":(.*?),", 1);
response = singleLotteryService.getOrderStatus(uid,id,device);
int i = 10;
while ("处理中".equals(response.jsonPath().getString("message")) && i > 0) {
Thread.sleep(500);
response = singleLotteryService.getOrderStatus(uid,id,device);
i--;
}
//根据case选择对应的校验项
switch(caseNum){
case 1:
Assert.assertEquals(response.jsonPath().getString("descrption"),"【勿动】商家落地页_单品抽奖","校验优惠券标题失败");
Assert.assertEquals(response.jsonPath().getString("lotteryType"), "coupon", "校验奖品类型失败");
Assert.assertEquals(response.jsonPath().getString("showUse"), "true", "校验是否展示马上使用失败");
Assert.assertEquals(response.jsonPath().getString("useBtnText"), "马上使用", "校验按钮文案展示失败");
if ( device.equals("iOS")) {
Assert.assertEquals(response.jsonPath().getString("iosDownloadUrl"), "https://app.aixuedai.com/app/coupon/dbCoupon?productId=515272", "校验Url失败");
}else{
Assert.assertEquals(response.jsonPath().getString("androidDownloadUrl"),"https://www.baidu.com/","校验Url失败");
}
logger.info("校验链接券码项:openUrl,useBtnText成功");
break;
case 2:
Assert.assertEquals(response.jsonPath().getString("descrption"),"【勿动】自动化实物奖品","校验实物标题失败");
Assert.assertEquals(response.jsonPath().getString("itemId"), "27131", "校验实物ID失败");
Assert.assertEquals(response.jsonPath().getString("lotteryType"), "object", "校验奖品类型失败");
logger.info("校验商家落地项:descrption,itemId,lotteryType成功");
break;
case 3:
Assert.assertEquals(response.jsonPath().getString("descrption"),"多档位话费充值","校验实物标题失败");
Assert.assertEquals(response.jsonPath().getString("itemId"), "1", "校验实物ID失败");
Assert.assertEquals(response.jsonPath().getString("lotteryType"), "phonebill", "校验奖品类型失败");
logger.info("校验商家落地项:descrption,itemId,lotteryType成功");
break;
case 4:
Assert.assertEquals(response.jsonPath().getString("descrption"),"支付宝充值","校验实物标题失败");
Assert.assertEquals(response.jsonPath().getString("itemId"), "55", "校验实物ID失败");
Assert.assertEquals(response.jsonPath().getString("lotteryType"), "alipay", "校验奖品类型失败");
logger.info("校验商家落地项:descrption,itemId,lotteryType成功");
break;
case 5:
Assert.assertEquals(response.jsonPath().getString("descrption"),"Q币充值","校验实物标题失败");
Assert.assertEquals(response.jsonPath().getString("itemId"), "2", "校验实物ID失败");
Assert.assertEquals(response.jsonPath().getString("lotteryType"), "qb", "校验奖品类型失败");
logger.info("校验商家落地项:descrption,itemId,lotteryType成功");
break;
case 6:
Assert.assertEquals(response.jsonPath().getString("descrption"),"【勿动】兑换记录页_单品抽奖","校验优惠券标题失败");
Assert.assertEquals(response.jsonPath().getString("lotteryType"), "coupon", "校验奖品类型失败");
Assert.assertEquals(response.jsonPath().getString("showUse"), "true", "校验是否展示马上使用失败");
Assert.assertEquals(response.jsonPath().getString("useBtnText"), "查看使用方法", "校验按钮文案展示失败");
Assert.assertTrue(response.jsonPath().getString("iosDownloadUrl").contains("//activity.m.duibatest.com.cn/crecord/recordDetailNew"),"兑换记录页url与实际url不匹配");
logger.info("校验链接券码项:openUrl,useBtnText成功");
break;
case 7:
Assert.assertEquals(response.jsonPath().getString("descrption"),"【勿动】自动化链接券码_单品抽奖","校验优惠券标题失败");
Assert.assertEquals(response.jsonPath().getString("lotteryType"), "coupon", "校验奖品类型失败");
Assert.assertEquals(response.jsonPath().getString("showUse"), "true", "校验是否展示马上使用失败");
Assert.assertEquals(response.jsonPath().getString("useBtnText"), "马上使用", "校验按钮文案展示失败");
Assert.assertEquals(response.jsonPath().getString("iosDownloadUrl"), "https://app.aixuedai.com/app/coupon/dbCoupon?productId=515272", "校验Url失败");
logger.info("校验链接券码项:openUrl,useBtnText成功");
break;
}
//通用校验项
Assert.assertEquals(response.jsonPath().getString("message"), "成功", "校验信息失败");
Assert.assertEquals(response.jsonPath().getString("status"), "1", "校验状态失败");
//查询数据库,获取当前积分
Thread.sleep(3000);
mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
String creditsNew = String.valueOf(mapuser.get("credits"));
logger.info("抽奖后积分:"+creditsNew);
//校验比较,抽奖前后积分
Assert.assertEquals(credits,creditsNew);
logger.info("校验领奖前后积分正确");
//出奖实物走领奖发奖逻辑以及订单校验
if(caseNum == 2){
//待领奖校验子订单状态
Map<String, Object> selectResult = jdbc.findSimpleResult("select * from credits_dev.single_lottery_order where id = '"+id+"'");
String exchangeStatus = String.valueOf(selectResult.get("exchange_status"));
Assert.assertEquals(exchangeStatus, "1", "待领奖校验兑换状态失败");
//领奖操作
String recordId = MatcherString.getString(response.asString(), "recordId=(.*?)&", 1);
response = newActivityService.doTakePrize(uid,"object", recordId);
Assert.assertEquals(response.jsonPath().getString("message"), "领奖成功");
logger.info("结果:领奖流程成功");
selectResult = jdbc.findSimpleResult("select * from credits_dev.single_lottery_order where id = '"+id+"'");
Assert.assertEquals(String.valueOf(selectResult.get("exchange_status")), "2", "待发货校验兑换状态失败");
String orderId = String.valueOf(selectResult.get("order_id"));
Map<String, Object> selectResult2 = jdbc.findSimpleResult("select * from orders_consumer.orders_"+tag+" where id = '"+orderId+"' ");
String flowWork = String.valueOf(selectResult2.get("flowwork_stage"));
logger.info("领奖后数据库订单节点:"+flowWork);
int j =10;
while (j > 0 && !flowWork.equals("SupplierExchange-started")) {
Thread.sleep(300);
selectResult2 = jdbc.findSimpleResult("select * from orders_consumer.orders_"+tag+" where id = '"+orderId+"' ");
flowWork = String.valueOf(selectResult2.get("flowwork_stage"));
logger.info("领奖后数据库订单节点:" + flowWork);
j--;
}
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("pay_status")),"prereduce","数据库主订单pay_status校验失败");
Assert.assertEquals(String.valueOf(selectResult2.get("status")),"consume_success","数据库主订单status校验失败");
//发货操作
managerService.expressSend(orderId);
logger.info("实物发货订单成功");
selectResult2 = jdbc.findSimpleResult("select * from orders_consumer.orders_"+tag+" where id = '"+orderId+"' ");
String flowWork2 = String.valueOf(selectResult2.get("flowwork_stage"));
logger.info("发货后数据库订单节点:"+flowWork2);
int k =10;
while (k > 0 && !flowWork2.equals("Success-complete")) {
Thread.sleep(1000);
selectResult2 = jdbc.findSimpleResult("select * from orders_consumer.orders_"+tag+" where id = '"+orderId+"' ");
flowWork2 = String.valueOf(selectResult2.get("flowwork_stage"));
logger.info("发货后数据库订单节点:" + flowWork2);
k--;
}
Assert.assertEquals(String.valueOf(selectResult2.get("pay_status")),"successs","数据库主订单pay_status校验失败");
Assert.assertEquals(String.valueOf(selectResult2.get("status")),"success","数据库主订单status校验失败");
}else if(caseNum == 7){
//待领奖校验子订单状态
Thread.sleep(2000);
Map<String, Object> selectResult = jdbc.findSimpleResult("select * from credits_dev.single_lottery_order where id = '"+id+"'");
String orderId = String.valueOf(selectResult.get("order_id"));
Map<String, Object> selectResult2 = jdbc.findSimpleResult("select * from orders_consumer.orders_"+tag+" where id = '"+orderId+"' ");
String flowWork = String.valueOf(selectResult2.get("flowwork_stage"));
logger.info("领奖后数据库订单节点:"+flowWork);
int k =10;
while (k > 0 && !flowWork.equals("Success-complete")) {
Thread.sleep(300);
selectResult2 = jdbc.findSimpleResult("select * from orders_consumer.orders_"+tag+" where id = '"+orderId+"' ");
flowWork = String.valueOf(selectResult2.get("flowwork_stage"));
logger.info("领奖后数据库订单节点:" + flowWork);
k--;
}
Assert.assertEquals(flowWork,"Success-complete","数据库主订单流程节点校验失败");
Assert.assertEquals(String.valueOf(selectResult2.get("item_id")),"29761","数据库主订单奖项id校验失败");
}
}
@Test(description = "出福袋,免费抽奖不扣积分" )
public void 免费抽奖() throws Exception {
logger.info("-------------------------------------出福袋,免费抽奖不扣积分-------------------------------------");
//查询数据库,当前积分(抽奖扣积分流程校验)
Map<String,Object> mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
String credits = String.valueOf(mapuser.get("credits"));
logger.info("抽奖前积分:"+credits);
Response response =singleLotteryService.doJoin(uid,"21309","21309","8hbyive");
String id =MatcherString.getString(response.asString(), "singleLotteryOrderId\":(.*?),", 1);
response = singleLotteryService.getOrderStatus(uid,id,"iOS");
int i = 10;
while ("处理中".equals(response.jsonPath().getString("message")) && i > 0) {
Thread.sleep(1000);
response = singleLotteryService.getOrderStatus(uid,id,"iOS");
response.prettyPrint();
i--;
}
response.prettyPrint();
if(activityService.isRunning("10.110.10.12","17791","tuia-engine")){
logger.info("tuia-engine服务启动成功");
Assert.assertEquals(response.jsonPath().getString("lottery.useBtnText"), "马上使用", "校验奖品类型失败");
Assert.assertEquals(response.jsonPath().getString("lottery.showUse"), "true", "校验是否展示马上使用失败");
Assert.assertEquals(response.jsonPath().getString("message"), "成功", "校验信息失败");
Assert.assertEquals(response.jsonPath().getString("status"), "1", "校验状态失败");
}else{
logger.info("tuia-engine服务启动未成功,福袋降级成谢谢参与!");
}
//查询数据库,获取当前积分
Thread.sleep(3000);
mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
String creditsNew = String.valueOf(mapuser.get("credits"));
logger.info("抽奖后积分:"+creditsNew);
//校验比较,抽奖前后积分
Assert.assertEquals(credits,creditsNew);
logger.info("校验领奖前后积分正确");
}
}
\ No newline at end of file
package http.cases.SingleLotteryTest;
import base.DuibaTestBase;
import utils.PublicMethod;
import http.service.Activity.ManagerService;
import http.service.Activity.SingleLotteryService;
import http.service.Authorization;
import http.service.hd.DeveloperService;
import utils.MatcherString;
import base.DuibaLog;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.testng.Assert;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
/**
* Created by zhaoran on 2018/4/17.
*/
public class 单品抽奖_中鼓励奖_AccessTest extends DuibaTestBase {
@Autowired
SingleLotteryService singleLotteryService;
@Autowired
DeveloperService developerService;
@Autowired
Authorization authorization;
@Autowired
ManagerService managerService;
@Value("${activity.host}")
String activityHost;
private static DuibaLog logger = DuibaLog.getLogger();
private static String actId;
private static String data;
//指定用户
private static int uid = 2709;
@DataProvider
public Object[][] providerMethod(Method method){
Object[][] result = null;
if(method.getName().equals("鼓励奖限制测试")) {
result = new Object[][]{
new Object[]{1, "27128", "1", "","鼓励奖优惠券数量1,数量用完则判断是否可中主奖"},
new Object[]{2, "27000", "99999", "1","鼓励奖限制,数量用完后用户无法再中鼓励奖"},
};
}
return result;
}
@Test(dataProvider = "providerMethod")
public void 鼓励奖限制测试(int caseNum,String inciteItemId,String inciteItemRemaining,String inciteItemConsumerWinLimit,String casename) throws Exception {
logger.info("-------------------------------------"+casename+"-------------------------------------");
//创建活动
this.创建并上架活动(inciteItemId, inciteItemRemaining, inciteItemConsumerWinLimit);
Response response = developerService.list2("【自动化】鼓励奖限制"+data);
String activityId = response.jsonPath().getString("data.list[0].id");
//当天首次抽奖中鼓励奖
response = this.单品抽奖入参(activityId,activityId,"asdsad");
//根据case选择对应的校验项
switch(caseNum){
case 1:
Assert.assertEquals(response.jsonPath().getString("descrption"),"【勿动】自动化优惠券——商家落地页","校验优惠券标题失败");
Assert.assertEquals(response.jsonPath().getString("lotteryType"), "coupon", "校验奖品类型失败");
Assert.assertEquals(response.jsonPath().getString("showUse"), "true", "校验奖品类型失败");
Assert.assertEquals(response.jsonPath().getString("message"), "成功", "校验message失败");
Assert.assertEquals(response.jsonPath().getString("status"), "1", "校验status失败");
logger.info("第一次抽奖,校验descrption,showUse,lotteryType,message,status成功");
logger.info("当天首次抽奖中鼓励奖—优惠券");
break;
case 2:
Assert.assertEquals(response.jsonPath().getString("descrption"),"自动化测试活动实物","校验优惠券标题失败");
Assert.assertEquals(response.jsonPath().getString("lotteryType"), "object", "校验奖品类型失败");
Assert.assertEquals(response.jsonPath().getString("message"), "成功", "校验message失败");
Assert.assertEquals(response.jsonPath().getString("status"), "1", "校验status失败");
logger.info("第一次抽奖,校验descrption,lotteryType,message,status成功");
logger.info("当天首次抽奖中鼓励奖—实物");
break;
}
//当天第二次抽奖
response = this.单品抽奖入参(activityId,activityId,"asdsad");
Assert.assertEquals(response.jsonPath().getString("descrption"),"支付宝充值","校验优惠券标题失败");
Assert.assertEquals(response.jsonPath().getString("lotteryType"), "alipay", "校验奖品类型失败");
Assert.assertEquals(response.jsonPath().getString("message"), "成功", "校验message失败");
Assert.assertEquals(response.jsonPath().getString("status"), "1", "校验status失败");
logger.info("第二次抽奖lotteryType,useBtnText,success");
logger.info("当天第二次抽奖中主奖—支付宝");
//删除测试数据
this.删除活动();
try {
jdbc.update("delete from credits_dev.duiba_single_lottery where title=?", "【自动化】鼓励奖限制"+data);
jdbc.update("delete from credits_dev.operating_activity where title=?", "【自动化】鼓励奖限制"+data);
} catch (Exception e) {
System.out.println(e);
}
}
public Response 单品抽奖入参(String operationAcitvityId,String oaId,String token) throws Exception {
//进行接口测试传参
Response response =singleLotteryService.doJoin(uid,operationAcitvityId,oaId,token);
//response.prettyPrint();
String id =MatcherString.getString(response.asString(), "singleLotteryOrderId\":(.*?),", 1);
response = singleLotteryService.getOrderStatus(uid,id,"iOS");
int i = 10;
while ("处理中".equals(response.jsonPath().getString("message")) && i > 0) {
Thread.sleep(500);
response = singleLotteryService.getOrderStatus(uid,id,"iOS");
i--;
}
return response;
}
public void 创建并上架活动(String inciteItemId,String inciteItemRemaining,String inciteItemConsumerWinLimit) throws Exception {
data = PublicMethod.data();
String title = "【自动化】鼓励奖限制"+data;
//创建单品抽奖活动
//构建鼓励奖
Map<String,String> incite = new HashMap<>();
incite.put("inciteItemId",inciteItemId);
incite.put("inciteItemRate","100");
incite.put("inciteItemRemaining",inciteItemRemaining);
incite.put("preInciteItemRemaining","99999");
incite.put("inciteItemConsumerWinLimit",inciteItemConsumerWinLimit);
incite.put("inciteItemMinComein","");
singleLotteryService.SingleLottery_create(title,incite);
//获取新建活动id
Response response = singleLotteryService.manager_index();
actId = MatcherString.getString(response.asString(), "<td>(.*?)</td>\n", 1);
//管理后台开启活动
singleLotteryService.changeStatus(actId,"1");
//开发者上架活动
developerService.joinIn(actId,"2");
logger.info("创建活动并上架成功");
}
public void 删除活动() throws Exception{
//管理后台删除单品抽奖活动
singleLotteryService.delete(actId);
//开发者删除推荐位活动
Response response = developerService.list2("【自动化】鼓励奖限制"+data);
String actId = response.jsonPath().getString("data.list[0].id");
developerService.delActivity(actId);
}
}
package http.cases.SingleLotteryTest;
import base.DuibaTestBase;
import utils.PublicMethod;
import http.service.Activity.ManagerService;
import http.service.Activity.SingleLotteryService;
import http.service.Authorization;
import http.service.hd.ActivityService;
import http.service.hd.DeveloperService;
import utils.MatcherString;
import base.DuibaLog;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.Test;
import java.util.HashMap;
import java.util.Map;
/**
* Created by zhaoran on 2018/4/17.
*/
public class 单品抽奖_出奖限制_AccessTest extends DuibaTestBase {
@Autowired
SingleLotteryService singleLotteryService;
@Autowired
DeveloperService developerService;
@Autowired
Authorization authorization;
@Autowired
ManagerService managerService;
@Autowired
ActivityService activityService;
@Value("${activity.host}")
String activityHost;
private static DuibaLog logger = DuibaLog.getLogger();
private static String actId;
private static String data;
//指定用户
private static int uid = 3777;
@AfterClass
public void after() throws Exception{
//数据库删除
try {
jdbc.update("delete from credits_dev.operating_activity where title=?","【自动化】出奖限制"+data);
jdbc.update("delete from credits_dev.duiba_single_lottery where title=?","【自动化】出奖限制"+data);
} catch (Exception e) {
System.out.println(e);
}
}
@Test(description = "每个用户可抽中奖品数上限为1")
public void 出奖限制测试() throws Exception {
this.创建并上架活动();
Response response = developerService.list2("【自动化】出奖限制"+data);
String activityId = response.jsonPath().getString("data.list[0].id");
//当天首次抽奖
response = this.单品抽奖入参(activityId,activityId,"asdsad");
Assert.assertEquals(response.jsonPath().getString("descrption"),"支付宝充值","校验优惠券标题失败");
Assert.assertEquals(response.jsonPath().getString("lotteryType"), "alipay", "校验奖品类型失败");
Assert.assertEquals(response.jsonPath().getString("message"), "成功", "校验message失败");
Assert.assertEquals(response.jsonPath().getString("status"), "1", "校验status失败");
logger.info("第一次抽奖,校验descrption,lotteryType,message,status成功");
//当天第二次抽奖
response = this.单品抽奖入参(activityId,activityId,"asdsad");
logger.info("tuia-engine服务启动成功");
Assert.assertEquals(response.jsonPath().getString("lotteryType"), "lucky", "校验奖品类型失败");
Assert.assertEquals(response.jsonPath().getString("lottery.useBtnText"), "马上使用", "校验是否展示马上使用失败");
Assert.assertEquals(response.jsonPath().getString("success"), "true", "校验success失败");
logger.info("第二次抽奖lotteryType,useBtnText,success");
this.删除活动();
}
public Response 单品抽奖入参(String operationAcitvityId,String oaId,String token) throws Exception {
//进行接口测试传参
Response response =singleLotteryService.doJoin(uid,operationAcitvityId,oaId,token);
//response.prettyPrint();
String id =MatcherString.getString(response.asString(), "singleLotteryOrderId\":(.*?),", 1);
response = singleLotteryService.getOrderStatus(uid,id,"iOS");
int i = 10;
while ("处理中".equals(response.jsonPath().getString("message")) && i > 0) {
Thread.sleep(500);
response = singleLotteryService.getOrderStatus(uid,id,"iOS");
i--;
}
return response;
}
public void 创建并上架活动() throws Exception {
data = PublicMethod.data();
String title = "【自动化】出奖限制"+data;
//创建单品抽奖活动
//构建鼓励奖
Map<String,String> incite = new HashMap<>();
incite.put("inciteItemId","");
incite.put("inciteItemRate","");
incite.put("inciteItemRemaining","");
incite.put("preInciteItemRemaining","");
incite.put("inciteItemConsumerWinLimit","");
incite.put("inciteItemMinComein","");
singleLotteryService.SingleLottery_create(title,incite);
//获取新建活动id
Response response = singleLotteryService.manager_index();
actId = MatcherString.getString(response.asString(), "<td>(.*?)</td>\n", 1);
//管理后台开启活动
singleLotteryService.changeStatus(actId,"1");
//开发者上架活动
developerService.joinIn(actId,"2");
logger.info("创建活动并上架成功");
}
public void 删除活动() throws Exception{
//管理后台删除单品抽奖活动
singleLotteryService.delete(actId);
//开发者删除推荐位活动
Response response = developerService.list2("【自动化】出奖限制"+data);
String actId = response.jsonPath().getString("data.list[0].id");
developerService.delActivity(actId);
}
}
package http.cases.SingleLotteryTest;
import base.Config;
import http.service.Activity.ManagerService;
import http.service.Activity.SingleLotteryService;
import http.service.Authorization;
import http.service.hd.DeveloperService;
import utils.MatcherString;
import base.DuibaLog;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
import org.testng.Assert;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import static io.restassured.RestAssured.given;
/**
* Created by zhaoran on 2018/4/17.
*/
@ContextConfiguration(classes = Config.class)
public class 单品抽奖_异常场景_AccessTest extends AbstractTestNGSpringContextTests {
@Autowired
SingleLotteryService singleLotteryService;
@Autowired
DeveloperService developerService;
@Autowired
Authorization authorization;
@Autowired
ManagerService managerService;
@Value("${activity.host}")
String activityHost;
private static DuibaLog logger = DuibaLog.getLogger();
//指定用户
private static int uid = 2709;
@DataProvider
public Object[][] providerMethod(Method method){
Object[][] result = null;
if(method.getName().equals("限制抽奖测试")) {
result = new Object[][]{
new Object[]{1, "20065", "积分不足"},
new Object[]{2, "20066", "永久次数抽完"},
new Object[]{3, "20073", "当日次数抽完"},
};
}
if(method.getName().equals("中奖限制测试")) {
result = new Object[][]{
new Object[]{"每人限中1次,次数用完无法中奖", "1340","20915"},
new Object[]{"活动奖品剩余不足,无法中奖", "1341","20927"},
new Object[]{"活动奖品库存不足,无法中奖", "1342","20941"},
};
}
return result;
}
@Test(description = "开发者关闭活动,用户调接口抽奖场景")
public void 活动关闭测试() throws Exception {
//关闭活动
Response HdResponse = developerService.closeActivity("20046","2239");
//参加抽奖
Response response = this.单品抽奖异常场景传参("20046");
//判断结果
Assert.assertEquals(response.jsonPath().getString("success"), "false", "校验success失败");
Assert.assertEquals(response.jsonPath().getString("message"), "活动已结束", "校验message失败");
logger.info("活动状态关闭后的抽奖页面验证成功");
//打开活动
HdResponse = developerService.openActivity("20046","2239");
}
@Test(dataProvider = "providerMethod")
public void 限制抽奖测试(int casenum,String activityId,String casename) throws Exception {
logger.info("-------------------------------------"+casename+"-------------------------------------");
//参加抽奖
Response response = this.单品抽奖异常场景传参(activityId);
//根据case选择对应的校验项
switch(casenum){
case 1:
Assert.assertEquals(response.jsonPath().getString("message"),"积分不足","校验message失败");
logger.info("积分不足测试校验项:messag成功");
break;
case 2:
Assert.assertEquals(response.jsonPath().getString("message"),"已抽完","校验message失败");
Assert.assertEquals(response.jsonPath().getString("lotteryButtonStatus"),"2","校验lotteryButtonStatus失败");
logger.info("永久次数不足测试校验项:message,lotteryButtonStatus成功");
break;
case 3:
String success = MatcherString.getString(response.asString(), "\"success\": (.*?),", 1);
int i= 8;
while(i>0&&(success.equals("true"))){
response = this.单品抽奖异常场景传参(activityId);
success = MatcherString.getString(response.asString(), "\"success\": (.*?),", 1);
i--;
}
Assert.assertEquals(response.jsonPath().getString("message"),"今日已抽完","校验message失败");
Assert.assertEquals(response.jsonPath().getString("lotteryButtonStatus"),"8","校验lotteryButtonStatus失败");
logger.info("今日次数不足测试校验项:message,lotteryButtonStatus成功");
break;
}
//通用校验项
Assert.assertEquals(response.jsonPath().getString("success"),"false","校验success失败");
logger.info("通用校验项:success成功");
}
@Test
public void 未登录抽奖测试() throws Exception {
//获取未登录场景cookie
Response responses = authorization.autoLogin();
//进行接口测试传参
Response response = singleLotteryService.init(responses.getDetailedCookies(),"18873");
//校验项
Assert.assertEquals(response.jsonPath().getString("lotteryButtonStatus"),"7","校验lotteryButtonStatus失败");
logger.info("未登录状态下无免费次数抽奖校验:lotteryButtonStatus成功");
}
@Test(dataProvider = "providerMethod")
public void 中奖限制测试(String casename,String actId,String activityId) throws Exception {
logger.info("-------------------------------------"+casename+"-------------------------------------");
//获取管理员后台活动信息
Response ManagerResponse = singleLotteryService.AdminDuibaSingleLottery(actId);
logger.info("预设中奖商品为:实物类");
logger.info("预设中奖几率为:"+MatcherString.getString(ManagerResponse.asString(), "mainItemRate\" value=\"(.*?)\"", 1)+"%");
logger.info("预设中奖每人限制:"+MatcherString.getString(ManagerResponse.asString(), "consumerWinLimit\" value=\"(.*?)\"", 1));
logger.info("预设剩余奖品数:"+MatcherString.getString(ManagerResponse.asString(), "mainItemRemaining\" value=\"(.*?)\"", 1));
//获取奖品剩余库存
String appItemId = MatcherString.getString(ManagerResponse.asString(), "mainItemId\" value=\"(.*?)\"", 1);
String Objremaind = this.getremind(appItemId);
logger.info("预设奖品库存:"+Objremaind+"个");
//进行接口测试传参
Response response =singleLotteryService.doJoin(uid,activityId,activityId,"asdsad");
//response.prettyPrint();
String id =MatcherString.getString(response.asString(), "singleLotteryOrderId\":(.*?),", 1);
response = singleLotteryService.getOrderStatus(uid,id,"iOS");
int i = 10;
while ("处理中".equals(response.jsonPath().getString("message")) && i > 0) {
Thread.sleep(500);
response = singleLotteryService.getOrderStatus(uid,id,"iOS");
i--;
}
String type = String.valueOf(response.jsonPath().getString("lotteryType"));
if (type.equals("lucky")){
Assert.assertTrue(response.jsonPath().getString("lottery.link").contains("//activity.m.duibatest.com.cn/crecord/recordLuckDetailNew?"));
Assert.assertEquals(response.jsonPath().getString("lottery.useBtnText"),"马上使用","校验useBtnText失败");
Assert.assertEquals(response.jsonPath().getString("isAppLucky"),"true","校验谢谢参与转福袋失败");
logger.info("校验中奖限制测试:link,useBtnText,isAppLucky成功");
logger.info("校验中奖限制测试成功,未返回预设必中实物奖品");
}
if (type.equals("thanks")){
logger.info("福袋库存不足会降级成谢谢参与!");//福袋库存不足会降级成谢谢参与!
}
if (type.equals("object")&&MatcherString.getString(ManagerResponse.asString(), "mainItemRemaining\" value=\"(.*?)\"", 1).equals("0")){
throw new Exception("用例失败,不应返回实物信息:"+response.asString());
}
}
@Test(description = "该单品抽奖已在大富翁app上架可参与")
public void 开发者未上架单品抽奖() {
Response response = this.单品抽奖异常场景传参("33488");
//logger.info("CCCCC"+response.asString());
Assert.assertEquals(response.jsonPath().getString("success"),"false");
Assert.assertEquals(response.jsonPath().getString("message"),"无权访问");
}
public Response 单品抽奖异常场景传参(String activityId) {
Map<String, String> map = new HashMap<>();
map.put("operationAcitvityId", activityId);
map.put("oaId", activityId);
map.put("token", "hdfjks");
Response response = given().cookies(authorization.dafuwengLogin(uid)).params(map).post(activityHost + "/singleLottery/doJoin");
response.prettyPrint();
return response;
}
public String getremind(String gid) throws Exception{
Response ManagerResponse = managerService.CouponConfig(gid);
ManagerResponse.prettyPrint();
String remind = MatcherString.getString(ManagerResponse.asString(), "remaining\" value=\"(.*?)\"", 1);
return remind;
}
}
package http.cases.SingleLotteryTest;
import base.DuibaTestBase;
import http.service.Activity.SingleLotteryService;
import utils.MatcherString;
import base.DuibaLog;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import java.lang.reflect.Method;
import java.util.Map;
/**
* Created by zhaoran on 2018/6/8.
*/
public class 自有单品抽奖_AccessTest extends DuibaTestBase {
@Autowired
SingleLotteryService singleLotteryService;
private static DuibaLog logger = DuibaLog.getLogger();
//指定用户
private static int uid = 2709;
@BeforeClass
public void before() {
try {
jdbc.update("delete from orders_consumer.orders_0616 where consumer_id = 100011624 and biz_params = 'DUIBA_SELF'", null);
} catch (Exception e) {
e.printStackTrace();
}
}
@DataProvider
public Object[][] providerMethod(Method method){
Object[][] result = null;
if(method.getName().equals("自有单品抽奖")) {
result = new Object[][]{
new Object[]{1, "26476", "ix18rh", "单品抽奖之优惠券","iOS"},
new Object[]{2, "26477", "ix18rh", "单品抽奖之实物","android"},
new Object[]{3, "26480", "40g83xb5", "单品抽奖之话费充值","iOS"},
new Object[]{4, "26478", "40g83xb5", "单品抽奖之支付宝充值","iOS"},
new Object[]{5, "26479", "9fm5ohz", "单品抽奖之Q币充值","iOS"},
new Object[]{6, "26481", "x62stnum", "单品抽奖之虚拟商品","iOS"},
};
}
return result;
}
@Test(dataProvider = "providerMethod" )
public void 自有单品抽奖(int caseNum,String activityId,String token,String casename,String device) throws Exception {
logger.info("-------------------------------------"+casename+"-------------------------------------");
//查询数据库,当前积分(抽奖扣积分流程校验)
Map<String,Object> mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
String credits = String.valueOf(mapuser.get("credits"));
logger.info("抽奖前积分:"+credits);
//扣去1积分
credits = String.valueOf(Integer.valueOf(credits)-1);
Response response =singleLotteryService.doJoin(uid,activityId,activityId,token);
//response.prettyPrint();
String id =MatcherString.getString(response.asString(), "singleLotteryOrderId\":(.*?),", 1);
response = singleLotteryService.getOrderStatus(uid,id,device);
int i = 10;
while ("处理中".equals(response.jsonPath().getString("message")) && i > 0) {
Thread.sleep(500);
response = singleLotteryService.getOrderStatus(uid,id,device);
i--;
}
//根据case选择对应的校验项
switch(caseNum){
case 1:
Assert.assertEquals(response.jsonPath().getString("descrption"),"【自动化】优惠券-普通","校验优惠券标题失败");
Assert.assertEquals(response.jsonPath().getString("lotteryType"), "coupon", "校验奖品类型失败");
Assert.assertEquals(response.jsonPath().getString("showUse"), "true", "校验是否展示马上使用失败");
Assert.assertEquals(response.jsonPath().getString("useBtnText"), "马上使用", "校验按钮文案展示失败");
if ( device.equals("iOS")) {
Assert.assertEquals(response.jsonPath().getString("iosDownloadUrl"), "www.baidu.com", "校验Url失败");
}else{
Assert.assertEquals(response.jsonPath().getString("androidDownloadUrl"),"www.baidu.com","校验Url失败");
}
logger.info("校验链接券码项:openUrl,useBtnText成功");
break;
case 2:
Assert.assertEquals(response.jsonPath().getString("descrption"),"【自动化测试误删】实物奖品","校验实物标题失败");
Assert.assertTrue(response.jsonPath().getString("url").contains("/activity/takePrizeNew?recordId"),"兑换记录页url与实际url不匹配");
Assert.assertEquals(response.jsonPath().getString("lotteryType"), "object", "校验奖品类型失败");
logger.info("校验商家落地项:descrption,url,lotteryType成功");
break;
case 3:
Assert.assertEquals(response.jsonPath().getString("descrption"),"多档位话费充值","校验实物标题失败");
Assert.assertEquals(response.jsonPath().getString("itemId"), "1", "校验实物ID失败");
Assert.assertEquals(response.jsonPath().getString("lotteryType"), "phonebill", "校验奖品类型失败");
Assert.assertTrue(response.jsonPath().getString("url").contains("/activity/takePrizeNew?recordId"),"兑换记录页url与实际url不匹配");
logger.info("校验商家落地项:descrption,itemId,lotteryType,url成功");
break;
case 4:
Assert.assertEquals(response.jsonPath().getString("descrption"),"支付宝充值","校验实物标题失败");
Assert.assertEquals(response.jsonPath().getString("itemId"), "55", "校验实物ID失败");
Assert.assertEquals(response.jsonPath().getString("lotteryType"), "alipay", "校验奖品类型失败");
Assert.assertTrue(response.jsonPath().getString("url").contains("/activity/takePrizeNew?recordId"),"兑换记录页url与实际url不匹配");
logger.info("校验商家落地项:descrption,itemId,lotteryType,url成功");
break;
case 5:
Assert.assertEquals(response.jsonPath().getString("descrption"),"Q币充值","校验实物标题失败");
Assert.assertEquals(response.jsonPath().getString("itemId"), "2", "校验实物ID失败");
Assert.assertEquals(response.jsonPath().getString("lotteryType"), "qb", "校验奖品类型失败");
Assert.assertTrue(response.jsonPath().getString("url").contains("/activity/takePrizeNew?recordId"),"兑换记录页url与实际url不匹配");
logger.info("校验商家落地项:descrption,itemId,lotteryType,url成功");
break;
case 6:
Assert.assertEquals(response.jsonPath().getString("descrption"),"【自动化】自有虚拟商品","校验优惠券标题失败");
Assert.assertEquals(response.jsonPath().getString("lotteryType"), "virtual", "校验奖品类型失败");
Assert.assertTrue(response.jsonPath().getString("url").contains("//activity.m.duibatest.com.cn/crecord/recordDetailNew"),"兑换记录页url与实际url不匹配");
logger.info("校验链接券码项:openUrl,useBtnText成功");
Thread.sleep(2000);
Map<String, Object> selectResult = jdbc.findSimpleResult("select * from orders_consumer.orders_0616 where consumer_id = 100011624 and biz_params = 'DUIBA_SELF' ",null);
//logger.info("selectResult结果为:"+selectResult);
Assert.assertEquals( selectResult.get("biz_params"),"DUIBA_SELF","虚拟商品出奖标识DUIBA_SELF校验失败");
logger.info("数据库存储虚拟商品标记结果为:"+selectResult.get("biz_params"));
break;
}
//通用校验项
Assert.assertEquals(response.jsonPath().getString("message"), "成功", "校验信息失败");
Assert.assertEquals(response.jsonPath().getString("status"), "1", "校验状态失败");
//查询数据库,获取当前积分
Thread.sleep(3000);
mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
String creditsNew = String.valueOf(mapuser.get("credits"));
logger.info("抽奖后积分:"+creditsNew);
//校验比较,抽奖前后积分
Assert.assertEquals(credits,creditsNew);
logger.info("校验领奖前后积分正确");
}
}
\ No newline at end of file
package http.cases.SingleLotteryTest;
import base.DuibaTestBase;
import http.service.Activity.SingleLotteryService;
import utils.MatcherString;
import base.DuibaLog;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.Test;
import java.util.Map;
/**
* Created by zhaoran on 2018/6/8.
*/
public class 自有库存不足_AccessTest extends DuibaTestBase {
@Autowired
SingleLotteryService singleLotteryService;
private static DuibaLog logger = DuibaLog.getLogger();
//指定用户
private static int uid = 3927;
@Test
public void 自有单品抽奖库存不足() throws Exception {
//查询数据库,当前积分(抽奖扣积分流程校验)
Map<String,Object> mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
String credits = String.valueOf(mapuser.get("credits"));
logger.info("抽奖前积分:"+credits);
//扣去1积分
credits = String.valueOf(Integer.valueOf(credits)-1);
Response response =singleLotteryService.doJoin(uid,"34541","34541","238wmftdc");
//response.prettyPrint();
String id =MatcherString.getString(response.asString(), "singleLotteryOrderId\":(.*?),", 1);
response = singleLotteryService.getOrderStatus(uid,id,"iOS");
int i = 10;
while ("处理中".equals(response.jsonPath().getString("message")) && i > 0) {
Thread.sleep(500);
response = singleLotteryService.getOrderStatus(uid,id,"iOS");
i--;
}
Assert.assertEquals(response.jsonPath().getString("lotteryType"), "lucky", "校验奖品类型失败");
Assert.assertEquals(response.jsonPath().getString("lottery.showUse"), "true", "校验是否展示马上使用失败");
Assert.assertEquals(response.jsonPath().getString("lottery.useBtnText"), "马上使用", "校验按钮文案展示失败");
//通用校验项
Assert.assertEquals(response.jsonPath().getString("message"), "成功", "校验信息失败");
Assert.assertEquals(response.jsonPath().getString("status"), "1", "校验状态失败");
//查询数据库,获取当前积分
Thread.sleep(3000);
mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
String creditsNew = String.valueOf(mapuser.get("credits"));
logger.info("抽奖后积分:"+creditsNew);
//校验比较,抽奖前后积分
Assert.assertEquals(credits,creditsNew);
logger.info("校验领奖前后积分正确");
}
}
\ No newline at end of file
......@@ -834,7 +834,7 @@ public class ManagerService {
map.put("expressId","123123213213");
map.put("expressName","圆通速递");
map.put("orderId",orderId);
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.ssoLogin()).params(map).post("http://"+url);
Response response = given().relaxedHTTPSValidation().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.ssoLogin()).params(map).post("https://"+url);
try {
Assert.assertEquals(response.jsonPath().getString("success"), "true");
} catch (Exception e) {
......
......@@ -55,7 +55,7 @@ public class Authorization {
private static Map<String,String> hdCookies;
private static Map<String,String> hdCookiesMabo;
private static Map<String,String> hdCookiesSaas;
private static Map<String,String> hdCookiesCommon;
private static Map<String,Map> hdCookiesCommon = new ConcurrentHashMap<>();
private static Map<String,String> openbsCookies;
private Map<String,String> ssoCookies =null;
......@@ -264,7 +264,8 @@ public class Authorization {
//密码为duibaduiba123
public Map hdLoginCommon(String email){
int i=10;
while((hdCookiesCommon==null||hdCookiesCommon.size()==0)&&i>0) {
Map<String,String> hdCookies = hdCookiesCommon.get(email);
while((hdCookies==null||hdCookies.size()==0)&&i>0) {
Response token=this.hdGetToken();
String url = PROTOCOL + hdHost + hdLoginPath;
Map<String,String> cookies=token.getCookies();
......@@ -274,13 +275,17 @@ public class Authorization {
paras.put("redirect", "/redirectApp");
paras.put("isAutoLogin", "true");
Response response = given().cookies(cookies).params(paras).post(url);
hdCookiesCommon=new HashMap<>(response.getCookies());
hdCookies=new HashMap<>(response.getCookies());
if(hdCookies==null||hdCookies.size()==0){
hdCookies.remove("csrf_token");
hdCookiesCommon.put(email,hdCookies);
}
i--;
}
//取消安全校验
hdCookiesCommon.remove("csrf_token");
// logger.info(hdCookies);
return hdCookiesCommon;
return hdCookies;
}
public Response hdGetToken(){
......
......@@ -172,7 +172,7 @@ public class ZdyflService {
return response;
}
//自定义分类-活动移出分类
//自定义分类_DuibaTest-活动移出分类
public Response removeClassifyAppItem1(String classifyId,String operatingActivityId) throws Exception {
String url=hdHost+"/devItem/removeClassifyAppItem";
......@@ -191,7 +191,7 @@ public class ZdyflService {
return response;
}
//自定义分类-商品移出分类
//自定义分类_DuibaTest-商品移出分类
public Response removeClassifyAppItem2(String classifyId,String appItemId) throws Exception {
String url=hdHost+"/devItem/removeClassifyAppItem";
......
......@@ -76,7 +76,7 @@ public class DeveloperAccountService {
map.put("mode","two");
map.put("orderId",orderId);
map.put("rowId","1");
Response response=given().cookies(authorization.hdLogin()).params(map).get("http://"+url);
Response response=given().cookies(authorization.hdLoginCommon("zhaoran@duiba.com.cn")).params(map).get("http://"+url);
try{
Assert.assertEquals(response.jsonPath().getString("success"),"true","/developerAccount/cashDetail接口失败");
......
......@@ -49,9 +49,28 @@ public class DsOrderService {
throw new Exception("请求订单审核接口失败,返回信息:"+response.asString());
}
return response;
}
//审核订单
public Response submitAudit(String idArray,String audit,String email) throws Exception{
String url = hdHost + "/dsOrder/submitAudit";
}
Map<String,String> map = new HashMap<>();
map.put("appId","18714");
map.put("idArray",idArray);
map.put("audit",audit);
map.put("reason","测试订单审核不通过");
logger.info("请求订单审核接口:" + url);
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginCommon(email)).params(map).post("http://"+url);
try{
Assert.assertEquals(response.jsonPath().getString("desc"),"成功");
}catch(Exception e){
throw new Exception("请求订单审核接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("请求订单审核接口失败,返回信息:"+response.asString());
}
return response;
}
}
package utils;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* Created by hanzhanli on 2017/8/16.
*/
public class StringUtil {
public static String generateStringByTime(){
Date date=new Date();
SimpleDateFormat sdf=new SimpleDateFormat("MMdd");
return sdf.format(date)+"-"+(int)(Math.random()*100);
}
public static String generateRandomString(int length) {
String str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
Random random = new Random();
StringBuffer buf = new StringBuffer();
for (int i = 0; i < length; i++) {
int num = random.nextInt(36);
buf.append(str.charAt(num));
}
return buf.toString();
}
public static String getMatcher(String regex, String source,int index) {
String result = "";
Pattern pattern = Pattern.compile(regex);
Matcher matcher = pattern.matcher(source);
if (matcher.find()) {
result = matcher.group(1);
}
return result;
}
public static void main(String[] args) {
String s = "{\"code\":\"0\",\"desc\":\"获取标签成功\",\"data\":{\"matchTagNums\":[\"20101\"],\"bannedTagNums\":[\"30101\"],\"promoteURLTagNums\":[\"40101\"],\"materialTagNums\":[\"50101\"]}}";
String source = "\"matchTagNums\":[\"(.*?)\"]";
System.out.println(getMatcher(source,s,1));
}
}
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