Commit ef6afeaf authored by 赵然's avatar 赵然

zr

parent a94d0f69
......@@ -405,7 +405,7 @@ public class Authorization {
Map<String, String> paras = new HashMap<>();
paras.put("email", ssoName);
paras.put("password", ssoPassword);
// paras.put("loginTimeout", "1");
paras.put("loginTimeout", "1");
paras.put("systemId", "1");
paras.put("redirect", "http://mng.duibatest.com.cn/AItem/index.htm");
......
package http.service.Saas;
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;
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 zhaoran on 2018/12/19.
*/
@Service
public class mallService {
@Value("${activity.host}")
String activityHost;
@Autowired
Authorization authorization;
private DuibaLog logger = DuibaLog.getLogger();
//获取购物车列表商品
public Response mallget(Integer uid) throws Exception {
String url = activityHost+"/mall-api/consumer/shopping-trolley/get";
Response response=given().cookies(authorization.dafuwengLogin(uid)).get(url);
response.prettyPrint();
try{
Assert.assertEquals(response.jsonPath().getString("success"),"true");
}catch(Exception e){
throw new Exception("购物车列表接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("购物车列表接口失败,返回信息:"+response.asString());
}
return response;
}
//获取购物车列表商品
public Response getMallCount(Integer uid) throws Exception {
String url = activityHost+"/mall-api/consumer/market-activity/getMallCount";
Response response=given().cookies(authorization.dafuwengLogin(uid)).get(url);
response.prettyPrint();
try{
Assert.assertEquals(response.jsonPath().getString("success"),"true");
}catch(Exception e){
throw new Exception("购物车数目接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("购物车数目接口失败,返回信息:"+response.asString());
}
return response;
}
// 加入购物车
public Response malladd(String appItemId,Integer uid) throws Exception {
String url = activityHost+"/mall-api/consumer/shopping-trolley/add";
Map<String,String> map = new HashMap<>();
map.put("appItemId",appItemId);
JSONObject jsonParam = JSONObject.parseObject(JSON.toJSONString(map));
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.dafuwengLogin(uid)).body(jsonParam).post(url);
response.prettyPrint();
try{
Assert.assertEquals(response.jsonPath().getString("success"),"true");
}catch(Exception e){
throw new Exception("添加购物车接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("添加购物车接口失败,返回信息:"+response.asString());
}
return response;
}
}
\ No newline at end of file
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