Commit 8a21976f authored by 郭姣's avatar 郭姣

222

parent 6acdd168
......@@ -5,6 +5,7 @@ import static io.restassured.RestAssured.*;
import com.alibaba.fastjson.JSONObject;
import io.restassured.response.Response;
import javax.xml.ws.Response;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
......@@ -19,8 +20,8 @@ public class NetworkUtils {
public Map<String, Object> fileHeaders = new HashMap<String, Object>();
// 钉钉的 headers
public Map<String, Object> dingTalkHeaders = new HashMap<String, Object>();
private volatile static NetworkUtils network;
// public Map<String, Object> dingTalkHeaders = new HashMap<String, Object>();
// private volatile static NetworkUtils network;
// 构造函数 初始化tku、content-type
private NetworkUtils(){
......@@ -33,7 +34,7 @@ public class NetworkUtils {
//二进制文件的headers
fileHeaders.put("Content-Type","multipart/form-data");
//钉钉的headers
dingTalkHeaders.put("Content-Type","application/json;charset=utf-8");
// dingTalkHeaders.put("Content-Type","application/json;charset=utf-8");
}
//单例模式
......@@ -160,17 +161,17 @@ public class NetworkUtils {
}
// post 钉钉机器人
public Response dingTalkRobot(Map<String, Object> params) {
String jsonStr = JSONObject.toJSONString(params);
Response response = given()
.headers(dingTalkHeaders)
.body(jsonStr)
.post(dingTalkPath);
if (!Objects.equals(response.statusCode(),200)){
System.out.println("请求状态码错误,code=【"+response.statusCode()+"】");
}
return response;
}
// public Response dingTalkRobot(Map<String, Object> params) {
// String jsonStr = JSONObject.toJSONString(params);
// Response response = given()
// .headers(dingTalkHeaders)
// .body(jsonStr)
// .post(dingTalkPath);
// if (!Objects.equals(response.statusCode(),200)){
// System.out.println("请求状态码错误,code=【"+response.statusCode()+"】");
// }
// 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