Commit 88594e86 authored by 吕雯燕's avatar 吕雯燕

lv

parent 32d443f2
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元");
}
}
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;
}
}
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