Commit 6eeff78a authored by 吕雯燕's avatar 吕雯燕

lv

parent 959a3921
......@@ -4,6 +4,7 @@ import base.DuibaLog;
import base.DuibaTestBase;
import http.cases.ExchangeTest.Database;
import http.service.hd.DevItemNewService;
import http.service.app.ChwVisualEditorService;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
......@@ -28,6 +29,8 @@ public class 商品分组组件_DuibaTest extends DuibaTestBase {
DevItemNewService devItemNewService;
@Autowired
Authorization authorization;
@Autowired
ChwVisualEditorService chwVisualEditorService;
@DataProvider
public Object[][] providerMethod(Method method) {
......@@ -44,6 +47,12 @@ public class 商品分组组件_DuibaTest extends DuibaTestBase {
new Object[]{2, "2125", "22542", "商品分组-自有老商品"}, //case2
};
}
if (method.getName().equals("手机端商品分组组件新商品展示")) {
result = new Object[][]{
new Object[]{1, "2102", "商品分组-兑吧新商品"}, //case1
new Object[]{2, "2104", "商品分组-自有新商品"}, //case2
};
}
return result;
}
......@@ -166,4 +175,67 @@ public class 商品分组组件_DuibaTest extends DuibaTestBase {
}
/**
* @param caseNum 用例编号
* @param classifyId 商品分组Id
* @param caseName 用例名称打印
* @throws Exception
*/
@Test(dataProvider = "providerMethod")
public void 手机端商品分组组件新商品展示(int caseNum, String classifyId, String caseName) throws Exception{
logger.info("---" + caseName + "---");
Map cookies = authorization.dafuwengLogin(7126);
Response response = chwVisualEditorService.itemsList(cookies,classifyId);
response.prettyPrint();
switch (caseNum){
case 1:
//手机端接口排序与前端不一致
Assert.assertEquals(response.jsonPath().getString("data.list[0].title"),"【自动化勿动】兑吧新优惠券普通券码跳转","校验第一个商品title失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].titleDownTxt"),"100积分","校验第一个商品credits失败");
Assert.assertEquals(response.jsonPath().getString("data.list[1].title"),"【自动化勿动】兑吧卡密跳转按钮","校验第二个商品title失败");
Assert.assertEquals(response.jsonPath().getString("data.list[1].titleDownTxt"),"200积分","校验第二个商品credits失败");
Assert.assertEquals(response.jsonPath().getString("data.list[2].title"),"【自动化勿动】兑吧新实物","校验第三个商品title失败");
Assert.assertEquals(response.jsonPath().getString("data.list[2].titleDownTxt"),"300积分","校验第三个商品credits失败");
Assert.assertEquals(response.jsonPath().getString("data.list[3].title"),"支付宝充值","校验第四个商品title失败");
Assert.assertEquals(response.jsonPath().getString("data.list[3].titleDownTxt"),"10万积分","校验第四个商品credits失败");
Assert.assertEquals(response.jsonPath().getString("data.list[4].title"),"10元话费","校验第五个商品title失败");
Assert.assertEquals(response.jsonPath().getString("data.list[4].titleDownTxt"),"1000积分","校验第五个商品credits失败");
logger.info("校验商品分组1-兑吧新商品成功");
break;
case 2:
Assert.assertEquals(response.jsonPath().getString("data.list[0].title"),"【自动化勿动】自有新优惠券跳转链接","校验第一个商品title失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].titleDownTxt"),"100积分","校验第一个商品credits失败");
Assert.assertEquals(response.jsonPath().getString("data.list[1].title"),"【自动化勿动】自有新实物加钱购","校验第二个商品title失败");
Assert.assertEquals(response.jsonPath().getString("data.list[1].titleDownTxt"),"150积分 + 10.00元","校验第二个商品credits失败");
Assert.assertEquals(response.jsonPath().getString("data.list[2].title"),"【自动化勿动】自有充值商品","校验第三个商品title失败");
Assert.assertEquals(response.jsonPath().getString("data.list[2].titleDownTxt"),"300积分","校验第三个商品credits失败");
Assert.assertEquals(response.jsonPath().getString("data.list[3].title"),"【自动化勿动】自有卡密","校验第四个商品title失败");
Assert.assertEquals(response.jsonPath().getString("data.list[3].titleDownTxt"),"550积分","校验第四个商品credits失败");
logger.info("校验商品分组2-自有新商品成功");
break;
}
}
}
package http.service.app;
import base.DuibaLog;
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.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static io.restassured.RestAssured.given;
@Service
public class ChwVisualEditorService {
@Value("${home.host}")
private String homeHost;
private DuibaLog logger = DuibaLog.getLogger();
@Autowired
Authorization authorization;
//手机端商品分组组件
public Response itemsList(Map cookies, String classifyId) throws Exception{
String url = "http://" + homeHost + "/chw/visual-editor/items/list";
Map<String,String> map = new HashMap<>();
map.put("classifyId",classifyId);
map.put("pageNo","1");
map.put("pageSize","300");
map.put("sort","custom");
logger.info("请求/chw/visual-editor/items/list接口");
Response response = given().contentType("application/json; charset=UTF-8").cookies(cookies).params(map).get( url);
try{
Assert.assertEquals(response.jsonPath().getString("success"),"true");
}catch(Exception e){
throw new Exception("/chw/visual-editor/items/list接口返回异常,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/chw/visual-editor/items/list接口返回异常,返回信息:"+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