Commit 5eff706f authored by 周松波's avatar 周松波

Merge branch 'develop' into songbo

parents 6e177c8d 8830a136
......@@ -92,9 +92,11 @@ public class 游戏_获取游戏信息测试_AccessTest extends DuibaTestBase {
response.prettyPrint();
Assert.assertEquals(MatcherString.getString(response.asString(),"\"success\": (.*?),",1),"true","校验预览结果失败");
String url = MatcherString.getString(response.asString(),"\"url\": \"(.*?)\"",1);
Assert.assertTrue(url.contains("http://activity.m.duibatest.com.cn/autoLogin/autologin?appKey=jlg88lyxz7siqtmr&uid=duiba-preview-user"),"校验获取的链接失败");
logger.info("url的信息为" +url);
Assert.assertTrue(url.contains("https://activity.m.duibatest.com.cn/autoLogin/autologin?appKey=jlg88lyxz7siqtmr&uid=duiba-preview-user"),"校验获取的链接失败");
String[] redirect = url.split("redirect=");
// logger.info("redirect的信息为" +redirect[1]);
logger.info("redirect的信息为" +redirect[1]);
Assert.assertTrue(String.valueOf(redirect[1]).contains("id%3D1338"),"校验重定向的活动id失败");
}
......
......@@ -25,7 +25,7 @@ import java.util.Map;
/**
* Created by zhaoran on 2018/07/10
*/
public class 中奖发奖限制_DuibaTest extends DuibaTestBase {
public class 中奖发奖限制 extends DuibaTestBase {
@Autowired
NewActivityService newActivityService;
......@@ -57,10 +57,10 @@ public class 中奖发奖限制_DuibaTest extends DuibaTestBase {
public void after() throws Exception{
//数据库删除
try {
jdbc.update("delete from hdtool_conf.duiba_hdtool where title=?", "【自动化】多奖项中奖限制"+data);
jdbc.update("delete from credits_dev.operating_activity where title=?","【自动化】多奖项中奖限制"+data);
jdbc.update("delete from hdtool_conf.duiba_hdtool where title=?", "【自动化】奖品发放限制"+data2);
jdbc.update("delete from credits_dev.operating_activity where title=?","【自动化】奖品发放限制"+data2);
jdbc.update("delete from hdtool_conf.duiba_hdtool where title=?", "【自动化】多奖项中奖限制_DuibaTest"+data);
jdbc.update("delete from credits_dev.operating_activity where title=?","【自动化】多奖项中奖限制_DuibaTest"+data);
jdbc.update("delete from hdtool_conf.duiba_hdtool where title=?", "【自动化】奖品发放限制_DuibaTest"+data2);
jdbc.update("delete from credits_dev.operating_activity where title=?","【自动化】奖品发放限制_DuibaTest"+data2);
} catch (Exception e) {
System.out.println(e);
}
......@@ -147,7 +147,7 @@ public class 中奖发奖限制_DuibaTest extends DuibaTestBase {
@Test
public void 多奖项中奖限制测试() throws Exception {
data = PublicMethod.data();
String title = "【自动化】多奖项中奖限制"+data;
String title = "【自动化】多奖项中奖限制_DuibaTest"+data;
this.创建并上架活动(title);
......@@ -182,7 +182,7 @@ public class 中奖发奖限制_DuibaTest extends DuibaTestBase {
@Test
public void 奖品发放限制测试() throws Exception {
data2 = PublicMethod.data();
String title = "【自动化】奖品发放限制"+data2;
String title = "【自动化】奖品发放限制_DuibaTest"+data2;
this.创建并上架活动2(title);
//获取管理员后台活动信息
......
package http.cases.NewActivityTest;
import com.alibaba.fastjson.JSON;
import base.DuibaTestBase;
import utils.PublicMethod;
import http.enums.ActivityDataTypeEnum;
import http.model.AwardVO;
import http.model.CustomHdToolVO;
import http.service.Activity.ManagerService;
import http.service.Activity.NewActivityService;
import http.service.hd.ActivityService;
import http.service.hd.CustomHdToolCtrlService;
import http.service.hd.DeveloperService;
import base.DuibaLog;
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 java.util.ArrayList;
import java.util.List;
/**
* Created by zhaoran on 2018/07/10
*/
public class 多奖项中奖限制 extends DuibaTestBase {
public class 多奖项中奖限制_DuibaTest extends DuibaTestBase {
@Autowired
NewActivityService newActivityService;
......@@ -37,113 +29,35 @@ public class 多奖项中奖限制 extends DuibaTestBase {
@Autowired
ActivityService activityService;
private static DuibaLog logger = DuibaLog.getLogger();
//指定用户
private static int uid = 2720;
//兑吧活动id
private static String actId ;
//活动入库id
private static String id ;
private static String data;
@AfterClass
public void after() throws Exception{
//数据库删除
try {
jdbc.update("delete from duiba_hdtool where title=?", "【自动化】多奖项中奖限制"+data);
jdbc.update("delete from credits_dev.operating_activity where title=?","【自动化】多奖项中奖限制"+data);
//case:[多奖项中奖限制测试_永久]数据处理:删除永久中奖记录
jdbc.update("UPDATE ckvtable.tb_kvtable_0687 SET int_value = '0' WHERE vkey = 'activity-centerwinOptionNum_100025007_35869_hdtool25885'");
} catch (Exception e) {
System.out.println(e);
}
}
public void 创建并上架活动(String title) throws Exception {
//管理后台创建活动并开启
logger.info("创建多奖项中奖限制活动");
CustomHdToolVO customHdToolVO = new CustomHdToolVO();
customHdToolVO.setActId(null);
customHdToolVO.setTitle(title);
customHdToolVO.setFacePrice("0.01");
customHdToolVO.setBrickId(167L);
customHdToolVO.setFactoryKey(ActivityDataTypeEnum.HDTOOL.getKey());
customHdToolVO.setOpenMutliPrizeLimit(true);
AwardVO awardVO1 = AwardVO.谢谢参与();
AwardVO awardVO2 = AwardVO.幸运福袋();
AwardVO awardVO3 = AwardVO.话费充值(1,"多档位话费充值","话费","100","1",true,null);
List<AwardVO> list = new ArrayList<AwardVO>();
list.add(awardVO1);
list.add(awardVO2);
list.add(awardVO3);
String awards = JSON.toJSONString(list);
//logger.info("设置的奖品信息:"+awards);
customHdToolVO.setAwards(awards);
customHdToolVO.setRule("多奖项中奖限制活动");
Response response = customHdToolCtrlService.saveOrEdit(customHdToolVO);
Assert.assertTrue(response.jsonPath().getBoolean("success"));
actId = response.jsonPath().getString("data.actId");
logger.info("多奖项中奖限制兑吧活动id为:"+actId);
managerService.switchSpecifyAndBlack("1",actId);
//定向开发者
managerService.saveSpecify(actId,"2239");
//开发者上架活动
Response HdResponse = developerService.joinIn(actId,"12");
logger.info("创建活动并上架成功");
}
@Test
public void 多奖项中奖限制测试() throws Exception {
data = PublicMethod.data();
String title = "【自动化】多奖项中奖限制"+data;
this.创建并上架活动(title);
public void 多奖项中奖限制测试_永久() throws Exception {
//获取管理员后台活动信息
Response ManagerResponse = managerService.edit(actId);
//获取奖品剩余库存
String appItemId = String.valueOf(ManagerResponse.jsonPath().getString("data.awards[2].appItemId"));
logger.info("预设必中奖品类型为:"+ManagerResponse.jsonPath().getString("data.awards[2].type"));
logger.info("预设中奖几率为:"+ManagerResponse.jsonPath().getString("data.awards[2].probability")+"%");
logger.info("预设中奖每人限制:"+ManagerResponse.jsonPath().getString("data.awards[2].limit")+"次");
logger.info("预设剩余奖品数:"+ManagerResponse.jsonPath().getString("data.awards[2].remaind")+"个");
//获取入库id
ManagerResponse = developerService.list2(title);
id = ManagerResponse.jsonPath().getString("data.list[0].id");
//第一次抽奖
Response response = this.新活动工具接口传参(id,"adsdas","iOS");
Response response = this.新活动工具接口传参("35869","adsdas","iOS");
Assert.assertEquals( String.valueOf(response.jsonPath().getString("lottery.type")),"phonebill","第一次抽奖出奖类型失败");
Assert.assertEquals( String.valueOf(response.jsonPath().getString("lottery.title")),"话费","第一次抽奖出奖title失败");
//第二次抽奖
response = this.新活动工具接口传参(id,"adsdas","iOS");
// if(activityService.isRunning("10.110.10.12","17791","tuia-engine")){
//logger.info("tuia-engine服务启动成功");
response = this.新活动工具接口传参("35869","adsdas","iOS");
Assert.assertEquals( String.valueOf(response.jsonPath().getString("lottery.type")),"lucky","第二次抽奖出奖类型失败");
Assert.assertEquals( String.valueOf(response.jsonPath().getString("lottery.useBtnText")),"马上使用","第二次抽奖出奖文案失败");
// }else{
// logger.info("tuia-engine服务启动未成功,福袋降级成谢谢参与!");
// Assert.assertEquals(response.jsonPath().getString("lottery.type"), "thanks", "校验类型失败");
// }
this.删除活动();
}
public void 删除活动() throws Exception{
//管理后台删除活动
managerService.delet(actId);
logger.info("管理后台删除活动成功!");
//开发者删除活动
developerService.delActivity(id);
logger.info("开发者后台删除活动成功!");
}
public Response 新活动工具接口传参(String activityId,String token,String device) throws Exception {
Response response = newActivityService.doJoin2(activityId,token);
response.prettyPrint();
......
package http.cases.NewActivityTest;
import com.alibaba.fastjson.JSON;
import base.DuibaTestBase;
import utils.PublicMethod;
import http.enums.ActivityDataTypeEnum;
import http.model.AwardVO;
import http.model.CustomHdToolVO;
import http.service.Activity.ManagerService;
import http.service.Activity.NewActivityService;
import http.service.hd.ActivityService;
......@@ -17,14 +12,17 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.Test;
import utils.HbaseService;
import java.util.ArrayList;
import java.util.List;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
/**
* Created by zhaoran on 2018/07/10
*/
public class 奖品发放限制 extends DuibaTestBase {
public class 奖品发放限制_DuibaTest extends DuibaTestBase {
@Autowired
NewActivityService newActivityService;
......@@ -36,113 +34,57 @@ public class 奖品发放限制 extends DuibaTestBase {
CustomHdToolCtrlService customHdToolCtrlService;
@Autowired
ActivityService activityService;
@Autowired
HbaseService hbaseService;
private static DuibaLog logger = DuibaLog.getLogger();
//指定用户
private static int uid = 2720;
//兑吧活动id
private static String actId ;
//活动入库id
private static String id ;
private static String data;
@AfterClass
public void after() throws Exception{
//数据库删除
try {
jdbc.update("delete from duiba_hdtool where title=?", "【自动化】奖品发放限制"+data);
jdbc.update("delete from credits_dev.operating_activity where title=?","【自动化】奖品发放限制"+data);
//case:[奖品发放限制测试_永久]数据处理:删除永久中奖记录
jdbc.update("UPDATE ckvtable.tb_kvtable_0687 SET int_value = '0' WHERE vkey = 'activity-centerwinOptionNum_100025007_35868_hdtool25884'");
//case:[奖品发放限制测试_每日]数据处理:删除每日中奖记录
String y_m_d = getTime2(0);
String key = "k05_PRIZE_K001_"+y_m_d+"_hdtool25933_100025007";
hbaseService.deleteHBASEKey2(key);
} catch (Exception e) {
System.out.println(e);
}
}
public void 创建并上架活动(String title) throws Exception {
//管理后台创建活动并开启
logger.info("创建奖品发放限制活动");
CustomHdToolVO customHdToolVO = new CustomHdToolVO();
customHdToolVO.setActId(null);
customHdToolVO.setTitle(title);
customHdToolVO.setFacePrice("0.01");
customHdToolVO.setBrickId(167L);
customHdToolVO.setFactoryKey(ActivityDataTypeEnum.HDTOOL.getKey());
//奖品发放限制设置
customHdToolVO.setOpenPrizesGrantLimit(true);
customHdToolVO.setPrizesGrantLimitDays(1);
AwardVO awardVO1 = AwardVO.谢谢参与();
AwardVO awardVO2 = AwardVO.幸运福袋();
AwardVO awardVO3 = AwardVO.话费充值(1,"多档位话费充值","话费","100","1",false,1);
List<AwardVO> list = new ArrayList<AwardVO>();
list.add(awardVO1);
list.add(awardVO2);
list.add(awardVO3);
String awards = JSON.toJSONString(list);
//logger.info("设置的奖品信息:"+awards);
customHdToolVO.setAwards(awards);
customHdToolVO.setRule("奖品发放限制为1");
Response response = customHdToolCtrlService.saveOrEdit(customHdToolVO);
Assert.assertTrue(response.jsonPath().getBoolean("success"));
actId = response.jsonPath().getString("data.actId");
logger.info("多奖项中奖限制兑吧活动id为:"+actId);
managerService.switchSpecifyAndBlack("1",actId);
//定向开发者
managerService.saveSpecify(actId,"2239");
//开发者上架活动
Response HdResponse = developerService.joinIn(actId,"12");
logger.info("创建活动并上架成功");
}
@Test
public void 奖品发放限制测试() throws Exception {
data = PublicMethod.data();
String title = "【自动化】奖品发放限制"+data;
this.创建并上架活动(title);
//获取管理员后台活动信息
Response ManagerResponse = managerService.edit(actId);
//获取奖品剩余库存
String appItemId = String.valueOf(ManagerResponse.jsonPath().getString("data.awards[2].appItemId"));
logger.info("预设必中奖品类型为:"+ManagerResponse.jsonPath().getString("data.awards[2].type"));
logger.info("预设中奖几率为:"+ManagerResponse.jsonPath().getString("data.awards[2].probability")+"%");
logger.info("预设中奖每人限制:"+ManagerResponse.jsonPath().getString("data.awards[2].limit")+"次");
logger.info("预设剩余奖品数:"+ManagerResponse.jsonPath().getString("data.awards[2].remaind")+"个");
//获取入库id
ManagerResponse = developerService.list2(title);
id = ManagerResponse.jsonPath().getString("data.list[0].id");
public void 奖品发放限制测试_永久() throws Exception {
//第一次抽奖
Response response = this.新活动工具接口传参(id,"adsdas","iOS");
Response response = this.新活动工具接口传参("35868","adsdas","iOS");
Assert.assertEquals( String.valueOf(response.jsonPath().getString("lottery.type")),"phonebill","第一次抽奖出奖类型失败");
Assert.assertEquals( String.valueOf(response.jsonPath().getString("lottery.title")),"话费","第一次抽奖出奖title失败");
//第二次抽奖
response = this.新活动工具接口传参(id,"adsdas","iOS");
if(String.valueOf(response.jsonPath().getString("lottery.type")).equals("lucky")){
logger.info("tuia-engine服务启动成功");
response = this.新活动工具接口传参("35868","adsdas","iOS");
Assert.assertEquals( String.valueOf(response.jsonPath().getString("lottery.type")),"lucky","第一次抽奖出奖类型失败");
Assert.assertEquals( String.valueOf(response.jsonPath().getString("lottery.useBtnText")),"马上使用","第一次抽奖出奖文案失败");
}else{
logger.info("tuia-engine服务启动未成功,福袋降级成谢谢参与!");
Assert.assertEquals(response.jsonPath().getString("lottery.type"), "thanks", "校验类型失败");
}
this.删除活动();
}
@Test
public void 奖品发放限制测试_每日() throws Exception {
//第一次抽奖
Response response = this.新活动工具接口传参("35920","adsdas","iOS");
Assert.assertEquals( String.valueOf(response.jsonPath().getString("lottery.type")),"phonebill","第一次抽奖出奖类型失败");
Assert.assertEquals( String.valueOf(response.jsonPath().getString("lottery.title")),"话费","第一次抽奖出奖title失败");
//第二次抽奖
response = this.新活动工具接口传参("35920","adsdas","iOS");
Assert.assertEquals( String.valueOf(response.jsonPath().getString("lottery.type")),"lucky","第一次抽奖出奖类型失败");
Assert.assertEquals( String.valueOf(response.jsonPath().getString("lottery.useBtnText")),"马上使用","第一次抽奖出奖文案失败");
public void 删除活动() throws Exception{
//管理后台删除活动
managerService.delet(actId);
logger.info("管理后台删除活动成功!");
//开发者删除活动
developerService.delActivity(id);
logger.info("开发者后台删除活动成功!");
}
public Response 新活动工具接口传参(String activityId,String token,String device) throws Exception {
......@@ -164,4 +106,16 @@ public class 奖品发放限制 extends DuibaTestBase {
return response;
}
public String getTime2(int amount){
SimpleDateFormat dateFormat = new SimpleDateFormat("YYYY-MM-dd", Locale.ENGLISH);
Date date = new Date();
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.DAY_OF_MONTH, amount);
date = calendar.getTime();
// System.out.println(dateFormat.format(date));
String time = dateFormat.format(date);
// System.out.println(time);
return time;
}
}
\ No newline at end of file
package http.cases.SaasDeveloperTest;
import base.Config;
import utils.PublicMethod;
import http.service.Saas.DeveloperVirtualService;
import http.service.Saas.SpglczService;
import base.DuibaLog;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
import org.testng.Assert;
import org.testng.annotations.Test;
/**
* Created by humengxin on 2018/11/02.
*/
@ContextConfiguration(classes = Config.class)
public class 商品管理操作_DuibaTest extends AbstractTestNGSpringContextTests {
@Autowired
SpglczService czService;
@Autowired
DeveloperVirtualService developerVirtualService;
private static DuibaLog logger = DuibaLog.getLogger();
@Test(description = "批量上架")
public void a_批量上架() throws Exception {
String data=PublicMethod.data();
//先添加2个商品
developerVirtualService.doUpdateVirtual("【自动化】加钱购自有虚拟商品"+data,"标识符100=10+1");
developerVirtualService.doUpdateVirtual("【自动化】加钱购自有虚拟商品"+data,"标识符100=10+1");
//查询实物商品集合
Response response= czService.appItems();
// 获取到上架商品id
String ids = response.jsonPath().getString("data.list[0].id");
String ids2 = response.jsonPath().getString("data.list[1].id");
czService.batchStandUpOrDown(ids,ids2);
//刷新查询商品集合
Response response2= czService.appItems();
//查看商品列表确认是否上架成功
Assert.assertEquals(response2.jsonPath().getString("data.list[0].statusText"),"上架", "校验商品上架失败");
Assert.assertEquals(response2.jsonPath().getString("data.list[1].statusText"),"上架", "校验商品上架失败");
logger.info("校验商品上架成功");
}
@Test(description = "批量复制")
public void b_批量复制() throws Exception {
String data = PublicMethod.data();
//查询实物商品集合
Response response= czService.appItems();
// 获取到上架商品id
String ids = response.jsonPath().getString("data.list[0].id");
String ids2 = response.jsonPath().getString("data.list[1].id");
//复制到另一个app
czService.batchCopy(ids,ids2);
//查看另一个app下是否存在该商品
Response response2=czService.appItems2();
Assert.assertEquals(response2.jsonPath().getString("data.list[0].itemType"), "直充", "校验商品类型失败");
Assert.assertEquals(response2.jsonPath().getString("data.list[0].belong"), "自有", "校验商品belong失败");
Assert.assertEquals(response2.jsonPath().getString("data.list[1].itemType"), "直充", "校验商品类型失败");
Assert.assertEquals(response2.jsonPath().getString("data.list[1].belong"), "自有", "校验商品belong失败");
logger.info("校验title,belong成功");
}
@Test(description = "批量删除")
public void c_批量删除() throws Exception {
String data = PublicMethod.data();
//查询实物商品集合
Response response= czService.appItems();
// 获取到上架商品id
String ids = response.jsonPath().getString("data.list[0].id");
String ids2 = response.jsonPath().getString("data.list[1].id");
czService.doBatchDel(ids,ids2);
}
}
package http.cases.WalletTest;
import base.DuibaLog;
import base.DuibaTestBase;
import http.service.Activity.SeedRedPacketService;
import http.service.Activity.WalletAccountService;
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.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.Test;
import utils.HbaseService;
import utils.PublicMethod;
import java.lang.reflect.Method;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.*;
import static io.restassured.RestAssured.given;
/**
* Created by 赵然 on 2018/11/06
*/
public class 账户余额清零 extends DuibaTestBase {
@Value("${activity.host}")
String activityHost;
@Autowired
SeedRedPacketService seedRedPacketService;
@Autowired
WalletAccountService walletAccountService;
@Autowired
Authorization authorization;
@Autowired
HbaseService hbaseService;
private DuibaLog logger = DuibaLog.getLogger();
//指定用户
private static int uid = 4486;
private static String consumerId = "100098059";
@AfterClass
public void afterclass() {
try {
//修改账户过期时间,确保账户始终处于过期状态
jdbc.update("update consumer_account_log.tb_expire_consumer_account set gmt_modified ='" + getTime(-1) + "' where account_id = '" + consumerId + "_6_0'");
//删除过期记录
jdbc.update("delete from consumer_account_log.tb_consumer_accounts_log where account_id = '"+consumerId+"_6_0' and biz_type=10");
//重置账户金额10000
jdbc.update("update consumer_accounts.tb_consumer_account_0011 set balance_amount ='10000' where account_id = '" + consumerId + "_6_0'");
} catch (Exception e) {
logger.info("数据后面置操作异常");
}
}
@Test
public void a_账户过期余额清零() throws Exception {
Map<String, Object> sqlResult = jdbc.findSimpleResult("select * from consumer_account_log.tb_expire_consumer_account where account_id = '"+consumerId+"_6_0' ");
String gmt_modified1 = String.valueOf(sqlResult.get("gmt_modified"));
logger.info("账户第一次登录时间为" + gmt_modified1);
//获取原账户余额
Map<String, Object> selectResult = jdbc.findSimpleResult("select * from consumer_accounts.tb_consumer_account_0011 where account_id = '"+consumerId+"_6_0' ");
int balance = Integer.parseInt(String.valueOf(selectResult.get("balance_amount")));
Assert.assertEquals(balance,10000,"查询账户余额失败");
logger.info("账户原有余额为" + balance);
//dafuweng登陆获取cookies
Map cookies = authorization.dafuwengLogin(uid);
//调用获取getWalletAccount,获取账户金额
Response response = walletAccountService.getWalletAccount(cookies);
String balanceAmount = response.jsonPath().getString("balanceAmount");
//校验,与数据对比
Assert.assertTrue(new BigDecimal(balanceAmount).compareTo(new BigDecimal("0"))==0,"钱包账户未清零");
logger.info("账户过期清零成功");
sqlResult = jdbc.findSimpleResult("select * from consumer_account_log.tb_expire_consumer_account where account_id = '"+consumerId+"_6_0' ");
String gmt_modified2 = String.valueOf(sqlResult.get("gmt_modified"));
logger.info("账户第二次登录时间为" + gmt_modified2);
Assert.assertEquals(gmt_modified1.equals(gmt_modified2)==false,true);
}
@Test
public void b_扣款明细校验() throws Exception {
//获取数据库扣款记录
Map<String, Object> selectResult = jdbc.findSimpleResult("select * from consumer_account_log.tb_consumer_accounts_log where account_id = '"+consumerId+"_6_0' and biz_type=10");
if(!selectResult.isEmpty() ||selectResult.equals("")||selectResult.equals(null) ) {
String change_money = String.valueOf(selectResult.get("change_money"));
String action_type = String.valueOf(selectResult.get("action_type"));
String sub_type = String.valueOf(selectResult.get("sub_type"));
String biz_description = String.valueOf(selectResult.get("biz_description"));
Assert.assertEquals(change_money, "10000", "数据库扣款金额校验失败");
Assert.assertEquals(action_type, "0", "数据库账户动作校验失败");
Assert.assertEquals(sub_type, "0", "数据库日志类型校验失败");
Assert.assertEquals(biz_description.contains("红包过期"), true, "数据库业务描述校验失败");
logger.info("数据库账户过期清零记录校验成功");
//获取最新的提现记录
Map cookies = authorization.dafuwengLogin(uid);
Response response = walletAccountService.walletDetail(cookies);
String money = response.jsonPath().getString("data[1].money");
String subType = response.jsonPath().getString("data[1].subType");
String description = response.jsonPath().getString("data[1].description");
Assert.assertTrue(new BigDecimal(money).compareTo(new BigDecimal("100"))==0,"扣款金额校验失败");
Assert.assertEquals(subType, "0", "日志类型校验失败");
Assert.assertEquals(description.contains("红包过期"),true, "日志类型校验失败");
logger.info("订单列表过期记录校验成功");
}else{
logger.info("数据库未生成扣款记录,有可能是用例距离上一次执行时间过短");
}
}
public String getTime(int amount){
SimpleDateFormat dateFormat = new SimpleDateFormat("YYYY-MM-dd", Locale.ENGLISH);
Date date = new Date();
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.MONTH, amount);
date = calendar.getTime();
// System.out.println(dateFormat.format(date));
String time = dateFormat.format(date)+" 08:00:00";
// System.out.println(time);
return time;
}
}
package http.cases.WalletTest;
import base.DuibaLog;
import base.DuibaTestBase;
import http.service.Activity.ManagerService;
import http.service.Activity.SeedRedPacketService;
import http.service.Activity.WalletAccountService;
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.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.Test;
import utils.HbaseService;
import utils.MatcherString;
import utils.PublicMethod;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.*;
import static io.restassured.RestAssured.given;
/**
* Created by mabo on 2018/8/15
*/
public class 账户异常提现_AccessTest extends DuibaTestBase{
@Value("${activity.host}")
String activityHost;
@Autowired
SeedRedPacketService seedRedPacketService;
@Autowired
WalletAccountService walletAccountService;
@Autowired
Authorization authorization;
@Autowired
HbaseService hbaseService;
@Autowired
ManagerService managerService;
private DuibaLog logger = DuibaLog.getLogger();
//指定用户
private static int uid = 4459;
private static String consumerId = "100098000";
private static int uid2 = 4460;
private static String consumerId2 = "100098001";
private static int uid3 = 4461;
private static String consumerId3 = "100098002";
private static int uid4 = 4474;
private static String consumerId4 = "100098031";
@AfterClass
public void afterclass() {
try {
//修改红包提现用户登录天数
String y_m = getTime2(0);
String key = "k01_AAWH_K003_"+y_m+"_"+consumerId;
hbaseService.updateHBASEKey(key,"","1");
String key2 = "k01_AAWH_K003_"+y_m+"_"+consumerId2;
hbaseService.updateHBASEKey(key2,"","1");
String key3 = "k01_AAWH_K003_"+y_m+"_"+consumerId3;
hbaseService.updateHBASEKey(key3,"","1");
String key4 = "k01_AAWH_K003_"+y_m+"_"+consumerId4;
hbaseService.updateHBASEKey(key4,"","1");
// 修改账户过期时间,确保账户余额不会过期清零
jdbc.update("update consumer_account_log.tb_expire_consumer_account set gmt_modified ='"+getTime(1)+"' where account_id = '"+consumerId+"_6_0'");
jdbc.update("update consumer_account_log.tb_expire_consumer_account set gmt_modified ='"+getTime(1)+"' where account_id = '"+consumerId2+"_6_0'");
jdbc.update("update consumer_account_log.tb_expire_consumer_account set gmt_modified ='"+getTime(1)+"' where account_id = '"+consumerId3+"_6_0'");
jdbc.update("update consumer_account_log.tb_expire_consumer_account set gmt_modified ='"+getTime(1)+"' where account_id = '"+consumerId4+"_6_0'");
} catch (Exception e) {
logger.info("数据后面置操作异常");
}
}
@Test
public void 用户账户余额不足() throws Exception {
//获取原账户余额
Map<String, Object> selectResult = jdbc.findSimpleResult("select * from consumer_accounts.tb_consumer_account_0976 where account_id = '"+consumerId+"_6_0' ");
int balance = Integer.parseInt(String.valueOf(selectResult.get("balance_amount")));
logger.info("账户原有余额为"+balance);
//账户支付宝提现
logger.info("请求doTakePrize");
Map<String,String> map = new HashMap<>();
map.put("alipay","peeulk6392@sandbox.com");
map.put("realname","沙箱环境");
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.dafuwengLogin(uid)).params(map).post(activityHost+"/walletAccount/doTakePrize");
response.prettyPrint();
Assert.assertEquals(response.jsonPath().getString("success"),"false","/walletAccount/doTakePrize接口失败");
Assert.assertEquals(response.jsonPath().getString("message"),"账户余额不足","/walletAccount/doTakePrize接口失败");
//获取新账户余额
selectResult = jdbc.findSimpleResult("select * from consumer_accounts.tb_consumer_account_0976 where account_id = '"+consumerId+"_6_0' ");
int balanceNew = Integer.parseInt(String.valueOf(selectResult.get("balance_amount")));
logger.info("账户新余额为"+balanceNew);
Assert.assertEquals(balanceNew,balance,"全局红包增加账户余额失败");
logger.info("用户账户余额校验成功");
}
@Test
public void 提现账号已使用() throws Exception {
//获取原账户余额
Map<String, Object> selectResult = jdbc.findSimpleResult("select * from consumer_accounts.tb_consumer_account_0977 where account_id = '"+consumerId2+"_6_0' ");
int balance = Integer.parseInt(String.valueOf(selectResult.get("balance_amount")));
logger.info("账户原有余额为"+balance);
//账户支付宝提现
logger.info("请求doTakePrize");
Map<String,String> map = new HashMap<>();
map.put("alipay","peeulk6392@sandbox.com");
map.put("realname","沙箱环境");
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.dafuwengLogin(uid2)).params(map).post(activityHost+"/walletAccount/doTakePrize");
Assert.assertEquals(response.jsonPath().getString("success"),"false","/walletAccount/doTakePrize接口失败");
Assert.assertEquals(response.jsonPath().getString("message"),"一个支付宝账户仅允许一个账户提现","/walletAccount/doTakePrize接口失败");
//获取新账户余额
selectResult = jdbc.findSimpleResult("select * from consumer_accounts.tb_consumer_account_0977 where account_id = '"+consumerId2+"_6_0' ");
int balanceNew = Integer.parseInt(String.valueOf(selectResult.get("balance_amount")));
logger.info("账户新余额为"+balanceNew);
Assert.assertEquals(balanceNew,balance,"全局红包增加账户余额失败");
logger.info("用户账户余额校验成功");
}
@Test
public void 开发者账户余额不足() throws Exception {
//获取原账户余额
Map<String, Object> selectResult = jdbc.findSimpleResult("select * from consumer_accounts.tb_consumer_account_0978 where account_id = '"+consumerId3+"_6_0' ");
int balance = Integer.parseInt(String.valueOf(selectResult.get("balance_amount")));
logger.info("账户原有余额为"+balance);
//账户支付宝提现
logger.info("请求doTakePrize");
Map<String,String> map = new HashMap<>();
map.put("alipay","peeulk6392@sandbox.com");
map.put("realname","沙箱环境");
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.dafuwengLogin(uid3)).params(map).post(activityHost+"/walletAccount/doTakePrize");
response.prettyPrint();
Assert.assertEquals(response.jsonPath().getString("success"),"false","/walletAccount/doTakePrize接口失败");
Assert.assertEquals(response.jsonPath().getString("message"),"扣app余额失败","/walletAccount/doTakePrize接口失败");
//获取新账户余额
selectResult = jdbc.findSimpleResult("select * from consumer_accounts.tb_consumer_account_0978 where account_id = '"+consumerId3+"_6_0' ");
int balanceNew = Integer.parseInt(String.valueOf(selectResult.get("balance_amount")));
logger.info("账户新余额为"+balanceNew);
Assert.assertEquals(balanceNew,balance,"全局红包增加账户余额失败");
logger.info("用户账户余额校验成功");
this.checkRecord(uid3,"0.01");
}
@Test
public void 兑吧账户余额不足() throws Exception {
Response responses = managerService.adminDuibaBalance();
String balanceManager = MatcherString.getString(responses.asString(), "type=\"hidden\" value=\"(.*?)\"", 1);
logger.info("获取兑吧余额:"+balanceManager);
double a = Double.valueOf(balanceManager);
double b = 99999.00;
BigDecimal data1 = new BigDecimal(a);
BigDecimal data2 = new BigDecimal(b);
if(data1.compareTo(data2) > 0){
logger.info("开始执行扣款预处理操作");
managerService.doCutMoney(String.valueOf(sub(a,99950.00)));
Thread.sleep(1000);
}
//获取原账户余额
Map<String, Object> selectResult = jdbc.findSimpleResult("select * from consumer_accounts.tb_consumer_account_1007 where account_id = '"+consumerId4+"_6_0' ");
int balance = Integer.parseInt(String.valueOf(selectResult.get("balance_amount")));
logger.info("账户原有余额为"+balance);
//账户支付宝提现
logger.info("请求doTakePrize");
Map<String,String> map = new HashMap<>();
map.put("alipay","peeulk6392@sandbox.com");
map.put("realname","沙箱环境");
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.dafuwengLogin(uid4)).params(map).post(activityHost+"/walletAccount/doTakePrize");
response.prettyPrint();
Assert.assertEquals(response.jsonPath().getString("success"),"false","/walletAccount/doTakePrize接口失败");
Assert.assertEquals(response.jsonPath().getString("message"),"扣兑吧余额失败","/walletAccount/doTakePrize接口失败");
//获取新账户余额
selectResult = jdbc.findSimpleResult("select * from consumer_accounts.tb_consumer_account_1007 where account_id = '"+consumerId4+"_6_0' ");
int balanceNew = Integer.parseInt(String.valueOf(selectResult.get("balance_amount")));
logger.info("账户新余额为"+balanceNew);
Assert.assertEquals(balanceNew,balance,"全局红包增加账户余额失败");
logger.info("用户账户余额校验成功");
this.checkRecord(uid4,"100000.0");
}
// 获取时间方法
public String getTime(int amount){
SimpleDateFormat dateFormat = new SimpleDateFormat("YYYY-MM-dd", Locale.ENGLISH);
Date date = new Date();
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.DAY_OF_MONTH, amount);
date = calendar.getTime();
// System.out.println(dateFormat.format(date));
String time = dateFormat.format(date)+" 08:00:00";
// System.out.println(time);
return time;
}
public String getTime2(int amount){
SimpleDateFormat dateFormat = new SimpleDateFormat("YYYY-MM", Locale.ENGLISH);
Date date = new Date();
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.DAY_OF_MONTH, amount);
date = calendar.getTime();
// System.out.println(dateFormat.format(date));
String time = dateFormat.format(date);
// System.out.println(time);
return time;
}
public void checkRecord (int uid,String Exmoney) throws Exception {
Thread.sleep(3000);
//获取最新的提现记录
Map cookies = authorization.dafuwengLogin(uid);
Response response = walletAccountService.walletDetail(cookies);
String money = response.jsonPath().getString("data[0].money");
String description = response.jsonPath().getString("data[0].description");
String subType = response.jsonPath().getString("data[0].subType");
String money1 = response.jsonPath().getString("data[1].money");
String description1 = response.jsonPath().getString("data[1].description");
String subType1 = response.jsonPath().getString("data[1].subType");
Assert.assertEquals(money,Exmoney,"扣款金额校验失败");
Assert.assertEquals(description,"提现","明细描述失败");
Assert.assertEquals(subType,"0","日志类型校验失败");
Assert.assertEquals(money1,Exmoney,"扣款金额校验失败");
Assert.assertEquals(description1,"提现 - 返还","明细描述失败");
Assert.assertEquals(subType1,"1","日志类型校验失败");
logger.info("账户余额明细校验成功");
}
/**
* 提供精确的减法运算。
* @param v1 被减数
* @param v2 减数
* @return 两个参数的差
*/
public static double sub(double v1,double v2){
BigDecimal b1 = new BigDecimal(Double.toString(v1));
BigDecimal b2 = new BigDecimal(Double.toString(v2));
return b1.subtract(b2).doubleValue();
}
}
......@@ -11,19 +11,21 @@ import org.springframework.beans.factory.annotation.Value;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import utils.HbaseService;
import utils.PublicMethod;
import java.lang.reflect.Method;
import java.text.SimpleDateFormat;
import java.util.*;
import static io.restassured.RestAssured.given;
/**
* Created by mabo on 2018/8/15
* Created by 赵然 on 2018/11/06
*/
public class 账户正常提现 extends DuibaTestBase{
public class 账户正常提现_AccessTest extends DuibaTestBase{
@Value("${activity.host}")
String activityHost;
@Autowired
......@@ -46,17 +48,69 @@ public class 账户正常提现 extends DuibaTestBase{
String y_m = getTime2(0);
String key = "k01_AAWH_K003_"+y_m+"_"+consumerId;
hbaseService.updateHBASEKey(key,"","1");
// Thread.sleep(300000);
//修改账户过期时间,确保账户余额不会过期清零
jdbc.update("update consumer_account_log.tb_expire_consumer_account set gmt_modified ='"+getTime(0)+"' where account_id = '"+consumerId+"_6_0'");
jdbc.update("update consumer_account_log.tb_expire_consumer_account set gmt_modified ='"+getTime(1)+"' where account_id = '"+consumerId+"_6_0'");
} catch (Exception e) {
logger.info("数据后面置操作异常");
}
}
@DataProvider
public Object[][] providerMethod(Method method) {
Object[][] result = null;
if (method.getName().equals("a_提现失败_账户错误")) {
result = new Object[][]{
new Object[]{1, "fail_account@sandbox.com", "沙箱环境"}, //case1
new Object[]{2, "peeulk6392@sandbox.com", "错误环境"}, //case2
};
}
return result;
}
/**
* @param alipay 支付宝提现账号
* @param realname 支付宝提现姓名
* @throws Exception
*/
@Test(dataProvider = "providerMethod")
public void a_提现失败_账户错误(int caseNum,String alipay,String realname) throws Exception {
//获取原账户余额
Map<String, Object> selectResult = jdbc.findSimpleResult("select * from consumer_accounts.tb_consumer_account_0854 where account_id = '100092758_6_0' ");
int balance = Integer.parseInt(String.valueOf(selectResult.get("balance_amount")));
logger.info("账户原有余额为"+balance);
//账户支付宝提现
Map cookies = authorization.dafuwengLogin(uid);
Response response = this.账户提现失败(cookies,alipay,realname);
String success = response.jsonPath().getString("success");
String orderStatus = response.jsonPath().getString("orderStatus");
String message = response.jsonPath().getString("message");
Assert.assertEquals(success,"false","success状态失败");
Assert.assertEquals(orderStatus,"-1","orderStatus状态失败");
switch (caseNum){
case 1:
Assert.assertEquals(message,"40004:Business Failed_PAYEE_NOT_EXIST:收款账号不存在","message校验失败");
break;
case 2:
Assert.assertEquals(message,"40004:Business Failed_PAYEE_USER_INFO_ERROR:收款用户姓名或其它信息不一致","message校验失败");
break;
}
//获取新账户余额
selectResult = jdbc.findSimpleResult("select * from consumer_accounts.tb_consumer_account_0854 where account_id = '100092758_6_0' ");
int balanceNew = Integer.parseInt(String.valueOf(selectResult.get("balance_amount")));
logger.info("账户新余额为"+balanceNew);
Assert.assertEquals(balanceNew,balance,"全局红包增加账户余额失败");
logger.info("用户账户余额校验成功");
}
@Test
public void a_正常提现() throws Exception {
public void b_正常提现() throws Exception {
//获取原账户余额
Map<String, Object> selectResult = jdbc.findSimpleResult("select * from consumer_accounts.tb_consumer_account_0854 where account_id = '100092758_6_0' ");
......@@ -77,7 +131,7 @@ public class 账户正常提现 extends DuibaTestBase{
}
@Test
public void b_余额明细校验() throws Exception {
public void c_余额明细校验() throws Exception {
//获取原账户余额
Map<String, Object> selectResult = jdbc.findSimpleResult("select * from consumer_account_log.tb_consumer_accounts_log where biz_id ="+orderId);
String change_money = String.valueOf(selectResult.get("change_money"));
......@@ -112,7 +166,7 @@ public class 账户正常提现 extends DuibaTestBase{
}
@Test
public void c_提现失败_登录次数不足() throws Exception {
public void d_提现失败_登录次数不足() throws Exception {
//获取原账户余额
Map<String, Object> selectResult = jdbc.findSimpleResult("select * from consumer_accounts.tb_consumer_account_0854 where account_id = '100092758_6_0' ");
......@@ -137,7 +191,7 @@ public class 账户正常提现 extends DuibaTestBase{
logger.info("用户账户余额校验成功");
}
public void 账户提现(Map cookies,String alipay,String realname) throws Exception {
public Response 账户提现(Map cookies,String alipay,String realname) throws Exception {
Response response = walletAccountService.doTakePrize(cookies,alipay,realname);
response.prettyPrint();
......@@ -153,8 +207,27 @@ public class 账户正常提现 extends DuibaTestBase{
i--;
response.prettyPrint();
}
return response;
}
public Response 账户提现失败(Map cookies,String alipay,String realname) throws Exception {
Response response = walletAccountService.doTakePrize(cookies,alipay,realname);
response.prettyPrint();
orderId = response.jsonPath().getString("orderId");
response = walletAccountService.getOrderStatus2(cookies,orderId);
response.prettyPrint();
String orderStatus = String.valueOf(response.jsonPath().getString("orderStatus"));
int i= 30;
while(i>0&&(orderStatus.equals("0"))){
Thread.sleep(1000);
response = walletAccountService.getOrderStatus2(cookies,orderId);
orderStatus = String.valueOf(response.jsonPath().getString("orderStatus"));
i--;
response.prettyPrint();
}
return response;
}
// 获取时间方法
public String getTime(int amount){
SimpleDateFormat dateFormat = new SimpleDateFormat("YYYY-MM-dd", Locale.ENGLISH);
......
......@@ -100,6 +100,16 @@ public class WalletAccountService {
}
public Response getOrderStatus2(Map cookies,String orderId) throws Exception {
logger.info("请求getOrderStatus");
Map<String,String> map = new HashMap<>();
map.put("orderId",orderId);
Response response = given().cookies(cookies).params(map).post(activityHost+"/walletAccount/getOrderStatus");
return response;
}
/**
* 红包账户提现记录
* @param cookies
......
package http.service.Saas;
import http.service.Authorization;
import base.DuibaLog;
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 asus on 2018/11/2.
*/
@Service
public class SpglczService {
@Value("${hdserver.host}")
String hdHost;
@Autowired
Authorization authorization;
private DuibaLog logger = DuibaLog.getLogger();
//查询商品管理列表数据
public Response appItems() throws Exception {
String url=hdHost+"/devItem/appItems";
Map<String,String> map = new HashMap<>();
map.put("appId","19515");
map.put("rowId","1");
map.put("itemType","");
map.put("status","");
map.put("itemName","");
map.put("belong","");
map.put("priceType","");
logger.info("请求查询商品url:"+url);
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas()).params(map).post("http://"+url);
response.prettyPrint();
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;
}
//查询要复制的app数据
public Response appItems2() throws Exception {
String url=hdHost+"/devItem/appItems";
Map<String,String> map = new HashMap<>();
map.put("appId","20979");
map.put("rowId","1");
map.put("itemType","");
map.put("status","");
map.put("itemName","");
map.put("belong","");
map.put("priceType","");
logger.info("请求查询商品url:"+url);
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas()).params(map).post("http://"+url);
response.prettyPrint();
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 batchStandUpOrDown(String ids,String ids2) throws Exception {
String url=hdHost+"/devItem/batchStandUpOrDown";
Map<String,String> map = new HashMap<>();
map.put("appId","19515");
map.put("ids",ids+","+ids2);
logger.info("请求批量上架商品url:"+url);
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas()).params(map).post("http://"+url);
response.prettyPrint();
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 batchCopy(String ids,String ids2) throws Exception {
String url=hdHost+"/devItem/batchCopy";
Map<String,String> map=new HashMap<>();
map.put("appId","19515");
map.put("ids",ids+","+ids2);
map.put("toAppIds","20979");
logger.info("请求批量商品url:"+url);
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas()).params(map).post("http://"+url);
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 doBatchDel(String ids,String ids2 ) throws Exception {
String url=hdHost+"/devItem/doBatchDel";
Map<String,String> map=new HashMap<>();
map.put("appId","19515");
map.put("ids", ids+","+ids2);
logger.info("请求批量商品url:"+url);
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas()).params(map).post("http://"+url);
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
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