Commit 1cb476f3 authored by 赵然's avatar 赵然

zr

parent 8b946a7d
...@@ -85,10 +85,6 @@ public class 种红包_AccessTest extends DuibaTestBase{ ...@@ -85,10 +85,6 @@ public class 种红包_AccessTest extends DuibaTestBase{
account = new BigDecimal(map.get("balance_amount").toString()).divide(new BigDecimal("100")); account = new BigDecimal(map.get("balance_amount").toString()).divide(new BigDecimal("100"));
Assert.assertTrue(account.compareTo(newAccount)==0,"钱包账户增加异常"); Assert.assertTrue(account.compareTo(newAccount)==0,"钱包账户增加异常");
} }
......
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");
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("数据后置操作异常");
}
}
}
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