refactor(接口测试): 优化获取分享报告
This commit is contained in:
parent
e62149ae10
commit
ce28d64da4
|
@ -16,10 +16,13 @@ public class ApiReportShareDTO {
|
|||
private String lang;
|
||||
|
||||
private String projectId;
|
||||
|
||||
@Schema(description = "分享扩展数据 资源的id" ,requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
|
||||
@Schema(description = "分享扩展数据 资源的id", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private String reportId;
|
||||
|
||||
@Schema(description = "分享链接是否被删")
|
||||
private Boolean deleted;
|
||||
private boolean deleted;
|
||||
|
||||
@Schema(description = "分享链接是否过期")
|
||||
private boolean expired;
|
||||
}
|
||||
|
|
|
@ -128,19 +128,30 @@ public class ApiReportShareService {
|
|||
}
|
||||
|
||||
public ApiReportShareDTO get(String id) {
|
||||
ShareInfo shareInfo = checkResource(id);
|
||||
ApiReportShareDTO dto = new ApiReportShareDTO();
|
||||
ShareInfo shareInfo = shareInfoMapper.selectByPrimaryKey(id);
|
||||
if (shareInfo == null) {
|
||||
dto.setExpired(true);
|
||||
return dto;
|
||||
}
|
||||
BeanUtils.copyBean(dto, shareInfo);
|
||||
dto.setReportId(new String(shareInfo.getCustomData()));
|
||||
//检查id是否存在
|
||||
dto.setDeleted(false);
|
||||
dto.setDeleted(true);
|
||||
ApiReport apiReport = apiReportMapper.selectByPrimaryKey(dto.getReportId());
|
||||
if (apiReport != null && BooleanUtils.isTrue(apiReport.getDeleted())) {
|
||||
dto.setDeleted(true);
|
||||
if (apiReport != null && BooleanUtils.isFalse(apiReport.getDeleted())) {
|
||||
dto.setDeleted(false);
|
||||
} else {
|
||||
ApiScenarioReport result = apiScenarioReportMapper.selectByPrimaryKey(dto.getReportId());
|
||||
if (result != null && BooleanUtils.isTrue(result.getDeleted())) {
|
||||
dto.setDeleted(true);
|
||||
if (result != null && BooleanUtils.isFalse(result.getDeleted())) {
|
||||
dto.setDeleted(false);
|
||||
}
|
||||
}
|
||||
if (BooleanUtils.isFalse(dto.isDeleted())) {
|
||||
try {
|
||||
validateExpired(shareInfo);
|
||||
} catch (Exception e) {
|
||||
dto.setExpired(true);
|
||||
}
|
||||
}
|
||||
return dto;
|
||||
|
|
|
@ -421,7 +421,7 @@ public class ApiReportControllerTests extends BaseTest {
|
|||
|
||||
mockMvc.perform(getRequestBuilder("/api/report/share/get/" + "test"))
|
||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
|
||||
.andExpect(status().is5xxServerError());
|
||||
.andExpect(status().isOk());
|
||||
|
||||
mvcResult = this.requestGetWithOk(BASIC + "/share/detail/" + shareId + "/" + "test-report-id" + "/" + "test-report-step-id1")
|
||||
.andReturn();
|
||||
|
@ -436,6 +436,16 @@ public class ApiReportControllerTests extends BaseTest {
|
|||
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
|
||||
.andExpect(status().is5xxServerError());
|
||||
|
||||
mvcResult = responsePost("/api/report/share/gen", shareInfo);
|
||||
shareInfoDTO = parseObjectFromMvcResult(mvcResult, ShareInfoDTO.class);
|
||||
shareId = shareInfoDTO.getId();
|
||||
shareInfo1 = shareInfoMapper.selectByPrimaryKey(shareId);
|
||||
shareInfo1.setUpdateTime(1702950953000L);
|
||||
shareInfoMapper.updateByPrimaryKey(shareInfo1);
|
||||
|
||||
this.requestGetWithOk("/api/report/share/get/" + shareId)
|
||||
.andReturn();
|
||||
|
||||
//TODO 过期的校验 未完成 需要补充
|
||||
//项目当前设置了分享时间 并且没有过期
|
||||
|
||||
|
|
|
@ -474,7 +474,7 @@ public class ApiScenarioReportControllerTests extends BaseTest {
|
|||
|
||||
mockMvc.perform(getRequestBuilder("/api/report/share/get/" + "test"))
|
||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
|
||||
.andExpect(status().is5xxServerError());
|
||||
.andExpect(status().isOk());
|
||||
|
||||
mvcResult = this.requestGetWithOk(BASIC + "/share/detail/" + shareId + "/" + "test-scenario-report-id" + "/" + "test-scenario-report-step-id1")
|
||||
.andReturn();
|
||||
|
|
Loading…
Reference in New Issue