Commit 8fb108e1 authored by 赵然's avatar 赵然

Merge branch 'develop'

parents 664cd062 ae63d464
......@@ -95,7 +95,7 @@ public class CustomActivity_DuibaTest extends DuibaTestBase {
String androidDL = MatcherString.getString(ManagerResponse.asString(), "androidurl: '(.*?)',", 1);
String iOSDL = MatcherString.getString(ManagerResponse.asString(), "iosurl: '(.*?)',", 1);
String usebtn = MatcherString.getString(ManagerResponse.asString(), "usebtn: '(.*?)',", 1);
String actLinkEx = "//activity.m.duibatest.com.cn/crecord/recordDetailNew/";
String actLinkEx = "//activity.m.duibatest.com.cn/crecord/recordDetailNew";
String linkUrl = MatcherString.getString(LinkResponse.asString(), "target=\"_blank\" href=\"(.*?)\">", 1);
//进行接口测试传参
......
......@@ -23,7 +23,8 @@ import static io.restassured.RestAssured.given;
* Created by panyuli on 2018/07/06.
*/
public class 优惠券_兑换流程测试pyl_ExchangeTest extends CheckTemplet {
public class 优惠券_兑换异常测试_ExchangeTest extends CheckTemplet {
@Autowired
private MobileService mobileService;
......
......@@ -54,7 +54,7 @@ public class 优惠券测试_DuibaTest extends AbstractTestNGSpringContextTests
String androidDL = MatcherString.getString(ManagerResponse.asString(), "androidurl: '(.*?)',", 1);
String iOSDL = MatcherString.getString(ManagerResponse.asString(), "iosurl: '(.*?)',", 1);
String actusebtn = MatcherString.getString(ManagerResponse.asString(), "usebtn: '(.*?)',", 1);
String actLinkEx = "//activity.m.duibatest.com.cn/crecord/recordDetailNew/";
String actLinkEx = "//activity.m.duibatest.com.cn/crecord/recordDetailNew";
String linkUrl = MatcherString.getString(LinkResponse.asString(), "target=\"_blank\" href=\"(.*?)\">", 1);
//获取管理员后台优惠券库存
......
......@@ -32,6 +32,7 @@ public class 谢谢参与测试_DuibaTest extends DuibaTestBase {
Assert.assertEquals(response.jsonPath().getString("lottery.type"), "thanks", "校验类型失败");
Assert.assertEquals(response.jsonPath().getString("lottery.id").isEmpty(), false, "校验id失败");
Assert.assertNotNull(response.jsonPath().getString("lottery.id"),"校验id失败");
//校验返回字段
Assert.assertEquals(response.asString().contains("id"),true,"校验id失败");
logger.info("校验type,id成功");
......
package http.cases.SaasDeveloperTest;
import base.Config;
import base.DuibaTestBase;
import base.DuibaLog;
import http.service.Saas.DeveloperCouponService;
import http.service.Saas.DeveloperObjectService;
import http.service.Saas.DoUpdateAppItemService;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
import org.testng.Assert;
import org.testng.annotations.Test;
@ContextConfiguration(classes = Config.class)
public class 修改兑吧商品 extends DuibaTestBase {
@Autowired
DoUpdateAppItemService doUpdateAppItemService;
@Autowired
DeveloperObjectService developerObjectService;
private DuibaLog logger = DuibaLog.getLogger();
//修改兑吧实物
@Test
public void a_修改兑吧实物() throws Exception{
String appId="19515";
String rowId="1";
String itemTyp="";
String status="";
String itemName="【SaaS-自动化测试】实物勿动";
String belong="";
String priceType="";
//查询商品,获取商品ID
Response response= doUpdateAppItemService.appItems(appId,rowId,itemTyp,status,itemName,belong,priceType);
//获取商品ID
String appItemId = String.valueOf(response.jsonPath().getString("data.list[0].id"));
String title = String.valueOf(response.jsonPath().getString("data.list[0].title"));
String type = String.valueOf(response.jsonPath().getString("data.list[0].type"));
// logger.info("获取appitermid=="+appItemId+"title=="+title+"type=="+type);
//编辑
Response response2=developerObjectService.editAppItem2(appItemId);
//保存
doUpdateAppItemService.doUpdateAppItem(appId,appItemId,title,"38",type,"31654");
Assert.assertEquals(response2.jsonPath().getString("data.title"), "【SaaS-自动化测试】实物勿动", "校验兑吧商品标题失败");
Assert.assertEquals(response2.jsonPath().getString("data.credits"), "38", "校验兑吧商品失败");
logger.info("校验title,belong成功");
}
//修改兑吧优惠券
@Test
public void b_修改兑吧优惠券() throws Exception{
String appId="19515";
String rowId="1";
String itemTyp="";
String status="";
String itemName="【SaaS-自动化测试】优惠券勿动";
String belong="";
String priceType="";
Response response= doUpdateAppItemService.appItems(appId,rowId,itemTyp,status,itemName,belong,priceType);
//获取商品ID
String appItemId = String.valueOf(response.jsonPath().getString("data.list[0].id"));
String title = String.valueOf(response.jsonPath().getString("data.list[0].title"));
String type = String.valueOf(response.jsonPath().getString("data.list[0].type"));
// logger.info("获取appitermid=="+appItemId+"title=="+title+"type=="+type);
//编辑
doUpdateAppItemService.doUpdateAppItem(appId,appItemId,title,"10","coupon","31658");
Response response2=developerObjectService.editAppItem2(appItemId);
Assert.assertEquals(response2.jsonPath().getString("data.title"), "【SaaS-自动化测试】优惠券勿动", "校验兑吧优惠券商品标题失败");
Assert.assertEquals(response2.jsonPath().getString("data.credits"), "10", "校验兑吧优惠券商品失败");
logger.info("校验title,belong成功");
}
}
package http.cases.SaasDeveloperTest;
import base.Config;
import base.DuibaTestBase;
import http.service.Saas.DeveloperBJZ;
import base.DuibaLog;
import http.service.Saas.DeveloperObjectService;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
import org.testng.Assert;
import org.testng.annotations.Test;
@ContextConfiguration(classes = Config.class)
public class 补给站 extends DuibaTestBase {
@Autowired
DeveloperBJZ developerBJZ;
@Autowired
DeveloperObjectService developerObjectService;
private DuibaLog logger = DuibaLog.getLogger();
String appId="19515";
//添加、上架至尊版实物
@Test
public void a_添加至尊版实物() throws Exception{
//查询列表,获取ID
Response response =developerBJZ.item("2");
String id= String.valueOf(response.jsonPath().getString("data.list[0].id"));
String title= String.valueOf(response.jsonPath().getString("data.list[0].title"));
//添加
developerBJZ.ajaxAddRepo(appId,id);
//上架
developerBJZ.ajaxDirectUp(appId,id);
//查询商品列表,验证商品是否上架成功
Response response2 =developerObjectService.appItems(appId,title);
String appItemId = String.valueOf(response2.jsonPath().getString("data.list[0].id"));
Assert.assertEquals(response2.jsonPath().getString("data.list[0].title"), "测试至尊享版-实物3", "校验实物标题失败");
Assert.assertEquals(response2.jsonPath().getString("data.list[0].status"), "1", "校验实物状态失败");
Assert.assertEquals(response2.jsonPath().getString("data.list[0].type"), "object", "校验实物类型失败");
logger.info("校验title,status成功");
//删除添加的商品
developerObjectService.ajaxDel(appItemId);
}
//添加、上架优惠券
@Test
public void b_添加至尊版优惠券() throws Exception{
//查询列表,获取ID
Response response =developerBJZ.coupons(appId,"2");
String id= String.valueOf(response.jsonPath().getString("data.list[0].id"));
String title= String.valueOf(response.jsonPath().getString("data.list[0].title"));
//添加
developerBJZ.ajaxAddRepo(appId,id);
//上架
developerBJZ.ajaxDirectUp(appId,id);
//查询商品列表,验证商品是否上架成功
Response response2 =developerObjectService.appItems(appId,title);
String appItemId = String.valueOf(response2.jsonPath().getString("data.list[0].id"));
Assert.assertEquals(response2.jsonPath().getString("data.list[0].title"), "测试至尊享版-优惠券", "校验优惠券标题名称失败");
Assert.assertEquals(response2.jsonPath().getString("data.list[0].status"), "1", "校验优惠券状态失败");
Assert.assertEquals(response2.jsonPath().getString("data.list[0].type"), "coupon", "校验优惠券类型失败");
logger.info("校验title,status成功");
//删除添加的商品
developerObjectService.ajaxDel(appItemId);
}
//添加活动
@Test
public void c_添加活动() throws Exception{
//查询热门活动-活动列表,获取商品ID
Response response=developerBJZ.saasActivitys("3");
String goodItemId= String.valueOf(response.jsonPath().getString("data.saasActivitys[0].id"));
//获取商品ID,进入商品订购页面,获取SKU
Response response2=developerBJZ.itemOrderDetail(goodItemId);
String skuId= String.valueOf(response2.jsonPath().getString("data.goodsItemSku[0].skuId"));
//点击订购,传入SKU创建订单
logger.info("kuid==="+skuId);
Response response3=developerBJZ.createAutomationOrderNew(skuId);
String orderid= String.valueOf(response3.jsonPath().getString("data"));
logger.info("kuid==="+orderid);
//下单购买
Response response4=developerBJZ.orderAccountPay(orderid);
}
}
......@@ -30,9 +30,10 @@ public class 种红包配置校验_AccessTest extends DuibaTestBase{
//指定用户
private static int uid = 4689;
private static int uid2 = 4552;
private static int uid3 = 3590;
private static int uid4 = 4386;
@Test
public void 出券开关校验_() throws Exception {
public void 出券衰减开关校验_() throws Exception {
//dafuweng登陆获取cookies
Map cookies = authorization.dafuwengLogin(uid);
//校验种红包配置
......@@ -58,11 +59,12 @@ public class 种红包配置校验_AccessTest extends DuibaTestBase{
logger.info("种红包的红包配置接口校验正确");
}
@Test
public void 出券开关校验_() throws Exception {
public void 出券衰减开关校验_() throws Exception {
//dafuweng登陆获取cookies
Map cookies = authorization.dafuwengLogin(uid2);
//校验种红包配置
......@@ -81,4 +83,53 @@ public class 种红包配置校验_AccessTest extends DuibaTestBase{
logger.info("种红包的红包配置接口校验正确");
}
@Test
public void 流量策略打开校验() throws Exception {
//dafuweng登陆获取cookies
Map cookies = authorization.dafuwengLogin(uid3);
//校验种红包配置
Response response = seedRedPacketService.getExtConfig(cookies);
response.prettyPrint();
String adPositions = response.jsonPath().getString("data.adPositions");
String adSwitch = response.jsonPath().getString("data.adSwitch");
String decrBeginTime = response.jsonPath().getString("data.decrBeginTime");
String decrSwitch = response.jsonPath().getString("data.decrSwitch");
Assert.assertNull(adPositions,"发券位置校验异常");
Assert.assertEquals(adSwitch,"false","种红包开关校验异常");
Assert.assertEquals(decrSwitch,"false","种红包衰减开关校验异常");
Assert.assertNull(decrBeginTime,"衰减时间校验异常");
logger.info("种红包的红包配置接口校验正确");
}
@Test
public void 衰减红包校验() throws Exception {
//dafuweng登陆获取cookies
Map cookies = authorization.dafuwengLogin(uid4);
//调用种植seed
Response response = seedRedPacketService.seed(cookies,"1","424","1");
//种子号
String orderId = response.jsonPath().getString("data.orderNum");
Assert.assertNotNull(orderId,"订单号为空");
logger.info("红包订单为:"+orderId);
//红包衰减
Thread.sleep(65000);
//获取种植结果状态getOrderStatus,异步接口,while循环,status为2处理完成,1处理中
response = seedRedPacketService.getOrderStatus(cookies,orderId);
String status = response.jsonPath().getString("data");
int i =5;
while(i>0&&status.equals("1")){
response = seedRedPacketService.getOrderStatus(cookies,orderId);
status = response.jsonPath().getString("data");
i--;
}
//获取种植获得金额
response = seedRedPacketService.reap(cookies,"1",orderId);
response.prettyPrint();
String isDecr = response.jsonPath().getString("data.isDecr");
Assert.assertEquals(isDecr,"true","红包衰减标识校验失败");
}
}
package http.service.Saas;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import http.service.Authorization;
import base.DuibaLog;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.testng.Assert;
import java.util.HashMap;
import java.util.Map;
import static io.restassured.RestAssured.given;
/**
* 补给站
*/
@Service
public class DeveloperBJZ {
@Value("${hdserver.host}")
String hdHost;
@Autowired
Authorization authorization;
private DuibaLog logger = DuibaLog.getLogger();
//优质好货--查询至尊版特权TAB
public Response item(String type) throws Exception{
String url="http://"+hdHost+"/saasitem/items";
Map<String,String> map = new HashMap<>();
map.put("type",type);
map.put("rowId","1");
map.put("itemName","");
map.put("max","20");
// logger.info("********"+url);
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas()).params(map).get(url);
// response.prettyPrint();
try{
Assert.assertEquals(response.jsonPath().getString("desc"),"成功");
}catch(Exception e){
throw new Exception("创建接口1失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("创建接口2失败,返回信息:"+response.asString());
}
return response;
}
//至尊特权添加商品
public Response ajaxAddRepo(String appId,String itemId) throws Exception{
String url="http://"+hdHost+"/devRepo/ajaxAddRepo";
Map<String,String> map = new HashMap<>();
map.put("appId",appId);
map.put("itemId",itemId);
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas()).params(map).post(url);
// response.prettyPrint();
try{
Assert.assertEquals(response.jsonPath().getString("desc"),"成功");
}catch(Exception e){
throw new Exception("创建接口1失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("创建接口2失败,返回信息:"+response.asString());
}
return response;
}
//至尊特权上架商品
public Response ajaxDirectUp(String appId,String itemIds) throws Exception{
String url="http://"+hdHost+"/devRepo/ajaxDirectUp";
Map<String,String> map = new HashMap<>();
map.put("appId",appId);
map.put("itemIds",itemIds);
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas()).params(map).post(url);
response.prettyPrint();
try{
Assert.assertEquals(response.jsonPath().getString("desc"),"直接上架成功");
}catch(Exception e){
throw new Exception("创建接口1失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("创建接口2失败,返回信息:"+response.asString());
}
return response;
}
//大牌好券--查询至尊版特权TAB
public Response coupons(String appId,String type) throws Exception{
String url="http://"+hdHost+"/saasitem/coupons";
Map<String,String> map = new HashMap<>();
map.put("appId",appId);
map.put("type",type);
map.put("rowId","1");
map.put("subType","");
map.put("max","12");
// logger.info("********"+url);
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas()).params(map).get(url);
// response.prettyPrint();
try{
Assert.assertEquals(response.jsonPath().getString("desc"),"成功");
}catch(Exception e){
throw new Exception("创建接口1失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("创建接口2失败,返回信息:"+response.asString());
}
return response;
}
//热门活动--查询活动
public Response saasActivitys(String categoryId) throws Exception{
String url="http://"+hdHost+"/saasitem/saasActivitys";
Map<String,Object> map = new HashMap<>();
map.put("attrIds","");
map.put("rowId","1");
map.put("max","25");
map.put("categoryId",categoryId);
logger.info("********"+url);
//json 格式转成form表单
JSONObject jsonParam = JSONObject.parseObject(JSON.toJSONString(map));
Response response=given().contentType("application/json;charset=UTF-8").cookies(authorization.hdLoginSaas("19515")).body(jsonParam).post(url);
// response.prettyPrint();
try{
Assert.assertEquals(response.jsonPath().getString("desc"),"成功");
}catch(Exception e){
throw new Exception("创建接口1失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("创建接口2失败,返回信息:"+response.asString());
}
return response;
}
//选中活动
public Response itemOrderDetail(String goodItemId) throws Exception{
String url="http://"+hdHost+"/saasitem/itemOrderDetail";
Map<String,String> map = new HashMap<>();
map.put("goodItemId",goodItemId);
// logger.info("********"+url);
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas()).params(map).get(url);
// response.prettyPrint();
try{
Assert.assertEquals(response.jsonPath().getString("desc"),"成功");
}catch(Exception e){
throw new Exception("创建接口1失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("创建接口2失败,返回信息:"+response.asString());
}
return response;
}
//订购活动--创建订单
public Response createAutomationOrderNew(String skuId) throws Exception{
String url="http://"+hdHost+"/saas/createAutomationOrderNew";
Map<String,String> map = new HashMap<>();
map.put("skuId",skuId);
// logger.info("********"+url);
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas("19515")).params(map).post(url);
// response.prettyPrint();
try{
Assert.assertEquals(response.jsonPath().getString("desc"),"成功");
}catch(Exception e){
throw new Exception("创建接口1失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("创建接口2失败,返回信息:"+response.asString());
}
return response;
}
//订购--账户余额付款
public Response orderAccountPay(String orderId) throws Exception{
String url="http://"+hdHost+"/saas/orderAccountPay";
Map<String,String> map = new HashMap<>();
map.put("orderId",orderId);
// logger.info("********"+url);
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas()).params(map).get(url);
// response.prettyPrint();
try{
Assert.assertEquals(response.jsonPath().getString("desc"),"成功");
}catch(Exception e){
throw new Exception("创建接口1失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("创建接口2失败,返回信息:"+response.asString());
}
return response;
}
}
This diff is collapsed.
......@@ -42,4 +42,26 @@ public class VirtualExchangeService {
return response;
}
public Response exchange2(Map cookies, String appItemId,String degreeId) throws Exception {
Map<String,String> map = new HashMap<>();
map.put("appItemId",appItemId);
map.put("degreeId",degreeId);
map.put("token","xz9eyi");
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
try{
Assert.assertEquals(String.valueOf(response.getStatusCode()), "200", "/objectExchange/exchange接口返回异常");
}catch(Exception e){
throw new Exception("/objectExchange/exchange接口返回异常,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/objectExchange/exchange接口返回异常,返回信息:"+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