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

lv

parent b565ebab
......@@ -258,4 +258,6 @@ public class SingleLottery_AccessTest extends DuibaTestBase {
}
}
\ No newline at end of file
package http.cases.SingleLotteryTest;
import base.DuibaTestBase;
import http.service.Activity.SingleLotteryService;
import http.service.Manager.AdminDuibaSingleLotteryService;
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.DataProvider;
import org.testng.annotations.Test;
/**
* Created by lvwenyan on 2019/4/4.
*/
public class 兑吧单品抽奖_新商品_AccessTest extends DuibaTestBase {
@Autowired
SingleLotteryService singleLotteryService;
@Autowired
AdminDuibaSingleLotteryService adminDuibaSingleLotteryService;
int uid = 7126;
@Test(description = "添加新商品作为奖品")
public void 选择主奖品为新实物() throws Exception{
String itemId = "32604";
Response response = adminDuibaSingleLotteryService.ajaxFindItemById(itemId);
response.prettyPrint();
String id = response.jsonPath().getString("item.id");
String name = response.jsonPath().getString("item.name");
Assert.assertEquals(id,"32604","校验商品id失败");
Assert.assertEquals(name,"【自动化勿动】兑吧新实物活动专用","校验商品名称失败");
logger.info("校验单品抽奖添加新实物成功");
}
@Test(description = "单品抽奖中奖新实物")
public void 中奖新实物() throws Exception{
String activityId = "43725";
String token = "ix18rh";
Response response =singleLotteryService.doJoin(uid,activityId,activityId,token);
response.prettyPrint();
String id =MatcherString.getString(response.asString(), "singleLotteryOrderId\":(.*?),", 1);
response = singleLotteryService.getOrderStatus(uid,id,"");
int i = 10;
while ("处理中".equals(response.jsonPath().getString("message")) && i > 0) {
Thread.sleep(500);
response = singleLotteryService.getOrderStatus(uid,id,"");
i--;
}
String descrption = response.jsonPath().getString("descrption");
String itemId = response.jsonPath().getString("itemId");
String lotteryType = response.jsonPath().getString("lotteryType");
Assert.assertEquals(descrption,"【自动化勿动】兑吧新实物活动专用","校验descrption失败");
Assert.assertEquals(itemId,"32604","校验itemid失败");
Assert.assertEquals(lotteryType,"object","校验lotteryType失败");
logger.info("校验单品抽奖中奖新实物成功");
}
}
package http.cases.SingleLotteryTest;
import base.DuibaTestBase;
import http.service.Activity.SingleLotteryService;
import http.service.Authorization;
import http.service.hd.AppSingleLotteryService;
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.DataProvider;
import org.testng.annotations.Test;
import java.util.HashMap;
import java.util.Map;
/**
* Created by lvwenyan on 2019/4/4.
*/
public class 自有单品抽奖_新商品_AccessTest extends DuibaTestBase {
@Autowired
SingleLotteryService singleLotteryService;
@Autowired
AppSingleLotteryService appSingleLotteryService;
@Autowired
Authorization authorization;
int uid = 7126;
@Test(description = "自有单品抽奖添加新实物商品")
public void 添加新实物奖品() throws Exception{
String appId = "22561";
String appItemId = "195020";
Map cookies = authorization.hdLoginCommonNew("15855555555");
Response response = appSingleLotteryService.ajaxFindAppItemById(cookies,appId,appItemId);
response.prettyPrint();
Assert.assertEquals(response.jsonPath().getString("data.appItemId"),appItemId,"校验appItemId失败");
Assert.assertEquals(response.jsonPath().getString("desc"),"成功","校验desc失败");
logger.info("校验自有单品抽奖添加新实物成功");
}
@Test(description = "自有单品抽奖中奖新实物")
public void 中奖新实物() throws Exception{
String activityId = "43751";
String token = "6xgees";
Response response =singleLotteryService.doJoin(uid,activityId,activityId,token);
response.prettyPrint();
String id =MatcherString.getString(response.asString(), "singleLotteryOrderId\":(.*?),", 1);
response = singleLotteryService.getOrderStatus(uid,id,"");
int i = 10;
while ("处理中".equals(response.jsonPath().getString("message")) && i > 0) {
Thread.sleep(500);
response = singleLotteryService.getOrderStatus(uid,id,"");
i--;
}
String descrption = response.jsonPath().getString("descrption");
String appItemId = response.jsonPath().getString("appItemId");
String lotteryType = response.jsonPath().getString("lotteryType");
Assert.assertEquals(descrption,"【自动化勿动】自有实物活动专用","校验descrption失败");
Assert.assertEquals(appItemId,"195020","校验itemid失败");
Assert.assertEquals(lotteryType,"object","校验lotteryType失败");
logger.info("校验自有单品抽奖中奖新实物成功");
}
}
......@@ -144,7 +144,7 @@ public class SingleLotteryService {
//获取单品抽奖信息
public Response AdminDuibaSingleLottery(String actId) throws Exception {
String url = ManagerHost + "/AdminDuibaSingleLottery/edit/"+actId;
String url = ManagerHost + "/AdminDuibaSingleLotteryService/edit/"+actId;
logger.info("请求兑吧管理后台余额url:" + url);
Response response = given().cookies(authorization.ssoLogin()).get("http://" + url);
......@@ -152,16 +152,16 @@ public class SingleLotteryService {
try {
Assert.assertEquals(String.valueOf(response.getStatusCode()), "200", "管理后台兑换项请求异常");
} catch (Exception e) {
throw new Exception("/AdminDuibaSingleLottery/edit/接口失败,返回信息:" + response.asString());
throw new Exception("/AdminDuibaSingleLotteryService/edit/接口失败,返回信息:" + response.asString());
} catch (Error er) {
throw new Exception("/AdminDuibaSingleLottery/edit/接口失败,返回信息:" + response.asString());
throw new Exception("/AdminDuibaSingleLotteryService/edit/接口失败,返回信息:" + response.asString());
}
return response;
}
//兑吧管理后台创建单品抽奖活动
public void SingleLottery_create(String title, Map<String,String> incite) throws Exception {
String saveUrl = ManagerHost+"/AdminDuibaSingleLottery/create";
String saveUrl = ManagerHost+"/AdminDuibaSingleLotteryService/create";
Map<String,String> map = new HashMap<>();
map.put("title",title);
......@@ -202,7 +202,7 @@ public class SingleLotteryService {
//兑吧管理后台单品抽奖列表页
public Response manager_index() throws Exception {
String url = ManagerHost+"/AdminDuibaSingleLottery/index";
String url = ManagerHost+"/AdminDuibaSingleLotteryService/index";
Response response=given().cookies(authorization.ssoLogin()).get("http://"+url);
//Response.prettyPrint();
......@@ -218,7 +218,7 @@ public class SingleLotteryService {
//兑吧管理后台开启单品抽奖活动 1-开启且可见
public void changeStatus(String atcId,String val) throws Exception {
String url = ManagerHost+"/AdminDuibaSingleLottery/changeStatus";
String url = ManagerHost+"/AdminDuibaSingleLotteryService/changeStatus";
Map<String,String> map = new HashMap<>();
map.put("id",atcId);
......@@ -228,26 +228,26 @@ public class SingleLotteryService {
Response response = given().cookies(authorization.ssoLogin()).params(map).post("http://" + url);
try{
Assert.assertEquals(response.jsonPath().getString("success"), "true", "/AdminDuibaSingleLottery/changeStatus接口失败");
Assert.assertEquals(response.jsonPath().getString("success"), "true", "/AdminDuibaSingleLotteryService/changeStatus接口失败");
}catch(Exception e){
throw new Exception("/AdminDuibaSingleLottery/changeStatus接口失败,返回信息:"+response.asString());
throw new Exception("/AdminDuibaSingleLotteryService/changeStatus接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/AdminDuibaSingleLottery/changeStatus接口失败,返回信息:"+response.asString());
throw new Exception("/AdminDuibaSingleLotteryService/changeStatus接口失败,返回信息:"+response.asString());
}
}
//兑吧管理后台删除活动
public void delete(String atcId) throws Exception {
String url = ManagerHost+"/AdminDuibaSingleLottery/delete/"+atcId;
String url = ManagerHost+"/AdminDuibaSingleLotteryService/delete/"+atcId;
Response response = given().cookies(authorization.ssoLogin()).post("http://" + url);
try{
Assert.assertEquals(response.jsonPath().getString("success"), "true", "/AdminDuibaSingleLottery/delete/接口失败");
Assert.assertEquals(response.jsonPath().getString("success"), "true", "/AdminDuibaSingleLotteryService/delete/接口失败");
}catch(Exception e){
throw new Exception("/AdminDuibaSingleLottery/delete/接口失败,返回信息:"+response.asString());
throw new Exception("/AdminDuibaSingleLotteryService/delete/接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/AdminDuibaSingleLottery/delete/接口失败,返回信息:"+response.asString());
throw new Exception("/AdminDuibaSingleLotteryService/delete/接口失败,返回信息:"+response.asString());
}
}
}
\ No newline at end of file
package http.service.Manager;
import base.DuibaLog;
import cn.com.duiba.activity.center.api.dto.activity.CLRewardDto;
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;
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;
/**
* Created by lvwenyan on 2019/4/4.
*/
@Service
public class AdminDuibaSingleLotteryService {
@Value("${manager.host}")
String ManagerHost; //ManagerHost = mng.duibatest.com.cn
@Autowired
Authorization authorization;
private DuibaLog logger = DuibaLog.getLogger();
//单品抽奖添加奖品
public Response ajaxFindItemById(String itemId) throws Exception{
String url = ManagerHost + "/AdminDuibaSingleLottery/ajaxFindItemById";
Map<String,String> map = new HashMap<>();
map.put("itemId",itemId);
Response response = given().contentType("text/html;charset=UTF-8").cookies(authorization.ssoLogin()).params(map).get("http://"+url);
// response.prettyPrint();
return response;
}
}
package http.service.hd;
import base.DuibaLog;
import io.restassured.response.Response;
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/4/4
*/
@Service
public class AppSingleLotteryService {
@Value("${hdserver.host}")
String hdserverHost;
public Response ajaxFindAppItemById(Map cookies, String appId, String appItemId) throws Exception{
String url = hdserverHost + "/appSingleLottery/ajaxFindAppItemById";
Map<String,String> map = new HashMap<>();
map.put("appId",appId);
map.put("appItemId",appItemId);
Response response = given().contentType("application/json;charset=UTF-8").cookies(cookies).params(map).get("http://"+ url);
try{
Assert.assertEquals(response.jsonPath().getString("success"),"true");
}catch(Exception e){
throw new Exception("/appSingleLottery/ajaxFindAppItemById接口失败,返回信息:" + response.asString());
}catch(Error er){
throw new Exception("/appSingleLottery/ajaxFindAppItemById接口失败,返回信息:" + 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