refactor(项目管理): 环境管理修改参数
This commit is contained in:
parent
8f4ddbbe87
commit
3ced8a7c18
|
@ -16,12 +16,6 @@ public class ApiCaseReportDTO implements Serializable {
|
||||||
@Schema(description = "任务名称")
|
@Schema(description = "任务名称")
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
@Schema(description = "用例id")
|
|
||||||
private String resourceId;
|
|
||||||
|
|
||||||
@Schema(description = "测试计划id")
|
|
||||||
private String testPlanId;
|
|
||||||
|
|
||||||
@Schema(description = "操作人")
|
@Schema(description = "操作人")
|
||||||
private String operationUser;
|
private String operationUser;
|
||||||
@Schema(description = "操作人id")
|
@Schema(description = "操作人id")
|
||||||
|
@ -36,9 +30,6 @@ public class ApiCaseReportDTO implements Serializable {
|
||||||
@Schema(description = "执行方式")
|
@Schema(description = "执行方式")
|
||||||
private String triggerMode;
|
private String triggerMode;
|
||||||
|
|
||||||
@Schema(description = "是否是测试计划执行的用例")
|
|
||||||
private boolean testPlan;
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
}
|
}
|
|
@ -235,8 +235,7 @@
|
||||||
api_report.start_time,
|
api_report.start_time,
|
||||||
api_report.create_user,
|
api_report.create_user,
|
||||||
api_report.trigger_mode,
|
api_report.trigger_mode,
|
||||||
api_report.test_plan_id,
|
api_report.test_plan_id
|
||||||
api_report.resource_id
|
|
||||||
from api_report where
|
from api_report where
|
||||||
<if test="request.id != null and request.id != ''">
|
<if test="request.id != null and request.id != ''">
|
||||||
api_report.resource_id = #{request.id}
|
api_report.resource_id = #{request.id}
|
||||||
|
|
|
@ -559,7 +559,6 @@ public class ApiTestCaseService {
|
||||||
apiReport.setOperationUser(userMap.get(apiReport.getCreateUser()));
|
apiReport.setOperationUser(userMap.get(apiReport.getCreateUser()));
|
||||||
Date date = new Date(apiReport.getStartTime());
|
Date date = new Date(apiReport.getStartTime());
|
||||||
apiReport.setNum(sdf.format(date));
|
apiReport.setNum(sdf.format(date));
|
||||||
apiReport.setTestPlan(!StringUtils.equals(apiReport.getTestPlanId(), "NONE"));
|
|
||||||
});
|
});
|
||||||
return executeList;
|
return executeList;
|
||||||
}
|
}
|
||||||
|
|
|
@ -608,9 +608,6 @@ public class ApiTestCaseControllerTests extends BaseTest {
|
||||||
Pager<?> returnPager = parseObjectFromMvcResult(mvcResult, Pager.class);
|
Pager<?> returnPager = parseObjectFromMvcResult(mvcResult, Pager.class);
|
||||||
//返回值不为空
|
//返回值不为空
|
||||||
Assertions.assertNotNull(returnPager);
|
Assertions.assertNotNull(returnPager);
|
||||||
List<ApiCaseReportDTO> reportDTOS = JSON.parseArray(JSON.toJSONString(returnPager.getList()), ApiCaseReportDTO.class);
|
|
||||||
reportDTOS.forEach(reportDTO -> Assertions.assertEquals(reportDTO.getResourceId(), first.getId()));
|
|
||||||
|
|
||||||
request.setFilter(new HashMap<>() {{
|
request.setFilter(new HashMap<>() {{
|
||||||
put("status", List.of(ApiReportStatus.SUCCESS.name()));
|
put("status", List.of(ApiReportStatus.SUCCESS.name()));
|
||||||
}});
|
}});
|
||||||
|
@ -619,7 +616,7 @@ public class ApiTestCaseControllerTests extends BaseTest {
|
||||||
//返回值不为空
|
//返回值不为空
|
||||||
Assertions.assertNotNull(returnPager);
|
Assertions.assertNotNull(returnPager);
|
||||||
Assertions.assertTrue(((List<ApiReport>) returnPager.getList()).size() <= request.getPageSize());
|
Assertions.assertTrue(((List<ApiReport>) returnPager.getList()).size() <= request.getPageSize());
|
||||||
reportDTOS = JSON.parseArray(JSON.toJSONString(returnPager.getList()), ApiCaseReportDTO.class);
|
List<ApiCaseReportDTO> reportDTOS = JSON.parseArray(JSON.toJSONString(returnPager.getList()), ApiCaseReportDTO.class);
|
||||||
reportDTOS.forEach(apiReport -> {
|
reportDTOS.forEach(apiReport -> {
|
||||||
Assertions.assertEquals(apiReport.getStatus(), ApiReportStatus.SUCCESS.name());
|
Assertions.assertEquals(apiReport.getStatus(), ApiReportStatus.SUCCESS.name());
|
||||||
});
|
});
|
||||||
|
|
|
@ -4,7 +4,6 @@ import io.metersphere.validation.groups.Created;
|
||||||
import io.metersphere.validation.groups.Updated;
|
import io.metersphere.validation.groups.Updated;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import jakarta.validation.constraints.NotBlank;
|
import jakarta.validation.constraints.NotBlank;
|
||||||
import jakarta.validation.constraints.NotNull;
|
|
||||||
import jakarta.validation.constraints.Size;
|
import jakarta.validation.constraints.Size;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
@ -27,7 +26,6 @@ public class EnvironmentRequest implements Serializable {
|
||||||
@NotBlank(message = "{environment_name_is_null}", groups = {Created.class, Updated.class})
|
@NotBlank(message = "{environment_name_is_null}", groups = {Created.class, Updated.class})
|
||||||
private String name;
|
private String name;
|
||||||
@Schema(description = "环境配置")
|
@Schema(description = "环境配置")
|
||||||
@NotNull(message = "{environment_config_is_null}", groups = {Created.class, Updated.class})
|
|
||||||
private EnvironmentConfig config;
|
private EnvironmentConfig config;
|
||||||
@Schema(description = "是否是mock环境")
|
@Schema(description = "是否是mock环境")
|
||||||
private Boolean mock;
|
private Boolean mock;
|
||||||
|
|
|
@ -17,10 +17,7 @@ import io.metersphere.sdk.file.FileRequest;
|
||||||
import io.metersphere.sdk.file.MinioRepository;
|
import io.metersphere.sdk.file.MinioRepository;
|
||||||
import io.metersphere.sdk.mapper.EnvironmentBlobMapper;
|
import io.metersphere.sdk.mapper.EnvironmentBlobMapper;
|
||||||
import io.metersphere.sdk.mapper.EnvironmentMapper;
|
import io.metersphere.sdk.mapper.EnvironmentMapper;
|
||||||
import io.metersphere.sdk.util.CommonBeanFactory;
|
import io.metersphere.sdk.util.*;
|
||||||
import io.metersphere.sdk.util.JSON;
|
|
||||||
import io.metersphere.sdk.util.LogUtils;
|
|
||||||
import io.metersphere.sdk.util.Translator;
|
|
||||||
import io.metersphere.system.dto.sdk.BaseSystemConfigDTO;
|
import io.metersphere.system.dto.sdk.BaseSystemConfigDTO;
|
||||||
import io.metersphere.system.dto.sdk.OptionDTO;
|
import io.metersphere.system.dto.sdk.OptionDTO;
|
||||||
import io.metersphere.system.dto.sdk.request.PosRequest;
|
import io.metersphere.system.dto.sdk.request.PosRequest;
|
||||||
|
@ -131,6 +128,9 @@ public class EnvironmentService {
|
||||||
request.setId(environment.getId());
|
request.setId(environment.getId());
|
||||||
EnvironmentBlob environmentBlob = new EnvironmentBlob();
|
EnvironmentBlob environmentBlob = new EnvironmentBlob();
|
||||||
environmentBlob.setId(environment.getId());
|
environmentBlob.setId(environment.getId());
|
||||||
|
if (request.getConfig() == null) {
|
||||||
|
request.setConfig(new EnvironmentConfig());
|
||||||
|
}
|
||||||
environmentBlob.setConfig(JSON.toJSONBytes(request.getConfig()));
|
environmentBlob.setConfig(JSON.toJSONBytes(request.getConfig()));
|
||||||
environmentBlobMapper.insert(environmentBlob);
|
environmentBlobMapper.insert(environmentBlob);
|
||||||
uploadFileToMinio(sslFiles, environment);
|
uploadFileToMinio(sslFiles, environment);
|
||||||
|
@ -163,6 +163,7 @@ public class EnvironmentService {
|
||||||
environmentInfoDTO.setName(environment.getName());
|
environmentInfoDTO.setName(environment.getName());
|
||||||
environmentInfoDTO.setId(environment.getId());
|
environmentInfoDTO.setId(environment.getId());
|
||||||
environmentInfoDTO.setMock(environment.getMock());
|
environmentInfoDTO.setMock(environment.getMock());
|
||||||
|
BeanUtils.copyBean(environmentInfoDTO, environment);
|
||||||
EnvironmentBlob environmentBlob = environmentBlobMapper.selectByPrimaryKey(environmentId);
|
EnvironmentBlob environmentBlob = environmentBlobMapper.selectByPrimaryKey(environmentId);
|
||||||
if (environmentBlob == null) {
|
if (environmentBlob == null) {
|
||||||
environmentInfoDTO.setConfig(new EnvironmentConfig());
|
environmentInfoDTO.setConfig(new EnvironmentConfig());
|
||||||
|
@ -284,6 +285,9 @@ public class EnvironmentService {
|
||||||
environmentMapper.updateByPrimaryKeySelective(environment);
|
environmentMapper.updateByPrimaryKeySelective(environment);
|
||||||
EnvironmentBlob environmentBlob = new EnvironmentBlob();
|
EnvironmentBlob environmentBlob = new EnvironmentBlob();
|
||||||
environmentBlob.setId(environment.getId());
|
environmentBlob.setId(environment.getId());
|
||||||
|
if (request.getConfig() == null) {
|
||||||
|
request.setConfig(new EnvironmentConfig());
|
||||||
|
}
|
||||||
environmentBlob.setConfig(JSON.toJSONBytes(request.getConfig()));
|
environmentBlob.setConfig(JSON.toJSONBytes(request.getConfig()));
|
||||||
environmentBlobMapper.updateByPrimaryKeySelective(environmentBlob);
|
environmentBlobMapper.updateByPrimaryKeySelective(environmentBlob);
|
||||||
uploadFileToMinio(sslFiles, environment);
|
uploadFileToMinio(sslFiles, environment);
|
||||||
|
|
|
@ -443,7 +443,6 @@ public class EnvironmentControllerTests extends BaseTest {
|
||||||
EnvironmentRequest request = new EnvironmentRequest();
|
EnvironmentRequest request = new EnvironmentRequest();
|
||||||
request.setProjectId(DEFAULT_PROJECT_ID);
|
request.setProjectId(DEFAULT_PROJECT_ID);
|
||||||
request.setName("name");
|
request.setName("name");
|
||||||
request.setConfig(new EnvironmentConfig());
|
|
||||||
MultiValueMap<String, Object> paramMap = new LinkedMultiValueMap<>();
|
MultiValueMap<String, Object> paramMap = new LinkedMultiValueMap<>();
|
||||||
paramMap.add("request", JSON.toJSONString(request));
|
paramMap.add("request", JSON.toJSONString(request));
|
||||||
MvcResult mvcResult = this.requestMultipartWithOkAndReturn(add, paramMap);
|
MvcResult mvcResult = this.requestMultipartWithOkAndReturn(add, paramMap);
|
||||||
|
@ -773,11 +772,6 @@ public class EnvironmentControllerTests extends BaseTest {
|
||||||
request.setConfig(new EnvironmentConfig());
|
request.setConfig(new EnvironmentConfig());
|
||||||
paramMap.set("request", JSON.toJSONString(request));
|
paramMap.set("request", JSON.toJSONString(request));
|
||||||
requestMultipart(add, paramMap, ERROR_REQUEST_MATCHER);
|
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.assertNotNull(environment);
|
||||||
Assertions.assertEquals(response.getId(), environment.getId());
|
Assertions.assertEquals(response.getId(), environment.getId());
|
||||||
Assertions.assertEquals(response.getName(), environment.getName());
|
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 = new EnvironmentExample();
|
||||||
example.createCriteria().andProjectIdEqualTo(DEFAULT_PROJECT_ID).andNameEqualTo("commonParams");
|
example.createCriteria().andProjectIdEqualTo(DEFAULT_PROJECT_ID).andNameEqualTo("commonParams");
|
||||||
|
@ -942,14 +947,14 @@ public class EnvironmentControllerTests extends BaseTest {
|
||||||
EnvironmentRequest request = new EnvironmentRequest();
|
EnvironmentRequest request = new EnvironmentRequest();
|
||||||
request.setId("environmentId2");
|
request.setId("environmentId2");
|
||||||
request.setProjectId(DEFAULT_PROJECT_ID);
|
request.setProjectId(DEFAULT_PROJECT_ID);
|
||||||
request.setName("name");
|
request.setName("test-edit-name");
|
||||||
request.setConfig(new EnvironmentConfig());
|
request.setConfig(new EnvironmentConfig());
|
||||||
MultiValueMap<String, Object> paramMap = new LinkedMultiValueMap<>();
|
MultiValueMap<String, Object> paramMap = new LinkedMultiValueMap<>();
|
||||||
paramMap.set("request", JSON.toJSONString(request));
|
paramMap.set("request", JSON.toJSONString(request));
|
||||||
requestMultipart(update, paramMap, ERROR_REQUEST_MATCHER);
|
requestMultipart(update, paramMap, ERROR_REQUEST_MATCHER);
|
||||||
//重名
|
//重名
|
||||||
EnvironmentExample example = new EnvironmentExample();
|
EnvironmentExample example = new EnvironmentExample();
|
||||||
example.createCriteria().andProjectIdEqualTo(DEFAULT_PROJECT_ID).andNameEqualTo("name");
|
example.createCriteria().andProjectIdEqualTo(DEFAULT_PROJECT_ID).andNameEqualTo("test-edit-name");
|
||||||
List<Environment> environments = environmentMapper.selectByExample(example);
|
List<Environment> environments = environmentMapper.selectByExample(example);
|
||||||
String id = environments.getFirst().getId();
|
String id = environments.getFirst().getId();
|
||||||
request = new EnvironmentRequest();
|
request = new EnvironmentRequest();
|
||||||
|
@ -959,15 +964,6 @@ public class EnvironmentControllerTests extends BaseTest {
|
||||||
request.setConfig(new EnvironmentConfig());
|
request.setConfig(new EnvironmentConfig());
|
||||||
paramMap.set("request", JSON.toJSONString(request));
|
paramMap.set("request", JSON.toJSONString(request));
|
||||||
requestMultipart(update, paramMap, ERROR_REQUEST_MATCHER);
|
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 {
|
public void testDeleteSuccess() throws Exception {
|
||||||
//校验参数
|
//校验参数
|
||||||
EnvironmentExample example = new EnvironmentExample();
|
EnvironmentExample example = new EnvironmentExample();
|
||||||
example.createCriteria().andProjectIdEqualTo(DEFAULT_PROJECT_ID).andNameEqualTo("name");
|
example.createCriteria().andProjectIdEqualTo(DEFAULT_PROJECT_ID).andNameEqualTo("test-edit-name");
|
||||||
List<Environment> environments = environmentMapper.selectByExample(example);
|
List<Environment> environments = environmentMapper.selectByExample(example);
|
||||||
String id = environments.getFirst().getId();
|
String id = environments.getFirst().getId();
|
||||||
this.requestGet(delete + id);
|
this.requestGet(delete + id);
|
||||||
|
|
Loading…
Reference in New Issue