Commit 9204fc49 authored by 钱雯君's avatar 钱雯君

Merge branch 'develop' into qwj_181029

parents a470c14c 63e15316
......@@ -160,7 +160,7 @@ public class CustomActivity_DuibaTest extends DuibaTestBase {
}
@Test
//@Test
public void 自定义活动增加抽奖次数() throws Exception {
this.创建并上架活动();
......
package http.cases.DefinedActivityTest;
import base.DuibaLog;
import base.DuibaTestBase;
import http.service.Activity.ManagerService;
import http.service.Activity.NewActivityService;
import http.service.Authorization;
import http.service.hd.ActivityService;
import http.service.hd.DeveloperService;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import utils.MatcherString;
import java.lang.reflect.Method;
import java.util.Map;
/**
* Created by lvwenyan on 2018/1/5.
*/
public class 活动增加抽奖次数_DuibaTest extends DuibaTestBase {
@Autowired
NewActivityService newActivityService;
@Autowired
ManagerService managerService;
@Autowired
Authorization authorization;
@Autowired
ActivityService activityService;
@Autowired
DeveloperService developerService;
private static DuibaLog logger = DuibaLog.getLogger();
//兑吧活动id
private static String hdtoolId ;
//活动入库id
private static String actId ;
@AfterClass
public void after() throws Exception {
//数据库删除
try {
jdbc.update("delete from hdtool_conf.duiba_hdtool where title=?", "自动化测试自定义活动");
jdbc.update("delete from credits_dev.operating_activity where title=?","自动化测试自定义活动");
} catch (Exception e) {
System.out.println(e);
}
}
@Test
public void 自定义活动增加抽奖次数() throws Exception {
this.创建并上架活动();
//获取开发者后台活动列表,获取活动id
//Response listResponse = activityService.list2("2239", "1");
//String hdtoolId = listResponse.jsonPath().getString("data.list[0].activityId");
//String actId = listResponse.jsonPath().getString("data.list[0].id");
Map<String, Object> selectResult = jdbc.findSimpleResult("select * from credits_dev.operating_activity where activity_id = "+hdtoolId);
actId = String.valueOf(selectResult.get("id"));
logger.info("兑吧活动ID:" + hdtoolId);
logger.info("活动入库ID:" + actId);
//活动创建后,页面免费次数
Response Response = newActivityService.ajaxElement("duiba", hdtoolId, actId, "false");
logger.info("活动创建后,初始页面免费次数:"+Response.jsonPath().getString("element.freeLimit"));
//增加活动免费抽奖次数
Response addResponse = newActivityService.addtimes("1", actId, "hdtool");
addResponse.prettyPrint();
//增加次数后验证活动页面免费次数
Response ajaxResponse = newActivityService.ajaxElement("duiba", hdtoolId, actId, "false");
logger.info("增加次数后活动页面免费次数为:"+ajaxResponse.jsonPath().getString("element.freeLimit"));
Assert.assertEquals(ajaxResponse.jsonPath().getString("element.freeLimit"), "1", "免费次数增加失败");
//增加次数后进行抽奖
Response dojoinResponse = this.自定义活动工具抽奖(actId, "lmxayt9a");
Response endResponse = newActivityService.ajaxElement("duiba", hdtoolId, actId, "false");
int i = 20;
while (i > 0 && (!endResponse.jsonPath().getString("element.freeLimit").equals("0"))) {
Thread.sleep(1000);
dojoinResponse = this.自定义活动工具抽奖(actId, "lmxayt9a");
endResponse = newActivityService.ajaxElement("duiba", hdtoolId, actId, "false");
i--;
}
logger.info("抽奖后活动页面免费次数为:"+endResponse.jsonPath().getString("element.freeLimit"));
Assert.assertEquals(endResponse.jsonPath().getString("element.freeLimit"), "0", "免费次数使用不正确");
logger.info("校验活动使用免费次数成功");
}
public Response 自定义活动工具抽奖(String activityId, String token) throws Exception {
Response response = newActivityService.doJoin2(activityId, token);
response.prettyPrint();
String orderId = response.jsonPath().getString("orderId");
response = newActivityService.getOrderStatus2(orderId);
response.prettyPrint();
String result = String.valueOf(response.jsonPath().getString("result"));
int i = 8;
while (i > 0 && (result.equals("0"))) {
Thread.sleep(1000);
response = newActivityService.getOrderStatus2(orderId);
result = String.valueOf(response.jsonPath().getString("result"));
i--;
response.prettyPrint();
}
return response;
}
public void 创建并上架活动() throws Exception {
//管理后台创建活动并开启
Response ManagerResponse = managerService.save_customHdtool();
hdtoolId = ManagerResponse.jsonPath().getString("data.actId");
//活动状态开启
managerService.switchSpecifyAndBlack("1", hdtoolId);
//定向开发者
managerService.saveSpecify(hdtoolId,"2239");
//开发者上架活动
Response HdResponse = developerService.joinIn(hdtoolId, "12");
logger.info("创建活动并上架成功");
}
}
\ No newline at end of file
......@@ -24,7 +24,7 @@ import java.util.List;
/**
* Created by zhaoran on 2018/07/10
*/
public class 多奖项中奖限制_DuibaTest extends DuibaTestBase {
public class 多奖项中奖限制 extends DuibaTestBase {
@Autowired
NewActivityService newActivityService;
......
......@@ -24,7 +24,7 @@ import java.util.List;
/**
* Created by zhaoran on 2018/07/10
*/
public class 奖品发放限制_DuibaTest extends DuibaTestBase {
public class 奖品发放限制 extends DuibaTestBase {
@Autowired
NewActivityService newActivityService;
......
......@@ -58,9 +58,19 @@ public class 定向测试_DuibaTest extends DuibaTestBase {
Assert.assertEquals(direct, "true", "校验创建活动自动打开定向功能失败");
Response hdResponse = developerService.list("2239");
String title = hdResponse.jsonPath().getString("data[0].title");
// Assert.assertNotEquals(title, "【推荐位测试数据】", "校验开发者集市定向活动失败,应不展示未定向到2239活动");
Assert.assertEquals(title.equals("【定向测试数据】"+data), false,"校验开发者集市定向活动失败,应不展示未定向到2239活动!");
//String title = hdResponse.jsonPath().getString("data[0].title");
for(int z=0;z<6;z++){
String title2 = hdResponse.jsonPath().getString("data["+z+"].title");
logger.info("第"+z+"个活动名称为"+title2);
if(title2.equals("【定向测试数据】"+data)){
throw new Exception("校验开发者集市定向活动失败,应展示定向到2239的活动");
}
if(z==5){
logger.info("校验开发者集市定向活动成功,应不展示未定向到2239活动!");
break;
}
}
//Assert.assertEquals(title.equals("【定向测试数据】"+data), false,"校验开发者集市定向活动失败,应不展示未定向到2239活动!");
}
// @Test(description = "打开定向功能未指定开发者",priority = 2)
......@@ -86,7 +96,6 @@ public class 定向测试_DuibaTest extends DuibaTestBase {
String title2 = hdResponse.jsonPath().getString("data["+z+"].title");
logger.info("第"+z+"个活动名称为"+title2);
if(title2.equals("【定向测试数据】"+data)){
// Assert.assertEquals(title2, "【定向测试数据】"+data, "校验开发者集市定向活动失败,应展示定向到2239的活动");
break;
}
if(z==5){
......
package http.cases.NewActivityTest;
import base.Config;
import base.DuibaLog;
import http.service.Activity.NewActivityService;
import http.service.hd.DeveloperService;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
import org.testng.Assert;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import utils.MatcherString;
import java.lang.reflect.Method;
/**
* Created by zhaoran on 2018/11/02
*/
@ContextConfiguration(classes = Config.class)
public class 开发者不可见测试_DuibaTest extends AbstractTestNGSpringContextTests {
@Autowired
NewActivityService newActivityService;
@Autowired
DeveloperService developerService;
private static DuibaLog logger = DuibaLog.getLogger();
@Test(description = "手机端活动应正常打开")
public void 页面访问测试() throws Exception {
//访问活动界面
Response response = newActivityService.index("35374");
//判断结果
Assert.assertEquals(MatcherString.getString(response.asString(),"<title>(.*?)</title>\n",1),"【自动化】开发者不可见","活动页打开异常!");
logger.info("活动页面打开成功");
}
@Test(description = "开发者端活动应不可见")
public void 开发者活动不可见() throws Exception {
Response response =developerService.list2("【自动化】开发者不可见");
Assert.assertEquals(response.asString().contains("【自动化】开发者不可见"), false, "校验活动title失败");
logger.info("校验title成功");
}
}
......@@ -26,11 +26,12 @@ public class 新活动工具测试_DuibaTest extends DuibaTestBase {
ActivityService activityService;
private static DuibaLog logger = DuibaLog.getLogger();
private static int uid = 4259;
@Test
public void 福袋商品测试() throws Exception {
logger.info("-------------------------------------活动中奖福袋商品-------------------------------------");
Response response = this.新活动工具接口传参("18567","1gffs6mq3","iOS");
Response response = this.新活动工具接口传参(uid,"18567","1gffs6mq3");
//String type = String.valueOf(response.jsonPath().getString("lottery.type"));
//推啊出券系统检测
// if(activityService.isRunning("10.110.10.12","17791","tuia-engine")){
......@@ -53,7 +54,7 @@ public class 新活动工具测试_DuibaTest extends DuibaTestBase {
@Test
public void 谢谢参与转福袋测试() throws Exception {
logger.info("-------------------------------------活动中奖谢谢参与转福袋-------------------------------------");
Response response = this.新活动工具接口传参("26640","1gffs6mq3","iOS");
Response response = this.新活动工具接口传参(uid,"26640","1gffs6mq3");
//String type = String.valueOf(response.jsonPath().getString("lottery.type"));
//推啊出券系统检测
// if(activityService.isRunning("10.110.10.12","17791","tuia-engine")){
......@@ -75,14 +76,14 @@ public class 新活动工具测试_DuibaTest extends DuibaTestBase {
@Test
public void 免费次数测试() throws Exception {
Response response1 = newActivityService.ajaxElement("3251","19114");
Response response1 = newActivityService.ajaxElement(uid,"3251","19114");
String freeLimit = String.valueOf(response1.jsonPath().getString("element.freeLimit"));
logger.info("抽奖前剩余免费抽奖次数:"+freeLimit);
freeLimit = String.valueOf(Integer.valueOf(freeLimit)-1);
Response response = this.新活动工具接口传参("19114","ogw24k6ns","iOS");
Response response = this.新活动工具接口传参(uid,"19114","ogw24k6ns");
Thread.sleep(1000);
Response response2 = newActivityService.ajaxElement("3251","19114");
Response response2 = newActivityService.ajaxElement(uid,"3251","19114");
String freeLimitNew = String.valueOf(response2.jsonPath().getString("element.freeLimit"));
logger.info("抽奖后剩余免费抽奖次数:"+freeLimitNew);
......@@ -94,14 +95,14 @@ public class 新活动工具测试_DuibaTest extends DuibaTestBase {
@Test
public void 再抽一次测试() throws Exception {
//查询数据库,当前积分(抽奖扣积分流程校验)
Map<String,Object> mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id=2720");
Map<String,Object> mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
String credits = String.valueOf(mapuser.get("credits"));
logger.info("抽奖前积分:"+credits);
//扣去1积分
credits = String.valueOf(Integer.valueOf(credits)-1);
//第一次抽奖
Response response = this.新活动工具接口传参("18580","m8rhchc","iOS");
Response response = this.新活动工具接口传参(uid,"18580","m8rhchc");
Assert.assertEquals(response.jsonPath().getString("lottery.type"),"again","校验type失败");
Assert.assertEquals(response.jsonPath().getString("lottery.id"), "11608", "校验id失败");
......@@ -109,7 +110,7 @@ public class 新活动工具测试_DuibaTest extends DuibaTestBase {
logger.info("校验:type,id,result成功");
//第一次抽奖后查询数据库,获取当前积分
mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id=2720");
mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
String creditsNew = String.valueOf(mapuser.get("credits"));
logger.info("第一次抽奖后积分:"+creditsNew);
//校验比较,抽奖前后积分
......@@ -117,11 +118,11 @@ public class 新活动工具测试_DuibaTest extends DuibaTestBase {
logger.info("校验第一次抽奖前后积分正确");
//第二次抽奖
response = newActivityService.doJoin2("18580","m8rhchc",response.jsonPath().getString("againTag"));
response = newActivityService.doJoin2(uid,"18580","m8rhchc",response.jsonPath().getString("againTag"));
response.prettyPrint();
Thread.sleep(2000);
//第二次抽奖后查询数据库,获取当前积分
mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id=2720");
mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
String creditsNew2 = String.valueOf(mapuser.get("credits"));
logger.info("第二次抽奖后积分:"+creditsNew2);
//校验比较,抽奖前后积分
......@@ -129,18 +130,18 @@ public class 新活动工具测试_DuibaTest extends DuibaTestBase {
logger.info("校验第二次抽奖前后积分正确");
}
public Response 新活动工具接口传参(String activityId,String token,String device) throws Exception {
Response response = newActivityService.doJoin2(activityId,token);
public Response 新活动工具接口传参(int uid,String activityId,String token) throws Exception {
Response response = newActivityService.doJoin2(uid,activityId,token);
response.prettyPrint();
String orderId = response.jsonPath().getString("orderId");
response = newActivityService.getOrderStatus2(orderId,device);
response = newActivityService.getOrderStatus2(uid,orderId);
response.prettyPrint();
String result = String.valueOf(response.jsonPath().getString("result"));
int i= 30;
while(i>0&&(result.equals("0"))){
Thread.sleep(1000);
response = newActivityService.getOrderStatus2(orderId,device);
response = newActivityService.getOrderStatus2(uid,orderId);
result = String.valueOf(response.jsonPath().getString("result"));
i--;
response.prettyPrint();
......
package http.cases.SaasDeveloperTest;
import base.Config;
import base.DuibaTestBase;
import http.service.Activity.ManagerService;
import http.service.Authorization;
import http.service.app.CouponExchangeService;
import http.service.app.CrecordService;
import http.service.app.MobileService;
import http.service.app.VirtualExchangeService;
import base.DuibaLog;
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.BeforeMethod;
import org.testng.annotations.Test;
import java.util.HashMap;
import java.util.Map;
@ContextConfiguration(classes = Config.class)
public class 异常订单测试 extends DuibaTestBase {
@Autowired
private MobileService mobileService;
@Autowired
private Authorization authorization;
@Autowired
private CouponExchangeService couponExchangeService;
@Autowired
private CrecordService crecordService;
@Autowired
ManagerService managerService;
@Autowired
VirtualExchangeService virtualExchangeService;
Map<String, String> userCookies = new HashMap<>();
private DuibaLog logger = DuibaLog.getLogger();
//指定用户
private static int uid = 2709;
//实物兑换限制消费
@Test(description = "实物兑换已兑换")
public void 已兑换() throws Exception {
//活动详情页
Response response = mobileService.detail(authorization.dafuwengLogin(uid), "28633");
// response.prettyPrint();
Map<String, String> map = authorization.dafuwengLogin(uid,true);
Assert.assertEquals(String.valueOf(response.getStatusCode()), "200", "活动详情页请求异常");
//实物兑换
Response response1 = couponExchangeService.objectExchange1(map, "167611", "28633", "null", "z9sydmcs", "null");
response1.prettyPrint();
String message2 = response1.jsonPath().getString("message");
Assert.assertEquals(message2, "已兑换", "message字段校验失败-期望是已兑换");
}
@Test(description = "实物兑换无库存")
public void 无库存() throws Exception {
Response response = mobileService.detail(authorization.dafuwengLogin(3661), "31051");//uid3661
// response.prettyPrint();
Map<String, String> map = authorization.dafuwengLogin(3661, true);
Assert.assertEquals(String.valueOf(response.getStatusCode()), "200", "活动详情页请求异常");
//实物兑换
Response response2 = couponExchangeService.objectExchange2(map, "179139", "null", "null", "z9sydmcs", "null");
response2.prettyPrint();
String message3 = response2.jsonPath().getString("message");
Assert.assertEquals(message3, "今日已兑完,明天再来哦(14)", "message字段校验失败-期望是无库存");
}
@BeforeMethod
public void 获取用户登录信息(){
userCookies = authorization.dafuwengLogin(3661, true);
}
@Test(description = "实物兑换无库存并发")
public void 并发() throws Exception{
Response response = mobileService.detail(authorization.dafuwengLogin(3661), "31152");//uid还可以为3662
// response.prettyPrint();
Assert.assertEquals(String.valueOf(response.getStatusCode()), "200", "活动详情页请求异常");
//实物兑换
Response response2 = couponExchangeService.objectExchange2(userCookies, "179139", "null", "null", "z9sydmcs", "null");
response2.prettyPrint();
String message3 = response2.jsonPath().getString("message");
Assert.assertEquals(message3, "今日已兑完,明天再来哦(14)", "message字段校验失败-期望是无库存");
//模拟10次同时请求
for (int i =0; i < 10;i++) {
Thread thread = new Thread(new MyRunnable());
thread.setName("thread"+ i);
thread.start();
thread.join();
}
}
class MyRunnable implements Runnable{
@Override
public void run() {
logger.info("开始执行 ");
try {
Response response2 = couponExchangeService.objectExchange2(userCookies, "179139", "null", "null", "z9sydmcs", "null");
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
package http.cases.SaasDeveloperTest;
import base.Config;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import utils.PublicMethod;
import http.service.Saas.ZdyflService;
import base.DuibaLog;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
import org.testng.Assert;
import org.testng.annotations.Test;
import java.util.List;
/**
* Created by humengxin on 2018/8/21.
*/
@ContextConfiguration(classes = Config.class)
public class 自定义分类 extends AbstractTestNGSpringContextTests {
@Autowired
ZdyflService zdyflService;
private static DuibaLog logger = DuibaLog.getLogger();
@Test(description = "开发者创建自定义分类商品")
public void a_添加自定义分类商品() throws Exception {
String data = PublicMethod.data();
//新建实物商品
zdyflService.editClassify();
//查看商品列表确认商品成功添加
Response response1=zdyflService.classify();
// 获取自定义分类商品ID
String classifyId = String.valueOf(response1.jsonPath().getString("data.list[0].id"));
Assert.assertEquals(response1.jsonPath().getString("data.list[0].name"), "hmx自动化", "校验分类名称失败");
Assert.assertEquals(response1.jsonPath().getString("data.list[0].appId"), "2239", "校验当前appid失败");
logger.info("校验name,appid成功");
//删除测试数据
//zdyflService.deleteClassify("2239",classifyId);
}
@Test(description = "上架活动")
public void b_上架活动() throws Exception {
String data = PublicMethod.data();
//新建实物商品
// 获取自定义分类商品ID
String classifyId = String.valueOf(zdyflService.classify().jsonPath().getString("data.list[0].id"));
Response response = zdyflService.list2(classifyId);
// 获取活动ID
String actId1 = String.valueOf(response.jsonPath().getString("data.list[1].id"));
String actId2 = String.valueOf(response.jsonPath().getString("data.list[2].id"));
String actId3 = String.valueOf(response.jsonPath().getString("data.list[3].id"));
String newString = actId1+","+actId2+","+actId3;
Response response1=zdyflService.saveToClassify(classifyId,newString);
Assert.assertEquals(response1.jsonPath().getString("data.length"),"3", "校验活动个数失败");
logger.info("校验上架活动 成功");
//删除测试数据
//zdyflService.deleteClassify("2239",classifyId);
}
@Test(description = "上架商品")
public void c_上架商品() throws Exception {
String data = PublicMethod.data();
//新建实物商品
// 获取自定义分类商品ID
String classifyId = String.valueOf(zdyflService.classify().jsonPath().getString("data.list[0].id"));
Response response=zdyflService.classifyAppItem("2239",classifyId);
Response response2 = zdyflService.classifyNoAppItem(classifyId);
// 获取商品ID
String Id1 = String.valueOf(response2.jsonPath().getString("data.list[2].itemid"));
String Id2 = String.valueOf(response2.jsonPath().getString("data.list[3].itemid"));
String Id3 = String.valueOf(response2.jsonPath().getString("data.list[4].itemid"));
String newString2 = Id1+","+Id2+","+Id3;
Response response1=zdyflService.saveToClassify2(classifyId,newString2);
Assert.assertEquals(response1.jsonPath().getString("data.length"),"3", "校验商品个数失败");
logger.info("校验 上架商品 成功");
//删除测试数据
//zdyflService.deleteClassify("2239",classifyId);
}
@Test(description = "预览自定义分类商品")
public void d_预览自定义分类商品() throws Exception {
String data = PublicMethod.data();
// 获取自定义分类商品ID
String classifyId = String.valueOf(zdyflService.classify().jsonPath().getString("data.list[0].id"));
Response response=zdyflService.classifyPreview(classifyId);
Assert.assertEquals(response.jsonPath().getString("data.isRedirect"), "true", "校验预览失败");
logger.info("校验 预览自定义分类列表商品 成功");
//删除测试数据
//zdyflService.deleteClassify("2239",classifyId);
}
@Test(description = "活动移出分类")
public void e_活动移出分类() throws Exception {
String data = PublicMethod.data();
// 获取自定义分类商品ID
String classifyId = String.valueOf(zdyflService.classify().jsonPath().getString("data.list[0].id"));
//删除前,查看所有商品数
Response response1 = zdyflService.classifyAppItem("2239",classifyId);
logger.info("XXXXXXXXX"+response1.asString());
// 获取活动ID
String actId11 = String.valueOf(response1.jsonPath().getString("data.classifyItemDetails[5].operatingActivityId"));
logger.info("XXXXXXXXX"+actId11);
Response response2=zdyflService.removeClassifyAppItem1(classifyId,actId11);
// Assert.assertEquals(response2.jsonPath().getString("message"),"移除成功", "校验活动个数失败");
logger.info("校验 活动移出分类 成功");
//删除测试数据
//zdyflService.deleteClassify("2239",classifyId);
}
@Test(description = "商品移出分类")
public void f_商品移出分类() throws Exception {
String data = PublicMethod.data();
//新建实物商品
// 获取自定义分类商品ID
String classifyId = String.valueOf(zdyflService.classify().jsonPath().getString("data.list[0].id"));
//删除前,查看所有商品数
Response response1 = zdyflService.classifyAppItem("2239",classifyId);
// 获取商品ID
String Id1 = String.valueOf(response1.jsonPath().getString("data.classifyItemDetails[0].appItemId"));
Response response2=zdyflService.removeClassifyAppItem2(classifyId,Id1);
//删除后,查看所有商品数
//Response response3 = zdyflService.classifyAppItem("2239",classifyId);
logger.info("校验 商品移除分类 成功");
//删除测试数据
//zdyflService.deleteClassify("2239",classifyId);
}
@Test(description = "删除新建的自定义分类")
public void g_删除新建的自定义分类() throws Exception {
//删除前,查看所有分类列表
Response response1=zdyflService.classify();
logger.info("删除前,查看所有分类列表"+response1.asString());
// 获取自定义分类商品ID
String classifyId = String.valueOf(response1.jsonPath().getString("data.list[0].id"));
//删除测试数据,删除后,查看所有分类列表
Response response2=zdyflService.deleteClassify("2239",classifyId);
logger.info("删除后,查看所有分类列表"+response2.asString());
}
@Test(description = "手机端自定义icon页面分页数据重复问题 校验")
public void h_分页数据重复问题() throws Exception {
String data = PublicMethod.data();
Response response1 = zdyflService.classifyAppItem("2239","1278");
logger.info("查询该自定义分类列表数据");
Response response2=zdyflService.getClassify("1");
System.out.println("----------------" + response2.asString());
String string = response2.asString();
//org.apache.commons.lang.StringEscapeUtils.unescapeJavaScript(response2.asString());
JSONObject jsonObject = JSONObject.parseObject(response2.asString());
JSONObject jsonObject2 = JSONObject.parseObject(JSON.toJSONString(jsonObject.get("data")));
List<String> items1 = JSONObject.parseArray(JSON.toJSONString(jsonObject2.get("items")), String.class);
//System.out.println("所有的第一页数据" + JSON.toJSONString(items1));
Response response3=zdyflService.getClassify("2");
System.out.println("所有的第一页数据" + response2.asString());
System.out.println("所有的第二页数据" + response3.asString());
JSONObject jsonObject3 = JSONObject.parseObject(response3.asString());
JSONObject jsonObject4 = JSONObject.parseObject(JSON.toJSONString(jsonObject3.get("data")));
List<String> items2 = JSONObject.parseArray(JSON.toJSONString(jsonObject4.get("items")), String.class);
//System.out.println("所有的第二页数据" + JSON.toJSONString(items2));
items1.stream().forEach(item->{
for (String item2 : items2) {
if (item2.equals(item)){
System.out.println("=========相同数据=======");
System.out.println("第一页" + item);
System.out.println("第二页" + item2);
throw new RuntimeException("=========相同数据=======");
}
}
});
}
}
\ No newline at end of file
package http.cases.SaasDeveloperTest;
import base.Config;
import utils.PublicMethod;
import http.service.Saas.DeveloperCouponService;
import http.service.Saas.DeveloperObjectService;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
import org.testng.Assert;
import org.testng.annotations.Test;
/**
* 自有优惠券添加、修改、删除、上架或下架、查询操作
*/
@ContextConfiguration(classes = Config.class)
public class 自有优惠券测试_DuibaTest extends AbstractTestNGSpringContextTests {
@Autowired
DeveloperObjectService developerObjectService;
@Autowired
DeveloperCouponService developerCouponService;
//我的商品列表中的ID
private static String appItemId;
//实物上下架状态
private static String status;
private static String data;
private static String data2;
private static String data3;
private static String data4;
@Test(description = "添加自有优惠券重复券码")
public void a_添加自有重复券() throws Exception{
//添加优惠券
data = PublicMethod.data();
developerCouponService.doUpdateCoupon("【自动化】自有重复券"+data);
//查看商品列表确认商品成功添加
Response response = developerObjectService.appItems("19515","【自动化】自有重复券"+data);
Assert.assertEquals(response.jsonPath().getString("data.list[0].title"), "【自动化】自有重复券"+data, "校验优惠券title失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].belong"), "自有", "校验优惠券belong失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].type"), "coupon", "校验优惠券type失败");
logger.info("校验title,belong成功");
//获取商品id
appItemId = String.valueOf(response.jsonPath().getString("data.list[0].id"));
//导入重复的券码
developerCouponService.doCFAddGoodsCouponsNew("19515",appItemId);
//查看商品列表确认商品成功添加
Response response2 = developerObjectService.appItems("19515","【自动化】自有重复券"+data);
Assert.assertEquals(response2.jsonPath().getString("data.list[0].title"), "【自动化】自有重复券"+data, "校验优惠券title失败");
Assert.assertEquals(response2.jsonPath().getString("data.list[0].belong"), "自有", "校验优惠券belong失败");
Assert.assertEquals(response2.jsonPath().getString("data.list[0].remaind"), "10000", "校验优惠券remaind失败");
Assert.assertEquals(response2.jsonPath().getString("data.list[0].type"), "coupon", "校验优惠券type失败");
logger.info("校验title,belong成功,remaind成功,type成功");
}
@Test(description = "上架实物商品或下架实物商品")
public void b_上下架优惠券() throws Exception{
//查看商品列表确认商品成功添加
// logger.info("status===="+status);
Response response =developerObjectService.appItems("19515","【自动化】自有重复券"+data);
status= String.valueOf(response.jsonPath().getString("data.list[0].status"));
if(status.equals("0")){
developerObjectService.standUp(appItemId,"up");
//查看商品列表,确认上架成功
Response response1 =developerObjectService.appItems("19515","【自动化】自有重复券"+data);
Assert.assertEquals(response1.jsonPath().getString("data.list[0].status"), "1", "校验上架实物失败");
Assert.assertEquals(response1.jsonPath().getString("data.list[0].statusText"), "上架", "校验上架实物失败");
logger.info("校验实物上架成功");
}else {
developerObjectService.standUp(appItemId,"down");
//查看商品列表,确认下架成功
Response response2 =developerObjectService.appItems("19515","【自动化】自有重复券"+data);
Assert.assertEquals(response2.jsonPath().getString("data.list[0].status"), "0", "校验下架实物失败");
Assert.assertEquals(response2.jsonPath().getString("data.list[0].statusText"), "下架", "校验下架实物失败");
logger.info("校验实物下架成功");
}
}
//删除
@Test(description = "删除优惠券")
public void c_删除优惠券() throws Exception{
developerObjectService.ajaxDel(appItemId);
}
@Test(description = "添加自有优惠券链接券码")
public void d_添加自有链接券() throws Exception{
//添加优惠券
data2 = PublicMethod.data();
developerCouponService.doUpdateCoupon("【自动化】自有链接券"+data2);
//查看商品列表确认商品成功添加
Response response = developerObjectService.appItems("19515","【自动化】自有链接券"+data2);
Assert.assertEquals(response.jsonPath().getString("data.list[0].title"), "【自动化】自有链接券"+data2, "校验优惠券title失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].belong"), "自有", "校验优惠券belong失败");
logger.info("校验title,belong成功");
//获取商品id
appItemId = String.valueOf(response.jsonPath().getString("data.list[0].id"));
//导入链接券码
developerCouponService.doLJAddGoodsCouponsNew("19515",appItemId);
//查看商品列表确认商品成功添加
Response response2 = developerObjectService.appItems("19515","【自动化】自有链接券"+data2);
Assert.assertEquals(response2.jsonPath().getString("data.list[0].title"), "【自动化】自有链接券"+data2, "校验优惠券title失败");
Assert.assertEquals(response2.jsonPath().getString("data.list[0].belong"), "自有", "校验优惠券belong失败");
Assert.assertEquals(response2.jsonPath().getString("data.list[0].remaind"), "10", "校验优惠券remaind失败");
Assert.assertEquals(response2.jsonPath().getString("data.list[0].type"), "coupon", "校验优惠券type失败");
logger.info("校验title,belong成功,remaind成功,type成功");
//删除
developerObjectService.ajaxDel(appItemId);
}
@Test(description = "添加自有优惠券普通券码")
public void e_添加自有普通券() throws Exception{
//添加优惠券
data3 = PublicMethod.data();
developerCouponService.doUpdateCoupon("【自动化】自有普通券"+data3);
//查看商品列表确认商品成功添加
Response response = developerObjectService.appItems("19515","【自动化】自有普通券"+data3);
Assert.assertEquals(response.jsonPath().getString("data.list[0].title"), "【自动化】自有普通券"+data3, "校验优惠券title失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].belong"), "自有", "校验优惠券belong失败");
logger.info("校验title,belong成功");
//获取商品id
appItemId = String.valueOf(response.jsonPath().getString("data.list[0].id"));
//导入普通的券码
developerCouponService.doPTAddGoodsCouponsNew("19515",appItemId);
//上传需要时间,休眠5秒
Thread.sleep(5000);
//查看商品列表确认商品成功添加
Response response2 = developerObjectService.appItems("19515","【自动化】自有普通券"+data3);
Assert.assertEquals(response2.jsonPath().getString("data.list[0].title"), "【自动化】自有普通券"+data3, "校验优惠券title失败");
Assert.assertEquals(response2.jsonPath().getString("data.list[0].belong"), "自有", "校验优惠券belong失败");
Assert.assertEquals(response2.jsonPath().getString("data.list[0].remaind"), "9", "校验优惠券remaind失败");
Assert.assertEquals(response2.jsonPath().getString("data.list[0].type"), "coupon", "校验优惠券type失败");
logger.info("校验title,belong成功,remaind成功,type成功");
//删除
developerObjectService.ajaxDel(appItemId);
}
@Test(description = "输入所有条件,新增加钱购优惠券")
public void f_加钱购优惠券() throws Exception{
data4 = PublicMethod.data();
developerCouponService.doJQGUpdateCoupon("【自动化】加钱购优惠券"+data4);
//查看商品列表确认商品成功添加
Response response = developerObjectService.appItems("19515","【自动化】加钱购优惠券"+data4);
//获取商品ID
appItemId = String.valueOf(response.jsonPath().getString("data.list[0].id"));
Assert.assertEquals(response.jsonPath().getString("data.list[0].title"), "【自动化】加钱购优惠券"+data4, "校验优惠券title失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].belong"), "自有", "校验优惠券belong失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].type"), "coupon", "校验优惠券type失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].titleDownTxt"), "88积分&nbsp;+&nbsp;20.0元", "校验加钱购status失败");
logger.info("校验title,belong成功");
//删除
developerObjectService.ajaxDel(appItemId);
}
}
package http.cases.SaasDeveloperTest;
import base.Config;
import utils.PublicMethod;
import http.service.Saas.DeveloperObjectService;
import base.DuibaLog;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
import org.testng.Assert;
import org.testng.annotations.Test;
/**
* 〈开发者后台--商品--添加、修改、删除积分实物测试〉
*
* @author wangxiaoshuang
*/
@ContextConfiguration(classes = Config.class)
public class 自有实物测试_DuibaTest extends AbstractTestNGSpringContextTests {
@Autowired
DeveloperObjectService objectService;
private DuibaLog logger = DuibaLog.getLogger();
//实物商品列表中的ID
private static String appItemId;
//实物上下架状态
private static String status;
private static String data;
@Test(description = "添加实物,放入仓库")
public void a_添加自有实物() throws Exception {
data = PublicMethod.data();
//新建实物商品---放入仓库
objectService.doUpdateObject("【自动化】自有实物"+data,"","no","0","1","0");
//查看商品列表确认商品成功添加
Response response =objectService.appItems("19515","【自动化】自有实物"+data);
//获取商品id
appItemId = String.valueOf(response.jsonPath().getString("data.list[0].id"));
status= String.valueOf(response.jsonPath().getString("data.list[0].status"));
Assert.assertEquals(response.jsonPath().getString("data.list[0].title"), "【自动化】自有实物"+data, "校验活动title失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].belong"), "自有", "校验活动belong失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].status"), "0", "校验活动status失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].type"), "object", "校验活动type失败");
logger.info("校验title,belong成功");
}
@Test(description = "上架实物商品或下架实物商品")
public void b_上下架实物() throws Exception{
//查看商品列表确认商品成功添加
Response response =objectService.appItems("19515","【自动化】自有实物"+data);
// String status = String.valueOf(response.jsonPath().getString("data.list[0].status"));
// appItemId = String.valueOf(response.jsonPath().getString("data.list[0].id"));
logger.info("status===="+status);
if(status.equals("0")){
objectService.standUp(appItemId,"up");
//查看商品列表,确认上架成功
Response response1 =objectService.appItems("19515","【自动化】自有实物"+data);
Assert.assertEquals(response1.jsonPath().getString("data.list[0].status"), "1", "校验上架实物失败");
Assert.assertEquals(response1.jsonPath().getString("data.list[0].statusText"), "上架", "校验上架实物失败");
logger.info("校验实物上架成功");
}else {
objectService.standUp(appItemId,"down");
//查看商品列表,确认下架成功
Response response2 =objectService.appItems("19515","【自动化】自有实物"+data);
Assert.assertEquals(response2.jsonPath().getString("data.list[0].status"), "0", "校验下架实物失败");
Assert.assertEquals(response2.jsonPath().getString("data.list[0].statusText"), "下架", "校验下架实物失败");
logger.info("校验实物下架成功");
}
}
@Test
public void c_删除实物() throws Exception{
objectService.ajaxDel(appItemId);
}
@Test(description = "添加加钱购实物后放入仓库")
public void d_加钱购实物放入仓库() throws Exception{
//新建实物商品---放入仓库
objectService.doUpdateObjectMoney("","no","100","9");
//查看商品列表确认商品成功添加
Response response =objectService.appItems("19515","【自动化】接口测试-加钱购");
//获取商品id
appItemId = String.valueOf(response.jsonPath().getString("data.list[0].id"));
status= String.valueOf(response.jsonPath().getString("data.list[0].status"));
Assert.assertEquals(response.jsonPath().getString("data.list[0].title"), "【自动化】接口测试-加钱购", "校验加钱购title失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].belong"), "自有", "校验加钱购belong失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].status"), "0", "校验加钱购status失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].titleDownTxt"), "100积分&nbsp;+&nbsp;9.0元", "校验加钱购status失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].type"), "object", "校验活动type失败");
logger.info("校验title,belong成功");
//删除商品
objectService.ajaxDel(appItemId);
}
@Test(description = "添加加钱购实物后直接上架")
public void e_加钱购实物上架() throws Exception{
//新建实物商品---放入仓库
objectService.doUpdateObjectMoney("","yes","100","9");
//查看商品列表确认商品成功添加
Response response =objectService.appItems("19515","【自动化】接口测试-加钱购");
//获取商品id
appItemId = String.valueOf(response.jsonPath().getString("data.list[0].id"));
status= String.valueOf(response.jsonPath().getString("data.list[0].status"));
Assert.assertEquals(response.jsonPath().getString("data.list[0].title"), "【自动化】接口测试-加钱购", "校验加钱购title失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].belong"), "自有", "校验加钱购belong失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].status"), "0", "校验加钱购status失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].titleDownTxt"), "100积分&nbsp;+&nbsp;9.0元", "校验加钱购status失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].type"), "object", "校验活动type失败");
logger.info("校验title,belong成功");
//删除商品
objectService.ajaxDel(appItemId);
}
}
package http.cases.SaasDeveloperTest;
import base.Config;
import utils.PublicMethod;
import http.service.Saas.DeveloperObjectService;
import http.service.Saas.DeveloperVirtualService;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
import org.testng.Assert;
import org.testng.annotations.Test;
/**
* 自有虚拟商品添加、修改、删除、上架或下架、查询操作
*/
@ContextConfiguration(classes = Config.class)
public class 自有虚拟商品测试_DuibaTest extends AbstractTestNGSpringContextTests {
@Autowired
DeveloperVirtualService developerVirtualService;
@Autowired
DeveloperObjectService developerObjectService;
//我的商品列表中的ID appItemId = String.valueOf(response.jsonPath().getString("data.list[0].id"));
private static String appItemId;
//实物上下架状态
private static String status;
private static String data;
private static String data2;
@Test(description = "添加单档位---加钱购虚拟商品")
public void a_添加单档位虚拟商品() throws Exception{
data = PublicMethod.data();
developerVirtualService.doUpdateVirtual("【自动化】加钱购自有虚拟商品"+data,"标识符100=10+1");
//查看商品列表确认商品成功添加
Response response =developerObjectService.appItems("19515","【自动化】加钱购自有虚拟商品"+data);
appItemId = String.valueOf(response.jsonPath().getString("data.list[0].id"));
Assert.assertEquals(response.jsonPath().getString("data.list[0].title"), "【自动化】加钱购自有虚拟商品"+data, "校验活动title失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].belong"), "自有", "校验活动belong失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].titleDownTxt"), "100积分&nbsp;+&nbsp;88.0元", "校验活动titleDownTxt失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].type"), "virtual", "校验活动type失败");
logger.info("校验title,belong成功");
}
@Test(description = "虚拟商品上架或下架")
public void b_虚拟商品上下架() throws Exception{
//查看商品列表确认商品成功添加
logger.info("status===="+status);
Response response =developerObjectService.appItems("19515","【自动化】加钱购自有虚拟商品"+data);
status= String.valueOf(response.jsonPath().getString("data.list[0].status"));
if(status.equals("0")){
developerObjectService.standUp(appItemId,"up");
//查看商品列表,确认上架成功
Response response1 =developerObjectService.appItems("19515","【自动化】加钱购自有虚拟商品"+data);
Assert.assertEquals(response1.jsonPath().getString("data.list[0].status"), "1", "校验上架实物失败");
Assert.assertEquals(response1.jsonPath().getString("data.list[0].statusText"), "上架", "校验上架实物失败");
logger.info("校验实物上架成功");
}else {
developerObjectService.standUp(appItemId,"down");
//查看商品列表,确认下架成功
Response response2 =developerObjectService.appItems("19515","【自动化】加钱购自有虚拟商品"+data);
Assert.assertEquals(response2.jsonPath().getString("data.list[0].status"), "0", "校验下架实物失败");
Assert.assertEquals(response2.jsonPath().getString("data.list[0].statusText"), "下架", "校验下架实物失败");
logger.info("校验实物下架成功");
}
}
@Test(description = "删除虚拟商品")
public void c_删除() throws Exception{
developerObjectService.ajaxDel(appItemId);
}
@Test(description = "添加多档位虚拟商品")
public void d_添加多档位虚拟商品() throws Exception{
String aloneGearTag="[{\"title\":\"档位1\",\"price\":\"标识100=10+1\",\"credits\":\"1\"},{\"title\":\"档位2\",\"price\":\"2\",\"credits\":\"2\"},{\"title\":\"档位3\",\"price\":\"3\",\"credits\":\"3\"}]";
data2 = PublicMethod.data();
developerVirtualService.doMoreUpdateVirtual("【自动化】自有虚拟商品"+data2,aloneGearTag);
//查看商品列表确认商品成功添加
Response response =developerObjectService.appItems("19515","【自动化】自有虚拟商品"+data2);
String appItemId = String.valueOf(response.jsonPath().getString("data.list[0].id"));
Assert.assertEquals(response.jsonPath().getString("data.list[0].title"), "【自动化】自有虚拟商品"+data2, "校验活动title失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].belong"), "自有", "校验活动belong失败");
logger.info("校验title,belong成功");
//删除
developerObjectService.ajaxDel(appItemId);
}
}
package http.cases.SaasDeveloperTest;
import base.Config;
import utils.PublicMethod;
import http.service.Saas.PlannedTaskService;
import base.DuibaLog;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
import org.testng.Assert;
import org.testng.annotations.Test;
/**
* Created by humengxin on 2018/9/3.
*/
@ContextConfiguration(classes = Config.class)
public class 计划任务_DuibaTest extends AbstractTestNGSpringContextTests {
@Autowired
PlannedTaskService plannedTaskService;
private static DuibaLog logger = DuibaLog.getLogger();
@Test(description = "添加商品类型计划任务")
public void a_添加商品类型计划任务() throws Exception {
String data=PublicMethod.data();
//查询实物商品集合
Response response= plannedTaskService.appItems();
// 获取到集合商品的ID
String sourceId = response.jsonPath().getString("data.list[0].id");
plannedTaskService.addTask("2239",sourceId);
//查看商品列表确认商品成功添加
Response response2=plannedTaskService.queryTasks("2239");
Assert.assertEquals(response2.jsonPath().getString("data[0].sourceName"),"【自动化】自有实物19:51:09", "校验名称失败");
Assert.assertEquals(response2.jsonPath().getString("data[0].sourceTypeName"),"商品", "校验类型失败");
logger.info("校验名称,类型成功");
//新建后删除测试数据
plannedTaskService.delTask("2239",sourceId);
}
@Test(description = "添加活动类型计划任务")
public void b_添加活动计划任务() throws Exception {
String data = PublicMethod.data();
//查询活动集合
Response response= plannedTaskService.list2();
// 获取到集合活动的ID
String sourceId = response.jsonPath().getString("data.list[0].id");
plannedTaskService.addTask2(sourceId);
//查看活动列表确认活动成功添加
Response response2=plannedTaskService.queryTasks("2239");
Assert.assertEquals(response2.jsonPath().getString("data[1].sourceName"),"自有刮刮乐", "校验名称失败");
Assert.assertEquals(response2.jsonPath().getString("data[1].sourceTypeName"),"活动工具", "校验类型失败");
logger.info("校验名称,类型成功");
//新建后删除测试数据
plannedTaskService.delTask("2239",sourceId);
}
@Test(description = "添加自定义链接类型计划任务")
public void c_添加自定义链接类型计划任务() throws Exception {
String data = PublicMethod.data();
//新建自定义链接计划任务
plannedTaskService.uploadBanner();
//查看列表是否成功添加
Response response=plannedTaskService.queryTasks("2239");
// 获取id
String sourceId=response.jsonPath().getString("data[0].sourceId");
//新建后删除测试数据
plannedTaskService.delTask("2239",sourceId);
}
@Test(description = "查看活动计划任务——活动规则")
public void d_查看活动规则() throws Exception {
String data = PublicMethod.data();
Response response= plannedTaskService.list2();
// 获取ID
String sourceId = response.jsonPath().getString("data.list[0].id");
plannedTaskService.addTask2(sourceId);
Response response2=plannedTaskService.queryTasks("2239");
plannedTaskService.rules("2239",sourceId,"appHdtool");
//新建后删除测试数据
plannedTaskService.delTask("2239",sourceId);
}
@Test(description = "删除计划任务")
public void e_删除计划任务() throws Exception {
String data = PublicMethod.data();
Response response= plannedTaskService.list2();
// 获取ID
String sourceId = response.jsonPath().getString("data.list[0].id");
plannedTaskService.addTask2(sourceId);
Response response2=plannedTaskService.queryTasks("2239");
plannedTaskService.delTask("2239",sourceId);
}
@Test(description = "预览计划任务")
public void f_预览计划任务() throws Exception {
String data = PublicMethod.data();
Response response= plannedTaskService.list2();
// 获取ID
String sourceId = response.jsonPath().getString("data.list[0].id");
plannedTaskService.addTask2(sourceId);
Response response2=plannedTaskService.queryTasks("2239");
// 获取id
String id=response2.jsonPath().getString("data[0].id");
plannedTaskService.preview("2239",id,sourceId,"appHdtool");
}
}
package http.cases.SaasDeveloperTest;
import base.Config;
import http.service.Saas.UpdateAppInfoService;
import base.DuibaLog;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
import org.testng.Assert;
import org.testng.annotations.Test;
@ContextConfiguration(classes = Config.class)
public class 设置_应用信息_DuibaTest extends AbstractTestNGSpringContextTests {
private DuibaLog logger = DuibaLog.getLogger();
@Autowired
UpdateAppInfoService updateAppInfoService;
//设置--保存应用信息
@Test
public void 保存应用信息() throws Exception{
String appId="19515";
String earnCreditsUrl="https://www.baidu.com/s?ie=utf-8&f=8&rsv_bp=1&tn=baidu&wd=www.baidu.com";
String creditsDetailUrl="https://www.baidu.com/s?ie=utf-8&f=8&rsv_bp=1&tn=baidu&wd=www.baidu.com";
Response response= updateAppInfoService.appInfo(appId);
Boolean isDecimalOpen=response.jsonPath().getBoolean("data.isDecimalOpen");
logger.info("******"+isDecimalOpen);
String unitName = isDecimalOpen ? "元" : "积分";
updateAppInfoService.UpdateAppInfo(appId,unitName,earnCreditsUrl,creditsDetailUrl,isDecimalOpen);
Response response2= updateAppInfoService.appInfo(appId);
Assert.assertEquals(response2.jsonPath().getString("data.name"), "(saas)接口自动化应用", "校验应用名称失败");
Assert.assertEquals(response2.jsonPath().getString("data.earnCreditsLetter"), "积分文案&2", "校验积分文案失败");
Assert.assertEquals(response2.jsonPath().getString("data.creditsDetailUrl"), "https://www.baidu.com/s?ie=utf-8&f=8&rsv_bp=1&tn=baidu&wd=www.baidu.com", "校验积分明细链接失败");
logger.info("保存应用信息成功");
}
}
package http.cases.SaasDeveloperTest;
import base.Config;
import utils.PublicMethod;
import http.service.Saas.ExpressTemplateService;
import base.DuibaLog;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
import org.testng.Assert;
import org.testng.annotations.Test;
/**
* 〈开发者后台--配置--更多--运费模板测试〉
*
* @author wangxiaoshuang
*/
@ContextConfiguration(classes = Config.class)
public class 设置运费模板_DuibaTest extends AbstractTestNGSpringContextTests {
@Autowired
ExpressTemplateService expressTemplateService;
private DuibaLog logger = DuibaLog.getLogger();
private static String data = PublicMethod.data();
//运费模板ID
private static String modelId;
//获取token
public String 获取token() throws Exception {
Response response=expressTemplateService.EditExpressTemplate("");
String token= String.valueOf(response.jsonPath().getString("data.token"));
return token;
}
//添加运费模板
@Test
public void a_创建模板() throws Exception {
//获取token
String token=获取token();
logger.info("token为:"+token);
//调用添加方法
expressTemplateService.SaveExpressTemplate("","19515",token,"测试模板wxs"+data,"");
//查询模板列表,获取ID
Response HdResponse = expressTemplateService.ExpressTemplateConfig();
modelId= HdResponse.jsonPath().getString("data.list[0].id");
//验证添加成功
Assert.assertEquals(HdResponse.jsonPath().getString("data.list[0].name"), "测试模板wxs"+data, "校验活动name失败");
Assert.assertEquals(HdResponse.jsonPath().getString("data.list[0].defaultExpressPrice"), "1000", "defaultExpressPrice");
// logger.info("校验创建模板成功,进行修改");
}
//修改运费模板
@Test
public void b_修改模板() throws Exception{
// logger.info("获取添加的ID**********"+modelId);
//调用修改方法
Response response=expressTemplateService.EditExpressTemplate(modelId);
//获取token
String token= String.valueOf(response.jsonPath().getString("data.token"));
//保存修改内容
expressTemplateService.SaveExpressTemplate(modelId,"19515",token,"测试模板wxs-修改"+data,modelId);
//查询列表,判断是否编辑成功
Response response1= expressTemplateService.ExpressTemplateConfig();
String modelId2= response1.jsonPath().getString("data.list[0].id");
Assert.assertEquals(response1.jsonPath().getString("data.list[0].name"), "测试模板wxs-修改"+data, "校验活动name失败");
Assert.assertEquals(response1.jsonPath().getString("data.list[0].defaultExpressPrice"), "1000", "defaultExpressPrice");
// logger.info("修改后的ID**********"+modelId2);
}
//删除运费模板
@Test
public void c_删除模板() throws Exception{
// logger.info("删除ID**********"+modelId);
//调用删除方法,传入模板ID
expressTemplateService.ajaxDel(modelId);
}
}
......@@ -59,7 +59,7 @@ public class ContractSign_signTest extends DuibaTestBase {
// }
@Test(description = "截止报名测试, 活动ID=3", priority = 10)
//@Test(description = "截止报名测试, 活动ID=3", priority = 10)
public void 截止报名测试() throws Exception{
Map<String,String> map = new HashMap<>();
......@@ -271,9 +271,11 @@ public class ContractSign_signTest extends DuibaTestBase {
map.put("openStatus", "true");
map.put("gradientAmountList","");
map.put("freeJoinLimit", "0");
map.put("enableAmpifyCard","false");
map.put("openType", "0");
logger.info("请求save接口");
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.ssoLogin()).params(map).post("https://mng.duibatest.com.cn/newmanager/signContract/save");
Response response = given().contentType("application/json").cookies(authorization.ssoLogin()).params(map).post("https://mng.duibatest.com.cn/newmanager/signContract/save");
try {
Assert.assertEquals(response.jsonPath().getString("success"), "true", "/signContract/save接口失败");
} catch (Exception e) {
......
......@@ -113,13 +113,13 @@ public class NewActivityService {
return response;
}
public Response doJoin2( String activityId,String token,String orderId) throws Exception{
public Response doJoin2( int uid,String activityId,String token,String orderId) throws Exception{
Map<String,String> map = new HashMap<>();
map.put("activityId",activityId);
map.put("token",token);
map.put("againOrderId",orderId);
logger.info("请求/hdtool/doJoin接口,activityId="+activityId);
Response response = given().cookies(authorization.dafuwengLogin(2720)).params(map).post(url+"/hdtool/doJoin");
Response response = given().cookies(authorization.dafuwengLogin(uid)).params(map).post(url+"/hdtool/doJoin");
try{
Assert.assertEquals(response.jsonPath().getString("success"),"true");
}catch(Exception e){
......
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