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

222

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