Commit 826f229d authored by 赵然's avatar 赵然

zr

parents 027eeafe 81f452ba
package http.cases.SaasDeveloperTest; package http.cases.SaasDeveloperTest;
import base.Config; import base.Config;
import base.DuibaTestBase;
import http.service.Saas.DeveloperBJZ; import http.service.Saas.DeveloperBJZ;
import base.DuibaLog; import base.DuibaLog;
import http.service.Saas.DeveloperObjectService;
import io.restassured.response.Response; import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.testng.AbstractTestNGSpringContextTests; import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
import org.testng.Assert; import org.testng.Assert;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import java.util.Map;
@ContextConfiguration(classes = Config.class) @ContextConfiguration(classes = Config.class)
public class 补给站 extends DuibaTestBase { public class 补给站 extends AbstractTestNGSpringContextTests{
@Autowired @Autowired
DeveloperBJZ developerBJZ; DeveloperBJZ developerBJZ;
@Autowired
DeveloperObjectService developerObjectService;
private DuibaLog logger = DuibaLog.getLogger(); private DuibaLog logger = DuibaLog.getLogger();
//至尊版app
String appId="19515"; String appId="19515";
//旗舰版app
String appId2="21695";
//添加、上架至尊版实物
@Test @Test(description = "至尊版app添加、上架至尊版实物")
public void a_添加至尊版实物() throws Exception{ public void a_添加至尊版实物() throws Exception{
//查询列表,获取ID //查询列表,获取ID
Response response =developerBJZ.item("2"); Response response =developerBJZ.items("2",appId);
String id= String.valueOf(response.jsonPath().getString("data.list[0].id")); String itemId= String.valueOf(response.jsonPath().getString("data.list[0].id"));
String title= String.valueOf(response.jsonPath().getString("data.list[0].title")); String itemIds= String.valueOf(response.jsonPath().getString("data.list[0].id"));
String itemName=String.valueOf(response.jsonPath().getString("data.list[0].title"));
//添加 //添加
developerBJZ.ajaxAddRepo(appId,id); developerBJZ.ajaxAddRepo(appId,itemId);
//上架 //上架
developerBJZ.ajaxDirectUp(appId,id); developerBJZ.ajaxDirectUp(appId,itemIds);
//查询商品列表,验证商品是否上架成功 //查询商品列表,验证商品是否上架成功
<<<<<<< HEAD
Response response2 =developerObjectService.appItems(appId,title); Response response2 =developerObjectService.appItems(appId,title);
String appItemId = String.valueOf(response2.jsonPath().getString("data.list[0].id")); String appItemId = String.valueOf(response2.jsonPath().getString("data.list[0].id"));
=======
Response response2 =developerBJZ.appItems(appId,itemName);
String appItemId2=response2.jsonPath().getString("data.list[0].id");
>>>>>>> 81f452ba10257ea84d884c525c3e448e7269e7ff
Assert.assertEquals(response2.jsonPath().getString("data.list[0].title"), "测试至尊享版-实物3", "校验实物标题失败"); 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].status"), "1", "校验实物状态失败");
Assert.assertEquals(response2.jsonPath().getString("data.list[0].type"), "object", "校验实物类型失败"); Assert.assertEquals(response2.jsonPath().getString("data.list[0].type"), "object", "校验实物类型失败");
logger.info("校验title,status成功"); logger.info("校验title,status,type成功");
//删除添加的商品 //删除添加的商品
developerObjectService.ajaxDel(appItemId); developerBJZ.ajaxDel(appId,appItemId2);
}
@Test(description = "旗舰版app添加、上架至尊版实物:异常场景,提示不能上架")
public void b_旗舰版添加至尊版实物() throws Exception{
//查询列表,获取ID
Response response =developerBJZ.items("2",appId2);
String id=String.valueOf(response.jsonPath().getString("data.list[0].id"));
//上架
Response response2=developerBJZ.ajaxDirectUp2(appId2,id);
//接口提示,至尊版专享,不能上架
Assert.assertEquals(response2.jsonPath().getString("desc"), "至尊版专享", "校验接口上架失败");
}
@Test(description = "优质好货搜索功能")
public void c_实物搜索() throws Exception{
// 根据具体的名称搜索出实物
developerBJZ.items2("2",appId);
// 输入精确的名称查询不到此实物
developerBJZ.items3("2",appId);
} }
//添加、上架优惠券
@Test
public void b_添加至尊版优惠券() throws Exception{
@Test(description = "//添加、上架优惠券")
public void d_添加至尊版优惠券() throws Exception{
//查询列表,获取ID //查询列表,获取ID
Response response =developerBJZ.coupons(appId,"2"); Response response =developerBJZ.coupons(appId,"2");
String id= String.valueOf(response.jsonPath().getString("data.list[0].id")); String itemId= String.valueOf(response.jsonPath().getString("data.list[0].id"));
String title= String.valueOf(response.jsonPath().getString("data.list[0].title")); String itemIds= String.valueOf(response.jsonPath().getString("data.list[0].id"));
String itemName= String.valueOf(response.jsonPath().getString("data.list[0].title"));
//添加 //添加
developerBJZ.ajaxAddRepo(appId,id); developerBJZ.ajaxAddRepo(appId,itemId);
//上架 //上架
developerBJZ.ajaxDirectUp(appId,id); developerBJZ.ajaxDirectUp(appId,itemIds);
//查询商品列表,验证商品是否上架成功 //查询商品列表,验证商品是否上架成功
Response response2 =developerObjectService.appItems(appId,title); Response response2 =developerBJZ.appItems(appId,itemName);
String appItemId = String.valueOf(response2.jsonPath().getString("data.list[0].id")); String appItemId2 = 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].title"), "测试至尊享版-优惠券", "校验优惠券标题名称失败");
Assert.assertEquals(response2.jsonPath().getString("data.list[0].status"), "1", "校验优惠券状态失败"); Assert.assertEquals(response2.jsonPath().getString("data.list[0].status"), "1", "校验优惠券状态失败");
Assert.assertEquals(response2.jsonPath().getString("data.list[0].type"), "coupon", "校验优惠券类型失败"); Assert.assertEquals(response2.jsonPath().getString("data.list[0].type"), "coupon", "校验优惠券类型失败");
logger.info("校验title,status成功"); logger.info("校验title,status,type成功");
//删除添加的商品 //删除添加的优惠券
developerObjectService.ajaxDel(appItemId); developerBJZ.ajaxDel(appId,appItemId2);
}
@Test(description = "//旗舰版app添加、上架至尊版优惠券:异常场景,提示不能上架")
public void e_旗舰版添加至尊版优惠券() throws Exception{
//查询列表,获取ID
Response response =developerBJZ.coupons(appId2,"2");
String id= String.valueOf(response.jsonPath().getString("data.list[0].id"));
//上架
Response response2=developerBJZ.ajaxDirectUp2(appId2,id);
//接口提示,至尊版专享,不能上架
Assert.assertEquals(response2.jsonPath().getString("desc"), "至尊版专享", "校验接口上架失败");
}
@Test(description = "//添加直冲类")
public void f_添加直冲类() throws Exception{
Response response= developerBJZ.directCharges(appId);
String itemId=String.valueOf(response.jsonPath().getString("data.list[1].id"));
String itemName=String.valueOf(response.jsonPath().getString("data.list[1].title"));
//添加直冲类
developerBJZ.ajaxAddRepo(appId,itemId);
//查询商品列表,验证商品是否添加成功
Response response2 =developerBJZ.appItems(appId,itemName);
String appItemId2 = String.valueOf(response2.jsonPath().getString("data.list[0].id"));
Assert.assertEquals(response2.jsonPath().getString("data.list[0].title"), "Q币充值", "校验标题名称失败");
Assert.assertEquals(response2.jsonPath().getString("data.list[0].status"), "0", "校验状态失败");
Assert.assertEquals(response2.jsonPath().getString("data.list[0].type"), "qb", "校验类型失败");
logger.info("校验title,status,type成功");
//删除添加的直冲类
developerBJZ.ajaxDel(appId,appItemId2);
} }
//添加活动 //添加活动
@Test @Test(description = "//添加活动")
public void c_添加活动() throws Exception{ public void g_添加活动() throws Exception{
//查询热门活动-活动列表,获取商品ID //查询热门活动-活动列表,获取商品ID
Response response=developerBJZ.saasActivitys("3"); Response response=developerBJZ.saasActivitys("3",appId);
String goodItemId= String.valueOf(response.jsonPath().getString("data.saasActivitys[0].id")); String goodItemId= String.valueOf(response.jsonPath().getString("data.saasActivitys[0].id"));
//获取商品ID,进入商品订购页面,获取SKU //获取商品ID,进入商品订购页面,获取SKU
Response response2=developerBJZ.itemOrderDetail(goodItemId); Response response2=developerBJZ.itemOrderDetail(goodItemId,appId);
String skuId= String.valueOf(response2.jsonPath().getString("data.goodsItemSku[0].skuId"));
//点击订购,传入SKU创建订单
logger.info("kuid==="+skuId);
Response response3=developerBJZ.createAutomationOrderNew(skuId,appId);
String orderid= String.valueOf(response3.jsonPath().getString("data"));
logger.info("kuid==="+orderid);
//下单购买
developerBJZ.orderAccountPay(orderid,appId);
//查询是否购买成功
Response response4=developerBJZ.findOrderById(orderid,appId);
Assert.assertEquals(response4.jsonPath().getString("data.vo.funcName"), "自动化测试活动--勿动", "校验名称失败");
Assert.assertEquals(response4.jsonPath().getString("data.vo.limitTime"), "一年", "校验购买期限失败");
logger.info("校验名称,期限成功");
}
@Test(description = "//添加签到活动")
public void h_添加签到活动() throws Exception{
//查询热门活动-活动列表,获取商品ID
Response response=developerBJZ.saasActivitys("2",appId);
String goodItemId= String.valueOf(response.jsonPath().getString("data.saasActivitys[1].id"));
//获取商品ID,进入商品订购页面,获取SKU
Response response2=developerBJZ.itemOrderDetail(goodItemId,appId);
String skuId= String.valueOf(response2.jsonPath().getString("data.goodsItemSku[0].skuId")); String skuId= String.valueOf(response2.jsonPath().getString("data.goodsItemSku[0].skuId"));
//点击订购,传入SKU创建订单 //点击订购,传入SKU创建订单
logger.info("kuid==="+skuId); logger.info("kuid==="+skuId);
Response response3=developerBJZ.createAutomationOrderNew(skuId); Response response3=developerBJZ.createAutomationOrderNew(skuId,appId);
String orderid= String.valueOf(response3.jsonPath().getString("data")); String orderid= String.valueOf(response3.jsonPath().getString("data"));
logger.info("kuid==="+orderid); logger.info("kuid==="+orderid);
//下单购买 //下单购买
Response response4=developerBJZ.orderAccountPay(orderid); developerBJZ.orderAccountPay(orderid,appId);
//查询是否购买成功
Response response4=developerBJZ.findOrderById(orderid,appId);
Assert.assertEquals(response4.jsonPath().getString("data.vo.funcName"), "SaaS签到", "校验名称失败");
logger.info("校验名称成功");
} }
} }
...@@ -32,7 +32,7 @@ public class 设置_应用信息_DuibaTest extends AbstractTestNGSpringContextTe ...@@ -32,7 +32,7 @@ public class 设置_应用信息_DuibaTest extends AbstractTestNGSpringContextTe
updateAppInfoService.UpdateAppInfo(appId,unitName,earnCreditsUrl,creditsDetailUrl,isDecimalOpen); updateAppInfoService.UpdateAppInfo(appId,unitName,earnCreditsUrl,creditsDetailUrl,isDecimalOpen);
Response response2= updateAppInfoService.appInfo(appId); Response response2= updateAppInfoService.appInfo(appId);
Assert.assertEquals(response2.jsonPath().getString("data.name"), "(saas)接口自动化应用", "校验应用名称失败"); Assert.assertEquals(response2.jsonPath().getString("data.name"), "(saas自动化)至尊版", "校验应用名称失败");
Assert.assertEquals(response2.jsonPath().getString("data.earnCreditsLetter"), "积分文案&2", "校验积分文案失败"); Assert.assertEquals(response2.jsonPath().getString("data.earnCreditsLetter"), "积分文案&2", "校验积分文案失败");
Assert.assertEquals(response2.jsonPath().getString("data.creditsDetailUrl"), "https://www.baidu.com/s?ie=utf-8&f=8&rsv_bp=1&tn=baidu&wd=www.baidu.com", "校验积分明细链接失败"); Assert.assertEquals(response2.jsonPath().getString("data.creditsDetailUrl"), "https://www.baidu.com/s?ie=utf-8&f=8&rsv_bp=1&tn=baidu&wd=www.baidu.com", "校验积分明细链接失败");
logger.info("保存应用信息成功"); logger.info("保存应用信息成功");
......
...@@ -249,6 +249,7 @@ public class Authorization { ...@@ -249,6 +249,7 @@ public class Authorization {
public Map hdLoginSaas(String appId){ public Map hdLoginSaas(String appId){
int i=10; int i=10;
logger.info("hdCookiesSaasByApp cookies:"+hdCookiesSaasByApp.toString());
Map<String,String> hdCookies = hdCookiesSaasByApp.get(appId); Map<String,String> hdCookies = hdCookiesSaasByApp.get(appId);
while((hdCookies==null||hdCookies.size()==0)&&i>0) { while((hdCookies==null||hdCookies.size()==0)&&i>0) {
Response token=this.hdGetToken(); Response token=this.hdGetToken();
...@@ -260,16 +261,21 @@ public class Authorization { ...@@ -260,16 +261,21 @@ public class Authorization {
paras.put("redirect", "/redirectApp"); paras.put("redirect", "/redirectApp");
paras.put("isAutoLogin", "true"); paras.put("isAutoLogin", "true");
Response response = given().cookies(cookies).params(paras).post(url); Response response = given().cookies(cookies).params(paras).post(url);
Map<String,String> map = response.getCookies();
logger.info("cookies:"+map.toString());
hdCookies=new HashMap<>(response.getCookies()); hdCookies=new HashMap<>(response.getCookies());
if(hdCookies!=null||hdCookies.size()!=0) {
//取消安全校验 //取消安全校验
hdCookies.remove("csrf_token"); hdCookies.remove("csrf_token");
hdCookies.put("appId",appId); hdCookies.put("appId", appId);
hdCookies.put("duibaAppId",appId); hdCookies.put("duibaAppId", appId);
logger.info("cookies2:"+hdCookies.toString());
hdCookiesSaasByApp.put(appId,hdCookies); hdCookiesSaasByApp.put(appId,hdCookies);
}
i--; i--;
} }
return hdCookies; return hdCookies;
} }
//密码为duibaduiba123 //密码为duibaduiba123
...@@ -287,7 +293,7 @@ public class Authorization { ...@@ -287,7 +293,7 @@ public class Authorization {
paras.put("isAutoLogin", "true"); paras.put("isAutoLogin", "true");
Response response = given().cookies(cookies).params(paras).post(url); Response response = given().cookies(cookies).params(paras).post(url);
hdCookies=new HashMap<>(response.getCookies()); hdCookies=new HashMap<>(response.getCookies());
if(hdCookies==null||hdCookies.size()==0){ if(hdCookies!=null||hdCookies.size()!=0){
hdCookies.remove("csrf_token"); hdCookies.remove("csrf_token");
hdCookiesCommon.put(email,hdCookies); hdCookiesCommon.put(email,hdCookies);
} }
...@@ -317,7 +323,7 @@ public class Authorization { ...@@ -317,7 +323,7 @@ public class Authorization {
Response response = given().cookies(cookies).params(paras).post(url); Response response = given().cookies(cookies).params(paras).post(url);
response.prettyPrint(); response.prettyPrint();
hdCookies=new HashMap<>(response.getCookies()); hdCookies=new HashMap<>(response.getCookies());
if(hdCookies==null||hdCookies.size()==0){ if(hdCookies!=null||hdCookies.size()!=0){
hdCookies.remove("csrf_token"); hdCookies.remove("csrf_token");
hdCookiesCommon.put(account,hdCookies); hdCookiesCommon.put(account,hdCookies);
} }
......
...@@ -27,156 +27,309 @@ public class DeveloperBJZ { ...@@ -27,156 +27,309 @@ public class DeveloperBJZ {
Authorization authorization; Authorization authorization;
private DuibaLog logger = DuibaLog.getLogger(); private DuibaLog logger = DuibaLog.getLogger();
//优质好货--查询至尊版特权TAB //优质好货--查询至尊版特权TAB
public Response item(String type) throws Exception{ public Response items(String type,String appId) throws Exception {
String url="http://"+hdHost+"/saasitem/items"; String url = "http://" + hdHost + "/saasitem/items";
Map<String,String> map = new HashMap<>(); Map<String,String> map = new HashMap<>();
map.put("type",type); map.put("type",type);
map.put("rowId","1"); map.put("rowId","1");
map.put("itemName",""); map.put("itemName","");
map.put("max","20"); map.put("max","20");
// logger.info("********"+url); Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas(appId)).params(map).get(url);
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas()).params(map).get(url); response.prettyPrint();
// response.prettyPrint(); try {
try{ Assert.assertEquals(response.jsonPath().getString("desc"), "成功");
Assert.assertEquals(response.jsonPath().getString("desc"),"成功"); } catch (Exception e) {
}catch(Exception e){ throw new Exception("创建接口1失败,返回信息:" + response.asString());
throw new Exception("创建接口1失败,返回信息:"+response.asString()); } catch (Error er) {
}catch(Error er){ throw new Exception("创建接口2失败,返回信息:" + response.asString());
throw new Exception("创建接口2失败,返回信息:"+response.asString());
} }
return response; return response;
} }
//至尊特权添加商品 //搜索具体的实物
public Response ajaxAddRepo(String appId,String itemId) throws Exception{ public Response items2(String type, String appId) throws Exception {
String url="http://"+hdHost+"/devRepo/ajaxAddRepo"; String url = "http://" + hdHost + "/saasitem/items";
Map<String,String> map = new HashMap<>(); Map<String,String> map = new HashMap<>();
map.put("type",type);
map.put("rowId","1");
map.put("itemName","测试至尊享版-实物3");
map.put("max","20");
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas(appId)).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 items3(String type,String appId) 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","测试至尊享版-实物31");
map.put("max","20");
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas(appId)).params(map).get(url);
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("appId",appId);
map.put("itemId",itemId); map.put("itemId",itemId);
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas()).params(map).post(url); Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas(appId)).params(map).post(url);
// response.prettyPrint(); // response.prettyPrint();
try{ try {
Assert.assertEquals(response.jsonPath().getString("desc"),"成功"); Assert.assertEquals(response.jsonPath().getString("desc"), "成功");
}catch(Exception e){ } catch (Exception e) {
throw new Exception("创建接口1失败,返回信息:"+response.asString()); throw new Exception("创建接口1失败,返回信息:" + response.asString());
}catch(Error er){ } catch (Error er) {
throw new Exception("创建接口2失败,返回信息:"+response.asString()); throw new Exception("创建接口2失败,返回信息:" + response.asString());
} }
return response; return response;
} }
//至尊特权上架商品 //至尊特权上架商品
public Response ajaxDirectUp(String appId,String itemIds) throws Exception{ public Response ajaxDirectUp(String appId, String itemIds) throws Exception {
String url="http://"+hdHost+"/devRepo/ajaxDirectUp"; String url = "http://" + hdHost + "/devRepo/ajaxDirectUp";
Map<String,String> map = new HashMap<>(); Map<String, String> map = new HashMap<>();
map.put("appId",appId); map.put("appId",appId);
map.put("itemIds",itemIds); map.put("itemIds",itemIds);
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas()).params(map).post(url); Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas(appId)).params(map).post(url);
response.prettyPrint(); response.prettyPrint();
try{ try {
Assert.assertEquals(response.jsonPath().getString("desc"),"直接上架成功"); Assert.assertEquals(response.jsonPath().getString("desc"), "直接上架成功");
}catch(Exception e){ } catch (Exception e) {
throw new Exception("创建接口1失败,返回信息:"+response.asString()); throw new Exception("创建接口1失败,返回信息:" + response.asString());
}catch(Error er){ } catch (Error er) {
throw new Exception("创建接口2失败,返回信息:"+response.asString()); throw new Exception("创建接口2失败,返回信息:" + response.asString());
} }
return response; return response;
} }
//大牌好券--查询至尊版特权TAB //旗舰版app上架:至尊特权商品
public Response coupons(String appId,String type) throws Exception{ public Response ajaxDirectUp2(String appId2, String itemIds) throws Exception {
String url="http://"+hdHost+"/saasitem/coupons"; String url = "http://" + hdHost + "/devRepo/ajaxDirectUp";
Map<String,String> map = new HashMap<>(); Map<String,String> map = new HashMap<>();
map.put("appId",appId2);
map.put("itemIds", itemIds);
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas(appId2)).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("appId",appId);
map.put("type",type); map.put("type",type);
map.put("rowId","1"); map.put("rowId","1");
map.put("subType",""); map.put("subType","");
map.put("max","12"); map.put("max","12");
// logger.info("********"+url); Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas(appId)).params(map).get(url);response.prettyPrint();
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas()).params(map).get(url); try {
// response.prettyPrint(); Assert.assertEquals(response.jsonPath().getString("desc"), "成功");
try{ } catch (Exception e) {
Assert.assertEquals(response.jsonPath().getString("desc"),"成功"); throw new Exception("创建接口1失败,返回信息:" + response.asString());
}catch(Exception e){ } catch (Error er) {
throw new Exception("创建接口1失败,返回信息:"+response.asString()); throw new Exception("创建接口2失败,返回信息:" + response.asString());
}catch(Error er){
throw new Exception("创建接口2失败,返回信息:"+response.asString());
} }
return response; return response;
} }
//热门活动--查询活动 //热门活动--查询活动
public Response saasActivitys(String categoryId) throws Exception{ public Response saasActivitys(String categoryId, String appId) throws Exception {
String url="http://"+hdHost+"/saasitem/saasActivitys"; String url = "http://" + hdHost + "/saasitem/saasActivitys";
Map<String,Object> map = new HashMap<>(); Map<String,Object> map = new HashMap<>();
map.put("attrIds",""); map.put("attrIds","");
map.put("rowId","1"); map.put("rowId","1");
map.put("max","25"); map.put("max","25");
map.put("categoryId",categoryId); map.put("categoryId",categoryId);
logger.info("********"+url); logger.info("********" + url);
//json 格式转成form表单 //json 格式转成form表单
JSONObject jsonParam = JSONObject.parseObject(JSON.toJSONString(map)); 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 response = given().contentType("application/json;charset=UTF-8").cookies(authorization.hdLoginSaas(appId)).body(jsonParam).post(url);
// response.prettyPrint();
try{ try {
Assert.assertEquals(response.jsonPath().getString("desc"),"成功"); Assert.assertEquals(response.jsonPath().getString("desc"), "成功");
}catch(Exception e){ } catch (Exception e) {
throw new Exception("创建接口1失败,返回信息:"+response.asString()); throw new Exception("创建接口1失败,返回信息:" + response.asString());
}catch(Error er){ } catch (Error er) {
throw new Exception("创建接口2失败,返回信息:"+response.asString()); throw new Exception("创建接口2失败,返回信息:" + response.asString());
} }
return response; return response;
} }
//选中活动 //选中活动
public Response itemOrderDetail(String goodItemId) throws Exception{ public Response itemOrderDetail(String goodItemId, String appId) throws Exception {
String url="http://"+hdHost+"/saasitem/itemOrderDetail"; String url = "http://" + hdHost + "/saasitem/itemOrderDetail";
Map<String,String> map = new HashMap<>(); Map<String, String> map = new HashMap<>();
map.put("goodItemId",goodItemId); map.put("goodItemId", goodItemId);
// logger.info("********"+url); // logger.info("********"+url);
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas()).params(map).get(url); Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas(appId)).params(map).get(url);
// response.prettyPrint(); // response.prettyPrint();
try{ try {
Assert.assertEquals(response.jsonPath().getString("desc"),"成功"); Assert.assertEquals(response.jsonPath().getString("desc"), "成功");
}catch(Exception e){ } catch (Exception e) {
throw new Exception("创建接口1失败,返回信息:"+response.asString()); throw new Exception("创建接口1失败,返回信息:" + response.asString());
}catch(Error er){ } catch (Error er) {
throw new Exception("创建接口2失败,返回信息:"+response.asString()); throw new Exception("创建接口2失败,返回信息:" + response.asString());
} }
return response; return response;
} }
//订购活动--创建订单 //订购活动--创建订单
public Response createAutomationOrderNew(String skuId) throws Exception{ public Response createAutomationOrderNew(String skuId, String appId) throws Exception {
String url="http://"+hdHost+"/saas/createAutomationOrderNew"; String url = "http://" + hdHost + "/saas/createAutomationOrderNew";
Map<String,String> map = new HashMap<>(); Map<String, String> map = new HashMap<>();
map.put("skuId",skuId); map.put("skuId", skuId);
// logger.info("********"+url); // logger.info("********"+url);
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas("19515")).params(map).post(url); Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas(appId)).params(map).post(url);
// response.prettyPrint(); // response.prettyPrint();
try{ try {
Assert.assertEquals(response.jsonPath().getString("desc"),"成功"); Assert.assertEquals(response.jsonPath().getString("desc"), "成功");
}catch(Exception e){ } catch (Exception e) {
throw new Exception("创建接口1失败,返回信息:"+response.asString()); throw new Exception("创建接口1失败,返回信息:" + response.asString());
}catch(Error er){ } catch (Error er) {
throw new Exception("创建接口2失败,返回信息:"+response.asString()); throw new Exception("创建接口2失败,返回信息:" + response.asString());
} }
return response; return response;
} }
//订购--账户余额付款 //订购--账户余额付款
public Response orderAccountPay(String orderId) throws Exception{ public Response orderAccountPay(String orderId, String appId) throws Exception {
String url="http://"+hdHost+"/saas/orderAccountPay"; String url = "http://" + hdHost + "/saas/orderAccountPay";
Map<String,String> map = new HashMap<>(); Map<String, String> map = new HashMap<>();
map.put("orderId",orderId); map.put("orderId",orderId);
// logger.info("********"+url); Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas(appId)).params(map).get(url);response.prettyPrint();
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas()).params(map).get(url); try {
// response.prettyPrint(); Assert.assertEquals(response.jsonPath().getString("desc"), "成功");
try{ } catch (Exception e) {
Assert.assertEquals(response.jsonPath().getString("desc"),"成功"); throw new Exception("创建接口1失败,返回信息:" + response.asString());
}catch(Exception e){ } catch (Error er) {
throw new Exception("创建接口1失败,返回信息:"+response.asString()); throw new Exception("创建接口2失败,返回信息:" + response.asString());
}catch(Error er){ }
throw new Exception("创建接口2失败,返回信息:"+response.asString()); return response;
}
//查询购买的活动订单信息
public Response findOrderById(String orderId, String appId) throws Exception {
String url = "http://" + hdHost + "/saas/findOrderById";
Map<String, String> map = new HashMap<>();
map.put("orderId",orderId);
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas(appId)).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 selectOrders(String appId) throws Exception {
String url = "http://" + hdHost + "/saas/selectOrders";
Map<String, String> map = new HashMap<>();
map.put("orderStatus","2");
map.put("appId",appId);
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas(appId)).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 directCharges(String appId) throws Exception {
String url = "http://" + hdHost + "/saasitem/directCharges";
Map<String, String> map = new HashMap<>();
map.put("rowId","1");
map.put("max","20");
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas(appId)).params(map).get(url);
response.prettyPrint();
try {
Assert.assertEquals(response.jsonPath().getString("desc"), "成功");
} catch (Exception e) {
throw new Exception("查询直冲类商品失败,返回信息:" + response.asString());
} catch (Error er) {
throw new Exception("查询直冲类商品失败,返回信息:" + response.asString());
}
return response;
}
//查询商品管理——商品
public Response appItems(String appId, String itemName) throws Exception {
String url = "http://" + hdHost + "/devItem/appItems";
Map<String,String> map = new HashMap<>();
map.put("rowId", "1");
map.put("itemType", "");
map.put("belong", "");
map.put("status", "");
map.put("priceType", "");
map.put("itemName",itemName);
map.put("appId",appId);
map.put("classifyId", "");
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas(appId)).params(map).post(url);
response.prettyPrint();
try {
Assert.assertEquals(response.jsonPath().getString("desc"), "成功");
} catch (Exception e) {
throw new Exception("查询商品管理——商品失败,返回信息:" + response.asString());
} catch (Error er) {
throw new Exception("查询商品管理——商品失败,返回信息:" + response.asString());
}
return response;
}
//删除实物
public Response ajaxDel(String appId,String appItemId) throws Exception {
String url = "http://" + hdHost + "/devItem/ajaxDel";
Map<String, String> map = new HashMap<>();
map.put("appId",appId);
map.put("appItemId",appItemId);
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas(appId)).params(map).post(url);
response.prettyPrint();
try {
Assert.assertEquals(response.jsonPath().getString("desc"), "成功");
} catch (Exception e) {
throw new Exception("删除商品接口接口失败,返回信息:" + response.asString());
} catch (Error er) {
throw new Exception("删除商品接口接口失败,返回信息:" + response.asString());
} }
return response; 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