Commit 497bbc74 authored by wangxiaoshuang's avatar wangxiaoshuang

wxs

parent 7b169114
package http.cases.GoodsAndTradeTest;
import base.Config;
import base.DuibaLog;
import base.DuibaTestBase;
import http.service.goods.DuibaDoUpdateCoupon;
import http.service.goods.DuibaList;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.testng.Assert;
import utils.PublicMethod;
@ContextConfiguration(classes = Config.class)
public class 供应商优惠券 extends DuibaTestBase {
@Autowired
DuibaDoUpdateCoupon duibaDoUpdateCoupon;
@Autowired
DuibaList duibaList;
private DuibaLog logger = DuibaLog.getLogger();
private static String data;
private static String itemId;
//新增链接券
public void 供应商链接券() throws Exception{
data = PublicMethod.data();
String name="[自动化]供应商链接券"+data;
//添加优惠券接口
duibaDoUpdateCoupon.doUpdateCouponLianjie(name);
//查询列表,验证是否添加成功
Response response =duibaList.listIndex("admin",name);
//获取商品ID
itemId = String.valueOf(response.jsonPath().getString("data.page.rows[0].itemDto.id"));
//校验数据
Assert.assertEquals(response.jsonPath().getString("data.page.rows[0].itemDto.name"), "【自动化】供应商链接券"+data, "校验优惠券name失败");
Assert.assertEquals(response.jsonPath().getString("data.page.rows[0].itemDto.type"), "coupon", "校验优惠券类型失败");
Assert.assertEquals(response.jsonPath().getString("data.page.rows[0].itemDto.remaining"), "100", "校验优惠券库存失败");
Assert.assertEquals(response.jsonPath().getString("data.page.rows[0].itemDto.version"), "1", "校验优惠券版本(新版本展示1,旧版本0失败)");
Assert.assertEquals(response.jsonPath().getString("data.page.rows[0].itemDto.actualPrice"), "10000", "校验优惠券供货价失败");
Assert.assertEquals(response.jsonPath().getString("data.page.rows[0].itemDto.facePrice"), "11000", "校验优惠券版本建议零售价失败");
logger.info("校验title,belong成功");
}
//新增重复券
public void 供应商重复券() throws Exception{
data = PublicMethod.data();
String name="[自动化]供应商重复券"+data;
//添加优惠券接口
duibaDoUpdateCoupon.doUpdateCouponChongfu(name);
//查询列表,验证是否添加成功
Response response =duibaList.listIndex("admin",name);
//获取商品ID
itemId = String.valueOf(response.jsonPath().getString("data.page.rows[0].itemDto.id"));
//校验数据
Assert.assertEquals(response.jsonPath().getString("data.page.rows[0].itemDto.name"), "【自动化】供应商重复券"+data, "校验优惠券name失败");
Assert.assertEquals(response.jsonPath().getString("data.page.rows[0].itemDto.type"), "coupon", "校验优惠券类型失败");
Assert.assertEquals(response.jsonPath().getString("data.page.rows[0].itemDto.remaining"), "200", "校验优惠券库存失败");
Assert.assertEquals(response.jsonPath().getString("data.page.rows[0].itemDto.version"), "1", "校验优惠券版本(新版本展示1,旧版本0失败)");
Assert.assertEquals(response.jsonPath().getString("data.page.rows[0].itemDto.actualPrice"), "8800", "校验优惠券供货价失败");
Assert.assertEquals(response.jsonPath().getString("data.page.rows[0].itemDto.facePrice"), "18800", "校验优惠券版本建议零售价失败");
logger.info("校验title,belong成功");
}
//新增重复券
public void 供应商普通券() throws Exception{
data = PublicMethod.data();
String name="[自动化]供应商普通券"+data;
//添加优惠券接口
duibaDoUpdateCoupon.doUpdateCouponChongfu(name);
//查询列表,验证是否添加成功
Response response =duibaList.listIndex("admin",name);
//获取商品ID
itemId = String.valueOf(response.jsonPath().getString("data.page.rows[0].itemDto.id"));
//校验数据
Assert.assertEquals(response.jsonPath().getString("data.page.rows[0].itemDto.name"), "【自动化】供应商普通券"+data, "校验优惠券name失败");
Assert.assertEquals(response.jsonPath().getString("data.page.rows[0].itemDto.type"), "coupon", "校验优惠券类型失败");
Assert.assertEquals(response.jsonPath().getString("data.page.rows[0].itemDto.remaining"), "9", "校验优惠券库存失败");
Assert.assertEquals(response.jsonPath().getString("data.page.rows[0].itemDto.version"), "1", "校验优惠券版本(新版本展示1,旧版本0失败)");
Assert.assertEquals(response.jsonPath().getString("data.page.rows[0].itemDto.actualPrice"), "3600", "校验优惠券供货价失败");
Assert.assertEquals(response.jsonPath().getString("data.page.rows[0].itemDto.facePrice"), "7200", "校验优惠券版本建议零售价失败");
logger.info("校验title,belong成功");
}
//删除链接券
public void 删除链接券() throws Exception{
duibaDoUpdateCoupon.deleteItem(itemId);
}
}
This diff is collapsed.
package http.service.goods;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
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 org.testng.Assert;
import java.util.HashMap;
import java.util.Map;
import static io.restassured.RestAssured.given;
@Service
public class DuibaList {
@Value("${manager.host}")
String ManagerHost;//ManagerHost = mng.duibatest.com.cn
@Autowired
Authorization authorization;
//查询列表
public Response listIndex(String nameType,String name) throws Exception{
String url="http://"+ManagerHost+"/newmanager/goods/item/index";
Map<String,Object> map = new HashMap<>();
map.put("status","");
map.put("itemType","");
map.put("operType","");
map.put("nameType",nameType);//??
map.put("pageSize","20");
map.put("pageNo","1");
map.put("itemClassifyIdObject","");
map.put("itemClassifyIdCoupon","");
map.put("itemName",name);//商品名称
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.ssoLogin()).get(url);
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;
}
}
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