diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/dto/definition/ApiCaseReportDTO.java b/backend/services/api-test/src/main/java/io/metersphere/api/dto/definition/ApiCaseReportDTO.java index 9547489588..d903e5488d 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/dto/definition/ApiCaseReportDTO.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/dto/definition/ApiCaseReportDTO.java @@ -16,12 +16,6 @@ public class ApiCaseReportDTO implements Serializable { @Schema(description = "任务名称") private String name; - @Schema(description = "用例id") - private String resourceId; - - @Schema(description = "测试计划id") - private String testPlanId; - @Schema(description = "操作人") private String operationUser; @Schema(description = "操作人id") @@ -36,9 +30,6 @@ public class ApiCaseReportDTO implements Serializable { @Schema(description = "执行方式") private String triggerMode; - @Schema(description = "是否是测试计划执行的用例") - private boolean testPlan; - private static final long serialVersionUID = 1L; } \ No newline at end of file diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiTestCaseMapper.xml b/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiTestCaseMapper.xml index 99fa643491..502a823cd7 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiTestCaseMapper.xml +++ b/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiTestCaseMapper.xml @@ -235,8 +235,7 @@ api_report.start_time, api_report.create_user, api_report.trigger_mode, - api_report.test_plan_id, - api_report.resource_id + api_report.test_plan_id from api_report where api_report.resource_id = #{request.id} 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 73bfa869cb..5250a51007 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 @@ -559,7 +559,6 @@ public class ApiTestCaseService { apiReport.setOperationUser(userMap.get(apiReport.getCreateUser())); Date date = new Date(apiReport.getStartTime()); apiReport.setNum(sdf.format(date)); - apiReport.setTestPlan(!StringUtils.equals(apiReport.getTestPlanId(), "NONE")); }); return executeList; } 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 779c05bcce..878d8f6c9e 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 @@ -608,9 +608,6 @@ public class ApiTestCaseControllerTests extends BaseTest { Pager returnPager = parseObjectFromMvcResult(mvcResult, Pager.class); //返回值不为空 Assertions.assertNotNull(returnPager); - List reportDTOS = JSON.parseArray(JSON.toJSONString(returnPager.getList()), ApiCaseReportDTO.class); - reportDTOS.forEach(reportDTO -> Assertions.assertEquals(reportDTO.getResourceId(), first.getId())); - request.setFilter(new HashMap<>() {{ put("status", List.of(ApiReportStatus.SUCCESS.name())); }}); @@ -619,7 +616,7 @@ public class ApiTestCaseControllerTests extends BaseTest { //返回值不为空 Assertions.assertNotNull(returnPager); Assertions.assertTrue(((List) returnPager.getList()).size() <= request.getPageSize()); - reportDTOS = JSON.parseArray(JSON.toJSONString(returnPager.getList()), ApiCaseReportDTO.class); + List reportDTOS = JSON.parseArray(JSON.toJSONString(returnPager.getList()), ApiCaseReportDTO.class); reportDTOS.forEach(apiReport -> { Assertions.assertEquals(apiReport.getStatus(), ApiReportStatus.SUCCESS.name()); }); diff --git a/backend/services/project-management/src/main/java/io/metersphere/project/dto/environment/EnvironmentRequest.java b/backend/services/project-management/src/main/java/io/metersphere/project/dto/environment/EnvironmentRequest.java index da8f485b9e..c80c663abb 100644 --- a/backend/services/project-management/src/main/java/io/metersphere/project/dto/environment/EnvironmentRequest.java +++ b/backend/services/project-management/src/main/java/io/metersphere/project/dto/environment/EnvironmentRequest.java @@ -4,7 +4,6 @@ import io.metersphere.validation.groups.Created; import io.metersphere.validation.groups.Updated; import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.NotBlank; -import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.Size; import lombok.Data; @@ -27,7 +26,6 @@ public class EnvironmentRequest implements Serializable { @NotBlank(message = "{environment_name_is_null}", groups = {Created.class, Updated.class}) private String name; @Schema(description = "环境配置") - @NotNull(message = "{environment_config_is_null}", groups = {Created.class, Updated.class}) private EnvironmentConfig config; @Schema(description = "是否是mock环境") private Boolean mock; diff --git a/backend/services/project-management/src/main/java/io/metersphere/project/service/EnvironmentService.java b/backend/services/project-management/src/main/java/io/metersphere/project/service/EnvironmentService.java index 794b7bfeff..12b8ddf308 100644 --- a/backend/services/project-management/src/main/java/io/metersphere/project/service/EnvironmentService.java +++ b/backend/services/project-management/src/main/java/io/metersphere/project/service/EnvironmentService.java @@ -17,10 +17,7 @@ import io.metersphere.sdk.file.FileRequest; import io.metersphere.sdk.file.MinioRepository; import io.metersphere.sdk.mapper.EnvironmentBlobMapper; import io.metersphere.sdk.mapper.EnvironmentMapper; -import io.metersphere.sdk.util.CommonBeanFactory; -import io.metersphere.sdk.util.JSON; -import io.metersphere.sdk.util.LogUtils; -import io.metersphere.sdk.util.Translator; +import io.metersphere.sdk.util.*; import io.metersphere.system.dto.sdk.BaseSystemConfigDTO; import io.metersphere.system.dto.sdk.OptionDTO; import io.metersphere.system.dto.sdk.request.PosRequest; @@ -131,6 +128,9 @@ public class EnvironmentService { request.setId(environment.getId()); EnvironmentBlob environmentBlob = new EnvironmentBlob(); environmentBlob.setId(environment.getId()); + if (request.getConfig() == null) { + request.setConfig(new EnvironmentConfig()); + } environmentBlob.setConfig(JSON.toJSONBytes(request.getConfig())); environmentBlobMapper.insert(environmentBlob); uploadFileToMinio(sslFiles, environment); @@ -163,6 +163,7 @@ public class EnvironmentService { environmentInfoDTO.setName(environment.getName()); environmentInfoDTO.setId(environment.getId()); environmentInfoDTO.setMock(environment.getMock()); + BeanUtils.copyBean(environmentInfoDTO, environment); EnvironmentBlob environmentBlob = environmentBlobMapper.selectByPrimaryKey(environmentId); if (environmentBlob == null) { environmentInfoDTO.setConfig(new EnvironmentConfig()); @@ -284,6 +285,9 @@ public class EnvironmentService { environmentMapper.updateByPrimaryKeySelective(environment); EnvironmentBlob environmentBlob = new EnvironmentBlob(); environmentBlob.setId(environment.getId()); + if (request.getConfig() == null) { + request.setConfig(new EnvironmentConfig()); + } environmentBlob.setConfig(JSON.toJSONBytes(request.getConfig())); environmentBlobMapper.updateByPrimaryKeySelective(environmentBlob); uploadFileToMinio(sslFiles, environment); diff --git a/backend/services/project-management/src/test/java/io/metersphere/project/controller/EnvironmentControllerTests.java b/backend/services/project-management/src/test/java/io/metersphere/project/controller/EnvironmentControllerTests.java index ce35a392a5..77404642a5 100644 --- a/backend/services/project-management/src/test/java/io/metersphere/project/controller/EnvironmentControllerTests.java +++ b/backend/services/project-management/src/test/java/io/metersphere/project/controller/EnvironmentControllerTests.java @@ -443,7 +443,6 @@ public class EnvironmentControllerTests extends BaseTest { EnvironmentRequest request = new EnvironmentRequest(); request.setProjectId(DEFAULT_PROJECT_ID); request.setName("name"); - request.setConfig(new EnvironmentConfig()); MultiValueMap paramMap = new LinkedMultiValueMap<>(); paramMap.add("request", JSON.toJSONString(request)); MvcResult mvcResult = this.requestMultipartWithOkAndReturn(add, paramMap); @@ -773,11 +772,6 @@ public class EnvironmentControllerTests extends BaseTest { request.setConfig(new EnvironmentConfig()); paramMap.set("request", JSON.toJSONString(request)); requestMultipart(add, paramMap, ERROR_REQUEST_MATCHER); - //配置为空 - request.setConfig(null); - paramMap.set("request", JSON.toJSONString(request)); - requestMultipart(add, paramMap, BAD_REQUEST_MATCHER); - } @@ -903,6 +897,17 @@ public class EnvironmentControllerTests extends BaseTest { Assertions.assertNotNull(environment); Assertions.assertEquals(response.getId(), environment.getId()); Assertions.assertEquals(response.getName(), environment.getName()); + request.setName("test-edit-name"); + request.setConfig(null); + paramMap.clear(); + paramMap.set("request", JSON.toJSONString(request)); + mvcResult = requestMultipartWithOkAndReturn(update, paramMap); + response = parseObjectFromMvcResult(mvcResult, Environment.class); + Assertions.assertNotNull(response); + environment = environmentMapper.selectByPrimaryKey(response.getId()); + Assertions.assertNotNull(environment); + Assertions.assertEquals(response.getId(), environment.getId()); + Assertions.assertEquals(response.getName(), environment.getName()); example = new EnvironmentExample(); example.createCriteria().andProjectIdEqualTo(DEFAULT_PROJECT_ID).andNameEqualTo("commonParams"); @@ -942,14 +947,14 @@ public class EnvironmentControllerTests extends BaseTest { EnvironmentRequest request = new EnvironmentRequest(); request.setId("environmentId2"); request.setProjectId(DEFAULT_PROJECT_ID); - request.setName("name"); + request.setName("test-edit-name"); request.setConfig(new EnvironmentConfig()); MultiValueMap paramMap = new LinkedMultiValueMap<>(); paramMap.set("request", JSON.toJSONString(request)); requestMultipart(update, paramMap, ERROR_REQUEST_MATCHER); //重名 EnvironmentExample example = new EnvironmentExample(); - example.createCriteria().andProjectIdEqualTo(DEFAULT_PROJECT_ID).andNameEqualTo("name"); + example.createCriteria().andProjectIdEqualTo(DEFAULT_PROJECT_ID).andNameEqualTo("test-edit-name"); List environments = environmentMapper.selectByExample(example); String id = environments.getFirst().getId(); request = new EnvironmentRequest(); @@ -959,15 +964,6 @@ public class EnvironmentControllerTests extends BaseTest { request.setConfig(new EnvironmentConfig()); paramMap.set("request", JSON.toJSONString(request)); requestMultipart(update, paramMap, ERROR_REQUEST_MATCHER); - //配置为空 - request = new EnvironmentRequest(); - request.setId("environmentId2"); - request.setProjectId(DEFAULT_PROJECT_ID); - request.setName("name"); - request.setConfig(null); - paramMap = new LinkedMultiValueMap<>(); - paramMap.set("request", JSON.toJSONString(request)); - requestMultipart(update, paramMap, BAD_REQUEST_MATCHER); } @@ -994,7 +990,7 @@ public class EnvironmentControllerTests extends BaseTest { public void testDeleteSuccess() throws Exception { //校验参数 EnvironmentExample example = new EnvironmentExample(); - example.createCriteria().andProjectIdEqualTo(DEFAULT_PROJECT_ID).andNameEqualTo("name"); + example.createCriteria().andProjectIdEqualTo(DEFAULT_PROJECT_ID).andNameEqualTo("test-edit-name"); List environments = environmentMapper.selectByExample(example); String id = environments.getFirst().getId(); this.requestGet(delete + id);