fix(接口测试): 用例列表全选,批量同步,部分用例没有同步成功

--bug=1047132 --user=陈建星 【接口测试】CASE列表-批量选中case-同步成功,查看用例详情仍显示与定义不一致,实际是没同步成功 https://www.tapd.cn/55049933/s/1585866
This commit is contained in:
AgAngle 2024-09-25 15:15:12 +08:00 committed by 刘瑞斌
parent 86488f392d
commit 9386c45d33
2 changed files with 1 additions and 11 deletions

View File

@ -1044,7 +1044,7 @@ public class ApiTestCaseService extends MoveNodeService {
AbstractMsTestElement apiMsTestElement = getApiMsTestElement(apiDefinitionBlob); AbstractMsTestElement apiMsTestElement = getApiMsTestElement(apiDefinitionBlob);
ApiTestCaseBlob apiTestCaseBlob = apiTestCaseBlobMapper.selectByPrimaryKey(apiTestCase.getId()); ApiTestCaseBlob apiTestCaseBlob = apiTestCaseBlobMapper.selectByPrimaryKey(apiTestCase.getId());
AbstractMsTestElement apiTestCaseMsTestElement = getTestElement(apiTestCaseBlob); AbstractMsTestElement apiTestCaseMsTestElement = getTestElement(apiTestCaseBlob);
boolean requestParamDifferent = HttpRequestParamDiffUtils.isRequestParamDiff(request.getSyncItems(), apiMsTestElement, apiTestCaseMsTestElement); boolean requestParamDifferent = HttpRequestParamDiffUtils.isRequestParamDiff(apiMsTestElement, apiTestCaseMsTestElement);
if (requestParamDifferent) { if (requestParamDifferent) {
// 如果参数与定义不一致则同步参数并记录日志和发送通知 // 如果参数与定义不一致则同步参数并记录日志和发送通知
ApiTestCaseLogDTO originCase = BeanUtils.copyBean(new ApiTestCaseLogDTO(), apiTestCase); ApiTestCaseLogDTO originCase = BeanUtils.copyBean(new ApiTestCaseLogDTO(), apiTestCase);

View File

@ -33,10 +33,6 @@ import static io.metersphere.sdk.util.XMLUtils.elementToMap;
public class HttpRequestParamDiffUtils { public class HttpRequestParamDiffUtils {
public static boolean isRequestParamDiff(Object request1, Object request2) { public static boolean isRequestParamDiff(Object request1, Object request2) {
return isRequestParamDiff(new ApiCaseSyncItemRequest(), request1, request2);
}
public static boolean isRequestParamDiff(ApiCaseSyncItemRequest syncItemRequest, Object request1, Object request2) {
if (!(request1 instanceof MsHTTPElement)) { if (!(request1 instanceof MsHTTPElement)) {
// 其他协议不比较 // 其他协议不比较
return false; return false;
@ -48,12 +44,6 @@ public class HttpRequestParamDiffUtils {
boolean isHeaderDiff = isParamKeyDiff(httpElement1.getHeaders(), httpElement2.getHeaders()); boolean isHeaderDiff = isParamKeyDiff(httpElement1.getHeaders(), httpElement2.getHeaders());
boolean isBodyDiff = isBodyDiff(httpElement1.getBody(), httpElement2.getBody()); boolean isBodyDiff = isBodyDiff(httpElement1.getBody(), httpElement2.getBody());
// 设置需要同步的同步项, 减少比较次数
syncItemRequest.setBody(isBodyDiff && BooleanUtils.isTrue(syncItemRequest.getBody()));
syncItemRequest.setHeader(isHeaderDiff && BooleanUtils.isTrue(syncItemRequest.getHeader()));
syncItemRequest.setQuery(isQueryDiff && BooleanUtils.isTrue(syncItemRequest.getQuery()));
syncItemRequest.setRest(isRestDiff && BooleanUtils.isTrue(syncItemRequest.getRest()));
if (isQueryDiff || isRestDiff || isHeaderDiff || isBodyDiff) { if (isQueryDiff || isRestDiff || isHeaderDiff || isBodyDiff) {
return true; return true;
} }