refactor(接口测试): 正则提取方式增加自定义模版选项
--story=1013329 --user=赵勇 接口测试-正则提取-添加模版匹配规则选项 https://www.tapd.cn/55049933/s/1426415 Signed-off-by: fit2-zhao <yong.zhao@fit2cloud.com>
This commit is contained in:
parent
147c7e4f8f
commit
9d86f375cb
|
@ -97,7 +97,11 @@ public class MsExtract extends MsTestElement {
|
|||
extractor.setMatchNumber(-1);
|
||||
}
|
||||
// $1$提取 JSON 响应中的第一个匹配项 $0$用于提取整个 JSON 响应
|
||||
extractor.setTemplate("$0$");
|
||||
if (StringUtils.isNotEmpty(extractRegex.getTemplate())) {
|
||||
extractor.setTemplate(extractRegex.getTemplate());
|
||||
} else {
|
||||
extractor.setTemplate("$1$");
|
||||
}
|
||||
extract.add(extractor.getRefName());
|
||||
|
||||
return extractor;
|
||||
|
|
|
@ -7,7 +7,7 @@ import lombok.EqualsAndHashCode;
|
|||
@Data
|
||||
public class MsExtractRegex extends MsExtractCommon {
|
||||
private String useHeaders;
|
||||
|
||||
private String template;
|
||||
public MsExtractRegex() {
|
||||
setType(MsExtractType.REGEX);
|
||||
}
|
||||
|
|
|
@ -31,7 +31,15 @@
|
|||
size="small"
|
||||
show-word-limit
|
||||
:placeholder="expression"
|
||||
@click.native="savePreParams(common.variable)" />
|
||||
@click.native="savePreParams(common.variable)"
|
||||
style="width: 70%" />
|
||||
|
||||
<el-autocomplete
|
||||
style="width: 25%; margin-left: 10px"
|
||||
size="small"
|
||||
placeholder="Template $i$ where i is capturing group number,stats at 1"
|
||||
v-model="common.template"
|
||||
:fetch-suggestions="querySearch" />
|
||||
</el-col>
|
||||
<el-col class="multiple_checkbox" v-if="edit">
|
||||
<el-checkbox v-model="common.multipleMatching" :disabled="isReadOnly">
|
||||
|
@ -104,10 +112,21 @@ export default {
|
|||
{ label: 'Response Code', value: 'code' },
|
||||
{ label: 'Response Message', value: 'message' },
|
||||
],
|
||||
restaurants: [
|
||||
{ value: '$0$', id: '$0$' },
|
||||
{ value: '$1$', id: '$1$' },
|
||||
],
|
||||
};
|
||||
},
|
||||
|
||||
created() {
|
||||
if (!this.common.template) {
|
||||
this.$set(this.common, 'template', '$1$');
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
querySearch(queryString, cb) {
|
||||
cb(this.restaurants);
|
||||
},
|
||||
add() {
|
||||
this.common.type = this.extractType;
|
||||
this.list.push(new ExtractCommon(this.extractType, this.common));
|
||||
|
|
Loading…
Reference in New Issue