eureka
tanghc 4 years ago
parent 3fce909a35
commit e40d885078
  1. 25
      sop-test/src/main/java/com/gitee/sop/test/Client.java
  2. 18
      sop-test/src/test/java/com/gitee/sop/test/AllInOneTest.java

@ -174,6 +174,8 @@ public class Client {
public static class RequestBuilder {
private static final String DEFAULT_VERSION = "1.0";
private Map<String, String> systemParam;
private String url;
private String method;
private String version = DEFAULT_VERSION;
@ -277,6 +279,20 @@ public class Client {
return this;
}
/**
* 添加系统参数
* @param name 参数名
* @param value 参数值
* @return 返回RequestBuilder
*/
public RequestBuilder addSystemParam(String name, String value) {
if (systemParam == null) {
systemParam = new HashMap<>(8);
}
systemParam.put(name, value);
return this;
}
/**
* 设置token
*
@ -376,9 +392,14 @@ public class Client {
params.put("charset", "utf-8");
params.put("sign_type", "RSA2");
params.put("timestamp", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
if (systemParam != null) {
params.putAll(systemParam);
}
// 业务参数
params.put("biz_content", JSON.toJSONString(bizContent == null ? Collections.emptyMap() : bizContent));
if (bizContent != null) {
// 业务参数
params.put("biz_content", JSON.toJSONString(bizContent));
}
if (!ignoreSign) {
String content = AlipaySignature.getSignContent(params);

@ -353,6 +353,24 @@ public class AllInOneTest extends TestBase {
client.execute(requestBuilder);
}
/**
* 以get方式提交
*/
public void testBindParam() {
Client.RequestBuilder requestBuilder = new Client.RequestBuilder()
.method("story.param.bind")
.version("1.0")
.addSystemParam("id", "1")
.addSystemParam("name", "葫芦娃")
.httpMethod(HttpTool.HTTPMethod.GET)
.callback(((requestInfo, responseData) -> {
System.out.println(responseData);
Assert.assertTrue(responseData.contains("参数绑定:id:1, name:葫芦娃"));
}));
client.execute(requestBuilder);
}
static class BizContent extends HashMap<String, Object> {
public BizContent add(String key, Object value) {
this.put(key, value);

Loading…
Cancel
Save