From 5ecbefb8847a17c8778f83c815992977890aaf17 Mon Sep 17 00:00:00 2001 From: AgAngle <1323481023@qq.com> Date: Tue, 6 Aug 2024 10:08:19 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=8E=A5=E5=8F=A3=E5=BF=BD=E7=95=A5=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E5=8F=82=E6=95=B0=E5=8F=98=E6=9B=B4=E9=80=9A=E7=9F=A5?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --task=1015861 --user=陈建星 【接口测试】接口用例支持同步更新接口变更-是否与定义不一致查询接口 https://www.tapd.cn/55049933/s/1557706 --- .../controller/definition/ApiTestCaseController.java | 6 +++--- .../api/dto/definition/ApiTestCaseDTO.java | 3 +++ .../api/service/definition/ApiTestCaseService.java | 12 ++++++++---- .../api/controller/ApiTestCaseControllerTests.java | 12 ++++++++---- 4 files changed, 22 insertions(+), 11 deletions(-) diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/controller/definition/ApiTestCaseController.java b/backend/services/api-test/src/main/java/io/metersphere/api/controller/definition/ApiTestCaseController.java index afd5c407e0..fed3aa2ee6 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/controller/definition/ApiTestCaseController.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/controller/definition/ApiTestCaseController.java @@ -319,11 +319,11 @@ public class ApiTestCaseController { } @GetMapping("/api-change/ignore/{id}") - @Operation(summary = "清除接口参数变更标识") + @Operation(summary = "忽略接口变更提示") @RequiresPermissions(logical = Logical.OR, value = {PermissionConstants.PROJECT_API_DEFINITION_CASE_ADD, PermissionConstants.PROJECT_API_DEFINITION_CASE_UPDATE}) @CheckOwner(resourceId = "#id", resourceType = "api_test_case") - public void ignoreApiChange(@PathVariable String id) { - apiTestCaseService.ignoreApiChange(id); + public void ignoreApiChange(@PathVariable String id, @RequestParam(name = "ignore") boolean ignore) { + apiTestCaseService.ignoreApiChange(id, ignore); } @GetMapping("/api/compare/{id}") diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/dto/definition/ApiTestCaseDTO.java b/backend/services/api-test/src/main/java/io/metersphere/api/dto/definition/ApiTestCaseDTO.java index 64e109abca..d5ea223a78 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/dto/definition/ApiTestCaseDTO.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/dto/definition/ApiTestCaseDTO.java @@ -101,6 +101,9 @@ public class ApiTestCaseDTO { @Schema(description = "与接口定义不一致") private Boolean inconsistentWithApi; + @Schema(description = "忽略接口与用例参数不一致") + private Boolean ignoreApiDiff; + @Schema(description = "忽略接口定义参数变更") private Boolean ignoreApiChange; } diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiTestCaseService.java b/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiTestCaseService.java index 7bc214995b..e62b4f5d4c 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiTestCaseService.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiTestCaseService.java @@ -980,13 +980,17 @@ public class ApiTestCaseService extends MoveNodeService { return ApiDataUtils.parseObject(new String(apiTestCaseBlob.getRequest()), AbstractMsTestElement.class); } - public void ignoreApiChange(String id) { + public void ignoreApiChange(String id, boolean ignore) { checkResourceExist(id); ApiTestCase apiTestCase = new ApiTestCase(); apiTestCase.setId(id); - apiTestCase.setApiChange(false); - apiTestCase.setIgnoreApiDiff(true); - apiTestCase.setIgnoreApiChange(true); + if (ignore) { + apiTestCase.setApiChange(false); + apiTestCase.setIgnoreApiDiff(true); + apiTestCase.setIgnoreApiChange(true); + } else { + apiTestCase.setIgnoreApiChange(false); + } apiTestCaseMapper.updateByPrimaryKeySelective(apiTestCase); } diff --git a/backend/services/api-test/src/test/java/io/metersphere/api/controller/ApiTestCaseControllerTests.java b/backend/services/api-test/src/test/java/io/metersphere/api/controller/ApiTestCaseControllerTests.java index e1b7b9864f..58221e234f 100644 --- a/backend/services/api-test/src/test/java/io/metersphere/api/controller/ApiTestCaseControllerTests.java +++ b/backend/services/api-test/src/test/java/io/metersphere/api/controller/ApiTestCaseControllerTests.java @@ -111,7 +111,7 @@ public class ApiTestCaseControllerTests extends BaseTest { private static final String RUN_POST = "run"; private static final String BATCH_RUN = "batch/run"; private static final String API_CHANGE_CLEAR = "api-change/clear/{0}"; - private static final String API_CHANGE_IGNORE = "api-change/ignore/{0}"; + private static final String API_CHANGE_IGNORE = "api-change/ignore/{0}?ignore={1}"; private static final String API_CHANGE_SYNC = "batch/api-change/sync"; private static final String API_COMPARE = "api/compare/{0}"; @@ -478,14 +478,18 @@ public class ApiTestCaseControllerTests extends BaseTest { updateCase.setApiChange(true); updateCase.setId(apiTestCase.getId()); apiTestCaseMapper.updateByPrimaryKeySelective(updateCase); - this.requestGetWithOk(API_CHANGE_IGNORE, apiTestCase.getId()); + this.requestGetWithOk(API_CHANGE_IGNORE, apiTestCase.getId(), true); Assertions.assertFalse(apiTestCaseMapper.selectByPrimaryKey(apiTestCase.getId()).getApiChange()); Assertions.assertTrue(apiTestCaseMapper.selectByPrimaryKey(apiTestCase.getId()).getIgnoreApiDiff()); Assertions.assertTrue(apiTestCaseMapper.selectByPrimaryKey(apiTestCase.getId()).getIgnoreApiChange()); + this.requestGetWithOk(API_CHANGE_IGNORE, apiTestCase.getId(), false); + Assertions.assertFalse(apiTestCaseMapper.selectByPrimaryKey(apiTestCase.getId()).getApiChange()); + Assertions.assertTrue(apiTestCaseMapper.selectByPrimaryKey(apiTestCase.getId()).getIgnoreApiDiff()); + Assertions.assertFalse(apiTestCaseMapper.selectByPrimaryKey(apiTestCase.getId()).getIgnoreApiChange()); // @@校验权限 - requestGetPermissionTest(PermissionConstants.PROJECT_API_DEFINITION_CASE_ADD, API_CHANGE_IGNORE, apiTestCase.getId()); - requestGetPermissionTest(PermissionConstants.PROJECT_API_DEFINITION_CASE_UPDATE, API_CHANGE_IGNORE, apiTestCase.getId()); + requestGetPermissionTest(PermissionConstants.PROJECT_API_DEFINITION_CASE_ADD, API_CHANGE_IGNORE, apiTestCase.getId(), true); + requestGetPermissionTest(PermissionConstants.PROJECT_API_DEFINITION_CASE_UPDATE, API_CHANGE_IGNORE, apiTestCase.getId(), false); } @Test