Commit 9b518205 authored by wangxiaoshuang's avatar wangxiaoshuang

Merge branch 'wxs'

parents 32d443f2 5f10ae3a
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 策略价会员商品自有优惠券_兑换流程测试 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 策略价会员商品自有卡密_兑换流程测试 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 策略价会员商品自有实物_兑换流程测试 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);
......
......@@ -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));
......
......@@ -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