Commit 36f8005f authored by 周松波's avatar 周松波

Merge branch 'develop' into songbo

parents 3830d172 9ecb0389
......@@ -267,6 +267,13 @@
<artifactId>java-gitlab-api</artifactId>
<version>1.3.8</version>
</dependency>
<dependency>
<groupId>cn.com.duiba</groupId>
<artifactId>wolf</artifactId>
<version>2.2.25</version>
</dependency>
</dependencies>
<build>
......
package base;
import cn.com.duiba.wolf.utils.BlowfishUtils;
import org.apache.commons.dbcp2.BasicDataSource;
/**
* Created by mabo on 2018/12/27
*/
public class DataSource extends BasicDataSource {
private String key = "CNxgrtFG2nYQUfu";
private DuibaLog logger = DuibaLog.getLogger();
@Override
public void setPassword(String password) {
password = BlowfishUtils.decryptBlowfish(password,key);
super.setPassword(password);
}
@Override
public void setUsername(String username) {
username = BlowfishUtils.decryptBlowfish(username,key);
super.setUsername(username);
}
public static void main(String[] args) {
}
}
......@@ -24,7 +24,7 @@ import static com.codeborne.selenide.Selenide.$;
* Created by mabo on 2018/11/20
*/
public class DuibaBaseUi extends DuibaBase{
RemoteWebDriver driver= WebDriverFactory.createWebDriver(WebDriverType.MOBLIE, ProxyFactory.createProxy());
public RemoteWebDriver driver= WebDriverFactory.createWebDriver(WebDriverType.MOBLIE, ProxyFactory.createProxy());
public ITestResult result;
......@@ -120,7 +120,7 @@ public class DuibaBaseUi extends DuibaBase{
int i=5;
while(i>0){
try {
$(By.xpath(xpath)).click();
driver.findElementByXPath(xpath).click();
logger.info("ByXpath:"+xpath+" click");
return;
} catch (Exception e) {
......@@ -156,6 +156,22 @@ public class DuibaBaseUi extends DuibaBase{
}
}
public final void clickByClassNoWait(String name) throws Exception{
String xpath = "//*[@class='"+name+"']";
try {
driver.findElementByXPath(xpath).click();
logger.info("xpath:"+xpath+" click");
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 点击,通过属性,包含
......@@ -195,6 +211,57 @@ public class DuibaBaseUi extends DuibaBase{
driver.switchTo().window(handle);
}
/**
* 校验元素是否存在
*/
public boolean ElementExist(String xpath)
{
int i=5;
while (i>0){
try {
logger.info("校验,xpath:"+xpath);
driver.findElementByXPath(xpath);
return true;
} catch (Exception e) {
sleep(1);
i--;
}
}
return false;
}
/**
* 校验元素,通过text
* @param text
* @return
*/
public boolean isExistByText(String text){
String xpath = "//*[text()='"+text+"']";
return ElementExist(xpath);
}
/**
* 校验元素,通过class
* @param byclass
* @return
*/
public boolean isExistByClass(String byclass){
String xpath = "//*[@class='"+byclass+"']";
return ElementExist(xpath);
}
/**
* 刷新页面
*/
public void refresh(){
driver.navigate().refresh();
}
}
......@@ -36,7 +36,7 @@ public class MysqlConnPool {
int maxtotal;
public static BasicDataSource bds;
public static DataSource bds;
public DuibaLog log = DuibaLog.getLogger();
public void initDataSource(){
......@@ -48,7 +48,7 @@ public class MysqlConnPool {
// return;
// }
log.info("初始化数据库");
BasicDataSource bds = new BasicDataSource();
DataSource bds = new DataSource();
bds.setDriverClassName(DRIVER);
bds.setUrl(URL);
bds.setUsername(USERNAME);
......
......@@ -88,7 +88,7 @@ public class 自有活动出奖_DuibaTest extends DuibaTestBase {
j--;
}
Assert.assertEquals(flowWork,"SupplierExchange-started","数据库主订单流程节点校验失败");
Assert.assertEquals(String.valueOf(selectResult2.get("biz_params")),"胡梦新:18258853242:浙江:杭州市:西湖区:西溪街道:数娱大厦 ","数据库主订单biz_params校验失败");
Assert.assertEquals(String.valueOf(selectResult2.get("biz_params")),"胡梦新:18258853242:浙江:杭州市:西湖区:西溪街道:数娱大厦 ","数据库主订单biz_params校验失败");
Assert.assertEquals(String.valueOf(selectResult2.get("pay_status")),"none","数据库主订单pay_status校验失败");
Assert.assertEquals(String.valueOf(selectResult2.get("status")),"consume_success","数据库主订单status校验失败");
......
......@@ -387,7 +387,7 @@ public class ActiveGroup_FloorTest extends DuibaTestBase {
}
@Test(dependsOnMethods = { "A_创建活动楼层皮肤" })
@Test
public void B_手机端活动() throws Exception {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");//设置日期格式
logger.info(df.format(new Date()));
......@@ -444,7 +444,7 @@ public class ActiveGroup_FloorTest extends DuibaTestBase {
}
@Test(dependsOnMethods = { "B_手机端活动" })
@Test
public void C_删除活动楼层皮肤() throws Exception {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");//设置日期格式
......
......@@ -154,7 +154,7 @@ public class Banner_FloorTest extends DuibaTestBase {
}
@Test(dependsOnMethods = { "A_创建banner楼层皮肤" })
@Test
public void B_banner楼层活动校验() throws Exception {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");//设置日期格式
......@@ -212,7 +212,7 @@ public class Banner_FloorTest extends DuibaTestBase {
}
@Test(dependsOnMethods = { "B_banner楼层活动校验" })
@Test
public void C_banner商品校验() throws Exception {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");//设置日期格式
......
......@@ -342,7 +342,7 @@ public class Coupon_FloorTest extends DuibaTestBase {
}
@Test(dependsOnMethods = { "A_创建优惠券楼层皮肤" })
@Test
public void B_优惠券手机端() throws Exception {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");//设置日期格式
logger.info(df.format(new Date()));
......@@ -392,7 +392,7 @@ public class Coupon_FloorTest extends DuibaTestBase {
}
@Test(dependsOnMethods = { "B_优惠券手机端" })
@Test
public void C_删除优惠券楼层皮肤() throws Exception {
......
......@@ -230,7 +230,7 @@ public class Game_FloorTest extends DuibaTestBase {
}
@Test(dependsOnMethods = { "A_创建游戏楼层皮肤" })
@Test
public void B_游戏手机端() throws Exception {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");//设置日期格式
logger.info(df.format(new Date()));
......@@ -272,7 +272,7 @@ public class Game_FloorTest extends DuibaTestBase {
}
@Test(dependsOnMethods = { "B_游戏手机端" })
@Test
public void C_删除游戏楼层皮肤() throws Exception {
......
......@@ -222,7 +222,7 @@ public class Icon_FloorTest extends DuibaTestBase {
}
@Test(dependsOnMethods = { "A_创建icon楼层皮肤" })
@Test
public void B_icon添加图标() throws Exception {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");//设置日期格式
......@@ -296,7 +296,7 @@ public class Icon_FloorTest extends DuibaTestBase {
}
@Test(dependsOnMethods = { "B_icon添加图标" })
@Test
public void C_icon编辑图标() throws Exception {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");//设置日期格式
logger.info(df.format(new Date()));
......@@ -352,7 +352,7 @@ public class Icon_FloorTest extends DuibaTestBase {
Assert.assertEquals(map.get("logo"),"//yun.dui88.com/images/201806/9lz5ifre0h.png","今日必抢logo校验错误");
}
@Test(dependsOnMethods = { "C_icon编辑图标" })
@Test
public void D_icon删除图标() throws Exception {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");//设置日期格式
logger.info(df.format(new Date()));
......@@ -388,7 +388,7 @@ public class Icon_FloorTest extends DuibaTestBase {
}
@Test(dependsOnMethods = { "D_icon删除图标" })
@Test
public void E_删除icon楼层皮肤() throws Exception {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");//设置日期格式
logger.info(df.format(new Date()));
......
......@@ -362,7 +362,7 @@ public class Item_FloorTest extends DuibaTestBase {
}
@Test(dependsOnMethods = { "A_item创建楼层皮肤" })
@Test
public void B_item手机端() throws Exception {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");//设置日期格式
......@@ -404,7 +404,7 @@ public class Item_FloorTest extends DuibaTestBase {
}
@Test(dependsOnMethods = { "B_item手机端" })
@Test
public void C_item删除楼层皮肤() throws Exception {
......
......@@ -806,7 +806,7 @@ public class Seckill_FloorTest extends DuibaTestBase {
response = floorService.switchOpenState(authorization.ssoLogin(),skinId,"true");
}
@Test(dependsOnMethods = { "A_Seckill创建楼层皮肤" })
@Test
public void B_Seckill手机端() throws Exception {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");//设置日期格式
logger.info(df.format(new Date()));
......@@ -849,7 +849,7 @@ public class Seckill_FloorTest extends DuibaTestBase {
}
@Test(dependsOnMethods = { "B_Seckill手机端" })
@Test
public void C_Seckill删除楼层皮肤() throws Exception {
......
......@@ -244,7 +244,7 @@ public class Showcase_FloorTest extends DuibaTestBase {
}
@Test(dependsOnMethods = { "A_Showcase创建楼层皮肤" })
@Test
public void B_Showcase手机端() throws Exception {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");//设置日期格式
......@@ -289,7 +289,7 @@ public class Showcase_FloorTest extends DuibaTestBase {
}
@Test(dependsOnMethods = { "B_Showcase手机端" })
@Test
public void C_Showcase删除楼层皮肤() throws Exception {
......
......@@ -510,7 +510,7 @@ public class Sign_FloorTest extends DuibaTestBase {
}
@Test(dependsOnMethods = { "A_sign创建楼层皮肤" })
@Test
public void B_sign手机端() throws Exception {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");//设置日期格式
logger.info(df.format(new Date()));
......@@ -545,7 +545,7 @@ public class Sign_FloorTest extends DuibaTestBase {
}
@Test(dependsOnMethods = { "B_sign手机端" })
@Test
public void C_sign删除楼层皮肤() throws Exception {
......
package http.cases.GoodsAndTradeTest;
import base.Config;
import base.DuibaLog;
import base.DuibaTestBase;
import http.service.goods.DuibaDoUpdateCoupon;
import http.service.goods.DuibaList;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.testng.Assert;
import utils.PublicMethod;
@ContextConfiguration(classes = Config.class)
public class 供应商优惠券 extends DuibaTestBase {
@Autowired
DuibaDoUpdateCoupon duibaDoUpdateCoupon;
@Autowired
DuibaList duibaList;
private DuibaLog logger = DuibaLog.getLogger();
private static String data;
private static String itemId;
//新增链接券
public void 供应商链接券() throws Exception{
data = PublicMethod.data();
String name="[自动化]供应商链接券"+data;
//添加优惠券接口
duibaDoUpdateCoupon.doUpdateCouponLianjie(name);
//查询列表,验证是否添加成功
Response response =duibaList.listIndex("admin",name);
//获取商品ID
itemId = String.valueOf(response.jsonPath().getString("data.page.rows[0].itemDto.id"));
//校验数据
Assert.assertEquals(response.jsonPath().getString("data.page.rows[0].itemDto.name"), "【自动化】供应商链接券"+data, "校验优惠券name失败");
Assert.assertEquals(response.jsonPath().getString("data.page.rows[0].itemDto.type"), "coupon", "校验优惠券类型失败");
Assert.assertEquals(response.jsonPath().getString("data.page.rows[0].itemDto.remaining"), "100", "校验优惠券库存失败");
Assert.assertEquals(response.jsonPath().getString("data.page.rows[0].itemDto.version"), "1", "校验优惠券版本(新版本展示1,旧版本0失败)");
Assert.assertEquals(response.jsonPath().getString("data.page.rows[0].itemDto.actualPrice"), "10000", "校验优惠券供货价失败");
Assert.assertEquals(response.jsonPath().getString("data.page.rows[0].itemDto.facePrice"), "11000", "校验优惠券版本建议零售价失败");
logger.info("校验title,belong成功");
}
//新增重复券
public void 供应商重复券() throws Exception{
data = PublicMethod.data();
String name="[自动化]供应商重复券"+data;
//添加优惠券接口
duibaDoUpdateCoupon.doUpdateCouponChongfu(name);
//查询列表,验证是否添加成功
Response response =duibaList.listIndex("admin",name);
//获取商品ID
itemId = String.valueOf(response.jsonPath().getString("data.page.rows[0].itemDto.id"));
//校验数据
Assert.assertEquals(response.jsonPath().getString("data.page.rows[0].itemDto.name"), "【自动化】供应商重复券"+data, "校验优惠券name失败");
Assert.assertEquals(response.jsonPath().getString("data.page.rows[0].itemDto.type"), "coupon", "校验优惠券类型失败");
Assert.assertEquals(response.jsonPath().getString("data.page.rows[0].itemDto.remaining"), "200", "校验优惠券库存失败");
Assert.assertEquals(response.jsonPath().getString("data.page.rows[0].itemDto.version"), "1", "校验优惠券版本(新版本展示1,旧版本0失败)");
Assert.assertEquals(response.jsonPath().getString("data.page.rows[0].itemDto.actualPrice"), "8800", "校验优惠券供货价失败");
Assert.assertEquals(response.jsonPath().getString("data.page.rows[0].itemDto.facePrice"), "18800", "校验优惠券版本建议零售价失败");
logger.info("校验title,belong成功");
}
//新增重复券
public void 供应商普通券() throws Exception{
data = PublicMethod.data();
String name="[自动化]供应商普通券"+data;
//添加优惠券接口
duibaDoUpdateCoupon.doUpdateCouponChongfu(name);
//查询列表,验证是否添加成功
Response response =duibaList.listIndex("admin",name);
//获取商品ID
itemId = String.valueOf(response.jsonPath().getString("data.page.rows[0].itemDto.id"));
//校验数据
Assert.assertEquals(response.jsonPath().getString("data.page.rows[0].itemDto.name"), "【自动化】供应商普通券"+data, "校验优惠券name失败");
Assert.assertEquals(response.jsonPath().getString("data.page.rows[0].itemDto.type"), "coupon", "校验优惠券类型失败");
Assert.assertEquals(response.jsonPath().getString("data.page.rows[0].itemDto.remaining"), "9", "校验优惠券库存失败");
Assert.assertEquals(response.jsonPath().getString("data.page.rows[0].itemDto.version"), "1", "校验优惠券版本(新版本展示1,旧版本0失败)");
Assert.assertEquals(response.jsonPath().getString("data.page.rows[0].itemDto.actualPrice"), "3600", "校验优惠券供货价失败");
Assert.assertEquals(response.jsonPath().getString("data.page.rows[0].itemDto.facePrice"), "7200", "校验优惠券版本建议零售价失败");
logger.info("校验title,belong成功");
}
//删除链接券
public void 删除链接券() throws Exception{
duibaDoUpdateCoupon.deleteItem(itemId);
}
}
......@@ -123,15 +123,17 @@ public class 自有优惠券测试_ExchangeTest extends AbstractTestNGSpringCont
logger.info("校验title,belong成功");
//获取商品id
appItemId = String.valueOf(response.jsonPath().getString("data.list[0].id"));
//导入普通的券码
developerCouponService.doPTAddGoodsCouponsNew("19515",appItemId);
Response quanma =developerCouponService.doPTAddGoodsCouponsNew("19515",appItemId);
String remaind= String.valueOf(quanma.jsonPath().getString("data.totalNum"));
//上传需要时间,休眠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].remaind"), remaind, "校验优惠券remaind失败");
Assert.assertEquals(response2.jsonPath().getString("data.list[0].type"), "coupon", "校验优惠券type失败");
logger.info("校验title,belong成功,remaind成功,type成功");
//删除
......
package http.cases.GoodsAndTradeTest;
import base.Config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
import org.testng.annotations.Test;
import java.text.SimpleDateFormat;
import java.util.Date;
@ContextConfiguration(classes = Config.class)
public class 自有卡券库 extends AbstractTestNGSpringContextTests {
@Value("${hdserver.host}")
String hdHost;
@Test
public void t333(){
Date date=new Date();
SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM--dd");
simpleDateFormat.format(date);
System.out.println("---------"+simpleDateFormat.format(date));
}
}
package http.cases.GoodsAndTradeTest;
import base.Config;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
@ContextConfiguration(classes = Config.class)
public class 自有实物商品 extends AbstractTestNGSpringContextTests {
}
......@@ -170,7 +170,7 @@ public class 出奖订单测试_DuibaTest extends DuibaTestBase {
}
Assert.assertEquals(flowWork,"SupplierExchange-started","数据库主订单流程节点校验失败");
Assert.assertEquals(String.valueOf(selectResult2.get("item_id")),"27131","数据库主订单奖项id校验失败");
Assert.assertEquals(String.valueOf(selectResult2.get("biz_params")),"胡梦新:18258853242:浙江:杭州市:西湖区:西溪街道:数娱大厦 ","数据库主订单biz_params校验失败");
Assert.assertEquals(String.valueOf(selectResult2.get("biz_params")),"胡梦新:18258853242:浙江:杭州市:西湖区:西溪街道:数娱大厦 ","数据库主订单biz_params校验失败");
Assert.assertEquals(String.valueOf(selectResult2.get("pay_status")),"prereduce","数据库主订单pay_status校验失败");
Assert.assertEquals(String.valueOf(selectResult2.get("status")),"consume_success","数据库主订单status校验失败");
......
......@@ -136,7 +136,7 @@ public class 新旧集卡_发卡_DuibaTest extends DuibaTestBase {
}
@Test
//@Test
public void 活动工具发旧集卡_扣积分() throws Exception{
String activityId = "37274";
......@@ -172,7 +172,7 @@ public class 新旧集卡_发卡_DuibaTest extends DuibaTestBase {
@Test
//@Test
public void 活动工具发新集卡_扣积分() throws Exception{
String activityId = "37275";
......
......@@ -306,6 +306,7 @@ public class pk_押注测试_AccessTest extends DuibaTestBase {
doJoinResponse.prettyPrint();
Assert.assertEquals(doJoinResponse.jsonPath().getString("code").toString(),"100060");
clear(consumerIds);
}
......@@ -332,7 +333,6 @@ public class pk_押注测试_AccessTest extends DuibaTestBase {
}
// @AfterMethod
@AfterClass
public void tearDown() {
......
/**
* Copyright (C), 2015-2018
* FileName: pk_瓜分红包_首页中奖弹层测试_AccessTest
* Author: qianwenjun
* Date: 2018/12/22 12:38
* Description:
*/
package http.cases.PkTest;
import base.DuibaLog;
import base.DuibaTestBase;
import com.alibaba.fastjson.JSONObject;
import http.model.PkPopPrizeVo;
import http.service.Activity.PkService;
import http.service.Manager.EditManagerInfoService;
import http.service.Manager.PkActivityService;
import http.service.hd.DeveloperConfigService;
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.Test;
import utils.GetCookieUtil;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 〈〉
*
* @author qianwenjun
* @create 2018/12/22
* @since 1.0.0
*/
public class pk_瓜分红包_发券测试 extends DuibaTestBase {
@Autowired
PkService pkService;
@Autowired
PkActivityService pkActivityService;
@Autowired
DeveloperConfigService developerConfigService;
@Autowired
EditManagerInfoService editManagerInfoService;
private static DuibaLog logger = DuibaLog.getLogger();
private Integer user01 = 5447;//appid=21982
private Integer user02 = 5448;//appid=21982
// private Integer user03 = 5449;//appid=21982
//
// private Integer user04 = 5450;//appid=21982
List<String> newBetIds = new ArrayList<>();
private String consumerIds = "";
@Test(priority = 0)
public void 瓜分红包_首页不中奖_发券() throws Exception{
String newBetId = "";
List<String> optionsIds = new ArrayList<>();
String groupId = "199";
newBetId = createPk("2","2020-08-12 00:00:00",groupId);
newBetIds.add(newBetId);
List<Map<String,Object>> pks = jdbc.findModeResult("select * from act_com_conf.tb_bet_option where bet_id = ?",newBetId);
logger.info("pk活动信息为"+JSONObject.toJSONString(pks));
for (int i=0;i<pks.size();i++){
optionsIds.add(pks.get(i).get("id").toString());
}
logger.info("pk活动id为:"+newBetId+",选项id为:"+ optionsIds.toString());
Response res1 = pkService.doJoin(user01,newBetId,optionsIds.get(0));
Response res2 = pkService.doJoin(user02,newBetId,optionsIds.get(1));
this.modifyOpenPrizeTime(newBetId,60);
//调用开奖接口
Response doDrowRresponse = pkActivityService.doDraw();
Assert.assertEquals(doDrowRresponse.jsonPath().getString("success"),"true","开奖结果校验失败");
Assert.assertEquals(doDrowRresponse.jsonPath().getString("data"),"开奖中。。。","开奖messag校验失败");
Thread.sleep(8000);
Response popRes = pkService.popup(user02);
popRes.prettyPrint();
Assert.assertEquals(popRes.jsonPath().getString("data.show"),"false","校验是否展示弹层失败");
Assert.assertEquals(popRes.jsonPath().getString("data.totalBonus"),"0.0","校验红包值失败");
Assert.assertEquals(popRes.jsonPath().getString("data.drawType"),"0","校验开奖类型失败");
Assert.assertEquals(popRes.jsonPath().getString("data.lucky"),"true","校验不发福袋失败失败");
Assert.assertEquals(popRes.jsonPath().getString("data.prizeList"),null,"校验中奖list为null");
Response popRes1 = pkService.popup(user01);
popRes1.prettyPrint();
Assert.assertEquals(popRes1.jsonPath().getString("data.show"),"true","校验是否展示弹层失败");
Assert.assertEquals(popRes1.jsonPath().getString("data.totalBonus"),"0.1","校验红包值失败");
Assert.assertEquals(popRes1.jsonPath().getString("data.drawType"),"0","校验开奖类型失败");
Assert.assertEquals(popRes1.jsonPath().getString("data.lucky"),"false","校验不发福袋失败失败");
List<PkPopPrizeVo> prizeVoList = popRes.jsonPath().getList("data.prizeList",PkPopPrizeVo.class);
logger.info("开奖结果的list为:"+JSONObject.toJSONString(prizeVoList));
for (PkPopPrizeVo prize:prizeVoList){
if (prize.getBonusType().equals("2")){
Assert.assertEquals(prize.getTotalBonus(),"10","校验list的瓜分红包金额失败");
}
}
}
@Test
public void 押注_新用户首次参与测试() throws Exception{
Map<String,String> user = this.createUser();
consumerIds = user.get("consumerId");
logger.info("consumerIds的信息为"+consumerIds);
String newBetId = "";
List<String> optionsIds = new ArrayList<>();
String groupId = "200";
newBetId = createPk("2","2020-08-12 00:00:00",groupId);
newBetIds.add(newBetId);
List<Map<String,Object>> pks = jdbc.findModeResult("select * from act_com_conf.tb_bet_option where bet_id = ?",newBetId);
logger.info("pk活动信息为"+JSONObject.toJSONString(pks));
for (int i=0;i<pks.size();i++){
optionsIds.add(pks.get(i).get("id").toString());
}
logger.info("pk活动id为:"+newBetId+",选项id为:"+ optionsIds.toString());
Response doJoinResponse = pkService.doJoin2(Integer.valueOf(user.get("uid")),newBetId,optionsIds.get(0));
doJoinResponse.prettyPrint();
Assert.assertEquals(doJoinResponse.jsonPath().getString("code").toString(),"100060");
}
public String createPk(String bounsType,String endTime,String groupId) throws Exception {
Response betResponse = pkActivityService.betForSetUp(bounsType,endTime);
logger.info("新建pk活动的结果信息为"+ JSONObject.toJSONString(betResponse.prettyPrint()));
betResponse.prettyPrint();
String betId = betResponse.jsonPath().getString("data");
logger.info("newBetId的信息为"+betId);
Response betRelation = pkActivityService.betGroupRelation(betId,endTime,groupId);
Response modifyStatusResponse = pkActivityService.modifySatus(betId);
return betId;
}
public void modifyOpenPrizeTime(String betId,int x) throws Exception{
String endTimeStr = "2018-11-26 20:24:39";
Boolean result1 = jdbc.update("update act_com_conf.tb_bet_config set end_time = ? where id = ?\n",endTimeStr,betId);
Boolean result2 = jdbc.update("update act_com_conf.tb_bet_group_relation set end_time = ? where bet_id = ?\n",endTimeStr,betId);
}
public Map<String,String> createUser() throws Exception{
Map<String,String> map = new HashMap<>();
Response response = editManagerInfoService.createUser("pk活动首次参与用户发券","103");
Map<String,Object> user = jdbc.findSimpleResult("select * from dafuweng.user where name = 'pk活动首次参与用户发券' and app_id = '103'\n");
String uid = user.get("id").toString();
String url = GetCookieUtil.genUrl(uid,"3NhqvHsNBDfcAJBUvdxmAs8mHq2d");
JSONObject cookie = GetCookieUtil.getConsumerIdFromCookie(url);
map.put("uid",uid);
map.put("consumerId",cookie.get("cid").toString());
logger.info("用户信息为,uid="+uid+"consumerId="+cookie.get("cid").toString());
return map;
}
public void clear(String comsumerIds) throws Exception{
Boolean res = jdbc.update("delete from dafuweng.user where name = 'pk活动首次参与用户' and app_id = '103'");
String dbName = "new_consumer.consumer_"+ String.format("%04d", Long.parseLong(comsumerIds)/10000000);
logger.info("用户的分表名dbName为"+dbName);
Boolean res1 = jdbc.update("delete from "+dbName+" where id = ?",comsumerIds);
}
// @AfterClass
public void tearDown() {
try {
for (String newBetId:newBetIds){
Boolean result1 = jdbc.update("delete from act_com_conf.tb_bet_option where bet_id = ?",newBetId);
Boolean result4 = jdbc.update("delete from act_record.tb_bet_record where bet_id = ?",newBetId);
Boolean result5 = jdbc.update("delete from bet_activity.tb_bet_result where bet_id = ?",newBetId);
Boolean result2 = jdbc.update("delete from act_com_conf.tb_bet_group_relation where bet_id = ?",newBetId);
Boolean result3 = jdbc.update("delete from act_com_conf.tb_bet_config where id = ?",newBetId);
}
clear(consumerIds);
} catch (SQLException e) {
e.printStackTrace();
} catch (Exception e){
e.printStackTrace();
}
}
}
\ No newline at end of file
/**
* Copyright (C), 2015-2018
* FileName: pk_瓜分红包_首页中奖弹层测试_AccessTest
* Author: qianwenjun
* Date: 2018/12/22 12:38
* Description:
*/
package http.cases.PkTest;
import base.DuibaLog;
import base.DuibaTestBase;
import com.alibaba.fastjson.JSONObject;
import http.model.PkPopPrizeVo;
import http.service.Activity.PkService;
import http.service.Manager.PkActivityService;
import io.restassured.response.Response;
import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* 〈〉
*
* @author qianwenjun
* @create 2018/12/22
* @since 1.0.0
*/
public class pk_瓜分红包_首页中奖弹层测试_AccessTest extends DuibaTestBase {
@Autowired
PkService pkService;
@Autowired
PkActivityService pkActivityService;
private static DuibaLog logger = DuibaLog.getLogger();
private Integer user01 = 5434;//appid=21982
private String consumerId01 = "100122071";
private Integer user02 = 5435;//appid=21982
private String consumerId02 = "100122072";
private Integer user03 = 5449;//appid=21982
private Integer user04 = 5450;//appid=21982
List<String> newBetIds = new ArrayList<>();
@Test(priority = 0)
public void 瓜分红包_首页中奖() throws Exception{
String newBetId = "";
List<String> optionsIds = new ArrayList<>();
String groupId = "194";
newBetId = createPk("2","2020-08-12 00:00:00",groupId);
newBetIds.add(newBetId);
List<Map<String,Object>> pks = jdbc.findModeResult("select * from act_com_conf.tb_bet_option where bet_id = ?",newBetId);
logger.info("pk活动信息为"+JSONObject.toJSONString(pks));
for (int i=0;i<pks.size();i++){
optionsIds.add(pks.get(i).get("id").toString());
}
logger.info("pk活动id为:"+newBetId+",选项id为:"+ optionsIds.toString());
Response res1 = pkService.doJoin(user03,newBetId,optionsIds.get(0));
this.modifyOpenPrizeTime(newBetId,60);
//调用开奖接口
Response doDrowRresponse = pkActivityService.doDraw();
Assert.assertEquals(doDrowRresponse.jsonPath().getString("success"),"true","开奖结果校验失败");
Assert.assertEquals(doDrowRresponse.jsonPath().getString("data"),"开奖中。。。","开奖messag校验失败");
Thread.sleep(8000);
Response popRes = pkService.popup(user03);
popRes.prettyPrint();
Assert.assertEquals(popRes.jsonPath().getString("data.show"),"true","校验是否展示弹层失败");
Assert.assertEquals(popRes.jsonPath().getString("data.totalBonus"),"0.1","校验是否展示弹层失败");
Assert.assertEquals(popRes.jsonPath().getString("data.drawType"),"0","校验开奖类型失败");
Assert.assertEquals(popRes.jsonPath().getString("data.lucky"),"false","校验不发福袋失败失败");
List<PkPopPrizeVo> prizeVoList = popRes.jsonPath().getList("data.prizeList",PkPopPrizeVo.class);
logger.info("开奖结果的list为:"+JSONObject.toJSONString(prizeVoList));
for (PkPopPrizeVo prize:prizeVoList){
if (prize.getBonusType().equals("2")){
Assert.assertEquals(prize.getTotalBonus(),"10","校验list的瓜分红包金额失败");
}
}
}
@Test(priority = 2)
public void 瓜分红包_首页不中奖() throws Exception{
String newBetId = "";
List<String> optionsIds = new ArrayList<>();
String groupId = "194";
newBetId = createPk("2","2020-08-12 00:00:00",groupId);
newBetIds.add(newBetId);
List<Map<String,Object>> pks = jdbc.findModeResult("select * from act_com_conf.tb_bet_option where bet_id = ?",newBetId);
logger.info("pk活动信息为"+JSONObject.toJSONString(pks));
for (int i=0;i<pks.size();i++){
optionsIds.add(pks.get(i).get("id").toString());
}
logger.info("pk活动id为:"+newBetId+",选项id为:"+ optionsIds.toString());
Response res1 = pkService.doJoin(user01,newBetId,optionsIds.get(0));
Response res2 = pkService.doJoin(user02,newBetId,optionsIds.get(1));
this.modifyOpenPrizeTime(newBetId,60);
//调用开奖接口
Response doDrowRresponse = pkActivityService.doDraw();
Assert.assertEquals(doDrowRresponse.jsonPath().getString("success"),"true","开奖结果校验失败");
Assert.assertEquals(doDrowRresponse.jsonPath().getString("data"),"开奖中。。。","开奖messag校验失败");
Thread.sleep(8000);
Response popRes = pkService.popup(user02);
popRes.prettyPrint();
Assert.assertEquals(popRes.jsonPath().getString("data.show"),"false","校验是否展示弹层失败");
Assert.assertEquals(popRes.jsonPath().getString("data.totalBonus"),"0.0","校验红包值失败");
Assert.assertEquals(popRes.jsonPath().getString("data.drawType"),"0","校验开奖类型失败");
Assert.assertEquals(popRes.jsonPath().getString("data.lucky"),"false","校验不发福袋失败失败");
Assert.assertEquals(popRes.jsonPath().getString("data.prizeList"),null,"校验中奖list为null");
}
@Test(priority = 1)
public void 瓜分红包_首页中_多次中奖() throws Exception{
for (int i=0;i<3;i++){
String newBetId = "";
List<String> optionsIds = new ArrayList<>();
String groupId = "194";
newBetId = createPk("2","2020-08-12 00:00:00",groupId);
newBetIds.add(newBetId);
List<Map<String,Object>> pks = jdbc.findModeResult("select * from act_com_conf.tb_bet_option where bet_id = ?",newBetId);
logger.info("pk活动信息为"+JSONObject.toJSONString(pks));
for (int j=0;j<pks.size();j++){
optionsIds.add(pks.get(j).get("id").toString());
}
logger.info("pk活动id为:"+newBetId+",选项id为:"+ optionsIds.toString());
Response res1 = pkService.doJoin(user04,newBetId,optionsIds.get(0));
this.modifyOpenPrizeTime(newBetId,60);
}
//调用开奖接口
Response doDrowRresponse = pkActivityService.doDraw();
Assert.assertEquals(doDrowRresponse.jsonPath().getString("success"),"true","开奖结果校验失败");
Assert.assertEquals(doDrowRresponse.jsonPath().getString("data"),"开奖中。。。","开奖messag校验失败");
Thread.sleep(8000);
Response popRes = pkService.popup(user04);
popRes.prettyPrint();
Assert.assertEquals(popRes.jsonPath().getString("data.show"),"true","校验是否展示弹层失败");
Assert.assertEquals(popRes.jsonPath().getString("data.totalBonus"),"0.3","校验是否展示弹层失败");
Assert.assertEquals(popRes.jsonPath().getString("data.drawType"),"0","校验开奖类型失败");
Assert.assertEquals(popRes.jsonPath().getString("data.lucky"),"false","校验不发福袋失败失败");
List<PkPopPrizeVo> prizeVoList = popRes.jsonPath().getList("data.prizeList",PkPopPrizeVo.class);
logger.info("开奖结果的list为:"+JSONObject.toJSONString(prizeVoList));
for (PkPopPrizeVo prize:prizeVoList){
if (prize.getBonusType().equals("2")){
Assert.assertEquals(prize.getTotalBonus(),"30","校验list的瓜分红包金额失败");
}
}
}
public String createPk(String bounsType,String endTime,String groupId) throws Exception {
Response betResponse = pkActivityService.betForSetUp(bounsType,endTime);
logger.info("新建pk活动的结果信息为"+ JSONObject.toJSONString(betResponse.prettyPrint()));
betResponse.prettyPrint();
String betId = betResponse.jsonPath().getString("data");
logger.info("newBetId的信息为"+betId);
Response betRelation = pkActivityService.betGroupRelation(betId,endTime,groupId);
Response modifyStatusResponse = pkActivityService.modifySatus(betId);
return betId;
}
public void modifyOpenPrizeTime(String betId,int x) throws Exception{
String endTimeStr = "2018-11-26 20:24:39";
Boolean result1 = jdbc.update("update act_com_conf.tb_bet_config set end_time = ? where id = ?\n",endTimeStr,betId);
Boolean result2 = jdbc.update("update act_com_conf.tb_bet_group_relation set end_time = ? where bet_id = ?\n",endTimeStr,betId);
}
@AfterClass
public void tearDown() {
try {
for (String newBetId:newBetIds){
Boolean result1 = jdbc.update("delete from act_com_conf.tb_bet_option where bet_id = ?",newBetId);
Boolean result4 = jdbc.update("delete from act_record.tb_bet_record where bet_id = ?",newBetId);
Boolean result5 = jdbc.update("delete from bet_activity.tb_bet_result where bet_id = ?",newBetId);
Boolean result2 = jdbc.update("delete from act_com_conf.tb_bet_group_relation where bet_id = ?",newBetId);
Boolean result3 = jdbc.update("delete from act_com_conf.tb_bet_config where id = ?",newBetId);
}
} catch (SQLException e) {
e.printStackTrace();
} catch (Exception e){
e.printStackTrace();
}
}
}
\ No newline at end of file
......@@ -50,6 +50,11 @@ public class pk_管理端测试_AccessTest extends DuibaTestBase {
private String groupId = "147";
// @Test
// public void test() throws Exception{
// Response oldBetList = pkActivityService.getMngBetList();
// oldBetList.prettyPrint();
// }
@Test
......
......@@ -35,7 +35,8 @@ public class 插件_抽奖扣积分测试_pluginTest extends DuibaTestBase {
private int uid = 3982;
private String consumerId = "100092192";
private Integer user01 = 5193;//appid=21833
private String consumerId01 = "100114050";
private static DuibaLog logger = DuibaLog.getLogger();
......@@ -67,10 +68,31 @@ public class 插件_抽奖扣积分测试_pluginTest extends DuibaTestBase {
logger.info("校验积分消耗成功,原积分值="+userCredit+",消耗后积分值为"+userCredit1);
}
//@Test
public void 插件_实物有奖项库存无兑换项库存测试() throws Exception{
}
Map<String,Object> user = jdbc.findSimpleResult("select * from dafuweng.user where id=?\n",uid);
Map<String,Object> consumer = jdbc.findSimpleResult("select * from new_consumer.consumer_0010 where id=?\n",consumerId);
Long userCredit = Long.parseLong(user.get("credits").toString());
Long consumerCredit = Long.parseLong(consumer.get("credits").toString());
Response playResponse = this.playPlugin(uid,"3355");
Assert.assertEquals(playResponse.jsonPath().getString("lottery.type"),"thanks","插件抽奖的奖品类型校验失败");
logger.info("插件奖品的兑换项库存不足,降级谢谢参与成功");
Map<String,Object> user1 = jdbc.findSimpleResult("select * from dafuweng.user where id=?\n",uid);
Map<String,Object> consumer1 = jdbc.findSimpleResult("select * from new_consumer.consumer_0010 where id=?\n",consumerId);
String userCredit1 = user1.get("credits").toString();
String consumerCredit1 = consumer1.get("credits").toString();
Assert.assertEquals(userCredit1,String.valueOf(userCredit-44),"user积分扣除校验失败");
Assert.assertEquals(consumerCredit1,String.valueOf(consumerCredit-44),"consumer积分扣除校验失败");
logger.info("校验积分消耗成功,原积分值="+userCredit+",消耗后积分值为"+userCredit1);
}
......
/**
* Copyright (C), 2015-2018
* FileName: 插件_插件信息获取测试_pluginTest
* Author: qianwenjun
* Date: 2018/12/20 09:48
* Description:
*/
package http.cases.PluginActivityTest;
import base.DuibaLog;
import base.DuibaTestBase;
import http.service.Activity.ActivityPlugDrawInfoService;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.Test;
/**
* 〈〉
*
* @author qianwenjun
* @create 2018/12/20
* @since 1.0.0
*/
public class 插件_插件信息获取测试_pluginTest extends DuibaTestBase {
@Autowired
ActivityPlugDrawInfoService activityPlugDrawInfoService;
private static DuibaLog logger = DuibaLog.getLogger();
private Integer user01 = 5416;//appid=21945
private Integer user02 = 5193;//appid=21833
@Test
public void 插件_人民币展示() throws Exception{
Response response = activityPlugDrawInfoService.getPrizeInfo(user01,"3354");
response.prettyPrint();
Assert.assertEquals(response.jsonPath().getString("needMonery"),"0.88","校验插件价值人民币展示错误");
Assert.assertEquals(response.jsonPath().getString("pluginLimitCount"),"2","校验插件限制次数错误");
Assert.assertEquals(response.jsonPath().getString("limitCount"),"1","校验插件免费次数错误");
Assert.assertEquals(response.jsonPath().getString("creditsPrice"),"88","校验插件限制次数错误");
Assert.assertEquals(response.jsonPath().getString("limitScope"),"1","校验插件次数维度错误");
}
@Test
public void 插件_50汇率展示展示() throws Exception{
Response response = activityPlugDrawInfoService.getPrizeInfo(user02,"3354");
response.prettyPrint();
Assert.assertEquals(response.jsonPath().getString("needMonery"),null,"校验插件价值人民币展示错误");
Assert.assertEquals(response.jsonPath().getString("pluginLimitCount"),"2","校验插件限制次数错误");
Assert.assertEquals(response.jsonPath().getString("limitCount"),"1","校验插件免费次数错误");
Assert.assertEquals(response.jsonPath().getString("creditsPrice"),"44","校验插件限制次数错误");
Assert.assertEquals(response.jsonPath().getString("limitScope"),"1","校验插件次数维度错误");
}
}
\ No newline at end of file
......@@ -112,6 +112,7 @@ public class 插件_限制次数测试_pluginTest extends DuibaTestBase {
Assert.assertEquals(freeTimes1.get("int_value").toString(),"1","免费次数记录校验失败");
Assert.assertEquals(actcommcTimes1.get("int_value").toString(),"2","限制次数记录校验失败");
Thread.sleep(3000);
Map<String,Object> user1 = jdbc.findSimpleResult("select * from dafuweng.user where id=?\n",uid_SubCredits);
Map<String,Object> consumer1 = jdbc.findSimpleResult("select * from new_consumer.consumer_0010 where id=?\n","100060071");
String userCredit1 = user1.get("credits").toString();
......
......@@ -141,7 +141,7 @@ public class 插件出奖异常测试_pluginTest extends DuibaTestBase {
}
@Test (dataProvider = "providerMethod")
//@Test (dataProvider = "providerMethod")
public void 插件中奖限制测试(Map<String,String> data) throws Exception{
logger.info(data.get("casename"));
Map<String,String> map = new HashMap<>();
......
......@@ -59,9 +59,9 @@ public class 插件工具抽奖测试_pluginTest extends DuibaTestBase {
Object[][] result = null;
if(method.getName().equals("插件工具抽奖测试")) {
result = new Object[][]{
new Object[]{1,"1100","插件出奖开心码测试"},
// new Object[]{2,"881","插件工具积分消耗"},
// new Object[]{3,"1137","插件工具免费次数使用"},
// new Object[]{1,"1100","插件出奖开心码测试"},
new Object[]{2,"881","插件工具积分消耗"},
new Object[]{3,"1137","插件工具免费次数使用"},
};
}
......
......@@ -28,6 +28,19 @@ public class 补给站_活动_DuibaTest extends AbstractTestNGSpringContextTests
//添加活动
@Test(description = "//添加活动")
public void a_添加活动() throws Exception{
//查询订单列表
Response orderResponse = developerBJZ.selectOrders("1",appId);
String id = orderResponse.jsonPath().getString("data.list");
logger.info("待付款订单id为:"+id);
if(id.equals("[]")){
logger.info("订购列表无待付款订单");
}else{
id = orderResponse.jsonPath().getString("data.list[0].id");
logger.info("待付款订单id为:"+id);
developerBJZ.cancleOrder(id,appId);
logger.info("待付款订单取消成功");
}
//查询热门活动-活动列表,获取商品ID
Response response=developerBJZ.saasActivitys("3",appId);
String goodItemId= String.valueOf(response.jsonPath().getString("data.saasActivitys[0].id"));
......
package http.cases.SaasDeveloperTest;
import base.Config;
import base.DuibaBase;
import http.service.Manager.ADeveloperService;
import http.service.Saas.UpdateAppInfoService;
import base.DuibaLog;
import io.restassured.response.Response;
import org.apache.commons.exec.ExecuteException;
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 {
//@ContextConfiguration(classes = Config.class)
public class 设置_应用信息_DuibaTest extends DuibaBase {
private DuibaLog logger = DuibaLog.getLogger();
@Autowired
UpdateAppInfoService updateAppInfoService;
@Autowired
ADeveloperService aDeveloperService;
String appId = "19515";
//设置--保存应用信息
@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);
//@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);
updateAppInfoService.UpdateAppInfo(appId, unitName, earnCreditsUrl, creditsDetailUrl, isDecimalOpen);
Thread.sleep(1000);
Response response2= updateAppInfoService.appInfo(appId);
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("保存应用信息成功");
}
@Test(description = "// 查询员工信息——高级管理员信息")
public void a_查询高级管理员信息() throws Exception {
Response response1 = aDeveloperService.developer("109","text");
logger.info("response1");
Response response2=updateAppInfoService.selectEmployeeList("","",appId);
logger.info("response2");
String mappname=response1.jsonPath().getString("list[0].appName");
String memail=response1.jsonPath().getString("list[0].email");
String mname=response1.jsonPath().getString("list[0].name");
String demail=response2.jsonPath().getString("data.list[0].developerAccount");
String dname=response2.jsonPath().getString("data.list[0].nickName");
// 校验2个接口的信息是否一致
Assert.assertEquals(mappname,"(saas自动化)至尊版", "校验应用名称失败");
Assert.assertEquals(memail,demail,"校验邮箱失败");
Assert.assertEquals(mname,dname,"校验高级管理员名称失败");
Assert.assertEquals(response2.jsonPath().getString("data.list[0].roleName"),"高级管理员","校验角色名称失败");
logger.info("校验高级管理员信息成功");
}
@Test(description = "//添加/编辑员工")
public void b_添加员工() throws Exception{
Response response=updateAppInfoService.selectAllRoles(appId);
//查询角色接口,得到普通管理员的角色ID
String roleId=response.jsonPath().getString("data[1].id");
//添加一个注册过的开发者&普通管理员信息
updateAppInfoService.saveOrUpdate("18258853242","hmx自动化测试",roleId,"普通管理员",appId);
//刷新员工管理列表
updateAppInfoService.selectEmployeeList("","1",appId);
//校验是否添加成功
Assert.assertEquals(updateAppInfoService.selectEmployeeList("","",appId).jsonPath().getString("data.list[1].developerAccount"),"18258853242", "校验账号信息失败");
Assert.assertEquals(updateAppInfoService.selectEmployeeList("","",appId).jsonPath().getString("data.list[1].nickName"),"hmx自动化测试", "校验名称失败");
Assert.assertEquals(updateAppInfoService.selectEmployeeList("","",appId).jsonPath().getString("data.list[1].roleName"),"普通管理员", "校验角色名称失败");
logger.info("校验普通管理员信息添加成功");
}
@Test(description = "兑吧账号精确搜索,姓名模糊搜索")
public void c_搜索场景() throws Exception{
//通过邮箱号精确搜索
updateAppInfoService.selectEmployeeList("","wxs@duiba.com.cn",appId);
//通过手机号精确搜索
updateAppInfoService.selectEmployeeList("","18258853242",appId);
//姓名模糊搜索
updateAppInfoService.selectEmployeeList("","hmx",appId);
//通过角色名称搜索
updateAppInfoService.selectEmployeeList("395","",appId);
logger.info("校验各种搜索成功");
}
@Test(description = "删除添加的管理员")
public void d_删除管理员() throws Exception{
Response response = updateAppInfoService.selectEmployeeList("","",appId);
String id = response.jsonPath().getString("data.list[1].id");
logger.info("员工id为:"+id);
response = updateAppInfoService.delete(appId,id);
logger.info("员工删除成功!");
}
}
/**
* Copyright (C), 2015-2018
* FileName: 购物车测试
* Author: zhaoran
* Date: 2018/12/10 19:45
* Description:
*/
package http.cases.SaasDeveloperTest;
import base.DuibaLog;
import base.DuibaTestBase;
import http.service.Activity.PkService;
import http.service.Authorization;
import http.service.Saas.MallService;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.testng.Assert;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import java.lang.reflect.Method;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;
import static io.restassured.RestAssured.given;
public class 购物车测试 extends DuibaTestBase {
@Value("${activity.host}")
String activityHost;
@Autowired
MallService mallService;
@Autowired
Authorization authorization;
private DuibaLog logger = DuibaLog.getLogger();
private static Integer uid = 5415;
@Test
public void 加入购物车() throws Exception{
//获取当前购物车数量
Response response = mallService.getMallCount(uid);
response.prettyPrint();
logger.info("购物车当前的数量为:"+response.jsonPath().getString("data.trolleyItemCount"));
}
}
\ No newline at end of file
......@@ -173,7 +173,7 @@ public class SingleLottery_AccessTest extends DuibaTestBase {
}
Assert.assertEquals(flowWork,"SupplierExchange-started","数据库主订单流程节点校验失败");
Assert.assertEquals(String.valueOf(selectResult2.get("item_id")),"27131","数据库主订单奖项id校验失败");
Assert.assertEquals(String.valueOf(selectResult2.get("biz_params")),"胡梦新:18258853242:浙江:杭州市:西湖区:西溪街道:数娱大厦 ","数据库主订单biz_params校验失败");
Assert.assertEquals(String.valueOf(selectResult2.get("biz_params")),"胡梦新:18258853242:浙江:杭州市:西湖区:西溪街道:数娱大厦 ","数据库主订单biz_params校验失败");
Assert.assertEquals(String.valueOf(selectResult2.get("pay_status")),"prereduce","数据库主订单pay_status校验失败");
Assert.assertEquals(String.valueOf(selectResult2.get("status")),"consume_success","数据库主订单status校验失败");
......
......@@ -9,12 +9,10 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import utils.MatcherString;
import utils.RedisUtil;
import java.lang.reflect.Method;
import java.text.SimpleDateFormat;
import java.util.*;
......@@ -23,7 +21,7 @@ import static io.restassured.RestAssured.given;
/**
* Created by zhaoran on 2018/6/8.
*/
public class 自有单抽限制_AccessTest extends DuibaTestBase {
public class 自有单抽限制 extends DuibaTestBase {
@Autowired
SingleLotteryService singleLotteryService;
@Autowired
......
......@@ -20,7 +20,7 @@ import static io.restassured.RestAssured.given;
/**
* Created by zhaoran on 2018/6/8.
*/
public class 预览单品抽奖_AccessTest extends DuibaTestBase {
public class 预览单品抽奖 extends DuibaTestBase {
@Autowired
SigninService signinService;
@Autowired
......
/**
* Copyright (C), 2015-2018
* FileName: PkPopPrizeVo
* Author: qianwenjun
* Date: 2018/12/22 14:07
* Description:
*/
package http.model;
import lombok.Getter;
import lombok.Setter;
/**
* 〈〉
*
* @author qianwenjun
* @create 2018/12/22
* @since 1.0.0
*/
@Getter
@Setter
public class PkPopPrizeVo {
private String bonusType;
private String pluginId;
private String title;
private String totalBonus;
}
\ No newline at end of file
......@@ -142,4 +142,24 @@ public class ActivityPlugDrawInfoService {
return response;
}
public Response getPrizeInfo(int uid,String activityId) throws Exception {
Map<String,String> map = new HashMap<>();
map.put("activityId",activityId);
logger.info("请求getPrizeInfo接口,orderId="+activityId);
Response response = given().cookies(authorization.dafuwengLogin(uid)).params(map).post(activityHost+"/plugin/getPrizeInfo");
Assert.assertEquals(response.jsonPath().getString("success"),"true");
try{
Assert.assertEquals(response.jsonPath().getString("success"),"true");
}catch(Exception e){
throw new Exception("/activityPlugDrawInfo/getOrderStatusPlugdraw接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/activityPlugDrawInfo/getOrderStatusPlugdraw接口失败,返回信息:"+response.asString());
}
return response;
}
}
......@@ -213,7 +213,7 @@ public class ManagerService {
map.put("limitScope","forever");
map.put("freeCount","999");
map.put("freeScope","everyday");
map.put("endDate","2018-12-31 19:00");
map.put("endDate","2030-12-31 19:00");
map.put("banner","//yun.duiba.com.cn/upload/uGlwJ1472642112981.png");
map.put("bannerImgNew","//yun.duiba.com.cn/upload/newHdTool/hitEgg/banner_750x220.png");
map.put("smallImgNew","//yun.duiba.com.cn/upload/newHdTool/hitEgg/thumbnail_370x370.png");
......
......@@ -300,7 +300,7 @@ public class Authorization {
public Map hdLoginSaasNew(String account,String appId){
String path = "/doLoginNew";
int i=10;
logger.info("hdCookiesSaasByApp cookies:"+hdCookiesSaasNew.toString());
logger.info("hdCookiesSaasNew cookies:"+hdCookiesSaasNew.toString());
Map<String,String> hdCookies = hdCookiesSaasNew.get(appId);
while((hdCookies==null||hdCookies.size()==0)&&i>0) {
Response token=this.hdGetToken();
......@@ -328,7 +328,7 @@ public class Authorization {
i--;
}
logger.info("hdCookiesSaasByApp cookies集合:"+hdCookiesSaasNew.toString());
logger.info("hdCookiesSaasNew cookies集合:"+hdCookiesSaasNew.toString());
return hdCookies;
}
......
......@@ -97,4 +97,32 @@ public class ADeveloperService {
}
return response;
}
//管理后台-开发者维护-查询开发者账号详细信息
public Response developer(String queryStrId,String type) throws Exception {
String url ="http://" + ManagerHost + "/newmanager/ADeveloper/developer";
Map<String,String> map = new HashMap<>();
map.put("queryStr","");
map.put("queryStrId",queryStrId);
map.put("type",type);
map.put("pageNo","1");
map.put("pageSize","20");
logger.info("url"+url);
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.ssoLogin()).params(map).get(url);
response.prettyPrint();
try {
Assert.assertEquals(response.jsonPath().getString("success"), "true");
} catch (Exception e) {
throw new Exception("创建接口1失败,返回信息:" + response.asString());
} catch (Error er) {
throw new Exception("创建接口2失败,返回信息:" + response.asString());
}
return response;
}
}
......@@ -145,7 +145,7 @@ public class DeveloperCouponService {
map.put("validEndDate","2020-03-19");
map.put("title","马上使用");
map.put("subType","0");
map.put("url","http://yun.dui88.com/coupons/1536305957168.txt");
map.put("url","http://yun.dui88.com/coupons/1546861142757.txt");
map.put("developShowType","0");
map.put("isLink","false");
map.put("btnTxt","");
......
package http.service.Saas;
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.HashMap;
import java.util.Map;
import static io.restassured.RestAssured.given;
/**
* Created by zhaoran on 2018/12/19.
*/
@Service
public class MallService {
@Value("${activity.host}")
String activityHost;
@Autowired
Authorization authorization;
private DuibaLog logger = DuibaLog.getLogger();
//获取购物车列表商品
public Response mallget(Integer uid) throws Exception {
String url = activityHost+"/mall-api/consumer/shopping-trolley/get";
Response response=given().cookies(authorization.dafuwengLogin(uid)).get(url);
response.prettyPrint();
try{
Assert.assertEquals(response.jsonPath().getString("success"),"true");
}catch(Exception e){
throw new Exception("购物车列表接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("购物车列表接口失败,返回信息:"+response.asString());
}
return response;
}
//获取购物车列表商品
public Response getMallCount(Integer uid) throws Exception {
String url = activityHost+"/mall-api/consumer/market-activity/getMallCount";
Response response=given().cookies(authorization.dafuwengLogin(uid)).get(url);
response.prettyPrint();
try{
Assert.assertEquals(response.jsonPath().getString("success"),"true");
}catch(Exception e){
throw new Exception("购物车数目接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("购物车数目接口失败,返回信息:"+response.asString());
}
return response;
}
// 加入购物车
public Response malladd(String appItemId,Integer uid) throws Exception {
String url = activityHost+"/mall-api/consumer/shopping-trolley/add";
Map<String,String> map = new HashMap<>();
map.put("appItemId",appItemId);
JSONObject jsonParam = JSONObject.parseObject(JSON.toJSONString(map));
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.dafuwengLogin(uid)).body(jsonParam).post(url);
response.prettyPrint();
try{
Assert.assertEquals(response.jsonPath().getString("success"),"true");
}catch(Exception e){
throw new Exception("添加购物车接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("添加购物车接口失败,返回信息:"+response.asString());
}
return response;
}
}
\ No newline at end of file
......@@ -2,6 +2,8 @@ package http.service.Saas;
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;
......@@ -73,4 +75,83 @@ public class UpdateAppInfoService {
return response;
}
//查询员工管理高级管理员信息(模糊查询,没有传参数)
public Response selectEmployeeList(String roleId,String keyword,String appId) throws Exception {
String url = "http://" + hdHost + "/employee/selectEmployeeList";
Map<String, String> map = new HashMap<>();
map.put("roleId",roleId);
map.put("rowId","1");
map.put("keyword",keyword);
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas(appId)).params(map).get(url);
response.prettyPrint();
try {
Assert.assertEquals(response.jsonPath().getString("desc"), "成功");
} catch (Exception e) {
throw new Exception("创建接口1失败,返回信息:" + response.asString());
} catch (Error er) {
throw new Exception("创建接口2失败,返回信息:" + response.asString());
}
return response;
}
//查询有的角色信息
public Response selectAllRoles(String appId) throws Exception {
String url = "http://" + hdHost + "/employee/selectAllRoles";
Map<String, String> map = new HashMap<>();
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas(appId)).params(map).get(url);
response.prettyPrint();
try {
Assert.assertEquals(response.jsonPath().getString("desc"), "成功");
} catch (Exception e) {
throw new Exception("创建接口1失败,返回信息:" + response.asString());
} catch (Error er) {
throw new Exception("创建接口2失败,返回信息:" + response.asString());
}
return response;
}
//添加员工——普通管理员
public Response saveOrUpdate(String developerAccount,String nickName,String roleId,String roleName,String appId) throws Exception {
String url = "http://" + hdHost + "/employee/saveOrUpdate";
Map<String, String> map = new HashMap<>();
map.put("developerAccount",developerAccount);
map.put("nickName",nickName);
map.put("roleId",roleId);
map.put("roleName",roleName);
JSONObject jsonParam = JSONObject.parseObject(JSON.toJSONString(map));
Response response =given().contentType("application/json;charset=UTF-8").cookies(authorization.hdLoginSaas(appId)).body(jsonParam).post(url);
response.prettyPrint();
try {
Assert.assertEquals(response.jsonPath().getString("desc"), "成功");
} catch (Exception e) {
throw new Exception("创建接口1失败,返回信息:" + response.asString());
} catch (Error er) {
throw new Exception("创建接口2失败,返回信息:" + response.asString());
}
return response;
}
//删除管理员
public Response delete(String appId,String id) throws Exception {
String url = "http://" + hdHost + "/employee/delete";
Map<String, String> map = new HashMap<>();
map.put("id",id);
Response response = given().cookies(authorization.hdLoginSaas(appId)).params(map).get(url);
response.prettyPrint();
try {
Assert.assertEquals(response.jsonPath().getString("desc"), "成功");
} catch (Exception e) {
throw new Exception("/employee/delete失败,返回信息:" + response.asString());
} catch (Error er) {
throw new Exception("/employee/delete失败,返回信息:" + response.asString());
}
return response;
}
}
package http.service.goods;
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.HashMap;
import java.util.Map;
import static io.restassured.RestAssured.given;
@Service
public class DevCards {
@Value("${hdserver.host}")
String hdHost;
@Autowired
Authorization authorization;
//添加券码
public Response cardsSave(String appId,String type,String name) throws Exception {
String url="http://"+hdHost+"/cardLibrary/save";
Map<String,Object> map = new HashMap<>();
map.put("appId",appId);//应用ID
map.put("type",type);//类型
map.put("name",name);//名称
map.put("fileUrl","http%3A%2F%2Fyun.dui88.com%2Fcoupons%2F1544497069778.txt");//文件地址
map.put("startDay","");//有效期--开始时间
map.put("endDay","");//有效期--结束时间
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas()).post(url);
try{
Assert.assertEquals(response.jsonPath().getString("desc"),"成功");
}catch(Exception e){
throw new Exception("创建接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("创建失败,返回信息:"+response.asString());
}
return response;
}
//查询
public Response list(String appId,String name,String type,String excludeRelated) throws Exception {
String url="http://"+hdHost+"/cardLibrary/list";
Map<String,Object> map = new HashMap<>();
map.put("name",name);//名称
map.put("pageNo","1");
map.put("pageSize","15");
map.put("appId",appId);
map.put("type",type);//类型:0:券码 1:链接 2:重复 3:卡密
map.put("excludeRelated",excludeRelated);//true:排查已关联的 false:不排除
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas()).get(url);
try{
Assert.assertEquals(response.jsonPath().getString("desc"),"成功");
}catch(Exception e){
throw new Exception("创建接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("创建失败,返回信息:"+response.asString());
}
return response;
}
//删除
public Response delete(String appId,String id) throws Exception {
String url="http://"+hdHost+"/cardLibrary/delete";
Map<String,Object> map = new HashMap<>();
map.put("appId",appId);
map.put("id",id);
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas()).post(url);
try{
Assert.assertEquals(response.jsonPath().getString("desc"),"成功");
}catch(Exception e){
throw new Exception("创建接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("创建失败,返回信息:"+response.asString());
}
return response;
}
}
package http.service.goods;
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.HashMap;
import java.util.Map;
import static io.restassured.RestAssured.given;
@Service
public class DevCardsKaquanDetails {
@Value("${hdserver.host}")
String hdHost;
@Autowired
Authorization authorization;
//查询指定卡券库批次列表信息
public Response getBatchList(String id) throws Exception {
String url="http://"+hdHost+"/cardLibrary/getBatchList";
Map<String,Object> map = new HashMap<>();
map.put("id",id);
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas()).get(url);
try{
Assert.assertEquals(response.jsonPath().getString("desc"),"成功");
}catch(Exception e){
throw new Exception("创建接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("创建失败,返回信息:"+response.asString());
}
return response;
}
//查询卡券库批次列表下的卡券详情
public Response getDetail(String appId,String id,String batchId) throws Exception {
String url="http://"+hdHost+"/cardLibrary/getDetail";
Map<String,Object> map = new HashMap<>();
map.put("appId",appId);
map.put("id",id);//卡券库ID
map.put("pageNo","1");
map.put("pageSize","15");
map.put("status","");
map.put("batchId",batchId);//批次ID
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas()).get(url);
try{
Assert.assertEquals(response.jsonPath().getString("desc"),"成功");
}catch(Exception e){
throw new Exception("创建接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("创建失败,返回信息:"+response.asString());
}
return response;
}
//批量删除批次
public Response deleteCouponBatch(String appId,String batchId,String cardLibraryId) throws Exception {
String url="http://"+hdHost+"/cardLibrary/deleteCouponBatch";
Map<String,Object> map = new HashMap<>();
map.put("appId",appId);
map.put("batchId",batchId);//批次ID
map.put("cardLibraryId",cardLibraryId);//卡券库ID
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas()).post(url);
try{
Assert.assertEquals(response.jsonPath().getString("desc"),"成功");
}catch(Exception e){
throw new Exception("创建接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("创建失败,返回信息:"+response.asString());
}
return response;
}
//删除卡券
public Response deleteCoupon(String appId,String id,String batchId,String cardLibraryId) throws Exception {
String url="http://"+hdHost+"/cardLibrary/deleteCoupon";
Map<String,Object> map = new HashMap<>();
map.put("appId",appId);
map.put("id",id);//卡券ID
map.put("pageNo","1");
map.put("pageSize","15");
map.put("status","");
map.put("batchId",batchId);//批次ID
map.put("cardLibraryId",cardLibraryId);//卡券库ID
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas()).post(url);
try{
Assert.assertEquals(response.jsonPath().getString("desc"),"成功");
}catch(Exception e){
throw new Exception("创建接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("创建失败,返回信息:"+response.asString());
}
return response;
}
//导入券码
public Response importCoupon(String appId,String id,String batchId,String cardLibraryId,String type) throws Exception {
String url="http://"+hdHost+"/cardLibrary/importCoupon";
Map<String,Object> map = new HashMap<>();
map.put("appId",appId);
map.put("id",id);
map.put("status","");
map.put("batchId",batchId);//批次ID
map.put("cardLibraryId",cardLibraryId);//卡券库ID
map.put("type",type);
map.put("fileUrl","http://yun.dui88.com/coupons/1545731089854.txt");
map.put("startDay","2019-12-26");
map.put("endDay","2044-12-26");
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas()).post(url);
try{
Assert.assertEquals(response.jsonPath().getString("desc"),"成功");
}catch(Exception e){
throw new Exception("创建接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("创建失败,返回信息:"+response.asString());
}
return response;
}
//轮询导入结果
public Response getImportStatus(String appId,String importId) throws Exception {
String url="http://"+hdHost+"/cardLibrary/getImportStatus";
Map<String,Object> map = new HashMap<>();
map.put("appId",appId);
map.put("importId",importId);
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas()).get(url);
try{
Assert.assertEquals(response.jsonPath().getString("desc"),"成功");
}catch(Exception e){
throw new Exception("创建接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("创建失败,返回信息:"+response.asString());
}
return response;
}
}
package http.service.goods;
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.HashMap;
import java.util.Map;
import static io.restassured.RestAssured.given;
@Service
public class DevDoUpdateCoupon {
@Value("${hdserver.host}")
String hdHost;
@Autowired
Authorization authorization;
//添加普通券码
public Response doupdateCouponPT(String appId, String classifyIds,String title,String type) throws Exception {
String url="http://"+hdHost+"/devItemNew/doUpdateCoupon";
Map<String,Object> map = new HashMap<>();
map.put("appId",appId);//应用ID
map.put("classifyIds",classifyIds);//商品分组
map.put("arealimitAreas"," [{provinceCode: \"340000\", provinceName: \"安徽省\", cityName: \"全省范围\", cityCode: \"all\"}]");
map.put("arealimitSwitch","true");//是否勾选地域限制 true 勾选,false 未勾选
map.put("arealimitType","1");//类型 1白名单 2 黑名单
map.put("attributes","[\n" +
"{\n" +
"\"skuInfo\": {\n" +
"\"remaining\": 10000,\n" +
"\"salePrice\": \"9.32\",\n" +
"\"facePrice\": \"9.20\",\n" +
"\"merchantCoding\": \"232323\"\n" +
"},\n" +
"\"children\": null\n" +
"}\n" +
"]");
map.put("isOwner","true");//是否自有商品
map.put("multiImage","[\n" +
"\"//yun.dui88.com/images/201812/fjwhiijs6j.jpg\",\n" +
"\"//yun.dui88.com/images/201812/243svyhvv0.png\"\n" +
"]");
map.put("multiSku","false");
map.put("levelLimitType","1");
map.put("levelCheckbox","[]");
map.put("validDaterange","[]");
map.put("showJumpButton","true");
map.put("cardLibraryId","46");//关联卡券
map.put("cardLibraryName","卡券");//关联卡券名称
map.put("showBarCode","true");
map.put("linkUrl","http://www.baidu.com");//跳转链接
map.put("title",title);
map.put("sellingPoint","卖点描述");
map.put("smallImage","//yun.dui88.com/images/201812/bqrfryl2bd.png");
map.put("devAudit","true");
map.put("weixinShareDesc","这是分享描述文案,分享后可以查看");
map.put("usageRule","<p>这是使用规则:</p><p>1、附近考虑到税费就是;</p><p>2、反馈的是浪费就开始;</p><p>3、风刀霜剑发了第三方市领导反馈</p>");
map.put("description","<p>这是图文详情信息,反馈代理商房间</p><p>1反馈到洛杉矶福克斯代理费收代理费水电费疯狂夺金发牢骚的</p>");
map.put("type",type);
map.put("subType","0");//0:券码 1:链接 2:重复 3:卡密
map.put("limitType","forever");
map.put("expressType","free");
//json 格式转成form表单
JSONObject jsonParam = JSONObject.parseObject(JSON.toJSONString(map));
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas()).body(jsonParam).post(url);
try{
Assert.assertEquals(response.jsonPath().getString("desc"),"成功");
}catch(Exception e){
throw new Exception("创建接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("创建失败,返回信息:"+response.asString());
}
return response;
}
//添加链接券
public Response doupdateCouponLianjie(String appId, String classifyIds,String title,String type) throws Exception {
String url="http://"+hdHost+"/devItemNew/doUpdateCoupon";
Map<String,Object> map = new HashMap<>();
map.put("appId",appId);//应用ID
map.put("classifyIds",classifyIds);//商品分组
map.put("arealimitSwitch","true");//是否勾选地域限制 true 勾选,false 未勾选
map.put("arealimitType","2");//类型 1白名单 2 黑名单
map.put("attributes","[\n" +
" {\n" +
" \"skuInfo\":{\n" +
" \"remaining\":\"10\",\n" +
" \"salePrice\":\"80\",\n" +
" \"facePrice\":\"20\",\n" +
" \"merchantCoding\":\"STREE001\"\n" +
" },\n" +
" \"children\":null\n" +
" }\n" +
" ]");
map.put("isOwner","true");//是否自有商品
map.put("multiImage","[\n" +
"\"//yun.dui88.com/images/201812/fjwhiijs6j.jpg\",\n" +
"\"//yun.dui88.com/images/201812/243svyhvv0.png\"\n" +
"]");
map.put("multiSku","false");
map.put("levelLimitType","1");
map.put("levelCheckbox","[]");
map.put("validDaterange","[\n" +
" \"2018-12-11\",\n" +
" \"2018-12-13\"\n" +
" ]");
map.put("showJumpButton","");
map.put("cardLibraryId","");//关联卡券
map.put("cardLibraryName","");//关联卡券名称
map.put("showBarCode","");
map.put("linkUrl","https://hz.58.com");//跳转链接
map.put("couponCode","");
map.put("couponCount","10");//数量
map.put("title",title);
map.put("sellingPoint","卖点描述");
map.put("smallImage","//yun.dui88.com/images/201812/bqrfryl2bd.png");
map.put("devAudit","true");
map.put("arealimitAreas","[\n" +
" {\n" +
" \"provinceCode\":\"360000\",\n" +
" \"provinceName\":\"江西省\",\n" +
" \"cityName\":\"全省范围\",\n" +
" \"cityCode\":\"all\"\n" +
" }\n" +
" ]");
map.put("weixinShareDesc","这是分享描述文案,分享后可以查看");
map.put("autoOffDate","2025-12-27 00:00");
map.put("usageRule","<p>这是使用规则:</p><p>1、附近考虑到税费就是;</p><p>2、反馈的是浪费就开始;</p><p>3、风刀霜剑发了第三方市领导反馈</p>");
map.put("description","<p>这是图文详情信息,反馈代理商房间</p><p>1反馈到洛杉矶福克斯代理费收代理费水电费疯狂夺金发牢骚的</p>");
map.put("type",type);
map.put("subType","1");//0:券码 1:链接 2:重复 3:卡密
map.put("limitType","forever");
map.put("expressType","free");
map.put("validStartDay","2018-12-11");
map.put("validEndDay","2018-12-13");
//json 格式转成form表单
JSONObject jsonParam = JSONObject.parseObject(JSON.toJSONString(map));
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas()).body(jsonParam).post(url);
try{
Assert.assertEquals(response.jsonPath().getString("desc"),"成功");
}catch(Exception e){
throw new Exception("创建接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("创建失败,返回信息:"+response.asString());
}
return response;
}
//添加重复券
public Response doupdateCouponChongfu(String appId, String classifyIds,String title,String type) throws Exception {
String url="http://"+hdHost+"/devItemNew/doUpdateCoupon";
Map<String,Object> map = new HashMap<>();
map.put("appId",appId);//应用ID
map.put("classifyIds",classifyIds);//商品分组
map.put("arealimitSwitch","true");//是否勾选地域限制 true 勾选,false 未勾选
map.put("arealimitType","2");//类型 1白名单 2 黑名单
map.put("attributes","[\n" +
" {\n" +
" \"skuInfo\":{\n" +
" \"remaining\":\"10\",\n" +
" \"salePrice\":\"80\",\n" +
" \"facePrice\":\"20\",\n" +
" \"merchantCoding\":\"STREE001\"\n" +
" },\n" +
" \"children\":null\n" +
" }\n" +
" ]");
map.put("isOwner","true");//是否自有商品
map.put("multiImage","[\n" +
"\"//yun.dui88.com/images/201812/fjwhiijs6j.jpg\",\n" +
"\"//yun.dui88.com/images/201812/243svyhvv0.png\"\n" +
"]");
map.put("multiSku","false");
map.put("levelLimitType","1");
map.put("levelCheckbox","[]");
map.put("validDaterange","[\n" +
" \"2018-12-11\",\n" +
" \"2022-12-13\"\n" +
" ]");
map.put("showJumpButton","");
map.put("cardLibraryId","");//关联卡券
map.put("cardLibraryName","");//关联卡券名称
map.put("showBarCode","");
map.put("linkUrl","https://hz.58.com");//跳转链接
map.put("couponCode","TTT0001");//券码
map.put("couponCount","10");//数量
map.put("title",title);
map.put("sellingPoint","卖点描述");
map.put("smallImage","//yun.dui88.com/images/201812/bqrfryl2bd.png");
map.put("devAudit","true");
map.put("arealimitAreas","[\n" +
" {\n" +
" \"provinceCode\":\"360000\",\n" +
" \"provinceName\":\"江西省\",\n" +
" \"cityName\":\"全省范围\",\n" +
" \"cityCode\":\"all\"\n" +
" }\n" +
" ]");
map.put("weixinShareDesc","这是分享描述文案,分享后可以查看");
map.put("autoOffDate","2025-12-27 00:00");
map.put("usageRule","<p>这是使用规则:</p><p>1、附近考虑到税费就是;</p><p>2、反馈的是浪费就开始;</p><p>3、风刀霜剑发了第三方市领导反馈</p>");
map.put("description","<p>这是图文详情信息,反馈代理商房间</p><p>1反馈到洛杉矶福克斯代理费收代理费水电费疯狂夺金发牢骚的</p>");
map.put("type",type);
map.put("subType","2");//0 普通 1:链接 2:重复 3:卡密
map.put("limitType","forever");
map.put("expressType","free");
map.put("validStartDay","2018-12-11");
map.put("validEndDay","2022-12-13");
//json 格式转成form表单
JSONObject jsonParam = JSONObject.parseObject(JSON.toJSONString(map));
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas()).body(jsonParam).post(url);
try{
Assert.assertEquals(response.jsonPath().getString("desc"),"成功");
}catch(Exception e){
throw new Exception("创建接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("创建失败,返回信息:"+response.asString());
}
return response;
}
}
package http.service.goods;
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.HashMap;
import java.util.Map;
import static io.restassured.RestAssured.given;
@Service
public class DevDoUpdateKaMi {
@Value("${hdserver.host}")
String hdHost;
@Autowired
Authorization authorization;
//添加无规格卡密
public Response doupdateCouponWuguige(String appId,String classifyIds,String title,String type) throws Exception{
String url="http://"+hdHost+"/devItemNew/doUpdateCoupon";
Map<String,Object> map = new HashMap<>();
map.put("appId",appId);//应用ID
map.put("isOwner","true");
map.put("multiImage","//yun.dui88.com/images/201812/7uukykd9va.png");
map.put("multiSku","false");//是否为多规格,true:是, false:否
map.put("levelLimitType","1");
map.put("arealimitType","1");
map.put("levelCheckbox","[]");
map.put("validDaterange","[]");
map.put("showJumpButton","false");
map.put("cardLibraryId","");
map.put("classifyIds",classifyIds);//商品分组
map.put("title",title);
map.put("sellingPoint","我是卡密无规格的卖点描述");
map.put("smallImage","//yun.dui88.com/images/201812/8oh63tx4ks.jpg");
map.put("devAudit","true");
map.put("arealimitSwitch","false");
map.put("weixinShareDesc","微信分享信息");
map.put("autoOffDate","2030-12-31 00:00");
map.put("usageRule","<p>使用规则</p>");
map.put("description","<p>图文详情</p>");
map.put("type",type);//商品类型
map.put("subType","3");//0:券码 1:链接 2:重复 3:卡密
map.put("limitType","forever");//限制类型
map.put("expressType","free");//运费类型,free:包邮,unity:统一运
//attributes 多规格列表
map.put("attributes","[\n" +
" {\n" +
" \"skuInfo\":{\n" +
" \"cardLibraryId\":\"54\",\n" +
" \"cardLibraryName\":\"5345\",\n" +
" \"remaining\":1,\n" +
" \"salePrice\":\"9.22\",\n" +
" \"facePrice\":\"32.23\",\n" +
" \"merchantCoding\":\"2323232\"\n" +
" },\n" +
" \"children\":null\n" +
" }\n" +
" ]");
//json 格式转成form表单
JSONObject jsonParam = JSONObject.parseObject(JSON.toJSONString(map));
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas()).body(jsonParam).post(url);
try{
Assert.assertEquals(response.jsonPath().getString("desc"),"成功");
}catch(Exception e){
throw new Exception("创建接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("创建失败,返回信息:"+response.asString());
}
return response;
}
//多规格--卡密
public Response doupdateCouponDuoguige(String appId,String classifyIds,String title,String type) throws Exception{
String url="http://"+hdHost+"/devItemNew/doUpdateCoupon";
Map<String,Object> map = new HashMap<>();
map.put("appId",appId);//应用ID
map.put("isOwner","true");
map.put("multiImage","//yun.dui88.com/images/201812/7uukykd9va.png");
map.put("multiSku","true");//是否为多规格,true:是, false:否
map.put("levelLimitType","1");
map.put("arealimitType","1");
map.put("levelCheckbox","[]");
map.put("validDaterange","[]");
map.put("showJumpButton","false");
map.put("cardLibraryId","");
map.put("classifyIds",classifyIds);//商品分组
map.put("title",title);
map.put("sellingPoint","我是卡密无规格的卖点描述");
map.put("smallImage","//yun.dui88.com/images/201812/8oh63tx4ks.jpg");
map.put("arealimitSwitch","false");
map.put("weixinShareDesc","微信分享信息");
map.put("autoOffDate","2030-12-31 00:00");
map.put("usageRule","<p>使用规则</p>");
map.put("description","<p>图文详情</p>");
map.put("type",type);//商品类型
map.put("subType","3");//0:普通 1:链接 2:重复 3:卡密
map.put("limitType","forever");//限制类型
map.put("expressType","free");//运费类型,free:包邮,unity:统一运
//attributes 多规格列表
map.put("attributes","[\n" +
" {\n" +
" \"id\":\"117\",\n" +
" \"skuInfo\":{\n" +
" \"salePrice\":\"2\",\n" +
" \"cardLibraryId\":\"82\",\n" +
" \"cardLibraryName\":\"卡密2\",\n" +
" \"remaining\":1,\n" +
" \"facePrice\":\"65.77\",\n" +
" \"merchantCoding\":\"RTTT001\"\n" +
" },\n" +
" \"specId\":\"0\",\n" +
" \"children\":null\n" +
" },\n" +
" {\n" +
" \"id\":\"118\",\n" +
" \"skuInfo\":{\n" +
" \"cardLibraryId\":\"83\",\n" +
" \"cardLibraryName\":\"卡密3\",\n" +
" \"remaining\":9,\n" +
" \"salePrice\":\"3.55\",\n" +
" \"facePrice\":\"7.65\"\n" +
" },\n" +
" \"specId\":\"0\",\n" +
" \"children\":null\n" +
" },\n" +
" {\n" +
" \"id\":\"119\",\n" +
" \"skuInfo\":{\n" +
" \"cardLibraryId\":\"84\",\n" +
" \"cardLibraryName\":\"卡密4\",\n" +
" \"remaining\":9,\n" +
" \"salePrice\":\"5.77\",\n" +
" \"facePrice\":\"55.5\"\n" +
" },\n" +
" \"specId\":\"0\",\n" +
" \"children\":null\n" +
" }\n" +
" ]");
//json 格式转成form表单
JSONObject jsonParam = JSONObject.parseObject(JSON.toJSONString(map));
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas()).body(jsonParam).post(url);
try{
Assert.assertEquals(response.jsonPath().getString("desc"),"成功");
}catch(Exception e){
throw new Exception("创建接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("创建失败,返回信息:"+response.asString());
}
return response;
}
}
package http.service.goods;
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.HashMap;
import java.util.Map;
import static io.restassured.RestAssured.given;
@Service
public class DevDoUpdateObject {
@Value("${hdserver.host}")
String hdHost;
@Autowired
Authorization authorization;
//单规格实物---自有商品
public Response doUpdateAppItem(String appId,String levelLimitType,String classifyIds,String title,String sellingPoint,String levelCheckbox) throws Exception{
String url="http://"+hdHost+"/devItemNew/doUpdateObject";
Map<String,Object> map = new HashMap<>();
map.put("appId",appId);//应用ID
map.put("isOwner","1");//是否自有商品 1:是 0:否
map.put("multiImage","[\"//yun.dui88.com/images/201811/i01a314qr1.jpg\"]");//商品主图列表,json数组
map.put("multiSku","false");//是否为多规格,true:是, false:否
map.put("levelLimitType",levelLimitType);
map.put("classifyIds",classifyIds);//商品分组id列表
map.put("title",title);//标题
map.put("sellingPoint",sellingPoint);//卖点描述
map.put("devAudit","true");//是否开启商品审核 true:开启 false:关闭
map.put("arealimitSwitch","true");
map.put("arealimitAreas","[{\"provinceCode\":\"320000\",\"provinceName\":\"江苏省\",\"cityName\":\"全省范围\",\"cityCode\":\"all\"}]");
map.put("levelLimit","true");//是否开启vip等级限制 true开启,false 未开启
map.put("levelCheckbox",levelCheckbox);//会员等级列表
map.put("expressPrice","0");//运费价格
map.put("weixinShareDesc","");//微信分享描述
map.put("description","<p>图文详情:接口自动化的图文信息</p>");
map.put("type","object");//商品类型 object:实物,coupon:优惠券,virtual:虚拟商品 ,phonebill:话费 , alipay:支付宝 ,qb:Q币 ,phoneflow:流量
map.put("subType","0");//优惠券子类型 0:普通, 1:链接型 , 2:可重复, 3:卡密
map.put("limitType","forever");//限制类型,forever:永久 everyday 每天 DAY_3:表示每3天
map.put("limitCount","10");//限制次数
map.put("expressType","free");//运费类型,free:包邮,unity:统一运费,template:运费模板
map.put("attributes","[{\"skuInfo\":{\"remaining\":\"22\",\"salePrice\":\"222\",\"facePrice\":\"22\",\"merchantCoding\":\"test\"},\"children\":null}]");
//json 格式转成form表单
JSONObject jsonParam = JSONObject.parseObject(JSON.toJSONString(map));
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas()).body(jsonParam).post(url);
try{
Assert.assertEquals(response.jsonPath().getString("desc"),"成功");
}catch(Exception e){
throw new Exception("创建接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("创建失败,返回信息:"+response.asString());
}
return response;
}
//查询商品列表
public Response appItems(String appId,String itemName) throws Exception{
String url="http://" + hdHost+"/devItem/appItems";
Map<String,String> map = new HashMap<>();
map.put("appId",appId);
map.put("itemName",itemName);
map.put("rowId","1");
map.put("pageSize","10");
map.put("itemType","");
map.put("status","");
map.put("belong","");
map.put("priceType","");
map.put("classifyId","");
// logger.info("======="+url);
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas()).params(map).post(url);
try{
Assert.assertEquals(response.jsonPath().getString("success"),"true","/devItem/appItems接口失败");
}catch(Exception e){
throw new Exception("/devItem/appItems接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/devItem/appItems接口失败,返回信息:"+response.asString());
}
return response;
}
}
package http.service.goods;
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.HashMap;
import java.util.Map;
import static io.restassured.RestAssured.given;
@Service
public class DevDoUpdateVirtual {
@Value("${hdserver.host}")
String hdHost;
@Autowired
Authorization authorization;
//添加无规格商家充值
public Response doUpdateVirtualWuguige(String appId, String classifyIds, String title, String type) throws Exception{
String url="http://"+hdHost+"/devItemNew/doUpdateVirtual";
Map<String,Object> map = new HashMap<>();
map.put("appId",appId);//应用ID
map.put("isOwner","true");
map.put("multiImage","[\n" +
" \"//yun.dui88.com/images/201812/b0pt4h46nb.png\",\n" +
" \"//yun.dui88.com/images/201812/vkk5btvaec.png\"\n" +
" ]");
map.put("multiSku","false");//是否为多规格,true:是, false:否
map.put("levelLimitType","1");
map.put("arealimitType","1");
map.put("levelCheckbox","[]");
map.put("validDaterange","[]");
map.put("showJumpButton","false");
map.put("cardLibraryId","");
map.put("classifyIds",classifyIds);//商品分组
map.put("needAccount","true");//是否开启账号 true 开启,false 未开启
map.put("accountTitle","账号");
map.put("accountPrompt","请输入账号信");
map.put("title",title);
map.put("sellingPoint","我是卡密无规格的卖点描述");
map.put("smallImage","//yun.dui88.com/images/201812/mlc9aoosfk.jpg");
map.put("arealimitSwitch","false");
map.put("weixinShareDesc","微信分享信息");
map.put("autoOffDate","2030-12-31 00:00");
map.put("description","<p>图文详情</p>");
map.put("type",type);//商品类型
map.put("subType","0");//0:普通 1:链接 2:重复 3:卡密
map.put("limitType","forever");//限制类型
map.put("expressType","free");//运费类型,free:包邮,unity:统一运
//attributes 多规格列表
map.put("attributes","[\n" +
" {\n" +
" \"skuInfo\":{\n" +
" \"remaining\":\"100\",\n" +
" \"merchantCoding\":\"TTT002\",\n" +
" \"salePrice\":\"6.75\",\n" +
" \"facePrice\":\"2.35\"\n" +
" },\n" +
" \"children\":null\n" +
" }\n" +
" ]");
//json 格式转成form表单
JSONObject jsonParam = JSONObject.parseObject(JSON.toJSONString(map));
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas()).body(jsonParam).post(url);
try{
Assert.assertEquals(response.jsonPath().getString("desc"),"成功");
}catch(Exception e){
throw new Exception("创建接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("创建失败,返回信息:"+response.asString());
}
return response;
}
//添加多规格商家充值
public Response doUpdateVirtualDuoguige(String appId, String classifyIds, String title, String type) throws Exception{
String url="http://"+hdHost+"/devItemNew/doUpdateVirtual";
Map<String,Object> map = new HashMap<>();
map.put("appId",appId);//应用ID
map.put("isOwner","true");
map.put("multiImage","[\n" +
" \"//yun.dui88.com/images/201812/b0pt4h46nb.png\",\n" +
" \"//yun.dui88.com/images/201812/vkk5btvaec.png\"\n" +
" ]");
map.put("multiSku","true");//是否为多规格,true:是, false:否
map.put("levelLimitType","1");
map.put("arealimitType","1");
map.put("levelCheckbox","[]");
map.put("validDaterange","[]");
map.put("showJumpButton","false");
map.put("cardLibraryId","");
map.put("classifyIds",classifyIds);//商品分组
map.put("needAccount","true");//是否开启账号 true 开启,false 未开启
map.put("accountTitle","账号");
map.put("accountPrompt","请输入账号信");
map.put("title",title);
map.put("sellingPoint","我是卡密无规格的卖点描述");
map.put("smallImage","//yun.dui88.com/images/201812/mlc9aoosfk.jpg");
map.put("arealimitSwitch","false");
map.put("weixinShareDesc","微信分享信息");
map.put("autoOffDate","2030-12-31 00:00");
map.put("description","<p>图文详情</p>");
map.put("type",type);//商品类型
map.put("subType","0");//0:普通 1:链接 2:重复 3:卡密
map.put("limitType","forever");//限制类型
map.put("expressType","free");//运费类型,free:包邮,unity:统一运
//attributes 多规格列表
map.put("attributes","\n" +
" {\n" +
" \"id\":\"120\",\n" +
" \"skuInfo\":{\n" +
" \"remaining\":\"11\",\n" +
" \"salePrice\":\"13\",\n" +
" \"facePrice\":\"32\",\n" +
" \"merchantCoding\":\"111\"\n" +
" },\n" +
" \"specId\":\"0\",\n" +
" \"children\":null\n" +
" },\n" +
" {\n" +
" \"id\":\"121\",\n" +
" \"skuInfo\":{\n" +
" \"remaining\":\"2\",\n" +
" \"salePrice\":\"23\",\n" +
" \"facePrice\":\"32\",\n" +
" \"merchantCoding\":\"222\"\n" +
" },\n" +
" \"specId\":\"0\",\n" +
" \"children\":null\n" +
" },\n" +
" {\n" +
" \"id\":\"122\",\n" +
" \"skuInfo\":{\n" +
" \"remaining\":\"32\",\n" +
" \"salePrice\":\"24\",\n" +
" \"facePrice\":\"32.23\",\n" +
" \"merchantCoding\":\"333\"\n" +
" },\n" +
" \"specId\":\"0\",\n" +
" \"children\":null\n" +
" },\n" +
" {\n" +
" \"id\":\"123\",\n" +
" \"skuInfo\":{\n" +
" \"remaining\":\"2\",\n" +
" \"salePrice\":\"33\",\n" +
" \"facePrice\":\"32.23\",\n" +
" \"merchantCoding\":\"444\"\n" +
" },\n" +
" \"specId\":\"0\",\n" +
" \"children\":null\n" +
" },\n" +
" {\n" +
" \"id\":\"124\",\n" +
" \"skuInfo\":{\n" +
" \"remaining\":\"3\",\n" +
" \"salePrice\":\"21\",\n" +
" \"facePrice\":\"32.43\",\n" +
" \"merchantCoding\":\"555\"\n" +
" },\n" +
" \"specId\":\"0\",\n" +
" \"children\":null\n" +
" }\n" +
" ]");
//json 格式转成form表单
JSONObject jsonParam = JSONObject.parseObject(JSON.toJSONString(map));
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas()).body(jsonParam).post(url);
try{
Assert.assertEquals(response.jsonPath().getString("desc"),"成功");
}catch(Exception e){
throw new Exception("创建接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("创建失败,返回信息:"+response.asString());
}
return response;
}
}
package http.service.goods;
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.HashMap;
import java.util.Map;
import static io.restassured.RestAssured.given;
@Service
public class DoUpdateCredits {
@Value("${hdserver.host}")
String hdHost;
@Autowired
Authorization authorization;
//获取商品ID
public Response getCreditsDetail(String appId,String appItemId) throws Exception{
String url="http://"+hdHost+"devItemNew/getCreditsDetail";
Map<String,Object> map = new HashMap<>();
map.put("appId",appId);//appid
map.put("appItemId",appItemId);//商品ID
//json 格式转成form表单
JSONObject jsonParam = JSONObject.parseObject(JSON.toJSONString(map));
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas()).body(jsonParam).get(url);
try{
Assert.assertEquals(response.jsonPath().getString("desc"),"成功");
}catch(Exception e){
throw new Exception("创建接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("创建失败,返回信息:"+response.asString());
}
return response;
}
//保存积分配置
public Response doUpdateCredits(String appId, String appItemId,String creditsInfos) throws Exception{
String url="http://"+hdHost+"/devItemNew/doUpdateCredits";
Map<String,Object> map = new HashMap<>();
map.put("appId",appId);//appid
map.put("appItemId",appItemId);//商品ID
map.put("buttonText","");
map.put("creditsInfos",creditsInfos);//自定义
map.put("dateRage","[\"2018-11-29\", \"2019-05-31\"]");
map.put("exchangeType","1");//兑换类型,1:自动 2:自定义
map.put("indexHidden","true");//是否在首页商品区隐藏,true:隐藏 false:显示
map.put("limitDate","2018-11-29,2019-05-31");//兑换日期限制
map.put("limitEverydayQuantity","6");//每日限量
map.put("multiSku","false");
map.put("onSale","false");//是否上架 true:立即上架 false:放入仓库
map.put("originalPriceBuy","true");//是否支持原价购买 ,true:支持 false:不支持
//json 格式转成form表单
JSONObject jsonParam = JSONObject.parseObject(JSON.toJSONString(map));
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas()).body(jsonParam).post(url);
try{
Assert.assertEquals(response.jsonPath().getString("desc"),"成功");
}catch(Exception e){
throw new Exception("创建接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("创建失败,返回信息:"+response.asString());
}
return response;
}
}
package http.service.goods;
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.HashMap;
import java.util.Map;
import static io.restassured.RestAssured.given;
@Service
public class DuibaCards {
@Value("${manager.host}")
String ManagerHost;//ManagerHost = mng.duibatest.com.cn
@Autowired
Authorization authorization;
//添加券码
public Response cardsSave(String appId,String type,String name) throws Exception {
String url="http://"+ManagerHost+"/cardLibrary/save";
Map<String,Object> map = new HashMap<>();
map.put("appId",appId);//应用ID
map.put("type",type);//类型
map.put("name",name);//名称
map.put("fileUrl","http%3A%2F%2Fyun.dui88.com%2Fcoupons%2F1544497069778.txt");//文件地址
map.put("startDay","");//有效期--开始时间
map.put("endDay","");//有效期--结束时间
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.ssoLogin()).post(url);
try{
Assert.assertEquals(response.jsonPath().getString("desc"),"成功");
}catch(Exception e){
throw new Exception("创建接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("创建失败,返回信息:"+response.asString());
}
return response;
}
//查询
public Response list(String appId,String name,String type,String excludeRelated) throws Exception {
String url="http://"+ManagerHost+"/cardLibrary/list";
Map<String,Object> map = new HashMap<>();
map.put("name",name);//名称
map.put("pageNo","1");
map.put("pageSize","15");
map.put("appId",appId);
map.put("type",type);//类型:0:券码 1:链接 2:重复 3:卡密
map.put("excludeRelated",excludeRelated);//true:排查已关联的 false:不排除
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.ssoLogin()).get(url);
try{
Assert.assertEquals(response.jsonPath().getString("desc"),"成功");
}catch(Exception e){
throw new Exception("创建接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("创建失败,返回信息:"+response.asString());
}
return response;
}
//导入批次
//删除
public Response delete(String appId,String id) throws Exception {
String url="http://"+ManagerHost+"/cardLibrary/delete";
Map<String,Object> map = new HashMap<>();
map.put("appId",appId);
map.put("id",id);
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.ssoLogin()).post(url);
try{
Assert.assertEquals(response.jsonPath().getString("desc"),"成功");
}catch(Exception e){
throw new Exception("创建接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("创建失败,返回信息:"+response.asString());
}
return response;
}
}
package http.service.goods;
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.HashMap;
import java.util.Map;
import static io.restassured.RestAssured.given;
@Service
public class DuibaDoUpdateCoupon {
@Value("${manager.host}")
String ManagerHost;//ManagerHost = mng.duibatest.com.cn
@Autowired
Authorization authorization;
//优惠券--链接券
public Response doUpdateCouponLianjie(String name) throws Exception {
String url="http://"+ManagerHost+"/newmanager/goods/coupon/doUpdateCoupon";
Map<String,Object> map = new HashMap<>();
map.put("subType","1");//0 普通券 1链接券 2重复券
map.put("multiImage","//yun.dui88.com/images/201812/b02d3ed2t1.png");
map.put("preSaasMallVTypeList","[]");
map.put("saasMallVTypeList","[]");
map.put("expressType","unity");
map.put("arealimitType","1");
map.put("arealimitSwitch","on");
map.put("opTypeCaptchaCheck","on");
map.put("directRecharge","0");
map.put("multiSku","false");//是否多规格,false 否,true 是
map.put("attributes","[\n" +
" {\n" +
" \"skuInfo\":{\n" +
" \"remaining\":100,\n" +
" \"salePrice\":\"10\",\n" +
" \"suggestMarketPrice\":\"11\",\n" +
" \"facePrice\":\"222\"\n" +
" },\n" +
" \"children\":null\n" +
" }\n" +
" ]");//多规格列表
map.put("cardLibraryId","");//卡券库ID
map.put("classifyId","");//优惠券分类
map.put("opTypeActivity","off");//是否活动专用
map.put("itemLimitConfigVO","{\n" +
" \"limitScope\":\"forever\",\n" +
" \"limitCount\":\"10\"\n" +
" }");//
map.put("showBarCode","");
map.put("showButton","");
map.put("linkUrl","http://www.baidu.com");
map.put("validDaterange","");
map.put("couponCode","");
map.put("couponCount","100");
map.put("validStartDay","2018-12-22");
map.put("validEndDay","2058-12-22");
map.put("name",name);
map.put("memo","接口自动化--链接券");
map.put("smallImage","//yun.dui88.com/images/201812/80r8dze8zz.pn");
map.put("arealimitAreas","[\n" +
" {\n" +
" \"provinceCode\":\"320000\",\n" +
" \"provinceName\":\"江苏省\",\n" +
" \"cityName\":\"全省范围\",\n" +
" \"cityCode\":\"all\"\n" +
" }\n" +
" ]");
map.put("usageRule","<p>21212</p>");
map.put("type","coupon");
//json 格式转成form表单
JSONObject jsonParam = JSONObject.parseObject(JSON.toJSONString(map));
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.ssoLogin()).body(jsonParam).post(url);
try{
Assert.assertEquals(response.jsonPath().getString("desc"),"成功");
}catch(Exception e){
throw new Exception("创建接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("创建失败,返回信息:"+response.asString());
}
return response;
}
//添加重复券码
public Response doUpdateCouponChongfu(String name) throws Exception {
String url="http://"+ManagerHost+"/newmanager/goods/coupon/doUpdateCoupon";
Map<String,Object> map = new HashMap<>();
map.put("subType","2");//0 普通券 1链接券 2重复券
map.put("multiImage","//yun.dui88.com/images/201812/b02d3ed2t1.png");
map.put("preSaasMallVTypeList","[]");
map.put("saasMallVTypeList","[]");
map.put("expressType","unity");
map.put("arealimitType","1");
map.put("arealimitSwitch","on");
map.put("opTypeCaptchaCheck","on");
map.put("directRecharge","0");
map.put("multiSku","false");//是否多规格,false 否,true 是
map.put("attributes","[\n" +
" {\n" +
" \"skuInfo\":{\n" +
" \"remaining\":100,\n" +
" \"salePrice\":\"88\",\n" +
" \"suggestMarketPrice\":\"188\",\n" +
" \"facePrice\":\"20\"\n" +
" },\n" +
" \"children\":null\n" +
" }\n" +
" ]");//多规格列表
map.put("cardLibraryId","");//卡券库ID
map.put("classifyId","");//优惠券分类
map.put("opTypeActivity","off");//是否活动专用
map.put("itemLimitConfigVO","{\n" +
" \"limitScope\":\"forever\",\n" +
" \"limitCount\":\"10\"\n" +
" }");//
map.put("showBarCode","");
map.put("showButton","");
map.put("linkUrl","");
map.put("validDaterange","");
map.put("couponCode","9999");
map.put("couponCount","200");
map.put("validStartDay","2018-12-22");
map.put("validEndDay","2058-12-22");
map.put("name",name);
map.put("memo","接口自动化--重复券");
map.put("smallImage","//yun.dui88.com/images/201812/80r8dze8zz.pn");
map.put("arealimitAreas","[\n" +
" {\n" +
" \"provinceCode\":\"320000\",\n" +
" \"provinceName\":\"江苏省\",\n" +
" \"cityName\":\"全省范围\",\n" +
" \"cityCode\":\"all\"\n" +
" }\n" +
" ]");
map.put("usageRule","<p>21212</p>");
map.put("type","coupon");
//json 格式转成form表单
JSONObject jsonParam = JSONObject.parseObject(JSON.toJSONString(map));
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.ssoLogin()).body(jsonParam).post(url);
try{
Assert.assertEquals(response.jsonPath().getString("desc"),"成功");
}catch(Exception e){
throw new Exception("创建接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("创建失败,返回信息:"+response.asString());
}
return response;
}
//新增普通券码
public Response doUpdateCouponPutong(String name,String cardLibraryId,String cardLibraryName) throws Exception {
String url="http://"+ManagerHost+"/newmanager/goods/coupon/doUpdateCoupon";
Map<String,Object> map = new HashMap<>();
map.put("subType","0");//0 普通券 1链接券 2重复券
map.put("multiImage","//yun.dui88.com/images/201812/b02d3ed2t1.png");
map.put("preSaasMallVTypeList","[]");
map.put("saasMallVTypeList","[]");
map.put("expressType","unity");
map.put("arealimitType","1");
map.put("arealimitSwitch","on");
map.put("opTypeCaptchaCheck","on");
map.put("directRecharge","0");
map.put("multiSku","false");//是否多规格,false 否,true 是
map.put("attributes","[\n" +
" {\n" +
" \"skuInfo\":{\n" +
" \"remaining\":9,\n" +
" \"salePrice\":\"36\",\n" +
" \"suggestMarketPrice\":\"72\",\n" +
" \"facePrice\":\"20\"\n" +
" },\n" +
" \"children\":null\n" +
" }\n" +
" ]");//多规格列表
map.put("cardLibraryId",cardLibraryId);//卡券库ID
map.put("cardLibraryName",cardLibraryName);
map.put("classifyId","");//优惠券分类
map.put("opTypeActivity","off");//是否活动专用
map.put("itemLimitConfigVO","{\n" +
" \"limitScope\":\"forever\",\n" +
" \"limitCount\":\"10\"\n" +
" }");//
map.put("showBarCode","");
map.put("showButton","");
map.put("linkUrl","");
map.put("validStartDay","2018-12-22");
map.put("validEndDay","2058-12-22");
map.put("name",name);
map.put("memo","接口自动化--重复券");
map.put("smallImage","//yun.dui88.com/images/201812/80r8dze8zz.pn");
map.put("arealimitAreas","[\n" +
" {\n" +
" \"provinceCode\":\"320000\",\n" +
" \"provinceName\":\"江苏省\",\n" +
" \"cityName\":\"全省范围\",\n" +
" \"cityCode\":\"all\"\n" +
" }\n" +
" ]");
map.put("usageRule","<p>21212</p>");
map.put("type","coupon");
//json 格式转成form表单
JSONObject jsonParam = JSONObject.parseObject(JSON.toJSONString(map));
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.ssoLogin()).body(jsonParam).post(url);
try{
Assert.assertEquals(response.jsonPath().getString("desc"),"成功");
}catch(Exception e){
throw new Exception("创建接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("创建失败,返回信息:"+response.asString());
}
return response;
}
//删除优惠券
public Response deleteItem(String id) throws Exception {
String url="http://"+ManagerHost+"/newmanager/goods/item/deleteItem/"+id;
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.ssoLogin()).get();
try{
Assert.assertEquals(response.jsonPath().getString("desc"),"成功");
}catch(Exception e){
throw new Exception("创建接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("创建失败,返回信息:"+response.asString());
}
return response;
}
}
package http.service.goods;
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.HashMap;
import java.util.Map;
import static io.restassured.RestAssured.given;
@Service
public class DuibaList {
@Value("${manager.host}")
String ManagerHost;//ManagerHost = mng.duibatest.com.cn
@Autowired
Authorization authorization;
//查询列表
public Response listIndex(String nameType,String name) throws Exception{
String url="http://"+ManagerHost+"/newmanager/goods/item/index";
Map<String,Object> map = new HashMap<>();
map.put("status","");
map.put("itemType","");
map.put("operType","");
map.put("nameType",nameType);//??
map.put("pageSize","20");
map.put("pageNo","1");
map.put("itemClassifyIdObject","");
map.put("itemClassifyIdCoupon","");
map.put("itemName",name);//商品名称
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.ssoLogin()).get(url);
try{
Assert.assertEquals(response.jsonPath().getString("desc"),"成功");
}catch(Exception e){
throw new Exception("创建接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("创建失败,返回信息:"+response.asString());
}
return response;
}
}
package http.service.goods;
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.HashMap;
import java.util.Map;
import static io.restassured.RestAssured.given;
@Service
public class DuibadoUpdateObject {
@Value("${manager.host}")
String ManagerHost;//ManagerHost = mng.duibatest.com.cn
@Autowired
Authorization authorization;
//单规格实物---兑吧商品
public Response doUpdateObject(String name) throws Exception {
String url="http://"+ManagerHost+"/goods/object/doUpdateObject";
Map<String,Object> map = new HashMap<>();
map.put("type","object");//商品类型 object:实物,coupon:优惠券,virtual:虚拟商品 ,phonebill:话费 , alipay:支付宝 ,qb:Q币 ,phoneflow:流量
map.put("multiImage","[\"//yun.dui88.com/images/201811/ndz1zqhyh3.png\"]");//商品主图列表
map.put("preSaasMallVTypeList","[]");//未修改前SAAS版本限购
map.put("saasMallVTypeList","[1,2,3,4]");//SAAS版本限购
map.put("expressType","unity");//运费类型,free:包邮,unity:统一运费,template:运费模板
map.put("directRecharge","0");//实物兑换直充类 值为:0 | 1 | 2 | 3; NOR_MALL(0, "无(非直充类)"), PRO_MALL(1, "话费、流量(手机号)"), FLAG_MALL(2, "Q币(QQ号)"), EXTRAME_MALL(3, "支付宝(姓名、支付宝账号)");
map.put("multiSku","false");//是否为多规格,true:是, false:否
map.put("attrsCopy","[]");//
map.put("opTypeActivity","off");//是否活动专用 on 是,off 否
map.put("activityImage","");//活动图片
map.put("name",name);//商品名称
map.put("memo","兑吧商品备注");//商品备注
map.put("smallImage","//yun.dui88.com/images/201811/8quo3igywn.png");//商品缩略图
map.put("expressPrice","3");//运费价格
map.put("description","商品描述分享信息");//详情
map.put("alertMessage","999");//待发货文案
//规格属性
map.put("attributes","[{\"skuInfo\":{\"remaining\":\"100\",\"supplyPrice\":\"10\",\"salePrice\":\"22\",\"facePrice\":\"11\",\"merchantCoding\":\"TTTYYY\"},\"children\":null}]");//
//json 格式转成form表单
JSONObject jsonParam = JSONObject.parseObject(JSON.toJSONString(map));
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.ssoLogin()).body(jsonParam).post(url);
try{
Assert.assertEquals(response.jsonPath().getString("desc"),"成功");
}catch(Exception e){
throw new Exception("创建接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("创建失败,返回信息:"+response.asString());
}
return response;
}
//多规格实物---兑吧商品
public Response moreDoUpdateObject(String name,String memo) throws Exception {
String url="http://"+ManagerHost+"/goods/object/doUpdateObject";
Map<String,Object> map = new HashMap<>();
map.put("attributes","[{id: \"161\", skuInfo: {}, specId: \"30\",…}, {id: \"162\", skuInfo: {}, specId: \"30\",…},…]");
map.put("type","object");
map.put("multiImage","//yun.dui88.com/images/201812/pxstomsmtn.png");
map.put("preSaasMallVTypeList","[]");
map.put("expressType","unity");
map.put("directRecharge","0");
map.put("multiSku","true");
map.put("attrsCopy","[\n" +
" {\n" +
" \"30\":\"161\",\n" +
" \"31\":\"164\",\n" +
" \"skuInfo\":{\n" +
" \"remaining\":\"1\",\n" +
" \"salePrice\":\"2\",\n" +
" \"suggestMarketPrice\":\"9\",\n" +
" \"facePrice\":\"11\"\n" +
" },\n" +
" \"guigeId\":\"31\",\n" +
" \"id\":\"164\",\n" +
" \"attributeValue\":\"红色\"\n" +
" },\n" +
" {\n" +
" \"30\":\"161\",\n" +
" \"31\":\"165\",\n" +
" \"skuInfo\":{\n" +
" \"remaining\":\"2\",\n" +
" \"salePrice\":\"3\",\n" +
" \"suggestMarketPrice\":\"19.99\",\n" +
" \"facePrice\":\"\"\n" +
" },\n" +
" \"guigeId\":\"31\",\n" +
" \"id\":\"165\",\n" +
" \"attributeValue\":\"黑色\"\n" +
" },\n" +
" {\n" +
" \"30\":\"162\",\n" +
" \"31\":\"164\",\n" +
" \"skuInfo\":{\n" +
" \"remaining\":\"3\",\n" +
" \"salePrice\":\"4\",\n" +
" \"suggestMarketPrice\":\"22\"\n" +
" },\n" +
" \"guigeId\":\"31\",\n" +
" \"id\":\"164\",\n" +
" \"attributeValue\":\"红色\"\n" +
" },\n" +
" {\n" +
" \"30\":\"162\",\n" +
" \"31\":\"165\",\n" +
" \"skuInfo\":{\n" +
" \"remaining\":\"4\",\n" +
" \"salePrice\":\"5\",\n" +
" \"suggestMarketPrice\":\"0.01\",\n" +
" \"facePrice\":\"12\"\n" +
" },\n" +
" \"guigeId\":\"31\",\n" +
" \"id\":\"165\",\n" +
" \"attributeValue\":\"黑色\"\n" +
" },\n" +
" {\n" +
" \"30\":\"163\",\n" +
" \"31\":\"164\",\n" +
" \"skuInfo\":{\n" +
" \"remaining\":\"5\",\n" +
" \"salePrice\":\"6\",\n" +
" \"suggestMarketPrice\":\"0.02\",\n" +
" \"facePrice\":\"21\"\n" +
" },\n" +
" \"guigeId\":\"31\",\n" +
" \"id\":\"164\",\n" +
" \"attributeValue\":\"红色\"\n" +
" },\n" +
" {\n" +
" \"30\":\"163\",\n" +
" \"31\":\"165\",\n" +
" \"skuInfo\":{\n" +
" \"remaining\":\"6\",\n" +
" \"salePrice\":\"7\",\n" +
" \"suggestMarketPrice\":\"2\"\n" +
" },\n" +
" \"guigeId\":\"31\",\n" +
" \"id\":\"165\",\n" +
" \"attributeValue\":\"黑色\"\n" +
" }\n" +
" ]");
map.put("name",name);
map.put("memo",memo);
map.put("smallImage","//yun.dui88.com/images/201812/n78va2s3at.jpg");
map.put("oldTableData","[\n" +
" {\n" +
" \"30\":\"161\",\n" +
" \"31\":\"164\",\n" +
" \"skuInfo\":{\n" +
" \"remaining\":\"1\",\n" +
" \"salePrice\":\"2\",\n" +
" \"suggestMarketPrice\":\"9\",\n" +
" \"facePrice\":\"11\"\n" +
" },\n" +
" \"guigeId\":\"31\",\n" +
" \"id\":\"164\",\n" +
" \"attributeValue\":\"红色\"\n" +
" },\n" +
" {\n" +
" \"30\":\"161\",\n" +
" \"31\":\"165\",\n" +
" \"skuInfo\":{\n" +
" \"remaining\":\"2\",\n" +
" \"salePrice\":\"3\",\n" +
" \"suggestMarketPrice\":\"19.99\",\n" +
" \"facePrice\":\"\"\n" +
" },\n" +
" \"guigeId\":\"31\",\n" +
" \"id\":\"165\",\n" +
" \"attributeValue\":\"黑色\"\n" +
" },\n" +
" {\n" +
" \"30\":\"162\",\n" +
" \"31\":\"164\",\n" +
" \"skuInfo\":{\n" +
" \"remaining\":\"3\",\n" +
" \"salePrice\":\"4\",\n" +
" \"suggestMarketPrice\":\"22\"\n" +
" },\n" +
" \"guigeId\":\"31\",\n" +
" \"id\":\"164\",\n" +
" \"attributeValue\":\"红色\"\n" +
" },\n" +
" {\n" +
" \"30\":\"162\",\n" +
" \"31\":\"165\",\n" +
" \"skuInfo\":{\n" +
" \"remaining\":\"4\",\n" +
" \"salePrice\":\"5\",\n" +
" \"suggestMarketPrice\":\"0.01\",\n" +
" \"facePrice\":\"12\"\n" +
" },\n" +
" \"guigeId\":\"31\",\n" +
" \"id\":\"165\",\n" +
" \"attributeValue\":\"黑色\"\n" +
" },\n" +
" {\n" +
" \"30\":\"163\",\n" +
" \"31\":\"164\",\n" +
" \"skuInfo\":{\n" +
" \"remaining\":\"5\",\n" +
" \"salePrice\":\"6\",\n" +
" \"suggestMarketPrice\":\"0.02\",\n" +
" \"facePrice\":\"21\"\n" +
" },\n" +
" \"guigeId\":\"31\",\n" +
" \"id\":\"164\",\n" +
" \"attributeValue\":\"红色\"\n" +
" },\n" +
" {\n" +
" \"30\":\"163\",\n" +
" \"31\":\"165\",\n" +
" \"skuInfo\":{\n" +
" \"remaining\":\"6\",\n" +
" \"salePrice\":\"7\",\n" +
" \"suggestMarketPrice\":\"2\"\n" +
" },\n" +
" \"guigeId\":\"31\",\n" +
" \"id\":\"165\",\n" +
" \"attributeValue\":\"黑色\"\n" +
" }\n" +
" ]");
map.put("expressPrice","0");
map.put("saasMallVTypeList","[]");
map.put("attributes","[\n" +
" {\n" +
" \"id\":\"161\",\n" +
" \"skuInfo\":{\n" +
"\n" +
" },\n" +
" \"specId\":\"30\",\n" +
" \"children\":[\n" +
" {\n" +
" \"id\":\"164\",\n" +
" \"imgUrl\":null,\n" +
" \"skuInfo\":{\n" +
" \"remaining\":\"1\",\n" +
" \"salePrice\":\"2\",\n" +
" \"suggestMarketPrice\":\"9\",\n" +
" \"facePrice\":\"11\"\n" +
" },\n" +
" \"specId\":\"31\",\n" +
" \"children\":null\n" +
" },\n" +
" {\n" +
" \"id\":\"165\",\n" +
" \"imgUrl\":null,\n" +
" \"skuInfo\":{\n" +
" \"remaining\":\"2\",\n" +
" \"salePrice\":\"3\",\n" +
" \"suggestMarketPrice\":\"19.99\",\n" +
" \"facePrice\":\"\"\n" +
" },\n" +
" \"specId\":\"31\",\n" +
" \"children\":null\n" +
" }\n" +
" ]\n" +
" },\n" +
" {\n" +
" \"id\":\"162\",\n" +
" \"skuInfo\":{\n" +
"\n" +
" },\n" +
" \"specId\":\"30\",\n" +
" \"children\":[\n" +
" {\n" +
" \"id\":\"164\",\n" +
" \"imgUrl\":null,\n" +
" \"skuInfo\":{\n" +
" \"remaining\":\"3\",\n" +
" \"salePrice\":\"4\",\n" +
" \"suggestMarketPrice\":\"22\"\n" +
" },\n" +
" \"specId\":\"31\",\n" +
" \"children\":null\n" +
" },\n" +
" {\n" +
" \"id\":\"165\",\n" +
" \"imgUrl\":null,\n" +
" \"skuInfo\":{\n" +
" \"remaining\":\"4\",\n" +
" \"salePrice\":\"5\",\n" +
" \"suggestMarketPrice\":\"0.01\",\n" +
" \"facePrice\":\"12\"\n" +
" },\n" +
" \"specId\":\"31\",\n" +
" \"children\":null\n" +
" }\n" +
" ]\n" +
" },\n" +
" {\n" +
" \"id\":\"163\",\n" +
" \"skuInfo\":{\n" +
"\n" +
" },\n" +
" \"specId\":\"30\",\n" +
" \"children\":[\n" +
" {\n" +
" \"id\":\"164\",\n" +
" \"imgUrl\":null,\n" +
" \"skuInfo\":{\n" +
" \"remaining\":\"5\",\n" +
" \"salePrice\":\"6\",\n" +
" \"suggestMarketPrice\":\"0.02\",\n" +
" \"facePrice\":\"21\"\n" +
" },\n" +
" \"specId\":\"31\",\n" +
" \"children\":null\n" +
" },\n" +
" {\n" +
" \"id\":\"165\",\n" +
" \"imgUrl\":null,\n" +
" \"skuInfo\":{\n" +
" \"remaining\":\"6\",\n" +
" \"salePrice\":\"7\",\n" +
" \"suggestMarketPrice\":\"2\"\n" +
" },\n" +
" \"specId\":\"31\",\n" +
" \"children\":null\n" +
" }\n" +
" ]\n" +
" }\n" +
" ]");
//json 格式转成form表单
JSONObject jsonParam = JSONObject.parseObject(JSON.toJSONString(map));
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.ssoLogin()).body(jsonParam).post(url);
try{
Assert.assertEquals(response.jsonPath().getString("desc"),"成功");
}catch(Exception e){
throw new Exception("创建接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("创建失败,返回信息:"+response.asString());
}
return response;
}
//活动商品
public Response ActivityDoUpdateObject(String name) throws Exception {
String url="http://"+ManagerHost+"/goods/object/doUpdateObject";
Map<String,Object> map = new HashMap<>();
map.put("type","object");
map.put("multiImage","[\"//yun.dui88.com/images/201811/ndz1zqhyh3.png\"]");
map.put("preSaasMallVTypeList","[]");
map.put("saasMallVTypeList","[1,2,3,4]");
map.put("expressType","unity");
map.put("directRecharge","0");
map.put("multiSku","true");//
map.put("attrsCopy","[]");
map.put("opTypeActivity","on");//是否开启活动
map.put("activityImage","//yun.dui88.com/images/201811/8quo3igywn.png");//活动中奖图片
map.put("name",name);
map.put("memo","兑吧商品备注");
map.put("smallImage","//yun.dui88.com/images/201811/8quo3igywn.png");//商品缩略图
map.put("expressPrice","3");
map.put("description","商品描述分享信息");
map.put("alertMessage","999");
map.put("attributes","[{\"skuInfo\":{\"remaining\":\"100\",\"supplyPrice\":\"10\",\"salePrice\":\"22\",\"facePrice\":\"11\",\"merchantCoding\":\"TTTYYY\"},\"children\":null}]");
//json 格式转成form表单
JSONObject jsonParam = JSONObject.parseObject(JSON.toJSONString(map));
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.ssoLogin()).body(jsonParam).post(url);
try{
Assert.assertEquals(response.jsonPath().getString("desc"),"成功");
}catch(Exception e){
throw new Exception("创建接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("创建失败,返回信息:"+response.asString());
}
return response;
}
}
package ui.cases.Activity;
import base.DuibaBaseUi;
import org.apache.commons.lang.StringUtils;
import org.testng.Assert;
import org.testng.annotations.Test;
import ui.service.Activity_egg_Page;
import ui.service.HomePage;
import ui.service.MoblieLogin;
import utils.StringUtil;
import static com.codeborne.selenide.Selenide.open;
/**
* Created by mabo on 2018/12/13
*/
public class 优惠券_Activity_ui extends DuibaBaseUi{
@Test
public void 正常流程() throws Exception {
// new MoblieLogin("5074",this);
// clickByClass("btn-close");
// screenshot();
// clickByTextEqual("ui自动化-活动工具-优惠券");
// screenshot();
// clickByClass("egg jump");
//
// clickByTextEqual("ui自动化-优惠券(活动)");
// sleep(2);
// clickByClass("J_gotoDetail logandgo");
//用户登陆,app 13193311111
new MoblieLogin("5074",this);
//手机端楼层
new HomePage("ui自动化-砸彩蛋-优惠券",this);
sleep(2);
new Activity_egg_Page("查看详情",this);
sleep(2);
Assert.assertTrue(isExistByText("ui自动化-优惠券(活动)"));
Assert.assertTrue(isExistByText("券码:"));
Assert.assertTrue(isExistByText("1111111"));
Assert.assertTrue(isExistByText("密码:"));
Assert.assertTrue(isExistByText("22222222"));
Assert.assertTrue(isExistByText("\n" +
" ui自动化-优惠券-使用说明"),"没有商品详情文本");
}
}
package ui.cases.Activity;
import base.DuibaBaseUi;
import org.testng.Assert;
import org.testng.annotations.Test;
import ui.service.Activity_egg_Page;
import ui.service.HomePage;
import ui.service.MoblieLogin;
import ui.service.TakePrizeNewPage;
import static com.codeborne.selenide.Selenide.open;
/**
* Created by mabo on 2018/12/14
*/
public class 实物_Activity_ui extends DuibaBaseUi{
@Test
public void 正常流程() throws Exception {
new MoblieLogin("5074",this);
//手机端楼层
new HomePage("ui自动化-砸彩蛋-实物",this);
new Activity_egg_Page("立即领奖",this);
new TakePrizeNewPage("马上领取",this);
sleep(2);
Assert.assertTrue(isExistByText("收货人:uitest  "),"出奖弹层校验失败");
Assert.assertTrue(isExistByText("13111133322"),"出奖弹层校验失败");//北京市北京市东城区东华门街道test
Assert.assertTrue(isExistByText("北京市北京市东城区东华门街道test "),"出奖弹层校验失败");
Assert.assertTrue(isExistByText("待发货"),"出奖弹层校验失败");
Assert.assertTrue(isExistByText("ui自动化-实物(活动)"),"出奖弹层校验失败");
Assert.assertTrue(isExistByText("订单来源:抽奖"),"出奖弹层校验失败");
}
}
package ui.cases.Activity;
import base.DuibaBaseUi;
import org.testng.Assert;
import org.testng.annotations.Test;
import ui.service.Activity_egg_Page;
import ui.service.HomePage;
import ui.service.MoblieLogin;
import static com.codeborne.selenide.Selenide.open;
/**
* Created by mabo on 2018/12/14
*/
public class 支付宝_Activity_ui extends DuibaBaseUi{
@Test
public void 正常流程() throws Exception {
new MoblieLogin("5074",this);
//手机端楼层
new HomePage("ui自动化-砸彩蛋-支付宝",this);
new Activity_egg_Page("立即领奖",this);
sleep(2);
clickByTextEqual("马上领取");
clickByTextEqual("确定");
sleep(5);
Assert.assertTrue(isExistByText("恭喜您兑换成功"),"出奖弹层校验失败");
Assert.assertTrue(isExistByText("充值帐号:"),"出奖弹层校验失败");
Assert.assertTrue(isExistByText("peeulk6392@sandbox.com"),"出奖弹层校验失败");
Assert.assertTrue(isExistByText("订单状态:"),"出奖弹层校验失败");
Assert.assertTrue(isExistByText("成功"),"出奖弹层校验失败");
Assert.assertTrue(isExistByText("订单编号:"),"出奖弹层校验失败");
}
}
package ui.cases.Activity;
import base.DuibaBaseUi;
import org.testng.Assert;
import org.testng.annotations.Test;
import ui.service.Activity_egg_Page;
import ui.service.HomePage;
import ui.service.MoblieLogin;
import static com.codeborne.selenide.Selenide.open;
/**
* Created by mabo on 2018/12/14
*/
public class 虚拟商品_Activity_ui extends DuibaBaseUi{
@Test
public void 正常流程() throws Exception {
new MoblieLogin("5074",this);
//手机端楼层
new HomePage("ui自动化-砸彩蛋-虚拟商品",this);
sleep(2);
new Activity_egg_Page("查看奖品",this);
Assert.assertTrue(isExistByText("ui自动化-活动工具-虚拟商品"),"出奖弹层校验失败");
Assert.assertTrue(isExistByText("已领奖"),"出奖弹层校验失败");
Assert.assertTrue(isExistByText("\n" +
"\t\t\tui自动化-活动工具-虚拟商品-详细说明\n" +
"\t\t"),"出奖弹层校验失败");
}
}
package ui.cases.Activity;
import base.DuibaBaseUi;
import org.testng.Assert;
import org.testng.annotations.Test;
import ui.service.Activity_egg_Page;
import ui.service.HomePage;
import ui.service.MoblieLogin;
import static com.codeborne.selenide.Selenide.open;
/**
* Created by mabo on 2018/12/14
*/
public class 谢谢参与_Activity_ui extends DuibaBaseUi{
@Test
public void 正常流程() throws Exception {
new MoblieLogin("5074",this);
//手机端楼层
new HomePage("ui自动化-活动工具-谢谢参与",this);
new Activity_egg_Page(null,this);
Assert.assertTrue(isExistByClass("noPrizes modal"));
}
}
......@@ -2,7 +2,11 @@ package ui.cases.Exchange;
import base.DuibaBaseUi;
import org.openqa.selenium.By;
import org.testng.Assert;
import org.testng.annotations.Test;
import ui.service.ExchangePage;
import ui.service.HomePage;
import ui.service.MoblieLogin;
import static com.codeborne.selenide.Selenide.$;
import static com.codeborne.selenide.Selenide.open;
......@@ -13,21 +17,21 @@ import static com.codeborne.selenide.Selenide.open;
public class 优惠券_ExchangeTest_ui extends DuibaBaseUi{
@Test
public void 优惠券兑换_正常流程() throws Exception {
open("http://dafuweng.duibatest.com.cn/user/index");
clickByTextEqual("5074");
switchWindow();
sleep(2);
clickByClass("btn-close");
screenshot();
clickByTextEqual("ui自动化-优惠券");
screenshot();
clickByTextEqual("马上兑换");
screenshot();
clickByTextEqual("确定");
screenshot();
//通过dafuweng登陆手机端
new MoblieLogin("5074",this);
//手机端楼层
new HomePage("ui自动化-优惠券",this);
//兑换页面
new ExchangePage("马上兑换",this);
sleep(5);
screenshot();
Assert.assertTrue(isExistByText("恭喜,兑换成功"));
Assert.assertTrue(isExistByText("ui自动化-优惠券"));
Assert.assertTrue(isExistByText("券码:"));
Assert.assertTrue(isExistByText("44444"));
Assert.assertTrue(isExistByText("密码:"));
Assert.assertTrue(isExistByText("5555555"));
}
}
package ui.cases.Exchange;
import base.DuibaBaseUi;
import org.testng.Assert;
import org.testng.annotations.Test;
import ui.service.ExchangePage;
import ui.service.HomePage;
import ui.service.MoblieLogin;
import static com.codeborne.selenide.Selenide.open;
......@@ -11,20 +15,39 @@ import static com.codeborne.selenide.Selenide.open;
public class 实物_ExchangeTest_ui extends DuibaBaseUi{
@Test
public void 实物兑换_正常流程() throws Exception {
open("http://dafuweng.duibatest.com.cn/user/index");
clickByTextEqual("5074");
switchWindow();
sleep(2);
clickByClass("btn-close");
screenshot();
clickByTextEqual("ui自动化-实物");
screenshot();
clickByTextEqual("马上兑换");
screenshot();
clickByTextEqual("确定");
screenshot();
// new MoblieLogin("5074",this);
// clickByClass("btn-close");
// screenshot();
// clickByTextEqual("ui自动化-实物");
// screenshot();
// clickByTextEqual("马上兑换");
// screenshot();
// clickByTextEqual("确定");
// screenshot();
// sleep(5);
// screenshot();
//通过dafuweng登陆手机端
new MoblieLogin("5074",this);
//手机端楼层
new HomePage("ui自动化-实物",this);
//兑换页面
new ExchangePage("马上兑换",this);
sleep(5);
screenshot();
Assert.assertTrue(isExistByText("待发货"));
Assert.assertTrue(isExistByText("收货人:uitest  "));
Assert.assertTrue(isExistByText("13111133322"));
Assert.assertTrue(isExistByText("北京市北京市东城区东华门街道test "));
Assert.assertTrue(isExistByText("ui自动化-实物"));
Assert.assertTrue(isExistByText("\n" +
" ui自动化-实物-待发货文案\n" +
" "));
}
}
package ui.cases.Exchange;
import base.DuibaBaseUi;
import org.testng.Assert;
import org.testng.annotations.Test;
import ui.service.ExchangePage;
import ui.service.HomePage;
import ui.service.MoblieLogin;
import static com.codeborne.selenide.Selenide.open;
......@@ -11,20 +15,22 @@ import static com.codeborne.selenide.Selenide.open;
public class 支付宝_ExchangeTest_ui extends DuibaBaseUi{
@Test
public void 支付宝_正常流程() throws Exception {
open("http://dafuweng.duibatest.com.cn/user/index");
clickByTextEqual("5074");
switchWindow();
sleep(2);
clickByClass("btn-close");
screenshot();
clickByTextEqual("支付宝充值");
screenshot();
clickByTextEqual("马上兑换");
screenshot();
clickByTextEqual("确定");
screenshot();
//通过dafuweng登陆手机端
new MoblieLogin("5074",this);
//手机端楼层
new HomePage("支付宝充值",this);
//兑换页面
new ExchangePage("马上兑换",this);
sleep(5);
screenshot();
Assert.assertTrue(isExistByText("请等待处理结果"));
Assert.assertTrue(isExistByText("peeulk6392@sandbox.com"));
Assert.assertTrue(isExistByText("待审核"));
Assert.assertTrue(isExistByText("订单编号:"));
}
}
package ui.cases.Plugin;
import base.DuibaBaseUi;
import org.testng.Assert;
import org.testng.annotations.Test;
import ui.service.MoblieLogin;
import static com.codeborne.selenide.Selenide.open;
/**
* Created by mabo on 2018/12/17
*/
public class 首页插件_Plugin_ui extends DuibaBaseUi{
@Test
public void 优惠券() throws Exception {
new MoblieLogin("5074",this);
sleep(3);
screenshot();
refresh();
sleep(2);
clickByClass("plugin-open");
clickByClass("plugin-img");
Assert.assertTrue(isExistByText("ui自动化-优惠券(活动)"));
Assert.assertTrue(isExistByText("券码:"));
Assert.assertTrue(isExistByText("1111111"));
Assert.assertTrue(isExistByText("密码:"));
Assert.assertTrue(isExistByText("22222222"));
Assert.assertTrue(isExistByText("商品详情"),"没有商品详情文本");
}
}
......@@ -66,6 +66,8 @@ public class WebDriverFactory {
Map<String, String> mobileEmulation = new HashMap<String, String>();
mobileEmulation.put("deviceName", "Nexus 5");
chromeOptions.setExperimentalOption("mobileEmulation", mobileEmulation);
chromeOptions.addArguments("--args --disable-web-security --user-data-dir");
Properties prop = System.getProperties();
String OS = prop.getProperty("os.name");
......
package ui.service;
import base.DuibaBaseUi;
/**
* Created by mabo on 2018/12/19
*/
public class Activity_egg_Page {
public Activity_egg_Page(String name, DuibaBaseUi father) throws Exception {
father.sleep(3);
father.clickByClass("egg");
if(name!=null)father.clickByTextEqual(name);
}
}
package ui.service;
import base.DuibaBaseUi;
import java.io.IOException;
/**
* Created by mabo on 2018/12/17
*/
public class ExchangePage {
public ExchangePage(String button,DuibaBaseUi father) throws Exception {
father.clickByTextEqual(button);
father.screenshot();
father.clickByTextEqual("确定");
father.screenshot();
}
}
package ui.service;
import base.DuibaBaseUi;
/**
* Created by mabo on 2018/12/17
*/
public class HomePage {
public HomePage(String click,DuibaBaseUi father) throws Exception {
father.clickByClass("plugin-close");
father.screenshot();
father.clickByTextEqual(click);
father.screenshot();
}
}
package ui.service;
import base.DuibaBaseUi;
import org.openqa.selenium.remote.RemoteWebDriver;
import static com.codeborne.selenide.Selenide.open;
import static java.lang.Thread.sleep;
/**
* Created by mabo on 2018/12/17
*/
public class MoblieLogin{
private String dafuwengUrl="http://dafuweng.duibatest.com.cn/user/index";
public MoblieLogin(String uid, DuibaBaseUi father) throws Exception {
open(dafuwengUrl);
father.clickByTextEqual(uid);
father.switchWindow();
sleep(2);
}
}
package ui.service;
import base.DuibaBase;
import base.DuibaBaseUi;
/**
* Created by mabo on 2018/12/29
*/
public class TakePrizeNewPage {
public TakePrizeNewPage(String name,DuibaBaseUi father) throws Exception {
father.sleep(2);
father.clickByTextEqual(name);
father.clickByTextEqual("确定");
}
}
......@@ -22,8 +22,8 @@ manager.host = mng.duibatest.com.cn
trade.host = activity.m.duibatest.com.cn
//\u6570\u636E\u5E93\u914D\u7F6E
db.name = duiba_test
db.password= svbP3KUw2PurAnBb2rbs3vohF
db.name = FjrtzzH
db.password= 2Fe36uDap8TMqtfzob3f1u8r2aK8qjdnwPP
db.url = jdbc:mysql://47.97.127.67:13001/?tinyInt1isBit=false
db.driver= com.mysql.cj.jdbc.Driver
db.maxtotal = 6
......
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