Commit 999c5105 authored by 马博's avatar 马博

update

parent 4289696d
......@@ -7,6 +7,7 @@ import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.core.env.Environment;
import java.io.FileNotFoundException;
import java.io.UnsupportedEncodingException;
import java.util.*;
......@@ -62,8 +63,14 @@ public class DingdingResult {
changes = Postman.sendFindTestApp(params);
}
gitlabProjectMerges = GitlabUtils.getMessage("credits-group",changes);
changes = changes+" 提交者:"+gitlabProjectMerges.getAuthor().getName()+" 描述:"+gitlabProjectMerges.getDescription();
try{
gitlabProjectMerges = GitlabUtils.getMessage("credits-group",changes);
changes = changes+" 提交者:"+gitlabProjectMerges.getAuthor().getName()+" 描述:"+gitlabProjectMerges.getDescription();
}catch (Exception e){
logger.info("不是兑吧服务,未发现变革");
}
this.total=total;
......
......@@ -14,15 +14,13 @@ import java.util.List;
public class GitlabUtils {
public static final String GIT_URL = "http://gitlab2.dui88.com";
public static final String SECRET = "rCyBy1sQ-JckquyFmo4c";
public static GitlabProjectMerges getMessage(String namespace,String projectname){
public static GitlabProjectMerges getMessage(String namespace,String projectname) throws IOException {
GitlabAPI gitlabAPI = GitlabAPI.connect(GitlabUtils.GIT_URL, GitlabUtils.SECRET);
GitlabProject gitlabProject= null;
try {
gitlabProject = gitlabAPI.getProject(namespace,projectname);
// gitlabProject = gitlabAPI.getProject("credits-group","hdtool-web");
} catch (IOException e) {
e.printStackTrace();
}
GitabProjectLatelyChangeQry qry = new GitabProjectLatelyChangeQry();
qry.setId(gitlabProject.getId());
......
......@@ -45,7 +45,7 @@ public class 自有新优惠券_兑换限制测试 extends CheckTemplet{
try {
jdbc.update("DELETE FROM credits_dev.consumer_limit_record where consumer_id = ?",consumerId);
jdbc.update("DELETE FROM credits_dev.consumer_limit_record_only where consumer_id = ?",consumerId);
// jdbc.update("DELETE FROM goods.tb_everyday_limit where app_item_id=193825");
jdbc.update("DELETE FROM goods.tb_everyday_limit where app_item_id=193845");
} catch (SQLException e) {
e.printStackTrace();
......@@ -59,14 +59,14 @@ public class 自有新优惠券_兑换限制测试 extends CheckTemplet{
Object[][] result = null;
if (method.getName().equals("日期兑换限制测试")) {
result = new Object[][]{
new Object[]{1, "193827", "实物日期兑换限制未开始测试"}, //case1
new Object[]{2, "193828", "实物日期兑换限制进行中测试"}, //case2
new Object[]{3, "193829", "实物日期兑换限制已结束"}, //case3
new Object[]{1, "194281",78,"实物日期兑换限制未开始测试"}, //case1
new Object[]{2, "194282",79,"实物日期兑换限制进行中测试"}, //case2
new Object[]{3, "194283",80,"实物日期兑换限制已结束"}, //case3
};
}
if (method.getName().equals("库存不足测试")) {
result = new Object[][]{
new Object[]{"193826", "实物库存不足测试"}, //case1
new Object[]{"193847", "实物库存不足测试"}, //case1
};
}
return result;
......@@ -189,241 +189,241 @@ public class 自有新优惠券_兑换限制测试 extends CheckTemplet{
}
// @Test
// public void 每日兑换上限测试() throws Exception {
//
// String appItemId = "193825";
// try{
//
// //第一次兑换
// Response response = couponExchangeService.couponExchange(authorization.dafuwengLogin(uid), appItemId, null);
// String orderId = response.jsonPath().getString("orderId");
// //获取兑换结果
// response = mobileService.orderStatusQuery(uid,orderId);
// response.prettyPrint();
// String message = response.jsonPath().getString("message");
// int i = 10;
// //异步接口,直到兑换成功
// while (i > 0 && "兑换正在处理中...".equals(message)) {
// Thread.sleep(1000);
// response = mobileService.orderStatusQuery(uid,orderId);
// response.prettyPrint();
// message = response.jsonPath().getString("message");
// i--;
// }
//
// Response detailResponse = mobileService.appItemDetail(authorization.dafuwengLogin(uid),appItemId);
// detailResponse.prettyPrint();
// String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
// logger.info("商品兑换按钮:" + exchangeText);
//
// //第二次兑换
// Thread.sleep(3000);
// try{
// response = couponExchangeService.couponExchange(authorization.dafuwengLogin(uid), appItemId,null);
// response.prettyPrint();
//
// }catch (Exception e){
// message = e.toString();
// }
// logger.info(message);
//
// Assert.assertTrue(message.contains("今日已兑完,明天再来哦(14)"),"校验message失败");
// Assert.assertTrue(message.contains("\"success\":false"),"校验success失败");
//
// Assert.assertEquals(exchangeText,"每日限量已兑完","校验兑换按钮失败");
// logger.info("校验实物每日兑换上限成功");
//
// }catch (Exception e){
//
// throw new Exception("异常信息打印:" + e);
//
// }finally {
// //清掉每日兑换限制数据
//// jdbc.update("DELETE FROM goods.tb_everyday_limit WHERE item_id = '"+itemId+"'");
//
// }
//
//
// }
//
// /**
// * @param appItemId 商品入库Id
// * @param caseName 用例名称打印
// * @throws Exception
// */
// @Test(dataProvider = "providerMethod")
// public void 库存不足测试(String appItemId, String caseName) throws Exception{
//
//
// logger.info(caseName);
//
// String message=null;
// try{
// //兑换
// Response response = couponExchangeService.couponExchange(authorization.dafuwengLogin(uid), appItemId, null);
//
// }catch (Exception e){
// message = e.getMessage();
// logger.info("message:"+message);
//
// }
//
//
//
// //获取按钮状态
// Response detailResponse = mobileService.appItemDetail(authorization.dafuwengLogin(uid),appItemId);
// String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
// logger.info("兑换按钮:" + exchangeText);
//
//
// Assert.assertTrue(message.contains("今日已兑完,明天再来哦(14)"),"校验message失败");
// Assert.assertEquals(exchangeText,"商品售罄","校验马上兑换按钮状态失败");
// logger.info("校验实物库存成功");
//
// }
//
// /**
// * @param caseNum 用例编号
// * @param appItemId 商品入库Id
// * @param caseName 用例名称打印
// * @throws Exception
// */
// @Test(dataProvider = "providerMethod")
// public void 日期兑换限制测试(int caseNum, String appItemId, String caseName) throws Exception{
//
// logger.info(caseName);
// String message = null;
//
// Map<String,String> map = new HashMap<>();
// map.put("appItemId",appItemId);
// Response response =null;
//
// //兑换
// try{
// response = couponExchangeService.couponExchange(authorization.dafuwengLogin(uid), appItemId, null);
//
// }catch (Exception e){
// message = e.getMessage();
// logger.info("message:"+message);
//
// }
//
// //获取按钮状态
// Response detailResponse = mobileService.appItemDetail(authorization.dafuwengLogin(uid),appItemId);
// String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
// logger.info("商品兑换按钮:" + exchangeText);
//
// switch (caseNum){
//
// case 1:
//// Assert.assertEquals(response.jsonPath().getString("message"),"请在限定时间内兑换哦(13)","校验日期兑换限制失败");
// Assert.assertTrue(message.contains("请在限定时间内兑换哦(13)"),"校验日期兑换限制失败");
// Assert.assertEquals(exchangeText,"即将开始","校验马上兑换按钮状态失败");
// logger.info("校验实物日期兑换限制未开始成功");
// break;
//
// case 2:
// Assert.assertEquals(response.jsonPath().getString("success"),"true","校验日期兑换限制失败");
//// Assert.assertTrue(message.contains("success"),"校验日期兑换限制失败");
// Assert.assertEquals(exchangeText,"马上兑换","校验马上兑换按钮状态失败");
// logger.info("校验实物日期兑换限制进行中成功");
// break;
//
// case 3:
//// Assert.assertEquals(response.jsonPath().getString("message"),"已结束","校验日期兑换限制失败");
// Assert.assertTrue(message.contains("已结束"),"校验日期兑换限制失败");
// Assert.assertEquals(exchangeText,"已结束","校验马上兑换按钮状态失败");
// logger.info("校验实物日期兑换限制已结束成功");
// break;
//
// }
//
//
// }
//
// @Test
// public void 会员等级测试()throws Exception{
//
// String appItemId = "193821";
// String message = "";
//
// //会员等级无法兑换
// try{
// Response response = couponExchangeService.couponExchange(authorization.dafuwengLogin(uid), appItemId,null);
// response.prettyPrint();
//
// }catch (Exception e){
// message = e.toString();
// }
// logger.info(message);
//
// //会员等级可兑换,vip=5
// Response response = couponExchangeService.couponExchange(authorization.generateSignAutoLogin("2wGQc3MZaQsqYFWcX4gguya5PnnS",3402),appItemId,null);
// response.prettyPrint();
//
// Assert.assertTrue(message.contains("会员等级不符,请挑选其他吧(15)"),"校验message失败");
// Assert.assertTrue(message.contains("\"success\":false"),"校验success失败");
// Assert.assertEquals(response.jsonPath().getString("success"),"true","校验兑换结果失败");
// logger.info("校验实物会员等级成功");
//
// }
//
// @Test
// public void 用户周期限制消费测试() throws Exception {
//
// String appItemId = "193824";
// try{
//
// //第一次兑换
// Response response = couponExchangeService.couponExchange(authorization.dafuwengLogin(uid), appItemId, null);
// response.prettyPrint();
// String orderId = response.jsonPath().getString("orderId");
// //获取兑换结果
// response = mobileService.orderStatusQuery(uid,orderId);
// response.prettyPrint();
// String message = response.jsonPath().getString("message");
// int i = 10;
// //异步接口,直到兑换成功
// while (i > 0 && "兑换正在处理中...".equals(message)) {
// Thread.sleep(1000);
// response = mobileService.orderStatusQuery(uid,orderId);
// response.prettyPrint();
// message = response.jsonPath().getString("message");
// i--;
// }
//
// Response detailResponse = mobileService.appItemDetail(authorization.dafuwengLogin(uid),appItemId);
// detailResponse.prettyPrint();
// String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
// logger.info("商品兑换按钮:" + exchangeText);
//
// //第二次兑换
// Thread.sleep(3000);
// try{
// response = couponExchangeService.couponExchange(authorization.dafuwengLogin(uid), appItemId, null);
// response.prettyPrint();
//
// }catch (Exception e){
// message = e.toString();
// }
// logger.info(message);
//
// Assert.assertTrue(message.contains("已达兑换次数上限"),"校验message失败");
// Assert.assertTrue(message.contains("\"success\":false"),"校验success失败");
//
// Assert.assertEquals(exchangeText,"已达兑换次数上限","校验兑换按钮失败");
// logger.info("校验实物用户周期限制消费成功");
//
// }catch (Exception e){
//
// throw new Exception("异常信息打印:" + e);
//
// }finally {
//// jdbc.update("DELETE FROM credits_dev.consumer_limit_record WHERE item_id = '"+itemId+"'");
//
// }
//
//
// }
@Test
public void 每日兑换上限测试() throws Exception {
String appItemId = "193845";
try{
//第一次兑换
Response response = gawService.couponExchange(uid, appItemId,42);
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 = mobileService.orderStatusQuery(uid,orderId);
response.prettyPrint();
message = response.jsonPath().getString("message");
i--;
}
Response detailResponse = mobileService.appItemDetail(authorization.dafuwengLogin(uid),appItemId);
detailResponse.prettyPrint();
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
logger.info("商品兑换按钮:" + exchangeText);
//第二次兑换
Thread.sleep(3000);
try{
response = gawService.couponExchange(uid, appItemId,42);
response.prettyPrint();
}catch (Exception e){
message = e.toString();
}
logger.info(message);
Assert.assertTrue(message.contains("商品售罄"),"校验message失败");
Assert.assertTrue(message.contains("\"success\":false"),"校验success失败");
Assert.assertEquals(exchangeText,"每日限量已兑完","校验兑换按钮失败");
logger.info("校验实物每日兑换上限成功");
}catch (Exception e){
throw new Exception("异常信息打印:" + e);
}finally {
//清掉每日兑换限制数据
// jdbc.update("DELETE FROM goods.tb_everyday_limit WHERE item_id = '"+itemId+"'");
}
}
/**
* @param appItemId 商品入库Id
* @param caseName 用例名称打印
* @throws Exception
*/
@Test(dataProvider = "providerMethod")
public void 库存不足测试(String appItemId, String caseName) throws Exception{
logger.info(caseName);
String message=null;
try{
//兑换
Response response = gawService.couponExchange(uid, appItemId,44);
}catch (Exception e){
message = e.getMessage();
logger.info("message:"+message);
}
//获取按钮状态
Response detailResponse = mobileService.appItemDetail(authorization.dafuwengLogin(uid),appItemId);
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
logger.info("兑换按钮:" + exchangeText);
Assert.assertTrue(message.contains("商品售罄"),"校验message失败");
Assert.assertEquals(exchangeText,"商品售罄","校验马上兑换按钮状态失败");
logger.info("校验实物库存成功");
}
/**
* @param caseNum 用例编号
* @param appItemId 商品入库Id
* @param caseName 用例名称打印
* @throws Exception
*/
@Test(dataProvider = "providerMethod")
public void 日期兑换限制测试(int caseNum, String appItemId,int skuId,String caseName) throws Exception{
logger.info(caseName);
String message = null;
Map<String,String> map = new HashMap<>();
map.put("appItemId",appItemId);
Response response =null;
//兑换
try{
response = gawService.couponExchange(uid, appItemId, skuId);
}catch (Exception e){
message = e.getMessage();
logger.info("message:"+message);
}
//获取按钮状态
Response detailResponse = mobileService.appItemDetail(authorization.dafuwengLogin(uid),appItemId);
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
logger.info("商品兑换按钮:" + exchangeText);
switch (caseNum){
case 1:
// Assert.assertEquals(response.jsonPath().getString("message"),"请在限定时间内兑换哦(13)","校验日期兑换限制失败");
Assert.assertTrue(message.contains("限2028-04-30至2029-04-17日期内兑换"),"校验日期兑换限制失败");
Assert.assertEquals(exchangeText,"限2028-04-30至2029-04-17日期内兑换","校验马上兑换按钮状态失败");
logger.info("校验实物日期兑换限制未开始成功");
break;
case 2:
Assert.assertEquals(response.jsonPath().getString("success"),"true","校验日期兑换限制失败");
// Assert.assertTrue(message.contains("success"),"校验日期兑换限制失败");
Assert.assertEquals(exchangeText,"马上兑换","校验马上兑换按钮状态失败");
logger.info("校验实物日期兑换限制进行中成功");
break;
case 3:
// Assert.assertEquals(response.jsonPath().getString("message"),"已结束","校验日期兑换限制失败");
Assert.assertTrue(message.contains("已结束"),"校验日期兑换限制失败");
Assert.assertEquals(exchangeText,"已结束","校验马上兑换按钮状态失败");
logger.info("校验实物日期兑换限制已结束成功");
break;
}
}
@Test
public void 会员等级测试()throws Exception{
String appItemId = "193848";
String message = "";
//会员等级无法兑换
try{
Response response = gawService.couponExchange(authorization.dafuwengLogin(uid), appItemId,45);
response.prettyPrint();
}catch (Exception e){
message = e.toString();
}
logger.info(message);
//会员等级可兑换,vip=5
Response response = gawService.couponExchange(authorization.generateSignAutoLogin("3tzVcss7SnAvA5ppT1m1rMPhaBcD",7083,1),appItemId,45);
response.prettyPrint();
Assert.assertTrue(message.contains("未达到会员等级要求"),"校验message失败");
Assert.assertTrue(message.contains("\"success\":false"),"校验success失败");
Assert.assertEquals(response.jsonPath().getString("success"),"true","校验兑换结果失败");
logger.info("校验实物会员等级成功");
}
@Test
public void 用户周期限制消费测试() throws Exception {
String appItemId = "193844";
try{
//第一次兑换
Response response = gawService.couponExchange(uid, appItemId,41);
response.prettyPrint();
String orderId = response.jsonPath().getString("data.orderId");
//获取兑换结果
response = mobileService.orderStatusQuery(uid,orderId);
response.prettyPrint();
String message = response.jsonPath().getString("message");
int i = 10;
//异步接口,直到兑换成功
while (i > 0 && "兑换正在处理中...".equals(message)) {
Thread.sleep(1000);
response = mobileService.orderStatusQuery(uid,orderId);
response.prettyPrint();
message = response.jsonPath().getString("message");
i--;
}
Response detailResponse = mobileService.appItemDetail(authorization.dafuwengLogin(uid),appItemId);
detailResponse.prettyPrint();
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
logger.info("商品兑换按钮:" + exchangeText);
//第二次兑换
Thread.sleep(3000);
try{
response = gawService.couponExchange(uid, appItemId,41);
response.prettyPrint();
}catch (Exception e){
message = e.toString();
}
logger.info(message);
Assert.assertTrue(message.contains("已达兑换次数上限"),"校验message失败");
Assert.assertTrue(message.contains("\"success\":false"),"校验success失败");
Assert.assertEquals(exchangeText,"已达兑换次数上限","校验兑换按钮失败");
logger.info("校验实物用户周期限制消费成功");
}catch (Exception e){
throw new Exception("异常信息打印:" + e);
}finally {
// jdbc.update("DELETE FROM credits_dev.consumer_limit_record WHERE item_id = '"+itemId+"'");
}
}
}
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.DataProvider;
import org.testng.annotations.Test;
import utils.MatcherString;
import java.lang.reflect.Method;
import java.sql.SQLException;
/**
* Created by mabo on 2019/3/26
*/
public class 自有新卡密_兑换限制测试 extends CheckTemplet {
@Autowired
http.service.app.gawService gawService;
@Autowired
http.service.app.tawService tawService;
@Autowired
MobileService mobileService;
@Autowired
Authorization authorization;
private int uid = 7004;
private String consumerId = "100144146";
private String url = "http://activity.m.duibatest.com.cn";
@BeforeMethod
public void beforeMethod() {
try {
jdbc.update("DELETE FROM credits_dev.consumer_limit_record where consumer_id = ?",consumerId);
jdbc.update("DELETE FROM credits_dev.consumer_limit_record_only where consumer_id = ?",consumerId);
jdbc.update("DELETE FROM goods.tb_everyday_limit where app_item_id=193845");
} catch (SQLException e) {
e.printStackTrace();
}
}
@DataProvider
public Object[][] providerMethod(Method method) {
Object[][] result = null;
if (method.getName().equals("日期兑换限制测试")) {
result = new Object[][]{
new Object[]{1, "193827", "实物日期兑换限制未开始测试"}, //case1
new Object[]{2, "193828", "实物日期兑换限制进行中测试"}, //case2
new Object[]{3, "193829", "实物日期兑换限制已结束"}, //case3
};
}
if (method.getName().equals("库存不足测试")) {
result = new Object[][]{
new Object[]{"193847", "实物库存不足测试"}, //case1
};
}
return result;
}
@Test
public void 用户每日限制消费测试() throws Exception {
String appItemId = "193850";
int skuId = 47;
try{
//第一次兑换
Response response = gawService.couponExchange(uid, appItemId,47);
response.prettyPrint();
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--;
}
Response detailResponse = mobileService.appItemDetail(authorization.dafuwengLogin(uid),appItemId);
detailResponse.prettyPrint();
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
logger.info("商品兑换按钮:" + exchangeText);
//第二次兑换
Thread.sleep(3000);
try{
response = gawService.couponExchange(uid, appItemId,47);
response.prettyPrint();
}catch (Exception e){
message = e.toString();
}
logger.info(message);
Assert.assertTrue(message.contains("今日已达兑换上限"),"校验message失败");
Assert.assertTrue(message.contains("\"success\":false"),"校验success失败");
Assert.assertEquals(exchangeText,"今日已达兑换上限","校验兑换按钮失败");
logger.info("校验实物用户每日限制消费成功");
}catch (Exception e){
throw new Exception("异常信息打印:" + e);
}finally {
// jdbc.update("DELETE FROM credits_dev.consumer_limit_record WHERE item_id = '"+itemId+"'");
}
}
// @Test
// public void 用户永久限制消费测试() throws Exception {
//
// String appItemId = "193843";
//
// try{
//
// //第一次兑换
// Response response = gawService.couponExchange(uid, appItemId,40);
// 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--;
// }
//
// Response detailResponse = mobileService.appItemDetail(authorization.dafuwengLogin(uid),appItemId);
// detailResponse.prettyPrint();
// String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
// logger.info("商品兑换按钮:" + exchangeText);
//
// //第二次兑换
// Thread.sleep(3000);
// try{
// response = gawService.couponExchange(uid, appItemId,40);
// response.prettyPrint();
//
// }catch (Exception e){
// message = e.toString();
// }
// logger.info(message);
//
// Assert.assertTrue(message.contains("已达兑换次数上限"),"校验message失败");
// Assert.assertTrue(message.contains("\"success\":false"),"校验success失败");
//
// Assert.assertEquals(exchangeText,"已达兑换次数上限","校验兑换按钮失败");
// logger.info("校验实物用户永久限制消费成功");
//
// }catch (Exception e){
//
// throw new Exception("异常信息打印:" + e);
//
// }finally {
//// jdbc.update("DELETE FROM credits_dev.consumer_limit_record WHERE item_id = '"+itemId+"'");
//// jdbc.update("DELETE FROM credits_dev.consumer_limit_record_only WHERE item_id = '"+itemId+"'");
//
//
//
// }
//
//
// }
//
// @Test
// public void 每日兑换上限测试() throws Exception {
//
// String appItemId = "193845";
// try{
//
// //第一次兑换
// Response response = gawService.couponExchange(uid, appItemId,42);
// 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 = mobileService.orderStatusQuery(uid,orderId);
// response.prettyPrint();
// message = response.jsonPath().getString("message");
// i--;
// }
//
// Response detailResponse = mobileService.appItemDetail(authorization.dafuwengLogin(uid),appItemId);
// detailResponse.prettyPrint();
// String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
// logger.info("商品兑换按钮:" + exchangeText);
//
// //第二次兑换
// Thread.sleep(3000);
// try{
// response = gawService.couponExchange(uid, appItemId,42);
// response.prettyPrint();
//
// }catch (Exception e){
// message = e.toString();
// }
// logger.info(message);
//
// Assert.assertTrue(message.contains("商品售罄"),"校验message失败");
// Assert.assertTrue(message.contains("\"success\":false"),"校验success失败");
//
// Assert.assertEquals(exchangeText,"每日限量已兑完","校验兑换按钮失败");
// logger.info("校验实物每日兑换上限成功");
//
// }catch (Exception e){
//
// throw new Exception("异常信息打印:" + e);
//
// }finally {
// //清掉每日兑换限制数据
//// jdbc.update("DELETE FROM goods.tb_everyday_limit WHERE item_id = '"+itemId+"'");
//
// }
//
//
// }
//
// /**
// * @param appItemId 商品入库Id
// * @param caseName 用例名称打印
// * @throws Exception
// */
// @Test(dataProvider = "providerMethod")
// public void 库存不足测试(String appItemId, String caseName) throws Exception{
//
//
// logger.info(caseName);
//
// String message=null;
// try{
// //兑换
// Response response = gawService.couponExchange(uid, appItemId,44);
//
// }catch (Exception e){
// message = e.getMessage();
// logger.info("message:"+message);
//
// }
//
//
//
// //获取按钮状态
// Response detailResponse = mobileService.appItemDetail(authorization.dafuwengLogin(uid),appItemId);
// String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
// logger.info("兑换按钮:" + exchangeText);
//
//
// Assert.assertTrue(message.contains("商品售罄"),"校验message失败");
// Assert.assertEquals(exchangeText,"商品售罄","校验马上兑换按钮状态失败");
// logger.info("校验实物库存成功");
//
// }
//
//// /**
//// * @param caseNum 用例编号
//// * @param appItemId 商品入库Id
//// * @param caseName 用例名称打印
//// * @throws Exception
//// */
//// @Test(dataProvider = "providerMethod")
//// public void 日期兑换限制测试(int caseNum, String appItemId, String caseName) throws Exception{
////
//// logger.info(caseName);
//// String message = null;
////
//// Map<String,String> map = new HashMap<>();
//// map.put("appItemId",appItemId);
//// Response response =null;
////
//// //兑换
//// try{
//// response = couponExchangeService.couponExchange(authorization.dafuwengLogin(uid), appItemId, null);
////
//// }catch (Exception e){
//// message = e.getMessage();
//// logger.info("message:"+message);
////
//// }
////
//// //获取按钮状态
//// Response detailResponse = mobileService.appItemDetail(authorization.dafuwengLogin(uid),appItemId);
//// String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
//// logger.info("商品兑换按钮:" + exchangeText);
////
//// switch (caseNum){
////
//// case 1:
////// Assert.assertEquals(response.jsonPath().getString("message"),"请在限定时间内兑换哦(13)","校验日期兑换限制失败");
//// Assert.assertTrue(message.contains("请在限定时间内兑换哦(13)"),"校验日期兑换限制失败");
//// Assert.assertEquals(exchangeText,"即将开始","校验马上兑换按钮状态失败");
//// logger.info("校验实物日期兑换限制未开始成功");
//// break;
////
//// case 2:
//// Assert.assertEquals(response.jsonPath().getString("success"),"true","校验日期兑换限制失败");
////// Assert.assertTrue(message.contains("success"),"校验日期兑换限制失败");
//// Assert.assertEquals(exchangeText,"马上兑换","校验马上兑换按钮状态失败");
//// logger.info("校验实物日期兑换限制进行中成功");
//// break;
////
//// case 3:
////// Assert.assertEquals(response.jsonPath().getString("message"),"已结束","校验日期兑换限制失败");
//// Assert.assertTrue(message.contains("已结束"),"校验日期兑换限制失败");
//// Assert.assertEquals(exchangeText,"已结束","校验马上兑换按钮状态失败");
//// logger.info("校验实物日期兑换限制已结束成功");
//// break;
////
//// }
////
////
//// }
//
// @Test
// public void 会员等级测试()throws Exception{
//
// String appItemId = "193821";
// String message = "";
//
// //会员等级无法兑换
// try{
// Response response = gawService.couponExchange(authorization.dafuwengLogin(uid), appItemId,44);
// response.prettyPrint();
//
// }catch (Exception e){
// message = e.toString();
// }
// logger.info(message);
//
// //会员等级可兑换,vip=5
// Response response = gawService.couponExchange(authorization.generateSignAutoLogin("2wGQc3MZaQsqYFWcX4gguya5PnnS",3402,1),appItemId,44);
// response.prettyPrint();
//
// Assert.assertTrue(message.contains("会员等级不符,请挑选其他吧(15)"),"校验message失败");
// Assert.assertTrue(message.contains("\"success\":false"),"校验success失败");
// Assert.assertEquals(response.jsonPath().getString("success"),"true","校验兑换结果失败");
// logger.info("校验实物会员等级成功");
//
// }
//
// @Test
// public void 用户周期限制消费测试() throws Exception {
//
// String appItemId = "193844";
// try{
//
// //第一次兑换
// Response response = gawService.couponExchange(uid, appItemId,41);
// response.prettyPrint();
// String orderId = response.jsonPath().getString("data.orderId");
// //获取兑换结果
// response = mobileService.orderStatusQuery(uid,orderId);
// response.prettyPrint();
// String message = response.jsonPath().getString("message");
// int i = 10;
// //异步接口,直到兑换成功
// while (i > 0 && "兑换正在处理中...".equals(message)) {
// Thread.sleep(1000);
// response = mobileService.orderStatusQuery(uid,orderId);
// response.prettyPrint();
// message = response.jsonPath().getString("message");
// i--;
// }
//
// Response detailResponse = mobileService.appItemDetail(authorization.dafuwengLogin(uid),appItemId);
// detailResponse.prettyPrint();
// String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
// logger.info("商品兑换按钮:" + exchangeText);
//
// //第二次兑换
// Thread.sleep(3000);
// try{
// response = gawService.couponExchange(uid, appItemId,41);
// response.prettyPrint();
//
// }catch (Exception e){
// message = e.toString();
// }
// logger.info(message);
//
// Assert.assertTrue(message.contains("已达兑换次数上限"),"校验message失败");
// Assert.assertTrue(message.contains("\"success\":false"),"校验success失败");
//
// Assert.assertEquals(exchangeText,"已达兑换次数上限","校验兑换按钮失败");
// logger.info("校验实物用户周期限制消费成功");
//
// }catch (Exception e){
//
// throw new Exception("异常信息打印:" + e);
//
// }finally {
//// jdbc.update("DELETE FROM credits_dev.consumer_limit_record WHERE item_id = '"+itemId+"'");
//
// }
//
//
// }
}
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.DataProvider;
import org.testng.annotations.Test;
import utils.MatcherString;
import java.lang.reflect.Method;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;
/**
* Created by mabo on 2019/3/26
*/
public class 自有新虚拟商品_充值_兑换限制 extends CheckTemplet{
@Autowired
http.service.app.gawService gawService;
@Autowired
http.service.app.tawService tawService;
@Autowired
MobileService mobileService;
@Autowired
Authorization authorization;
private int uid = 7005;
private String consumerId = "100144147";
private String url = "http://activity.m.duibatest.com.cn";
private Map cookie = null;
@BeforeMethod
public void beforeMethod() {
try {
cookie = authorization.dafuwengLogin(uid);
jdbc.update("DELETE FROM credits_dev.consumer_limit_record where consumer_id = ?",consumerId);
jdbc.update("DELETE FROM credits_dev.consumer_limit_record_only where consumer_id = ?",consumerId);
jdbc.update("DELETE FROM goods.tb_everyday_limit where app_item_id=193883");
} catch (Exception e) {
e.printStackTrace();
}
}
@DataProvider
public Object[][] providerMethod(Method method) {
Object[][] result = null;
if (method.getName().equals("日期兑换限制测试")) {
result = new Object[][]{
new Object[]{1, "194257",75, "实物日期兑换限制未开始测试"}, //case1
new Object[]{2, "194258",76,"实物日期兑换限制进行中测试"}, //case2
new Object[]{3, "194259",77, "实物日期兑换限制已结束"}, //case3
};
}
if (method.getName().equals("库存不足测试")) {
result = new Object[][]{
new Object[]{"193885", "实物库存不足测试"}, //case1
};
}
return result;
}
@Test
public void 用户每日限制消费测试() throws Exception {
String appItemId = "193851";
try{
//第一次兑换
Response response = gawService.virtualExchange(cookie, appItemId,48);
response.prettyPrint();
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--;
}
Response detailResponse = mobileService.appItemDetail(authorization.dafuwengLogin(uid),appItemId);
detailResponse.prettyPrint();
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
logger.info("商品兑换按钮:" + exchangeText);
//第二次兑换
Thread.sleep(3000);
try{
response = gawService.virtualExchange(cookie, appItemId,48);;
response.prettyPrint();
}catch (Exception e){
message = e.toString();
}
logger.info(message);
Assert.assertTrue(message.contains("今日已达兑换上限"),"校验message失败");
Assert.assertTrue(message.contains("\"success\":false"),"校验success失败");
Assert.assertEquals(exchangeText,"今日已达兑换上限","校验兑换按钮失败");
logger.info("校验实物用户每日限制消费成功");
}catch (Exception e){
throw new Exception("异常信息打印:" + e);
}finally {
// jdbc.update("DELETE FROM credits_dev.consumer_limit_record WHERE item_id = '"+itemId+"'");
}
}
@Test
public void 用户永久限制消费测试() throws Exception {
String appItemId = "193882";
try{
//第一次兑换
Response response = gawService.virtualExchange(cookie, appItemId,54);
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--;
}
Response detailResponse = mobileService.appItemDetail(authorization.dafuwengLogin(uid),appItemId);
detailResponse.prettyPrint();
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
logger.info("商品兑换按钮:" + exchangeText);
//第二次兑换
Thread.sleep(3000);
try{
response = gawService.virtualExchange(cookie, appItemId,54);
response.prettyPrint();
}catch (Exception e){
message = e.toString();
}
logger.info(message);
Assert.assertTrue(message.contains("已达兑换次数上限"),"校验message失败");
Assert.assertTrue(message.contains("\"success\":false"),"校验success失败");
Assert.assertEquals(exchangeText,"已达兑换次数上限","校验兑换按钮失败");
logger.info("校验实物用户永久限制消费成功");
}catch (Exception e){
throw new Exception("异常信息打印:" + e);
}finally {
// jdbc.update("DELETE FROM credits_dev.consumer_limit_record WHERE item_id = '"+itemId+"'");
// jdbc.update("DELETE FROM credits_dev.consumer_limit_record_only WHERE item_id = '"+itemId+"'");
}
}
@Test
public void 每日兑换上限测试() throws Exception {
String appItemId = "193883";
try{
//第一次兑换
Response response = gawService.virtualExchange(cookie, appItemId,55);
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 = mobileService.orderStatusQuery(uid,orderId);
response.prettyPrint();
message = response.jsonPath().getString("message");
i--;
}
Response detailResponse = mobileService.appItemDetail(authorization.dafuwengLogin(uid),appItemId);
detailResponse.prettyPrint();
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
logger.info("商品兑换按钮:" + exchangeText);
//第二次兑换
Thread.sleep(3000);
try{
response = gawService.virtualExchange(cookie, appItemId,55);
response.prettyPrint();
}catch (Exception e){
message = e.toString();
}
logger.info(message);
Assert.assertTrue(message.contains("商品售罄"),"校验message失败");
Assert.assertTrue(message.contains("\"success\":false"),"校验success失败");
Assert.assertEquals(exchangeText,"每日限量已兑完","校验兑换按钮失败");
logger.info("校验实物每日兑换上限成功");
}catch (Exception e){
throw new Exception("异常信息打印:" + e);
}finally {
//清掉每日兑换限制数据
// jdbc.update("DELETE FROM goods.tb_everyday_limit WHERE item_id = '"+itemId+"'");
}
}
/**
* @param appItemId 商品入库Id
* @param caseName 用例名称打印
* @throws Exception
*/
@Test(dataProvider = "providerMethod")
public void 库存不足测试(String appItemId, String caseName) throws Exception{
logger.info(caseName);
String message=null;
try{
//兑换
Response response = gawService.virtualExchange(cookie, appItemId,57);
}catch (Exception e){
message = e.getMessage();
logger.info("message:"+message);
}
//获取按钮状态
Response detailResponse = mobileService.appItemDetail(authorization.dafuwengLogin(uid),appItemId);
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
logger.info("兑换按钮:" + exchangeText);
Assert.assertTrue(message.contains("商品售罄"),"校验message失败");
Assert.assertEquals(exchangeText,"商品售罄","校验马上兑换按钮状态失败");
logger.info("校验实物库存成功");
}
/**
* @param caseNum 用例编号
* @param appItemId 商品入库Id
* @param caseName 用例名称打印
* @throws Exception
*/
@Test(dataProvider = "providerMethod")
public void 日期兑换限制测试(int caseNum, String appItemId,int skuId, String caseName) throws Exception{
logger.info(caseName);
String message = null;
Map<String,String> map = new HashMap<>();
map.put("appItemId",appItemId);
Response response =null;
//兑换
try{
response = gawService.virtualExchange(cookie, appItemId, skuId);
}catch (Exception e){
message = e.getMessage();
logger.info("message:"+message);
}
//获取按钮状态
Response detailResponse = mobileService.appItemDetail(authorization.dafuwengLogin(uid),appItemId);
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
logger.info("商品兑换按钮:" + exchangeText);
switch (caseNum){
case 1:
// Assert.assertEquals(response.jsonPath().getString("message"),"请在限定时间内兑换哦(13)","校验日期兑换限制失败");
Assert.assertTrue(message.contains("限2019-03-28至2032-04-30日期内兑换"),"校验日期兑换限制失败");
Assert.assertEquals(exchangeText,"限2019-03-28至2032-04-30日期内兑换","校验马上兑换按钮状态失败");
logger.info("校验实物日期兑换限制未开始成功");
break;
case 2:
Assert.assertEquals(response.jsonPath().getString("success"),"true","校验日期兑换限制失败");
// Assert.assertTrue(message.contains("success"),"校验日期兑换限制失败");
Assert.assertEquals(exchangeText,"马上兑换","校验马上兑换按钮状态失败");
logger.info("校验实物日期兑换限制进行中成功");
break;
case 3:
// Assert.assertEquals(response.jsonPath().getString("message"),"已结束","校验日期兑换限制失败");
Assert.assertTrue(message.contains("已结束"),"校验日期兑换限制失败");
Assert.assertEquals(exchangeText,"已结束","校验马上兑换按钮状态失败");
logger.info("校验实物日期兑换限制已结束成功");
break;
}
}
@Test
public void 会员等级测试()throws Exception{
String appItemId = "194305";
String message = "";
//会员等级无法兑换
try{
Response response = gawService.virtualExchange(authorization.dafuwengLogin(uid), appItemId,81);
response.prettyPrint();
}catch (Exception e){
message = e.toString();
}
logger.info(message);
//会员等级可兑换,vip=5
Response response = gawService.virtualExchange(authorization.generateSignAutoLogin("3tzVcss7SnAvA5ppT1m1rMPhaBcD",7083,1),appItemId,81);
response.prettyPrint();
Assert.assertTrue(message.contains("未达到会员等级要求"),"校验message失败");
Assert.assertTrue(message.contains("\"success\":false"),"校验success失败");
Assert.assertEquals(response.jsonPath().getString("success"),"true","校验兑换结果失败");
logger.info("校验实物会员等级成功");
}
@Test
public void 用户周期限制消费测试() throws Exception {
String appItemId = "193886";
try{
//第一次兑换
Response response = gawService.virtualExchange(cookie, appItemId,59);
response.prettyPrint();
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--;
}
Response detailResponse = mobileService.appItemDetail(cookie,appItemId);
detailResponse.prettyPrint();
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
logger.info("商品兑换按钮:" + exchangeText);
//第二次兑换
Thread.sleep(3000);
try{
response = gawService.virtualExchange(cookie, appItemId,59);
response.prettyPrint();
}catch (Exception e){
message = e.toString();
}
logger.info(message);
Assert.assertTrue(message.contains("已达兑换次数上限"),"校验message失败");
Assert.assertTrue(message.contains("\"success\":false"),"校验success失败");
Assert.assertEquals(exchangeText,"已达兑换次数上限","校验兑换按钮失败");
logger.info("校验实物用户周期限制消费成功");
}catch (Exception e){
throw new Exception("异常信息打印:" + e);
}finally {
// jdbc.update("DELETE FROM credits_dev.consumer_limit_record WHERE item_id = '"+itemId+"'");
}
}
}
......@@ -110,9 +110,9 @@ public class gawService {
Assert.assertEquals(response.jsonPath().getString("success"),"true");
}catch(Exception e){
throw new Exception("/gaw/objectExchange/create接口返回异常,返回信息:"+response.asString());
throw new Exception("/gaw/couponExchange/create接口返回异常,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/gaw/objectExchange/create接口返回异常,返回信息:"+response.asString());
throw new Exception("/gaw/couponExchange/create接口返回异常,返回信息:"+response.asString());
}
return response;
......@@ -165,4 +165,93 @@ public class gawService {
return response;
}
//优惠券兑换接口
public Response couponExchange(Map cookie, String appItemId,int skuId) 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","100");
mapList.put("price",0);
list.add(mapList);
map.put("remark",""); //买家留言
map.put("degreeId","");
map.put("actualPrice","0"); //总金额
map.put("actualCredits","100"); //总积分
map.put("itemParam",list.toArray());
map.put("payType","3");
map.put("expressPrice","0");
map.put("validate","");
map.put("token","yrJRr7Cddp2YeQd");
JSONObject jsonParam = JSONObject.parseObject(JSON.toJSONString(map));
logger.info("请求实物兑换接口:"+ "/gaw/couponExchange/create");
Response response = given().contentType("application/json; charset=UTF-8").cookies(cookie).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{
Assert.assertEquals(response.jsonPath().getString("success"),"true");
}catch(Exception e){
throw new Exception("/gaw/couponExchange/create接口返回异常,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/gaw/couponExchange/create接口返回异常,返回信息:"+response.asString());
}
return response;
}
//虚拟商品(充值)兑换接口
public Response virtualExchange(Map cookie, String appItemId,int skuId) 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","100");
mapList.put("price",0);
list.add(mapList);
map.put("remark",""); //买家留言
map.put("degreeId","");
map.put("actualPrice","0"); //总金额
map.put("actualCredits","100"); //总积分
map.put("itemParam",list.toArray());
map.put("payType","3");
map.put("expressPrice","0");
map.put("validate","");
map.put("token","yrJRr7Cddp2YeQd");
JSONObject jsonParam = JSONObject.parseObject(JSON.toJSONString(map));
logger.info("请求实物兑换接口:"+ "/gaw/virtualExchange/create");
Response response = given().contentType("application/json; charset=UTF-8").cookies(cookie).body(jsonParam).post("http://"+goodsHost+"/gaw/virtualExchange/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{
Assert.assertEquals(response.jsonPath().getString("success"),"true");
}catch(Exception e){
throw new Exception("/gaw/virtualExchange/create接口返回异常,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/gaw/virtualExchange/create接口返回异常,返回信息:"+response.asString());
}
return response;
}
}
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