Commit c8eddab0 authored by 吕雯燕's avatar 吕雯燕

lv

parent ab3eba78
package http.cases.ClcardTest;
import base.DuibaTestBase;
import http.service.Activity.ClcardService;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import java.sql.SQLException;
import java.util.Map;
public class 集卡活动领奖_AccessTest extends DuibaTestBase {
@Autowired
ClcardService clcardService;
@BeforeMethod
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");
} catch (SQLException e) {
e.printStackTrace();
}
}
@Test(description = "集卡活动领奖支付宝测试")
public void 集卡领奖成功() throws Exception{
int uid = 7402;
String activityId = "45501";
//集卡领奖
Response openPrizeResponse = clcardService.openPrize(uid,activityId);
openPrizeResponse.prettyPrint();
String desc = openPrizeResponse.jsonPath().getString("desc");
//活动首页信息
Response response = clcardService.activity(uid,activityId);
response.prettyPrint();
String cards0 = response.jsonPath().getString("data.cards[0].count");
String cards1 = response.jsonPath().getString("data.cards[1].count");
String cards2 = response.jsonPath().getString("data.cards[2].count");
String rules0 = response.jsonPath().getString("data.prizes[0].rules[0].cardCount");
String rules1 = response.jsonPath().getString("data.prizes[0].rules[1].cardCount");
String rules2 = response.jsonPath().getString("data.prizes[0].rules[2].cardCount");
Assert.assertEquals(desc,"OK","校验desc失败");
Assert.assertEquals(cards0,"0","校验card0失败");
Assert.assertEquals(cards1,"0","校验card1失败");
Assert.assertEquals(cards2,"1","校验card2失败");
Assert.assertEquals(rules0,"1","校验rules0失败");
Assert.assertEquals(rules1,"2","校验rules1失败");
Assert.assertEquals(rules2,"3","校验rules2失败");
logger.info("集卡活动领奖成功");
}
}
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/11/27
*/
@Service
public class ClcardService {
@Value("${activity.host}")
String activityHost;
@Autowired
Authorization authorization;
private DuibaLog logger = DuibaLog.getLogger();
/**
* @param activityId 活动id
* @param uid 用户id
* @return
* @throws Exception
*/
public Response openPrize(int uid,String activityId) throws Exception{
Map<String,String> map = new HashMap<>();
map.put("id",activityId);
map.put("grade","1");
map.put("preview","false");
logger.info("请求/hdtool/clcard/openPrize接口");
Response response = given().cookies(authorization.dafuwengLogin(uid)).params(map).post(activityHost+"/hdtool/clcard/openPrize");
try {
Assert.assertEquals(response.jsonPath().getString("success"), "true", "/hdtool/clcard/openPrize接口失败");
} catch (Exception e) {
throw new Exception("/hdtool/clcard/openPrize接口失败,返回信息:" + response.asString());
} catch (Error er) {
throw new Exception("/hdtool/clcard/openPrize接口失败,返回信息:" + response.asString());
}
return response;
}
/**
* @param activityId 活动id
* @param uid 用户id
* @return
* @throws Exception
*/
public Response activity(int uid,String activityId) throws Exception{
Map<String,String> map = new HashMap<>();
map.put("id",activityId);
logger.info("请求/hdtool/clcard/activity接口");
Response response = given().cookies(authorization.dafuwengLogin(uid)).params(map).get(activityHost+"/hdtool/clcard/activity");
try {
Assert.assertEquals(response.jsonPath().getString("success"), "true", "/hdtool/clcard/activity接口失败");
} catch (Exception e) {
throw new Exception("/hdtool/clcard/activity接口失败,返回信息:" + response.asString());
} catch (Error er) {
throw new Exception("/hdtool/clcard/activity接口失败,返回信息:" + response.asString());
}
return response;
}
}
package http.service.Activity;
import base.DuibaLog;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import http.service.Authorization;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -10,13 +8,10 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.testng.Assert;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static io.restassured.RestAssured.given;
import static io.restassured.RestAssured.trustStore;
/**
* Created by lvwenyan on 2019/11/23
......
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