Commit 37b364cd authored by 赵然's avatar 赵然

zr

parent 31d26070
...@@ -77,10 +77,10 @@ public class 答题_创建答题活动_DuibaTest extends DuibaTestBase { ...@@ -77,10 +77,10 @@ public class 答题_创建答题活动_DuibaTest extends DuibaTestBase {
} }
@AfterClass // @AfterClass
public void 清理数据() throws Exception{ // public void 清理数据() throws Exception{
jdbc.update("delete from hdtool_conf.duiba_hdtool where id="+actId); // jdbc.update("delete from hdtool_conf.duiba_hdtool where id="+actId);
logger.info("清理答题活动数据成功,活动id:"+actId); // logger.info("清理答题活动数据成功,活动id:"+actId);
} // }
} }
...@@ -10,6 +10,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -10,6 +10,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.testng.Assert; import org.testng.Assert;
import org.testng.annotations.AfterClass; import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import utils.HbaseService; import utils.HbaseService;
import utils.PublicMethod; import utils.PublicMethod;
...@@ -24,7 +25,7 @@ import static io.restassured.RestAssured.given; ...@@ -24,7 +25,7 @@ import static io.restassured.RestAssured.given;
/** /**
* Created by 赵然 on 2018/11/06 * Created by 赵然 on 2018/11/06
*/ */
public class 账户余额清零 extends DuibaTestBase { public class 账户余额清零_AccessTest extends DuibaTestBase {
@Value("${activity.host}") @Value("${activity.host}")
String activityHost; String activityHost;
@Autowired @Autowired
...@@ -40,24 +41,26 @@ public class 账户余额清零 extends DuibaTestBase { ...@@ -40,24 +41,26 @@ public class 账户余额清零 extends DuibaTestBase {
private static int uid = 4486; private static int uid = 4486;
private static String consumerId = "100098059"; private static String consumerId = "100098059";
@AfterClass @BeforeClass
public void afterclass() { public void beforeclass() {
try { 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 //重置账户金额10000
jdbc.update("update consumer_accounts.tb_consumer_account_0011 set balance_amount ='10000' where account_id = '" + consumerId + "_6_0'"); walletAccountService.updateConsumerAccount(consumerId,"6","10000");
} catch (Exception e) {
} catch (Exception e) {
logger.info("数据后面置操作异常"); logger.info("数据后面置操作异常");
} }
} }
@Test @Test
public void a_账户过期余额清零() throws Exception { public void a_账户过期余额清零() throws Exception {
//修改账户过期时间,确保账户始终处于过期状态
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'");
//删除自动化充值记录
jdbc.update("delete from consumer_account_log.tb_consumer_accounts_log where account_id = '"+consumerId+"_6_0' and biz_type='19'");
Map<String, Object> sqlResult = jdbc.findSimpleResult("select * from consumer_account_log.tb_expire_consumer_account where account_id = '"+consumerId+"_6_0' "); 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")); String gmt_modified1 = String.valueOf(sqlResult.get("gmt_modified"));
logger.info("账户第一次登录时间为" + gmt_modified1); logger.info("账户第一次登录时间为" + gmt_modified1);
...@@ -90,33 +93,30 @@ public class 账户余额清零 extends DuibaTestBase { ...@@ -90,33 +93,30 @@ public class 账户余额清零 extends DuibaTestBase {
public void b_扣款明细校验() throws Exception { 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"); 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 change_money = String.valueOf(selectResult.get("change_money")); String action_type = String.valueOf(selectResult.get("action_type"));
String action_type = String.valueOf(selectResult.get("action_type")); String sub_type = String.valueOf(selectResult.get("sub_type"));
String sub_type = String.valueOf(selectResult.get("sub_type")); String biz_description = String.valueOf(selectResult.get("biz_description"));
String biz_description = String.valueOf(selectResult.get("biz_description"));
Assert.assertEquals(change_money, "10000", "数据库扣款金额校验失败");
Assert.assertEquals(change_money, "10000", "数据库扣款金额校验失败"); Assert.assertEquals(action_type, "0", "数据库账户动作校验失败");
Assert.assertEquals(action_type, "0", "数据库账户动作校验失败"); Assert.assertEquals(sub_type, "0", "数据库日志类型校验失败");
Assert.assertEquals(sub_type, "0", "数据库日志类型校验失败"); Assert.assertEquals(biz_description.contains("红包过期"), true, "数据库业务描述校验失败");
Assert.assertEquals(biz_description.contains("红包过期"), true, "数据库业务描述校验失败"); logger.info("数据库账户过期清零记录校验成功");
logger.info("数据库账户过期清零记录校验成功");
//获取最新的提现记录
//获取最新的提现记录 Map cookies = authorization.dafuwengLogin(uid);
Map cookies = authorization.dafuwengLogin(uid); Response response = walletAccountService.walletDetail(cookies);
Response response = walletAccountService.walletDetail(cookies); String money = response.jsonPath().getString("data[1].money");
String money = response.jsonPath().getString("data[1].money"); String subType = response.jsonPath().getString("data[1].subType");
String subType = response.jsonPath().getString("data[1].subType"); String description = response.jsonPath().getString("data[1].description");
String description = response.jsonPath().getString("data[1].description");
Assert.assertTrue(new BigDecimal(money).compareTo(new BigDecimal("100"))==0,"扣款金额校验失败");
Assert.assertTrue(new BigDecimal(money).compareTo(new BigDecimal("100"))==0,"扣款金额校验失败"); Assert.assertEquals(subType, "0", "日志类型校验失败");
Assert.assertEquals(subType, "0", "日志类型校验失败"); Assert.assertEquals(description.contains("红包过期"),true, "日志类型校验失败");
Assert.assertEquals(description.contains("红包过期"),true, "日志类型校验失败"); logger.info("订单列表过期记录校验成功");
logger.info("订单列表过期记录校验成功");
}else{
logger.info("数据库未生成扣款记录,有可能是用例距离上一次执行时间过短");
}
} }
......
...@@ -135,4 +135,32 @@ public class WalletAccountService { ...@@ -135,4 +135,32 @@ public class WalletAccountService {
return response; return response;
} }
/**
* 红包账户修改钱包账户余额后门
* @param consumerId
* @param accountType
* @param balanceAmount
* @return
* @throws Exception
*/
public void updateConsumerAccount(String consumerId,String accountType,String balanceAmount) throws Exception {
logger.info("请求修改钱包账户余额后门:updateConsumerAccount");
Map<String,String> map = new HashMap<>();
map.put("consumerId",consumerId);
map.put("accountType",accountType);
map.put("balanceAmount",balanceAmount);
Response response = given().params(map).get(activityHost+"/aaw/automated/updateConsumerAccount");
// try{
// Assert.assertEquals(response.jsonPath().getString("success"),"true","/walletAccount/walletDetail接口失败");
//
// }catch(Exception e){
// throw new Exception("/aaw/automated/updateConsumerAccount接口失败,返回信息:"+response.asString());
// }catch(Error er){
// throw new Exception("/aaw/automated/updateConsumerAccount接口失败,返回信息:"+response.asString());
//
// }
//return response;
}
} }
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