MCPcopy Create free account
hub / github.com/ChenSen5/api_autotest / buildParam

Method buildParam

src/test/java/test/com/sen/api/TestBase.java:52–75  ·  view source on GitHub ↗

组件预参数(处理__fucn()以及${xxxx}) @param apiDataBean @return

(String param)

Source from the content-addressed store, hash-verified

50 * @return
51 */
52 protected String buildParam(String param) {
53 // 处理${}
54 param = getCommonParam(param);
55 // Pattern pattern = Pattern.compile("__(.*?)\\(.*\\)");// 取__开头的函数正则表达式
56 // Pattern pattern =
57 // Pattern.compile("__(\\w*?)\\((\\w*,)*(\\w*)*\\)");// 取__开头的函数正则表达式
58 Matcher m = funPattern.matcher(param);
59 while (m.find()) {
60 String funcName = m.group(1);
61 String args = m.group(2);
62 String value;
63 // bodyfile属于特殊情况,不进行匹配,在post请求的时候进行处理
64 if (FunctionUtil.isFunction(funcName)
65 && !funcName.equals("bodyfile")) {
66 // 属于函数助手,调用那个函数助手获取。
67 value = FunctionUtil.getValue(funcName, args.split(","));
68 // 解析对应的函数失败
69 Assert.assertNotNull(value,
70 String.format("解析函数失败:%s。", funcName));
71 param = StringUtil.replaceFirst(param, m.group(), value);
72 }
73 }
74 return param;
75 }
76
77 protected void savePreParam(String preParam) {
78 // 通过';'分隔,将参数加入公共参数map中

Callers 1

buildRequestParamMethod · 0.80

Calls 4

getCommonParamMethod · 0.95
isFunctionMethod · 0.95
getValueMethod · 0.95
replaceFirstMethod · 0.95

Tested by

no test coverage detected