fix(接口测试): 修复mock期望设置时Query参数和Rest参数的与或关系相互影响的问题

--bug=1013269 --user=宋天阳 【接口测试】mock期望,query和rest的and/or关系会互相影响
https://www.tapd.cn/55049933/s/1169387
This commit is contained in:
song-tianyang 2022-05-31 09:55:19 +08:00 committed by TIanyang
parent 5013502dd1
commit 93e878c860
3 changed files with 12 additions and 3 deletions

View File

@ -422,10 +422,14 @@ public class MockConfigService {
} }
} }
String restFilterType = paramsFilterType;
if (expectParamsObj.containsKey("restFilterType") && StringUtils.isNotEmpty(expectParamsObj.getString("restFilterType"))) {
restFilterType = expectParamsObj.getString("restFilterType");
}
if (expectParamsObj.containsKey("rest")) { if (expectParamsObj.containsKey("rest")) {
JSONArray restArray = expectParamsObj.getJSONArray("rest"); JSONArray restArray = expectParamsObj.getJSONArray("rest");
List<MockConfigRequestParams> mockConfigRequestParams = MockApiUtils.getParamsByJSONArray(restArray); List<MockConfigRequestParams> mockConfigRequestParams = MockApiUtils.getParamsByJSONArray(restArray);
if (!MockApiUtils.checkParamsCompliance(requestMockParams.getRestParamsObj(), mockConfigRequestParams, StringUtils.equals(paramsFilterType, "And"))) { if (!MockApiUtils.checkParamsCompliance(requestMockParams.getRestParamsObj(), mockConfigRequestParams, StringUtils.equals(restFilterType, "And"))) {
return false; return false;
} }
} }

View File

@ -6,7 +6,11 @@
<div class="top-line-box" :style="{ height:lineDivTopHeight+'px',marginTop:lineDivMarginTopHeight+'px'}"> <div class="top-line-box" :style="{ height:lineDivTopHeight+'px',marginTop:lineDivMarginTopHeight+'px'}">
</div> </div>
<div> <div>
<el-select class="ms-http-select" size="small" v-model="filterTypeObject.paramsFilterType" <el-select v-if="isRest" class="ms-http-select" size="small" v-model="filterTypeObject.restFilterType"
style="width: 100px">
<el-option v-for="item in filterTypes" :key="item.id" :label="item.label" :value="item.id"/>
</el-select>
<el-select v-else class="ms-http-select" size="small" v-model="filterTypeObject.paramsFilterType"
style="width: 100px"> style="width: 100px">
<el-option v-for="item in filterTypes" :key="item.id" :label="item.label" :value="item.id"/> <el-option v-for="item in filterTypes" :key="item.id" :label="item.label" :value="item.id"/>
</el-select> </el-select>
@ -51,6 +55,7 @@ export default {
suggestions: Array, suggestions: Array,
parameters: Array, parameters: Array,
filterTypeObject: Object, filterTypeObject: Object,
isRest: Boolean,
isReadOnly: { isReadOnly: {
type: Boolean, type: Boolean,
default: false default: false

View File

@ -48,7 +48,7 @@
<el-row> <el-row>
<el-link class="ms-el-link" @click="batchAdd" style="color: #783887"> {{ $t("commons.batch_add") }}</el-link> <el-link class="ms-el-link" @click="batchAdd" style="color: #783887"> {{ $t("commons.batch_add") }}</el-link>
</el-row> </el-row>
<mock-combination-condition :filter-type-object="request" :is-read-only="isReadOnly" :is-show-enable="isShowEnable" :suggestions="apiParams.rest" :parameters="request.rest"/> <mock-combination-condition :is-rest="true" :filter-type-object="request" :is-read-only="isReadOnly" :is-show-enable="isShowEnable" :suggestions="apiParams.rest" :parameters="request.rest"/>
</el-tab-pane> </el-tab-pane>
<!--请求体--> <!--请求体-->