Commit 8e25c0e0 authored by 吕雯燕's avatar 吕雯燕

Merge branch 'duiba_wenyan'

parents 4508ecf9 8a426bac
package http.cases.VisualEditorTest;
import base.Config;
import base.DuibaLog;
import base.DuibaTestBase;
import http.cases.ExchangeTest.Database;
import http.service.hd.DevItemNewService;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.testng.Assert;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import utils.PublicMethod;
import java.lang.reflect.Method;
import java.util.Map;
import http.service.Authorization;
/**
* created by lvwenyan 2019/4/17
*/
public class 商品分组组件_DuibaTest extends DuibaTestBase {
@Autowired
DevItemNewService devItemNewService;
@Autowired
Authorization authorization;
@DataProvider
public Object[][] providerMethod(Method method) {
Object[][] result = null;
if (method.getName().equals("后台商品分组组件新商品展示")) {
result = new Object[][]{
new Object[]{1, "2102", "22561", "商品分组-兑吧新商品"}, //case1
new Object[]{2, "2104", "22561", "商品分组-自有新商品"}, //case2
};
}
if (method.getName().equals("后台商品分组组件老商品展示")) {
result = new Object[][]{
new Object[]{1, "2124", "22542", "商品分组-兑吧老商品"}, //case1
new Object[]{2, "2125", "22542", "商品分组-自有老商品"}, //case2
};
}
return result;
}
/**
* @param caseNum 用例编号
* @param classifyId 商品分组Id
* @param appId appId
* @param caseName 用例名称打印
* @throws Exception
*/
@Test(dataProvider = "providerMethod")
public void 后台商品分组组件新商品展示(int caseNum, String classifyId, String appId, String caseName) throws Exception{
logger.info("---" + caseName + "---");
Map cookies = authorization.hdLoginCommonNew("15855555555");
Response response = devItemNewService.appItems(cookies,classifyId,appId);
response.prettyPrint();
switch (caseNum){
case 1:
Assert.assertEquals(response.jsonPath().getString("data.rows[0].title"),"10元话费","校验第一个商品title失败");
Assert.assertEquals(response.jsonPath().getString("data.rows[0].customCredits"),"1000","校验第一个商品credits失败");
Assert.assertEquals(response.jsonPath().getString("data.rows[1].title"),"支付宝充值","校验第二个商品title失败");
Assert.assertEquals(response.jsonPath().getString("data.rows[1].customCredits"),"100000","校验第二个商品credits失败");
Assert.assertEquals(response.jsonPath().getString("data.rows[2].title"),"【自动化勿动】兑吧新实物","校验第三个商品title失败");
Assert.assertEquals(response.jsonPath().getString("data.rows[2].customCredits"),"300","校验第三个商品credits失败");
Assert.assertEquals(response.jsonPath().getString("data.rows[3].title"),"【自动化勿动】兑吧卡密跳转按钮","校验第四个商品title失败");
Assert.assertEquals(response.jsonPath().getString("data.rows[3].customCredits"),"200","校验第四个商品credits失败");
Assert.assertEquals(response.jsonPath().getString("data.rows[4].title"),"【自动化勿动】兑吧新优惠券普通券码跳转","校验第五个商品title失败");
Assert.assertEquals(response.jsonPath().getString("data.rows[4].customCredits"),"100","校验第五个商品credits失败");
logger.info("校验商品分组1-兑吧商品成功");
break;
case 2:
Assert.assertEquals(response.jsonPath().getString("data.rows[0].title"),"【自动化勿动】自有卡密","校验第一个商品title失败");
Assert.assertEquals(response.jsonPath().getString("data.rows[0].customCredits"),"550","校验第一个商品credits失败");
Assert.assertEquals(response.jsonPath().getString("data.rows[1].title"),"【自动化勿动】自有充值商品","校验第二个商品title失败");
Assert.assertEquals(response.jsonPath().getString("data.rows[1].customCredits"),"300","校验第二个商品credits失败");
Assert.assertEquals(response.jsonPath().getString("data.rows[2].title"),"【自动化勿动】自有新实物加钱购","校验第三个商品title失败");
Assert.assertEquals(response.jsonPath().getString("data.rows[2].customCredits"),"150","校验第三个商品credits失败");
Assert.assertEquals(response.jsonPath().getString("data.rows[3].title"),"【自动化勿动】自有新优惠券跳转链接","校验第四个商品title失败");
Assert.assertEquals(response.jsonPath().getString("data.rows[3].customCredits"),"100","校验第四个商品credits失败");
logger.info("校验商品分组2-自有商品成功");
break;
}
}
/**
* @param caseNum 用例编号
* @param classifyId 商品分组Id
* @param appId appId
* @param caseName 用例名称打印
* @throws Exception
*/
@Test(dataProvider = "providerMethod")
public void 后台商品分组组件老商品展示(int caseNum, String classifyId, String appId, String caseName) throws Exception{
logger.info("---" + caseName + "---");
Map cookies = authorization.hdLoginCommonNew("15833333333");
Response response = devItemNewService.appItems(cookies,classifyId,appId);
response.prettyPrint();
switch (caseNum){
case 1:
Assert.assertEquals(response.jsonPath().getString("data.rows[0].title"),"【勿动】兑吧优惠券共享库存测试","校验第一个商品title失败");
Assert.assertEquals(response.jsonPath().getString("data.rows[0].customCredits"),"20","校验第一个商品credits失败");
Assert.assertEquals(response.jsonPath().getString("data.rows[1].title"),"【自动化勿动】兑吧实物日期兑换限制进行中","校验第二个商品title失败");
Assert.assertEquals(response.jsonPath().getString("data.rows[1].customCredits"),"100","校验第二个商品credits失败");
Assert.assertEquals(response.jsonPath().getString("data.rows[2].title"),"5元话费","校验第三个商品title失败");
Assert.assertEquals(response.jsonPath().getString("data.rows[2].customCredits"),"500","校验第三个商品credits失败");
Assert.assertEquals(response.jsonPath().getString("data.rows[3].title"),"支付宝充值","校验第四个商品title失败");
Assert.assertEquals(response.jsonPath().getString("data.rows[3].customCredits"),"1000","校验第四个商品credits失败");
logger.info("校验商品分组1-兑吧商品成功");
break;
case 2:
Assert.assertEquals(response.jsonPath().getString("data.rows[0].title"),"【自动化勿动】自有虚拟商品","校验第一个商品title失败");
Assert.assertEquals(response.jsonPath().getString("data.rows[0].customCredits"),"1000","校验第一个商品credits失败");
Assert.assertEquals(response.jsonPath().getString("data.rows[1].title"),"【自动化勿动】自有实物","校验第二个商品title失败");
Assert.assertEquals(response.jsonPath().getString("data.rows[1].customCredits"),"200","校验第二个商品credits失败");
Assert.assertEquals(response.jsonPath().getString("data.rows[2].title"),"【自动化勿动】自有优惠券","校验第三个商品title失败");
Assert.assertEquals(response.jsonPath().getString("data.rows[2].customCredits"),"100","校验第三个商品credits失败");
logger.info("校验商品分组2-自有商品成功");
break;
}
}
}
......@@ -384,7 +384,7 @@ public class Authorization {
paras.put("isAutoLogin", "true");
paras.put("validate","22");
Response response = given().cookies(cookies).params(paras).post(url);
response.prettyPrint();
// response.prettyPrint();
hdCookies=new HashMap<>(response.getCookies());
if(hdCookies!=null&&hdCookies.size()!=0){
hdCookies.remove("csrf_token");
......
......@@ -98,6 +98,33 @@ public class DevItemNewService {
}
//商品分组组件
public Response appItems(Map cookies, String classifyId, String appId) throws Exception{
String url = hdserverHost + "/devItemNew/appItems";
Map<String,String> map = new HashMap<>();
map.put("classifyId",classifyId);
map.put("status","on");
map.put("pageSize","100");
map.put("appId",appId);
map.put("pageNo","1");
logger.info("请求商品分组组件接口:"+ "/devItemNew/appItems");
Response response = given().contentType("application/json;charset=UTF-8").cookies(cookies).params(map).get("http://" + url);
try{
Assert.assertEquals(response.jsonPath().getString("success"),"true");
}catch(Exception e){
throw new Exception("/devItemNew/appItems接口返回异常,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/devItemNew/appItems接口返回异常,返回信息:"+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