Commit cb1c41af authored by 赵然's avatar 赵然

Merge branch 'zr' into develop

parents 5eff706f c0463881
......@@ -11,6 +11,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.Test;
import utils.RedisUtil;
/**
......@@ -35,6 +36,8 @@ public class 多奖项中奖限制_DuibaTest extends DuibaTestBase {
try {
//case:[多奖项中奖限制测试_永久]数据处理:删除永久中奖记录
jdbc.update("UPDATE ckvtable.tb_kvtable_0687 SET int_value = '0' WHERE vkey = 'activity-centerwinOptionNum_100025007_35869_hdtool25885'");
//case:[多奖项中奖限制测试_每日]数据处理:删除每日中奖记录
RedisUtil.clearKey("PRIZE_K004_35934_100025007");
} catch (Exception e) {
System.out.println(e);
}
......@@ -57,6 +60,21 @@ public class 多奖项中奖限制_DuibaTest extends DuibaTestBase {
}
@Test
public void 多奖项中奖限制测试_每日() throws Exception {
//第一次抽奖
Response response = this.新活动工具接口传参("35934","adsdas","iOS");
Assert.assertEquals( String.valueOf(response.jsonPath().getString("lottery.type")),"phonebill","第一次抽奖出奖类型失败");
Assert.assertEquals( String.valueOf(response.jsonPath().getString("lottery.title")),"话费","第一次抽奖出奖title失败");
//第二次抽奖
response = this.新活动工具接口传参("35934","adsdas","iOS");
Assert.assertEquals( String.valueOf(response.jsonPath().getString("lottery.type")),"lucky","第二次抽奖出奖类型失败");
Assert.assertEquals( String.valueOf(response.jsonPath().getString("lottery.useBtnText")),"马上使用","第二次抽奖出奖文案失败");
}
public Response 新活动工具接口传参(String activityId,String token,String device) throws Exception {
Response response = newActivityService.doJoin2(activityId,token);
......
......@@ -85,10 +85,6 @@ public class 种红包_AccessTest extends DuibaTestBase{
account = new BigDecimal(map.get("balance_amount").toString()).divide(new BigDecimal("100"));
Assert.assertTrue(account.compareTo(newAccount)==0,"钱包账户增加异常");
}
......@@ -108,7 +104,7 @@ public class 种红包_AccessTest extends DuibaTestBase{
}
@Test
@Test(description = "第二块土地种植一次解锁")
public void 解锁土地() throws Exception {
Response response = seedRedPacketService.updateUserLand("19380","1","2","100066444","2");
Map cookies = authorization.dafuwengLogin(3454);
......
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 http.service.Manager.EditManagerInfoService;
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.BeforeClass;
import org.testng.annotations.Test;
import java.math.BigDecimal;
import java.util.Map;
import static io.restassured.RestAssured.given;
/**
* Created by 赵然 on 2018/11/08
*/
public class 种红包新用户_AccessTest extends DuibaTestBase{
@Autowired
SeedRedPacketService seedRedPacketService;
@Autowired
WalletAccountService walletAccountService;
@Autowired
EditManagerInfoService editManagerInfoService;
@Autowired
Authorization authorization;
private DuibaLog logger = DuibaLog.getLogger();
//指定用户
private static int uid;
private static String consumerId;
private static String tag;
@BeforeClass
public void beforeclass() {
try {
this.createUser();
} catch (Exception e) {
logger.info("数据前后置操作异常");
}
}
@AfterClass
public void afterclass() {
try {
this.clear();
} catch (Exception e) {
logger.info("数据后置操作异常");
}
}
@Test
public void a_新人收红包() throws Exception {
logger.info("用户信息为,uid="+uid+",consumerId="+consumerId);
tag = String.format("%04d", Long.parseLong(consumerId) % 1024);
//dafuweng登陆获取cookies
Map cookies = authorization.dafuwengLogin(uid);
//调用getLandList接口,生成新人待收获红包,并校验第一块土地默认解锁
Response response = seedRedPacketService.getLandList(cookies,"1","424");
String landStatus = response.jsonPath().getString("data.landList[0].landStatus");
Assert.assertEquals(landStatus,"4","新人第一块土地状态校验失败");
Thread.sleep(1000);
//获取新人红包订单号
Map<String,Object> sqlResult = jdbc.findSimpleResult("select * from activity_order_con.tb_trade_center_activity_order_"+tag+" where consumer_id ="+consumerId+" and activity_type = 'seedRedPacket'");
String orderId = sqlResult.get("order_num").toString();
String add_credits = sqlResult.get("add_credits").toString();
Assert.assertEquals(add_credits,"20","新人红包金额校验失败");
//获取新人红包兑换状态:1-待兑换
String exchange_status = sqlResult.get("exchange_status").toString();
logger.info("收获前,exchange_status状态为:"+exchange_status);
Assert.assertEquals(exchange_status,"1","新人红包兑换状态校验失败");
//获取种植获得金额
response = seedRedPacketService.reap(cookies,"1",orderId);
String isDecr = response.jsonPath().getString("data.isDecr");
String isFirstReap = response.jsonPath().getString("data.isFirstReap");
String redPacketAmount = response.jsonPath().getString("data.redPacketAmount");
Assert.assertEquals(isDecr,"false","红包衰减校验失败");
Assert.assertEquals(isFirstReap,"true","类型是否新人红包校验失败");
Assert.assertTrue(new BigDecimal(redPacketAmount).compareTo(new BigDecimal("0.2"))==0,"新人红包金额校验失败");
//获取新人红包兑换状态:2-兑换成功
Map<String,Object> sqlResult2 = jdbc.findSimpleResult("select * from activity_order_con.tb_trade_center_activity_order_"+tag+" where consumer_id ="+consumerId+" and activity_type = 'seedRedPacket'");
String exchange_status2 = sqlResult2.get("exchange_status").toString();
logger.info("收获后,exchange_status状态为:"+exchange_status2);
Assert.assertEquals(exchange_status2,"2","新人红包兑换状态校验失败");
//调用获取getWalletAccount,获取账户金额
response = walletAccountService.getWalletAccount(cookies);
String balanceAmount = response.jsonPath().getString("balanceAmount");
//校验,与数据对比
Assert.assertTrue(new BigDecimal(balanceAmount).compareTo(new BigDecimal("0.2"))==0,"新人红包入账失败");
logger.info("新人红包入账失败");
}
@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'");
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, "20", "数据库扣款金额校验失败");
Assert.assertEquals(action_type, "1", "数据库账户动作校验失败");
Assert.assertEquals(sub_type, "1", "数据库日志类型校验失败");
Assert.assertEquals(biz_description, "种红包活动用户领取红包收入", "数据库业务描述校验失败");
logger.info("数据库新人红包入账记录校验成功");
//获取最新的提现记录
Map cookies = authorization.dafuwengLogin(uid);
Response response = walletAccountService.walletDetail(cookies);
String money = response.jsonPath().getString("data[0].money");
String subType = response.jsonPath().getString("data[0].subType");
String description = response.jsonPath().getString("data[0].description");
Assert.assertTrue(new BigDecimal(money).compareTo(new BigDecimal("0.2"))==0,"扣款金额校验失败");
Assert.assertEquals(subType, "1", "日志类型校验失败");
Assert.assertEquals(description,"种红包活动用户领取红包收入", "数据库业务描述校验失败");
logger.info("余额明细列表校验成功");
}
public void createUser() throws Exception{
Response response = editManagerInfoService.createUser("种红包新用户","68");
Map<String,Object> user = jdbc.findSimpleResult("select * from dafuweng.user where name = '种红包新用户' and app_id = '68'");
uid = Integer.valueOf(user.get("id").toString());
String url = "http://47.97.214.108/user/loginDuiba?uid=" + uid;
Response login = given().get(url);
Map<String,Object> consumer = jdbc.findSimpleResult("select * from new_consumer.consumer_0010 where partner_user_id =? and app_id = '19380'",uid);
consumerId = consumer.get("id").toString();
}
public void clear(){
try {
jdbc.update("delete from dafuweng.user where name = '种红包新用户' and app_id = '68'");
jdbc.update("delete from new_consumer.consumer_0010 where id = ?",consumerId);
} catch (Exception e) {
logger.info("数据后置操作异常");
}
}
}
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.BeforeClass;
import org.testng.annotations.Test;
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;
private DuibaLog logger = DuibaLog.getLogger();
//指定用户
private static int uid = 4552;
private static String consumerId = "100101015";
@BeforeClass
public void beforeclass() {
try {
seedRedPacketService.updateUserLand("19380","1","8",consumerId,"1");
seedRedPacketService.updateUserLand("19380","1","6",consumerId,"1");
seedRedPacketService.updateUserLand("19380","1","4",consumerId,"1");
} catch (Exception e) {
logger.info("数据前后置操作异常");
}
}
@Test(description = "第四块土地消耗积分解锁")
public void 第四块土地解锁() throws Exception {
//dafuweng登陆获取cookies
Map cookies = authorization.dafuwengLogin(uid);
//调用getLandList接口
Response response = seedRedPacketService.getLandList(cookies,"1","424");
String landStatus = response.jsonPath().getString("data.landList[3].landStatus");
logger.info("第四块土地状态为:可解锁-"+landStatus);
Assert.assertEquals(landStatus,"2","第四块土地状态校验失败");
//调用解锁土地接口
response = seedRedPacketService.unlockLand(cookies,"1","424","4");
//调用getLandList接口
response = seedRedPacketService.getLandList(cookies,"1","424");
landStatus = response.jsonPath().getString("data.landList[3].landStatus");
logger.info("第四块土地状态为:空地-"+landStatus);
Assert.assertEquals(landStatus,"3","第四块土地状态校验失败");
}
@Test(description = "第四块土地消耗积分解锁")
public void 第四块土地解锁_未达条件() throws Exception {
//dafuweng登陆获取cookies
Map cookies = authorization.dafuwengLogin(4582);
//调用getLandList接口
Response response = seedRedPacketService.getLandList(cookies,"1","424");
String landStatus = response.jsonPath().getString("data.landList[3].landStatus");
logger.info("第四块土地状态为:未解锁-"+landStatus);
Assert.assertEquals(landStatus,"1","第四块土地状态校验失败");
//调用解锁土地接口
Map<String,String> map = new HashMap<>();
map.put("activityId","1");
map.put("floorId","424");
map.put("landId","4");
map.put("dcm","228.4.2.0");
map.put("dpm","19380.5.424.4");
logger.info("请求unlockLand接口,landId=4");
response = given().cookies(cookies).params(map).get(activityHost+"/seedRedPacket/unlockLand");
Assert.assertEquals(response.jsonPath().getString("success"),"false","/seedRedPacket/seed接口失败");
Assert.assertEquals(response.jsonPath().getString("desc"),"用户地块不是可解锁状态","/seedRedPacket/seed接口失败");
logger.info("用户未达条件,地块不是可解锁状态");
}
@Test(description = "第六块土地兑换一次解锁")
public void 第六块土地解锁() throws Exception {
//dafuweng登陆获取cookies
Map cookies = authorization.dafuwengLogin(uid);
//调用getLandList接口
Response response = seedRedPacketService.getLandList(cookies,"1","424");
String landStatus = response.jsonPath().getString("data.landList[5].landStatus");
logger.info("第六块土地状态为:可解锁-"+landStatus);
Assert.assertEquals(landStatus,"2","第六块土地状态校验失败");
//调用解锁土地接口
response = seedRedPacketService.unlockLand(cookies,"1","424","6");
//调用getLandList接口
response = seedRedPacketService.getLandList(cookies,"1","424");
landStatus = response.jsonPath().getString("data.landList[5].landStatus");
logger.info("第六块土地状态为:空地-"+landStatus);
Assert.assertEquals(landStatus,"3","第六块土地状态校验失败");
}
@Test(description = "第八块土地提现一次解锁")
public void 第八块土地解锁() throws Exception {
//dafuweng登陆获取cookies
Map cookies = authorization.dafuwengLogin(uid);
//调用getLandList接口
Response response = seedRedPacketService.getLandList(cookies,"1","424");
String landStatus = response.jsonPath().getString("data.landList[7].landStatus");
logger.info("第八块土地状态为:可解锁-"+landStatus);
Assert.assertEquals(landStatus,"2","第八块土地状态校验失败");
//调用解锁土地接口
response = seedRedPacketService.unlockLand(cookies,"1","424","8");
//调用getLandList接口
response = seedRedPacketService.getLandList(cookies,"1","424");
landStatus = response.jsonPath().getString("data.landList[7].landStatus");
logger.info("第八块土地状态为:空地-"+landStatus);
Assert.assertEquals(landStatus,"3","第八块土地状态校验失败");
}
}
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.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import utils.RedisUtil;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.*;
/**
* Created by mabo on 2018/8/15
*/
public class 种红包登录解锁_AccessTest extends DuibaTestBase{
@Autowired
SeedRedPacketService seedRedPacketService;
@Autowired
WalletAccountService walletAccountService;
@Autowired
Authorization authorization;
private DuibaLog logger = DuibaLog.getLogger();
//指定用户
private static int uid = 4565;
private static String consumerId = "100101043";
@BeforeClass
public void beforeclass() {
try {
//还原用户的连续登陆天数为2
RedisUtil.setKey( "AAW_K146_19380_"+consumerId+"_"+getTime(),"2");
seedRedPacketService.updateUserLand("19380","1","3",consumerId,"1");
seedRedPacketService.updateUserLand("19380","1","5",consumerId,"1");
seedRedPacketService.updateUserLand("19380","1","7",consumerId,"1");
} catch (Exception e) {
logger.info("数据前后置操作异常");
}
}
@Test(description = "第三块土地连续登录3天解锁")
public void a_第三块土地解锁() throws Exception {
//dafuweng登陆获取cookies
Map cookies = authorization.dafuwengLogin(uid);
//调用getLandList接口
Response response = seedRedPacketService.getLandList(cookies,"1","424");
String landStatus = response.jsonPath().getString("data.landList[2].landStatus");
logger.info("第三块土地状态为:未解锁-"+landStatus);
Assert.assertEquals(landStatus,"1","第三块土地状态校验失败");
//修改redis用户连续登陆天数为3天
RedisUtil.setKey( "AAW_K146_19380_"+consumerId+"_"+getTime(),"3");
//调用getLandList接口
response = seedRedPacketService.getLandList(cookies,"1","424");
landStatus = response.jsonPath().getString("data.landList[2].landStatus");
logger.info("第三块土地状态为:可解锁-"+landStatus);
Assert.assertEquals(landStatus,"2","第三块土地状态校验失败");
//调用解锁土地接口
response = seedRedPacketService.unlockLand(cookies,"1","424","3");
//调用getLandList接口
response = seedRedPacketService.getLandList(cookies,"1","424");
landStatus = response.jsonPath().getString("data.landList[2].landStatus");
logger.info("第三块土地状态为:空地-"+landStatus);
Assert.assertEquals(landStatus,"3","第三块土地状态校验失败");
}
@Test(description = "第五块土地连续登录7天解锁")
public void b_第五块土地解锁() throws Exception {
//dafuweng登陆获取cookies
Map cookies = authorization.dafuwengLogin(uid);
//调用getLandList接口
Response response = seedRedPacketService.getLandList(cookies,"1","424");
String landStatus = response.jsonPath().getString("data.landList[4].landStatus");
logger.info("第五块土地状态为:未解锁-"+landStatus);
Assert.assertEquals(landStatus,"1","第五块土地状态校验失败");
//修改redis用户连续登陆天数为3天
RedisUtil.setKey( "AAW_K146_19380_"+consumerId+"_"+getTime(),"7");
//调用getLandList接口
response = seedRedPacketService.getLandList(cookies,"1","424");
landStatus = response.jsonPath().getString("data.landList[4].landStatus");
logger.info("第五块土地状态为:可解锁-"+landStatus);
Assert.assertEquals(landStatus,"2","第五块土地状态校验失败");
//调用解锁土地接口
response = seedRedPacketService.unlockLand(cookies,"1","424","5");
//调用getLandList接口
response = seedRedPacketService.getLandList(cookies,"1","424");
landStatus = response.jsonPath().getString("data.landList[4].landStatus");
logger.info("第五块土地状态为:空地-"+landStatus);
Assert.assertEquals(landStatus,"3","第五块土地状态校验失败");
}
@Test(description = "第七块土地连续登录15天解锁")
public void c_第七块土地解锁() throws Exception {
//dafuweng登陆获取cookies
Map cookies = authorization.dafuwengLogin(uid);
//调用getLandList接口
Response response = seedRedPacketService.getLandList(cookies,"1","424");
String landStatus = response.jsonPath().getString("data.landList[6].landStatus");
logger.info("第七块土地状态为:未解锁-"+landStatus);
Assert.assertEquals(landStatus,"1","第七块土地状态校验失败");
//修改redis用户连续登陆天数为3天
RedisUtil.setKey( "AAW_K146_19380_"+consumerId+"_"+getTime(),"15");
//调用getLandList接口
response = seedRedPacketService.getLandList(cookies,"1","424");
landStatus = response.jsonPath().getString("data.landList[6].landStatus");
logger.info("第七块土地状态为:可解锁-"+landStatus);
Assert.assertEquals(landStatus,"2","第七块土地状态校验失败");
//调用解锁土地接口
response = seedRedPacketService.unlockLand(cookies,"1","424","7");
//调用getLandList接口
response = seedRedPacketService.getLandList(cookies,"1","424");
landStatus = response.jsonPath().getString("data.landList[6].landStatus");
logger.info("第七块土地状态为:空地-"+landStatus);
Assert.assertEquals(landStatus,"3","第七块土地状态校验失败");
}
//获取当天日期
public String getTime(){
SimpleDateFormat dateFormat = new SimpleDateFormat("YYYY-MM-dd", Locale.ENGLISH);
Date date = new Date();
String time = dateFormat.format(date);
return time;
}
}
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