Commit 629bee8c authored by 赵然's avatar 赵然

zr

parent c7a95f64
package http.cases.ExchangeTest;
public class Database {
//主订单库
public static String orders_consumer = "orders_consumer";
//主订单分表
public static String orders = "orders_0614";
public static String orders2 = "orders_0874";
public static String orders3 = "orders_0693";
public static String orders4 = "orders_0208";
public static String orders5 = "orders_0209";
public static String orders6 = "orders_0210";
public static String orders7 = "orders_0211";
}
package http.cases.ExchangeTest;
import base.DuibaTestBase;
import http.service.Activity.ManagerService;
import http.service.Authorization;
import http.service.app.CouponExchangeService;
import http.service.app.MobileService;
import http.service.app.SeckillService;
import http.service.hd.PlatformCouponService;
import base.DuibaLog;
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.Test;
import java.util.Map;
//@ContextConfiguration(classes = DuibaConfig.class)
public class Exchange_ExchangeTest extends DuibaTestBase{
@Value("${manager.host}")
String ManagerHost;
@Autowired
private MobileService mobileService;
@Autowired
private Authorization authorization;
@Autowired
private CouponExchangeService couponExchangeService;
@Autowired
private PlatformCouponService platformCouponService;
@Autowired
private SeckillService SeckillService;
@Autowired
ManagerService managerService;
private DuibaLog logger = DuibaLog.getLogger();
// private MysqlUtils jdbc;
//指定用户
private static int uid = 3766;
// @BeforeClass
// public void before(){
// jdbc = MysqlUtils.mysqlDuiba("dafuweng");
// }
// @AfterClass
// public void after(){
// jdbc.releaseConn();
//
// }
//实物兑换并发货
@Test(description = "实物兑换")
public void goods() throws Exception {
//查询数据库,当前积分
Map<String,Object> mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
String credits = String.valueOf(mapuser.get("credits"));
logger.info("兑换前积分:"+credits);
//扣去100积分
credits = String.valueOf(Integer.valueOf(credits)-100);
//活动详情页
Response response =mobileService.detail(authorization.dafuwengLogin(uid),"26762");
Map<String,String> map = authorization.dafuwengLogin(uid);
Assert.assertEquals(String.valueOf(response.getStatusCode()),"200","活动详情页请求异常");
//实物兑换
response = couponExchangeService.objectExchange(map,"159143","2619","null","z9sydmcs","null");
// response.prettyPrint();
//校验兑换成功
// Assert.assertEquals(response.jsonPath().getString("success"),"true");
//获取orderId
String orderId = response.jsonPath().getString("orderId");
//获取兑换结果
response = mobileService.orderAmbStatusQuery(uid,orderId);
response.prettyPrint();
String message = response.jsonPath().getString("data.message");
int i=10;
//异步接口,直到兑换成功
while(i>0&&"兑换正在处理中...".equals(message)){
Thread.sleep(1000);
response = mobileService.orderAmbStatusQuery(uid,orderId);
response.prettyPrint();
message = response.jsonPath().getString("data.message");
i--;
}
//查询数据库,获取当前积分
Thread.sleep(3000);
mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
String creditsNew = String.valueOf(mapuser.get("credits"));
logger.info("兑换后积分:"+creditsNew);
//校验比较,兑换前后积分
Assert.assertEquals(credits,creditsNew);
logger.info("校验兑换前后积分正确");
//兑吧管理后台发货
managerService.expressSend(orderId);
logger.info("实物兑换订单成功");
}
//秒杀
@Test(description = "秒杀兑换")
public void seckill(){
Response response = SeckillService.ajaxSubmit("18556");
response.prettyPrint();
Assert.assertEquals(response.jsonPath().getString("success"),"true");
}
//优惠券兑换
@Test(description = "优惠券兑换")
public void coupon() throws Exception {
//查询数据库,当前积分
Map<String,Object> mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
String credits = String.valueOf(mapuser.get("credits"));
logger.info("兑换前积分:"+credits); //扣去100积分
credits = String.valueOf(Integer.valueOf(credits)-100);
//优惠券兑换
Response response = couponExchangeService.couponExchange(authorization.dafuwengLogin(uid),"157070","27050");
String orderId = response.jsonPath().getString("orderId");
//查看兑换结果
response = mobileService.orderStatusQuery(response.getDetailedCookies(),uid,orderId);
String status = response.jsonPath().getString("status");
//异步接口
int i=10;
while(i>0&&"processing".equals(status)){
Thread.sleep(1000);
response = mobileService.orderStatusQuery(response.getDetailedCookies(),uid,orderId);
response.prettyPrint();
status = response.jsonPath().getString("status");
i--;
}
//查询数据库,获取当前积分
Thread.sleep(3000);
mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
String creditsNew = String.valueOf(mapuser.get("credits"));
logger.info("兑换后积分:"+creditsNew);
//校验比较,兑换前后积分
Assert.assertEquals(credits.trim(),creditsNew,"优惠券兑换后积分扣除异常");
logger.info("校验兑换前后积分正确");
}
}
package http.cases.ExchangeTest;
import base.DuibaTestBase;
import http.service.Activity.ManagerService;
import http.service.Authorization;
import http.service.app.CouponExchangeService;
import http.service.app.CrecordService;
import http.service.app.MobileService;
import http.service.app.VirtualExchangeService;
import http.service.hd.DeveloperAccountService;
import utils.MatcherString;
import base.DuibaLog;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.Test;
import java.util.Map;
/**
* Created by yeqinqin on 2018/6/11.
*/
public class 实物_兑换异常测试_ExchangeTest extends DuibaTestBase {
@Autowired
private MobileService mobileService;
@Autowired
private Authorization authorization;
@Autowired
private CouponExchangeService couponExchangeService;
@Autowired
private CrecordService crecordService;
@Autowired
ManagerService managerService;
@Autowired
VirtualExchangeService virtualExchangeService;
@Autowired
DeveloperAccountService developerAccountService;
private DuibaLog logger = DuibaLog.getLogger();
//指定用户
private static int uid = 3770;
//实物兑换积分不足
@Test(description = "实物兑换积分不足")
public void 积分不足() throws Exception {
//活动详情页
Response response = mobileService.detail(authorization.dafuwengLogin(3086), "28515");
Map<String, String> map = authorization.dafuwengLogin(3086);
Assert.assertEquals(String.valueOf(response.getStatusCode()), "200", "活动详情页请求异常");
//实物兑换
response = couponExchangeService.objectExchange(map, "167141", "28515", "null", "z9sydmcs", "null");
response.prettyPrint();
//校验兑换成功
// Assert.assertEquals(response.jsonPath().getString("success"),"true");
//获取orderId
String orderId = response.jsonPath().getString("orderId");
//获取兑换结果
response = mobileService.orderAmbStatusQuery(3086,orderId);
response.prettyPrint();
String message = response.jsonPath().getString("data.message");
int i = 10;
//异步接口,直到兑换成功
while (i > 0 && "兑换正在处理中...".equals(message)) {
Thread.sleep(1000);
response = mobileService.orderAmbStatusQuery(3086,orderId);
response.prettyPrint();
message = response.jsonPath().getString("data.message");
i--;
}
//校验messaga字段返回值
String message2 = response.jsonPath().getString("data.message");
Assert.assertEquals(message2,"兑换失败,用户积分余额不足","message字段校验失败-期望是积分不足");
// authorization.dafuwengLogin(2720,true);
}
//实物兑换限制消费
@Test(description = "实物兑换已兑换")
public void 已兑换() throws Exception {
//活动详情页
Response response = mobileService.detail(authorization.dafuwengLogin(uid), "28633");
// response.prettyPrint();
Map<String, String> map = authorization.dafuwengLogin(uid);
Assert.assertEquals(String.valueOf(response.getStatusCode()), "200", "活动详情页请求异常");
//实物兑换
Response response1 = couponExchangeService.objectExchange1(map, "167611", "28633", "null", "z9sydmcs", "null");
response1.prettyPrint();
//校验兑换成功
// Assert.assertEquals(response.jsonPath().getString("success"),"true");
//获取orderId
// String orderId = response1.jsonPath().getString("orderId");
// //获取兑换结果
// Response response3 = mobileService.orderAmbStatusQuery(orderId);
// response3.prettyPrint();
// String message = response3.jsonPath().getString("data.message");
// int i = 10;
// //异步接口,直到兑换成功
// while (i > 0 && "兑换正在处理中...".equals(message)) {
// Thread.sleep(1000);
// response3 = mobileService.orderAmbStatusQuery(orderId);
// response3.prettyPrint();
// message = response3.jsonPath().getString("data.message");
// i--;
// }
//校验messaga字段返回值
String message2 = response1.jsonPath().getString("message");
Assert.assertEquals(message2,"已兑换","message字段校验失败-期望是已兑换");
}
@Test
public void 开发者余额不足测试() throws Exception{
int uid = 3490;
//开发者余额, 开发者账户:xuyan_8707@163.com
Response accountResponse = developerAccountService.accountInfoCommon("xuyan_8707@163.com");
String remainMoney = accountResponse.jsonPath().getString("data.remainMoney");
logger.info("兑换前的开发者账户余额:" + remainMoney);
Response detailResponse = mobileService.detail(authorization.dafuwengLogin(uid),"31050");
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
logger.info("~~~"+exchangeText);
Assert.assertTrue(exchangeText.contains("已兑完"));
String message=null;
String succcess = null;
try{
Response response = couponExchangeService.objectExchange1(authorization.dafuwengLogin(uid), "178880", "31050", "null", "z9sydmcs", "null");
message = response.jsonPath().getString("message");
}catch (Exception e){
message = e.toString();
}
logger.info(message);
Assert.assertTrue(message.contains("没有兑换成功"));
}
// @Test
public void 每日兑换限制() throws Exception {
int uid = 3490;
//第一次兑换
Response response = couponExchangeService.objectExchange(authorization.dafuwengLogin(uid), "178879", "31049", "null", "z9sydmcs", "null");
response.prettyPrint();
String orderId = response.jsonPath().getString("orderId");
//获取兑换结果
response = mobileService.orderAmbStatusQuery(uid,orderId);
response.prettyPrint();
String message = response.jsonPath().getString("data.message");
int i = 10;
//异步接口,直到兑换成功
while (i > 0 && "兑换正在处理中...".equals(message)) {
Thread.sleep(1000);
response = mobileService.orderAmbStatusQuery(uid,orderId);
response.prettyPrint();
message = response.jsonPath().getString("data.message");
i--;
}
//第二次兑换
try{
response = couponExchangeService.objectExchange(authorization.dafuwengLogin(uid), "178879", "31049", "null", "z9sydmcs", "null");
response.prettyPrint();
}catch (Exception e){
// message = e.toString();
}
// logger.info(message);
// Assert.assertTrue(message.contains("已兑完"));
// Assert.assertTrue(message.contains("\"success\":false"));
}
}
package http.cases.ExchangeTest;
import base.DuibaTestBase;
import http.service.Activity.ManagerService;
import http.service.Authorization;
import http.service.app.MobileService;
import http.service.app.VirtualExchangeService;
import base.DuibaLog;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.Test;
import java.util.Map;
/**
* Created by yeqinqin on 2018/6/11.
*/
public class 虚拟商品_兑换异常测试 extends DuibaTestBase {
@Autowired
private MobileService mobileService;
@Autowired
private Authorization authorization;
@Autowired
ManagerService managerService;
@Autowired
VirtualExchangeService virtualExchangeService;
private DuibaLog logger = DuibaLog.getLogger();
//指定用户
private static int uid = 0;
//实物兑换积分不足
@Test(description = "自有虚拟商品积分不足")
public void 积分不足() throws Exception {
//活动详情页
Response response = mobileService.appItemDetail(authorization.dafuwengLogin(uid), "181159");
Map<String, String> map = authorization.dafuwengLogin(uid,true);
Assert.assertEquals(String.valueOf(response.getStatusCode()), "200", "商品详情页面");
response.prettyPrint();
System.out.println(response.asString());
System.out.println("女汉子");
//自有虚拟商品兑换
response = virtualExchangeService.exchange(authorization.dafuwengLogin(uid), "181159", "123");
//获取orderId
String orderId = response.jsonPath().getString("orderId");
response = mobileService.orderAmbStatusQuery(uid,orderId);
response.prettyPrint();
String message = response.jsonPath().getString("data.message");
//异步接口,直到兑换成功
int i=10;
//异步接口,直到兑换成功
while(i>0&&"兑换正在处理中...".equals(message)){
Thread.sleep(1000);
response = mobileService.orderAmbStatusQuery(uid,orderId);
response.prettyPrint();
message = response.jsonPath().getString("data.message");
i--;
}
Assert.assertEquals(message.trim(),"兑换失败,用户积分余额不足","校验自有虚拟商品积分不足");
}
}
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