diff --git a/backend/src/main/java/io/metersphere/api/dto/mock/MockApiUtils.java b/backend/src/main/java/io/metersphere/api/dto/mock/MockApiUtils.java index 9c281ecc39..6c442fe0a3 100644 --- a/backend/src/main/java/io/metersphere/api/dto/mock/MockApiUtils.java +++ b/backend/src/main/java/io/metersphere/api/dto/mock/MockApiUtils.java @@ -432,8 +432,8 @@ public class MockApiUtils { } - public static RequestMockParams getParams(String urlParams, String apiPath, JSONObject queryParamsObject, JSON paramJson) { - RequestMockParams returnParams = getGetParamMap(urlParams, apiPath, queryParamsObject); + public static RequestMockParams getParams(String urlParams, String apiPath, JSONObject queryParamsObject, JSON paramJson, boolean isPostRequest) { + RequestMockParams returnParams = getGetParamMap(urlParams, apiPath, queryParamsObject, isPostRequest); if (paramJson != null) { if (paramJson instanceof JSONObject) { if (!((JSONObject) paramJson).isEmpty()) { @@ -462,13 +462,19 @@ public class MockApiUtils { return queryParamsObject; } - private static RequestMockParams getGetParamMap(String urlParams, String apiPath, JSONObject queryParamsObject) { + private static RequestMockParams getGetParamMap(String urlParams, String apiPath, JSONObject queryParamsObject, boolean isPostRequest) { RequestMockParams requestMockParams = new RequestMockParams(); JSONObject urlParamsObject = getSendRestParamMapByIdAndUrl(apiPath, urlParams); requestMockParams.setRestParamsObj(urlParamsObject); requestMockParams.setQueryParamsObj(queryParamsObject); + + if(isPostRequest){ + JSONArray jsonArray = new JSONArray(); + jsonArray.add(queryParamsObject); + requestMockParams.setBodyParams(jsonArray); + } return requestMockParams; } diff --git a/backend/src/main/java/io/metersphere/api/service/MockConfigService.java b/backend/src/main/java/io/metersphere/api/service/MockConfigService.java index 7c7790d764..75a83cb91b 100644 --- a/backend/src/main/java/io/metersphere/api/service/MockConfigService.java +++ b/backend/src/main/java/io/metersphere/api/service/MockConfigService.java @@ -365,7 +365,7 @@ public class MockConfigService { if (jsonObject.containsKey("name") && jsonObject.containsKey("value")) { String headerName = jsonObject.getString("name"); String headerValue = jsonObject.getString("value"); - if(StringUtils.isNotEmpty(headerName)){ + if (StringUtils.isNotEmpty(headerName)) { if (!requestHeaderMap.containsKey(headerName) || !StringUtils.equals(requestHeaderMap.get(headerName), headerValue)) { return false; } @@ -1155,13 +1155,10 @@ public class MockConfigService { if (project != null) { String urlSuffix = this.getUrlSuffix(project.getSystemId(), request); aualifiedApiList = apiDefinitionService.preparedUrl(project.getId(), method, urlSuffix); - JSON paramJson = MockApiUtils.getPostParamMap(request); JSONObject parameterObject = MockApiUtils.getParameterJsonObject(request); - for (ApiDefinitionWithBLOBs api : aualifiedApiList) { - RequestMockParams mockParams = MockApiUtils.getParams(urlSuffix, api.getPath(), parameterObject, paramJson); - + RequestMockParams mockParams = MockApiUtils.getParams(urlSuffix, api.getPath(), parameterObject, paramJson, true); MockConfigResponse mockConfigData = this.findByApiId(api.getId()); MockExpectConfigResponse finalExpectConfig = this.findExpectConfig(requestHeaderMap, mockConfigData.getMockExpectConfigList(), mockParams); if (finalExpectConfig != null) { @@ -1170,36 +1167,6 @@ public class MockConfigService { break; } } - - -// List apiIdList = aualifiedApiList.stream().map(ApiDefinitionWithBLOBs::getId).collect(Collectors.toList()); -// MockConfigResponse mockConfigData = this.findByApiIdList(apiIdList); - -// if (mockConfigData != null && mockConfigData.getMockExpectConfigList() != null) { -// String urlSuffix = this.getUrlSuffix(project.getSystemId(), request); -// aualifiedApiList = apiDefinitionService.preparedUrl(project.getId(), method, null, urlSuffix); -// JSON paramJson = MockApiUtils.getParams(request); -// if (paramJson instanceof JSONObject) { -// JSONArray paramsArray = new JSONArray(); -// paramsArray.add(paramJson); -// RequestMockParams mockParams = new RequestMockParams(); -// mockParams.setBodyParams(paramsArray); -// MockExpectConfigResponse finalExpectConfig = this.findExpectConfig(requestHeaderMap, mockConfigData.getMockExpectConfigList(), mockParams); -// if (finalExpectConfig != null) { -// isMatch = true; -// returnStr = this.updateHttpServletResponse(finalExpectConfig, url, requestHeaderMap, mockParams, response); -// } -// } else if (paramJson instanceof JSONArray) { -// JSONArray paramArray = (JSONArray) paramJson; -// RequestMockParams mockParams = new RequestMockParams(); -// mockParams.setBodyParams(paramArray); -// MockExpectConfigResponse finalExpectConfig = this.findExpectConfig(requestHeaderMap, mockConfigData.getMockExpectConfigList(), mockParams); -// if (finalExpectConfig != null) { -// isMatch = true; -// returnStr = this.updateHttpServletResponse(finalExpectConfig, url, requestHeaderMap, mockParams, response); -// } -// } -// } } if (!isMatch) { @@ -1230,7 +1197,7 @@ public class MockConfigService { JSONObject parameterObject = MockApiUtils.getParameterJsonObject(request); for (ApiDefinitionWithBLOBs api : aualifiedApiList) { - RequestMockParams paramMap = MockApiUtils.getParams(urlSuffix, api.getPath(), parameterObject, paramJson); + RequestMockParams paramMap = MockApiUtils.getParams(urlSuffix, api.getPath(), parameterObject, paramJson, false); MockConfigResponse mockConfigData = this.findByApiId(api.getId()); if (mockConfigData != null && mockConfigData.getMockExpectConfigList() != null) { diff --git a/frontend/src/business/components/track/common/tableItems/planview/StatusTableItem.vue b/frontend/src/business/components/track/common/tableItems/planview/StatusTableItem.vue index 558ec16903..48cf299c8f 100644 --- a/frontend/src/business/components/track/common/tableItems/planview/StatusTableItem.vue +++ b/frontend/src/business/components/track/common/tableItems/planview/StatusTableItem.vue @@ -1,14 +1,15 @@ diff --git a/frontend/src/business/components/track/plan/view/comonents/report/detail/component/ApiScenarioFailureResult.vue b/frontend/src/business/components/track/plan/view/comonents/report/detail/component/ApiScenarioFailureResult.vue index 216b13a799..a672353186 100644 --- a/frontend/src/business/components/track/plan/view/comonents/report/detail/component/ApiScenarioFailureResult.vue +++ b/frontend/src/business/components/track/plan/view/comonents/report/detail/component/ApiScenarioFailureResult.vue @@ -44,6 +44,8 @@ + +