Commit b5f8aa16 authored by 马博's avatar 马博

Merge branch 'master' of gitlab2.dui88.com:mabo/test-platform

parents 8ad86640 ec503ecb
......@@ -59,7 +59,7 @@ public class 集卡活动助力_AccessTest extends DuibaTestBase {
//开始助力
Response helpResponse = clcardService.doHelpNew(uid1,activityId,shareCode);
helpResponse.prettyPrint();
Thread.sleep(100);
Thread.sleep(1000);
//首页集卡信息
indexResponse = clcardService.activity(uid1,activityId);
int resultCount = Integer.parseInt(indexResponse.jsonPath().getString("data.cards[1].count"));
......
......@@ -3,6 +3,7 @@ package http.cases.ClcardTest;
import base.DuibaTestBase;
import http.service.Activity.ClcardService;
import io.restassured.response.Response;
import org.apache.ibatis.jdbc.SQL;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.AfterMethod;
......@@ -29,18 +30,13 @@ public class 集卡活动领奖_AccessTest extends DuibaTestBase {
@BeforeClass
public void before(){
try {
//修改表,增加用户卡片,"集卡领奖成功"
jdbc.update("update collect_card_consumer.tb_collect_card_info_0548 set item_count = item_count +1 , item_total_count = item_total_count +1 WHERE consumer_id = 100164132 AND item_id = 12");
jdbc.update("update collect_card_consumer.tb_collect_card_info_0548 set item_count = item_count +2 , item_total_count = item_total_count +2 WHERE consumer_id = 100164132 AND item_id = 13");
jdbc.update("update collect_card_consumer.tb_collect_card_info_0548 set item_count = item_count +3 , item_total_count = item_total_count +3 WHERE consumer_id = 100164132 AND item_id = 14");
try{
//修改表,增加用户卡片,"A_集卡单用户并发领奖"
jdbc.update("update collect_card_consumer.tb_collect_card_info_0332 set item_count = item_count +1 , item_total_count = item_total_count +1 WHERE consumer_id = 100168012 AND item_id = 20");
jdbc.update("update collect_card_consumer.tb_collect_card_info_0332 set item_count = item_count +1 , item_total_count = item_total_count +1 WHERE consumer_id = 100168012 AND item_id = 21");
} catch (SQLException e) {
}catch (SQLException e) {
e.printStackTrace();
}
......@@ -50,6 +46,13 @@ public class 集卡活动领奖_AccessTest extends DuibaTestBase {
@Test(description = "集卡活动领奖支付宝测试")
public void 集卡领奖成功() throws Exception{
//修改表,增加用户卡片,"集卡领奖成功"
jdbc.update("update collect_card_consumer.tb_collect_card_info_0548 set item_count = item_count +1 , item_total_count = item_total_count +1 WHERE consumer_id = 100164132 AND item_id = 12");
jdbc.update("update collect_card_consumer.tb_collect_card_info_0548 set item_count = item_count +2 , item_total_count = item_total_count +2 WHERE consumer_id = 100164132 AND item_id = 13");
jdbc.update("update collect_card_consumer.tb_collect_card_info_0548 set item_count = item_count +3 , item_total_count = item_total_count +3 WHERE consumer_id = 100164132 AND item_id = 14");
Thread.sleep(1000);
int uid = 7402;
String activityId = "45501";
......@@ -81,19 +84,19 @@ public class 集卡活动领奖_AccessTest extends DuibaTestBase {
Assert.assertEquals(response.jsonPath().getString("lottery.title"),"支付宝","校验奖品title失败");
Assert.assertEquals(response.jsonPath().getString("result"),"2","校验result失败");
Assert.assertEquals(cards0,"1","校验card0失败");
Assert.assertEquals(cards0,"0","校验card0失败");
Assert.assertEquals(cards1,"2","校验card1失败");
Assert.assertEquals(cards2,"4","校验card2失败");
Assert.assertEquals(cards2,"1","校验card2失败");
Assert.assertEquals(rules0,"1","校验rules0失败");
Assert.assertEquals(rules1,"2","校验rules1失败");
Assert.assertEquals(rules2,"3","校验rules2失败");
logger.info("集卡活动领奖成功");
logger.info("校验成功:集卡活动领奖成功");
}
@Test(description = "集卡活动领奖库存不足测试")
@Test(description = "集卡活动领奖实物库存不足测试")
public void 集卡领奖库存不足() throws Exception{
int uid = 7414;
......@@ -117,7 +120,7 @@ public class 集卡活动领奖_AccessTest extends DuibaTestBase {
//库存不足,接口会轮询处理超时
Assert.assertEquals(result,"0","校验result失败");
Assert.assertEquals(response.jsonPath().getString("takeSuccess"),"false","校验takeSuccess失败");
logger.info("集卡大奖库存不足领奖失败");
logger.info("校验成功:集卡大奖库存不足领奖失败");
}
......@@ -132,7 +135,7 @@ public class 集卡活动领奖_AccessTest extends DuibaTestBase {
response.prettyPrint();
Assert.assertEquals(response.jsonPath().getString("desc"),"卡片还未集齐,请继续集卡","校验desc失败");
logger.info("集卡卡片未集齐领奖失败");
logger.info("校验成功:集卡卡片未集齐领奖失败");
}
......@@ -141,10 +144,11 @@ public class 集卡活动领奖_AccessTest extends DuibaTestBase {
//同一用户并发领奖 活动:【自动化】集卡发奖3
@Test(threadPoolSize = 5, invocationCount =5)
public void A_集卡单用户并发领奖() throws Exception {
int uid = 7416;
String activityId = "45531";
//领奖(只有一次兑换机会)
//领奖(只有一次机会)
Response response = clcardService.openPrize2(uid,activityId);
resultList.add(response.asString());
logger.info("请求返回结果:" + response.asString());
......@@ -155,21 +159,77 @@ public class 集卡活动领奖_AccessTest extends DuibaTestBase {
int fail = 0;
int success = 0;
for (String s: resultList) {
if(s.contains("desc\":\"服务器开小差了,请稍后重试")){
fail++;
}else if(s.contains("\"desc\":\"OK\"")){
if(s.contains("\"desc\":\"OK\"")){
success++;
}else{
}else if (s.contains("\"success\":false")){
fail++;
}else {
System.out.println(s);
}
}
//检验 成功的只有一个。错误提示有多种
Assert.assertEquals(fail,4,"校验fail数量失败");
Assert.assertEquals(success,1,"校验success数量失败");
logger.info("校验集卡单用户并发成功");
logger.info("校验成功:集卡单用户并发领奖");
}
@Test(description = "集卡活动已下架,领奖测试")
public void 集卡活动已下架再领奖() throws Exception{
int uid = 7451;
String activityId = "45620";
Response response = clcardService.openPrize2(uid,activityId);
response.prettyPrint();
Assert.assertEquals(response.jsonPath().getString("desc"),"活动不存在!","校验desc失败");
logger.info("校验成功:集卡活动已下架领奖失败");
}
@Test(description = "集卡活动已结束,领奖测试")
public void 集卡活动已结束再领奖() throws Exception{
int uid = 7450;
String activityId = "45619";
Response response = clcardService.openPrize2(uid,activityId);
response.prettyPrint();
Assert.assertEquals(response.jsonPath().getString("desc"),"活动已结束","校验desc失败");
logger.info("校验成功:集卡活动已结束领奖失败");
}
@Test(description = "开发者余额不足,集卡领奖支付宝测试")
public void 开发者余额不足领奖() throws Exception{
//开发者账号:13000000000
int uid = 7452;
String activityId = "45622";
Response response = clcardService.openPrize(uid,activityId);
String orderNum = response.jsonPath().getString("data.orderNum");
response = clcardService.getOrderStatus(uid,orderNum);
response.prettyPrint();
String result = String.valueOf(response.jsonPath().getString("result"));
int i= 30;
while(i>0&&(result.equals("0"))){
Thread.sleep(500);
response = clcardService.getOrderStatus(uid,orderNum);
result = String.valueOf(response.jsonPath().getString("result"));
i--;
response.prettyPrint();
}
//库存不足,接口会轮询处理超时
Assert.assertEquals(result,"0","校验result失败");
Assert.assertEquals(response.jsonPath().getString("takeSuccess"),"false","校验takeSuccess失败");
logger.info("校验成功:开发者余额不足领奖支付宝失败");
}
}
......@@ -17,7 +17,7 @@ public class Database {
public static String orders13 = "orders_0411";
public static String orders14 = "orders_0712";
public static String orders15 = "orders_0063";
public static String orders16 = "orders_0721";
public static String orders16 = "orders_0632";
......
......@@ -113,7 +113,7 @@ public class Qb_兑换流程测试_ExchangeTest extends CheckTemplet {
@Test
public void qbExchange_档位不存在() throws Exception {
int uid = 3767;
int uid = 7474;
String message = "";
......@@ -178,12 +178,12 @@ public class Qb_兑换流程测试_ExchangeTest extends CheckTemplet {
Assert.assertTrue(message.contains("\"success\":false"));
}
@Test
public void 每日兑换限制() throws Exception {
int uid = 3767;
int uid = 7475;
//第一次兑换
Thread.sleep(5000);
Response response = qbExchangeService.doTakePrize(authorization.dafuwengLogin(uid),"1234345554","1");
String orderId = (String)response.jsonPath().get("orderId");
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid),orderId);
......@@ -209,12 +209,12 @@ public class Qb_兑换流程测试_ExchangeTest extends CheckTemplet {
Assert.assertTrue(message.contains("\"success\":false"));
}
@Test
public void 永久兑换限制() throws Exception {
int uid = 3767;
int uid = 7476;
//第一次兑换
Thread.sleep(5000);
Response response = qbExchangeService.doTakePrize(authorization.dafuwengLogin(uid),"1234345554","2");
String orderId = (String)response.jsonPath().get("orderId");
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid),orderId);
......
......@@ -69,7 +69,6 @@ public class Qb_兑换限制测试_ExchangeTest extends CheckTemplet {
int uid = 4932;
//第一次兑换
Thread.sleep(4000);
Response response = qbExchangeService.doTakePrize(authorization.dafuwengLogin(uid),"1234343554","1");
String orderId = (String)response.jsonPath().get("orderId");
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid),orderId);
......@@ -100,10 +99,9 @@ public class Qb_兑换限制测试_ExchangeTest extends CheckTemplet {
@Test(description = "Q币2元用户兑换限制永久")
public void 用户永久兑换限制() throws Exception {
int uid = 4933;
int uid = 7477;
//第一次兑换
Thread.sleep(4000);
Response response = qbExchangeService.doTakePrize(authorization.dafuwengLogin(uid),"1234345554","2");
String orderId = (String)response.jsonPath().get("orderId");
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid),orderId);
......@@ -136,10 +134,9 @@ public class Qb_兑换限制测试_ExchangeTest extends CheckTemplet {
@Test(description = "Q币3元用户兑换限制每月")
public void 用户每月兑换限制() throws Exception {
int uid = 4933;
int uid = 7478;
//第一次兑换
Thread.sleep(4000);
Response response = qbExchangeService.doTakePrize(authorization.dafuwengLogin(uid),"12343432554","3");
String orderId = (String)response.jsonPath().get("orderId");
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid),orderId);
......@@ -208,7 +205,6 @@ public class Qb_兑换限制测试_ExchangeTest extends CheckTemplet {
int uid = 4934;
//第一次兑换
Thread.sleep(5000);
Response response = qbExchangeService.doTakePrize(authorization.dafuwengLogin(uid),"123434555412","1");
String orderId = (String)response.jsonPath().get("orderId");
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid),orderId);
......
......@@ -276,9 +276,9 @@ public class 新Qb_兑换流程测试_ExchangeTest extends CheckTemplet {
public void Q币用户id篡改测试() throws Exception{
//商品: lv测试应用77
//uid1: 大富翁app
//uid1: lv测试应用55
//uid2: lv测试应用88
int uid1 = 7084;
int uid1 = 7315;
int uid2 = 7292;
String actualCredits = "3";
String degreeId = "3";
......@@ -287,7 +287,7 @@ public class 新Qb_兑换流程测试_ExchangeTest extends CheckTemplet {
String qq = "806854056";
String message = "";
//话费兑换, 大富翁app已上架Q币
//话费兑换, uid1 -app已上架Q币
Response response = gawService.qbExchange(uid1,actualCredits,degreeId,appItemId,credits,qq);
response.prettyPrint();
String orderId = response.jsonPath().getString("data.orderId");
......@@ -301,12 +301,12 @@ public class 新Qb_兑换流程测试_ExchangeTest extends CheckTemplet {
logger.info("订单积分:" + orderCredits);
Assert.assertEquals(orderStatus,"consume_success","校验status失败");
Assert.assertEquals(orderappId,"1","校验appId失败");
Assert.assertEquals(orderappId,"22561","校验appId失败");
Assert.assertEquals(orderCredits,"300","校验credits失败");
logger.info("校验Q币用户id1篡改兑换成功");
//Q币兑换,lv测试应用88app未上架Q币
//Q币兑换,lv测试应用88app未入库Q币
try{
Response response2 = gawService.qbExchange(uid2,actualCredits,degreeId,appItemId,credits,qq);
response2.prettyPrint();
......
......@@ -302,7 +302,7 @@ public class 新多档位话费_兑换流程测试_ExchangeTest extends CheckTem
logger.info("校验话费用户id1篡改兑换成功");
//话费兑换,lv测试应用88app未上架话费
//话费兑换,lv测试应用88app未入库话费
try{
Response response2 = gawService.phonebillExchange(uid2,actualCredits,degreeId,appItemId,credits);
response2.prettyPrint();
......
......@@ -346,7 +346,7 @@ public class 新支付宝_兑换流程测试_ExchangeTest extends CheckTemplet {
logger.info(message);
Assert.assertTrue(message.contains("\"success\":false"),"校验message失败");
Assert.assertTrue(message.contains("\"desc\":\"商家未采购商品\""),"校验message失败");
Assert.assertTrue(message.contains("\"desc\":\"商品已下架\""),"校验message失败");
logger.info("校验支付宝用户id2篡改无法兑换成功");
......
......@@ -208,6 +208,7 @@ public class 兑吧老优惠券_兑换流程测试_ExchangeTest extends CheckTem
@Test
public void 优惠券预分配每日限额测试() throws Exception{
int uid = 7447;
//获取当前的时间
Date dNow = new Date();
SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd");
......
......@@ -107,40 +107,32 @@ public class 兑吧老实物_兑换流程测试_ExchangeTest extends CheckTemple
return result;
}
//实物兑换积分不足
//实物兑换积分不足实物兑换积分不足
@Test(description = "实物兑换积分不足")
public void 积分不足() throws Exception {
String message = "";
//活动详情页
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", "yrJRr7Cddp2YeQd", "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);
//无法兑换,直接抛出
try{
response = couponExchangeService.objectExchange(map, "167141", "28515", "null", "yrJRr7Cddp2YeQd", "null");
response.prettyPrint();
message = response.jsonPath().getString("data.message");
i--;
}catch (Exception e){
message = e.toString();
}
logger.info(message);
//校验messaga字段返回值
String message2 = response.jsonPath().getString("data.message");
Assert.assertEquals(message2,"兑换失败,用户积分余额不足","message字段校验失败-期望是积分不足");
Assert.assertTrue(message.contains("\"success\":false"),"校验message失败");
Assert.assertTrue(message.contains("\"message\":\"您的积分不足\""),"校验message失败"); //这个提示很奇怪
logger.info("校验实物兑换积分不足成功");
// authorization.dafuwengLogin(2720,true);
}
//实物兑换限制消费
......
package http.cases.ExchangeTest.策略会员商品;
import http.cases.ExchangeTest.CheckTemplet;
import http.service.Authorization;
import http.service.app.MobileService;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import utils.MatcherString;
import java.sql.SQLException;
public class 策略价会员商品自有优惠券_兑换流程测试_ExchangeTest extends CheckTemplet {
@Autowired
http.service.app.gawService gawService;
@Autowired
http.service.app.tawService tawService;
@Autowired
MobileService mobileService;
@Autowired
Authorization authorization;
//指定用户
private static int uid = 6926;
private Boolean bl=true;
private String url = "http://activity.m.duibatest.com.cn";
@BeforeMethod
public void beforeMethod(){
try {
//永久
jdbc.update("DELETE FROM marketing.tb_vip_goods_consumer_limit_record WHERE app_item_id =199421");
//每日限量
jdbc.update("DELETE FROM marketing.tb_vip_goods_consumer_limit_record WHERE app_item_id =199420");
//周期限量
jdbc.update("DELETE FROM marketing.tb_vip_goods_consumer_limit_record WHERE app_item_id =199422");
//商品每天限制
jdbc.update("DELETE FROM credits_dev.consumer_limit_record where app_item_id =199423");
jdbc.update("DELETE FROM marketing.tb_vip_goods_consumer_limit_record WHERE app_item_id =199423");
//商品永久限制
jdbc.update("DELETE FROM credits_dev.consumer_limit_record where app_item_id =199424");
jdbc.update("DELETE FROM credits_dev.consumer_limit_record_only where app_item_id =199424");
jdbc.update("DELETE FROM marketing.tb_vip_goods_consumer_limit_record WHERE app_item_id =199424");
//商品周期限制
jdbc.update("DELETE FROM credits_dev.consumer_limit_record where app_item_id =199425");
jdbc.update("DELETE FROM credits_dev.consumer_limit_record_only where app_item_id =199425");
jdbc.update("DELETE FROM marketing.tb_vip_goods_consumer_limit_record WHERE app_item_id =199425");
} catch (SQLException e) {
e.printStackTrace();
}
}
@Test(description = "策略价会员商品自有优惠券--每日限制")
public void 策略会员商品每日兑换上限测试() throws Exception {
String appItemId = "199420";
int skuid=233;
String actualCredits="32";
String credits="32";
try{
Thread.sleep(4000);
//第一次兑换
Response response = gawService.couponExchange2(uid, appItemId,credits,actualCredits,skuid,bl);
String orderId = response.jsonPath().getString("data.orderId");
//获取兑换结果
response = tawService.orderStatus(orderId,uid);
response.prettyPrint();
String message = response.jsonPath().getString("message");
int i = 10;
//异步接口,直到兑换成功
while (i > 0 && "兑换正在处理中...".equals(message)) {
Thread.sleep(1000);
response = tawService.orderStatus(orderId,uid);
response.prettyPrint();
message = response.jsonPath().getString("message");
i--;
}
Thread.sleep(4000);
Response detailResponse = mobileService.appItemDetail(authorization.dafuwengLogin(uid),appItemId);
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
logger.info("商品兑换按钮:" + exchangeText);
//第二次兑换
try{
System.out.println("**************第二次兑换");
response = gawService.couponExchange2(uid, appItemId,credits,actualCredits,skuid,bl);
response.prettyPrint();
}catch (Exception e){
message = e.toString();
}
logger.info(message);
Assert.assertTrue(message.contains("\"success\":false"),"校验success失败");
Assert.assertEquals(exchangeText,"已达兑换上限","校验兑换按钮失败");
logger.info("校验策略会员商品自有优惠券每日兑换上限成功");
}catch (Exception e){
throw new Exception("异常信息打印:" + e);
}
}
@Test(description = "策略价会员商品自有优惠券--永久限制")
public void 策略会员商品永久兑换上限测试() throws Exception {
String appItemId = "199421";
int skuid=234;
String actualCredits="32";
String credits="32";
try{
Thread.sleep(4000);
//第一次兑换
Response response = gawService.couponExchange2(uid, appItemId,credits,actualCredits,skuid,bl);
String orderId = response.jsonPath().getString("data.orderId");
//获取兑换结果
response = tawService.orderStatus(orderId,uid);
String message = response.jsonPath().getString("message");
int i = 10;
//异步接口,直到兑换成功
while (i > 0 && "兑换正在处理中...".equals(message)) {
Thread.sleep(1000);
response = tawService.orderStatus(orderId,uid);
response.prettyPrint();
message = response.jsonPath().getString("message");
i--;
}
Thread.sleep(4000);
Response detailResponse = mobileService.appItemDetail(authorization.dafuwengLogin(uid),appItemId);
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
logger.info("商品兑换按钮:" + exchangeText);
//第二次兑换
try{
System.out.println("**************第二次兑换");
response = gawService.couponExchange2(uid, appItemId,credits,actualCredits,skuid,bl);
response.prettyPrint();
}catch (Exception e){
message = e.toString();
}
logger.info(message);
Assert.assertTrue(message.contains("\"success\":false"),"校验success失败");
Assert.assertEquals(exchangeText,"已达兑换上限","校验兑换按钮失败");
logger.info("校验策略会员商品自有优惠券永久兑换上限成功");
}catch (Exception e){
throw new Exception("异常信息打印:" + e);
}
}
@Test(description = "策略价会员商品自有优惠券--周期限制")
public void 策略会员商品周期兑换上限测试() throws Exception {
String appItemId = "199422";
int skuid=235;
String actualCredits="32";
String credits="32";
try{
Thread.sleep(4000);
//第一次兑换
Response response = gawService.couponExchange2(uid, appItemId,credits,actualCredits,skuid,bl);
String orderId = response.jsonPath().getString("data.orderId");
//获取兑换结果
response = tawService.orderStatus(orderId,uid);
String message = response.jsonPath().getString("message");
int i = 10;
//异步接口,直到兑换成功
while (i > 0 && "兑换正在处理中...".equals(message)) {
Thread.sleep(1000);
response = tawService.orderStatus(orderId,uid);
response.prettyPrint();
message = response.jsonPath().getString("message");
i--;
}
Thread.sleep(4000);
Response detailResponse = mobileService.appItemDetail(authorization.dafuwengLogin(uid),appItemId);
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
logger.info("商品兑换按钮:" + exchangeText);
//第二次兑换
try{
System.out.println("**************第二次兑换");
response = gawService.couponExchange2(uid, appItemId,credits,actualCredits,skuid,bl);
response.prettyPrint();
}catch (Exception e){
message = e.toString();
}
logger.info(message);
Assert.assertTrue(message.contains("\"success\":false"),"校验success失败");
Assert.assertEquals(exchangeText,"已达兑换上限","校验兑换按钮失败");
logger.info("校验策略会员商品自有优惠券周期兑换上限成功");
}catch (Exception e){
throw new Exception("异常信息打印:" + e);
}
}
@Test(description = "策略价会员商品自有优惠券--商品每日限购小于会员限制")
public void 策略会员商品商品每日限购小于会员限制测试() throws Exception {
String appItemId = "199423";
int skuid=236;
String actualCredits="32";
String credits="32";
try{
Thread.sleep(4000);
//第一次兑换
Response response = gawService.couponExchange2(uid, appItemId,credits,actualCredits,skuid,bl);
response.prettyPrint();
String orderId = response.jsonPath().getString("data.orderId");
//获取兑换结果
response = tawService.orderStatus(orderId,uid);
String message = response.jsonPath().getString("message");
int i = 10;
//异步接口,直到兑换成功
while (i > 0 && "兑换正在处理中...".equals(message)) {
Thread.sleep(1000);
response = tawService.orderStatus(orderId,uid);
response.prettyPrint();
message = response.jsonPath().getString("message");
i--;
}
Thread.sleep(4000);
Response detailResponse = mobileService.appItemDetail(authorization.dafuwengLogin(uid),appItemId);
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
logger.info("商品兑换按钮:" + exchangeText);
//第二次兑换
try{
response = gawService.couponExchange2(uid, appItemId,credits,actualCredits,skuid,bl);
response.prettyPrint();
}catch (Exception e){
message = e.toString();
}
logger.info(message);
Assert.assertTrue(message.contains("\"success\":false"),"校验success失败");
Assert.assertEquals(exchangeText,"今日已达兑换上限","校验兑换按钮失败");
logger.info("校验策略会员商品自有优惠券周期兑换上限成功");
}catch (Exception e){
throw new Exception("异常信息打印:" + e);
}
}
@Test(description = "策略价会员商品自有优惠券--商品永久限购小于会员限制")
public void 策略会员商品商品永久限购小于会员限制测试() throws Exception {
String appItemId = "199424";
int skuid=237;
String actualCredits="45";
String credits="45";
try{
Thread.sleep(4000);
//第一次兑换
Response response = gawService.couponExchange2(uid, appItemId,credits,actualCredits,skuid,bl);
response.prettyPrint();
String orderId = response.jsonPath().getString("data.orderId");
//获取兑换结果
response = tawService.orderStatus(orderId,uid);
String message = response.jsonPath().getString("message");
int i = 10;
//异步接口,直到兑换成功
while (i > 0 && "兑换正在处理中...".equals(message)) {
Thread.sleep(1000);
response = tawService.orderStatus(orderId,uid);
response.prettyPrint();
message = response.jsonPath().getString("message");
i--;
}
Thread.sleep(4000);
Response detailResponse = mobileService.appItemDetail(authorization.dafuwengLogin(uid),appItemId);
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
logger.info("商品兑换按钮:" + exchangeText);
//第二次兑换
try{
response = gawService.couponExchange2(uid, appItemId,credits,actualCredits,skuid,bl);
response.prettyPrint();
}catch (Exception e){
message = e.toString();
}
logger.info(message);
Assert.assertTrue(message.contains("\"success\":false"),"校验success失败");
Assert.assertEquals(exchangeText,"已达兑换次数上限","校验兑换按钮失败");
logger.info("校验策略会员商品自有优惠券周期兑换上限成功");
}catch (Exception e){
throw new Exception("异常信息打印:" + e);
}
}
@Test(description = "策略价会员商品自有优惠券--商品周期限购小于会员限制")
public void 策略会员商品商品周期限购小于会员限制测试() throws Exception {
String appItemId = "199425";
int skuid=238;
String actualCredits="78";
String credits="78";
try{
Thread.sleep(1000);
//第一次兑换
Response response = gawService.couponExchange2(uid, appItemId,credits,actualCredits,skuid,bl);
response.prettyPrint();
String orderId = response.jsonPath().getString("data.orderId");
//获取兑换结果
response = tawService.orderStatus(orderId,uid);
String message = response.jsonPath().getString("message");
int i = 10;
//异步接口,直到兑换成功
while (i > 0 && "兑换正在处理中...".equals(message)) {
Thread.sleep(1000);
response = tawService.orderStatus(orderId,uid);
response.prettyPrint();
message = response.jsonPath().getString("message");
i--;
}
Thread.sleep(4000);
Response detailResponse = mobileService.appItemDetail(authorization.dafuwengLogin(uid),appItemId);
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
logger.info("商品兑换按钮:" + exchangeText);
//第二次兑换
try{
response = gawService.couponExchange2(uid, appItemId,credits,actualCredits,skuid,bl);
response.prettyPrint();
}catch (Exception e){
message = e.toString();
}
logger.info(message);
Assert.assertTrue(message.contains("\"success\":false"),"校验success失败");
Assert.assertEquals(exchangeText,"已达兑换次数上限","校验兑换按钮失败");
logger.info("校验策略会员商品自有优惠券周期兑换上限成功");
}catch (Exception e){
throw new Exception("异常信息打印:" + e);
}
}
@Test(description = "策略价会员商品自有优惠券--会员限制兑换")
public void 策略商品商品设置会员限制() throws Exception{
String appItemId = "199419";
int skuid=232;
String message = "";
String actualCredits="43";
String credits="43";
// //会员等级无法兑换
try{
Thread.sleep(4000);
Response response = gawService.couponExchange2(uid, appItemId,actualCredits,credits,skuid,bl);
response.prettyPrint();
}catch (Exception e){
message = e.toString();
}
Response detailResponse = mobileService.appItemDetail(authorization.dafuwengLogin(uid),appItemId);
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
logger.info("商品兑换按钮:" + exchangeText);
Assert.assertTrue(message.contains("\"success\":false"),"校验success失败");
Assert.assertEquals(exchangeText,"暂无兑换权限","校验兑换按钮失败");
logger.info("校验策略会员商品自有优惠券周期兑换上限成功");
// 会员等级可兑换,vip=1
Thread.sleep(4000);
Response response = gawService.couponExchange(authorization.generateSignAutoLogin("3tzVcss7SnAvA5ppT1m1rMPhaBcD",7083,1),appItemId,skuid,bl);
response.prettyPrint();
Assert.assertEquals(response.jsonPath().getString("success"),"true","校验兑换结果失败");
logger.info("校验实物会员等级成功");
}
@Test(description = "策略价会员商品自有优惠券--会员未限制,商品限制无法兑换")
public void 策略商品商品设置商品设置会员未限制() throws Exception{
String appItemId = "199427";
int skuid=240;
String message = "";
String actualCredits="53";
String credits="53";
// //会员等级无法兑换
try{
Thread.sleep(2000);
Response response = gawService.couponExchange2(uid, appItemId,actualCredits,credits,skuid,bl);
response.prettyPrint();
}catch (Exception e){
message = e.toString();
}
Response detailResponse = mobileService.appItemDetail(authorization.dafuwengLogin(uid),appItemId);
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
logger.info("商品兑换按钮:" + exchangeText);
Assert.assertTrue(message.contains("\"success\":false"),"校验success失败");
Assert.assertEquals(exchangeText,"无兑换权限","校验兑换按钮失败");
Assert.assertTrue(message.contains("未达到会员等级要求"),"校验兑换按钮失败");
logger.info("策略价会员商品自有实物--会员未限制,商品限制无法兑换");
}
}
package http.cases.ExchangeTest.策略会员商品;
import http.cases.ExchangeTest.CheckTemplet;
import http.service.Authorization;
import http.service.app.MobileService;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import utils.MatcherString;
import java.sql.SQLException;
public class 策略价会员商品自有卡密_兑换流程测试_ExchangeTest extends CheckTemplet {
@Autowired
http.service.app.gawService gawService;
@Autowired
http.service.app.tawService tawService;
@Autowired
MobileService mobileService;
@Autowired
Authorization authorization;
//指定用户
private static int uid = 6926;
private Boolean bl=true;
private String url = "http://activity.m.duibatest.com.cn";
@BeforeMethod
public void beforeMethod(){
try {
//永久
jdbc.update("DELETE FROM marketing.tb_vip_goods_consumer_limit_record WHERE app_item_id =199432");
//每日限量
jdbc.update("DELETE FROM marketing.tb_vip_goods_consumer_limit_record WHERE app_item_id =199431");
//周期限量
jdbc.update("DELETE FROM marketing.tb_vip_goods_consumer_limit_record WHERE app_item_id =199430");
//商品每天限制
jdbc.update("DELETE FROM credits_dev.consumer_limit_record where app_item_id =199433");
jdbc.update("DELETE FROM marketing.tb_vip_goods_consumer_limit_record WHERE app_item_id =199433");
//商品永久限制
jdbc.update("DELETE FROM credits_dev.consumer_limit_record where app_item_id =199434");
jdbc.update("DELETE FROM credits_dev.consumer_limit_record_only where app_item_id =199434");
jdbc.update("DELETE FROM marketing.tb_vip_goods_consumer_limit_record WHERE app_item_id =199434");
//商品周期限制
jdbc.update("DELETE FROM credits_dev.consumer_limit_record where app_item_id =199435");
jdbc.update("DELETE FROM credits_dev.consumer_limit_record_only where app_item_id =199435");
jdbc.update("DELETE FROM marketing.tb_vip_goods_consumer_limit_record WHERE app_item_id =199435");
} catch (SQLException e) {
e.printStackTrace();
}
}
@Test(description = "策略价会员商品自有卡密--每日限制")
public void 策略会员商品卡密每日兑换上限测试() throws Exception {
String appItemId = "199432";
int skuid=245;
String actualCredits="20";
String credits="20";
try{
Thread.sleep(2000);
//第一次兑换
Response response = gawService.couponExchange2(uid, appItemId,credits,actualCredits,skuid,bl);
String orderId = response.jsonPath().getString("data.orderId");
//获取兑换结果
response = tawService.orderStatus(orderId,uid);
response.prettyPrint();
String message = response.jsonPath().getString("message");
int i = 10;
//异步接口,直到兑换成功
while (i > 0 && "兑换正在处理中...".equals(message)) {
Thread.sleep(1000);
response = tawService.orderStatus(orderId,uid);
response.prettyPrint();
message = response.jsonPath().getString("message");
i--;
}
Thread.sleep(4000);
Response detailResponse = mobileService.appItemDetail(authorization.dafuwengLogin(uid),appItemId);
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
logger.info("商品兑换按钮:" + exchangeText);
//第二次兑换
try{
System.out.println("**************第二次兑换");
response = gawService.couponExchange2(uid, appItemId,credits,actualCredits,skuid,bl);
response.prettyPrint();
}catch (Exception e){
message = e.toString();
}
logger.info(message);
Assert.assertTrue(message.contains("\"success\":false"),"校验success失败");
Assert.assertTrue(message.contains("\"desc\":\"会员商品已达最高限购次数\""),"校验success失败");
Assert.assertEquals(exchangeText,"已达兑换上限","校验兑换按钮失败");
logger.info("校验策略价会员商品自有卡密--每日限制成功");
}catch (Exception e){
throw new Exception("异常信息打印:" + e);
}
}
@Test(description = "策略价会员商品自有卡密--永久限制")
public void 策略会员商品卡密永久兑换上限测试() throws Exception {
String appItemId = "199431";
int skuid=244;
String actualCredits="20";
String credits="20";
try{
Thread.sleep(2000);
//第一次兑换
Response response = gawService.couponExchange2(uid, appItemId,credits,actualCredits,skuid,bl);
String orderId = response.jsonPath().getString("data.orderId");
//获取兑换结果
response = tawService.orderStatus(orderId,uid);
String message = response.jsonPath().getString("message");
int i = 10;
//异步接口,直到兑换成功
while (i > 0 && "兑换正在处理中...".equals(message)) {
Thread.sleep(1000);
response = tawService.orderStatus(orderId,uid);
response.prettyPrint();
message = response.jsonPath().getString("message");
i--;
}
Thread.sleep(4000);
Response detailResponse = mobileService.appItemDetail(authorization.dafuwengLogin(uid),appItemId);
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
logger.info("商品兑换按钮:" + exchangeText);
//第二次兑换
try{
System.out.println("**************第二次兑换");
response = gawService.couponExchange2(uid, appItemId,credits,actualCredits,skuid,bl);
response.prettyPrint();
}catch (Exception e){
message = e.toString();
}
logger.info(message);
Assert.assertTrue(message.contains("\"success\":false"),"校验success失败");
Assert.assertEquals(exchangeText,"已达兑换上限","校验兑换按钮失败");
logger.info("校验策略价会员商品自有卡密--永久限制成功");
}catch (Exception e){
throw new Exception("异常信息打印:" + e);
}
}
@Test(description = "策略价会员商品自有卡密--周期限制")
public void 策略会员商品卡密周期兑换上限测试() throws Exception {
String appItemId = "199430";
int skuid=243;
String actualCredits="21";
String credits="21";
try{
Thread.sleep(2000);
//第一次兑换
Response response = gawService.couponExchange2(uid, appItemId,credits,actualCredits,skuid,bl);
String orderId = response.jsonPath().getString("data.orderId");
//获取兑换结果
response = tawService.orderStatus(orderId,uid);
String message = response.jsonPath().getString("message");
int i = 10;
//异步接口,直到兑换成功
while (i > 0 && "兑换正在处理中...".equals(message)) {
Thread.sleep(1000);
response = tawService.orderStatus(orderId,uid);
response.prettyPrint();
message = response.jsonPath().getString("message");
i--;
}
Thread.sleep(4000);
Response detailResponse = mobileService.appItemDetail(authorization.dafuwengLogin(uid),appItemId);
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
logger.info("商品兑换按钮:" + exchangeText);
//第二次兑换
try{
System.out.println("**************第二次兑换");
response = gawService.couponExchange2(uid, appItemId,credits,actualCredits,skuid,bl);
response.prettyPrint();
}catch (Exception e){
message = e.toString();
}
logger.info(message);
Assert.assertTrue(message.contains("\"success\":false"),"校验success失败");
Assert.assertTrue(message.contains("\"desc\":\"会员商品已达最高限购次数\""),"校验success失败");
Assert.assertEquals(exchangeText,"已达兑换上限","校验兑换按钮失败");
logger.info("校验策略价会员商品自有卡密--周期限制成功");
}catch (Exception e){
throw new Exception("异常信息打印:" + e);
}
}
@Test(description = "策略价会员商品自有卡密--商品每日限购小于会员限制")
public void 策略会员商品卡密商品每日限购小于会员限制测试() throws Exception {
String appItemId = "199433";
int skuid=246;
String actualCredits="20";
String credits="20";
try{
Thread.sleep(4000);
//第一次兑换
Response response = gawService.couponExchange2(uid, appItemId,credits,actualCredits,skuid,bl);
response.prettyPrint();
String orderId = response.jsonPath().getString("data.orderId");
//获取兑换结果
response = tawService.orderStatus(orderId,uid);
String message = response.jsonPath().getString("message");
int i = 10;
//异步接口,直到兑换成功
while (i > 0 && "兑换正在处理中...".equals(message)) {
Thread.sleep(1000);
response = tawService.orderStatus(orderId,uid);
response.prettyPrint();
message = response.jsonPath().getString("message");
i--;
}
Thread.sleep(4000);
Response detailResponse = mobileService.appItemDetail(authorization.dafuwengLogin(uid),appItemId);
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
logger.info("商品兑换按钮:" + exchangeText);
//第二次兑换
try{
response = gawService.couponExchange2(uid, appItemId,credits,actualCredits,skuid,bl);
response.prettyPrint();
}catch (Exception e){
message = e.toString();
}
logger.info(message);
Assert.assertTrue(message.contains("\"success\":false"),"校验success失败");
Assert.assertEquals(exchangeText,"今日已达兑换上限","校验兑换按钮失败");
logger.info("校验策略价会员商品自有卡密--商品每日限购小于会员限制成功");
}catch (Exception e){
throw new Exception("异常信息打印:" + e);
}
}
@Test(description = "策略价会员商品自有卡密--商品永久限购小于会员限制")
public void 策略会员商品商品永久限购小于会员限制测试() throws Exception {
String appItemId = "199434";
int skuid=247;
String actualCredits="20";
String credits="20";
try{
Thread.sleep(4000);
//第一次兑换
Response response = gawService.couponExchange2(uid, appItemId,credits,actualCredits,skuid,bl);
response.prettyPrint();
String orderId = response.jsonPath().getString("data.orderId");
//获取兑换结果
response = tawService.orderStatus(orderId,uid);
String message = response.jsonPath().getString("message");
int i = 10;
//异步接口,直到兑换成功
while (i > 0 && "兑换正在处理中...".equals(message)) {
Thread.sleep(1000);
response = tawService.orderStatus(orderId,uid);
response.prettyPrint();
message = response.jsonPath().getString("message");
i--;
}
Thread.sleep(4000);
Response detailResponse = mobileService.appItemDetail(authorization.dafuwengLogin(uid),appItemId);
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
logger.info("商品兑换按钮:" + exchangeText);
//第二次兑换
try{
response = gawService.couponExchange2(uid, appItemId,credits,actualCredits,skuid,bl);
response.prettyPrint();
}catch (Exception e){
message = e.toString();
}
logger.info(message);
Assert.assertTrue(message.contains("\"success\":false"),"校验success失败");
Assert.assertEquals(exchangeText,"已达兑换次数上限","校验兑换按钮失败");
logger.info("校验策略价会员商品自有卡密--商品永久限购小于会员限制成功");
}catch (Exception e){
throw new Exception("异常信息打印:" + e);
}
}
@Test(description = "策略价会员商品自有卡密--商品周期限购小于会员限制")
public void 策略会员商品商品卡密周期限购小于会员限制测试() throws Exception {
String appItemId = "199435";
int skuid=248;
String actualCredits="20";
String credits="20";
try{
Thread.sleep(1000);
//第一次兑换
Response response = gawService.couponExchange2(uid, appItemId,credits,actualCredits,skuid,bl);
response.prettyPrint();
String orderId = response.jsonPath().getString("data.orderId");
//获取兑换结果
response = tawService.orderStatus(orderId,uid);
String message = response.jsonPath().getString("message");
int i = 10;
//异步接口,直到兑换成功
while (i > 0 && "兑换正在处理中...".equals(message)) {
Thread.sleep(1000);
response = tawService.orderStatus(orderId,uid);
response.prettyPrint();
message = response.jsonPath().getString("message");
i--;
}
Thread.sleep(4000);
Response detailResponse = mobileService.appItemDetail(authorization.dafuwengLogin(uid),appItemId);
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
logger.info("商品兑换按钮:" + exchangeText);
//第二次兑换
try{
response = gawService.couponExchange2(uid, appItemId,credits,actualCredits,skuid,bl);
response.prettyPrint();
}catch (Exception e){
message = e.toString();
}
logger.info(message);
Assert.assertTrue(message.contains("\"success\":false"),"校验success失败");
Assert.assertEquals(exchangeText,"已达兑换次数上限","校验兑换按钮失败");
logger.info("校验策略价会员商品自有卡密--商品周期限购小于会员限制成功");
}catch (Exception e){
throw new Exception("异常信息打印:" + e);
}
}
@Test(description = "策略价会员商品自有卡密--会员限制兑换")
public void 策略商品商品卡密设置会员限制() throws Exception{
String appItemId = "199428";
int skuid=241;
String message = "";
String actualCredits="21";
String credits="21";
// //会员等级无法兑换
try{
Thread.sleep(4000);
Response response = gawService.couponExchange2(uid, appItemId,actualCredits,credits,skuid,bl);
response.prettyPrint();
}catch (Exception e){
message = e.toString();
}
Response detailResponse = mobileService.appItemDetail(authorization.dafuwengLogin(uid),appItemId);
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
logger.info("商品兑换按钮:" + exchangeText);
Assert.assertTrue(message.contains("\"success\":false"),"校验success失败");
Assert.assertEquals(exchangeText,"暂无兑换权限","校验兑换按钮失败");
logger.info("校验策略会员商品自有优惠券周期兑换上限成功");
// 会员等级可兑换,vip=1
Thread.sleep(4000);
Response response = gawService.couponExchange(authorization.generateSignAutoLogin("3tzVcss7SnAvA5ppT1m1rMPhaBcD",7083,1),appItemId,skuid,bl);
response.prettyPrint();
Assert.assertEquals(response.jsonPath().getString("success"),"true","校验兑换结果失败");
logger.info("校验实物会员等级成功");
}
@Test(description = "策略价会员商品自有卡密--会员未限制,商品限制无法兑换")
public void 策略商品商品卡密设置商品设置会员未限制() throws Exception{
String appItemId = "199429";
int skuid=242;
String message = "";
String actualCredits="21";
String credits="21";
// //会员等级无法兑换
try{
Thread.sleep(2000);
Response response = gawService.couponExchange2(uid, appItemId,actualCredits,credits,skuid,bl);
response.prettyPrint();
}catch (Exception e){
message = e.toString();
}
Response detailResponse = mobileService.appItemDetail(authorization.dafuwengLogin(uid),appItemId);
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
logger.info("商品兑换按钮:" + exchangeText);
Assert.assertTrue(message.contains("\"success\":false"),"校验success失败");
Assert.assertEquals(exchangeText,"无兑换权限","校验兑换按钮失败");
Assert.assertTrue(message.contains("未达到会员等级要求"),"校验兑换按钮失败");
logger.info("策略价会员商品自有实物--会员未限制,商品限制无法兑换");
}
}
package http.cases.ExchangeTest.策略会员商品;
import http.cases.ExchangeTest.CheckTemplet;
import http.service.Authorization;
import http.service.app.MobileService;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import utils.MatcherString;
import java.sql.SQLException;
public class 策略价会员商品自有实物_兑换流程测试_ExchangeTest extends CheckTemplet {
@Autowired
http.service.app.gawService gawService;
@Autowired
http.service.app.tawService tawService;
@Autowired
MobileService mobileService;
@Autowired
Authorization authorization;
//指定用户
private static int uid = 6926;
boolean bl=true;
private String url = "http://activity.m.duibatest.com.cn";
@BeforeMethod
public void beforeMethod(){
try {
//永久
jdbc.update("DELETE FROM marketing.tb_vip_goods_consumer_limit_record WHERE app_item_id =199413");
System.out.println("delete-----------===========199413");
//每日限量
jdbc.update("DELETE FROM marketing.tb_vip_goods_consumer_limit_record WHERE app_item_id =199410");
System.out.println("delete-----------===========199410");
//周期限量
jdbc.update("DELETE FROM marketing.tb_vip_goods_consumer_limit_record WHERE app_item_id =199414");
System.out.println("delete-----------===========199414");
//商品每天限制
jdbc.update("DELETE FROM credits_dev.consumer_limit_record where app_item_id =199415");
jdbc.update("DELETE FROM marketing.tb_vip_goods_consumer_limit_record WHERE app_item_id =199415");
//商品永久限制
jdbc.update("DELETE FROM credits_dev.consumer_limit_record where app_item_id =199416");
jdbc.update("DELETE FROM credits_dev.consumer_limit_record_only where app_item_id =199416");
jdbc.update("DELETE FROM marketing.tb_vip_goods_consumer_limit_record WHERE app_item_id =199416");
//商品周期限制
jdbc.update("DELETE FROM credits_dev.consumer_limit_record where app_item_id =199417");
jdbc.update("DELETE FROM credits_dev.consumer_limit_record_only where app_item_id =199417");
jdbc.update("DELETE FROM marketing.tb_vip_goods_consumer_limit_record WHERE app_item_id =199417");
} catch (SQLException e) {
e.printStackTrace();
}
}
@Test(description = "策略价会员商品自有实物--会员未限制,商品限制无法兑换")
public void 策略商品商品设置会员限制() throws Exception{
String appItemId = "199418";
String itemId = "null";
String message = "";
String skuId="231";
String actualCredits="43";
String credits="43";
//会员等级无法兑换
try{
//会员等级可兑换,vip=2
Thread.sleep(3000);
Response response =gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits,bl);
response.prettyPrint();
logger.info(response.toString());
}catch (Exception e){
message = e.toString();
}
logger.info(message.toString());
Assert.assertTrue(message.contains("未达到会员等级要求"),"校验message失败");
Assert.assertTrue(message.contains("\"success\":false"),"校验success失败");
logger.info("校验策略会员商品自有实物---会员兑换限制成功");
}
@Test(description = "策略价会员商品自有实物--会员限制无法兑换")
public void 策略商品会员限制() throws Exception{
String appItemId = "199278";
String itemId = "null";
String message = "";
String skuId="220";
String actualCredits="20";
String credits="20";
//会员等级无法兑换
try{
//会员等级可兑换,vip=2
Thread.sleep(3000);
Response response =gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits,bl);
response.prettyPrint();
logger.info(response.toString());
}catch (Exception e){
message = e.toString();
}
logger.info(message.toString());
Assert.assertTrue(message.contains("\"desc\":\"哎呀,网络出现异常,刷新试试~"),"校验message失败");
Assert.assertTrue(message.contains("\"success\":false"),"校验success失败");
logger.info("校验策略会员商品自有实物---会员兑换限制成功");
}
@Test(description = "策略价会员商品自有实物--每日兑换限制")
public void 策略会员兑换_每日兑换限制() throws Exception{
String appItemId = "199410";
String itemId = "null";
String message = "";
String skuId="225";
String actualCredits="9";
String credits="9";
boolean bl=true;
//会员等级无法兑换
try{
//会员等级可兑换,vip=0和1,默认用户等级是0,第一次兑换
System.out.println("**************第一次兑换");
Thread.sleep(1000);
Response response =gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits,bl);
// response.prettyPrint();
String orderId = response.jsonPath().getString("data.orderId");
//获取兑换结果
response = tawService.orderStatus(orderId,uid);
response.prettyPrint();
String status = response.jsonPath().getString("data.status");
int i = 10;
//异步接口,直到兑换成功
while (i> 0 && status.equals("processing")) {
Thread.sleep(1000);
response = tawService.orderStatus(orderId,uid);
response.prettyPrint();
status = response.jsonPath().getString("data.status");
i--;
}
Assert.assertEquals(status,"wait_delivery","校验轮询结果status失败");
Thread.sleep(5000);
Response detailResponse = mobileService.appItemDetail(authorization.dafuwengLogin(uid),appItemId);
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
logger.info("商品兑换按钮:" + exchangeText);
//第二次兑换
try{
System.out.println("**************第二次兑换");
response = gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits,bl);
response.prettyPrint();
}catch (Exception e){
message = e.toString();
}
logger.info(message);
Assert.assertTrue(message.contains("\"success\":false"),"校验success失败");
Assert.assertEquals(exchangeText,"已达兑换上限","校验兑换按钮失败");
logger.info("校验自有新实物每日限量限制成功");
}catch (Exception e){
message = e.toString();
}
}
@Test(description = "策略价会员商品自有实物--永久兑换限制")
public void 策略会员兑换_永久兑换限制() throws Exception{
String appItemId = "199413";
String itemId = "null";
String message = "";
String skuId="226";
String actualCredits="32";
String credits="32";
boolean bl=true;
//会员等级无法兑换
try{
//会员等级可兑换,vip=0和1,默认用户等级是0,第一次兑换
System.out.println("*****3*********第一次兑换");
Thread.sleep(1000);
Response response =gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits,bl);
// response.prettyPrint();
String orderId = response.jsonPath().getString("data.orderId");
//获取兑换结果
response = tawService.orderStatus(orderId,uid);
response.prettyPrint();
String status = response.jsonPath().getString("data.status");
int i = 10;
//异步接口,直到兑换成功
while (i> 0 && status.equals("processing")) {
Thread.sleep(1000);
response = tawService.orderStatus(orderId,uid);
response.prettyPrint();
status = response.jsonPath().getString("data.status");
i--;
}
Assert.assertEquals(status,"wait_delivery","校验轮询结果status失败");
Thread.sleep(5000);
Response detailResponse = mobileService.appItemDetail(authorization.dafuwengLogin(uid),appItemId);
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
logger.info("商品兑换按钮:" + exchangeText);
//第二次兑换
try{
System.out.println("**************2222第二次兑换");
response = gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits,bl);
response.prettyPrint();
}catch (Exception e){
message = e.toString();
}
logger.info(message);
Assert.assertTrue(message.contains("\"success\":false"),"校验success失败");
Assert.assertEquals(exchangeText,"已达兑换上限","校验兑换按钮失败");
Assert.assertTrue(message.contains("\"desc\":\"会员商品已达最高限购次数\""),"校验兑换按钮失败");
logger.info("校验策略会员商品自有新实物永久限量限制成功");
}catch (Exception e){
message = e.toString();
}
}
@Test(description = "策略价会员商品自有实物--周期兑换限制")
public void 策略会员兑换_周期兑换限制() throws Exception{
String appItemId = "199414";
String itemId = "null";
String message = "";
String skuId="227";
String actualCredits="88";
String credits="88";
boolean bl=true;
//会员等级无法兑换
try{
//会员等级可兑换,vip=0和1,默认用户等级是0,第一次兑换
Thread.sleep(1000);
Response response =gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits,bl);
// response.prettyPrint();
String orderId = response.jsonPath().getString("data.orderId");
//获取兑换结果
response = tawService.orderStatus(orderId,uid);
response.prettyPrint();
String status = response.jsonPath().getString("data.status");
int i = 10;
//异步接口,直到兑换成功
while (i> 0 && status.equals("processing")) {
Thread.sleep(1000);
response = tawService.orderStatus(orderId,uid);
response.prettyPrint();
status = response.jsonPath().getString("data.status");
i--;
}
Assert.assertEquals(status,"wait_delivery","校验轮询结果status失败");
Thread.sleep(5000);
Response detailResponse = mobileService.appItemDetail(authorization.dafuwengLogin(uid),appItemId);
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
logger.info("商品兑换按钮:" + exchangeText);
//第二次兑换
try{
response = gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits,bl);
response.prettyPrint();
}catch (Exception e){
message = e.toString();
}
logger.info(message);
Assert.assertTrue(message.contains("\"success\":false"),"校验success失败");
Assert.assertEquals(exchangeText,"已达兑换上限","校验兑换按钮失败");
Assert.assertTrue(message.contains("\"desc\":\"会员商品已达最高限购次数\""),"校验兑换按钮失败");
logger.info("校验策略会员商品自有新实物永久限量限制成功");
}catch (Exception e){
message = e.toString();
}
}
@Test(description = "策略会员兑换_商品限制值小于会员都设置兑换限制--每日兑换限制")
public void 策略会员兑换_商品限制值小于会员都设置每日兑换限制() throws Exception{
String appItemId = "199415";
String itemId = "null";
String message = "";
String skuId="228";
String actualCredits="55";
String credits="55";
boolean bl=true;
//会员等级无法兑换
try{
//会员等级可兑换,vip=0和1,默认用户等级是0,第一次兑换
Thread.sleep(1000);
Response response =gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits,bl);
// response.prettyPrint();
String orderId = response.jsonPath().getString("data.orderId");
//获取兑换结果
response = tawService.orderStatus(orderId,uid);
response.prettyPrint();
String status = response.jsonPath().getString("data.status");
int i = 10;
//异步接口,直到兑换成功
while (i> 0 && status.equals("processing")) {
Thread.sleep(1000);
response = tawService.orderStatus(orderId,uid);
response.prettyPrint();
status = response.jsonPath().getString("data.status");
i--;
}
Assert.assertEquals(status,"wait_delivery","校验轮询结果status失败");
Thread.sleep(5000);
Response detailResponse = mobileService.appItemDetail(authorization.dafuwengLogin(uid),appItemId);
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
logger.info("商品兑换按钮:" + exchangeText);
//第二次兑换
try{
System.out.println("**************第二次兑换");
response = gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits,bl);
response.prettyPrint();
}catch (Exception e){
message = e.toString();
}
logger.info(message);
Assert.assertTrue(message.contains("\"success\":false"),"校验success失败");
Assert.assertEquals(exchangeText,"今日已达兑换上限","校验兑换按钮失败");
logger.info("策略会员兑换_商品限制值小于会员都设置兑换限制--每日兑换限制,取商品限购");
}catch (Exception e){
message = e.toString();
}
}
@Test(description = "策略会员兑换_商品限制值小于会员都设置兑换限制--永久兑换限制")
public void 策略会员兑换_商品限制值小于会员都设置永久兑换限制() throws Exception{
String appItemId = "199416";
String itemId = "null";
String message = "";
String skuId="229";
String actualCredits="29";
String credits="29";
boolean bl=true;
//会员等级无法兑换
try{
//会员等级可兑换,vip=0和1,默认用户等级是0,第一次兑换
Thread.sleep(1000);
Response response =gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits,bl);
// response.prettyPrint();
String orderId = response.jsonPath().getString("data.orderId");
//获取兑换结果
response = tawService.orderStatus(orderId,uid);
response.prettyPrint();
String status = response.jsonPath().getString("data.status");
int i = 10;
//异步接口,直到兑换成功
while (i> 0 && status.equals("processing")) {
Thread.sleep(1000);
response = tawService.orderStatus(orderId,uid);
response.prettyPrint();
status = response.jsonPath().getString("data.status");
i--;
}
Assert.assertEquals(status,"wait_delivery","校验轮询结果status失败");
Thread.sleep(5000);
Response detailResponse = mobileService.appItemDetail(authorization.dafuwengLogin(uid),appItemId);
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
logger.info("商品兑换按钮:" + exchangeText);
//第二次兑换
try{
System.out.println("**************第二次兑换");
response = gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits,bl);
response.prettyPrint();
}catch (Exception e){
message = e.toString();
}
logger.info(message);
Assert.assertTrue(message.contains("\"success\":false"),"校验success失败");
Assert.assertEquals(exchangeText,"已达兑换次数上限","校验兑换按钮失败");
logger.info("策略会员兑换_商品限制值小于会员都设置兑换限制--永久兑换限制,取商品限购");
}catch (Exception e){
message = e.toString();
}
}
@Test(description = "策略会员兑换_商品限制值小于会员都设置兑换限制--周期兑换限制")
public void 策略会员兑换_商品限制值小于会员都设置周期兑换限制() throws Exception{
String appItemId = "199417";
String itemId = "null";
String message = "";
String skuId="230";
String actualCredits="13";
String credits="13";
boolean bl=true;
//会员等级无法兑换
try{
//会员等级可兑换,vip=0和1,默认用户等级是0,第一次兑换
Thread.sleep(1000);
Response response =gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits,bl);
// response.prettyPrint();
String orderId = response.jsonPath().getString("data.orderId");
//获取兑换结果
response = tawService.orderStatus(orderId,uid);
response.prettyPrint();
String status = response.jsonPath().getString("data.status");
int i = 10;
//异步接口,直到兑换成功
while (i> 0 && status.equals("processing")) {
Thread.sleep(1000);
response = tawService.orderStatus(orderId,uid);
response.prettyPrint();
status = response.jsonPath().getString("data.status");
i--;
}
Assert.assertEquals(status,"wait_delivery","校验轮询结果status失败");
Thread.sleep(5000);
Response detailResponse = mobileService.appItemDetail(authorization.dafuwengLogin(uid),appItemId);
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
logger.info("商品兑换按钮:" + exchangeText);
//第二次兑换
try{
System.out.println("**************第二次兑换");
response = gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits,bl);
response.prettyPrint();
}catch (Exception e){
message = e.toString();
}
logger.info(message);
Assert.assertTrue(message.contains("\"success\":false"),"校验success失败");
Assert.assertEquals(exchangeText,"今日已达兑换上限","校验兑换按钮失败");
logger.info("策略会员兑换_商品限制值小于会员都设置兑换限制--周期兑换限制,取商品限购");
}catch (Exception e){
message = e.toString();
}
}
}
......@@ -35,6 +35,7 @@ public class 自有新优惠券_兑换限制测试_ExchangeTest extends CheckTem
private int uid = 7003;
private String consumerId = "100144145";
private boolean bl=false;
private String url = "http://activity.m.duibatest.com.cn";
......@@ -362,14 +363,13 @@ public class 自有新优惠券_兑换限制测试_ExchangeTest extends CheckTem
@Test
public void 会员等级测试()throws Exception{
String appItemId = "193848";
String message = "";
//会员等级无法兑换
try{
Thread.sleep(4000);
Response response = gawService.couponExchange(authorization.dafuwengLogin(uid), appItemId,45);
Response response = gawService.couponExchange(authorization.dafuwengLogin(uid), appItemId,45,bl);
response.prettyPrint();
}catch (Exception e){
......@@ -379,7 +379,7 @@ public class 自有新优惠券_兑换限制测试_ExchangeTest extends CheckTem
//会员等级可兑换,vip=5
Thread.sleep(4000);
Response response = gawService.couponExchange(authorization.generateSignAutoLogin("3tzVcss7SnAvA5ppT1m1rMPhaBcD",7083,1),appItemId,45);
Response response = gawService.couponExchange(authorization.generateSignAutoLogin("3tzVcss7SnAvA5ppT1m1rMPhaBcD",7083,1),appItemId,45,bl);
response.prettyPrint();
Assert.assertTrue(message.contains("未达到会员等级要求"),"校验message失败");
......@@ -524,7 +524,7 @@ public class 自有新优惠券_兑换限制测试_ExchangeTest extends CheckTem
//优惠券兑换
Thread.sleep(4000);
Response response = gawService.couponExchange(authorization.dafuwengLogin(uid),appItemId,skuId);
Response response = gawService.couponExchange(authorization.dafuwengLogin(uid),appItemId,skuId,bl);
response.prettyPrint();
String orderId = response.jsonPath().getString("data.orderId");
//获取兑换结果
......@@ -656,7 +656,6 @@ public class 自有新优惠券_兑换限制测试_ExchangeTest extends CheckTem
status = response.jsonPath().getString("data.status");
i--;
}
mapStock = jdbc.findSimpleResult("SELECT * FROM stock.tb_stock WHERE stock_id = 1060747299329170094");
String newStock = String.valueOf(mapStock.get("stock"));
String result = String.valueOf(Integer.valueOf(stock)-1);
......
......@@ -44,6 +44,7 @@ public class 自有新卡密_兑换限制测试_ExchangeTest extends CheckTemple
private int uid = 7004;
private String consumerId = "100144146";
private boolean bl=false;
private String url = "http://activity.m.duibatest.com.cn";
......@@ -326,7 +327,7 @@ public class 自有新卡密_兑换限制测试_ExchangeTest extends CheckTemple
//兑换
try{
Thread.sleep(4000);
response = gawService.couponExchange(authorization.dafuwengLogin(uid), appItemId, skuId);
response = gawService.couponExchange(authorization.dafuwengLogin(uid), appItemId, skuId,bl);
}catch (Exception e){
message = e.getMessage();
......@@ -384,7 +385,7 @@ public class 自有新卡密_兑换限制测试_ExchangeTest extends CheckTemple
//会员等级无法兑换
try{
Thread.sleep(4000);
Response response = gawService.couponExchange(authorization.dafuwengLogin(uid), appItemId,86);
Response response = gawService.couponExchange(authorization.dafuwengLogin(uid), appItemId,86,bl);
response.prettyPrint();
}catch (Exception e){
......@@ -394,7 +395,7 @@ public class 自有新卡密_兑换限制测试_ExchangeTest extends CheckTemple
//会员等级可兑换,vip=5
Thread.sleep(4000);
Response response = gawService.couponExchange(authorization.generateSignAutoLogin("3tzVcss7SnAvA5ppT1m1rMPhaBcD",7083,1),appItemId,86);
Response response = gawService.couponExchange(authorization.generateSignAutoLogin("3tzVcss7SnAvA5ppT1m1rMPhaBcD",7083,1),appItemId,86,bl);
response.prettyPrint();
Assert.assertTrue(message.contains("未达到会员等级要求"),"校验message失败");
......
......@@ -71,11 +71,12 @@ public class 自有新实物_兑换流程测试_ExchangeTest extends CheckTemple
String skuId="17";
String actualCredits="1";
String credits="1";
boolean bl=false;
try{
//第一次兑换
Thread.sleep(3000);
Response response = gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits);
Response response = gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits,bl);
String orderId = response.jsonPath().getString("data.orderId");
//获取兑换结果
response = tawService.orderStatus(orderId,uid);
......@@ -99,7 +100,7 @@ public class 自有新实物_兑换流程测试_ExchangeTest extends CheckTemple
//第二次兑换
try{
response = gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits);
response = gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits,bl);
response.prettyPrint();
}catch (Exception e){
......@@ -125,10 +126,12 @@ public class 自有新实物_兑换流程测试_ExchangeTest extends CheckTemple
String skuId="24";
String actualCredits="2";
String credits="2";
boolean bl=false;
try{
//第一次兑换
Thread.sleep(3000);
Response response = gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits);
Response response = gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits,bl);
logger.info("********1"+"111111");
String orderId = response.jsonPath().getString("data.orderId");
//获取兑换结果
......@@ -152,7 +155,7 @@ public class 自有新实物_兑换流程测试_ExchangeTest extends CheckTemple
//第二次兑换
try{
response = gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits);
response = gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits,bl);
logger.info("********2");
response.prettyPrint();
......@@ -181,10 +184,12 @@ public class 自有新实物_兑换流程测试_ExchangeTest extends CheckTemple
String skuId="25";
String actualCredits="3";
String credits="3";
boolean bl=false;
try{
//第一次兑换
Thread.sleep(3000);
Response response = gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits);
Response response = gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits,bl);
String orderId = response.jsonPath().getString("data.orderId");
//获取兑换结果
response = tawService.orderStatus(orderId,uid);
......@@ -206,7 +211,8 @@ public class 自有新实物_兑换流程测试_ExchangeTest extends CheckTemple
// logger.info("商品兑换按钮:" + exchangeText);
//第二次兑换
try{
response = gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits);
response = gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits,bl
);
response.prettyPrint();
}catch (Exception e){
......@@ -233,10 +239,13 @@ public class 自有新实物_兑换流程测试_ExchangeTest extends CheckTemple
String skuId="26";
String actualCredits="5";
String credits="5";
boolean bl=false;
try{
//第一次兑换
Thread.sleep(3000);
Response response = gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits);
Response response = gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits,bl
);
String orderId = response.jsonPath().getString("data.orderId");
//获取兑换结果
response = tawService.orderStatus(orderId,uid);
......@@ -258,7 +267,8 @@ public class 自有新实物_兑换流程测试_ExchangeTest extends CheckTemple
// logger.info("商品兑换按钮:" + exchangeText);
//第二次兑换
try{
response = gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits);
response = gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits,bl
);
response.prettyPrint();
}catch (Exception e){
......@@ -336,6 +346,8 @@ public class 自有新实物_兑换流程测试_ExchangeTest extends CheckTemple
String skuId="33";
String actualCredits="8";
String credits="8";
boolean bl=false;
jdbc.update("UPDATE stock.tb_stock set stock = 0 where stock_id = 940298957084170033");
Thread.sleep(1000);
......@@ -347,7 +359,7 @@ public class 自有新实物_兑换流程测试_ExchangeTest extends CheckTemple
try{
Thread.sleep(3000);
Response response = gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits);
Response response = gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits,bl);
response.prettyPrint();
}catch (Exception e){
......@@ -448,10 +460,10 @@ public class 自有新实物_兑换流程测试_ExchangeTest extends CheckTemple
String appItemId = "197041";
String itemId = null ;
String skuId = "159";
boolean bl=false;
//实物兑换,积分传0
Response response =gawService.objectExchange(uid,appItemId,itemId,skuId,"0","0");
Response response =gawService.objectExchange(uid,appItemId,itemId,skuId,"0","0",bl);
response.prettyPrint();
String orderId = response.jsonPath().getString("data.orderId");
......@@ -506,6 +518,8 @@ public class 自有新实物_兑换流程测试_ExchangeTest extends CheckTemple
String skuId = "183";
String credits = "10";
String actualCredits = "10";
boolean bl=false;
//查询兑换前的库存
//stock_id 通过表tb_app_item_sku 来查询
......@@ -513,7 +527,7 @@ public class 自有新实物_兑换流程测试_ExchangeTest extends CheckTemple
String stock = String.valueOf(mapStock.get("stock"));
logger.info("兑换前的库存:" + stock);
Response response = gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits);
Response response = gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits,bl);
String orderId = response.jsonPath().getString("data.orderId");
//获取兑换结果
response = tawService.orderStatus(orderId,uid);
......
package http.cases.LotterySquareTest;
import base.DuibaTestBase;
import http.service.Activity.LotterySquareService;
import io.restassured.response.Response;
import org.apache.ibatis.jdbc.SQL;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import java.sql.SQLException;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CopyOnWriteArrayList;
/**
* Created by lvwenyan on 2019/12/21
*/
public class 红包广场提现_AccessTest extends DuibaTestBase {
@Autowired
LotterySquareService lotterySquareService;
@Test(description = "用户提现成功测试")
public void 红包提现成功() throws Exception{
int uid = 7450;
String activityId = "1";
String money = "1";
//查询提现页面
Response indexResponse = lotterySquareService.cashIndexInfo(uid,activityId);
indexResponse.prettyPrint();
String accountBalance = indexResponse.jsonPath().getString("data.accountBalance");
String leftCashTimes = indexResponse.jsonPath().getString("data.leftCashTimes");
logger.info("钱包余额:" + accountBalance);
logger.info("剩余可提现次数:" + leftCashTimes);
String accountBalanceResult = String.valueOf(Integer.valueOf(accountBalance) -100) ;
String leftCashTimesResult = String.valueOf(Integer.valueOf(leftCashTimes) -1) ;
//提现接口
Response cashDrawsResponse = lotterySquareService.cashDraws(uid,activityId,money);
cashDrawsResponse.prettyPrint();
//再次查询提现页面
indexResponse = lotterySquareService.cashIndexInfo(uid,activityId);
accountBalance = indexResponse.jsonPath().getString("data.accountBalance");
leftCashTimes = indexResponse.jsonPath().getString("data.leftCashTimes");
logger.info("提现后钱包余额:" + accountBalance);
logger.info("提现后剩余可提现次数:" + leftCashTimes);
Assert.assertEquals(accountBalance,accountBalanceResult,"校验accountBalance失败");
Assert.assertEquals(leftCashTimes,leftCashTimesResult,"校验leftCashTimes失败");
logger.info("校验成功:红包广场提现1元");
}
@Test(description = "用户提现失败测试:支付宝账号已被绑定")
public void 支付宝账号已被绑定() throws Exception{
int uid = 7451;
String activityId = "1";
String money = "1";
String account = "peeulk6392@sandbox.com";
String username = "沙箱环境";
Response response = lotterySquareService.cashDraws2(uid,activityId,money,account,username);
response.prettyPrint();
Assert.assertEquals(response.jsonPath().getString("success"),"false","校验success失败");
Assert.assertEquals(response.jsonPath().getString("desc"),"该支付宝账号已被绑定,请更换","校验desc失败");
logger.info("校验成功:支付宝账号已被绑定提现失败");
}
@Test(description = "用户提现失败测试:支付宝账号非法")
public void 支付宝账号非法() throws Exception{
int uid = 7451;
String activityId = "1";
String money = "1";
String account = "lvwenyan@duiba.co";
String username = "吕雯燕";
Response response = lotterySquareService.cashDraws2(uid,activityId,money,account,username);
response.prettyPrint();
Assert.assertEquals(response.jsonPath().getString("success"),"false","校验success失败");
Assert.assertEquals(response.jsonPath().getString("desc"),"系统异常,请稍后再试","校验desc失败");
logger.info("校验成功:支付宝账号非法提现失败");
}
@Test(description = "用户提现失败测试:钱包余额不足")
public void 钱包余额不足() throws Exception{
int uid = 7453;
String activityId = "1";
String money = "1";
String account = "lvwenyan5@duiba.com.cn";
String username = "吕雯燕";
Response response = lotterySquareService.cashDraws2(uid,activityId,money,account,username);
response.prettyPrint();
Assert.assertEquals(response.jsonPath().getString("success"),"false","校验success失败");
Assert.assertEquals(response.jsonPath().getString("desc"),"余额不足","校验desc失败");
logger.info("校验成功:钱包余额不足提现失败");
}
@Test(description = "用户提现测试:金额超过固定额度")
public void 金额超过固定额度() throws Exception{
int uid = 7454;
String activityId = "2";
//固定额度:1元,提现100元
String money = "100";
String account = "peeulk6392@sandbox.com";
String username = "沙箱环境";
//用户提现
Response response = lotterySquareService.cashDraws2(uid,activityId,money,account,username);
response.prettyPrint();
//账户资金流水
Response detailResponse = lotterySquareService.accountDetail(uid,activityId);
detailResponse.prettyPrint();
Assert.assertEquals(response.jsonPath().getString("success"),"true","校验success失败");
Assert.assertEquals(detailResponse.jsonPath().getString("data.list[0].money"),"1.0","校验money失败");
Assert.assertEquals(detailResponse.jsonPath().getString("data.list[0].description"),"红包广场提现操作","校验description失败");
logger.info("校验成功:金额超过固定额度只能提现1元");
}
@Test(description = "用户提现失败测试:提现次数不足")
public void 提现次数不足() throws Exception{
int uid = 7455;
String activityId = "3";
String money = "1";
String account = "lvwenyan@duiba.com.cn";
String username = "吕雯燕";
Response response = lotterySquareService.cashDraws2(uid,activityId,money,account,username);
response.prettyPrint();
Assert.assertEquals(response.jsonPath().getString("success"),"false","校验success失败");
Assert.assertEquals(response.jsonPath().getString("desc"),"活动期间提现次数已达上限","校验desc失败");
logger.info("校验成功:提现次数不足无法提现");
}
}
......@@ -44,6 +44,7 @@ public class 权益一期线上用户核销中匹配兑换码兑换_DuibaTest ex
Response response = equityPrizeService.exchange(authorization.dafuwengLogin(uid), exc_code, null);
Thread.sleep(2000);
Map<String, Object> ChangeStock = jdbc.findSimpleResult("SELECT * FROM stock.tb_stock WHERE stock_id =1173112680215170105");
String exchanggeStock = String.valueOf(ChangeStock.get("stock"));
......@@ -66,9 +67,11 @@ public class 权益一期线上用户核销中匹配兑换码兑换_DuibaTest ex
throw new Exception("异常信息打印:" + e);
}
jdbc.update("update goods.tb_equity_goods_record set consumer_id=null ,partner_user_id=null" +
" ,app_item_id=null ,verification_time=null ,order_num=null where exc_code = '"+exc_code+"'");
}finally {
jdbc.update("update goods.tb_equity_goods_record set consumer_id=null ,partner_user_id=null" +
" ,app_item_id=null ,verification_time=null ,order_num=null where exc_code = '"+exc_code+"'");
}
}
@Test
......@@ -266,6 +269,7 @@ public class 权益一期线上用户核销中匹配兑换码兑换_DuibaTest ex
//第一次核销
logger.info("用户第一次核销");
Response response = equityPrizeService.exchange(authorization.dafuwengLogin(uid), exc_code, null);
Thread.sleep(2000);
Map<String, Object> ChangeStock = jdbc.findSimpleResult("SELECT * FROM stock.tb_stock WHERE stock_id =1178701910023420109");
//第一次兑换之后的商品的库存成功
String exchanggeStock = String.valueOf(ChangeStock.get("stock"));
......@@ -284,8 +288,10 @@ public class 权益一期线上用户核销中匹配兑换码兑换_DuibaTest ex
logger.info("进行第二次核销");
response = equityPrizeService.exchange(authorization.dafuwengLogin(uid), exc_code1, null);
ChangeStock = jdbc.findSimpleResult("SELECT * FROM stock.tb_stock WHERE stock_id =1178701910023420109");
exchanggeStock = String.valueOf(ChangeStock.get("stock"));
Thread.sleep(2000);
ChangeStock = jdbc.findSimpleResult("SELECT * FROM stock.tb_stock WHERE stock_id =1178701910023420109");
exchanggeStock = String.valueOf(ChangeStock.get("stock"));
//response.prettyPrint();
//获取到 code 数据
code = response.jsonPath().getString("code");
......@@ -315,12 +321,14 @@ public class 权益一期线上用户核销中匹配兑换码兑换_DuibaTest ex
throw new Exception("异常信息打印:" + e);
}finally {
jdbc.update("update goods.tb_equity_goods_record set consumer_id=null ,partner_user_id=null" +
" ,app_item_id=null ,verification_time=null ,order_num=null where exc_code = '"+exc_code+"'");
jdbc.update("update goods.tb_equity_goods_record set consumer_id=null ,partner_user_id=null" +
" ,app_item_id=null ,verification_time=null ,order_num=null where exc_code = '"+exc_code1+"'");
jdbc.update("DELETE FROM goods.tb_everyday_limit where app_item_id ='199280 '");
}
jdbc.update("update goods.tb_equity_goods_record set consumer_id=null ,partner_user_id=null" +
" ,app_item_id=null ,verification_time=null ,order_num=null where exc_code = '"+exc_code+"'");
jdbc.update("update goods.tb_equity_goods_record set consumer_id=null ,partner_user_id=null" +
" ,app_item_id=null ,verification_time=null ,order_num=null where exc_code = '"+exc_code1+"'");
jdbc.update("DELETE FROM goods.tb_everyday_limit where app_item_id ='199280 '");
}
}
......
package http.cases.equitySubjectTest;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import http.cases.ExchangeTest.CheckTemplet;
import http.service.Activity.equityPrizeService;
import http.service.Authorization;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.Test;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class 权益二期线上用户核销匹配权益及兑换码兑换_DuibaTest extends CheckTemplet {
@Autowired
public equityPrizeService equityPrizeService;
@Autowired
private Authorization authorization;
int uid = 7409;
@Test
//(invocationCount=5)一个权益下面多少商品的数据
public void 权益商品列表数据返回正确() throws Exception {
//权益id:12 核销下面对应的商品的 实物 :id 199281 = 优惠券id:199282
logger.info("权益类表数据返回正确 -开始了");
String equityId="12";
//查询权益下面的商品数据
Response response = equityPrizeService.chwequityGoodsList(authorization.dafuwengLogin(uid), equityId);
String code = response.jsonPath().getString("code");
Assert.assertEquals(code,"0000000000","权益类表数据返回正确接口 失败,code:"+code );
String data= JSON.parseObject(response.asString()).getString("data");
JSONArray jsonArray = JSON.parseArray(data);
List<String> list = new ArrayList();
for (Object jsonobject:
jsonArray) {
String s = jsonobject.toString();
JSONObject js = JSON.parseObject(s);
String appitem = js.getString("appItemId");
list.add(appitem);
}
//数组长度的校验 长度判断
Assert.assertEquals(list.size()+"","2","接口数据返回listsize()数值 不一致,size:"+list.size() );
String appItemId= list.get(0);
logger.info("list.get(0) appItemId:"+appItemId+"list.get(1) appItemId1:"+ list.get(1));
Assert.assertEquals(appItemId,"199281","接口获取商品的1id 不一致,code:"+appItemId );
String appItemId1= list.get(1);
Assert.assertEquals(appItemId1,"199282","接口获取商品的2id 不一致,code:"+appItemId1 );
logger.info("权益类表数据返回正确 -结束了");
}
@Test
//(invocationCount=5)一个组件下面多少个权益数据
public void 权益列表首页接口返回正确() throws Exception {
logger.info("权益列表首页接口返回正确 -开始了");
ArrayList<Integer>list=new ArrayList<Integer>();
list.add(25);
list.add(24);
Response response = equityPrizeService.chwvisualeditorfindEquityListByIds(authorization.dafuwengLogin(uid),list);
response.prettyPrint();
List<Integer> ids = response.jsonPath().getList("data.id");
Assert.assertTrue(response.jsonPath().getBoolean("success"),"接口返回失败");
// Assert.assertEquals(code,"0000000000","权益类表数据返回正确接口 失败,code:"+code );
Assert.assertEquals(ids.size(), list.size(),"数据条数不匹配");
logger.info("权益列表首页接口返回正确 -结束了");
}
@Test
//(invocationCount=5)
public void 商品兑换首页成功() throws Exception {
logger.info("商品兑换首页成功 -->开始了");
String equityId="12";
String appItemId="199281";
String appSkuId="222";
//查询权益下面的商品数据
Response response = equityPrizeService.gawequityPrizeindex(authorization.dafuwengLogin(uid),equityId,appItemId,appSkuId);
Assert.assertEquals(response.prettyPrint().contains("确认兑换"),true,"页面数据没有包含确认兑换" );
logger.info("商品兑换首页成功 -->结束了");
}
@Test
public void 兑换码为null核销() throws Exception {
logger.info(" 兑换码为null核销-->开始了");
String equityId="12";
String appItemId="199281";
String appSkuId="222";
String excCode=null;
Response response = equityPrizeService.gawequityPrizeexchange(authorization.dafuwengLogin(uid),
excCode,appItemId,equityId,appSkuId);
String code = response.jsonPath().getString("code");
String desc = response.jsonPath().getString("desc");
logger.info("code:"+code+",desc:"+desc);
//校验
Assert.assertEquals(code,"1001000","兑换码为null核销 有问题" );
response.prettyPrint();
logger.info(" 兑换码为null核销-->结束了");
}
@Test(description = "自有商品优惠券兑换")
//取值orderid 取值,等等在写
public void ZDH核销二期自有优惠券核销成功() throws Exception {
String excCode="AQAQ49";
try {
logger.info(" ZDH核销二期自有优惠券核销成功-->开始了");
String equityId="14";
String appItemId="199342";
String appSkuId="224";
Map<String, Object> mapStock = jdbc.findSimpleResult("SELECT * FROM stock.tb_stock WHERE stock_id =1180511530272670111");
//获取兑换之前优惠券的库存stock
String stock = String.valueOf(mapStock.get("stock"));
//请求核销接口
Response response = equityPrizeService.gawequityPrizeexchange(authorization.dafuwengLogin(uid),
excCode,appItemId,equityId,appSkuId);
response.prettyPrint();
Thread.sleep(2000);
mapStock = jdbc.findSimpleResult("SELECT * FROM stock.tb_stock WHERE stock_id =1180511530272670111");
//核销之后优惠券的库存
String exchanggeStock = String.valueOf(mapStock.get("stock"));
//核对兑换之后以及兑换之后的库存
logger.info("stock:"+stock +"exchanggeStock:"+exchanggeStock);
Assert.assertEquals(stock, (Integer.parseInt(exchanggeStock) + 1 + ""), "兑换之后商品库存兑换不一致-失敗");
//获取:订单号
String orderId = response.jsonPath().getString("data.orderId");
logger.info("data.orderId= :"+orderId);
Assert.assertEquals(orderId.isEmpty(), false, "订单号没有获取到");
//获取code以及desc
response.prettyPrint();
logger.info(" ZDH核销二期自有优惠券核销成功-->结束了");
}catch (Exception e){
throw new Exception("异常信息打印:" + e);
}finally {
jdbc.update("update goods.tb_equity_goods_record set consumer_id=null ,partner_user_id=null" +
" ,app_item_id=null ,verification_time=null ,order_num=null , app_sku_id =null where exc_code = '"+excCode+"'");
}
}
@Test
public void ZDH核销二期权益已过期() throws Exception{
//equityId=15
logger.info("ZDH核销二期权益已过期【】 --》开始了");
String equityId="15";
String appItemId="199477";
String appSkuId="249";
String excCode="2-ZdH9";
Response response = equityPrizeService.gawequityPrizeexchange(authorization.dafuwengLogin(uid),
excCode,appItemId,equityId,appSkuId);
String code = response.jsonPath().getString("code");
String desc = response.jsonPath().getString("desc");
logger.info("code:"+code+",desc:"+desc);
//校验
Assert.assertEquals(code,"1001003","ZDH权益已过期 有问题" );
response.prettyPrint();
logger.info(" ZDH核销二期权益已过期-->结束了");
}
@Test
//匹配权益,输入不是这个权益下的兑换码【匹配权益及兑换码兑换】
public void ZDH二期权益兑换输入其他权益的兑换码() throws Exception{
//equityId=15
logger.info("ZDH二期权益兑换输入其他权益的兑换码 --》开始了");
String equityId="14";
String appItemId="199342";
String appSkuId="224";
//exeCode 是权益equityId=15 下的 2-ZdH9
String excCode="2-ZdH9";
Response response = equityPrizeService.gawequityPrizeexchange(authorization.dafuwengLogin(uid),
excCode,appItemId,equityId,appSkuId);
String code = response.jsonPath().getString("code");
String desc = response.jsonPath().getString("desc");
logger.info("code:"+code+",desc:"+desc);
//校验
Assert.assertEquals(code,"1001000","ZDH二期权益兑换输入其他权益的兑换码 有问题" );
response.prettyPrint();
logger.info(" ZDH二期权益兑换输入其他权益的兑换码-->结束了");
}
@Test
public void ZDH二期权益兑换输入不存在的兑换码() throws Exception{
//equityId=15
logger.info("ZDH二期权益兑换输入不存在的兑换码( --》开始了");
String equityId="14";
String appItemId="199342";
String appSkuId="224";
String excCode="AJDNKDNCKDNVKDNKKSNKDN";
Response response = equityPrizeService.gawequityPrizeexchange(authorization.dafuwengLogin(uid),
excCode,appItemId,equityId,appSkuId);
String code = response.jsonPath().getString("code");
String desc = response.jsonPath().getString("desc");
logger.info("code:"+code+",desc:"+desc);
//校验
Assert.assertEquals(code,"1001000","ZDH二期权益兑换输入不存在的兑换码( 有问题" );
response.prettyPrint();
logger.info(" ZDH二期权益兑换输入不存在的兑换码(-->结束了");
}
@Test
public void ZDH二期权益权益删除() throws Exception{
//equityId=15
logger.info("ZDH二期权益权益删除( --》开始了");
String equityId="16";
String appItemId="199478";
String appSkuId="250";
String excCode="2-ZdH-DELET8";
Response response = equityPrizeService.gawequityPrizeexchange(authorization.dafuwengLogin(uid),
excCode,appItemId,equityId,appSkuId);
String code = response.jsonPath().getString("code");
String desc = response.jsonPath().getString("desc");
logger.info("code:"+code+",desc:"+desc);
//校验
Assert.assertEquals(code,"1001000","ZDH二期权益权益删除( 有问题" );
response.prettyPrint();
logger.info(" ZDH二期权益权益删除(-->结束了");
}
@Test
public void ZDH兑换码删除输入删除的兑换码() throws Exception{
//equityId=15
logger.info("2-ZDH兑换码删除输入删除的兑换码( --》开始了");
String equityId="17";
String appItemId="199479";
String appSkuId="251";
String excCode="2-ZdHDHUN2";
Response response = equityPrizeService.gawequityPrizeexchange(authorization.dafuwengLogin(uid),
excCode,appItemId,equityId,appSkuId);
String code = response.jsonPath().getString("code");
String desc = response.jsonPath().getString("desc");
logger.info("code:"+code+",desc:"+desc);
//校验
Assert.assertEquals(code,"1001000","2-ZDH兑换码删除输入删除的兑换码( 有问题" );
response.prettyPrint();
logger.info(" 2-ZDH兑换码删除输入删除的兑换码(-->结束了");
}
@Test
public void ZDH兑换码已核销再次兑换() throws Exception{
//equityId=15
logger.info("2-ZDH兑换码已核销再次兑换( --》开始了");
String equityId="14";
String appItemId="199342";
String appSkuId="224";
String excCode="AQAQ46";
Response response = equityPrizeService.gawequityPrizeexchange(authorization.dafuwengLogin(uid),
excCode,appItemId,equityId,appSkuId);
String code = response.jsonPath().getString("code");
String desc = response.jsonPath().getString("desc");
logger.info("code:"+code+",desc:"+desc);
//校验
Assert.assertEquals(code,"1001001","2-ZDH兑换码已核销再次兑换( 有问题" );
response.prettyPrint();
logger.info(" 2-ZDH兑换码已核销再次兑换(-->结束了");
}
@Test
public void ZDH权益未过期兑换码过期() throws Exception{
//equityId=15
logger.info("2-ZDH权益未过期兑换码过期( --》开始了");
String equityId="18";
String appItemId="199479";
String appSkuId="251";
String excCode="AS12";
Response response = equityPrizeService.gawequityPrizeexchange(authorization.dafuwengLogin(uid),
excCode,appItemId,equityId,appSkuId);
String code = response.jsonPath().getString("code");
String desc = response.jsonPath().getString("desc");
logger.info("code:"+code+",desc:"+desc);
//校验
Assert.assertEquals(code,"1001003","2-ZDH权益未过期兑换码过期( 有问题" );
response.prettyPrint();
logger.info(" 2-ZDH权益未过期兑换码过期(-->结束了");
}
@Test
public void ZDH权益未开始进行兑换() throws Exception{
//equityId=15
logger.info("2-ZDH权益未开始进行兑换( --》开始了");
String equityId="19";
String appItemId="199480";
String appSkuId="252";
String excCode="ASQ10";
Response response = equityPrizeService.gawequityPrizeexchange(authorization.dafuwengLogin(uid),
excCode,appItemId,equityId,appSkuId);
String code = response.jsonPath().getString("code");
String desc = response.jsonPath().getString("desc");
logger.info("code:"+code+",desc:"+desc);
//校验
Assert.assertEquals(code,"1001002","2-ZDH权益未开始进行兑换( 有问题" );
response.prettyPrint();
logger.info(" 2-ZDH权益未开始进行兑换(-->结束了");
}
@Test(description = "自有商品奖品库存不足")
public void ZDH权益已开始库存不足() throws Exception{
//equityId=15
logger.info("2-ZDH权益已开始库存不足( --》开始了");
String equityId="20";
String appItemId="199481";
String appSkuId="253";
String excCode="ASQ25";
Response response = equityPrizeService.gawequityPrizeexchange(authorization.dafuwengLogin(uid),
excCode,appItemId,equityId,appSkuId);
String code = response.jsonPath().getString("code");
String desc = response.jsonPath().getString("desc");
logger.info("code:"+code+",desc:"+desc);
//校验
Assert.assertEquals(code,"1001002","2-ZDH权益已开始库存不足( 有问题" );
response.prettyPrint();
logger.info(" 2-ZDH权益已开始库存不足(-->结束了");
}
@Test(description = "自有商品单规格实物-核销成功")
public void ZDH核销二期自有商品自有商品单规格实物() throws Exception {
String excCode="ASQ55";
try {
logger.info(" ZDH核销二期自有商品自有商品单规格实物-->开始了");
String equityId="22";
String appItemId="199482";
String appSkuId="254";
Map<String, Object> mapStock = jdbc.findSimpleResult("SELECT * FROM stock.tb_stock WHERE stock_id =1187647586463670254");
//获取兑换之前优惠券的库存stock
String stock = String.valueOf(mapStock.get("stock"));
//请求核销接口
Response response = equityPrizeService.gawequityPrizeexchange(authorization.dafuwengLogin(uid),
excCode,appItemId,equityId,appSkuId);
response.prettyPrint();
Thread.sleep(2000);
mapStock = jdbc.findSimpleResult("SELECT * FROM stock.tb_stock WHERE stock_id =1187647586463670254");
//核销之后优惠券的库存
String exchanggeStock = String.valueOf(mapStock.get("stock"));
//核对兑换之后以及兑换之后的库存
logger.info("stock:"+stock +"exchanggeStock:"+exchanggeStock);
Assert.assertEquals(stock, (Integer.parseInt(exchanggeStock) + 1 + ""), "兑换之后商品库存兑换不一致-失敗");
//获取:订单号
String orderId = response.jsonPath().getString("data.orderId");
logger.info("data.orderId= :"+orderId);
Assert.assertEquals(orderId.isEmpty(), false, "订单号没有获取到");
//获取code以及desc
response.prettyPrint();
logger.info(" ZDH核销二期自有商品自有商品单规格实物-->结束了");
}catch (Exception e){
throw new Exception("异常信息打印:" + e);
}
jdbc.update("update goods.tb_equity_goods_record set consumer_id=null ,partner_user_id=null" +
" ,app_item_id=null ,verification_time=null ,order_num=null , app_sku_id =null where exc_code = '"+excCode+"'");
}
@Test(description = "自有商品多规格实物-核销成功 -选择大的 规格")
public void ZDH核销二期自有商品多规格实物核销() throws Exception {
String excCode="ASQ45";
try {
logger.info(" ZDH核销二期自有商品多规格实物核销-->开始了");
String equityId="21";
String appItemId="199483";
String appSkuId="256";
Map<String, Object> mapStock = jdbc.findSimpleResult("SELECT * FROM stock.tb_stock WHERE stock_id =1187709945218920256");
//获取兑换之前优惠券的库存stock
String stock = String.valueOf(mapStock.get("stock"));
//请求核销接口
Response response = equityPrizeService.gawequityPrizeexchange(authorization.dafuwengLogin(uid),
excCode,appItemId,equityId,appSkuId);
response.prettyPrint();
Thread.sleep(2000);
mapStock = jdbc.findSimpleResult("SELECT * FROM stock.tb_stock WHERE stock_id =1187709945218920256");
//核销之后优惠券的库存
String exchanggeStock = String.valueOf(mapStock.get("stock"));
//核对兑换之后以及兑换之后的库存
logger.info("stock:"+stock +"exchanggeStock:"+exchanggeStock);
Assert.assertEquals(stock, (Integer.parseInt(exchanggeStock) + 1 + ""), "兑换之后商品库存兑换不一致-失敗");
//获取:订单号
String orderId = response.jsonPath().getString("data.orderId");
logger.info("data.orderId= :"+orderId);
Assert.assertEquals(orderId.isEmpty(), false, "订单号没有获取到");
//获取code以及desc
response.prettyPrint();
logger.info(" ZDH核销二期自有商品多规格实物核销-->结束了");
}catch (Exception e){
throw new Exception("异常信息打印:" + e);
}finally{ jdbc.update("update goods.tb_equity_goods_record set consumer_id=null ,partner_user_id=null" +
" ,app_item_id=null ,verification_time=null ,order_num=null , app_sku_id =null where exc_code = '"+excCode+"'");}
}
@Test(description = "自有商品多规格实物-核销成功 -选择中的 规格 库存不足")
public void ZDH核销二期自有商品多规格实物核销其中规格一个无库存() throws Exception {
String excCode="ASQ46";
try {
logger.info(" ZDH核销二期自有商品多规格实物核销其中规格一个无库存-->开始了");
String equityId="21";
String appItemId="199483";
String appSkuId="258";
Response response = equityPrizeService.gawequityPrizeexchange(authorization.dafuwengLogin(uid),
excCode,appItemId,equityId,appSkuId);
String code = response.jsonPath().getString("code");
String desc = response.jsonPath().getString("desc");
logger.info("code:"+code+",desc:"+desc);
//校验
Assert.assertEquals(code,"1001002","2-ZDH核销二期自有商品多规格实物核销其中规格一个无库存( 有问题" );
//获取code以及desc
response.prettyPrint();
logger.info(" ZDH核销二期自有商品多规格实物核销其中规格一个无库存-->结束了");
}catch (Exception e){
throw new Exception("异常信息打印:" + e);
}
jdbc.update("update goods.tb_equity_goods_record set consumer_id=null ,partner_user_id=null" +
" ,app_item_id=null ,verification_time=null ,order_num=null , app_sku_id =null where exc_code = '"+excCode+"'");
}
@Test(description = "自有商品多规格实物-核销成功 -选择中的 规格 规格不存在")
public void ZDH核销二期自有商品多规格实物核销其中规格规格不存在() throws Exception {
String excCode="ASQ46";
try {
logger.info(" ZDH核销二期自有商品多规格实物核销其中规格一个无库存-->开始了");
String equityId="21";
String appItemId="199483";
String appSkuId="2581";
Response response = equityPrizeService.gawequityPrizeexchange(authorization.dafuwengLogin(uid),
excCode,appItemId,equityId,appSkuId);
String code = response.jsonPath().getString("code");
String desc = response.jsonPath().getString("desc");
logger.info("code:"+code+",desc:"+desc);
//校验
Assert.assertEquals(code,"1001002","2-ZDH核销二期自有商品多规格实物核销其中规格一个无库存( 有问题" );
//获取code以及desc
response.prettyPrint();
logger.info(" ZDH核销二期自有商品多规格实物核销其中规格一个无库存-->结束了");
}catch (Exception e){
throw new Exception("异常信息打印:" + e);
}
jdbc.update("update goods.tb_equity_goods_record set consumer_id=null ,partner_user_id=null" +
" ,app_item_id=null ,verification_time=null ,order_num=null , app_sku_id =null where exc_code = '"+excCode+"'");
}
@Test(description = "自有商品实物下架")
public void ZDH自有商品实物下架() throws Exception {
String excCode="ASQ83";
try {
logger.info(" ZDH自有商品实物下架-->开始了");
String equityId="23";
String appItemId="199484";
String appSkuId="259";
Response response = equityPrizeService.gawequityPrizeexchange(authorization.dafuwengLogin(uid),
excCode,appItemId,equityId,appSkuId);
String code = response.jsonPath().getString("code");
String desc = response.jsonPath().getString("desc");
logger.info("code:"+code+",desc:"+desc);
//校验
Assert.assertEquals(code,"1001002","2-ZDH自有商品实物下架( 有问题" );
//获取code以及desc
response.prettyPrint();
logger.info(" ZDH自有商品实物下架-->结束了");
}catch (Exception e){
throw new Exception("异常信息打印:" + e);
}
jdbc.update("update goods.tb_equity_goods_record set consumer_id=null ,partner_user_id=null" +
" ,app_item_id=null ,verification_time=null ,order_num=null , app_sku_id =null where exc_code = '"+excCode+"'");
}
@Test(description = "自有商品实物删除")
public void 自有商品实物删除() throws Exception {
String excCode="ASQ95";
try {
logger.info(" 自有商品实物删除-->开始了");
String equityId="24";
String appItemId="199485";
String appSkuId="260";
Response response = equityPrizeService.gawequityPrizeexchange(authorization.dafuwengLogin(uid),
excCode,appItemId,equityId,appSkuId);
String code = response.jsonPath().getString("code");
String desc = response.jsonPath().getString("desc");
logger.info("code:"+code+",desc:"+desc);
//校验
Assert.assertEquals(code,"1001002","2-自有商品实物删除( 有问题" );
//获取code以及desc
response.prettyPrint();
logger.info(" 自有商品实物删除-->结束了");
}catch (Exception e){
throw new Exception("异常信息打印:" + e);
}
jdbc.update("update goods.tb_equity_goods_record set consumer_id=null ,partner_user_id=null" +
" ,app_item_id=null ,verification_time=null ,order_num=null , app_sku_id =null where exc_code = '"+excCode+"'");
}
@Test(description = "自有商品单2-ZDH核销二期限购每日限量【限购】")
//兑换限制 -》每日限购2次
public void ZDH核销二期自有商品自有商品每日限购测试() throws Exception {
String excCode1="ASQ123";
String excCode2="ASQ122";
String excCode3="ASQ120";
try {
logger.info(" ZDH核销二期自有商品自有商品每日限购测试-->开始了");
String equityId="25";
String appItemId="199486";
String appSkuId="261";
Map<String, Object> mapStock = jdbc.findSimpleResult("SELECT * FROM stock.tb_stock WHERE stock_id =1187737166225920261");
//获取兑换之前优惠券的库存stock
String stock = String.valueOf(mapStock.get("stock"));
//请求核销接口
logger.info("进行第一次核销");
Response response = equityPrizeService.gawequityPrizeexchange(authorization.dafuwengLogin(uid),
excCode1,appItemId,equityId,appSkuId);
response.prettyPrint();
Thread.sleep(2000);
mapStock = jdbc.findSimpleResult("SELECT * FROM stock.tb_stock WHERE stock_id =1187737166225920261");
//核销之后优惠券的库存
String exchanggeStock = String.valueOf(mapStock.get("stock"));
//核对兑换之后以及兑换之后的库存
logger.info("总库存stock:"+stock +"第一次核销的库存exchanggeStock:"+exchanggeStock);
Assert.assertEquals(stock, (Integer.parseInt(exchanggeStock) + 1 + ""), "兑换之后商品库存兑换不一致-失敗");
//获取:订单号
String orderId = response.jsonPath().getString("data.orderId");
logger.info("第一次核销的订单 号data.orderId="+orderId);
Assert.assertEquals(orderId.isEmpty(), false, "第一次核销的订单订单号没有获取到");
//进行第二次核销
Thread.sleep(2000);
logger.info("第一次核销正常,进行第二次核销");
response = equityPrizeService.gawequityPrizeexchange(authorization.dafuwengLogin(uid),
excCode2,appItemId,equityId,appSkuId);
response.prettyPrint();
//核销之后优惠券的库存
Thread.sleep(2000);
mapStock = jdbc.findSimpleResult("SELECT * FROM stock.tb_stock WHERE stock_id =1187737166225920261");
exchanggeStock = String.valueOf(mapStock.get("stock"));
logger.info("exchanggeStock 第二次库存:"+exchanggeStock);
Assert.assertEquals(stock, (Integer.parseInt(exchanggeStock) + 2 + ""), "【第二次】兑换之后商品库存兑换不一致-失敗");
//获取:订单号
orderId = response.jsonPath().getString("data.orderId");
logger.info("第二次核销的订单 号data.orderId="+orderId);
Assert.assertEquals(orderId.isEmpty(), false, "第二次核销的订单订单号没有获取到");
//进行第三次核销
Thread.sleep(1000);
logger.info("第二次核销正常,进行第三次核销");
response = equityPrizeService.gawequityPrizeexchange(authorization.dafuwengLogin(uid),
excCode3,appItemId,equityId,appSkuId);
String code = response.jsonPath().getString("code");
String desc = response.jsonPath().getString("desc");
logger.info("code:"+code+",desc:"+desc);
//校验
Assert.assertEquals(code,"1001002","2-ZDH核销二期自有商品自有商品每日限购测试( 有问题" );
logger.info(" ZDH核销二期自有商品自有商品每日限购测试-->结束了");
}catch (Exception e){
throw new Exception("异常信息打印:" + e);
}finally {
jdbc.update("update goods.tb_equity_goods_record set consumer_id=null ,partner_user_id=null" +
" ,app_item_id=null ,verification_time=null ,order_num=null , app_sku_id =null " +
"where exc_code in( '"+excCode1+"',"+"'"+excCode2+"','"+excCode3+"')");
jdbc.update("DELETE FROM goods.tb_everyday_limit where app_item_id ='199486 '");
}
}
}
package http.service.Activity;
import base.DuibaLog;
import http.service.Authorization;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.testng.Assert;
import java.util.HashMap;
import java.util.Map;
import static io.restassured.RestAssured.given;
/**
* Created by lvwenyan on 2019/12/21
*/
@Service
public class LotterySquareService {
@Value("${activity.host}")
String activityHost;
@Autowired
Authorization authorization;
private DuibaLog logger = DuibaLog.getLogger();
/**
* @param uid
* @param actId 活动id
* @return
* @throws Exception
*/
public Response cashIndexInfo(int uid, String actId) throws Exception{
Map<String,String> map = new HashMap<>();
map.put("actId",actId);
logger.info("请求/aaw/lotterySquare/cashIndexInfo接口");
Response response = given().cookies(authorization.dafuwengLogin(uid)).params(map).get(activityHost+"/aaw/lotterySquare/cashIndexInfo");
try {
Assert.assertEquals(response.jsonPath().getString("success"), "true", "/aaw/lotterySquare/cashIndexInfo接口失败");
} catch (Exception e) {
throw new Exception("/aaw/lotterySquare/cashIndexInfo接口失败,返回信息:" + response.asString());
} catch (Error er) {
throw new Exception("/aaw/lotterySquare/cashIndexInfo接口失败,返回信息:" + response.asString());
}
return response;
}
/**
* @param uid
* @param actId 活动id
* @param money 金额
* @return
* @throws Exception
*/
public Response cashDraws(int uid, String actId,String money) throws Exception{
Map<String,String> map = new HashMap<>();
map.put("actId",actId);
map.put("money",money);
map.put("account","peeulk6392@sandbox.com");
map.put("username","沙箱环境");
logger.info("请求/aaw/lotterySquare/cashDraws接口");
Response response = given().cookies(authorization.dafuwengLogin(uid)).contentType("application/x-www-form-urlencoded;charset=UTF-8").params(map).post(activityHost+"/aaw/lotterySquare/cashDraws");
try {
Assert.assertEquals(response.jsonPath().getString("success"), "true", "/aaw/lotterySquare/cashDraws接口失败");
} catch (Exception e) {
throw new Exception("/aaw/lotterySquare/cashDraws接口失败,返回信息:" + response.asString());
} catch (Error er) {
throw new Exception("/aaw/lotterySquare/cashDraws接口失败,返回信息:" + response.asString());
}
return response;
}
/**
* @param uid
* @param actId 活动id
* @param money 金额
* @param account 支付宝账号
* @param username 真实姓名
* @return
* @throws Exception
*/
public Response cashDraws2(int uid, String actId,String money,String account, String username){
Map<String,String> map = new HashMap<>();
map.put("actId",actId);
map.put("money",money);
map.put("account",account);
map.put("username",username);
logger.info("请求/aaw/lotterySquare/cashDraws接口");
Response response = given().cookies(authorization.dafuwengLogin(uid)).contentType("application/x-www-form-urlencoded;charset=UTF-8").params(map).post(activityHost+"/aaw/lotterySquare/cashDraws");
return response;
}
/**
* @param uid
* @param actId 活动id
* @return
* @throws Exception
*/
public Response accountDetail(int uid, String actId) throws Exception{
Map<String,String> map = new HashMap<>();
map.put("actId",actId);
map.put("pageSize","20");
map.put("pageNum","1");
logger.info("请求/aaw/lotterySquare/accountDetail接口");
Response response = given().cookies(authorization.dafuwengLogin(uid)).params(map).get(activityHost+"/aaw/lotterySquare/accountDetail");
try {
Assert.assertEquals(response.jsonPath().getString("success"), "true", "/aaw/lotterySquare/accountDetail接口失败");
} catch (Exception e) {
throw new Exception("/aaw/lotterySquare/accountDetail接口失败,返回信息:" + response.asString());
} catch (Error er) {
throw new Exception("/aaw/lotterySquare/accountDetail接口失败,返回信息:" + response.asString());
}
return response;
}
}
package http.service.Activity;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import http.service.Authorization;
import io.restassured.http.Cookies;
import io.restassured.response.Response;
......@@ -7,10 +9,11 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.testng.Assert;
import org.testng.annotations.Test;
import java.util.HashMap;
import java.util.Map;
import java.util.*;
import static base.Postman.logger;
import static io.restassured.RestAssured.given;
@Service
......@@ -22,6 +25,7 @@ public class equityPrizeService {
/**
* 核销一期 /aaw/equityPrize/exchange
* 匹配兑换码兑换 一期-线上核销
* Request Method: POST
*
* @param excCode 兑换码
......@@ -46,6 +50,108 @@ public class equityPrizeService {
return response;
}
/**
* 核销二期匹配 权益及兑换码兑换-线上核销
* 权益商品列表
* /chw//chw/visual-editor/equityGoodsList
* Request Method: GET
*
* @param equityId 权益id
* @return
* @throws Exception
*/
public Response chwequityGoodsList(Map cookies, String equityId) throws Exception {
Response response = given().cookies(cookies).get(activityHost + "/chw/visual-editor/equityGoodsList?equityId="+equityId);
try {
// Assert.assertEquals(response.jsonPath().getString("success"), "true", "/aaw/equityPrize/exchange接口失败");
Assert.assertEquals(String.valueOf(response.getStatusCode()), "200", "/chw//chw/visual-editor/equityGoodsList接口失败");
} catch (Exception e) {
throw new Exception("/chw/visual-editor/equityGoodsList接口失败,返回信息:" + response.asString());
} catch (Error er) {
throw new Exception("/chw/visual-editor/equityGoodsList接口失败,返回信息:" + response.asString());
}
return response;
}
@Test
/*
*q权益二期匹配 权益及兑换码兑换-线上核销
* 商品兑换首页
* /gaw/equityPrize/index
* * Request Method: post
* equityId 权益id , appitemid 商品id , appSkuid
* */
public Response gawequityPrizeindex( Map cookies,String equityId ,String appItemId ,String appSkuId) throws Exception {
logger.info(activityHost + "/gaw/equityPrize/index?equityId="+equityId+"&appItemId="+appItemId+"&appSkuId="+appSkuId);
Response response = given().cookies(cookies).get(activityHost + "/gaw/equityPrize/index?equityId="+equityId+"&appItemId="+appItemId+"&appSkuId="+appSkuId);
try {
Assert.assertEquals(String.valueOf(response.getStatusCode()), "200", "/gaw/equityPrize/index接口失败");
} catch (Exception e) {
throw new Exception("/gaw/equityPrize/index接口失败,返回信息:" + response.asString());
} catch (Error er) {
throw new Exception("/gaw/equityPrize/index接口失败,返回信息:" + response.asString());
}
return response;
}
/*
* 权益核销【匹配 权益及兑换码兑换-线上核销】
* 权益兑换接口sku /gaw/equityPrize/exchange
*
* */
public Response gawequityPrizeexchange( Map cookies,String excCode,String appItemId,
String equityId,String appSkuId) throws Exception {
Map<String, String> map = new HashMap<>();
map.put("excCode", excCode);
map.put("appItemId", appItemId);
map.put("equityId", equityId);
map.put("appSkuId", appSkuId);
map.put("validate", "undefined");
//token 代码中写死的测试token
map.put("token", "yrJRr7Cddp2YeQd");
Response response = given().cookies(cookies).params(map).post(activityHost + "/gaw/equityPrize/exchange");
try {
Assert.assertEquals(String.valueOf(response.getStatusCode()), "200", "/gaw/equityPrize/exchange接口失败");
} catch (Exception e) {
throw new Exception("/gaw/equityPrize/exchange接口失败,返回信息:" + response.asString());
} catch (Error er) {
throw new Exception("/gaw/equityPrize/exchange接口失败,返回信息:" + response.asString());
}
return response;
}
/*
* 权益核销【匹配 权益及兑换码兑换-线上核销】
* 权益列表 /chw/visual-editor/findEquityListByIds
*
* */
public Response chwvisualeditorfindEquityListByIds(Map cookies, List<Integer> array) throws Exception {
// JSONObject json = new JSONObject();
// json.put("equityIds", array);
Map<String, List<Integer>> map = new HashMap<>();
map.put("equityIds", array);
Response response = given().contentType("application/json;charset=UTF-8").cookies(cookies).body(map).post(activityHost + "/chw/visual-editor/findEquityListByIds");
//Response response = given().contentType("application/json;charset=UTF-8").body("{\"equityIds\":[25,24]}").cookies(cookies).post(activityHost + "/chw/visual-editor/findEquityListByIds");
try {
Assert.assertEquals(String.valueOf(response.getStatusCode()), "200", " /chw/visual-editor/findEquityListByIds接口失败");
} catch (Exception e) {
throw new Exception("/gaw/equityPrize/exchange接口失败,返回信息:" + response.asString());
} catch (Error er) {
throw new Exception("/gaw/equityPrize/exchange接口失败,返回信息:" + response.asString());
}
return response;
}
}
\ No newline at end of file
......@@ -125,7 +125,7 @@ public class gawService {
//普通自有新实物兑换接口
public Response objectExchange(int uid, String appItemId,String itemId,String skuId,String credits,String actualCredits ) throws Exception {
public Response objectExchange(int uid, String appItemId,String itemId,String skuId,String credits,String actualCredits,boolean bl ) throws Exception {
Map<String,Object> map = new HashMap<>();
Map<String,Object> mapList = new HashMap<>();
......@@ -147,6 +147,7 @@ public class gawService {
map.put("expressPrice","0");
map.put("validate","");
map.put("token","yrJRr7Cddp2YeQd");
map.put("vipFlag",bl);
JSONObject jsonParam = JSONObject.parseObject(JSON.toJSONString(map));
......@@ -227,6 +228,51 @@ public class gawService {
// Response saveResponse = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.dafuwengLogin(uid)).params(map).post("http://"+goodsHost+"/gaw/objectExchange/create");
// response.prettyPrint();
try{
Assert.assertEquals(response.jsonPath().getString("success"),"true");
}catch(Exception e){
throw new Exception("/gaw/objectExchange/create接口返回异常,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/gaw/objectExchange/create接口返回异常,返回信息:"+response.asString());
}
return response;
}
//会员商品优惠券兑换接口
public Response couponExchange2(int uid, String appItemId,String credits,String actualCredits, int skuId,boolean bl) throws Exception {
Map<String,Object> map = new HashMap<>();
Map<String,Object> mapList = new HashMap<>();
List<Map> list = new ArrayList<>();
mapList.put("skuId",skuId);
mapList.put("appItemId",appItemId);
mapList.put("credits",credits);
mapList.put("price",0);
list.add(mapList);
map.put("remark",""); //买家留言
map.put("degreeId","");
map.put("actualPrice","0"); //总金额
map.put("actualCredits",actualCredits); //总积分
map.put("itemParam",list.toArray());
map.put("payType","3");
map.put("expressPrice","0");
map.put("validate","");
map.put("token","yrJRr7Cddp2YeQd");
map.put("vipFlag",bl);
JSONObject jsonParam = JSONObject.parseObject(JSON.toJSONString(map));
logger.info("请求优惠券兑换接口:"+ "/gaw/couponExchange/create");
Response response = given().contentType("application/json; charset=UTF-8").cookies(authorization.dafuwengLogin(uid)).body(jsonParam).post("http://"+goodsHost+"/gaw/couponExchange/create");
// Response saveResponse = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.dafuwengLogin(uid)).params(map).post("http://"+goodsHost+"/gaw/objectExchange/create");
// response.prettyPrint();
try{
......@@ -284,7 +330,7 @@ public class gawService {
}
//优惠券兑换接口
public Response couponExchange(Map cookie, String appItemId,int skuId) throws Exception {
public Response couponExchange(Map cookie, String appItemId,int skuId,boolean bl) throws Exception {
Map<String,Object> map = new HashMap<>();
Map<String,Object> mapList = new HashMap<>();
......@@ -305,6 +351,7 @@ public class gawService {
map.put("expressPrice","0");
map.put("validate","");
map.put("token","yrJRr7Cddp2YeQd");
map.put("vipFlag",bl);
JSONObject jsonParam = JSONObject.parseObject(JSON.toJSONString(map));
......@@ -555,7 +602,7 @@ public class gawService {
logger.info("请求Qb兑换接口:"+ "/gaw/qbExchange/create");
Response response = given().contentType("application/json; charset=UTF-8").cookies(authorization.dafuwengLogin(uid)).body(jsonParam).post("http://"+goodsHost+"/gaw/qbExchange/create");
response.prettyPrint();
try{
Assert.assertEquals(response.jsonPath().getString("success"),"true");
......
......@@ -74,7 +74,7 @@ public class testservice extends AbstractTestNGSpringContextTestsDuiba {
Thread.sleep(3000);
Response response = gawService.objectExchange(1,appItemId,itemId,skuId,credits,actualCredits);
Response response = gawService.objectExchange(1,appItemId,itemId,skuId,credits,actualCredits,false);
response.prettyPrint();
//(enabled=true, dataProvider="testdp", threadPoolSize=1, invocationCount=2)
......
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