Commit b5f8aa16 authored by 马博's avatar 马博

Merge branch 'master' of gitlab2.dui88.com:mabo/test-platform

parents 8ad86640 ec503ecb
......@@ -59,7 +59,7 @@ public class 集卡活动助力_AccessTest extends DuibaTestBase {
//开始助力
Response helpResponse = clcardService.doHelpNew(uid1,activityId,shareCode);
helpResponse.prettyPrint();
Thread.sleep(100);
Thread.sleep(1000);
//首页集卡信息
indexResponse = clcardService.activity(uid1,activityId);
int resultCount = Integer.parseInt(indexResponse.jsonPath().getString("data.cards[1].count"));
......
......@@ -3,6 +3,7 @@ package http.cases.ClcardTest;
import base.DuibaTestBase;
import http.service.Activity.ClcardService;
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;
......@@ -29,18 +30,13 @@ public class 集卡活动领奖_AccessTest extends DuibaTestBase {
@BeforeClass
public void before(){
try {
//修改表,增加用户卡片,"集卡领奖成功"
jdbc.update("update collect_card_consumer.tb_collect_card_info_0548 set item_count = item_count +1 , item_total_count = item_total_count +1 WHERE consumer_id = 100164132 AND item_id = 12");
jdbc.update("update collect_card_consumer.tb_collect_card_info_0548 set item_count = item_count +2 , item_total_count = item_total_count +2 WHERE consumer_id = 100164132 AND item_id = 13");
jdbc.update("update collect_card_consumer.tb_collect_card_info_0548 set item_count = item_count +3 , item_total_count = item_total_count +3 WHERE consumer_id = 100164132 AND item_id = 14");
try{
//修改表,增加用户卡片,"A_集卡单用户并发领奖"
jdbc.update("update collect_card_consumer.tb_collect_card_info_0332 set item_count = item_count +1 , item_total_count = item_total_count +1 WHERE consumer_id = 100168012 AND item_id = 20");
jdbc.update("update collect_card_consumer.tb_collect_card_info_0332 set item_count = item_count +1 , item_total_count = item_total_count +1 WHERE consumer_id = 100168012 AND item_id = 21");
} catch (SQLException e) {
}catch (SQLException e) {
e.printStackTrace();
}
......@@ -50,6 +46,13 @@ public class 集卡活动领奖_AccessTest extends DuibaTestBase {
@Test(description = "集卡活动领奖支付宝测试")
public void 集卡领奖成功() throws Exception{
//修改表,增加用户卡片,"集卡领奖成功"
jdbc.update("update collect_card_consumer.tb_collect_card_info_0548 set item_count = item_count +1 , item_total_count = item_total_count +1 WHERE consumer_id = 100164132 AND item_id = 12");
jdbc.update("update collect_card_consumer.tb_collect_card_info_0548 set item_count = item_count +2 , item_total_count = item_total_count +2 WHERE consumer_id = 100164132 AND item_id = 13");
jdbc.update("update collect_card_consumer.tb_collect_card_info_0548 set item_count = item_count +3 , item_total_count = item_total_count +3 WHERE consumer_id = 100164132 AND item_id = 14");
Thread.sleep(1000);
int uid = 7402;
String activityId = "45501";
......@@ -81,19 +84,19 @@ public class 集卡活动领奖_AccessTest extends DuibaTestBase {
Assert.assertEquals(response.jsonPath().getString("lottery.title"),"支付宝","校验奖品title失败");
Assert.assertEquals(response.jsonPath().getString("result"),"2","校验result失败");
Assert.assertEquals(cards0,"1","校验card0失败");
Assert.assertEquals(cards0,"0","校验card0失败");
Assert.assertEquals(cards1,"2","校验card1失败");
Assert.assertEquals(cards2,"4","校验card2失败");
Assert.assertEquals(cards2,"1","校验card2失败");
Assert.assertEquals(rules0,"1","校验rules0失败");
Assert.assertEquals(rules1,"2","校验rules1失败");
Assert.assertEquals(rules2,"3","校验rules2失败");
logger.info("集卡活动领奖成功");
logger.info("校验成功:集卡活动领奖成功");
}
@Test(description = "集卡活动领奖库存不足测试")
@Test(description = "集卡活动领奖实物库存不足测试")
public void 集卡领奖库存不足() throws Exception{
int uid = 7414;
......@@ -117,7 +120,7 @@ public class 集卡活动领奖_AccessTest extends DuibaTestBase {
//库存不足,接口会轮询处理超时
Assert.assertEquals(result,"0","校验result失败");
Assert.assertEquals(response.jsonPath().getString("takeSuccess"),"false","校验takeSuccess失败");
logger.info("集卡大奖库存不足领奖失败");
logger.info("校验成功:集卡大奖库存不足领奖失败");
}
......@@ -132,7 +135,7 @@ public class 集卡活动领奖_AccessTest extends DuibaTestBase {
response.prettyPrint();
Assert.assertEquals(response.jsonPath().getString("desc"),"卡片还未集齐,请继续集卡","校验desc失败");
logger.info("集卡卡片未集齐领奖失败");
logger.info("校验成功:集卡卡片未集齐领奖失败");
}
......@@ -141,10 +144,11 @@ public class 集卡活动领奖_AccessTest extends DuibaTestBase {
//同一用户并发领奖 活动:【自动化】集卡发奖3
@Test(threadPoolSize = 5, invocationCount =5)
public void A_集卡单用户并发领奖() throws Exception {
int uid = 7416;
String activityId = "45531";
//领奖(只有一次兑换机会)
//领奖(只有一次机会)
Response response = clcardService.openPrize2(uid,activityId);
resultList.add(response.asString());
logger.info("请求返回结果:" + response.asString());
......@@ -155,21 +159,77 @@ public class 集卡活动领奖_AccessTest extends DuibaTestBase {
int fail = 0;
int success = 0;
for (String s: resultList) {
if(s.contains("desc\":\"服务器开小差了,请稍后重试")){
fail++;
}else if(s.contains("\"desc\":\"OK\"")){
if(s.contains("\"desc\":\"OK\"")){
success++;
}else{
}else if (s.contains("\"success\":false")){
fail++;
}else {
System.out.println(s);
}
}
//检验 成功的只有一个。错误提示有多种
Assert.assertEquals(fail,4,"校验fail数量失败");
Assert.assertEquals(success,1,"校验success数量失败");
logger.info("校验集卡单用户并发成功");
logger.info("校验成功:集卡单用户并发领奖");
}
@Test(description = "集卡活动已下架,领奖测试")
public void 集卡活动已下架再领奖() throws Exception{
int uid = 7451;
String activityId = "45620";
Response response = clcardService.openPrize2(uid,activityId);
response.prettyPrint();
Assert.assertEquals(response.jsonPath().getString("desc"),"活动不存在!","校验desc失败");
logger.info("校验成功:集卡活动已下架领奖失败");
}
@Test(description = "集卡活动已结束,领奖测试")
public void 集卡活动已结束再领奖() throws Exception{
int uid = 7450;
String activityId = "45619";
Response response = clcardService.openPrize2(uid,activityId);
response.prettyPrint();
Assert.assertEquals(response.jsonPath().getString("desc"),"活动已结束","校验desc失败");
logger.info("校验成功:集卡活动已结束领奖失败");
}
@Test(description = "开发者余额不足,集卡领奖支付宝测试")
public void 开发者余额不足领奖() throws Exception{
//开发者账号:13000000000
int uid = 7452;
String activityId = "45622";
Response response = clcardService.openPrize(uid,activityId);
String orderNum = response.jsonPath().getString("data.orderNum");
response = clcardService.getOrderStatus(uid,orderNum);
response.prettyPrint();
String result = String.valueOf(response.jsonPath().getString("result"));
int i= 30;
while(i>0&&(result.equals("0"))){
Thread.sleep(500);
response = clcardService.getOrderStatus(uid,orderNum);
result = String.valueOf(response.jsonPath().getString("result"));
i--;
response.prettyPrint();
}
//库存不足,接口会轮询处理超时
Assert.assertEquals(result,"0","校验result失败");
Assert.assertEquals(response.jsonPath().getString("takeSuccess"),"false","校验takeSuccess失败");
logger.info("校验成功:开发者余额不足领奖支付宝失败");
}
}
......@@ -17,7 +17,7 @@ public class Database {
public static String orders13 = "orders_0411";
public static String orders14 = "orders_0712";
public static String orders15 = "orders_0063";
public static String orders16 = "orders_0721";
public static String orders16 = "orders_0632";
......
......@@ -113,7 +113,7 @@ public class Qb_兑换流程测试_ExchangeTest extends CheckTemplet {
@Test
public void qbExchange_档位不存在() throws Exception {
int uid = 3767;
int uid = 7474;
String message = "";
......@@ -178,12 +178,12 @@ public class Qb_兑换流程测试_ExchangeTest extends CheckTemplet {
Assert.assertTrue(message.contains("\"success\":false"));
}
@Test
public void 每日兑换限制() throws Exception {
int uid = 3767;
int uid = 7475;
//第一次兑换
Thread.sleep(5000);
Response response = qbExchangeService.doTakePrize(authorization.dafuwengLogin(uid),"1234345554","1");
String orderId = (String)response.jsonPath().get("orderId");
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid),orderId);
......@@ -209,12 +209,12 @@ public class Qb_兑换流程测试_ExchangeTest extends CheckTemplet {
Assert.assertTrue(message.contains("\"success\":false"));
}
@Test
public void 永久兑换限制() throws Exception {
int uid = 3767;
int uid = 7476;
//第一次兑换
Thread.sleep(5000);
Response response = qbExchangeService.doTakePrize(authorization.dafuwengLogin(uid),"1234345554","2");
String orderId = (String)response.jsonPath().get("orderId");
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid),orderId);
......
......@@ -69,7 +69,6 @@ public class Qb_兑换限制测试_ExchangeTest extends CheckTemplet {
int uid = 4932;
//第一次兑换
Thread.sleep(4000);
Response response = qbExchangeService.doTakePrize(authorization.dafuwengLogin(uid),"1234343554","1");
String orderId = (String)response.jsonPath().get("orderId");
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid),orderId);
......@@ -100,10 +99,9 @@ public class Qb_兑换限制测试_ExchangeTest extends CheckTemplet {
@Test(description = "Q币2元用户兑换限制永久")
public void 用户永久兑换限制() throws Exception {
int uid = 4933;
int uid = 7477;
//第一次兑换
Thread.sleep(4000);
Response response = qbExchangeService.doTakePrize(authorization.dafuwengLogin(uid),"1234345554","2");
String orderId = (String)response.jsonPath().get("orderId");
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid),orderId);
......@@ -136,10 +134,9 @@ public class Qb_兑换限制测试_ExchangeTest extends CheckTemplet {
@Test(description = "Q币3元用户兑换限制每月")
public void 用户每月兑换限制() throws Exception {
int uid = 4933;
int uid = 7478;
//第一次兑换
Thread.sleep(4000);
Response response = qbExchangeService.doTakePrize(authorization.dafuwengLogin(uid),"12343432554","3");
String orderId = (String)response.jsonPath().get("orderId");
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid),orderId);
......@@ -208,7 +205,6 @@ public class Qb_兑换限制测试_ExchangeTest extends CheckTemplet {
int uid = 4934;
//第一次兑换
Thread.sleep(5000);
Response response = qbExchangeService.doTakePrize(authorization.dafuwengLogin(uid),"123434555412","1");
String orderId = (String)response.jsonPath().get("orderId");
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid),orderId);
......
......@@ -276,9 +276,9 @@ public class 新Qb_兑换流程测试_ExchangeTest extends CheckTemplet {
public void Q币用户id篡改测试() throws Exception{
//商品: lv测试应用77
//uid1: 大富翁app
//uid1: lv测试应用55
//uid2: lv测试应用88
int uid1 = 7084;
int uid1 = 7315;
int uid2 = 7292;
String actualCredits = "3";
String degreeId = "3";
......@@ -287,7 +287,7 @@ public class 新Qb_兑换流程测试_ExchangeTest extends CheckTemplet {
String qq = "806854056";
String message = "";
//话费兑换, 大富翁app已上架Q币
//话费兑换, uid1 -app已上架Q币
Response response = gawService.qbExchange(uid1,actualCredits,degreeId,appItemId,credits,qq);
response.prettyPrint();
String orderId = response.jsonPath().getString("data.orderId");
......@@ -301,12 +301,12 @@ public class 新Qb_兑换流程测试_ExchangeTest extends CheckTemplet {
logger.info("订单积分:" + orderCredits);
Assert.assertEquals(orderStatus,"consume_success","校验status失败");
Assert.assertEquals(orderappId,"1","校验appId失败");
Assert.assertEquals(orderappId,"22561","校验appId失败");
Assert.assertEquals(orderCredits,"300","校验credits失败");
logger.info("校验Q币用户id1篡改兑换成功");
//Q币兑换,lv测试应用88app未上架Q币
//Q币兑换,lv测试应用88app未入库Q币
try{
Response response2 = gawService.qbExchange(uid2,actualCredits,degreeId,appItemId,credits,qq);
response2.prettyPrint();
......
......@@ -302,7 +302,7 @@ public class 新多档位话费_兑换流程测试_ExchangeTest extends CheckTem
logger.info("校验话费用户id1篡改兑换成功");
//话费兑换,lv测试应用88app未上架话费
//话费兑换,lv测试应用88app未入库话费
try{
Response response2 = gawService.phonebillExchange(uid2,actualCredits,degreeId,appItemId,credits);
response2.prettyPrint();
......
......@@ -346,7 +346,7 @@ public class 新支付宝_兑换流程测试_ExchangeTest extends CheckTemplet {
logger.info(message);
Assert.assertTrue(message.contains("\"success\":false"),"校验message失败");
Assert.assertTrue(message.contains("\"desc\":\"商家未采购商品\""),"校验message失败");
Assert.assertTrue(message.contains("\"desc\":\"商品已下架\""),"校验message失败");
logger.info("校验支付宝用户id2篡改无法兑换成功");
......
......@@ -208,6 +208,7 @@ public class 兑吧老优惠券_兑换流程测试_ExchangeTest extends CheckTem
@Test
public void 优惠券预分配每日限额测试() throws Exception{
int uid = 7447;
//获取当前的时间
Date dNow = new Date();
SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd");
......
......@@ -107,40 +107,32 @@ public class 兑吧老实物_兑换流程测试_ExchangeTest extends CheckTemple
return result;
}
//实物兑换积分不足
//实物兑换积分不足实物兑换积分不足
@Test(description = "实物兑换积分不足")
public void 积分不足() throws Exception {
String message = "";
//活动详情页
Response response = mobileService.detail(authorization.dafuwengLogin(3086), "28515");
Map<String, String> map = authorization.dafuwengLogin(3086);
Assert.assertEquals(String.valueOf(response.getStatusCode()), "200", "活动详情页请求异常");
//实物兑换
//无法兑换,直接抛出
try{
response = couponExchangeService.objectExchange(map, "167141", "28515", "null", "yrJRr7Cddp2YeQd", "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--;
}catch (Exception e){
message = e.toString();
}
logger.info(message);
//校验messaga字段返回值
String message2 = response.jsonPath().getString("data.message");
Assert.assertEquals(message2,"兑换失败,用户积分余额不足","message字段校验失败-期望是积分不足");
Assert.assertTrue(message.contains("\"success\":false"),"校验message失败");
Assert.assertTrue(message.contains("\"message\":\"您的积分不足\""),"校验message失败"); //这个提示很奇怪
logger.info("校验实物兑换积分不足成功");
// authorization.dafuwengLogin(2720,true);
}
//实物兑换限制消费
......
......@@ -35,6 +35,7 @@ public class 自有新优惠券_兑换限制测试_ExchangeTest extends CheckTem
private int uid = 7003;
private String consumerId = "100144145";
private boolean bl=false;
private String url = "http://activity.m.duibatest.com.cn";
......@@ -362,14 +363,13 @@ public class 自有新优惠券_兑换限制测试_ExchangeTest extends CheckTem
@Test
public void 会员等级测试()throws Exception{
String appItemId = "193848";
String message = "";
//会员等级无法兑换
try{
Thread.sleep(4000);
Response response = gawService.couponExchange(authorization.dafuwengLogin(uid), appItemId,45);
Response response = gawService.couponExchange(authorization.dafuwengLogin(uid), appItemId,45,bl);
response.prettyPrint();
}catch (Exception e){
......@@ -379,7 +379,7 @@ public class 自有新优惠券_兑换限制测试_ExchangeTest extends CheckTem
//会员等级可兑换,vip=5
Thread.sleep(4000);
Response response = gawService.couponExchange(authorization.generateSignAutoLogin("3tzVcss7SnAvA5ppT1m1rMPhaBcD",7083,1),appItemId,45);
Response response = gawService.couponExchange(authorization.generateSignAutoLogin("3tzVcss7SnAvA5ppT1m1rMPhaBcD",7083,1),appItemId,45,bl);
response.prettyPrint();
Assert.assertTrue(message.contains("未达到会员等级要求"),"校验message失败");
......@@ -524,7 +524,7 @@ public class 自有新优惠券_兑换限制测试_ExchangeTest extends CheckTem
//优惠券兑换
Thread.sleep(4000);
Response response = gawService.couponExchange(authorization.dafuwengLogin(uid),appItemId,skuId);
Response response = gawService.couponExchange(authorization.dafuwengLogin(uid),appItemId,skuId,bl);
response.prettyPrint();
String orderId = response.jsonPath().getString("data.orderId");
//获取兑换结果
......@@ -656,7 +656,6 @@ public class 自有新优惠券_兑换限制测试_ExchangeTest extends CheckTem
status = response.jsonPath().getString("data.status");
i--;
}
mapStock = jdbc.findSimpleResult("SELECT * FROM stock.tb_stock WHERE stock_id = 1060747299329170094");
String newStock = String.valueOf(mapStock.get("stock"));
String result = String.valueOf(Integer.valueOf(stock)-1);
......
......@@ -44,6 +44,7 @@ public class 自有新卡密_兑换限制测试_ExchangeTest extends CheckTemple
private int uid = 7004;
private String consumerId = "100144146";
private boolean bl=false;
private String url = "http://activity.m.duibatest.com.cn";
......@@ -326,7 +327,7 @@ public class 自有新卡密_兑换限制测试_ExchangeTest extends CheckTemple
//兑换
try{
Thread.sleep(4000);
response = gawService.couponExchange(authorization.dafuwengLogin(uid), appItemId, skuId);
response = gawService.couponExchange(authorization.dafuwengLogin(uid), appItemId, skuId,bl);
}catch (Exception e){
message = e.getMessage();
......@@ -384,7 +385,7 @@ public class 自有新卡密_兑换限制测试_ExchangeTest extends CheckTemple
//会员等级无法兑换
try{
Thread.sleep(4000);
Response response = gawService.couponExchange(authorization.dafuwengLogin(uid), appItemId,86);
Response response = gawService.couponExchange(authorization.dafuwengLogin(uid), appItemId,86,bl);
response.prettyPrint();
}catch (Exception e){
......@@ -394,7 +395,7 @@ public class 自有新卡密_兑换限制测试_ExchangeTest extends CheckTemple
//会员等级可兑换,vip=5
Thread.sleep(4000);
Response response = gawService.couponExchange(authorization.generateSignAutoLogin("3tzVcss7SnAvA5ppT1m1rMPhaBcD",7083,1),appItemId,86);
Response response = gawService.couponExchange(authorization.generateSignAutoLogin("3tzVcss7SnAvA5ppT1m1rMPhaBcD",7083,1),appItemId,86,bl);
response.prettyPrint();
Assert.assertTrue(message.contains("未达到会员等级要求"),"校验message失败");
......
......@@ -71,11 +71,12 @@ public class 自有新实物_兑换流程测试_ExchangeTest extends CheckTemple
String skuId="17";
String actualCredits="1";
String credits="1";
boolean bl=false;
try{
//第一次兑换
Thread.sleep(3000);
Response response = gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits);
Response response = gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits,bl);
String orderId = response.jsonPath().getString("data.orderId");
//获取兑换结果
response = tawService.orderStatus(orderId,uid);
......@@ -99,7 +100,7 @@ public class 自有新实物_兑换流程测试_ExchangeTest extends CheckTemple
//第二次兑换
try{
response = gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits);
response = gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits,bl);
response.prettyPrint();
}catch (Exception e){
......@@ -125,10 +126,12 @@ public class 自有新实物_兑换流程测试_ExchangeTest extends CheckTemple
String skuId="24";
String actualCredits="2";
String credits="2";
boolean bl=false;
try{
//第一次兑换
Thread.sleep(3000);
Response response = gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits);
Response response = gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits,bl);
logger.info("********1"+"111111");
String orderId = response.jsonPath().getString("data.orderId");
//获取兑换结果
......@@ -152,7 +155,7 @@ public class 自有新实物_兑换流程测试_ExchangeTest extends CheckTemple
//第二次兑换
try{
response = gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits);
response = gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits,bl);
logger.info("********2");
response.prettyPrint();
......@@ -181,10 +184,12 @@ public class 自有新实物_兑换流程测试_ExchangeTest extends CheckTemple
String skuId="25";
String actualCredits="3";
String credits="3";
boolean bl=false;
try{
//第一次兑换
Thread.sleep(3000);
Response response = gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits);
Response response = gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits,bl);
String orderId = response.jsonPath().getString("data.orderId");
//获取兑换结果
response = tawService.orderStatus(orderId,uid);
......@@ -206,7 +211,8 @@ public class 自有新实物_兑换流程测试_ExchangeTest extends CheckTemple
// logger.info("商品兑换按钮:" + exchangeText);
//第二次兑换
try{
response = gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits);
response = gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits,bl
);
response.prettyPrint();
}catch (Exception e){
......@@ -233,10 +239,13 @@ public class 自有新实物_兑换流程测试_ExchangeTest extends CheckTemple
String skuId="26";
String actualCredits="5";
String credits="5";
boolean bl=false;
try{
//第一次兑换
Thread.sleep(3000);
Response response = gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits);
Response response = gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits,bl
);
String orderId = response.jsonPath().getString("data.orderId");
//获取兑换结果
response = tawService.orderStatus(orderId,uid);
......@@ -258,7 +267,8 @@ public class 自有新实物_兑换流程测试_ExchangeTest extends CheckTemple
// logger.info("商品兑换按钮:" + exchangeText);
//第二次兑换
try{
response = gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits);
response = gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits,bl
);
response.prettyPrint();
}catch (Exception e){
......@@ -336,6 +346,8 @@ public class 自有新实物_兑换流程测试_ExchangeTest extends CheckTemple
String skuId="33";
String actualCredits="8";
String credits="8";
boolean bl=false;
jdbc.update("UPDATE stock.tb_stock set stock = 0 where stock_id = 940298957084170033");
Thread.sleep(1000);
......@@ -347,7 +359,7 @@ public class 自有新实物_兑换流程测试_ExchangeTest extends CheckTemple
try{
Thread.sleep(3000);
Response response = gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits);
Response response = gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits,bl);
response.prettyPrint();
}catch (Exception e){
......@@ -448,10 +460,10 @@ public class 自有新实物_兑换流程测试_ExchangeTest extends CheckTemple
String appItemId = "197041";
String itemId = null ;
String skuId = "159";
boolean bl=false;
//实物兑换,积分传0
Response response =gawService.objectExchange(uid,appItemId,itemId,skuId,"0","0");
Response response =gawService.objectExchange(uid,appItemId,itemId,skuId,"0","0",bl);
response.prettyPrint();
String orderId = response.jsonPath().getString("data.orderId");
......@@ -506,6 +518,8 @@ public class 自有新实物_兑换流程测试_ExchangeTest extends CheckTemple
String skuId = "183";
String credits = "10";
String actualCredits = "10";
boolean bl=false;
//查询兑换前的库存
//stock_id 通过表tb_app_item_sku 来查询
......@@ -513,7 +527,7 @@ public class 自有新实物_兑换流程测试_ExchangeTest extends CheckTemple
String stock = String.valueOf(mapStock.get("stock"));
logger.info("兑换前的库存:" + stock);
Response response = gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits);
Response response = gawService.objectExchange(uid,appItemId,itemId,skuId,credits,actualCredits,bl);
String orderId = response.jsonPath().getString("data.orderId");
//获取兑换结果
response = tawService.orderStatus(orderId,uid);
......
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元");
}
@Test(description = "用户提现失败测试:提现次数不足")
public void 提现次数不足() throws Exception{
int uid = 7455;
String activityId = "3";
String money = "1";
String account = "lvwenyan@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("校验成功:提现次数不足无法提现");
}
}
......@@ -44,6 +44,7 @@ public class 权益一期线上用户核销中匹配兑换码兑换_DuibaTest ex
Response response = equityPrizeService.exchange(authorization.dafuwengLogin(uid), exc_code, null);
Thread.sleep(2000);
Map<String, Object> ChangeStock = jdbc.findSimpleResult("SELECT * FROM stock.tb_stock WHERE stock_id =1173112680215170105");
String exchanggeStock = String.valueOf(ChangeStock.get("stock"));
......@@ -66,11 +67,13 @@ public class 权益一期线上用户核销中匹配兑换码兑换_DuibaTest ex
throw new Exception("异常信息打印:" + e);
}
}finally {
jdbc.update("update goods.tb_equity_goods_record set consumer_id=null ,partner_user_id=null" +
" ,app_item_id=null ,verification_time=null ,order_num=null where exc_code = '"+exc_code+"'");
}
}
@Test
// +(invocationCount=5)
public void 兑换的权益码不存在() throws Exception {
......@@ -266,6 +269,7 @@ public class 权益一期线上用户核销中匹配兑换码兑换_DuibaTest ex
//第一次核销
logger.info("用户第一次核销");
Response response = equityPrizeService.exchange(authorization.dafuwengLogin(uid), exc_code, null);
Thread.sleep(2000);
Map<String, Object> ChangeStock = jdbc.findSimpleResult("SELECT * FROM stock.tb_stock WHERE stock_id =1178701910023420109");
//第一次兑换之后的商品的库存成功
String exchanggeStock = String.valueOf(ChangeStock.get("stock"));
......@@ -284,7 +288,9 @@ public class 权益一期线上用户核销中匹配兑换码兑换_DuibaTest ex
logger.info("进行第二次核销");
response = equityPrizeService.exchange(authorization.dafuwengLogin(uid), exc_code1, null);
Thread.sleep(2000);
ChangeStock = jdbc.findSimpleResult("SELECT * FROM stock.tb_stock WHERE stock_id =1178701910023420109");
exchanggeStock = String.valueOf(ChangeStock.get("stock"));
//response.prettyPrint();
//获取到 code 数据
......@@ -315,7 +321,7 @@ public class 权益一期线上用户核销中匹配兑换码兑换_DuibaTest ex
throw new Exception("异常信息打印:" + e);
}
}finally {
jdbc.update("update goods.tb_equity_goods_record set consumer_id=null ,partner_user_id=null" +
" ,app_item_id=null ,verification_time=null ,order_num=null where exc_code = '"+exc_code+"'");
jdbc.update("update goods.tb_equity_goods_record set consumer_id=null ,partner_user_id=null" +
......@@ -323,5 +329,7 @@ public class 权益一期线上用户核销中匹配兑换码兑换_DuibaTest ex
jdbc.update("DELETE FROM goods.tb_everyday_limit where app_item_id ='199280 '");
}
}
}
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;
}
}
package http.service.Activity;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import http.service.Authorization;
import io.restassured.http.Cookies;
import io.restassured.response.Response;
......@@ -7,10 +9,11 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.testng.Assert;
import org.testng.annotations.Test;
import java.util.HashMap;
import java.util.Map;
import java.util.*;
import static base.Postman.logger;
import static io.restassured.RestAssured.given;
@Service
......@@ -22,6 +25,7 @@ public class equityPrizeService {
/**
* 核销一期 /aaw/equityPrize/exchange
* 匹配兑换码兑换 一期-线上核销
* Request Method: POST
*
* @param excCode 兑换码
......@@ -46,6 +50,108 @@ public class equityPrizeService {
return response;
}
/**
* 核销二期匹配 权益及兑换码兑换-线上核销
* 权益商品列表
* /chw//chw/visual-editor/equityGoodsList
* Request Method: GET
*
* @param equityId 权益id
* @return
* @throws Exception
*/
public Response chwequityGoodsList(Map cookies, String equityId) throws Exception {
Response response = given().cookies(cookies).get(activityHost + "/chw/visual-editor/equityGoodsList?equityId="+equityId);
try {
// Assert.assertEquals(response.jsonPath().getString("success"), "true", "/aaw/equityPrize/exchange接口失败");
Assert.assertEquals(String.valueOf(response.getStatusCode()), "200", "/chw//chw/visual-editor/equityGoodsList接口失败");
} catch (Exception e) {
throw new Exception("/chw/visual-editor/equityGoodsList接口失败,返回信息:" + response.asString());
} catch (Error er) {
throw new Exception("/chw/visual-editor/equityGoodsList接口失败,返回信息:" + response.asString());
}
return response;
}
@Test
/*
*q权益二期匹配 权益及兑换码兑换-线上核销
* 商品兑换首页
* /gaw/equityPrize/index
* * Request Method: post
* equityId 权益id , appitemid 商品id , appSkuid
* */
public Response gawequityPrizeindex( Map cookies,String equityId ,String appItemId ,String appSkuId) throws Exception {
logger.info(activityHost + "/gaw/equityPrize/index?equityId="+equityId+"&appItemId="+appItemId+"&appSkuId="+appSkuId);
Response response = given().cookies(cookies).get(activityHost + "/gaw/equityPrize/index?equityId="+equityId+"&appItemId="+appItemId+"&appSkuId="+appSkuId);
try {
Assert.assertEquals(String.valueOf(response.getStatusCode()), "200", "/gaw/equityPrize/index接口失败");
} catch (Exception e) {
throw new Exception("/gaw/equityPrize/index接口失败,返回信息:" + response.asString());
} catch (Error er) {
throw new Exception("/gaw/equityPrize/index接口失败,返回信息:" + response.asString());
}
return response;
}
/*
* 权益核销【匹配 权益及兑换码兑换-线上核销】
* 权益兑换接口sku /gaw/equityPrize/exchange
*
* */
public Response gawequityPrizeexchange( Map cookies,String excCode,String appItemId,
String equityId,String appSkuId) throws Exception {
Map<String, String> map = new HashMap<>();
map.put("excCode", excCode);
map.put("appItemId", appItemId);
map.put("equityId", equityId);
map.put("appSkuId", appSkuId);
map.put("validate", "undefined");
//token 代码中写死的测试token
map.put("token", "yrJRr7Cddp2YeQd");
Response response = given().cookies(cookies).params(map).post(activityHost + "/gaw/equityPrize/exchange");
try {
Assert.assertEquals(String.valueOf(response.getStatusCode()), "200", "/gaw/equityPrize/exchange接口失败");
} catch (Exception e) {
throw new Exception("/gaw/equityPrize/exchange接口失败,返回信息:" + response.asString());
} catch (Error er) {
throw new Exception("/gaw/equityPrize/exchange接口失败,返回信息:" + response.asString());
}
return response;
}
/*
* 权益核销【匹配 权益及兑换码兑换-线上核销】
* 权益列表 /chw/visual-editor/findEquityListByIds
*
* */
public Response chwvisualeditorfindEquityListByIds(Map cookies, List<Integer> array) throws Exception {
// JSONObject json = new JSONObject();
// json.put("equityIds", array);
Map<String, List<Integer>> map = new HashMap<>();
map.put("equityIds", array);
Response response = given().contentType("application/json;charset=UTF-8").cookies(cookies).body(map).post(activityHost + "/chw/visual-editor/findEquityListByIds");
//Response response = given().contentType("application/json;charset=UTF-8").body("{\"equityIds\":[25,24]}").cookies(cookies).post(activityHost + "/chw/visual-editor/findEquityListByIds");
try {
Assert.assertEquals(String.valueOf(response.getStatusCode()), "200", " /chw/visual-editor/findEquityListByIds接口失败");
} catch (Exception e) {
throw new Exception("/gaw/equityPrize/exchange接口失败,返回信息:" + response.asString());
} catch (Error er) {
throw new Exception("/gaw/equityPrize/exchange接口失败,返回信息:" + response.asString());
}
return response;
}
}
\ No newline at end of file
......@@ -125,7 +125,7 @@ public class gawService {
//普通自有新实物兑换接口
public Response objectExchange(int uid, String appItemId,String itemId,String skuId,String credits,String actualCredits ) throws Exception {
public Response objectExchange(int uid, String appItemId,String itemId,String skuId,String credits,String actualCredits,boolean bl ) throws Exception {
Map<String,Object> map = new HashMap<>();
Map<String,Object> mapList = new HashMap<>();
......@@ -147,6 +147,7 @@ public class gawService {
map.put("expressPrice","0");
map.put("validate","");
map.put("token","yrJRr7Cddp2YeQd");
map.put("vipFlag",bl);
JSONObject jsonParam = JSONObject.parseObject(JSON.toJSONString(map));
......@@ -227,6 +228,51 @@ public class gawService {
// Response saveResponse = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.dafuwengLogin(uid)).params(map).post("http://"+goodsHost+"/gaw/objectExchange/create");
// response.prettyPrint();
try{
Assert.assertEquals(response.jsonPath().getString("success"),"true");
}catch(Exception e){
throw new Exception("/gaw/objectExchange/create接口返回异常,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/gaw/objectExchange/create接口返回异常,返回信息:"+response.asString());
}
return response;
}
//会员商品优惠券兑换接口
public Response couponExchange2(int uid, String appItemId,String credits,String actualCredits, int skuId,boolean bl) throws Exception {
Map<String,Object> map = new HashMap<>();
Map<String,Object> mapList = new HashMap<>();
List<Map> list = new ArrayList<>();
mapList.put("skuId",skuId);
mapList.put("appItemId",appItemId);
mapList.put("credits",credits);
mapList.put("price",0);
list.add(mapList);
map.put("remark",""); //买家留言
map.put("degreeId","");
map.put("actualPrice","0"); //总金额
map.put("actualCredits",actualCredits); //总积分
map.put("itemParam",list.toArray());
map.put("payType","3");
map.put("expressPrice","0");
map.put("validate","");
map.put("token","yrJRr7Cddp2YeQd");
map.put("vipFlag",bl);
JSONObject jsonParam = JSONObject.parseObject(JSON.toJSONString(map));
logger.info("请求优惠券兑换接口:"+ "/gaw/couponExchange/create");
Response response = given().contentType("application/json; charset=UTF-8").cookies(authorization.dafuwengLogin(uid)).body(jsonParam).post("http://"+goodsHost+"/gaw/couponExchange/create");
// Response saveResponse = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.dafuwengLogin(uid)).params(map).post("http://"+goodsHost+"/gaw/objectExchange/create");
// response.prettyPrint();
try{
......@@ -284,7 +330,7 @@ public class gawService {
}
//优惠券兑换接口
public Response couponExchange(Map cookie, String appItemId,int skuId) throws Exception {
public Response couponExchange(Map cookie, String appItemId,int skuId,boolean bl) throws Exception {
Map<String,Object> map = new HashMap<>();
Map<String,Object> mapList = new HashMap<>();
......@@ -305,6 +351,7 @@ public class gawService {
map.put("expressPrice","0");
map.put("validate","");
map.put("token","yrJRr7Cddp2YeQd");
map.put("vipFlag",bl);
JSONObject jsonParam = JSONObject.parseObject(JSON.toJSONString(map));
......@@ -555,7 +602,7 @@ public class gawService {
logger.info("请求Qb兑换接口:"+ "/gaw/qbExchange/create");
Response response = given().contentType("application/json; charset=UTF-8").cookies(authorization.dafuwengLogin(uid)).body(jsonParam).post("http://"+goodsHost+"/gaw/qbExchange/create");
response.prettyPrint();
try{
Assert.assertEquals(response.jsonPath().getString("success"),"true");
......
......@@ -74,7 +74,7 @@ public class testservice extends AbstractTestNGSpringContextTestsDuiba {
Thread.sleep(3000);
Response response = gawService.objectExchange(1,appItemId,itemId,skuId,credits,actualCredits);
Response response = gawService.objectExchange(1,appItemId,itemId,skuId,credits,actualCredits,false);
response.prettyPrint();
//(enabled=true, dataProvider="testdp", threadPoolSize=1, invocationCount=2)
......
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