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

Method getBuildValue

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

获取格式化后的值 @param sourchJson @param key @return

(String sourchJson, String key)

Source from the content-addressed store, hash-verified

163 * @return
164 */
165 private String getBuildValue(String sourchJson, String key) {
166 key = key.trim();
167 Matcher funMatch = funPattern.matcher(key);
168 if (key.startsWith("$.")) {// jsonpath
169 key = JSONPath.read(sourchJson, key).toString();
170 } else if (funMatch.find()) {
171 // String args;
172 // if (funMatch.group(2).startsWith("$.")) {
173 // args = JSONPath.read(sourchJson, funMatch.group(2)).toString();
174 // } else {
175 // args = funMatch.group(2);
176 // }
177 String args = funMatch.group(2);
178 String[] argArr = args.split(",");
179 for (int index = 0; index < argArr.length; index++) {
180 String arg = argArr[index];
181 if (arg.startsWith("$.")) {
182 argArr[index] = JSONPath.read(sourchJson, arg).toString();
183 }
184 }
185 String value = FunctionUtil.getValue(funMatch.group(1), argArr);
186 key = StringUtil.replaceFirst(key, funMatch.group(), value);
187
188 }
189 return key;
190 }
191
192 /**
193 * 提取json串中的值保存至公共池中

Callers 2

verifyResultMethod · 0.95
saveResultMethod · 0.95

Calls 3

getValueMethod · 0.95
replaceFirstMethod · 0.95
toStringMethod · 0.80

Tested by

no test coverage detected