Commit f4fcef82 authored by 赵然's avatar 赵然

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

parents 58c27935 089fbef0
......@@ -151,40 +151,45 @@ public class DingdingResult {
System.out.println("run+\".\"+type:"+run+"."+type);
if ((run+"."+type).equals("ui.group"))return "ui自动化测试";
run =this.env.getProperty(run+"."+type);
// System.out.println("(runs+\".\"+type):"+run+"."+type);
// System.out.println("runs:"+run);
System.out.println("run:"+run);
return new String(run.getBytes("ISO-8859-1"), "UTF-8");//ISO-8859-1
String returnString = new String(run.getBytes("ISO-8859-1"), "UTF-8");//ISO-8859-1
System.out.println("returnString:"+returnString);
return returnString;
}
public static void main(String[] args) throws UnsupportedEncodingException {
String s = "**/*_signTest.java";
s = s.substring(s.indexOf("_")+1,s.indexOf("."));
System.out.println(s);
// String s = "**/*_signTest.java";
// s = s.substring(s.indexOf("_")+1,s.indexOf("."));
// System.out.println(s);
//
//
// ApplicationContext context = new AnnotationConfigApplicationContext(Config.class);
// Environment env=context.getBean(Environment.class);
// String ss = env.getProperty("pluginTest.names");
// System.out.println(ss =new String(ss.getBytes("ISO-8859-1"), "UTF-8"));
//
//
// String run = "**/*_signTest.java";
// String type = "names";
// run = run.substring(run.indexOf("_")+1, run.indexOf("."));
// run =env.getProperty(run+"."+type);
// System.out.println(run = new String(run.getBytes("ISO-8859-1"), "UTF-8"));
// String[] sp =run.split(",");
// List<String> list = Arrays.asList(sp);
// List<String> names = new ArrayList<>();
// names.addAll(list);
ApplicationContext context = new AnnotationConfigApplicationContext(Config.class);
Environment env=context.getBean(Environment.class);
String ss = env.getProperty("pluginTest.names");
String ss = env.getProperty("Cms_ui.group");
System.out.println(ss =new String(ss.getBytes("ISO-8859-1"), "UTF-8"));
String run = "**/*_signTest.java";
String type = "names";
run = run.substring(run.indexOf("_")+1, run.indexOf("."));
run =env.getProperty(run+"."+type);
System.out.println(run = new String(run.getBytes("ISO-8859-1"), "UTF-8"));
String[] sp =run.split(",");
List<String> list = Arrays.asList(sp);
List<String> names = new ArrayList<>();
names.addAll(list);
}
}
\ No newline at end of file
......@@ -456,6 +456,14 @@ public class DuibaBaseUi extends DuibaBase{
}
}
/**
* 输入,通过xpath
* @param xpath
* @param text
* @param index 元素的下标
* @throws Exception
*/
public final void inputByXpath(String xpath,String text,int index) throws Exception{
int i=5;
......@@ -480,10 +488,17 @@ public class DuibaBaseUi extends DuibaBase{
}
/**
* 滑动窗口到顶部
*/
public void scrollToTop(){
((JavascriptExecutor) driver).executeScript("window.scrollTo(document.body.scrollHeight,0)");
}
/**
* 滑动窗口到底部
*/
public void scrollToDown(){
((JavascriptExecutor) driver).executeScript("window.scrollTo(0,document.body.scrollHeight)");
......
......@@ -628,6 +628,50 @@ public class 自有新优惠券_兑换限制测试_ExchangeTest extends CheckTem
}
@Test(description = "新优惠券扣库存测试")
public void 优惠券扣库存测试() throws Exception{
int uid = 7312;
String appItemId = "197567";
int skuId = 187;
//查询兑换前的库存
//stock_id 通过表tb_goods_batch 来查询
Map<String,Object> mapStock = jdbc.findSimpleResult("SELECT * FROM stock.tb_stock WHERE stock_id = 1060747299329170094");
String stock = String.valueOf(mapStock.get("stock"));
logger.info("兑换前的库存:" + stock);
Response response = gawService.couponExchange(uid,appItemId,skuId);
String orderId = response.jsonPath().getString("data.orderId");
//获取兑换结果
response = tawService.orderStatus(orderId,uid);
response.prettyPrint();
String status = response.jsonPath().getString("data.status");
int i = 10;
//异步接口,直到兑换成功
while (i> 0 && status.equals("processing")) {
Thread.sleep(1000);
response = tawService.orderStatus(orderId,uid);
response.prettyPrint();
status = response.jsonPath().getString("data.status");
i--;
}
mapStock = jdbc.findSimpleResult("SELECT * FROM stock.tb_stock WHERE stock_id = 1060747299329170094");
String newStock = String.valueOf(mapStock.get("stock"));
String result = String.valueOf(Integer.valueOf(stock)-1);
logger.info("兑换后的库存:" + newStock);
Assert.assertEquals(response.jsonPath().getString("data.status"),"success","校验订单状态失败");
Assert.assertEquals(newStock,result,"校验扣库存失败");
logger.info("校验新优惠券商品扣库存成功");
}
......
......@@ -497,55 +497,53 @@ public class 自有新实物_兑换流程测试_ExchangeTest extends CheckTemple
}
@Test(description = "新实物扣库存测试")
public void 实物扣库存测试() throws Exception{
int uid = 7302;
String appItemId = "197385";
String itemId = null;
String skuId = "183";
String credits = "10";
String actualCredits = "10";
//查询兑换前的库存
//stock_id 通过表tb_app_item_sku 来查询
Map<String,Object> mapStock = jdbc.findSimpleResult("SELECT * FROM stock.tb_stock WHERE stock_id = 1059049813690420183");
String stock = String.valueOf(mapStock.get("stock"));
logger.info("兑换前的库存:" + stock);
Response response = gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits);
String orderId = response.jsonPath().getString("data.orderId");
//获取兑换结果
response = tawService.orderStatus(orderId,uid);
response.prettyPrint();
String status = response.jsonPath().getString("data.status");
int i = 10;
//异步接口,直到兑换成功
while (i> 0 && status.equals("processing")) {
Thread.sleep(1000);
response = tawService.orderStatus(orderId,uid);
response.prettyPrint();
status = response.jsonPath().getString("data.status");
i--;
}
mapStock = jdbc.findSimpleResult("SELECT * FROM stock.tb_stock WHERE stock_id = 1059049813690420183");
String newStock = String.valueOf(mapStock.get("stock"));
String result = String.valueOf(Integer.valueOf(stock)-1);
logger.info("兑换后的库存:" + newStock);
//测试使用
//@Test(enabled=true, dataProvider="testdp", threadPoolSize=1, invocationCount=100)
@DataProvider(name = "testdp", parallel = true)
public static Object[][]testdp(){
return new Object[][]{
{1},
{2},
{3},
{4},
{162},
{6},
{8},
{10},
{157},
{158}
};
}
// @Test(enabled=true, dataProvider="testdp", threadPoolSize=1, invocationCount=100)
public void test(int uid) throws Exception {
// System.out.println("Current Thread Id: " + Thread.currentThread().getId() + ". Dataprovider number: "+ dpNumber);
// Thread.sleep(5000);
String appItemId = "159040";
String itemId = "null";
String message = "";
String skuId="144";
String actualCredits="8";
String credits="100";
Assert.assertEquals(response.jsonPath().getString("data.status"),"wait_delivery","校验订单状态失败");
Assert.assertEquals(newStock,result,"校验扣库存失败");
logger.info("校验新实物商品扣库存成功");
Thread.sleep(4000);
Response response = gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits);
response.prettyPrint();
//(enabled=true, dataProvider="testdp", threadPoolSize=1, invocationCount=2)
}
String orderId = response.jsonPath().getString("data.orderId");
response = tawService.orderStatus(orderId,uid);
response.prettyPrint();
}
}
......@@ -500,4 +500,50 @@ public class 自有新虚拟商品_充值_兑换限制_ExchangeTest extends Chec
}
@Test(description = "虚拟商品扣库存测试")
public void 虚拟商品扣库存测试() throws Exception{
int uid = 7313;
Map cookies = authorization.dafuwengLogin(uid);
String appItemId = "197568";
int skuId = 188;
//查询兑换前的库存
//stock_id 通过表tb_app_item_sku 来查询
Map<String,Object> mapStock = jdbc.findSimpleResult("SELECT * FROM stock.tb_stock WHERE stock_id = 1060758938511670188");
String stock = String.valueOf(mapStock.get("stock"));
logger.info("兑换前的库存:" + stock);
Response response = gawService.virtualExchange(cookies, appItemId,skuId);
String orderId = response.jsonPath().getString("data.orderId");
//获取兑换结果
response = tawService.orderStatus(orderId,uid);
response.prettyPrint();
String status = response.jsonPath().getString("data.status");
int i = 10;
//异步接口,直到兑换成功
while (i> 0 && status.equals("processing")) {
Thread.sleep(1000);
response = tawService.orderStatus(orderId,uid);
response.prettyPrint();
status = response.jsonPath().getString("data.status");
i--;
}
mapStock = jdbc.findSimpleResult("SELECT * FROM stock.tb_stock WHERE stock_id = 1060758938511670188");
String newStock = String.valueOf(mapStock.get("stock"));
String result = String.valueOf(Integer.valueOf(stock)-1);
logger.info("兑换后的库存:" + newStock);
Assert.assertEquals(response.jsonPath().getString("data.status"),"success","校验订单状态失败");
Assert.assertEquals(newStock,result,"校验扣库存失败");
logger.info("校验充值商品扣库存成功");
}
}
......@@ -222,7 +222,7 @@ public class gawService {
JSONObject jsonParam = JSONObject.parseObject(JSON.toJSONString(map));
logger.info("请求实物兑换接口:"+ "/gaw/couponExchange/create");
logger.info("请求优惠券兑换接口:"+ "/gaw/couponExchange/create");
Response response = given().contentType("application/json; charset=UTF-8").cookies(authorization.dafuwengLogin(uid)).body(jsonParam).post("http://"+goodsHost+"/gaw/couponExchange/create");
// Response saveResponse = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.dafuwengLogin(uid)).params(map).post("http://"+goodsHost+"/gaw/objectExchange/create");
......@@ -353,7 +353,7 @@ public class gawService {
JSONObject jsonParam = JSONObject.parseObject(JSON.toJSONString(map));
logger.info("请求实物兑换接口:"+ "/gaw/couponExchange/create");
logger.info("请求虚拟商品兑换接口:"+ "/gaw/virtualExchange/create");
Response response = given().contentType("application/json; charset=UTF-8").cookies(cookie).body(jsonParam).post("http://"+goodsHost+"/gaw/virtualExchange/create");
// Response saveResponse = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.dafuwengLogin(uid)).params(map).post("http://"+goodsHost+"/gaw/objectExchange/create");
......
......@@ -127,6 +127,41 @@ public class DevItemNewService {
}
//商品组件
public Response appItems(Map cookies, String appId, List<Integer> itemIdList) throws Exception{
String url = hdserverHost + "/devItemNew/appItems";
Map<String,Object> map = new HashMap<>();
map.put("status","on");
map.put("pageSize","300");
map.put("appId",appId);
map.put("pageNo","1");
map.put("itemIdList",itemIdList);
map.put("sort","custom");
map.put("soldOutType","show");
map.put("forGoodsVisual","true");
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;
}
......
......@@ -85,3 +85,10 @@ ui.names=mabo
ui.group=\u81EA\u52A8\u5316
ui.resultUrl=http://101.68.72.146:18080/job/duiba_ui/HTML_20Report/suite1_test1_results.html
ui.job=duiba_ui
Cms_ui.project=界面自动化核心业务
Cms_ui.names=mabo
Cms_ui.group=自动化
Cms_ui.resultUrl=http://10.254.187.25/job/duiba_ui/HTML_20Report/suite1_test1_results.html
Cms_ui.job=duiba_cms_ui
\ No newline at end of file
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