Commit 81775641 authored by panyuli's avatar panyuli

Merge branch 'panyuli' into develop

parents 12afc8b3 5e2d9f85
......@@ -17,10 +17,7 @@ import org.testng.annotations.Test;
import java.lang.reflect.Method;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.*;
import static io.restassured.RestAssured.given;
......@@ -776,8 +773,6 @@ public class 优惠券_兑换流程测试_ExchangeTest extends DuibaTestBase {
}
//优惠券兑换接口抽离
public Response 优惠券兑换(String appItemId,String itemId,int uid) throws Exception {
Response response = couponExchangeService.couponExchange(authorization.dafuwengLogin(uid),appItemId,itemId);
......@@ -822,5 +817,4 @@ public class 优惠券_兑换流程测试_ExchangeTest extends DuibaTestBase {
}
package http.cases.ExchangeTest;
import base.DuibaLog;
import base.DuibaTestBase;
import http.service.Activity.ManagerService;
import http.service.Authorization;
import http.service.app.CouponExchangeService;
import http.service.app.CrecordService;
import http.service.app.LogService;
import http.service.app.MobileService;
import http.service.hd.DeveloperAccountService;
import http.service.hd.DsOrderService;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import utils.MatcherString;
import utils.RedisUtil;
import java.lang.reflect.Method;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import static io.restassured.RestAssured.given;
/**
* Created by panyuli on 2018/07/06.
*/
public class 优惠券_兑换流程测试pyl_ExchangeTest extends DuibaTestBase {
@Autowired
private MobileService mobileService;
@Autowired
private Authorization authorization;
@Autowired
private CouponExchangeService couponExchangeService;
@Autowired
private DsOrderService dsOrderService;
@Autowired
ManagerService managerService;
@Autowired
DeveloperAccountService developerAccountService;
@Autowired
CrecordService crecordService;
@Autowired
LogService logService;
private DuibaLog logger = DuibaLog.getLogger();
// private MysqlUtils jdbc;
private String url = "http://activity.m.duibatest.com.cn";
//指定用户
private static int uid = 4478;
@Test(description = "自有优惠券商品兑换成功页添加跳转链接开启,界面按钮显示")
public void 兑换成功页添加跳转链接开启() throws Exception {
logger.info("自有优惠券商品兑换成功页添加跳转链接开启,界面按钮显示");
Response response = mobileService.appItemDetail(authorization.dafuwengLogin(uid), "185439");
// response.prettyPrint();
// logger.info( "response.prettyPrint()"+ response.asString());
Map<String, String> map = authorization.dafuwengLogin(uid,true);
// Iterator it = map.entrySet().iterator();
// while (it.hasNext()) {
// Map.Entry entry = (Map.Entry) it.next();
// Object key = entry.getKey();
// Object value = entry.getValue();
// System.out.println("key=" + key + " value=" + value);
// }
Assert.assertEquals(response.asString().contains("马上兑换"),true,"页面数据返回错误");
logger.info("校验 页面数据文本信息 成功");
response = couponExchangeService.couponExchange(authorization.dafuwengLogin(uid),"185439",null);
String orderId = response.jsonPath().getString("orderId");
logger.info("订单号:" + orderId);
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid), orderId);
response.prettyPrint();
String status = response.jsonPath().getString("status");
//异步接口
int i = 10;
while (i > 0 && status.equals("processing")) {
Thread.sleep(1000);
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid), orderId);
response.prettyPrint();
status = response.jsonPath().getString("status");
i--;
}
// response.prettyPrint();
Response resultResponse = crecordService.recordDetail(orderId,uid);
//resultResponse.prettyPrint();
String exchangeText = MatcherString.getString(resultResponse.asString(), "\"btnText\":\"(.*?)\",", 1);
logger.info("exchangeText"+exchangeText);
Assert.assertEquals(resultResponse.asString().contains("马上使用"),true,"页面数据返回错误");
Assert.assertEquals(exchangeText,"马上使用","页面数据返回错误");
logger.info("自有优惠券商品兑换成功页添加跳转链接开启,界面按钮显示息 成功");
}
@Test(description = "自有优惠券兑换失败兑换条展示错乱 bugid=908131")
public void 优惠券兑换失败兑换条展示错乱() throws Exception {
logger.info("自有优惠券商品兑换成功页添加跳转链接开启,界面按钮显示");
Response response = mobileService.appItemDetail(authorization.dafuwengLogin(uid), "185529");
Map<String, String> map = authorization.dafuwengLogin(uid,true);
Assert.assertEquals(response.asString().contains("马上兑换"),true,"页面数据返回错误");
logger.info("校验 页面数据文本信息 成功");
response = couponExchangeService.couponExchange(authorization.dafuwengLogin(uid),"185529",null);
String orderId = response.jsonPath().getString("orderId");
logger.info("订单号:" + orderId);
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid), orderId);
response.prettyPrint();
String status = response.jsonPath().getString("status");
//异步接口
int i = 10;
while (i > 0 && status.equals("processing")) {
Thread.sleep(1000);
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid), orderId);
response.prettyPrint();
status = response.jsonPath().getString("status");
i--;
}
// response.prettyPrint();
Response resultResponse = crecordService.recordDetailNew(orderId,uid);
resultResponse.prettyPrint();
String exchangeText = MatcherString.getString(resultResponse.asString(), "\"isShowButton\":(.*?),", 1);
logger.info("exchangeText:"+exchangeText);
Assert.assertEquals(exchangeText,"false","页面数据返回错误");
Assert.assertEquals(resultResponse.asString().contains("马上兑换"),false,"页面数据返回错误");
//Assert.assertEquals(resultResponse.asString().contains("审核中"),true,"页面数据返回错误");
logger.info("自有优惠券兑换失败兑换条展示错乱 成功");
}
@Test(description = "自有优惠券商品兑换成功页添加跳转链接开启,界面按钮显示")
public void 兑换成功页添加界面按钮显示且可以正常调转() throws Exception {
logger.info("自有优惠券商品兑换成功页添加跳转链接开启,界面按钮显示");
Response response = mobileService.appItemDetail(authorization.dafuwengLogin(uid), "185571");
// response.prettyPrint();
// logger.info( "response.prettyPrint()"+ response.asString());
Map<String, String> map = authorization.dafuwengLogin(uid,true);
Assert.assertEquals(response.asString().contains("马上兑换"),true,"页面数据返回错误");
logger.info("校验 页面数据文本信息 成功");
response = couponExchangeService.couponExchange(authorization.dafuwengLogin(uid),"185571",null);
String orderId = response.jsonPath().getString("orderId");
logger.info("订单号:" + orderId);
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid), orderId);
response.prettyPrint();
String status = response.jsonPath().getString("status");
//异步接口
int i = 10;
while (i > 0 && status.equals("processing")) {
Thread.sleep(1000);
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid), orderId);
response.prettyPrint();
status = response.jsonPath().getString("status");
i--;
}
// response.prettyPrint();
Response resultResponse = crecordService.recordDetail(orderId,uid);
//resultResponse.prettyPrint();
String exchangeText = MatcherString.getString(resultResponse.asString(), "\"btnText\":\"(.*?)\",", 1);
logger.info("exchangeText"+exchangeText);
Assert.assertEquals(resultResponse.asString().contains("马上兑换"),true,"页面数据返回错误");
Assert.assertEquals(exchangeText,"马上兑换","页面数据返回错误");
exchangeText = MatcherString.getString(resultResponse.asString(), "\"androidDownloadUrl\":\"(.*?)\",", 1);
String url=exchangeText;
logger.info("url:"+url);
// resultResponse.prettyPrint();
Assert.assertEquals(resultResponse.asString().contains("www.baidu.com"),true,"按钮对应的连接数据返回错误");
logger.info("自有优惠券商品兑换成功页添加跳转链接开启,界面按钮显示息 成功");
}
}
package http.cases.ExchangeTest;
import base.DuibaTestBase;
import http.service.Activity.ManagerService;
import http.service.Authorization;
import http.service.app.MobileService;
import http.service.app.VirtualExchangeService;
import base.DuibaLog;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.Test;
import java.util.Map;
/**
* Created by yeqinqin on 2018/6/11.
*/
public class 虚拟商品_兑换异常测试 extends DuibaTestBase {
@Autowired
private MobileService mobileService;
@Autowired
private Authorization authorization;
@Autowired
ManagerService managerService;
@Autowired
VirtualExchangeService virtualExchangeService;
private DuibaLog logger = DuibaLog.getLogger();
//指定用户
private static int uid = 0;
//实物兑换积分不足
@Test(description = "自有虚拟商品积分不足")
public void 积分不足() throws Exception {
//活动详情页
Response response = mobileService.appItemDetail(authorization.dafuwengLogin(uid), "181159");
Map<String, String> map = authorization.dafuwengLogin(uid,true);
Assert.assertEquals(String.valueOf(response.getStatusCode()), "200", "商品详情页面");
response.prettyPrint();
System.out.println(response.asString());
System.out.println("女汉子");
//自有虚拟商品兑换
response = virtualExchangeService.exchange(authorization.dafuwengLogin(uid), "181159", "123");
//获取orderId
String orderId = response.jsonPath().getString("orderId");
response = mobileService.orderAmbStatusQuery(uid,orderId);
response.prettyPrint();
String message = response.jsonPath().getString("data.message");
//异步接口,直到兑换成功
int i=10;
//异步接口,直到兑换成功
while(i>0&&"兑换正在处理中...".equals(message)){
Thread.sleep(1000);
response = mobileService.orderAmbStatusQuery(uid,orderId);
response.prettyPrint();
message = response.jsonPath().getString("data.message");
i--;
}
Assert.assertEquals(message.trim(),"兑换失败,用户积分余额不足","校验自有虚拟商品积分不足");
}
}
package http.cases.ExchangeTest;
import base.DuibaTestBase;
import http.service.Activity.ManagerService;
import http.service.Authorization;
import http.service.app.CrecordService;
import http.service.app.MobileService;
import http.service.app.VirtualExchangeService;
import base.DuibaLog;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.Test;
import utils.MatcherString;
import java.util.Map;
/**
* Created by panyuli on 2018/6/11.
*/
public class 虚拟商品_兑换异常测试_ExchangeTest extends DuibaTestBase {
@Autowired
private MobileService mobileService;
@Autowired
private Authorization authorization;
@Autowired
ManagerService managerService;
@Autowired
VirtualExchangeService virtualExchangeService;
@Autowired
CrecordService crecordService;
private DuibaLog logger = DuibaLog.getLogger();
//指定用户
private static int uid = 4502;
//实物兑换积分不足
@Test(description = "自有虚拟商品积分不足")
public void 自有虚拟商品积分不足() throws Exception {
logger.info("自有虚拟商品积分不足" );
uid = 3086;
//商品详情页面
Response response = mobileService.appItemDetail(authorization.dafuwengLogin(uid), "185534");
Map<String, String> map = authorization.dafuwengLogin(uid,true);
response.prettyPrint();
Assert.assertEquals(response.asString().contains("不足,去赚"),true,"页面数据返回错误");
logger.info("校验 页面数据文本信息 成功");
//自有虚拟商品兑换
response = virtualExchangeService.exchange(authorization.dafuwengLogin(uid), "185534", "121");
response.prettyPrint();
//获取orderId
String orderId = response.jsonPath().getString("orderId");
logger.info("orderid:"+orderId);
response = mobileService.orderAmbStatusQuery(uid,orderId);
String message = response.jsonPath().getString("data.message");
int i=10;
//异步接口,直到兑换成功
while(i>0&&"兑换正在处理中...".equals(message)){
Thread.sleep(1000);
response = mobileService.orderAmbStatusQuery(uid,orderId);
response.prettyPrint();
message = response.jsonPath().getString("data.message");
i--;
}
Assert.assertEquals(message.trim(),"兑换失败,用户积分余额不足","校验自有虚拟商品积分不足");
logger.info("校验积分不足验证成功");
}
@Test(description = "自有虚拟商品库存不足")
public void 自有虚拟商品库存不足() throws Exception {
logger.info("自有虚拟商品库存不足" );
//用户id
uid=4502;
//活动详情页
Response response = mobileService.appItemDetail(authorization.dafuwengLogin(uid), "185535");
Map<String, String> map = authorization.dafuwengLogin(uid,true);
Assert.assertEquals(response.asString().contains("已兑完"),true,"页面数据返回错误");
logger.info("校验 页面数据文本信息 成功");
String message=null;
try{
response = virtualExchangeService.exchange(authorization.dafuwengLogin(uid), "185535", "123");
response.prettyPrint();
}catch(Exception e){
message=e.toString();
}
Assert.assertTrue(message.contains("今日已兑完,明天再来哦(14)"),"今日已兑完,校验失败");
logger.info("自有虚拟商品库存不足");
}
@Test(description = "虚拟商品用户每日兑换限制测试只能兑换一次" )
public void 自有虚拟商品用户每日兑换限制测试只能兑换一次() throws Exception{
try{
logger.info("虚拟商品用户每日兑换限制测试只能兑换一次");
//商品详情页面
Response response = mobileService.appItemDetail(authorization.dafuwengLogin(uid), "185684");
Map<String, String> map = authorization.dafuwengLogin(uid,true);
Assert.assertEquals(response.asString().contains("马上兑换"),true,"页面数据返回错误");
logger.info("校验 页面数据文本信息 成功");
//自有虚拟商品兑换
response = virtualExchangeService.exchange(authorization.dafuwengLogin(uid), "185684", "123");
//获取orderId
String orderId = response.jsonPath().getString("orderId");
logger.info("orderid:"+orderId);
response = mobileService.orderAmbStatusQuery(uid,orderId);
String message = response.jsonPath().getString("data.message");
int i=10;
//异步接口,直到兑换成功
while(i>0&&"兑换正在处理中...".equals(message)){
Thread.sleep(1000);
response = mobileService.orderAmbStatusQuery(uid,orderId);
response.prettyPrint();
message = response.jsonPath().getString("data.message");
i--;
}
Response resultResponse = crecordService.recordDetailNew(orderId,uid);
String exchangeText = MatcherString.getString(resultResponse.asString(), "\"exchangeStatusText\":\"(.*?)\",", 1);
logger.info("exchangeText"+exchangeText);
Assert.assertEquals(resultResponse.asString().contains("兑换成功"),true,"兑换数据页面数据返回错误");
//按钮层校验
response = mobileService.appItemDetail(authorization.dafuwengLogin(uid), "185684");
Assert.assertEquals(response.asString().contains("今日已兑换"),true,"页面数据返回错误");
// 第二次兑换接口层校验
response = virtualExchangeService.exchange(authorization.dafuwengLogin(uid), "185684", "123");
Assert.assertEquals(response.jsonPath().getString("message").contains("今日已兑换"),true,"接口数据返回数据返回错误");
logger.info("虚拟商品用户每日兑换限制测试只能兑换一次 成功");
}catch (Exception e){
throw new Exception("异常信息打印:" + e);
}finally {
jdbc.update("DELETE FROM credits_dev.consumer_limit_record_only WHERE app_item_id = '185684'");
jdbc.update("DELETE FROM credits_dev.consumer_limit_record WHERE app_item_id = '185684'");
}
}
@Test(description = "虚拟商品用户永久兑换")
public void 自有虚拟商品用户永久一次兑换() throws Exception{
try{
logger.info("自有虚拟商品用户永久一次兑换");
//商品详情页面
Response response = mobileService.appItemDetail(authorization.dafuwengLogin(uid), "185738");
Map<String, String> map = authorization.dafuwengLogin(uid,true);
response.prettyPrint();
Assert.assertEquals(response.asString().contains("马上兑换"),true,"页面数据返回错误");
logger.info("校验 页面数据文本信息 成功");
//自有虚拟商品兑换
response = virtualExchangeService.exchange(authorization.dafuwengLogin(uid), "185738", "123");
//获取orderId
String orderId = response.jsonPath().getString("orderId");
logger.info("orderid:"+orderId);
response = mobileService.orderAmbStatusQuery(uid,orderId);
String message = response.jsonPath().getString("data.message");
int i=10;
//异步接口,直到兑换成功
while(i>0&&"兑换正在处理中...".equals(message)){
Thread.sleep(1000);
response = mobileService.orderAmbStatusQuery(uid,orderId);
response.prettyPrint();
message = response.jsonPath().getString("data.message");
i--;
}
Response resultResponse = crecordService.recordDetailNew(orderId,uid);
String exchangeText = MatcherString.getString(resultResponse.asString(), "\"exchangeStatusText\":\"(.*?)\",", 1);
logger.info("exchangeText"+exchangeText);
Assert.assertEquals(resultResponse.asString().contains("兑换成功"),true,"兑换数据页面数据返回错误");
// 第二次兑换 按钮层校验
// response = mobileService.appItemDetail(authorization.dafuwengLogin(uid), "185684");
// response.prettyPrint();
// Assert.assertEquals(response.asString().contains("已兑换"),true,"页面数据返回错误");
// 第二次兑换接口层校验
response = virtualExchangeService.exchange(authorization.dafuwengLogin(uid), "185684", "123");
Assert.assertEquals(response.jsonPath().getString("message").contains("今日已兑换"),true,"接口数据返回数据返回错误");
logger.info("虚拟商品用户永久兑换 成功");
}catch (Exception e){
throw new Exception("异常信息打印:" + e);
}finally {
jdbc.update("DELETE FROM credits_dev.consumer_limit_record_only WHERE app_item_id = '185738'");
jdbc.update("DELETE FROM credits_dev.consumer_limit_record WHERE app_item_id = '185738'");
}
}
//@Test(description = "虚拟商品自定义兑换按钮文案马上使用按钮")
public void 虚拟商品自定义兑换按钮文案马上使用按钮() throws Exception {
logger.info("虚拟商品马上使用按钮验证开始");
//创建虚拟商品的时候,有自定义兑换按钮文案的文案设置,将文案设置成马上使用
}
}
\ No newline at end of file
......@@ -56,4 +56,5 @@ public class CrecordService {
return response;
}
}
package http.service.app;
import http.service.Authorization;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.Map;
import static io.restassured.RestAssured.given;
@Service
public class LogService {
@Value("${trade.host}")
private String tradeHost;
@Autowired
Authorization authorization;
//优惠券使用按钮
public Response redirect(String url,int uid){
Map<String,String> map = new HashMap<>();
map.put("url",url);
map.put("dpm","2239.25.1.0");
map.put("dcm","102.185571.0.0");
map.put("couponcode","10000106");
Response response = given().cookies(authorization.dafuwengLogin(uid)).params(map).get("http://"+tradeHost+"/log/redirect");
return response;
}
}
......@@ -32,7 +32,7 @@ public class MobileService {
}
public Response appItemDetail(Map cookies,String itemId){
/* public Response appItemDetail(Map cookies,String itemId){
Map<String,String> map = new HashMap<>();
map.put("itemId",itemId);
map.put("dpm","1.5.183.5");
......@@ -41,8 +41,27 @@ public class MobileService {
response.prettyPrint();
return response;
}
}*/
public Response appItemDetail(Map cookies,String appItemId) throws Exception {
Map<String,String> map = new HashMap<>();
map.put("appItemId",appItemId);
map.put("dpm","1.5.183.5");
map.put ("dcm","102.181159.0.0");
logger.info("请求商品详情页面");
Response response = given().cookies(cookies).params(map).get("http://"+goodsHost+"/mobile/appItemDetail");
try {
Assert.assertEquals(String.valueOf(response.getStatusCode()), "200", "/mobile/appItemDetail接口失败");
} catch (Exception e) {
throw new Exception("/mobile/appItemDetail接口失败,返回信息:" + response.asString());
} catch (Error er) {
throw new Exception("/mobile/appItemDetail接口失败,返回信息:" + response.asString());
}
return response;
}
// public Response orderStatusQuery(Cookies cookies,String orderId){
//
......
......@@ -29,11 +29,9 @@ public class VirtualExchangeService {
logger.info("请求/virtualExchange/exchange接口");
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(cookies).params(map).post("http://"+goodsHost+"/virtualExchange/exchange");//couponExchange
// response.prettyPrint();
try{
Assert.assertEquals(response.jsonPath().getString("success"),"true");
System.out.println("");
}catch(Exception e){
throw new Exception("/objectExchange/exchange接口返回异常,返回信息:"+response.asString());
......
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