Commit 4010541c authored by 吕雯燕's avatar 吕雯燕

lv

parent 29127928
package http.cases.NewActivityTest;
import base.DuibaTestBase;
import http.service.Manager.AdminNewDuibaHdtoolService;
import http.service.Activity.NewActivityService;
import org.apache.bcel.generic.NEW;
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 兑吧活动工具_新商品_DuibaTest extends DuibaTestBase {
@Autowired
AdminNewDuibaHdtoolService adminNewDuibaHdtoolService;
@Autowired
NewActivityService newActivityService;
@Test(description = "兑吧活动工具添加新实物")
public void 添加新实物奖品() throws Exception{
String type = "object";
String name = "兑吧新实物活动专用";
Response response = adminNewDuibaHdtoolService.ajaxFindItemByName(type,name);
response.prettyPrint();
Assert.assertEquals(response.jsonPath().getString("list[0].appItemId"),"32604","校验appItmId失败");
Assert.assertEquals(response.jsonPath().getString("list[0].title"),"兑吧新实物活动专用","校验title失败");
logger.info("校验兑吧活动工具添加新实物奖品成功");
}
@Test(description = "兑吧活动工具中奖新实物")
public void 中奖新实物奖品() throws Exception{
String activityId = "43752";
String token = "ulxn1sd";
int uid = 7126;
Response response = newActivityService.doJoin2(uid,activityId,token);
response.prettyPrint();
String orderId = response.jsonPath().getString("orderId");
response = newActivityService.getOrderStatus2(uid,orderId);
response.prettyPrint();
String result = String.valueOf(response.jsonPath().getString("result"));
int i= 30;
while(i>0&&(result.equals("0"))){
Thread.sleep(1000);
response = newActivityService.getOrderStatus2(uid,orderId);
result = String.valueOf(response.jsonPath().getString("result"));
i--;
response.prettyPrint();
}
Assert.assertEquals(response.jsonPath().getString("lottery.id"),"28244","校验奖品id失败");
Assert.assertEquals(response.jsonPath().getString("lottery.title"),"兑吧新实物","校验奖品title失败");
logger.info("校验兑吧活动工具中奖新实物成功");
}
}
package http.cases.NewActivityTest;
import base.DuibaTestBase;
import http.service.Authorization;
import http.service.hd.LaunchService;
import http.service.Activity.NewActivityService;
import org.apache.bcel.generic.NEW;
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.Map;
/**
* Created by lvwenyan on 2019/4/4.
*/
public class 自有活动工具_新商品_DuibaTest extends DuibaTestBase {
@Autowired
LaunchService launchService;
@Autowired
Authorization authorization;
@Autowired
NewActivityService newActivityService;
int uid = 7126;
@Test(description = "自有活动工具添加新实物奖品")
public void 添加新实物奖品() throws Exception{
Map cookies = authorization.hdLoginCommonNew("15855555555");
String type = "object";
String name = "自有实物活动专用";
String appId = "22561";
Response response = launchService.findItemBySearch(cookies,type,name,appId);
response.prettyPrint();
Assert.assertEquals(response.jsonPath().getString("data.list[0].appItemId"),"195020","校验appItemId失败");
Assert.assertEquals(response.jsonPath().getString("data.list[0].title"),"【自动化勿动】自有实物活动专用","校验title失败");
logger.info("校验自有活动工具添加新实物成功");
}
@Test(description = "自有活动工具中奖新实物")
public void 中奖新实物() throws Exception{
String activityId = "43753";
String token = "ulxn1sd";
Response response = newActivityService.doJoin2(uid,activityId,token);
response.prettyPrint();
String orderId = response.jsonPath().getString("orderId");
response = newActivityService.getOrderStatus2(uid,orderId);
response.prettyPrint();
String result = String.valueOf(response.jsonPath().getString("result"));
int i= 30;
while(i>0&&(result.equals("0"))){
Thread.sleep(1000);
response = newActivityService.getOrderStatus2(uid,orderId);
result = String.valueOf(response.jsonPath().getString("result"));
i--;
response.prettyPrint();
}
Assert.assertEquals(response.jsonPath().getString("lottery.id"),"31650","校验奖品id失败");
Assert.assertEquals(response.jsonPath().getString("lottery.title"),"新实物","校验奖品title失败");
logger.info("校验自有活动工具中奖新实物成功");
}
@Test(description = "添加下架的实物奖品")
public void 添加下架的实物奖品() throws Exception{
Map cookies = authorization.hdLoginCommonNew("15855555555");
String type = "object";
String name = "自有实物下架活动专用";
String appId = "22561";
String activityId = "43754";
String token = "h5wn0epv";
//添加奖品
Response findResponse = launchService.findItemBySearch(cookies,type,name,appId);
findResponse.prettyPrint();
Assert.assertEquals(findResponse.jsonPath().getString("data.list[0].appItemId"),"195024","校验appItemId失败");
Assert.assertEquals(findResponse.jsonPath().getString("data.list[0].title"),"【自动化勿动】自有实物下架活动专用","校验title失败");
logger.info("校验自有活动工具添加下架实物成功");
//抽奖
Response response = newActivityService.doJoin2(uid,activityId,token);
// response.prettyPrint();
String orderId = response.jsonPath().getString("orderId");
response = newActivityService.getOrderStatus2(uid,orderId);
response.prettyPrint();
String result = String.valueOf(response.jsonPath().getString("result"));
int i= 30;
while(i>0&&(result.equals("0"))){
Thread.sleep(1000);
response = newActivityService.getOrderStatus2(uid,orderId);
result = String.valueOf(response.jsonPath().getString("result"));
i--;
response.prettyPrint();
}
Assert.assertEquals(response.jsonPath().getString("lottery.id"),"31654","校验奖品id失败");
Assert.assertEquals(response.jsonPath().getString("lottery.title"),"下架实物","校验奖品title失败");
logger.info("校验自有活动工具中奖下架实物成功");
}
}
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 AdminNewDuibaHdtoolService {
@Value("${manager.host}")
String ManagerHost;
@Autowired
Authorization authorization;
private DuibaLog logger = DuibaLog.getLogger();
//单品抽奖添加奖品
public Response ajaxFindItemByName(String type, String name) throws Exception {
String url = ManagerHost + "/AdminNewDuibaHdtool/ajaxFindItemByName";
Map<String, String> map = new HashMap<>();
map.put("type", type);
map.put("name", name);
Response response = given().contentType("application/json;charset=UTF-8").cookies(authorization.ssoLogin()).params(map).get("http://" + url);
try {
Assert.assertEquals(response.jsonPath().getString("success"), "true", "/AdminNewDuibaHdtool/ajaxFindItemByName接口失败");
} catch (Exception e) {
throw new Exception("/AdminNewDuibaHdtool/ajaxFindItemByName接口失败,返回信息:" + response.asString());
} catch (Error er) {
throw new Exception("/AdminNewDuibaHdtool/ajaxFindItemByName接口失败,返回信息:" + response.asString());
}
return response;
}
}
......@@ -68,4 +68,25 @@ public class LaunchService {
return response;
}
//选择奖品
public Response findItemBySearch(Map cookies, String type, String name, String appId) throws Exception{
String url = hdHost + "/launch/findItemBySearch";
Map<String,String> map = new HashMap<>();
map.put("type",type);
map.put("name",name);
map.put("appId",appId);
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(cookies).params(map).post("http://"+url);
try{
Assert.assertEquals(response.jsonPath().getString("desc"),"成功");
}catch(Exception e){
throw new Exception("请求/launch/findItemBySearch接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("请求/launch/findItemBySearch接口失败,返回信息:"+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