Commit 4de4f50e authored by 赵然's avatar 赵然

Merge branch 'develop' of gitlab2.dui88.com:mabo/test-platform into develop

parents c73bf836 bb911049
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);
}
}
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.
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