Commit 9ab94714 authored by 吕雯燕's avatar 吕雯燕

Merge branch 'duiba_wenyan' into develop

parents aa557bdd cf15013e
package http.cases.ExchangeTest;
import http.service.Authorization;
import http.service.app.CouponExchangeService;
import http.service.app.CrecordService;
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;
import static io.restassured.RestAssured.given;
/**
* Created by lvwenyan on 2019/3/14
*/
public class 多档位话费_兑换流程测试_ExchangeTest extends CheckTemplet {
@Autowired
private MobileService mobileService;
@Autowired
private Authorization authorization;
@Autowired
private CouponExchangeService couponExchangeService;
@Autowired
private CrecordService crecordService;
private static int uid = 6537;
@Test(description = "多档位话费10元用户每天兑换限制")
public void 多档位话费用户每日兑换限制测试() throws Exception{
String message = "";
try{
//话费第一次兑换
Response response = couponExchangeService.phonebillExchange(authorization.dafuwengLogin(uid),"10");
response.prettyPrint();
Assert.assertEquals(response.jsonPath().getString("success"),"true","校验兑换失败");
logger.info("用户成功兑换一次");
//再次兑换
try{
response = couponExchangeService.phonebillExchange(authorization.dafuwengLogin(uid),"10");
response.prettyPrint();
}catch (Exception e){
message = e.toString();
}
logger.info(message);
//获取按钮状态
Response detailResponse = mobileService.detail(authorization.dafuwengLogin(uid),"1");
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"btnText\":\"(.\"btnText\\\":\\\"(.*?)\\\"*?)\",", 1);
logger.info("兑换按钮:"+ exchangeText);
Assert.assertTrue(message.contains("已兑完"),"校验message失败");
Assert.assertEquals(exchangeText,"今日已兑换","校验马上兑换按钮状态失败");
logger.info("校验多档位话费用户每日兑换限制成功");
}catch (Exception e){
throw new Exception("异常信息打印:" + e);
}finally {
jdbc.update("DELETE FROM credits_dev.consumer_limit_record WHERE item_id = '1'");
}
}
}
......@@ -63,7 +63,7 @@ public class 话费_兑换限制测试_ExchangeTest extends CheckTemplet{
}
@Test(description = "每个用户每日兑换限制")
@Test(description = "5元话费用户每日兑换限制")
public void phonebill_每日() throws Exception {
Thread.sleep(2000);
Map<String, Object> mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
......@@ -104,7 +104,7 @@ public class 话费_兑换限制测试_ExchangeTest extends CheckTemplet{
}
@Test(description = "永久兑换限制")
@Test(description = "10元话费用户永久兑换限制")
public void phonebill_永久() throws Exception {
Thread.sleep(2000);
Map<String, Object> mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
......@@ -144,7 +144,7 @@ public class 话费_兑换限制测试_ExchangeTest extends CheckTemplet{
}
}
@Test
@Test(description = "20元话费每日兑换上限")
public void 每日兑换上限测试() throws Exception{
String appItemId = "191793";
......@@ -224,13 +224,13 @@ public class 话费_兑换限制测试_ExchangeTest extends CheckTemplet{
case 1:
Assert.assertTrue(message.contains("请在限定时间内兑换哦(13)"),"校验message失败");
Assert.assertEquals(exchangeText,"即将开始","校验马上兑换按钮状态失败");
logger.info("校验话费兑换日期限制未开始成功");
logger.info("校验2元话费兑换日期限制未开始成功");
break;
case 2:
Assert.assertTrue(message.contains("已结束"),"校验message失败");
Assert.assertEquals(exchangeText,"已结束","校验马上兑换按钮状态失败");
logger.info("校验话费兑换日期限制已结束成功");
logger.info("校验50元话费兑换日期限制已结束成功");
break;
}
......@@ -242,6 +242,37 @@ public class 话费_兑换限制测试_ExchangeTest extends CheckTemplet{
@Test(description = "1元话费会员等级")
public void 会员等级测试() throws Exception{
String appItemId = "191794";
String itemId = "1660";
String degreeId = "1";
String message = "";
//会员等级无法兑换
try{
Response response = couponExchangeService.phonebillExchange(authorization.dafuwengLogin(uid),appItemId,itemId,degreeId);
response.prettyPrint();
}catch (Exception e){
message = e.toString();
}
logger.info(message);
//会员等级可兑换,vip=5
Response response = couponExchangeService.phonebillExchange(authorization.generateSignAutoLogin("SoMhngEcDDfJcqPF6Siz3gVQCfz",6574),appItemId,itemId,degreeId);
response.prettyPrint();
Assert.assertTrue(message.contains("会员等级不符,请挑选其他吧(15)"),"校验message失败");
Assert.assertTrue(message.contains("\"success\":false"),"校验success失败");
Assert.assertEquals(response.jsonPath().getString("success"),"true","校验兑换结果失败");
logger.info("校验1元话费会员等级成功");
}
......
......@@ -36,7 +36,7 @@ public class 插件场景测试_pluginTest extends DuibaTestBase {
private static DuibaLog logger = DuibaLog.getLogger();
// private MysqlUtils jdbc;
//指定用户
private static int uid = 2721;
private static int uid = 6618;
@BeforeClass
public void before(){
......@@ -104,7 +104,7 @@ public class 插件场景测试_pluginTest extends DuibaTestBase {
//先定向再开启
Map<String, Object> mapId = jdbc.findSimpleResult("SELECT * FROM credits_activity.tb_activity_plugin ORDER BY gmt_create DESC LIMIT 1");
String id = String.valueOf(mapId.get("id"));
logger.info(id);
logger.info("插件活动ID:" + id);
pluginService.addSpecify(id);
pluginService.changeStatus(id, "1");
......@@ -157,7 +157,7 @@ public class 插件场景测试_pluginTest extends DuibaTestBase {
//先定向再开启
Map<String, Object> mapId = jdbc.findSimpleResult("SELECT * FROM credits_activity.tb_activity_plugin ORDER BY gmt_create DESC LIMIT 1");
String id = String.valueOf(mapId.get("id"));
logger.info(id);
logger.info("插件活动id:" + id);
pluginService.addSpecify(id);
pluginService.changeStatus(id, "1");
......
......@@ -154,6 +154,7 @@ public class CouponExchangeService {
map.put("phone","18012341234");
map.put("phoneCatName","中国电信");
map.put("phoneProvince","江苏");
map.put("itemId","1");
logger.info("请求/phonebillExchange/exchange接口");
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(cookies).params(map).post("http://"+goodsHost+"/phonebillExchange/exchange");//phonebillExchange
// response.prettyPrint();
......
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