Commit 22d3525f authored by 吕雯燕's avatar 吕雯燕

lv

parent 4010541c
package http.cases.SaasDeveloperTest;
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.Test;
import utils.PublicMethod;
import java.util.Map;
import http.service.Authorization;
/**
* created by lvwenyan 2019/4/4
*/
public class 新商品_编辑_DuibaTest extends DuibaTestBase {
@Autowired
DevItemNewService devItemNewService;
@Autowired
Authorization authorization;
@Test(description = "保存实物商品修改状态")
public void 保存实物修改状态() throws Exception{
Map cookies = authorization.hdLoginCommonNew("15855555555");
String appId = "22561";
String appItemId = "195026";
String skuId = "101";
try{
Map<String,Object> mapAppItem = jdbc.findSimpleResult("SELECT * FROM goods.app_item WHERE id = " + appItemId);
String status = String.valueOf(mapAppItem.get("status"));
logger.info("商品当前状态:" + status);
Assert.assertEquals(status,"on","校验商品上架状态失败");
//修改实物状态--仓库中,onsale=false
Response response = devItemNewService.doUpdateCredits(cookies,appId,appItemId,skuId,"false");
response.prettyPrint();
mapAppItem = jdbc.findSimpleResult("SELECT * FROM goods.app_item WHERE id = " + appItemId);
status = String.valueOf(mapAppItem.get("status"));
logger.info("商品修改后状态:" + status);
Assert.assertEquals(response.jsonPath().getString("desc"),"成功","校验商品保存失败");
Assert.assertEquals(status,"off","校验商品下架状态失败");
logger.info("校验实物保存修改状态成功");
}catch (Exception e){
throw new Exception("异常信息打印:" + e);
}finally {
//修改实物状态--在售,onsale=true
Response response = devItemNewService.doUpdateCredits(cookies,appId,appItemId,skuId,"true");
response.prettyPrint();
}
}
@Test(description = "修改优惠券商品上架、下架状态")
public void 商品上架与下架() throws Exception{
Map cookies = authorization.hdLoginCommonNew("15855555555");
String appId = "22561";
String appItemIds = "195027";
try{
Map<String,Object> mapAppItem = jdbc.findSimpleResult("SELECT * FROM goods.app_item WHERE id = " + appItemIds);
String status = String.valueOf(mapAppItem.get("status"));
logger.info("商品当前状态:" + status);
Assert.assertEquals(status,"on","校验商品上架状态失败");
//修改状态--下架,status = off
Response response = devItemNewService.batchStandUpOrDown(cookies,appId,appItemIds,"off");
response.prettyPrint();
mapAppItem = jdbc.findSimpleResult("SELECT * FROM goods.app_item WHERE id = " + appItemIds);
status = String.valueOf(mapAppItem.get("status"));
logger.info("商品修改后状态:" + status);
Assert.assertEquals(response.jsonPath().getString("desc"),"成功","校验商品保存失败");
Assert.assertEquals(status,"off","校验商品下架状态失败");
logger.info("校验优惠券修改下架状态成功");
}catch (Exception e){
throw new Exception("异常信息打印:" + e);
}finally {
//修改状态--上架,status= on
Response response = devItemNewService.batchStandUpOrDown(cookies,appId,appItemIds,"on");
response.prettyPrint();
}
}
}
package http.cases.SaasDeveloperTest;
import base.Config;
import base.DuibaLog;
import base.DuibaTestBase;
import http.service.hd.VisualEditorService;
import http.service.Authorization;
import http.cases.ExchangeTest.Database;
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.Test;
import utils.PublicMethod;
import java.util.Map;
import http.service.Authorization;
/**
* Created by lvwenyan on 2019/4/4
*/
public class 活动管理_DuibaTest extends DuibaTestBase {
@Autowired
Authorization authorization;
@Autowired
VisualEditorService visualEditorService;
@Test(description = "活动管理-活动列表数据")
public void 活动列表() throws Exception{
Map cookies = authorization.hdLoginCommonNew("15855555555");
String appId = "22561";
Response response = visualEditorService.activityList(cookies,"1",appId);
response.prettyPrint();
Assert.assertEquals(response.jsonPath().getString("data.result[0].activityId"),"511","校验PK赛活动id失败");
Assert.assertEquals(response.jsonPath().getString("data.result[0].title"),"lv测试PK赛1","校验PK赛活动title失败");
Assert.assertEquals(response.jsonPath().getString("data.result[0].typeName"),"组件-pk赛","校验PK赛活动typeName失败");
Assert.assertEquals(response.jsonPath().getString("data.result[0].status"),"2","校验PK赛活动status失败");
logger.info("校验活动列表-PK赛成功");
}
}
package http.service.hd;
import base.DuibaLog;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import io.restassured.response.Response;
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;
/**
* Created by lvwenyan on 2019/4/4
*/
@Service
public class DevItemNewService {
@Value("${hdserver.host}")
private String hdserverHost;
private DuibaLog logger = DuibaLog.getLogger();
//保存商品
public Response doUpdateCredits(Map cookies, String appId, String appItemId,String skuId, String onSale) throws Exception{
String url = hdserverHost + "/devItemNew/doUpdateCredits";
Map<String,Object> map = new HashMap<>();
Map<String,Object> mapList = new HashMap<>();
List<Map> list = new ArrayList<>();
mapList.put("skuId",skuId);
list.add(mapList);
map.put("appId",appId);
map.put("appItemId",appItemId);
map.put("buttonText","");
map.put("creditsInfos",list.toArray());
map.put("dateRage","[]");
map.put("exchangeType","1");
map.put("indexHidden","false");
map.put("isOwner","true");
map.put("limitDate","");
map.put("limitEverydayQuantity","");
map.put("lockTypeList","[]");
map.put("multiSku","false");
map.put("onSale",onSale);
map.put("originalPriceBuy","false");
JSONObject jsonParam = JSONObject.parseObject(JSON.toJSONString(map));
logger.info("请求商品保存接口:"+ "/devItemNew/doUpdateCredits");
Response response = given().contentType("application/json; charset=UTF-8").cookies(cookies).body(jsonParam).post("http://" + url);
try{
Assert.assertEquals(response.jsonPath().getString("success"),"true");
}catch(Exception e){
throw new Exception("/devItemNew/doUpdateCredits接口返回异常,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/devItemNew/doUpdateCredits接口返回异常,返回信息:"+response.asString());
}
return response;
}
//商品上架、下架
public Response batchStandUpOrDown(Map cookies, String appId, String appItemIds, String status) throws Exception{
String url = hdserverHost + "/devItemNew/batchStandUpOrDown";
Map<String,String> map = new HashMap<>();
map.put("appId",appId);
map.put("appItemIds",appItemIds);
map.put("status",status);
logger.info("请求商品上架下架接口:"+ "/devItemNew/batchStandUpOrDown");
Response response = given().contentType("application/x-www-form-urlencoded").cookies(cookies).params(map).post("http://" + url);
try{
Assert.assertEquals(response.jsonPath().getString("success"),"true");
}catch(Exception e){
throw new Exception("/devItemNew/batchStandUpOrDown接口返回异常,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/devItemNew/batchStandUpOrDown接口返回异常,返回信息:"+response.asString());
}
return response;
}
}
package http.service.hd;
import base.DuibaLog;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import io.restassured.response.Response;
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;
/**
* Created by lvwenyan on 2019/4/4
*/
@Service
public class VisualEditorService {
@Value("${hdserver.host}")
private String hdserverHost;
private DuibaLog logger = DuibaLog.getLogger();
//活动管理列表
public Response activityList(Map cookies, String pageNo, String appId) throws Exception{
String url = hdserverHost + "/visual-editor/activity/list";
Map<String,String> map = new HashMap<>();
map.put("pageNo",pageNo);
map.put("pageSize","10");
map.put("appId",appId);
logger.info("请求活动列表接口:"+ "/visual-editor/activity/list");
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("/visual-editor/activity/list接口返回异常,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/visual-editor/activity/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