Commit 2e16ae71 authored by 胡梦新's avatar 胡梦新

zr

parents 826f229d e759bed8
...@@ -11,170 +11,115 @@ import org.springframework.test.context.testng.AbstractTestNGSpringContextTests; ...@@ -11,170 +11,115 @@ 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 AbstractTestNGSpringContextTests{ public class 补给站_商品 extends AbstractTestNGSpringContextTests {
@Autowired @Autowired
DeveloperBJZ developerBJZ; DeveloperBJZ developerBJZ;
private DuibaLog logger = DuibaLog.getLogger(); private DuibaLog logger = DuibaLog.getLogger();
//至尊版app //至尊版app
String appId="19515"; String appId = "19515";
//旗舰版app //旗舰版app
String appId2="21695"; String appId2 = "21695";
@Test(description = "至尊版app添加、上架至尊版实物") @Test(description = "至尊版app添加、上架至尊版实物")
public void a_添加至尊版实物() throws Exception{ public void a_添加至尊版实物() throws Exception {
//查询列表,获取ID //查询列表,获取ID
Response response =developerBJZ.items("2",appId); Response response = developerBJZ.items("2", appId);
String itemId= String.valueOf(response.jsonPath().getString("data.list[0].id")); String itemId = String.valueOf(response.jsonPath().getString("data.list[0].id"));
String itemIds= String.valueOf(response.jsonPath().getString("data.list[0].id")); String itemIds = String.valueOf(response.jsonPath().getString("data.list[0].id"));
String itemName=String.valueOf(response.jsonPath().getString("data.list[0].title")); String itemName = String.valueOf(response.jsonPath().getString("data.list[0].title"));
//添加 //添加
developerBJZ.ajaxAddRepo(appId,itemId); developerBJZ.ajaxAddRepo(appId, itemId);
//上架 //上架
developerBJZ.ajaxDirectUp(appId,itemIds); developerBJZ.ajaxDirectUp(appId, itemIds);
//查询商品列表,验证商品是否上架成功 //查询商品列表,验证商品是否上架成功
<<<<<<< HEAD Response response2 = developerBJZ.appItems(appId, itemName);
Response response2 =developerObjectService.appItems(appId,title); String appItemId2 = 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,type成功"); logger.info("校验title,status,type成功");
//删除添加的商品 //删除添加的商品
developerBJZ.ajaxDel(appId,appItemId2); developerBJZ.ajaxDel(appId, appItemId2);
} }
@Test(description = "旗舰版app添加、上架至尊版实物:异常场景,提示不能上架") @Test(description = "旗舰版app添加、上架至尊版实物:异常场景,提示不能上架")
public void b_旗舰版添加至尊版实物() throws Exception{ public void b_旗舰版添加至尊版实物() throws Exception {
//查询列表,获取ID //查询列表,获取ID
Response response =developerBJZ.items("2",appId2); Response response = developerBJZ.items("2", appId2);
String id=String.valueOf(response.jsonPath().getString("data.list[0].id")); String id = String.valueOf(response.jsonPath().getString("data.list[0].id"));
//上架 //上架
Response response2=developerBJZ.ajaxDirectUp2(appId2,id); Response response2 = developerBJZ.ajaxDirectUp2(appId2, id);
//接口提示,至尊版专享,不能上架 //接口提示,至尊版专享,不能上架
Assert.assertEquals(response2.jsonPath().getString("desc"), "至尊版专享", "校验接口上架失败"); Assert.assertEquals(response2.jsonPath().getString("desc"), "至尊版专享", "校验接口上架失败");
} }
@Test(description = "优质好货搜索功能") @Test(description = "优质好货搜索功能")
public void c_实物搜索() throws Exception{ public void c_实物搜索() throws Exception {
// 根据具体的名称搜索出实物 // 根据具体的名称搜索出实物
developerBJZ.items2("2",appId); developerBJZ.items2("2", appId);
// 输入精确的名称查询不到此实物 // 输入精确的名称查询不到此实物
developerBJZ.items3("2",appId); developerBJZ.items3("2", appId);
} }
@Test(description = "//添加、上架优惠券") @Test(description = "//添加、上架优惠券")
public void d_添加至尊版优惠券() throws Exception{ public void d_添加至尊版优惠券() throws Exception {
//查询列表,获取ID //查询列表,获取ID
Response response =developerBJZ.coupons(appId,"2"); Response response = developerBJZ.coupons(appId, "2");
String itemId= String.valueOf(response.jsonPath().getString("data.list[0].id")); String itemId = String.valueOf(response.jsonPath().getString("data.list[0].id"));
String itemIds= String.valueOf(response.jsonPath().getString("data.list[0].id")); String itemIds = String.valueOf(response.jsonPath().getString("data.list[0].id"));
String itemName= String.valueOf(response.jsonPath().getString("data.list[0].title")); String itemName = String.valueOf(response.jsonPath().getString("data.list[0].title"));
//添加 //添加
developerBJZ.ajaxAddRepo(appId,itemId); developerBJZ.ajaxAddRepo(appId, itemId);
//上架 //上架
developerBJZ.ajaxDirectUp(appId,itemIds); developerBJZ.ajaxDirectUp(appId, itemIds);
//查询商品列表,验证商品是否上架成功 //查询商品列表,验证商品是否上架成功
Response response2 =developerBJZ.appItems(appId,itemName); Response response2 = developerBJZ.appItems(appId, itemName);
String appItemId2 = 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,type成功"); logger.info("校验title,status,type成功");
//删除添加的优惠券 //删除添加的优惠券
developerBJZ.ajaxDel(appId,appItemId2); developerBJZ.ajaxDel(appId, appItemId2);
} }
@Test(description = "//旗舰版app添加、上架至尊版优惠券:异常场景,提示不能上架") @Test(description = "//旗舰版app添加、上架至尊版优惠券:异常场景,提示不能上架")
public void e_旗舰版添加至尊版优惠券() throws Exception{ public void e_旗舰版添加至尊版优惠券() throws Exception {
//查询列表,获取ID //查询列表,获取ID
Response response =developerBJZ.coupons(appId2,"2"); Response response = developerBJZ.coupons(appId2, "2");
String id= String.valueOf(response.jsonPath().getString("data.list[0].id")); String id = String.valueOf(response.jsonPath().getString("data.list[0].id"));
//上架 //上架
Response response2=developerBJZ.ajaxDirectUp2(appId2,id); Response response2 = developerBJZ.ajaxDirectUp2(appId2, id);
//接口提示,至尊版专享,不能上架 //接口提示,至尊版专享,不能上架
Assert.assertEquals(response2.jsonPath().getString("desc"), "至尊版专享", "校验接口上架失败"); Assert.assertEquals(response2.jsonPath().getString("desc"), "至尊版专享", "校验接口上架失败");
} }
@Test(description = "//添加直冲类") @Test(description = "//添加直冲类")
public void f_添加直冲类() throws Exception{ public void f_添加直冲类() throws Exception {
Response response= developerBJZ.directCharges(appId); Response response = developerBJZ.directCharges(appId);
String itemId=String.valueOf(response.jsonPath().getString("data.list[1].id")); String itemId = String.valueOf(response.jsonPath().getString("data.list[1].id"));
String itemName=String.valueOf(response.jsonPath().getString("data.list[1].title")); String itemName = String.valueOf(response.jsonPath().getString("data.list[1].title"));
//添加直冲类 //添加直冲类
developerBJZ.ajaxAddRepo(appId,itemId); developerBJZ.ajaxAddRepo(appId, itemId);
//查询商品列表,验证商品是否添加成功 //查询商品列表,验证商品是否添加成功
Response response2 =developerBJZ.appItems(appId,itemName); Response response2 = developerBJZ.appItems(appId, itemName);
String appItemId2 = 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"), "Q币充值", "校验标题名称失败"); 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].status"), "0", "校验状态失败");
Assert.assertEquals(response2.jsonPath().getString("data.list[0].type"), "qb", "校验类型失败"); Assert.assertEquals(response2.jsonPath().getString("data.list[0].type"), "qb", "校验类型失败");
logger.info("校验title,status,type成功"); logger.info("校验title,status,type成功");
//删除添加的直冲类 //删除添加的直冲类
developerBJZ.ajaxDel(appId,appItemId2); developerBJZ.ajaxDel(appId, appItemId2);
}
//添加活动
@Test(description = "//添加活动")
public void g_添加活动() throws Exception{
//查询热门活动-活动列表,获取商品ID
Response response=developerBJZ.saasActivitys("3",appId);
String goodItemId= String.valueOf(response.jsonPath().getString("data.saasActivitys[0].id"));
//获取商品ID,进入商品订购页面,获取SKU
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"));
//点击订购,传入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"), "SaaS签到", "校验名称失败");
logger.info("校验名称成功");
} }
} }
\ No newline at end of file
package http.cases.SaasDeveloperTest;
import base.Config;
import http.service.Saas.DeveloperBJZ;
import base.DuibaLog;
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 AbstractTestNGSpringContextTests{
@Autowired
DeveloperBJZ developerBJZ;
private DuibaLog logger = DuibaLog.getLogger();
//至尊版app
String appId="19515";
//旗舰版app
String appId2="21695";
//添加活动
@Test(description = "//添加活动")
public void a_添加活动() throws Exception{
//查询热门活动-活动列表,获取商品ID
Response response=developerBJZ.saasActivitys("3",appId);
String goodItemId= String.valueOf(response.jsonPath().getString("data.saasActivitys[0].id"));
//获取商品ID,进入商品订购页面,获取SKU
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 b_添加签到活动() 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"));
//点击订购,传入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"), "SaaS签到", "校验名称失败");
logger.info("校验名称成功");
}
@Test(description = "付款时有待处理的订单(异常场景)")
public void c_待处理的订单() 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"));
//点击订购,传入SKU创建订单
logger.info("kuid==="+skuId);
developerBJZ.createAutomationOrderNew(skuId,appId);
developerBJZ.createAutomationOrderNew2(skuId,appId);
Assert.assertEquals(developerBJZ.createAutomationOrderNew2(skuId,appId).jsonPath().getString("desc"), "订单未处理", "校验订单待处理成功");
//查询待处理订单
Response response3=developerBJZ.selectOrders("1",appId);
Assert.assertEquals(response3.jsonPath().getString("data.list[0].serviceName"), "SaaS签到", "校验名称失败");
logger.info("查询待处理订单成功");
}
@Test(description="查询交易关闭的订单")
public void d_交易关闭的订单() throws Exception{
//查询待付款订单
Response response=developerBJZ.selectOrders("1",appId);
String orderId=String.valueOf(response.jsonPath().getString("data.list[0].id"));
// 点击取消付款,进入到交易关闭订单
developerBJZ.cancleOrder(orderId,appId);
Response response2=developerBJZ.selectOrders("3",appId);
Assert.assertEquals(response2.jsonPath().getString("data.list[0].serviceName"), "SaaS签到", "校验名称失败");
logger.info("查询交易关闭订单成功");
}
}
...@@ -220,6 +220,21 @@ public class DeveloperBJZ { ...@@ -220,6 +220,21 @@ public class DeveloperBJZ {
return response; return response;
} }
//订购活动--创建订单
public Response createAutomationOrderNew2(String skuId, String appId) throws Exception {
String url = "http://" + hdHost + "/saas/createAutomationOrderNew";
Map<String, String> map = new HashMap<>();
map.put("skuId", skuId);
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas(appId)).params(map).post(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 orderAccountPay(String orderId, String appId) throws Exception { public Response orderAccountPay(String orderId, String appId) throws Exception {
String url = "http://" + hdHost + "/saas/orderAccountPay"; String url = "http://" + hdHost + "/saas/orderAccountPay";
...@@ -254,10 +269,10 @@ public class DeveloperBJZ { ...@@ -254,10 +269,10 @@ public class DeveloperBJZ {
} }
//查看记录是否添加购买成功 //查看记录是否添加购买成功
public Response selectOrders(String appId) throws Exception { public Response selectOrders(String orderStatus, String appId) throws Exception {
String url = "http://" + hdHost + "/saas/selectOrders"; String url = "http://" + hdHost + "/saas/selectOrders";
Map<String, String> map = new HashMap<>(); Map<String, String> map = new HashMap<>();
map.put("orderStatus","2"); map.put("orderStatus",orderStatus);
map.put("appId",appId); 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(); Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas(appId)).params(map).get(url);response.prettyPrint();
try { try {
...@@ -270,6 +285,23 @@ public class DeveloperBJZ { ...@@ -270,6 +285,23 @@ public class DeveloperBJZ {
return response; return response;
} }
//取消付款
public Response cancleOrder(String orderId ,String appId) throws Exception {
String url = "http://" + hdHost + "/saas/cancleOrder";
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).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 directCharges(String appId) throws Exception { public Response directCharges(String appId) throws Exception {
String url = "http://" + hdHost + "/saasitem/directCharges"; String url = "http://" + hdHost + "/saasitem/directCharges";
......
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