Commit 100038b1 authored by 吕雯燕's avatar 吕雯燕

Merge branch 'duiba_wenyan'

parents f2f23b45 a1040c9b
package http.cases.LotterySquareTest;
import base.DuibaTestBase;
import http.service.Activity.LotterySquareService;
import io.restassured.response.Response;
import org.apache.ibatis.jdbc.SQL;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import java.sql.SQLException;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CopyOnWriteArrayList;
/**
* Created by lvwenyan on 2019/12/21
*/
public class 红包广场提现_AccessTest extends DuibaTestBase {
@Autowired
LotterySquareService lotterySquareService;
@Test(description = "用户提现成功测试")
public void 红包提现成功() throws Exception{
int uid = 7450;
String activityId = "1";
String money = "1";
//查询提现页面
Response indexResponse = lotterySquareService.cashIndexInfo(uid,activityId);
indexResponse.prettyPrint();
String accountBalance = indexResponse.jsonPath().getString("data.accountBalance");
String leftCashTimes = indexResponse.jsonPath().getString("data.leftCashTimes");
logger.info("钱包余额:" + accountBalance);
logger.info("剩余可提现次数:" + leftCashTimes);
String accountBalanceResult = String.valueOf(Integer.valueOf(accountBalance) -100) ;
String leftCashTimesResult = String.valueOf(Integer.valueOf(leftCashTimes) -1) ;
//提现接口
Response cashDrawsResponse = lotterySquareService.cashDraws(uid,activityId,money);
cashDrawsResponse.prettyPrint();
//再次查询提现页面
indexResponse = lotterySquareService.cashIndexInfo(uid,activityId);
accountBalance = indexResponse.jsonPath().getString("data.accountBalance");
leftCashTimes = indexResponse.jsonPath().getString("data.leftCashTimes");
logger.info("提现后钱包余额:" + accountBalance);
logger.info("提现后剩余可提现次数:" + leftCashTimes);
Assert.assertEquals(accountBalance,accountBalanceResult,"校验accountBalance失败");
Assert.assertEquals(leftCashTimes,leftCashTimesResult,"校验leftCashTimes失败");
logger.info("校验成功:红包广场提现1元");
}
@Test(description = "用户提现失败测试:支付宝账号已被绑定")
public void 支付宝账号已被绑定() throws Exception{
int uid = 7451;
String activityId = "1";
String money = "1";
String account = "peeulk6392@sandbox.com";
String username = "沙箱环境";
Response response = lotterySquareService.cashDraws2(uid,activityId,money,account,username);
response.prettyPrint();
Assert.assertEquals(response.jsonPath().getString("success"),"false","校验success失败");
Assert.assertEquals(response.jsonPath().getString("desc"),"该支付宝账号已被绑定,请更换","校验desc失败");
logger.info("校验成功:支付宝账号已被绑定提现失败");
}
@Test(description = "用户提现失败测试:支付宝账号非法")
public void 支付宝账号非法() throws Exception{
int uid = 7451;
String activityId = "1";
String money = "1";
String account = "lvwenyan@duiba.co";
String username = "吕雯燕";
Response response = lotterySquareService.cashDraws2(uid,activityId,money,account,username);
response.prettyPrint();
Assert.assertEquals(response.jsonPath().getString("success"),"false","校验success失败");
Assert.assertEquals(response.jsonPath().getString("desc"),"系统异常,请稍后再试","校验desc失败");
logger.info("校验成功:支付宝账号非法提现失败");
}
@Test(description = "用户提现失败测试:钱包余额不足")
public void 钱包余额不足() throws Exception{
int uid = 7453;
String activityId = "1";
String money = "1";
String account = "lvwenyan5@duiba.com.cn";
String username = "吕雯燕";
Response response = lotterySquareService.cashDraws2(uid,activityId,money,account,username);
response.prettyPrint();
Assert.assertEquals(response.jsonPath().getString("success"),"false","校验success失败");
Assert.assertEquals(response.jsonPath().getString("desc"),"余额不足","校验desc失败");
logger.info("校验成功:钱包余额不足提现失败");
}
@Test(description = "用户提现测试:金额超过固定额度")
public void 金额超过固定额度() throws Exception{
int uid = 7454;
String activityId = "2";
//固定额度:1元,提现100元
String money = "100";
String account = "peeulk6392@sandbox.com";
String username = "沙箱环境";
//用户提现
Response response = lotterySquareService.cashDraws2(uid,activityId,money,account,username);
response.prettyPrint();
//账户资金流水
Response detailResponse = lotterySquareService.accountDetail(uid,activityId);
detailResponse.prettyPrint();
Assert.assertEquals(response.jsonPath().getString("success"),"true","校验success失败");
Assert.assertEquals(detailResponse.jsonPath().getString("data.list[0].money"),"1.0","校验money失败");
Assert.assertEquals(detailResponse.jsonPath().getString("data.list[0].description"),"红包广场提现操作","校验description失败");
logger.info("校验成功:金额超过固定额度只能提现1元");
}
}
package http.service.Activity;
import base.DuibaLog;
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 lvwenyan on 2019/12/21
*/
@Service
public class LotterySquareService {
@Value("${activity.host}")
String activityHost;
@Autowired
Authorization authorization;
private DuibaLog logger = DuibaLog.getLogger();
/**
* @param uid
* @param actId 活动id
* @return
* @throws Exception
*/
public Response cashIndexInfo(int uid, String actId) throws Exception{
Map<String,String> map = new HashMap<>();
map.put("actId",actId);
logger.info("请求/aaw/lotterySquare/cashIndexInfo接口");
Response response = given().cookies(authorization.dafuwengLogin(uid)).params(map).get(activityHost+"/aaw/lotterySquare/cashIndexInfo");
try {
Assert.assertEquals(response.jsonPath().getString("success"), "true", "/aaw/lotterySquare/cashIndexInfo接口失败");
} catch (Exception e) {
throw new Exception("/aaw/lotterySquare/cashIndexInfo接口失败,返回信息:" + response.asString());
} catch (Error er) {
throw new Exception("/aaw/lotterySquare/cashIndexInfo接口失败,返回信息:" + response.asString());
}
return response;
}
/**
* @param uid
* @param actId 活动id
* @param money 金额
* @return
* @throws Exception
*/
public Response cashDraws(int uid, String actId,String money) throws Exception{
Map<String,String> map = new HashMap<>();
map.put("actId",actId);
map.put("money",money);
map.put("account","peeulk6392@sandbox.com");
map.put("username","沙箱环境");
logger.info("请求/aaw/lotterySquare/cashDraws接口");
Response response = given().cookies(authorization.dafuwengLogin(uid)).contentType("application/x-www-form-urlencoded;charset=UTF-8").params(map).post(activityHost+"/aaw/lotterySquare/cashDraws");
try {
Assert.assertEquals(response.jsonPath().getString("success"), "true", "/aaw/lotterySquare/cashDraws接口失败");
} catch (Exception e) {
throw new Exception("/aaw/lotterySquare/cashDraws接口失败,返回信息:" + response.asString());
} catch (Error er) {
throw new Exception("/aaw/lotterySquare/cashDraws接口失败,返回信息:" + response.asString());
}
return response;
}
/**
* @param uid
* @param actId 活动id
* @param money 金额
* @param account 支付宝账号
* @param username 真实姓名
* @return
* @throws Exception
*/
public Response cashDraws2(int uid, String actId,String money,String account, String username){
Map<String,String> map = new HashMap<>();
map.put("actId",actId);
map.put("money",money);
map.put("account",account);
map.put("username",username);
logger.info("请求/aaw/lotterySquare/cashDraws接口");
Response response = given().cookies(authorization.dafuwengLogin(uid)).contentType("application/x-www-form-urlencoded;charset=UTF-8").params(map).post(activityHost+"/aaw/lotterySquare/cashDraws");
return response;
}
/**
* @param uid
* @param actId 活动id
* @return
* @throws Exception
*/
public Response accountDetail(int uid, String actId) throws Exception{
Map<String,String> map = new HashMap<>();
map.put("actId",actId);
map.put("pageSize","20");
map.put("pageNum","1");
logger.info("请求/aaw/lotterySquare/accountDetail接口");
Response response = given().cookies(authorization.dafuwengLogin(uid)).params(map).get(activityHost+"/aaw/lotterySquare/accountDetail");
try {
Assert.assertEquals(response.jsonPath().getString("success"), "true", "/aaw/lotterySquare/accountDetail接口失败");
} catch (Exception e) {
throw new Exception("/aaw/lotterySquare/accountDetail接口失败,返回信息:" + response.asString());
} catch (Error er) {
throw new Exception("/aaw/lotterySquare/accountDetail接口失败,返回信息:" + 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