refactor(接口测试): 优化接口多协议或空协议
This commit is contained in:
parent
fde8326fd2
commit
1ac6f63e56
|
@ -372,9 +372,6 @@ public class ApiDefinitionMockService {
|
|||
}
|
||||
|
||||
public void batchDelete(ApiTestCaseBatchRequest request, String userId) {
|
||||
if (CollectionUtils.isEmpty(request.getProtocols())) {
|
||||
return;
|
||||
}
|
||||
List<String> ids = doSelectIds(request);
|
||||
if (CollectionUtils.isNotEmpty(ids)) {
|
||||
SubListUtils.dealForSubList(ids, 500, subList -> deleteResourceByIds(subList, request.getProjectId(), userId));
|
||||
|
@ -400,9 +397,7 @@ public class ApiDefinitionMockService {
|
|||
}
|
||||
|
||||
public void batchEdit(ApiMockBatchEditRequest request, String userId) {
|
||||
if (CollectionUtils.isEmpty(request.getProtocols())) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<String> ids = doSelectIds(request);
|
||||
if (CollectionUtils.isNotEmpty(ids)) {
|
||||
SubListUtils.dealForSubList(ids, 500, subList -> batchEditByType(request, subList, userId, request.getProjectId()));
|
||||
|
@ -468,7 +463,7 @@ public class ApiDefinitionMockService {
|
|||
}
|
||||
|
||||
public List<String> doSelectIds(ApiTestCaseBatchRequest request) {
|
||||
if (request.isSelectAll()) {
|
||||
if (request.isSelectAll() && CollectionUtils.isNotEmpty(request.getProtocols())) {
|
||||
List<String> ids = extApiDefinitionMockMapper.getIds(request);
|
||||
if (CollectionUtils.isNotEmpty(request.getExcludeIds())) {
|
||||
ids.removeAll(request.getExcludeIds());
|
||||
|
|
|
@ -136,7 +136,7 @@ public class ApiDefinitionService extends MoveNodeService {
|
|||
private ApiDefinitionNoticeService apiDefinitionNoticeService;
|
||||
|
||||
public List<ApiDefinitionDTO> getApiDefinitionPage(ApiDefinitionPageRequest request, String userId) {
|
||||
if (CollectionUtils.isNotEmpty(request.getProtocols())) {
|
||||
if (CollectionUtils.isEmpty(request.getProtocols())) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
CustomFieldUtils.setBaseQueryRequestCustomMultipleFields(request, userId);
|
||||
|
@ -297,9 +297,6 @@ public class ApiDefinitionService extends MoveNodeService {
|
|||
|
||||
public void batchUpdate(ApiDefinitionBatchUpdateRequest request, String userId) {
|
||||
ProjectService.checkResourceExist(request.getProjectId());
|
||||
if (CollectionUtils.isEmpty(request.getProtocols())) {
|
||||
return;
|
||||
}
|
||||
List<String> ids = getBatchApiIds(request, request.getProjectId(), request.getProtocols(), false, userId);
|
||||
// 记录更新前的数据
|
||||
apiDefinitionLogService.batchUpdateLog(ids, userId, request.getProjectId());
|
||||
|
@ -436,9 +433,6 @@ public class ApiDefinitionService extends MoveNodeService {
|
|||
}
|
||||
|
||||
public void batchDeleteToGc(ApiDefinitionBatchDeleteRequest request, String userId) {
|
||||
if (CollectionUtils.isEmpty(request.getProtocols())) {
|
||||
return;
|
||||
}
|
||||
List<String> ids = getBatchApiIds(request, request.getProjectId(), request.getProtocols(), false, userId);
|
||||
if (CollectionUtils.isNotEmpty(ids)) {
|
||||
handleDeleteApiDefinition(ids, request.getDeleteAllVersion(), request.getProjectId(), userId, true);
|
||||
|
@ -446,9 +440,6 @@ public class ApiDefinitionService extends MoveNodeService {
|
|||
}
|
||||
|
||||
public void batchMove(ApiDefinitionBatchMoveRequest request, String userId) {
|
||||
if (CollectionUtils.isEmpty(request.getProtocols())) {
|
||||
return;
|
||||
}
|
||||
List<String> ids = getBatchApiIds(request, request.getProjectId(), request.getProtocols(), false, userId);
|
||||
if (!ids.isEmpty()) {
|
||||
// 移动接口所有版本引用的数据
|
||||
|
@ -830,9 +821,6 @@ public class ApiDefinitionService extends MoveNodeService {
|
|||
}
|
||||
|
||||
public void batchRecover(ApiDefinitionBatchRequest request, String userId) {
|
||||
if (CollectionUtils.isEmpty(request.getProtocols())) {
|
||||
return;
|
||||
}
|
||||
List<String> ids = getBatchApiIds(request, request.getProjectId(), request.getProtocols(), true, userId);
|
||||
if (CollectionUtils.isNotEmpty(ids)) {
|
||||
handleRecoverApiDefinition(ids, userId, request.getProjectId(), true);
|
||||
|
@ -840,9 +828,6 @@ public class ApiDefinitionService extends MoveNodeService {
|
|||
}
|
||||
|
||||
public void batchDelete(ApiDefinitionBatchRequest request, String userId) {
|
||||
if (CollectionUtils.isEmpty(request.getProtocols())) {
|
||||
return;
|
||||
}
|
||||
List<String> ids = getBatchApiIds(request, request.getProjectId(), request.getProtocols(), true, userId);
|
||||
if (CollectionUtils.isNotEmpty(ids)) {
|
||||
handleTrashDelApiDefinition(ids, userId, request.getProjectId(), true);
|
||||
|
@ -897,8 +882,7 @@ public class ApiDefinitionService extends MoveNodeService {
|
|||
// 获取批量操作选中的ID
|
||||
public <T> List<String> getBatchApiIds(T dto, String projectId, List<String> protocols, boolean deleted, String userId) {
|
||||
TableBatchProcessDTO request = (TableBatchProcessDTO) dto;
|
||||
if (request.isSelectAll()) {
|
||||
// 全选
|
||||
if (request.isSelectAll() && CollectionUtils.isNotEmpty(protocols)) {
|
||||
CustomFieldUtils.setBaseQueryRequestCustomMultipleFields(request.getCondition(), userId);
|
||||
List<String> ids = extApiDefinitionMapper.getIds(request, projectId, protocols, deleted);
|
||||
if (CollectionUtils.isNotEmpty(request.getExcludeIds())) {
|
||||
|
@ -906,6 +890,7 @@ public class ApiDefinitionService extends MoveNodeService {
|
|||
}
|
||||
return ids;
|
||||
} else {
|
||||
request.getSelectIds().removeAll(request.getExcludeIds());
|
||||
return request.getSelectIds();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,9 +29,7 @@ public class ApiTestCaseRecoverService {
|
|||
private ApiTestCaseService apiTestCaseService;
|
||||
|
||||
public void batchRecover(ApiTestCaseBatchRequest request, String userId) {
|
||||
if (CollectionUtils.isEmpty(request.getProtocols())) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<String> ids = doSelectIds(request, true);
|
||||
if (CollectionUtils.isEmpty(ids)) {
|
||||
return;
|
||||
|
|
|
@ -382,9 +382,7 @@ public class ApiTestCaseService extends MoveNodeService {
|
|||
}
|
||||
|
||||
public void batchDelete(ApiTestCaseBatchRequest request, String userId) {
|
||||
if (CollectionUtils.isEmpty(request.getProtocols())) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<String> ids = doSelectIds(request, true);
|
||||
if (CollectionUtils.isEmpty(ids)) {
|
||||
return;
|
||||
|
@ -424,7 +422,7 @@ public class ApiTestCaseService extends MoveNodeService {
|
|||
}
|
||||
|
||||
public List<String> doSelectIds(ApiTestCaseBatchRequest request, boolean deleted) {
|
||||
if (request.isSelectAll()) {
|
||||
if (request.isSelectAll() && CollectionUtils.isNotEmpty(request.getProtocols())) {
|
||||
List<String> ids = extApiTestCaseMapper.getIds(request, deleted);
|
||||
if (CollectionUtils.isNotEmpty(request.getExcludeIds())) {
|
||||
ids.removeAll(request.getExcludeIds());
|
||||
|
@ -437,9 +435,6 @@ public class ApiTestCaseService extends MoveNodeService {
|
|||
}
|
||||
|
||||
public void batchMoveGc(ApiTestCaseBatchRequest request, String userId) {
|
||||
if (CollectionUtils.isEmpty(request.getProtocols())) {
|
||||
return;
|
||||
}
|
||||
List<String> ids = doSelectIds(request, false);
|
||||
batchDeleteToGc(ids, userId, request.getProjectId(), true);
|
||||
}
|
||||
|
@ -462,9 +457,7 @@ public class ApiTestCaseService extends MoveNodeService {
|
|||
}
|
||||
|
||||
public void batchEdit(ApiCaseBatchEditRequest request, String userId) {
|
||||
if (CollectionUtils.isEmpty(request.getProtocols())) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<String> ids = doSelectIds(request, false);
|
||||
if (CollectionUtils.isEmpty(ids)) {
|
||||
return;
|
||||
|
|
|
@ -2154,10 +2154,7 @@ public class ApiScenarioService extends MoveNodeService {
|
|||
}
|
||||
|
||||
private void getCaseStep(ApiScenarioSystemRequest request, ScenarioSystemRequest caseRequest, List<ApiScenarioStepDTO> steps) {
|
||||
if (CollectionUtils.isEmpty(caseRequest.getProtocols())) {
|
||||
return;
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(caseRequest.getModuleIds())) {
|
||||
if (CollectionUtils.isNotEmpty(caseRequest.getModuleIds()) && CollectionUtils.isNotEmpty(caseRequest.getProtocols())) {
|
||||
caseRequest.getSelectedIds().addAll(extApiTestCaseMapper.getIdsByModules(caseRequest));
|
||||
}
|
||||
caseRequest.getSelectedIds().removeAll(caseRequest.getUnselectedIds());
|
||||
|
@ -2181,10 +2178,7 @@ public class ApiScenarioService extends MoveNodeService {
|
|||
}
|
||||
|
||||
private void getApiStep(ApiScenarioSystemRequest request, ScenarioSystemRequest apiRequest, List<ApiScenarioStepDTO> steps) {
|
||||
if (CollectionUtils.isEmpty(apiRequest.getProtocols())) {
|
||||
return;
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(apiRequest.getModuleIds())) {
|
||||
if (CollectionUtils.isNotEmpty(apiRequest.getModuleIds()) && CollectionUtils.isNotEmpty(apiRequest.getProtocols())) {
|
||||
apiRequest.getSelectedIds().addAll(extApiDefinitionMapper.getIdsByModules(apiRequest));
|
||||
}
|
||||
apiRequest.getSelectedIds().removeAll(apiRequest.getUnselectedIds());
|
||||
|
|
|
@ -817,12 +817,6 @@ public class ApiDefinitionControllerTests extends BaseTest {
|
|||
request.setSelectAll(false);
|
||||
request.setProtocols(List.of("HTTP"));
|
||||
this.requestPostWithOkAndReturn(BATCH_MOVE, request);
|
||||
// @@校验日志
|
||||
|
||||
String[] ids = {"1001", "1002", "1005"};
|
||||
for (String id : ids) {
|
||||
checkLogModelList.add(new CheckLogModel(id, OperationLogType.UPDATE, BATCH_MOVE));
|
||||
}
|
||||
|
||||
// 移动全部 条件为关键字为st-6的数据
|
||||
request.setSelectAll(true);
|
||||
|
@ -831,7 +825,7 @@ public class ApiDefinitionControllerTests extends BaseTest {
|
|||
request.setCondition(baseCondition);
|
||||
this.requestPostWithOkAndReturn(BATCH_MOVE, request);
|
||||
// @@校验日志
|
||||
checkLogModelList.add(new CheckLogModel("1006", OperationLogType.UPDATE, BATCH_MOVE));
|
||||
//checkLogModelList.add(new CheckLogModel("1006", OperationLogType.UPDATE, BATCH_MOVE));
|
||||
// @@校验权限
|
||||
requestPostPermissionTest(PermissionConstants.PROJECT_API_DEFINITION_UPDATE, BATCH_MOVE, request);
|
||||
}
|
||||
|
|
|
@ -503,7 +503,7 @@
|
|||
onBeforeOk: async () => {
|
||||
try {
|
||||
await loadRealMap.value[props.group].delete(props.moduleType, record?.id as string);
|
||||
Message.success(t('project.taskCenter.delScheduleSuccess'));
|
||||
Message.success(t('project.basicInfo.deleted'));
|
||||
initData();
|
||||
} catch (error) {
|
||||
// eslint-disable-next-line no-console
|
||||
|
|
|
@ -41,8 +41,8 @@ export default {
|
|||
'project.taskCenter.delScheduleSuccess': 'Delete scheduled task successfully',
|
||||
'project.taskCenter.delSchedule.tip':
|
||||
'Deleting the scheduled task will cause the task to stop. Do you want to continue?',
|
||||
'project.taskCenter.enableScheduleSuccess': 'Enable scheduled task successfully',
|
||||
'project.taskCenter.disableScheduleSuccess': 'Disable scheduled task successfully',
|
||||
'project.taskCenter.enableScheduleSuccess': 'Enable successfully',
|
||||
'project.taskCenter.disableScheduleSuccess': 'Disable successfully',
|
||||
'project.belongProject': 'Project',
|
||||
'project.belongOrganization': 'Organization',
|
||||
'project.taskCenter.batchEnable': 'Batch enable',
|
||||
|
|
|
@ -39,8 +39,8 @@ export default {
|
|||
'project.taskCenter.delSchedule': '确定删除定时任务吗?',
|
||||
'project.taskCenter.delScheduleSuccess': '删除定时任务成功',
|
||||
'project.taskCenter.delSchedule.tip': '删除定时任务会导致任务停止,是否继续?',
|
||||
'project.taskCenter.enableScheduleSuccess': '启用定时任务成功',
|
||||
'project.taskCenter.disableScheduleSuccess': '关闭定时任务成功',
|
||||
'project.taskCenter.enableScheduleSuccess': '已开启',
|
||||
'project.taskCenter.disableScheduleSuccess': '已关闭',
|
||||
'project.belongProject': '所属项目',
|
||||
'project.belongOrganization': '所属组织',
|
||||
'project.taskCenter.batchEnable': '批量开启',
|
||||
|
|
Loading…
Reference in New Issue