From 90dfd84a4ea92909010149117f8d7730b1f40443 Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Fri, 5 Jul 2024 14:49:58 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E8=8E=B7=E5=8F=96=E6=AD=A4=E9=9B=86?= =?UTF-8?q?=E5=90=88=E7=9A=84=E7=AC=AC=E4=B8=80=E4=B8=AA=E5=85=83=E7=B4=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/metersphere/sdk/util/XMLUtils.java | 2 +- .../processor/SqlProcessorConverter.java | 2 +- .../api/service/ApiFileResourceService.java | 4 +- .../api/service/ApiTaskCenterService.java | 3 - .../ApiDefinitionImportService.java | 2 +- .../definition/ApiDefinitionService.java | 2 +- .../ApiTestCaseBatchRunService.java | 2 +- .../controller/ApiDebugControllerTests.java | 6 +- .../ApiDebugModuleControllerTests.java | 2 +- .../ApiDefinitionControllerTests.java | 6 +- .../ApiDefinitionModuleControllerTests.java | 2 +- .../ApiScenarioControllerTests.java | 26 +++---- .../ApiScenarioModuleControllerTests.java | 2 +- .../controller/ApiShareControllerTests.java | 6 +- .../ApiTestCaseControllerTests.java | 10 +-- .../BaseFileManagementTestService.java | 2 +- .../bug/service/BugAttachmentLogService.java | 4 +- .../bug/service/BugAttachmentService.java | 8 +-- .../bug/service/BugLogService.java | 2 +- .../bug/service/BugScheduleServiceImpl.java | 4 +- .../metersphere/bug/service/BugService.java | 14 ++-- .../bug/service/BugStatusService.java | 2 +- .../BugAttachmentControllerTests.java | 4 +- .../controller/BugCommentControllerTests.java | 4 +- .../bug/controller/BugControllerTests.java | 10 +-- .../BugRelateCaseControllerTests.java | 2 +- .../provider/CaseReviewCaseProvider.java | 2 +- .../CaseReviewFunctionalCaseService.java | 18 ++--- .../FunctionalCaseAttachmentService.java | 10 +-- .../FunctionalCaseCustomFieldService.java | 2 +- .../service/FunctionalCaseDemandService.java | 4 +- .../service/FunctionalCaseService.java | 20 +++--- .../service/ReviewFunctionalCaseService.java | 6 +- .../controller/CaseReviewControllerTests.java | 72 +++++++++---------- ...seReviewFunctionalCaseControllerTests.java | 6 +- .../FunctionalCaseCommentControllerTests.java | 4 +- .../FunctionalCaseDemandControllerTests.java | 8 +-- .../FunctionalCaseMinderControllerTest.java | 10 +-- .../FunctionalCaseReviewControllerTests.java | 2 +- .../FunctionalTestCaseControllerTests.java | 2 +- .../ReviewFunctionalCaseControllerTests.java | 28 ++++---- .../dto/environment/ssl/KeyStoreConfig.java | 8 +-- .../service/MessageTaskLogService.java | 4 +- .../service/NoticeMessageTaskService.java | 8 +-- .../service/ProjectApplicationService.java | 10 +-- .../project/service/ProjectRobotService.java | 4 +- .../service/ProjectTemplateService.java | 2 +- .../service/ProjectUserRoleLogService.java | 2 +- .../service/ProjectUserRoleService.java | 2 +- .../controller/CreateEnvironmentTests.java | 2 +- .../EnvironmentControllerTests.java | 4 +- .../controller/FakeErrorControllerTests.java | 10 +-- .../NoticeMessageTaskControllerTests.java | 16 ++--- .../ProjectCustomFieldControllerTests.java | 12 ++-- .../ProjectMemberControllerTests.java | 2 +- .../ProjectRobotControllerTests.java | 4 +- .../ProjectTemplateControllerTests.java | 12 ++-- .../ProjectUserRoleControllerTests.java | 8 +-- .../FileManagementControllerTests.java | 8 +-- .../system/job/CleanUpReportJob.java | 4 +- .../system/log/aspect/OperationLogAspect.java | 4 +- .../system/service/ApiPluginService.java | 2 +- .../system/service/BaseStatusItemService.java | 2 +- .../system/service/BaseUserRoleService.java | 6 +- .../system/service/CommonProjectService.java | 4 +- .../system/service/MessageDetailService.java | 2 +- .../system/service/OrganizationService.java | 2 +- .../OrganizationUserRoleLogService.java | 2 +- .../service/OrganizationUserRoleService.java | 2 +- .../system/service/PlatformPluginService.java | 2 +- .../system/service/PluginLoadService.java | 2 +- .../service/SystemParameterService.java | 4 +- .../system/service/UserInviteService.java | 2 +- .../system/service/UserKeyService.java | 2 +- .../system/service/UserLoginService.java | 16 ++--- .../io/metersphere/system/base/BaseTest.java | 10 +-- .../CommonNoticeSendServiceTests.java | 4 +- .../GlobalUserRoleControllerTests.java | 2 +- ...GlobalUserRoleRelationControllerTests.java | 4 +- .../NotificationControllerTests.java | 2 +- .../OrganizationControllerTests.java | 2 +- ...rganizationCustomFieldControllerTests.java | 12 ++-- .../OrganizationProjectControllerTests.java | 20 +++--- ...zationStatusFlowSettingControllerTest.java | 4 +- .../OrganizationTemplateControllerTests.java | 6 +- .../OrganizationUserRoleControllerTests.java | 2 +- .../ServiceIntegrationControllerTests.java | 2 +- .../SystemOrganizationControllerTests.java | 14 ++-- .../SystemProjectControllerTests.java | 18 ++--- .../TestResourcePoolControllerTests.java | 4 +- .../UserApiKeysControllerTests.java | 10 +-- .../UserLocalConfigControllerTests.java | 6 +- .../user/PersonalControllerTests.java | 2 +- .../service/TestResourcePoolServiceTest.java | 4 +- .../plan/service/TestPlanApiCaseService.java | 2 +- .../service/TestPlanApiScenarioService.java | 2 +- .../TestPlanCollectionMinderService.java | 4 +- .../TestPlanFunctionalCaseService.java | 6 +- .../plan/service/TestPlanLogService.java | 2 +- .../io/metersphere/plan/utils/CountUtils.java | 2 +- .../TestPlanApiCaseControllerTests.java | 4 +- .../TestPlanApiScenarioControllerTests.java | 4 +- .../TestPlanBugControllerTests.java | 2 +- .../TestPlanCaseControllerTests.java | 2 +- ...stPlanCollectionMinderControllerTests.java | 2 +- .../TestPlanReportControllerTests.java | 4 +- .../plan/controller/TestPlanTests.java | 16 ++--- 107 files changed, 340 insertions(+), 343 deletions(-) diff --git a/backend/framework/sdk/src/main/java/io/metersphere/sdk/util/XMLUtils.java b/backend/framework/sdk/src/main/java/io/metersphere/sdk/util/XMLUtils.java index de0b1d375a..7fdd5e4c0e 100644 --- a/backend/framework/sdk/src/main/java/io/metersphere/sdk/util/XMLUtils.java +++ b/backend/framework/sdk/src/main/java/io/metersphere/sdk/util/XMLUtils.java @@ -131,7 +131,7 @@ public class XMLUtils { list.add(jsonObject); } if (list.size() == 1) { - result.put(node.getName(), list.get(0)); + result.put(node.getName(), list.getFirst()); } else { result.put(node.getName(), list); } diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/parser/jmeter/processor/SqlProcessorConverter.java b/backend/services/api-test/src/main/java/io/metersphere/api/parser/jmeter/processor/SqlProcessorConverter.java index 4bdc66a06e..9186327344 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/parser/jmeter/processor/SqlProcessorConverter.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/parser/jmeter/processor/SqlProcessorConverter.java @@ -120,7 +120,7 @@ public abstract class SqlProcessorConverter extends MsProcessorConverter kafkaTemplate; private static final String DEFAULT_SORT = "start_time desc"; - private final static String PROJECT_STOP = "/task/center/api/project/stop"; - private final static String ORG_STOP = "/task/center/api/org/stop"; - private final static String SYSTEM_STOP = "/task/center/api/system/stop"; /** * 任务中心实时任务列表-项目级 diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiDefinitionImportService.java b/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiDefinitionImportService.java index 0ef8e31ec4..cb292f536c 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiDefinitionImportService.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiDefinitionImportService.java @@ -182,7 +182,7 @@ public class ApiDefinitionImportService { applicationExample.createCriteria().andProjectIdEqualTo(request.getProjectId()).andTypeEqualTo("API_URL_REPEATABLE"); List projectApplications = projectApplicationMapper.selectByExample(applicationExample); if (CollectionUtils.isNotEmpty(projectApplications)) { - String typeValue = projectApplications.get(0).getTypeValue(); + String typeValue = projectApplications.getFirst().getTypeValue(); }*/ //过滤(一次只导入一个协议) List filterData = initData.stream().filter(t -> t.getProtocol().equals(request.getProtocol())).collect(Collectors.toList()); diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiDefinitionService.java b/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiDefinitionService.java index e7eb642b52..74e7516d22 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiDefinitionService.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiDefinitionService.java @@ -947,7 +947,7 @@ public class ApiDefinitionService extends MoveNodeService { if (ApiDefinitionDocType.ALL.name().equals(request.getType()) || ApiDefinitionDocType.MODULE.name().equals(request.getType())) { List list = extApiDefinitionMapper.listDoc(request); if (!list.isEmpty()) { - ApiDefinitionDTO first = list.get(0); + ApiDefinitionDTO first = list.getFirst(); handleBlob(first.getId(), first); String docTitle; if (ApiDefinitionDocType.ALL.name().equals(request.getType())) { diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiTestCaseBatchRunService.java b/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiTestCaseBatchRunService.java index 87fb7dd46e..cecfc93d07 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiTestCaseBatchRunService.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiTestCaseBatchRunService.java @@ -280,7 +280,7 @@ public class ApiTestCaseBatchRunService { reportId = IDGenerator.nextStr(); } else { // 独立报告,执行到当前任务时初始化报告 - reportId = initApiReport(runModeConfig, List.of(apiTestCase), queue.getUserId()).get(0).getApiReportId(); + reportId = initApiReport(runModeConfig, List.of(apiTestCase), queue.getUserId()).getFirst().getApiReportId(); } if (apiTestCase == null) { diff --git a/backend/services/api-test/src/test/java/io/metersphere/api/controller/ApiDebugControllerTests.java b/backend/services/api-test/src/test/java/io/metersphere/api/controller/ApiDebugControllerTests.java index 4f731294aa..594bdb72a8 100644 --- a/backend/services/api-test/src/test/java/io/metersphere/api/controller/ApiDebugControllerTests.java +++ b/backend/services/api-test/src/test/java/io/metersphere/api/controller/ApiDebugControllerTests.java @@ -381,7 +381,7 @@ public class ApiDebugControllerTests extends BaseTest { // 校验数据是否正确 List apiDebugList = getResultDataArray(mvcResult, ApiDebugSimpleDTO.class); Assertions.assertEquals(apiDebugList.size(), 2); - Assertions.assertEquals(apiDebugList.get(0), BeanUtils.copyBean(new ApiDebugSimpleDTO(), + Assertions.assertEquals(apiDebugList.getFirst(), BeanUtils.copyBean(new ApiDebugSimpleDTO(), apiDebugMapper.selectByPrimaryKey(addApiDebug.getId()))); Assertions.assertEquals(apiDebugList.get(1), BeanUtils.copyBean(new ApiDebugSimpleDTO(), apiDebugMapper.selectByPrimaryKey(anotherAddApiDebug.getId()))); @@ -468,7 +468,7 @@ public class ApiDebugControllerTests extends BaseTest { Assertions.assertFalse(testResourcePools.isEmpty()); ProjectTestResourcePool projectTestResourcePool = new ProjectTestResourcePool(); projectTestResourcePool.setProjectId(DEFAULT_PROJECT_ID); - projectTestResourcePool.setTestResourcePoolId(testResourcePools.get(0).getId()); + projectTestResourcePool.setTestResourcePoolId(testResourcePools.getFirst().getId()); projectTestResourcePoolMapper.insert(projectTestResourcePool); this.requestPost(DEBUG, request); projectTestResourcePoolMapper.deleteByExample(projectTestResourcePoolExample); @@ -753,7 +753,7 @@ public class ApiDebugControllerTests extends BaseTest { request.setModuleId("root"); request.setFileName("test-debug-file1"); request.setOriginalName("test-debug-file1.txt"); - request.setFileId(apiFileResources.get(0).getFileId()); + request.setFileId(apiFileResources.getFirst().getFileId()); this.requestPost(TRANSFER, request).andExpect(status().isOk()); } diff --git a/backend/services/api-test/src/test/java/io/metersphere/api/controller/ApiDebugModuleControllerTests.java b/backend/services/api-test/src/test/java/io/metersphere/api/controller/ApiDebugModuleControllerTests.java index 4b92d28f8c..3e3edb6890 100644 --- a/backend/services/api-test/src/test/java/io/metersphere/api/controller/ApiDebugModuleControllerTests.java +++ b/backend/services/api-test/src/test/java/io/metersphere/api/controller/ApiDebugModuleControllerTests.java @@ -409,7 +409,7 @@ public class ApiDebugModuleControllerTests extends BaseTest { List apiDebugModules = apiDebugModuleMapper.selectByExample(example); assert CollectionUtils.isNotEmpty(apiDebugModules); updateRequest = new ModuleUpdateRequest(); - updateRequest.setId(apiDebugModules.get(0).getId()); + updateRequest.setId(apiDebugModules.getFirst().getId()); updateRequest.setName("default-update-Project"); requestPostPermissionTest(PermissionConstants.PROJECT_API_DEBUG_UPDATE, URL_MODULE_UPDATE, updateRequest); } diff --git a/backend/services/api-test/src/test/java/io/metersphere/api/controller/ApiDefinitionControllerTests.java b/backend/services/api-test/src/test/java/io/metersphere/api/controller/ApiDefinitionControllerTests.java index 4368ee6c7a..552505358c 100644 --- a/backend/services/api-test/src/test/java/io/metersphere/api/controller/ApiDefinitionControllerTests.java +++ b/backend/services/api-test/src/test/java/io/metersphere/api/controller/ApiDefinitionControllerTests.java @@ -222,7 +222,7 @@ public class ApiDefinitionControllerTests extends BaseTest { msHttpElement.setBody(ApiDebugControllerTests.addBodyLinkFile(msHttpElement.getBody(), fileMetadataId)); request.setRequest(getMsElementParam(msHttpElement)); List msHttpResponse = MsHTTPElementTest.getMsHttpResponse(); - msHttpResponse.get(0).setBody(ApiDebugControllerTests.addBodyLinkFile(msHttpResponse.get(0).getBody(), fileMetadataId)); + msHttpResponse.getFirst().setBody(ApiDebugControllerTests.addBodyLinkFile(msHttpResponse.getFirst().getBody(), fileMetadataId)); request.setResponse(msHttpResponse); uploadFileId = doUploadTempFile(getMockMultipartFile("api-add-file_upload.JPG")); @@ -256,7 +256,7 @@ public class ApiDefinitionControllerTests extends BaseTest { apiFileResourceExample.createCriteria().andResourceIdEqualTo(apiDefinition.getId()); List apiFileResources = apiFileResourceMapper.selectByExample(apiFileResourceExample); Assertions.assertFalse(apiFileResources.isEmpty()); - apiTransferRequest.setFileId(apiFileResources.get(0).getFileId()); + apiTransferRequest.setFileId(apiFileResources.getFirst().getFileId()); apiTransferRequest.setFileName("test-file_upload"); apiTransferRequest.setOriginalName("test-file_upload.JPG"); this.requestPost("transfer", apiTransferRequest).andExpect(status().isOk()); @@ -899,7 +899,7 @@ public class ApiDefinitionControllerTests extends BaseTest { private void assertPateDate(Pager pageData) { List apiDefinitions = ApiDataUtils.parseArray(JSON.toJSONString(pageData.getList()), ApiDefinitionDTO.class); if (CollectionUtils.isNotEmpty(apiDefinitions)) { - ApiDefinitionDTO apiDefinitionDTO = apiDefinitions.get(0); + ApiDefinitionDTO apiDefinitionDTO = apiDefinitions.getFirst(); // 判断用例数是否正确 ApiTestCaseExample example = new ApiTestCaseExample(); example.createCriteria() diff --git a/backend/services/api-test/src/test/java/io/metersphere/api/controller/ApiDefinitionModuleControllerTests.java b/backend/services/api-test/src/test/java/io/metersphere/api/controller/ApiDefinitionModuleControllerTests.java index a5e3786474..ab552a6c66 100644 --- a/backend/services/api-test/src/test/java/io/metersphere/api/controller/ApiDefinitionModuleControllerTests.java +++ b/backend/services/api-test/src/test/java/io/metersphere/api/controller/ApiDefinitionModuleControllerTests.java @@ -475,7 +475,7 @@ public class ApiDefinitionModuleControllerTests extends BaseTest { List apiDebugModules = apiDefinitionModuleMapper.selectByExample(example); assert CollectionUtils.isNotEmpty(apiDebugModules); updateRequest = new ModuleUpdateRequest(); - updateRequest.setId(apiDebugModules.get(0).getId()); + updateRequest.setId(apiDebugModules.getFirst().getId()); updateRequest.setName("default-update-Project"); requestPostPermissionTest(PermissionConstants.PROJECT_API_DEFINITION_UPDATE, URL_MODULE_UPDATE, updateRequest); } diff --git a/backend/services/api-test/src/test/java/io/metersphere/api/controller/ApiScenarioControllerTests.java b/backend/services/api-test/src/test/java/io/metersphere/api/controller/ApiScenarioControllerTests.java index 1a9b4057fd..f415dda94e 100644 --- a/backend/services/api-test/src/test/java/io/metersphere/api/controller/ApiScenarioControllerTests.java +++ b/backend/services/api-test/src/test/java/io/metersphere/api/controller/ApiScenarioControllerTests.java @@ -273,7 +273,7 @@ public class ApiScenarioControllerTests extends BaseTest { schedule.setValue("0 0 0/1 * * ? "); } else { apiScenario.setGrouped(false); - apiScenario.setEnvironmentId(environments.get(0).getId()); + apiScenario.setEnvironmentId(environments.getFirst().getId()); schedule.setValue("1111"); } scheduleMapper.insertSelective(schedule); @@ -356,7 +356,7 @@ public class ApiScenarioControllerTests extends BaseTest { List steps = getApiScenarioStepRequests(); Map steptDetailMap = new HashMap<>(); steptDetailMap.put(steps.get(1).getId(), getMsHttpElementParam()); - steptDetailMap.put(steps.get(0).getId(), getMsHttpElementParam()); + steptDetailMap.put(steps.getFirst().getId(), getMsHttpElementParam()); request.setSteps(steps); request.setStepDetails(steptDetailMap); request.setScenarioConfig(getScenarioConfig()); @@ -662,7 +662,7 @@ public class ApiScenarioControllerTests extends BaseTest { for (ApiScenarioStepRequest step : steps) { steptDetailMap.put(step.getId(), getMsHttpElementStr(msHttpElement)); } - fileMetadataStepId = steps.get(0).getId(); + fileMetadataStepId = steps.getFirst().getId(); request.setSteps(steps); request.setStepDetails(steptDetailMap); @@ -675,10 +675,10 @@ public class ApiScenarioControllerTests extends BaseTest { List apiScenarioCsv = apiScenarioCsvMapper.selectByExample(apiScenarioCsvExample); Map collect = apiScenarioCsv.stream().collect(Collectors.toMap(ApiScenarioCsv::getFileId, t -> t)); // 验证修改步骤 - steps.get(0).setName("test name update"); - CsvVariable csvVariable = request.getScenarioConfig().getVariable().getCsvVariables().get(0); - request.getScenarioConfig().getVariable().getCsvVariables().get(0).setId(collect.get(csvVariable.getFile().getFileId()).getId()); - CsvVariable csvVariable1 = request.getScenarioConfig().getVariable().getCsvVariables().get(0); + steps.getFirst().setName("test name update"); + CsvVariable csvVariable = request.getScenarioConfig().getVariable().getCsvVariables().getFirst(); + request.getScenarioConfig().getVariable().getCsvVariables().getFirst().setId(collect.get(csvVariable.getFile().getFileId()).getId()); + CsvVariable csvVariable1 = request.getScenarioConfig().getVariable().getCsvVariables().getFirst(); request.getScenarioConfig().getVariable().getCsvVariables().get(1).setId(collect.get(csvVariable1.getFile().getFileId()).getId()); this.requestPostWithOk(DEFAULT_UPDATE, request); assertUpdateSteps(steps, steptDetailMap); @@ -862,7 +862,7 @@ public class ApiScenarioControllerTests extends BaseTest { apiFileResourceExample.createCriteria().andResourceIdEqualTo(addApiScenario.getId()); List apiFileResources = apiFileResourceMapper.selectByExample(apiFileResourceExample); Assertions.assertFalse(apiFileResources.isEmpty()); - apiTransferRequest.setFileId(apiFileResources.get(0).getFileId()); + apiTransferRequest.setFileId(apiFileResources.getFirst().getFileId()); apiTransferRequest.setFileName("test-scenario-file-1"); apiTransferRequest.setOriginalName("test-scenario-file-1.txt"); this.requestPost(TRANSFER, apiTransferRequest).andExpect(status().isOk()); @@ -873,7 +873,7 @@ public class ApiScenarioControllerTests extends BaseTest { public void testStepTransfer() throws Exception { this.requestGetWithOk(TRANSFER_OPTIONS, DEFAULT_PROJECT_ID); ApiTransferRequest apiTransferRequest = new ApiTransferRequest(); - apiTransferRequest.setSourceId(addApiScenarioSteps.get(0).getId()); + apiTransferRequest.setSourceId(addApiScenarioSteps.getFirst().getId()); apiTransferRequest.setProjectId(DEFAULT_PROJECT_ID); apiTransferRequest.setModuleId("root"); apiTransferRequest.setLocal(true); @@ -1692,11 +1692,11 @@ public class ApiScenarioControllerTests extends BaseTest { EnvironmentExample environmentExample = new EnvironmentExample(); environmentExample.createCriteria().andProjectIdEqualTo(DEFAULT_PROJECT_ID).andMockEqualTo(true); List environments = environmentMapper.selectByExample(environmentExample); - request.setEnvId(environments.get(0).getId()); + request.setEnvId(environments.getFirst().getId()); requestPostAndReturn(BATCH_EDIT, request); - //判断数据的环境是不是environments.get(0).getId() + //判断数据的环境是不是environments.getFirst().getId() apiScenarios = apiScenarioMapper.selectByExample(example); - apiScenarios.forEach(apiTestCase -> Assertions.assertEquals(apiTestCase.getEnvironmentId(), environments.get(0).getId())); + apiScenarios.forEach(apiTestCase -> Assertions.assertEquals(apiTestCase.getEnvironmentId(), environments.getFirst().getId())); //环境数据为空 request.setEnvId(null); @@ -2558,7 +2558,7 @@ public class ApiScenarioControllerTests extends BaseTest { apiScenario.setEnvironmentId("scenario-environment-group-id"); } else if (i <= 100) { apiScenario.setGrouped(false); - apiScenario.setEnvironmentId(environments.get(0).getId()); + apiScenario.setEnvironmentId(environments.getFirst().getId()); } else if (i <= 150) { //带blob ApiScenarioBlob apiScenarioBlob = new ApiScenarioBlob(); diff --git a/backend/services/api-test/src/test/java/io/metersphere/api/controller/ApiScenarioModuleControllerTests.java b/backend/services/api-test/src/test/java/io/metersphere/api/controller/ApiScenarioModuleControllerTests.java index b89da8d744..50535b5a65 100644 --- a/backend/services/api-test/src/test/java/io/metersphere/api/controller/ApiScenarioModuleControllerTests.java +++ b/backend/services/api-test/src/test/java/io/metersphere/api/controller/ApiScenarioModuleControllerTests.java @@ -402,7 +402,7 @@ public class ApiScenarioModuleControllerTests extends BaseTest { List apiDebugModules = apiScenarioModuleMapper.selectByExample(example); assert CollectionUtils.isNotEmpty(apiDebugModules); updateRequest = new ModuleUpdateRequest(); - updateRequest.setId(apiDebugModules.get(0).getId()); + updateRequest.setId(apiDebugModules.getFirst().getId()); updateRequest.setName("default-update-Project"); requestPostPermissionTest(PermissionConstants.PROJECT_API_SCENARIO_UPDATE, URL_MODULE_UPDATE, updateRequest); } diff --git a/backend/services/api-test/src/test/java/io/metersphere/api/controller/ApiShareControllerTests.java b/backend/services/api-test/src/test/java/io/metersphere/api/controller/ApiShareControllerTests.java index 30c79091a4..182f6d18fe 100644 --- a/backend/services/api-test/src/test/java/io/metersphere/api/controller/ApiShareControllerTests.java +++ b/backend/services/api-test/src/test/java/io/metersphere/api/controller/ApiShareControllerTests.java @@ -79,7 +79,7 @@ public class ApiShareControllerTests extends BaseTest { List shareInfos = extShareInfoMapper.selectByShareTypeAndShareApiIdWithBLOBs(ShareInfoType.SINGLE.name(), JSON.toJSONString(request).getBytes(), "zh_CN"); Assertions.assertNotNull(shareInfos); Assertions.assertEquals(1, shareInfos.size()); - Assertions.assertEquals(shareInfoDTO.getId(), shareInfos.get(0).getId()); + Assertions.assertEquals(shareInfoDTO.getId(), shareInfos.getFirst().getId()); Assertions.assertTrue(shareInfoDTO.getShareUrl().contains("?shareId=")); request.setApiId("111"); @@ -96,7 +96,7 @@ public class ApiShareControllerTests extends BaseTest { List shareInfosModule = extShareInfoMapper.selectByShareTypeAndShareApiIdWithBLOBs(ShareInfoType.BATCH.name(), JSON.toJSONString(request).getBytes(), "zh_CN"); Assertions.assertNotNull(shareInfosModule); Assertions.assertEquals(1, shareInfosModule.size()); - Assertions.assertEquals(shareInfoDTOModule.getId(), shareInfosModule.get(0).getId()); + Assertions.assertEquals(shareInfoDTOModule.getId(), shareInfosModule.getFirst().getId()); Assertions.assertTrue(shareInfoDTOModule.getShareUrl().contains("?shareId=")); // @@分享全部文档 @@ -111,7 +111,7 @@ public class ApiShareControllerTests extends BaseTest { List allShareInfos = extShareInfoMapper.selectByShareTypeAndShareApiIdWithBLOBs(ShareInfoType.BATCH.name(), JSON.toJSONString(request).getBytes(), "zh_CN"); Assertions.assertNotNull(allShareInfos); Assertions.assertEquals(1, allShareInfos.size()); - Assertions.assertEquals(allShareInfoDTO.getId(), allShareInfos.get(0).getId()); + Assertions.assertEquals(allShareInfoDTO.getId(), allShareInfos.getFirst().getId()); Assertions.assertTrue(allShareInfoDTO.getShareUrl().contains("?shareId=")); assertTestShareView(allShareInfoDTO.getId()); 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 82478fb04c..3f758abb09 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 @@ -346,7 +346,7 @@ public class ApiTestCaseControllerTests extends BaseTest { request.setPriority("P0"); request.setStatus(ApiDefinitionStatus.PROCESSING.name()); request.setTags(new LinkedHashSet<>(List.of("tag1", "tag2"))); - request.setEnvironmentId(environments.get(0).getId()); + request.setEnvironmentId(environments.getFirst().getId()); MsHTTPElement msHttpElement = MsHTTPElementTest.getMsHttpElement(); msHttpElement.setBody(ApiDebugControllerTests.addBodyLinkFile(msHttpElement.getBody(), fileMetadataId)); request.setRequest(getMsElementParam(msHttpElement)); @@ -750,7 +750,7 @@ public class ApiTestCaseControllerTests extends BaseTest { apiFileResourceExample.createCriteria().andResourceIdEqualTo(apiTestCase.getId()); List apiFileResources = apiFileResourceMapper.selectByExample(apiFileResourceExample); Assertions.assertFalse(apiFileResources.isEmpty()); - apiTransferRequest.setFileId(apiFileResources.get(0).getFileId()); + apiTransferRequest.setFileId(apiFileResources.getFirst().getFileId()); apiTransferRequest.setFileName("test-api-test-case-1"); apiTransferRequest.setOriginalName("test-api-test-case-1.txt"); this.requestPost("transfer", apiTransferRequest).andExpect(status().isOk()); @@ -1018,11 +1018,11 @@ public class ApiTestCaseControllerTests extends BaseTest { EnvironmentExample environmentExample = new EnvironmentExample(); environmentExample.createCriteria().andProjectIdEqualTo(DEFAULT_PROJECT_ID).andMockEqualTo(true); List environments = environmentMapper.selectByExample(environmentExample); - request.setEnvironmentId(environments.get(0).getId()); + request.setEnvironmentId(environments.getFirst().getId()); requestPostWithOkAndReturn(BATCH_EDIT, request); - //判断数据的环境是不是environments.get(0).getId() + //判断数据的环境是不是environments.getFirst().getId() caseList = apiTestCaseMapper.selectByExample(example); - caseList.forEach(apiTestCase -> Assertions.assertEquals(apiTestCase.getEnvironmentId(), environments.get(0).getId())); + caseList.forEach(apiTestCase -> Assertions.assertEquals(apiTestCase.getEnvironmentId(), environments.getFirst().getId())); //环境数据为空 request.setEnvironmentId(null); this.requestPost(BATCH_EDIT, request, ERROR_REQUEST_MATCHER); diff --git a/backend/services/api-test/src/test/java/io/metersphere/api/service/BaseFileManagementTestService.java b/backend/services/api-test/src/test/java/io/metersphere/api/service/BaseFileManagementTestService.java index 497daaafd9..9a7dbf4660 100644 --- a/backend/services/api-test/src/test/java/io/metersphere/api/service/BaseFileManagementTestService.java +++ b/backend/services/api-test/src/test/java/io/metersphere/api/service/BaseFileManagementTestService.java @@ -57,7 +57,7 @@ public class BaseFileManagementTestService { FileAssociationExample example = new FileAssociationExample(); example.createCriteria().andFileIdEqualTo(originFileId) .andSourceIdEqualTo(resourceId); - FileAssociation fileAssociation = fileAssociationMapper.selectByExample(example).get(0); + FileAssociation fileAssociation = fileAssociationMapper.selectByExample(example).getFirst(); return fileAssociationService.upgrade(fileAssociation.getId(), fileLogRecord); } diff --git a/backend/services/bug-management/src/main/java/io/metersphere/bug/service/BugAttachmentLogService.java b/backend/services/bug-management/src/main/java/io/metersphere/bug/service/BugAttachmentLogService.java index e3c4e13bd4..947d37e0f1 100644 --- a/backend/services/bug-management/src/main/java/io/metersphere/bug/service/BugAttachmentLogService.java +++ b/backend/services/bug-management/src/main/java/io/metersphere/bug/service/BugAttachmentLogService.java @@ -59,10 +59,10 @@ public class BugAttachmentLogService { BugFileDTO deleteFile; if (request.getAssociated()) { // 关联 - deleteFile = allBugFiles.stream().filter(file -> !file.getLocal() && StringUtils.equals(request.getRefId(), file.getRefId())).toList().get(0); + deleteFile = allBugFiles.stream().filter(file -> !file.getLocal() && StringUtils.equals(request.getRefId(), file.getRefId())).toList().getFirst(); } else { // 本地 - deleteFile = allBugFiles.stream().filter(file -> file.getLocal() && StringUtils.equals(request.getRefId(), file.getRefId())).toList().get(0); + deleteFile = allBugFiles.stream().filter(file -> file.getLocal() && StringUtils.equals(request.getRefId(), file.getRefId())).toList().getFirst(); } LogDTO dto = buildUpdateLog(bug); dto.setModifiedValue(JSON.toJSONBytes(originalFileNames)); diff --git a/backend/services/bug-management/src/main/java/io/metersphere/bug/service/BugAttachmentService.java b/backend/services/bug-management/src/main/java/io/metersphere/bug/service/BugAttachmentService.java index 168e228fdf..5e684cfeec 100644 --- a/backend/services/bug-management/src/main/java/io/metersphere/bug/service/BugAttachmentService.java +++ b/backend/services/bug-management/src/main/java/io/metersphere/bug/service/BugAttachmentService.java @@ -510,7 +510,7 @@ public class BugAttachmentService { FileAssociation association = fileAssociationMapper.selectByPrimaryKey(refId); FileMetadataExample example = new FileMetadataExample(); example.createCriteria().andIdEqualTo(association.getFileId()); - FileMetadata fileMetadata = fileMetadataMapper.selectByExample(example).get(0); + FileMetadata fileMetadata = fileMetadataMapper.selectByExample(example).getFirst(); // 取消关联的附件同步至平台 if (!StringUtils.equals(platformName, BugPlatform.LOCAL.getName())) { File deleteTmpFile = new File(FilenameUtils.normalize(LocalRepositoryDir.getBugTmpDir() + File.separator + fileMetadata.getName() + "." + fileMetadata.getType())); @@ -628,7 +628,7 @@ public class BugAttachmentService { if (CollectionUtils.isEmpty(bugLocalAttachments)) { return null; } - return bugLocalAttachments.get(0); + return bugLocalAttachments.getFirst(); } /** @@ -700,7 +700,7 @@ public class BugAttachmentService { if (CollectionUtils.isEmpty(folderFileNames)) { return null; } - String[] pathSplit = folderFileNames.get(0).split("/"); + String[] pathSplit = folderFileNames.getFirst().split("/"); return pathSplit[pathSplit.length - 1]; } catch (Exception e) { @@ -769,7 +769,7 @@ public class BugAttachmentService { bytes = getPreviewImg(fileName, fileId, compressed); } else { //在正式目录获取 - BugLocalAttachment attachment = bugAttachments.get(0); + BugLocalAttachment attachment = bugAttachments.getFirst(); fileName = attachment.getFileName(); FileRequest fileRequest = buildBugFileRequest(projectId, attachment.getBugId(), attachment.getFileId(), attachment.getFileName(), compressed); try { diff --git a/backend/services/bug-management/src/main/java/io/metersphere/bug/service/BugLogService.java b/backend/services/bug-management/src/main/java/io/metersphere/bug/service/BugLogService.java index cb9b36922d..16591910a4 100644 --- a/backend/services/bug-management/src/main/java/io/metersphere/bug/service/BugLogService.java +++ b/backend/services/bug-management/src/main/java/io/metersphere/bug/service/BugLogService.java @@ -121,6 +121,6 @@ public class BugLogService { originalBug.setDescription(bugContent.getDescription()); } // 缺陷自定义字段 - return bugService.handleCustomField(List.of(originalBug), originalBug.getProjectId()).get(0); + return bugService.handleCustomField(List.of(originalBug), originalBug.getProjectId()).getFirst(); } } diff --git a/backend/services/bug-management/src/main/java/io/metersphere/bug/service/BugScheduleServiceImpl.java b/backend/services/bug-management/src/main/java/io/metersphere/bug/service/BugScheduleServiceImpl.java index 9ada015ed0..bcc3ce7b31 100644 --- a/backend/services/bug-management/src/main/java/io/metersphere/bug/service/BugScheduleServiceImpl.java +++ b/backend/services/bug-management/src/main/java/io/metersphere/bug/service/BugScheduleServiceImpl.java @@ -29,8 +29,8 @@ public class BugScheduleServiceImpl implements BaseBugScheduleService { List syncCron = bugSyncConfigs.stream().filter(config -> config.getType().equals(ProjectApplicationType.BUG.BUG_SYNC.name() + "_" + ProjectApplicationType.BUG_SYNC_CONFIG.CRON_EXPRESSION.name())).toList(); List syncEnable = bugSyncConfigs.stream().filter(config -> config.getType().equals(ProjectApplicationType.BUG.BUG_SYNC.name() + "_" + ProjectApplicationType.BUG_SYNC_CONFIG.SYNC_ENABLE.name())).toList(); if (CollectionUtils.isNotEmpty(syncCron)) { - Boolean enable = Boolean.valueOf(syncEnable.get(0).getTypeValue()); - String typeValue = syncCron.get(0).getTypeValue(); + Boolean enable = Boolean.valueOf(syncEnable.getFirst().getTypeValue()); + String typeValue = syncCron.getFirst().getTypeValue(); Schedule schedule = scheduleService.getScheduleByResource(projectId, BugSyncJob.class.getName()); Optional optional = Optional.ofNullable(schedule); optional.ifPresentOrElse(s -> { diff --git a/backend/services/bug-management/src/main/java/io/metersphere/bug/service/BugService.java b/backend/services/bug-management/src/main/java/io/metersphere/bug/service/BugService.java index c0a2813a79..45267eaeae 100644 --- a/backend/services/bug-management/src/main/java/io/metersphere/bug/service/BugService.java +++ b/backend/services/bug-management/src/main/java/io/metersphere/bug/service/BugService.java @@ -727,7 +727,7 @@ public class BugService { // 平台默认模板 Template pluginDefaultTemplate = projectTemplateService.getPluginBugTemplate(project.getId()); List templateOption = projectTemplateService.getOption(project.getId(), TemplateScene.BUG.name()); - ProjectTemplateOptionDTO defaultProjectTemplate = templateOption.stream().filter(ProjectTemplateOptionDTO::getEnableDefault).toList().get(0); + ProjectTemplateOptionDTO defaultProjectTemplate = templateOption.stream().filter(ProjectTemplateOptionDTO::getEnableDefault).toList().getFirst(); if (isPluginDefaultTemplate(defaultProjectTemplate.getId(), pluginDefaultTemplate)) { BeanUtils.copyBean(msDefaultTemplate, pluginDefaultTemplate); } else { @@ -945,7 +945,7 @@ public class BugService { if (StringUtils.isBlank(statusField.get().getValue()) && StringUtils.equalsIgnoreCase(BugPlatform.LOCAL.getName(), platformName)) { // Local平台设置状态默认值为状态流-开始状态 List localStartStatusItem = bugStatusService.getToStatusItemOptionOnLocal(request.getProjectId(), StringUtils.EMPTY); - bug.setStatus(localStartStatusItem.get(0).getValue()); + bug.setStatus(localStartStatusItem.getFirst().getValue()); } else { bug.setStatus(statusField.get().getValue()); } @@ -1036,7 +1036,7 @@ public class BugService { if (CollectionUtils.isEmpty(bugs)) { throw new MSException(BUG_NOT_EXIST); } - return bugs.get(0); + return bugs.getFirst(); } /** @@ -1491,13 +1491,13 @@ public class BugService { .replace("alt=\"" + key + "\"", "src=\"/bug/attachment/preview/md/" + updateBug.getProjectId() + "/" + fileId + "/false\"")); if (updateBug.getPlatformDefaultTemplate()) { // 来自富文本自定义字段 - PlatformCustomFieldItemDTO descriptionField = updateBug.getCustomFieldList().stream().filter(field -> StringUtils.equals(field.getCustomData(), "description")).toList().get(0); + PlatformCustomFieldItemDTO descriptionField = updateBug.getCustomFieldList().stream().filter(field -> StringUtils.equals(field.getCustomData(), "description")).toList().getFirst(); descriptionField.setValue(updateBug.getDescription()); } } else { // 来自富文本自定义字段 PlatformCustomFieldItemDTO richTextField = updateBug.getCustomFieldList().stream().filter(field -> StringUtils.equals(field.getType(), PlatformCustomFieldType.RICH_TEXT.name()) - && field.getValue() != null && StringUtils.contains(field.getValue().toString(), "alt=\"" + key + "\"")).toList().get(0); + && field.getValue() != null && StringUtils.contains(field.getValue().toString(), "alt=\"" + key + "\"")).toList().getFirst(); richTextField.setValue(richTextField.getValue().toString().replace("alt=\"" + key + "\"", "src=\"/bug/attachment/preview/md/" + updateBug.getProjectId() + "/" + fileId + "/false\"")); } })); @@ -2002,13 +2002,13 @@ public class BugService { .replace("alt=\"" + key + "\"", "src=\"/bug/attachment/preview/md/" + platformBug.getProjectId() + "/" + fileId + "/false\"")); if (platformBug.getPlatformDefaultTemplate()) { // 来自富文本自定义字段 - PlatformCustomFieldItemDTO descriptionField = platformBug.getCustomFieldList().stream().filter(field -> StringUtils.equals(field.getCustomData(), "description")).toList().get(0); + PlatformCustomFieldItemDTO descriptionField = platformBug.getCustomFieldList().stream().filter(field -> StringUtils.equals(field.getCustomData(), "description")).toList().getFirst(); descriptionField.setValue(platformBug.getDescription()); } } else { // 来自富文本自定义字段 PlatformCustomFieldItemDTO richTextField = platformBug.getCustomFieldList().stream().filter(field -> StringUtils.equals(field.getType(), PlatformCustomFieldType.RICH_TEXT.name()) - && field.getValue() != null && StringUtils.contains(field.getValue().toString(), "alt=\"" + key + "\"")).toList().get(0); + && field.getValue() != null && StringUtils.contains(field.getValue().toString(), "alt=\"" + key + "\"")).toList().getFirst(); richTextField.setValue(richTextField.getValue().toString().replace("alt=\"" + key + "\"", "src=\"/bug/attachment/preview/md/" + platformBug.getProjectId() + "/" + fileId + "/false\"")); } })); diff --git a/backend/services/bug-management/src/main/java/io/metersphere/bug/service/BugStatusService.java b/backend/services/bug-management/src/main/java/io/metersphere/bug/service/BugStatusService.java index 3265b6a1c9..73a04e91be 100644 --- a/backend/services/bug-management/src/main/java/io/metersphere/bug/service/BugStatusService.java +++ b/backend/services/bug-management/src/main/java/io/metersphere/bug/service/BugStatusService.java @@ -113,7 +113,7 @@ public class BugStatusService { example.setOrderByClause("create_time desc"); List bugs = bugMapper.selectByExample(example); if (CollectionUtils.isNotEmpty(bugs)) { - return bugs.get(0).getPlatformBugId(); + return bugs.getFirst().getPlatformBugId(); } else { return StringUtils.EMPTY; } diff --git a/backend/services/bug-management/src/test/java/io/metersphere/bug/controller/BugAttachmentControllerTests.java b/backend/services/bug-management/src/test/java/io/metersphere/bug/controller/BugAttachmentControllerTests.java index 2396460768..397a5908ac 100644 --- a/backend/services/bug-management/src/test/java/io/metersphere/bug/controller/BugAttachmentControllerTests.java +++ b/backend/services/bug-management/src/test/java/io/metersphere/bug/controller/BugAttachmentControllerTests.java @@ -93,7 +93,7 @@ public class BugAttachmentControllerTests extends BaseTest { BugUploadFileRequest request = new BugUploadFileRequest(); request.setBugId("default-attachment-bug-id"); request.setProjectId("default-project-for-attachment"); - request.setSelectIds(List.of(unRelatedFiles.get(0).getId())); + request.setSelectIds(List.of(unRelatedFiles.getFirst().getId())); MultiValueMap paramMap1 = getDefaultMultiPartParam(request, null); this.requestMultipartWithOk(BUG_ATTACHMENT_UPLOAD, paramMap1); String filePath = Objects.requireNonNull(this.getClass().getClassLoader().getResource("file/test.xlsx")).getPath(); @@ -105,7 +105,7 @@ public class BugAttachmentControllerTests extends BaseTest { request.setSelectIds(List.of("not-exist-file-id")); MultiValueMap paramMap4 = getDefaultMultiPartParam(request, null); this.requestMultipart(BUG_ATTACHMENT_UPLOAD, paramMap4); - request.setSelectIds(List.of(unRelatedFiles.get(0).getId())); + request.setSelectIds(List.of(unRelatedFiles.getFirst().getId())); MultiValueMap paramMap5 = getDefaultMultiPartParam(request, null); this.requestMultipart(BUG_ATTACHMENT_UPLOAD, paramMap5); MultiValueMap paramMap6 = getDefaultMultiPartParam(request, file); diff --git a/backend/services/bug-management/src/test/java/io/metersphere/bug/controller/BugCommentControllerTests.java b/backend/services/bug-management/src/test/java/io/metersphere/bug/controller/BugCommentControllerTests.java index 19b60806c8..1679145a2d 100644 --- a/backend/services/bug-management/src/test/java/io/metersphere/bug/controller/BugCommentControllerTests.java +++ b/backend/services/bug-management/src/test/java/io/metersphere/bug/controller/BugCommentControllerTests.java @@ -45,10 +45,10 @@ public class BugCommentControllerTests extends BaseTest { ResultHolder resultHolder = JSON.parseObject(sortData, ResultHolder.class); List comments = JSON.parseArray(JSON.toJSONString(resultHolder.getData()), BugCommentDTO.class); Assertions.assertTrue(CollectionUtils.isNotEmpty(comments)); - Assertions.assertTrue(StringUtils.equals("default-bug-comment-id-3", comments.get(0).getId())); + Assertions.assertTrue(StringUtils.equals("default-bug-comment-id-3", comments.getFirst().getId())); // 第二条评论的子评论不为空且ID为default-bug-comment-id-2 Assertions.assertTrue(CollectionUtils.isNotEmpty(comments.get(1).getChildComments()) && - StringUtils.equals("default-bug-comment-id-2", comments.get(1).getChildComments().get(0).getId())); + StringUtils.equals("default-bug-comment-id-2", comments.get(1).getChildComments().getFirst().getId())); } @Test diff --git a/backend/services/bug-management/src/test/java/io/metersphere/bug/controller/BugControllerTests.java b/backend/services/bug-management/src/test/java/io/metersphere/bug/controller/BugControllerTests.java index fc40f81b5e..3d06c8964a 100644 --- a/backend/services/bug-management/src/test/java/io/metersphere/bug/controller/BugControllerTests.java +++ b/backend/services/bug-management/src/test/java/io/metersphere/bug/controller/BugControllerTests.java @@ -155,7 +155,7 @@ public class BugControllerTests extends BaseTest { // 返回的数据量不超过规定要返回的数据量相同 Assertions.assertTrue(JSON.parseArray(JSON.toJSONString(pageData.getList())).size() <= bugRequest.getPageSize()); // 返回值中取出第一条数据, 并判断是否包含关键字default - BugDTO bugDTO = JSON.parseArray(JSON.toJSONString(pageData.getList()), BugDTO.class).get(0); + BugDTO bugDTO = JSON.parseArray(JSON.toJSONString(pageData.getList()), BugDTO.class).getFirst(); Assertions.assertTrue(StringUtils.contains(bugDTO.getTitle(), bugRequest.getKeyword()) || StringUtils.contains(bugDTO.getId(), bugRequest.getKeyword())); @@ -168,7 +168,7 @@ public class BugControllerTests extends BaseTest { ResultHolder sortHolder = JSON.parseObject(sortData, ResultHolder.class); Pager sortPageData = JSON.parseObject(JSON.toJSONString(sortHolder.getData()), Pager.class); // 返回值中取出第一条ID最大的数据, 并判断是否是default-bug - BugDTO maxBugDTO = JSON.parseArray(JSON.toJSONString(sortPageData.getList()), BugDTO.class).get(0); + BugDTO maxBugDTO = JSON.parseArray(JSON.toJSONString(sortPageData.getList()), BugDTO.class).getFirst(); Assertions.assertTrue(maxBugDTO.getId().contains("default")); // 拖拽 @@ -884,7 +884,7 @@ public class BugControllerTests extends BaseTest { private Bug getAddJiraBug() { BugExample example = new BugExample(); example.createCriteria().andTitleEqualTo("这是一个系统Jira模板创建的缺陷"); - return bugMapper.selectByExample(example).get(0); + return bugMapper.selectByExample(example).getFirst(); } /** @@ -895,7 +895,7 @@ public class BugControllerTests extends BaseTest { private BugLocalAttachment getAddJiraLocalFile() { BugLocalAttachmentExample example = new BugLocalAttachmentExample(); example.createCriteria().andBugIdEqualTo(getAddJiraBug().getId()); - return bugLocalAttachmentMapper.selectByExample(example).get(0); + return bugLocalAttachmentMapper.selectByExample(example).getFirst(); } /** @@ -906,7 +906,7 @@ public class BugControllerTests extends BaseTest { private FileAssociation getAddJiraAssociateFile() { FileAssociationExample example = new FileAssociationExample(); example.createCriteria().andSourceIdEqualTo(getAddJiraBug().getId()).andSourceTypeEqualTo(FileAssociationSourceUtil.SOURCE_TYPE_BUG); - return fileAssociationMapper.selectByExample(example).get(0); + return fileAssociationMapper.selectByExample(example).getFirst(); } /** diff --git a/backend/services/bug-management/src/test/java/io/metersphere/bug/controller/BugRelateCaseControllerTests.java b/backend/services/bug-management/src/test/java/io/metersphere/bug/controller/BugRelateCaseControllerTests.java index f98e3b136e..dc11dc5d3b 100644 --- a/backend/services/bug-management/src/test/java/io/metersphere/bug/controller/BugRelateCaseControllerTests.java +++ b/backend/services/bug-management/src/test/java/io/metersphere/bug/controller/BugRelateCaseControllerTests.java @@ -117,7 +117,7 @@ public class BugRelateCaseControllerTests extends BaseTest { // 返回的数据量不超过规定要返回的数据量相同 Assertions.assertTrue(JSON.parseArray(JSON.toJSONString(pageData.getList())).size() <= request.getPageSize()); // 返回值中取出第一条数据, 并判断是否包含关键字default - BugRelateCaseDTO bugRelateCaseDTO = JSON.parseArray(JSON.toJSONString(pageData.getList()), BugRelateCaseDTO.class).get(0); + BugRelateCaseDTO bugRelateCaseDTO = JSON.parseArray(JSON.toJSONString(pageData.getList()), BugRelateCaseDTO.class).getFirst(); Assertions.assertTrue(StringUtils.contains(bugRelateCaseDTO.getRelateCaseName(), request.getKeyword())); } diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/provider/CaseReviewCaseProvider.java b/backend/services/case-management/src/main/java/io/metersphere/functional/provider/CaseReviewCaseProvider.java index 614806b534..161a24d536 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/provider/CaseReviewCaseProvider.java +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/provider/CaseReviewCaseProvider.java @@ -140,7 +140,7 @@ public class CaseReviewCaseProvider implements BaseCaseProvider { collect.forEach((caseId, caseList) -> { FunctionalCase functionalCase = new FunctionalCase(); functionalCase.setId(caseId); - functionalCase.setReviewStatus(caseList.get(0).getStatus()); + functionalCase.setReviewStatus(caseList.getFirst().getStatus()); mapper.updateByPrimaryKeySelective(functionalCase); }); } diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/service/CaseReviewFunctionalCaseService.java b/backend/services/case-management/src/main/java/io/metersphere/functional/service/CaseReviewFunctionalCaseService.java index 2651fab2e6..e604de15b7 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/service/CaseReviewFunctionalCaseService.java +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/service/CaseReviewFunctionalCaseService.java @@ -214,7 +214,7 @@ public class CaseReviewFunctionalCaseService { private String getMyStatus(List histories, String viewStatusUserId) { List list = histories.stream().filter(history -> StringUtils.equalsIgnoreCase(history.getCreateUser(), viewStatusUserId)).toList(); if (CollectionUtils.isNotEmpty(list)) { - return list.get(0).getStatus(); + return list.getFirst().getStatus(); } //重新提审记录 @@ -328,7 +328,7 @@ public class CaseReviewFunctionalCaseService { ProjectApplicationExample example = new ProjectApplicationExample(); example.createCriteria().andProjectIdEqualTo(request.getProjectId()).andTypeEqualTo(ProjectApplicationType.CASE.CASE_RE_REVIEW.name()); List projectApplications = projectApplicationMapper.selectByExample(example); - if (CollectionUtils.isNotEmpty(projectApplications) && Boolean.valueOf(projectApplications.get(0).getTypeValue())) { + if (CollectionUtils.isNotEmpty(projectApplications) && Boolean.valueOf(projectApplications.getFirst().getTypeValue())) { if (!StringUtils.equals(name, request.getName()) || !StringUtils.equals(new String(blob.getSteps() == null ? new byte[0] : blob.getSteps(), StandardCharsets.UTF_8), request.getSteps()) || !StringUtils.equals(new String(blob.getTextDescription() == null ? new byte[0] : blob.getTextDescription(), StandardCharsets.UTF_8), request.getTextDescription()) @@ -526,10 +526,10 @@ public class CaseReviewFunctionalCaseService { AtomicInteger passCount = new AtomicInteger(); AtomicInteger unPassCount = new AtomicInteger(); hasReviewedUserMap.forEach((k, v) -> { - if (StringUtils.equalsIgnoreCase(v.get(0).getStatus(), FunctionalCaseReviewStatus.PASS.toString())) { + if (StringUtils.equalsIgnoreCase(v.getFirst().getStatus(), FunctionalCaseReviewStatus.PASS.toString())) { passCount.set(passCount.get() + 1); } - if (StringUtils.equalsIgnoreCase(v.get(0).getStatus(), FunctionalCaseReviewStatus.UN_PASS.toString())) { + if (StringUtils.equalsIgnoreCase(v.getFirst().getStatus(), FunctionalCaseReviewStatus.UN_PASS.toString())) { unPassCount.set(unPassCount.get() + 1); } }); @@ -646,7 +646,7 @@ public class CaseReviewFunctionalCaseService { } private String newReviewStatus(List historyUsers, List newUsers, List reviewHistories, List newReviewers) { - CaseReviewHistory caseReviewHistory = reviewHistories.get(0); + CaseReviewHistory caseReviewHistory = reviewHistories.getFirst(); if (newUsers.contains(caseReviewHistory.getCreateUser()) && FunctionalCaseReviewStatus.RE_REVIEWED.name().equals(caseReviewHistory.getStatus())) { return FunctionalCaseReviewStatus.RE_REVIEWED.name(); } @@ -731,7 +731,7 @@ public class CaseReviewFunctionalCaseService { Map> projectModuleMap = functionalModuleIds.stream().collect(Collectors.groupingBy(FunctionalCaseModule::getProjectId)); if (MapUtils.isEmpty(projectModuleMap)) { projectRootMap.forEach((projectId, projectOptionDTOList) -> { - BaseTreeNode projectNode = new BaseTreeNode(projectId, projectOptionDTOList.get(0).getProjectName(), Project.class.getName()); + BaseTreeNode projectNode = new BaseTreeNode(projectId, projectOptionDTOList.getFirst().getProjectName(), Project.class.getName()); returnList.add(projectNode); BaseTreeNode defaultNode = functionalCaseModuleService.getDefaultModule(Translator.get("functional_case.module.default.name")); projectNode.addChild(defaultNode); @@ -739,7 +739,7 @@ public class CaseReviewFunctionalCaseService { return returnList; } projectModuleMap.forEach((projectId, moduleList) -> { - BaseTreeNode projectNode = new BaseTreeNode(projectId, moduleList.get(0).getProjectName(), Project.class.getName()); + BaseTreeNode projectNode = new BaseTreeNode(projectId, moduleList.getFirst().getProjectName(), Project.class.getName()); returnList.add(projectNode); List projectModuleIds = moduleList.stream().map(FunctionalCaseModule::getId).toList(); List nodeByNodeIds = functionalCaseModuleService.getNodeByNodeIds(projectModuleIds); @@ -804,8 +804,8 @@ public class CaseReviewFunctionalCaseService { List optionDTOS = new ArrayList<>(); collect.forEach((k, v) -> { OptionDTO optionDTO = new OptionDTO(); - optionDTO.setId(v.get(0).getUserName()); - optionDTO.setName(v.get(0).getStatus()); + optionDTO.setId(v.getFirst().getUserName()); + optionDTO.setName(v.getFirst().getStatus()); optionDTOS.add(optionDTO); }); return optionDTOS; diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseAttachmentService.java b/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseAttachmentService.java index 024b887f07..b73595f5f9 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseAttachmentService.java +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseAttachmentService.java @@ -290,7 +290,7 @@ public class FunctionalCaseAttachmentService { example.createCriteria().andFileIdEqualTo(request.getFileId()).andCaseIdEqualTo(request.getCaseId()); List caseAttachments = functionalCaseAttachmentMapper.selectByExample(example); if (CollectionUtils.isNotEmpty(caseAttachments)) { - FunctionalCaseAttachment attachment = caseAttachments.get(0); + FunctionalCaseAttachment attachment = caseAttachments.getFirst(); FileRequest fileRequest = new FileRequest(); fileRequest.setFileName(attachment.getFileName()); fileRequest.setFolder(DefaultRepositoryDir.getFunctionalCaseDir(request.getProjectId(), request.getCaseId()) + "/" + attachment.getFileId()); @@ -315,7 +315,7 @@ public class FunctionalCaseAttachmentService { List caseAttachments = functionalCaseAttachmentMapper.selectByExample(example); byte[] bytes = null; if (CollectionUtils.isNotEmpty(caseAttachments)) { - FunctionalCaseAttachment attachment = caseAttachments.get(0); + FunctionalCaseAttachment attachment = caseAttachments.getFirst(); FileRequest fileRequest = new FileRequest(); fileRequest.setFileName(attachment.getFileName()); fileRequest.setFolder(DefaultRepositoryDir.getFunctionalCaseDir(request.getProjectId(), request.getCaseId()) + "/" + attachment.getFileId()); @@ -334,7 +334,7 @@ public class FunctionalCaseAttachmentService { example.createCriteria().andFileIdEqualTo(request.getFileId()).andCaseIdEqualTo(request.getCaseId()); List caseAttachments = functionalCaseAttachmentMapper.selectByExample(example); if (CollectionUtils.isNotEmpty(caseAttachments)) { - return caseAttachments.get(0); + return caseAttachments.getFirst(); } return new FunctionalCaseAttachment(); } @@ -460,7 +460,7 @@ public class FunctionalCaseAttachmentService { if (CollectionUtils.isEmpty(folderFileNames)) { return null; } - String[] pathSplit = folderFileNames.get(0).split("/"); + String[] pathSplit = folderFileNames.getFirst().split("/"); return pathSplit[pathSplit.length - 1]; } catch (Exception e) { @@ -533,7 +533,7 @@ public class FunctionalCaseAttachmentService { bytes = getPreviewImg(fileName, fileId, compressed); } else { //在正式目录获取 - FunctionalCaseAttachment attachment = caseAttachments.get(0); + FunctionalCaseAttachment attachment = caseAttachments.getFirst(); fileName = attachment.getFileName(); FileRequest fileRequest = new FileRequest(); fileRequest.setFileName(attachment.getFileName()); diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseCustomFieldService.java b/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseCustomFieldService.java index 33aa8c8515..48d4b70969 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseCustomFieldService.java +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseCustomFieldService.java @@ -60,7 +60,7 @@ public class FunctionalCaseCustomFieldService { example.createCriteria().andCaseIdEqualTo(caseId).andFieldIdEqualTo(fieldId); List functionalCaseCustomFields = functionalCaseCustomFieldMapper.selectByExample(example); if (CollectionUtils.isNotEmpty(functionalCaseCustomFields)) { - return functionalCaseCustomFields.get(0); + return functionalCaseCustomFields.getFirst(); } return null; } diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseDemandService.java b/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseDemandService.java index b0dba7e8b1..3bebdde09c 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseDemandService.java +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseDemandService.java @@ -82,7 +82,7 @@ public class FunctionalCaseDemandService { if (functionalCaseDemandMap.containsKey(demand.getParent())) { FunctionalDemandDTO functionalDemandDTO = new FunctionalDemandDTO(); BeanUtils.copyBean(functionalDemandDTO, demand); - functionalCaseDemandMap.get(demand.getParent()).stream().filter(t -> StringUtils.equalsIgnoreCase(t.getDemandPlatform(), demand.getDemandPlatform())).toList().get(0).addChild(functionalDemandDTO); + functionalCaseDemandMap.get(demand.getParent()).stream().filter(t -> StringUtils.equalsIgnoreCase(t.getDemandPlatform(), demand.getDemandPlatform())).toList().getFirst().addChild(functionalDemandDTO); resetMap(demand, functionalCaseDemandMap, functionalDemandDTO); } else { notMatchedList.add(demand); @@ -196,7 +196,7 @@ public class FunctionalCaseDemandService { if (functionalCaseDemand == null) { throw new MSException(Translator.get("case.demand.not.exist")); } - dealWithDemand(request.getDemandList().get(0), functionalCaseDemand); + dealWithDemand(request.getDemandList().getFirst(), functionalCaseDemand); functionalCaseDemand.setCreateTime(null); functionalCaseDemand.setCreateUser(null); functionalCaseDemand.setUpdateUser(userId); diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseService.java b/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseService.java index e18e207881..dc84424806 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseService.java +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseService.java @@ -252,7 +252,7 @@ public class FunctionalCaseService { private static void copyFile(FunctionalCaseAddRequest request, String caseId, String saveAttachmentFileId, Map> oldFileMap, FunctionalCaseAttachmentDTO functionalCaseAttachmentDTO, FileRepository defaultRepository) { List oldFunctionalCaseAttachments = oldFileMap.get(saveAttachmentFileId); if (CollectionUtils.isNotEmpty(oldFunctionalCaseAttachments)) { - FunctionalCaseAttachment functionalCaseAttachment = oldFunctionalCaseAttachments.get(0); + FunctionalCaseAttachment functionalCaseAttachment = oldFunctionalCaseAttachments.getFirst(); // 复制文件 FileCopyRequest fileCopyRequest = new FileCopyRequest(); fileCopyRequest.setCopyFolder(DefaultRepositoryDir.getFunctionalCaseDir(request.getProjectId(), functionalCaseAttachment.getCaseId()) + "/" + saveAttachmentFileId); @@ -362,7 +362,7 @@ public class FunctionalCaseService { List versions = extBaseProjectVersionMapper.getVersionByIds(List.of(functionalCaseDetailDTO.getVersionId())); if (CollectionUtils.isNotEmpty(versions)) { - functionalCaseDetailDTO.setVersionName(versions.get(0).getName()); + functionalCaseDetailDTO.setVersionName(versions.getFirst().getName()); } @@ -483,7 +483,7 @@ public class FunctionalCaseService { if (CollectionUtils.isEmpty(functionalCases)) { throw new MSException(CaseManagementResultCode.FUNCTIONAL_CASE_NOT_FOUND); } - return functionalCases.get(0); + return functionalCases.getFirst(); } @@ -1061,7 +1061,7 @@ public class FunctionalCaseService { example.createCriteria().andNumEqualTo(Long.valueOf(num)).andProjectIdEqualTo(projectId).andDeletedEqualTo(false); List functionalCases = functionalCaseMapper.selectByExample(example); if (CollectionUtils.isNotEmpty(functionalCases)) { - return functionalCases.get(0).getId(); + return functionalCases.getFirst().getId(); } return null; } @@ -1343,8 +1343,8 @@ public class FunctionalCaseService { } private void batchHandImportUpdateLog(FunctionalCaseHistoryLogDTO newData, Map> collect, Map> blobsCollect, Map> customFieldMap, List logDTOS, SessionUser user) { - FunctionalCase oldCase = collect.get(newData.getFunctionalCase().getId()).get(0); - FunctionalCaseBlob oldBlod = blobsCollect.get(newData.getFunctionalCase().getId()).get(0); + FunctionalCase oldCase = collect.get(newData.getFunctionalCase().getId()).getFirst(); + FunctionalCaseBlob oldBlod = blobsCollect.get(newData.getFunctionalCase().getId()).getFirst(); List oldCustomFields = customFieldMap.get(newData.getFunctionalCase().getId()); batchSaveImportData(newData, new FunctionalCaseHistoryLogDTO(oldCase, oldBlod, oldCustomFields, new ArrayList<>(), new ArrayList<>()), user, OperationLogType.IMPORT.name(), OperationLogModule.FUNCTIONAL_CASE, logDTOS); } @@ -1377,7 +1377,7 @@ public class FunctionalCaseService { private void parseUpdateDataToModule(FunctionalCaseExcelData functionalCaseExcelData, FunctionalCaseImportRequest request, String userId, Map caseModulePathMap, TemplateDTO defaultTemplateDTO, FunctionalCaseMapper caseMapper, FunctionalCaseBlobMapper caseBlobMapper, FunctionalCaseCustomFieldMapper customFieldMapper, Map customFieldsMap, Map> collect, List historyLogDTOS) { //用例表 - FunctionalCase functionalCase = collect.get(functionalCaseExcelData.getNum()).get(0); + FunctionalCase functionalCase = collect.get(functionalCaseExcelData.getNum()).getFirst(); functionalCase.setName(functionalCaseExcelData.getName()); functionalCase.setModuleId(caseModulePathMap.get(functionalCaseExcelData.getModule())); @@ -1409,9 +1409,9 @@ public class FunctionalCaseService { } private void addStatusIds(List projectApplications, List caseIds, Map> collect, Map> blobsCollect, FunctionalCaseExcelData functionalCaseExcelData) { - FunctionalCase functionalCase = collect.get(functionalCaseExcelData.getNum()).get(0); - if (CollectionUtils.isNotEmpty(projectApplications) && Boolean.valueOf(projectApplications.get(0).getTypeValue())) { - FunctionalCaseBlob blob = blobsCollect.get(functionalCaseExcelData.getNum()).get(0); + FunctionalCase functionalCase = collect.get(functionalCaseExcelData.getNum()).getFirst(); + if (CollectionUtils.isNotEmpty(projectApplications) && Boolean.valueOf(projectApplications.getFirst().getTypeValue())) { + FunctionalCaseBlob blob = blobsCollect.get(functionalCaseExcelData.getNum()).getFirst(); if (!StringUtils.equals(functionalCase.getName(), functionalCaseExcelData.getName()) || !StringUtils.equals(new String(blob.getSteps(), StandardCharsets.UTF_8), StringUtils.defaultIfBlank(functionalCaseExcelData.getSteps(), StringUtils.EMPTY)) || !StringUtils.equals(new String(blob.getTextDescription(), StandardCharsets.UTF_8), StringUtils.defaultIfBlank(functionalCaseExcelData.getTextDescription(), StringUtils.EMPTY)) diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/service/ReviewFunctionalCaseService.java b/backend/services/case-management/src/main/java/io/metersphere/functional/service/ReviewFunctionalCaseService.java index 20a83ca6b0..760cef320f 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/service/ReviewFunctionalCaseService.java +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/service/ReviewFunctionalCaseService.java @@ -135,7 +135,7 @@ public class ReviewFunctionalCaseService { CaseReviewFunctionalCaseExample caseReviewFunctionalCaseExample = new CaseReviewFunctionalCaseExample(); caseReviewFunctionalCaseExample.createCriteria().andReviewIdEqualTo(request.getReviewId()).andCaseIdEqualTo(request.getCaseId()); List caseReviewFunctionalCases = caseReviewFunctionalCaseMapper.selectByExample(caseReviewFunctionalCaseExample); - String status = caseReviewFunctionalCases.get(0).getStatus(); + String status = caseReviewFunctionalCases.getFirst().getStatus(); if (StringUtils.equals(request.getReviewPassRule(), CaseReviewPassRule.SINGLE.toString())) { if (StringUtils.equalsIgnoreCase(request.getStatus(), FunctionalCaseReviewStatus.UNDER_REVIEWED.toString()) || isAdmin) { functionalCaseStatus = status; @@ -151,10 +151,10 @@ public class ReviewFunctionalCaseService { AtomicInteger unPassCount = new AtomicInteger(); hasReviewedUserMap.forEach((k, v) -> { List list = v.stream().sorted(Comparator.comparing(CaseReviewHistory::getCreateTime).reversed()).toList(); - if (StringUtils.equalsIgnoreCase(list.get(0).getStatus(), FunctionalCaseReviewStatus.PASS.toString())) { + if (StringUtils.equalsIgnoreCase(list.getFirst().getStatus(), FunctionalCaseReviewStatus.PASS.toString())) { passCount.set(passCount.get() + 1); } - if (StringUtils.equalsIgnoreCase(list.get(0).getStatus(), FunctionalCaseReviewStatus.UN_PASS.toString())) { + if (StringUtils.equalsIgnoreCase(list.getFirst().getStatus(), FunctionalCaseReviewStatus.UN_PASS.toString())) { unPassCount.set(unPassCount.get() + 1); } }); diff --git a/backend/services/case-management/src/test/java/io/metersphere/functional/controller/CaseReviewControllerTests.java b/backend/services/case-management/src/test/java/io/metersphere/functional/controller/CaseReviewControllerTests.java index 007c3c6f38..aff833eebd 100644 --- a/backend/services/case-management/src/test/java/io/metersphere/functional/controller/CaseReviewControllerTests.java +++ b/backend/services/case-management/src/test/java/io/metersphere/functional/controller/CaseReviewControllerTests.java @@ -87,7 +87,7 @@ public class CaseReviewControllerTests extends BaseTest { checkLog(caseReview.getId(), OperationLogType.ADD); List caseReviews = getCaseReviews("创建评审1"); Assertions.assertEquals(1, caseReviews.size()); - String caseReviewId = caseReviews.get(0).getId(); + String caseReviewId = caseReviews.getFirst().getId(); CaseReviewUserExample caseReviewUserExample = new CaseReviewUserExample(); caseReviewUserExample.createCriteria().andReviewIdEqualTo(caseReviewId); List caseReviewUsers = caseReviewUserMapper.selectByExample(caseReviewUserExample); @@ -131,7 +131,7 @@ public class CaseReviewControllerTests extends BaseTest { list = caseReviews.stream().map(CaseReview::getId).distinct().toList(); Assertions.assertEquals(1, list.size()); caseReviewFunctionalCaseExample = new CaseReviewFunctionalCaseExample(); - caseReviewFunctionalCaseExample.createCriteria().andReviewIdEqualTo(caseReviews.get(0).getId()); + caseReviewFunctionalCaseExample.createCriteria().andReviewIdEqualTo(caseReviews.getFirst().getId()); caseReviewFunctionalCases = caseReviewFunctionalCaseMapper.selectByExample(caseReviewFunctionalCaseExample); FunctionalCaseExample functionalCaseExample = new FunctionalCaseExample(); functionalCaseExample.createCriteria().andProjectIdEqualTo(baseAssociateCaseRequest.getProjectId()); @@ -194,7 +194,7 @@ public class CaseReviewControllerTests extends BaseTest { this.requestPostWithOk(ADD_CASE_REVIEW, caseReviewRequest); List caseReviews = getCaseReviews("创建评审2"); Assertions.assertEquals(1, caseReviews.size()); - String caseReviewId = caseReviews.get(0).getId(); + String caseReviewId = caseReviews.getFirst().getId(); CaseReviewUserExample caseReviewUserExample = new CaseReviewUserExample(); caseReviewUserExample.createCriteria().andReviewIdEqualTo(caseReviewId); List caseReviewUsers = caseReviewUserMapper.selectByExample(caseReviewUserExample); @@ -213,8 +213,8 @@ public class CaseReviewControllerTests extends BaseTest { this.requestPostWithOk(ADD_CASE_REVIEW, caseReviewRequest); List caseReviews = getCaseReviews("创建评审3"); Assertions.assertEquals(1, caseReviews.size()); - String caseReviewId = caseReviews.get(0).getId(); - Assertions.assertNotNull(caseReviews.get(0).getTags()); + String caseReviewId = caseReviews.getFirst().getId(); + Assertions.assertNotNull(caseReviews.getFirst().getTags()); CaseReviewUserExample caseReviewUserExample = new CaseReviewUserExample(); caseReviewUserExample.createCriteria().andReviewIdEqualTo(caseReviewId); List caseReviewUsers = caseReviewUserMapper.selectByExample(caseReviewUserExample); @@ -245,7 +245,7 @@ public class CaseReviewControllerTests extends BaseTest { @Order(5) public void followCaseReview() throws Exception { List caseReviews = getCaseReviews("创建评审1"); - CaseReview caseReview = caseReviews.get(0); + CaseReview caseReview = caseReviews.getFirst(); CaseReviewFollowerRequest caseReviewFollowerRequest = new CaseReviewFollowerRequest(); caseReviewFollowerRequest.setCaseReviewId(caseReview.getId()); caseReviewFollowerRequest.setUserId("admin"); @@ -276,14 +276,14 @@ public class CaseReviewControllerTests extends BaseTest { @Order(7) public void editCaseReviewSuccess() throws Exception { List caseReviews = getCaseReviews("创建评审1"); - CaseReview caseReview = caseReviews.get(0); + CaseReview caseReview = caseReviews.getFirst(); CaseReviewRequest caseReviewRequest = getCaseReviewAddRequest("创建评审更新1", CaseReviewPassRule.SINGLE.toString(), null, true, true, caseReview.getId()); this.requestPostWithOk(EDIT_CASE_REVIEW, caseReviewRequest); List updateCaseReviews = getCaseReviews("创建评审更新1"); Assertions.assertEquals(1, updateCaseReviews.size()); List caseReviews2 = getCaseReviews("创建评审2"); - CaseReview caseReview2 = caseReviews2.get(0); + CaseReview caseReview2 = caseReviews2.getFirst(); CaseReviewRequest caseReviewRequest2 = getCaseReviewAddRequest("创建评审更新2", CaseReviewPassRule.SINGLE.toString(), null, false, true, caseReview2.getId()); this.requestPostWithOk(EDIT_CASE_REVIEW, caseReviewRequest2); List updateCaseReviews2 = getCaseReviews("创建评审更新2"); @@ -299,7 +299,7 @@ public class CaseReviewControllerTests extends BaseTest { caseReviewRequest = getCaseReviewAddRequest("创建评审更新1", CaseReviewPassRule.SINGLE.toString(), null, true, true, "XXX"); this.requestPost(EDIT_CASE_REVIEW, caseReviewRequest).andExpect(status().is5xxServerError()); List caseReviews = getCaseReviews("创建评审1"); - CaseReview caseReview = caseReviews.get(0); + CaseReview caseReview = caseReviews.getFirst(); CaseReviewRequest caseReviewRequestWidthStartTime = getCaseReviewAddRequest("创建评审更新1", CaseReviewPassRule.SINGLE.toString(), caseReview.getId(), true, true, null); caseReviewRequestWidthStartTime.setStartTime(1678188043000L); caseReviewRequestWidthStartTime.setEndTime(1678188103000L); @@ -324,7 +324,7 @@ public class CaseReviewControllerTests extends BaseTest { public void associateCaseSuccess() throws Exception { List caseReviews = getCaseReviews("创建评审更新1"); Assertions.assertEquals(1, caseReviews.size()); - String caseReviewId = caseReviews.get(0).getId(); + String caseReviewId = caseReviews.getFirst().getId(); CaseReviewAssociateRequest caseReviewAssociateRequest = new CaseReviewAssociateRequest(); caseReviewAssociateRequest.setProjectId(projectId); caseReviewAssociateRequest.setReviewId(caseReviewId); @@ -350,7 +350,7 @@ public class CaseReviewControllerTests extends BaseTest { Assertions.assertTrue(userIdList.contains("gyq_review_test")); Assertions.assertTrue(userIdList.contains("gyq_review_test2")); List caseReviews2 = getCaseReviews("创建评审更新1"); - Assertions.assertTrue( caseReviews.get(0).getCaseCount() caseReviews = getCaseReviews("创建评审更新1"); caseReviewAssociateRequest = new CaseReviewAssociateRequest(); caseReviewAssociateRequest.setProjectId(projectId); - caseReviewAssociateRequest.setReviewId(caseReviews.get(0).getId()); + caseReviewAssociateRequest.setReviewId(caseReviews.getFirst().getId()); baseAssociateCaseRequest = new BaseAssociateCaseRequest(); baseAssociateCaseRequest.setProjectId(projectId); baseAssociateCaseRequest.setSelectAll(false); @@ -385,7 +385,7 @@ public class CaseReviewControllerTests extends BaseTest { caseReviewAssociateRequest = new CaseReviewAssociateRequest(); caseReviewAssociateRequest.setProjectId(projectId); - caseReviewAssociateRequest.setReviewId(caseReviews.get(0).getId()); + caseReviewAssociateRequest.setReviewId(caseReviews.getFirst().getId()); baseAssociateCaseRequest = new BaseAssociateCaseRequest(); baseAssociateCaseRequest.setProjectId("project-gyq-case-review-testYY"); baseAssociateCaseRequest.setSelectAll(true); @@ -453,7 +453,7 @@ public class CaseReviewControllerTests extends BaseTest { Assertions.assertTrue(moduleCount.containsKey("all")); CaseReviewFunctionalCaseExample caseReviewFunctionalCaseExample = new CaseReviewFunctionalCaseExample(); - caseReviewFunctionalCaseExample.createCriteria().andReviewIdEqualTo(caseReviews.get(0).getId()); + caseReviewFunctionalCaseExample.createCriteria().andReviewIdEqualTo(caseReviews.getFirst().getId()); List caseReviewFunctionalCases = caseReviewFunctionalCaseMapper.selectByExample(caseReviewFunctionalCaseExample); Map caseReviewFunctionalCaseMap = caseReviewFunctionalCases.stream().collect(Collectors.toMap(CaseReviewFunctionalCase::getCaseId, t -> t)); caseReviewFunctionalCaseMap.forEach((k, v) -> { @@ -491,11 +491,11 @@ public class CaseReviewControllerTests extends BaseTest { Assertions.assertTrue(JSON.parseArray(JSON.toJSONString(pageData.getList())).size() <= request.getPageSize()); List caseReviewDTOS = JSON.parseArray(JSON.toJSONString(pageData.getList()), CaseReviewDTO.class); List caseReviewOne = caseReviewDTOS.stream().filter(t -> StringUtils.equals(t.getName(), "创建评审更新1")).toList(); - Assertions.assertTrue(caseReviewOne.get(0).getPassCount() > 0); - Assertions.assertTrue(caseReviewOne.get(0).getUnPassCount() > 0); - Assertions.assertTrue(caseReviewOne.get(0).getUnderReviewedCount() > 0); - Assertions.assertTrue(caseReviewOne.get(0).getReReviewedCount() > 0); - Assertions.assertTrue(caseReviewOne.get(0).getReviewedCount() > 0); + Assertions.assertTrue(caseReviewOne.getFirst().getPassCount() > 0); + Assertions.assertTrue(caseReviewOne.getFirst().getUnPassCount() > 0); + Assertions.assertTrue(caseReviewOne.getFirst().getUnderReviewedCount() > 0); + Assertions.assertTrue(caseReviewOne.getFirst().getReReviewedCount() > 0); + Assertions.assertTrue(caseReviewOne.getFirst().getReviewedCount() > 0); request = new CaseReviewPageRequest(); filters = new HashMap<>(); @@ -551,26 +551,26 @@ public class CaseReviewControllerTests extends BaseTest { public void testPos() throws Exception { List caseReviews = getCaseReviews("创建评审更新1"); List caseReviews2 = getCaseReviews("创建评审更新2"); - Long pos = caseReviews.get(0).getPos(); - Long pos2 = caseReviews2.get(0).getPos(); + Long pos = caseReviews.getFirst().getPos(); + Long pos2 = caseReviews2.getFirst().getPos(); PosRequest posRequest = new PosRequest(); posRequest.setProjectId(projectId); - posRequest.setTargetId(caseReviews.get(0).getId()); - posRequest.setMoveId(caseReviews2.get(0).getId()); + posRequest.setTargetId(caseReviews.getFirst().getId()); + posRequest.setMoveId(caseReviews2.getFirst().getId()); posRequest.setMoveMode("AFTER"); this.requestPostWithOkAndReturn(EDIT_POS_CASE_REVIEW_URL, posRequest); caseReviews = getCaseReviews("创建评审更新1"); caseReviews2 = getCaseReviews("创建评审更新2"); - Long pos3 = caseReviews.get(0).getPos(); - Long pos4 = caseReviews2.get(0).getPos(); + Long pos3 = caseReviews.getFirst().getPos(); + Long pos4 = caseReviews2.getFirst().getPos(); Assertions.assertTrue(Objects.equals(pos, pos3)); Assertions.assertTrue(pos2 > pos4); posRequest.setMoveMode("BEFORE"); this.requestPostWithOkAndReturn(EDIT_POS_CASE_REVIEW_URL, posRequest); caseReviews = getCaseReviews("创建评审更新1"); caseReviews2 = getCaseReviews("创建评审更新2"); - Long pos5 = caseReviews.get(0).getPos(); - Long pos6 = caseReviews2.get(0).getPos(); + Long pos5 = caseReviews.getFirst().getPos(); + Long pos6 = caseReviews2.getFirst().getPos(); Assertions.assertTrue(Objects.equals(pos5, pos3)); Assertions.assertTrue(pos6 > pos4); } @@ -579,7 +579,7 @@ public class CaseReviewControllerTests extends BaseTest { @Order(14) public void testFunctionalCaseDetail() throws Exception { List caseReviews = getCaseReviews("创建评审更新1"); - String id = caseReviews.get(0).getId(); + String id = caseReviews.getFirst().getId(); assertErrorCode(this.requestGet(DETAIL_CASE_REVIEW + "ERROR_TEST_FUNCTIONAL_CASE_ID"), CaseManagementResultCode.CASE_REVIEW_NOT_FOUND); MvcResult mvcResult = this.requestGetWithOkAndReturn(DETAIL_CASE_REVIEW + id); // 获取返回值 @@ -593,17 +593,17 @@ public class CaseReviewControllerTests extends BaseTest { @Order(15) public void testBatchMove() throws Exception { List caseReviews = getCaseReviews("创建评审更新1"); - String moduleId = caseReviews.get(0).getModuleId(); + String moduleId = caseReviews.getFirst().getModuleId(); CaseReviewBatchRequest request = new CaseReviewBatchRequest(); request.setProjectId(projectId); request.setMoveModuleId("CASE_REVIEW_REAL_MODULE_ID2"); request.setSelectAll(false); this.requestPostWithOkAndReturn(BATCH_MOVE_CASE_REVIEW, request); request.setSelectAll(true); - request.setExcludeIds(List.of(caseReviews.get(0).getId())); + request.setExcludeIds(List.of(caseReviews.getFirst().getId())); this.requestPostWithOkAndReturn(BATCH_MOVE_CASE_REVIEW, request); caseReviews = getCaseReviews("创建评审更新1"); - String moduleIdNew = caseReviews.get(0).getModuleId(); + String moduleIdNew = caseReviews.getFirst().getModuleId(); Assertions.assertTrue(StringUtils.equals(moduleId, moduleIdNew)); request = new CaseReviewBatchRequest(); request.setProjectId(projectId); @@ -611,7 +611,7 @@ public class CaseReviewControllerTests extends BaseTest { request.setSelectAll(false); this.requestPostWithOkAndReturn(BATCH_MOVE_CASE_REVIEW, request); caseReviews = getCaseReviews("创建评审更新1"); - String moduleIdNewOne = caseReviews.get(0).getModuleId(); + String moduleIdNewOne = caseReviews.getFirst().getModuleId(); Assertions.assertTrue(StringUtils.equals(moduleIdNewOne, moduleIdNew)); request.setMoveModuleId(null); request.setSelectAll(false); @@ -622,7 +622,7 @@ public class CaseReviewControllerTests extends BaseTest { @Order(16) public void testDelete() throws Exception { List caseReviews = getCaseReviews("创建评审更新2"); - delCaseReview(caseReviews.get(0).getId()); + delCaseReview(caseReviews.getFirst().getId()); delCaseReview("caseReviewIdX"); } @@ -633,7 +633,7 @@ public class CaseReviewControllerTests extends BaseTest { public void testDisassociate() throws Exception { List caseReviews = getCaseReviews("创建评审更新1"); Assertions.assertEquals(1, caseReviews.size()); - String caseReviewId = caseReviews.get(0).getId(); + String caseReviewId = caseReviews.getFirst().getId(); CaseReviewFunctionalCaseExample caseReviewFunctionalCaseExample = new CaseReviewFunctionalCaseExample(); caseReviewFunctionalCaseExample.createCriteria().andReviewIdEqualTo(caseReviewId).andCaseIdEqualTo("CASE_REVIEW_TEST_GYQ_ID6"); List caseReviewFunctionalCases = caseReviewFunctionalCaseMapper.selectByExample(caseReviewFunctionalCaseExample); @@ -651,7 +651,7 @@ public class CaseReviewControllerTests extends BaseTest { caseReviews = getCaseReviews("创建评审3"); Assertions.assertEquals(1, caseReviews.size()); - caseReviewId = caseReviews.get(0).getId(); + caseReviewId = caseReviews.getFirst().getId(); CaseReviewAssociateRequest caseReviewAssociateRequest = new CaseReviewAssociateRequest(); caseReviewAssociateRequest.setProjectId(projectId); caseReviewAssociateRequest.setReviewId(caseReviewId); @@ -680,7 +680,7 @@ public class CaseReviewControllerTests extends BaseTest { @Order(18) public void testDisassociateFalse() throws Exception { List caseReviews = getCaseReviews("创建评审更新1"); - String caseReviewId = caseReviews.get(0).getId(); + String caseReviewId = caseReviews.getFirst().getId(); mockMvc.perform(MockMvcRequestBuilders.get(DISASSOCIATE_CASE_REVIEW+caseReviewId+"/CASE_REVIEW_TEST_GYQ_IDXX").header(SessionConstants.HEADER_TOKEN, sessionId) .header(SessionConstants.CSRF_TOKEN, csrfToken) .header(SessionConstants.CURRENT_PROJECT, projectId) diff --git a/backend/services/case-management/src/test/java/io/metersphere/functional/controller/CaseReviewFunctionalCaseControllerTests.java b/backend/services/case-management/src/test/java/io/metersphere/functional/controller/CaseReviewFunctionalCaseControllerTests.java index 8effe81d8e..04ea454c84 100644 --- a/backend/services/case-management/src/test/java/io/metersphere/functional/controller/CaseReviewFunctionalCaseControllerTests.java +++ b/backend/services/case-management/src/test/java/io/metersphere/functional/controller/CaseReviewFunctionalCaseControllerTests.java @@ -238,7 +238,7 @@ public class CaseReviewFunctionalCaseControllerTests extends BaseTest { @Order(7) public void testPos() throws Exception { List caseReviewList = getCaseReviewFunctionalCase("wx_review_id_1"); - CaseReviewFunctionalCase caseReviews = caseReviewList.get(0); + CaseReviewFunctionalCase caseReviews = caseReviewList.getFirst(); CaseReviewFunctionalCase caseReviews2 = caseReviewList.get(1); Long pos = caseReviews.getPos(); Long pos2 = caseReviews2.getPos(); @@ -251,7 +251,7 @@ public class CaseReviewFunctionalCaseControllerTests extends BaseTest { this.requestPostWithOkAndReturn(REVIEW_FUNCTIONAL_CASE_POS, posRequest); caseReviewList = getCaseReviewFunctionalCase("wx_review_id_1"); caseReviews = caseReviewList.get(1); - caseReviews2 = caseReviewList.get(0); + caseReviews2 = caseReviewList.getFirst(); Long pos3 = caseReviews.getPos(); Long pos4 = caseReviews2.getPos(); Assertions.assertTrue(Objects.equals(pos, pos3)); @@ -259,7 +259,7 @@ public class CaseReviewFunctionalCaseControllerTests extends BaseTest { posRequest.setMoveMode("BEFORE"); this.requestPostWithOkAndReturn(REVIEW_FUNCTIONAL_CASE_POS, posRequest); caseReviewList = getCaseReviewFunctionalCase("wx_review_id_1"); - caseReviews = caseReviewList.get(0); + caseReviews = caseReviewList.getFirst(); caseReviews2 = caseReviewList.get(1); Long pos5 = caseReviews.getPos(); Long pos6 = caseReviews2.getPos(); diff --git a/backend/services/case-management/src/test/java/io/metersphere/functional/controller/FunctionalCaseCommentControllerTests.java b/backend/services/case-management/src/test/java/io/metersphere/functional/controller/FunctionalCaseCommentControllerTests.java index 35fe9324f1..f1fed71bc3 100644 --- a/backend/services/case-management/src/test/java/io/metersphere/functional/controller/FunctionalCaseCommentControllerTests.java +++ b/backend/services/case-management/src/test/java/io/metersphere/functional/controller/FunctionalCaseCommentControllerTests.java @@ -435,7 +435,7 @@ public class FunctionalCaseCommentControllerTests { FunctionalCaseCommentExample functionalCaseCommentExample = new FunctionalCaseCommentExample(); functionalCaseCommentExample.createCriteria().andCaseIdEqualTo("xiaomeinvGTest").andNotifierEqualTo("default-project-member-user-guo;default-project-member-user-guo;default-project-member-user-guo-4;"); List functionalCaseComments = functionalCaseCommentMapper.selectByExample(functionalCaseCommentExample); - String id = functionalCaseComments.get(0).getId(); + String id = functionalCaseComments.getFirst().getId(); Assertions.assertFalse(functionalCaseComments.isEmpty()); delFunctionalCaseComment(id); functionalCaseCommentExample = new FunctionalCaseCommentExample(); @@ -517,7 +517,7 @@ public class FunctionalCaseCommentControllerTests { FunctionalCaseCommentExample functionalCaseCommentExample = new FunctionalCaseCommentExample(); functionalCaseCommentExample.createCriteria().andCaseIdEqualTo("xiaomeinvGTest"); List functionalCaseComments = functionalCaseCommentMapper.selectByExample(functionalCaseCommentExample); - return functionalCaseComments.get(0); + return functionalCaseComments.getFirst(); } } diff --git a/backend/services/case-management/src/test/java/io/metersphere/functional/controller/FunctionalCaseDemandControllerTests.java b/backend/services/case-management/src/test/java/io/metersphere/functional/controller/FunctionalCaseDemandControllerTests.java index 985890afd4..bc66dfc183 100644 --- a/backend/services/case-management/src/test/java/io/metersphere/functional/controller/FunctionalCaseDemandControllerTests.java +++ b/backend/services/case-management/src/test/java/io/metersphere/functional/controller/FunctionalCaseDemandControllerTests.java @@ -273,7 +273,7 @@ public class FunctionalCaseDemandControllerTests extends BaseTest { functionalCaseDemandExample = new FunctionalCaseDemandExample(); functionalCaseDemandExample.createCriteria().andCaseIdEqualTo("DEMAND_TEST_FUNCTIONAL_CASE_ID"); functionalCaseDemands = functionalCaseDemandMapper.selectByExample(functionalCaseDemandExample); - Assertions.assertTrue(StringUtils.equals(functionalCaseDemands.get(0).getDemandName(), "手动加入2")); + Assertions.assertTrue(StringUtils.equals(functionalCaseDemands.getFirst().getDemandName(), "手动加入2")); } @Test @@ -292,7 +292,7 @@ public class FunctionalCaseDemandControllerTests extends BaseTest { functionalCaseDemandExample = new FunctionalCaseDemandExample(); functionalCaseDemandExample.createCriteria().andCaseIdEqualTo("DEMAND_TEST_FUNCTIONAL_CASE_ID"); functionalCaseDemands = functionalCaseDemandMapper.selectByExample(functionalCaseDemandExample); - Assertions.assertTrue(StringUtils.equals(functionalCaseDemands.get(0).getDemandName(), "手动加入2")); + Assertions.assertTrue(StringUtils.equals(functionalCaseDemands.getFirst().getDemandName(), "手动加入2")); } @Test @@ -314,7 +314,7 @@ public class FunctionalCaseDemandControllerTests extends BaseTest { functionalCaseDemandExample = new FunctionalCaseDemandExample(); functionalCaseDemandExample.createCriteria().andCaseIdEqualTo("DEMAND_TEST_FUNCTIONAL_CASE_ID"); functionalCaseDemands = functionalCaseDemandMapper.selectByExample(functionalCaseDemandExample); - Assertions.assertNotNull(functionalCaseDemands.get(0).getDemandId()); + Assertions.assertNotNull(functionalCaseDemands.getFirst().getDemandId()); functionalCaseDemandRequest = new FunctionalCaseDemandRequest(); functionalCaseDemandRequest.setId("hehe"); @@ -344,7 +344,7 @@ public class FunctionalCaseDemandControllerTests extends BaseTest { FunctionalCaseDemandExample functionalCaseDemandExample = new FunctionalCaseDemandExample(); functionalCaseDemandExample.createCriteria().andCaseIdEqualTo(caseId); List functionalCaseDemands = functionalCaseDemandMapper.selectByExample(functionalCaseDemandExample); - return functionalCaseDemands.get(0).getId(); + return functionalCaseDemands.getFirst().getId(); } @Test diff --git a/backend/services/case-management/src/test/java/io/metersphere/functional/controller/FunctionalCaseMinderControllerTest.java b/backend/services/case-management/src/test/java/io/metersphere/functional/controller/FunctionalCaseMinderControllerTest.java index f63a5bebd3..7e5b678938 100644 --- a/backend/services/case-management/src/test/java/io/metersphere/functional/controller/FunctionalCaseMinderControllerTest.java +++ b/backend/services/case-management/src/test/java/io/metersphere/functional/controller/FunctionalCaseMinderControllerTest.java @@ -291,7 +291,7 @@ public class FunctionalCaseMinderControllerTest extends BaseTest { FunctionalCaseCustomFieldExample customFieldExample = new FunctionalCaseCustomFieldExample(); customFieldExample.createCriteria().andCaseIdEqualTo("TEST_FUNCTIONAL_MINDER_CASE_ID_1").andFieldIdEqualTo("custom_field_minder_gyq_id_3"); List functionalCaseCustomFields = functionalCaseCustomFieldMapper.selectByExample(customFieldExample); - Assertions.assertTrue(StringUtils.equalsIgnoreCase(functionalCaseCustomFields.get(0).getValue(),"P0")); + Assertions.assertTrue(StringUtils.equalsIgnoreCase(functionalCaseCustomFields.getFirst().getValue(),"P0")); FunctionalCaseModule functionalCaseModule = functionalCaseModuleMapper.selectByPrimaryKey("TEST_MINDER_MODULE_ID_GYQ7"); Assertions.assertTrue(StringUtils.equalsIgnoreCase(functionalCaseModule.getName(),"移动7")); @@ -313,18 +313,18 @@ public class FunctionalCaseMinderControllerTest extends BaseTest { functionalCaseExample.createCriteria().andNameEqualTo("新增用例"); functionalCases = functionalCaseMapper.selectByExample(functionalCaseExample); Assertions.assertTrue(CollectionUtils.isNotEmpty(functionalCases)); - Assertions.assertTrue(functionalCases.get(0).getPos() > 0L); + Assertions.assertTrue(functionalCases.getFirst().getPos() > 0L); Assertions.assertTrue(CollectionUtils.isNotEmpty(functionalCases)); customFieldExample = new FunctionalCaseCustomFieldExample(); - customFieldExample.createCriteria().andCaseIdEqualTo(functionalCases.get(0).getId()).andFieldIdEqualTo("custom_field_minder_gyq_id_3"); + customFieldExample.createCriteria().andCaseIdEqualTo(functionalCases.getFirst().getId()).andFieldIdEqualTo("custom_field_minder_gyq_id_3"); functionalCaseCustomFields = functionalCaseCustomFieldMapper.selectByExample(customFieldExample); - Assertions.assertTrue(StringUtils.equalsIgnoreCase(functionalCaseCustomFields.get(0).getValue(),"P2")); + Assertions.assertTrue(StringUtils.equalsIgnoreCase(functionalCaseCustomFields.getFirst().getValue(),"P2")); FunctionalCaseModuleExample functionalCaseModuleExample = new FunctionalCaseModuleExample(); functionalCaseModuleExample.createCriteria().andNameEqualTo("新增9"); List functionalCaseModules = functionalCaseModuleMapper.selectByExample(functionalCaseModuleExample); Assertions.assertTrue(CollectionUtils.isNotEmpty(functionalCaseModules)); - Assertions.assertTrue(functionalCaseModules.get(0).getPos() > 0L); + Assertions.assertTrue(functionalCaseModules.getFirst().getPos() > 0L); request = new FunctionalCaseMinderEditRequest(); request.setProjectId("project-case-minder-test"); request.setVersionId("ffff"); diff --git a/backend/services/case-management/src/test/java/io/metersphere/functional/controller/FunctionalCaseReviewControllerTests.java b/backend/services/case-management/src/test/java/io/metersphere/functional/controller/FunctionalCaseReviewControllerTests.java index 6339c69c51..16c271298f 100644 --- a/backend/services/case-management/src/test/java/io/metersphere/functional/controller/FunctionalCaseReviewControllerTests.java +++ b/backend/services/case-management/src/test/java/io/metersphere/functional/controller/FunctionalCaseReviewControllerTests.java @@ -76,7 +76,7 @@ public class FunctionalCaseReviewControllerTests extends BaseTest { caseReviewHistory.setCreateTime(System.currentTimeMillis()); caseReviewHistoryMapper.insertSelective(caseReviewHistory); List gyqReviewCaseTest = getCaseReviewHistoryList("gyqReviewCaseTest"); - Assertions.assertTrue(StringUtils.isNotBlank(gyqReviewCaseTest.get(0).getContentText())); + Assertions.assertTrue(StringUtils.isNotBlank(gyqReviewCaseTest.getFirst().getContentText())); caseReviewHistory = new CaseReviewHistory(); caseReviewHistory.setReviewId("用例关系名称2"); caseReviewHistory.setCaseId("gyqReviewCaseTest"); diff --git a/backend/services/case-management/src/test/java/io/metersphere/functional/controller/FunctionalTestCaseControllerTests.java b/backend/services/case-management/src/test/java/io/metersphere/functional/controller/FunctionalTestCaseControllerTests.java index e0bdde030d..584ca1088d 100644 --- a/backend/services/case-management/src/test/java/io/metersphere/functional/controller/FunctionalTestCaseControllerTests.java +++ b/backend/services/case-management/src/test/java/io/metersphere/functional/controller/FunctionalTestCaseControllerTests.java @@ -581,7 +581,7 @@ public class FunctionalTestCaseControllerTests extends BaseTest { testPlanCaseExecuteHistory.setCreateTime(System.currentTimeMillis()); testPlanCaseExecuteHistoryMapper.insertSelective(testPlanCaseExecuteHistory); List gyqReviewCaseTest = getPlanExecuteHistoryList("gyq_associate_function_case"); - Assertions.assertTrue(StringUtils.isNotBlank(gyqReviewCaseTest.get(0).getContentText())); + Assertions.assertTrue(StringUtils.isNotBlank(gyqReviewCaseTest.getFirst().getContentText())); testPlanCaseExecuteHistory = new TestPlanCaseExecuteHistory(); testPlanCaseExecuteHistory.setTestPlanCaseId("test_plan_associate_case_gyq_two"); testPlanCaseExecuteHistory.setTestPlanId("associate_case_plan_gyq_two"); diff --git a/backend/services/case-management/src/test/java/io/metersphere/functional/controller/ReviewFunctionalCaseControllerTests.java b/backend/services/case-management/src/test/java/io/metersphere/functional/controller/ReviewFunctionalCaseControllerTests.java index a628983181..18c74fc576 100644 --- a/backend/services/case-management/src/test/java/io/metersphere/functional/controller/ReviewFunctionalCaseControllerTests.java +++ b/backend/services/case-management/src/test/java/io/metersphere/functional/controller/ReviewFunctionalCaseControllerTests.java @@ -94,7 +94,7 @@ public class ReviewFunctionalCaseControllerTests extends BaseTest { reviewers.add("admin"); reviewers.add("default-project-member-user-gyq"); List caseReviews = addReview("创建用例评审1", caseIds, reviewers, CaseReviewPassRule.SINGLE.toString()); - String reviewId = caseReviews.get(0).getId(); + String reviewId = caseReviews.getFirst().getId(); ReviewFunctionalCaseRequest reviewFunctionalCaseRequest = new ReviewFunctionalCaseRequest(); reviewFunctionalCaseRequest.setReviewId(reviewId); reviewFunctionalCaseRequest.setCaseId("gyqReviewCaseTest"); @@ -111,7 +111,7 @@ public class ReviewFunctionalCaseControllerTests extends BaseTest { CaseReviewFunctionalCaseExample caseReviewFunctionalCaseExample = new CaseReviewFunctionalCaseExample(); caseReviewFunctionalCaseExample.createCriteria().andReviewIdEqualTo(reviewId).andCaseIdEqualTo("gyqReviewCaseTest"); List caseReviewFunctionalCases = caseReviewFunctionalCaseMapper.selectByExample(caseReviewFunctionalCaseExample); - Assertions.assertTrue(StringUtils.equalsIgnoreCase(caseReviewFunctionalCases.get(0).getStatus(), FunctionalCaseReviewStatus.PASS.toString())); + Assertions.assertTrue(StringUtils.equalsIgnoreCase(caseReviewFunctionalCases.getFirst().getStatus(), FunctionalCaseReviewStatus.PASS.toString())); //单人评审不通过 reviewFunctionalCaseRequest = new ReviewFunctionalCaseRequest(); reviewFunctionalCaseRequest.setReviewId(reviewId); @@ -129,7 +129,7 @@ public class ReviewFunctionalCaseControllerTests extends BaseTest { caseReviewFunctionalCaseExample = new CaseReviewFunctionalCaseExample(); caseReviewFunctionalCaseExample.createCriteria().andReviewIdEqualTo(reviewId).andCaseIdEqualTo("gyqReviewCaseTestOne"); caseReviewFunctionalCases = caseReviewFunctionalCaseMapper.selectByExample(caseReviewFunctionalCaseExample); - Assertions.assertTrue(StringUtils.equalsIgnoreCase(caseReviewFunctionalCases.get(0).getStatus(), FunctionalCaseReviewStatus.UN_PASS.toString())); + Assertions.assertTrue(StringUtils.equalsIgnoreCase(caseReviewFunctionalCases.getFirst().getStatus(), FunctionalCaseReviewStatus.UN_PASS.toString())); reviewFunctionalCaseRequest = new ReviewFunctionalCaseRequest(); @@ -148,7 +148,7 @@ public class ReviewFunctionalCaseControllerTests extends BaseTest { caseReviewFunctionalCaseExample = new CaseReviewFunctionalCaseExample(); caseReviewFunctionalCaseExample.createCriteria().andReviewIdEqualTo(reviewId).andCaseIdEqualTo("gyqReviewCaseTestOne"); caseReviewFunctionalCases = caseReviewFunctionalCaseMapper.selectByExample(caseReviewFunctionalCaseExample); - Assertions.assertTrue(StringUtils.equalsIgnoreCase(caseReviewFunctionalCases.get(0).getStatus(), FunctionalCaseReviewStatus.RE_REVIEWED.toString())); + Assertions.assertTrue(StringUtils.equalsIgnoreCase(caseReviewFunctionalCases.getFirst().getStatus(), FunctionalCaseReviewStatus.RE_REVIEWED.toString())); reviewFunctionalCaseRequest = new ReviewFunctionalCaseRequest(); reviewFunctionalCaseRequest.setReviewId(reviewId); @@ -161,7 +161,7 @@ public class ReviewFunctionalCaseControllerTests extends BaseTest { reviewFunctionalCaseService.saveReview(reviewFunctionalCaseRequest, "default-project-member-user-gyq-4"); caseReviewFunctionalCaseExample.createCriteria().andReviewIdEqualTo(reviewId).andCaseIdEqualTo("gyqReviewCaseTestOne"); caseReviewFunctionalCases = caseReviewFunctionalCaseMapper.selectByExample(caseReviewFunctionalCaseExample); - Assertions.assertTrue(StringUtils.equalsIgnoreCase(caseReviewFunctionalCases.get(0).getStatus(), FunctionalCaseReviewStatus.RE_REVIEWED.toString())); + Assertions.assertTrue(StringUtils.equalsIgnoreCase(caseReviewFunctionalCases.getFirst().getStatus(), FunctionalCaseReviewStatus.RE_REVIEWED.toString())); reviewFunctionalCaseRequest = new ReviewFunctionalCaseRequest(); reviewFunctionalCaseRequest.setReviewId(reviewId); @@ -174,7 +174,7 @@ public class ReviewFunctionalCaseControllerTests extends BaseTest { reviewFunctionalCaseService.saveReview(reviewFunctionalCaseRequest, "admin"); caseReviewFunctionalCaseExample.createCriteria().andReviewIdEqualTo(reviewId).andCaseIdEqualTo("gyqReviewCaseTestOne"); caseReviewFunctionalCases = caseReviewFunctionalCaseMapper.selectByExample(caseReviewFunctionalCaseExample); - Assertions.assertTrue(StringUtils.equalsIgnoreCase(caseReviewFunctionalCases.get(0).getStatus(), FunctionalCaseReviewStatus.RE_REVIEWED.toString())); + Assertions.assertTrue(StringUtils.equalsIgnoreCase(caseReviewFunctionalCases.getFirst().getStatus(), FunctionalCaseReviewStatus.RE_REVIEWED.toString())); } @Test @@ -187,7 +187,7 @@ public class ReviewFunctionalCaseControllerTests extends BaseTest { reviewers.add("admin"); reviewers.add("default-project-member-user-gyq"); List caseReviews = addReview("创建用例评审2", caseIds, reviewers, CaseReviewPassRule.MULTIPLE.toString()); - String reviewId = caseReviews.get(0).getId(); + String reviewId = caseReviews.getFirst().getId(); CaseReviewHistory caseReviewHistory = new CaseReviewHistory(); caseReviewHistory.setReviewId(reviewId); caseReviewHistory.setCaseId("gyqReviewCaseTestTwo"); @@ -213,9 +213,9 @@ public class ReviewFunctionalCaseControllerTests extends BaseTest { CaseReviewFunctionalCaseExample caseReviewFunctionalCaseExample = new CaseReviewFunctionalCaseExample(); caseReviewFunctionalCaseExample.createCriteria().andReviewIdEqualTo(reviewId).andCaseIdEqualTo("gyqReviewCaseTestTwo"); List caseReviewFunctionalCases = caseReviewFunctionalCaseMapper.selectByExample(caseReviewFunctionalCaseExample); - Assertions.assertTrue(StringUtils.equalsIgnoreCase(caseReviewFunctionalCases.get(0).getStatus(), FunctionalCaseReviewStatus.UNDER_REVIEWED.toString())); + Assertions.assertTrue(StringUtils.equalsIgnoreCase(caseReviewFunctionalCases.getFirst().getStatus(), FunctionalCaseReviewStatus.UNDER_REVIEWED.toString())); List caseReviews1 = getCaseReviews("创建用例评审2"); - System.out.println(caseReviews1.get(0).getStatus()); + System.out.println(caseReviews1.getFirst().getStatus()); reviewFunctionalCaseRequest = new ReviewFunctionalCaseRequest(); @@ -247,7 +247,7 @@ public class ReviewFunctionalCaseControllerTests extends BaseTest { List reviewers = new ArrayList<>(); reviewers.add("admin"); List caseReviews = addReview("创建用例评审3", caseIds, reviewers, CaseReviewPassRule.MULTIPLE.toString()); - String reviewId = caseReviews.get(0).getId(); + String reviewId = caseReviews.getFirst().getId(); ReviewFunctionalCaseRequest reviewFunctionalCaseRequest = new ReviewFunctionalCaseRequest(); reviewFunctionalCaseRequest.setReviewId(reviewId); reviewFunctionalCaseRequest.setCaseId("gyqReviewCaseTestThree"); @@ -264,7 +264,7 @@ public class ReviewFunctionalCaseControllerTests extends BaseTest { CaseReviewFunctionalCaseExample caseReviewFunctionalCaseExample = new CaseReviewFunctionalCaseExample(); caseReviewFunctionalCaseExample.createCriteria().andReviewIdEqualTo(reviewId).andCaseIdEqualTo("gyqReviewCaseTestThree"); List caseReviewFunctionalCases = caseReviewFunctionalCaseMapper.selectByExample(caseReviewFunctionalCaseExample); - Assertions.assertTrue(StringUtils.equalsIgnoreCase(caseReviewFunctionalCases.get(0).getStatus(), FunctionalCaseReviewStatus.PASS.toString())); + Assertions.assertTrue(StringUtils.equalsIgnoreCase(caseReviewFunctionalCases.getFirst().getStatus(), FunctionalCaseReviewStatus.PASS.toString())); reviewFunctionalCaseRequest = new ReviewFunctionalCaseRequest(); reviewFunctionalCaseRequest.setReviewId(reviewId); @@ -282,7 +282,7 @@ public class ReviewFunctionalCaseControllerTests extends BaseTest { caseReviewFunctionalCaseExample = new CaseReviewFunctionalCaseExample(); caseReviewFunctionalCaseExample.createCriteria().andReviewIdEqualTo(reviewId).andCaseIdEqualTo("gyqReviewCaseTestFour"); caseReviewFunctionalCases = caseReviewFunctionalCaseMapper.selectByExample(caseReviewFunctionalCaseExample); - Assertions.assertTrue(StringUtils.equalsIgnoreCase(caseReviewFunctionalCases.get(0).getStatus(), FunctionalCaseReviewStatus.UN_PASS.toString())); + Assertions.assertTrue(StringUtils.equalsIgnoreCase(caseReviewFunctionalCases.getFirst().getStatus(), FunctionalCaseReviewStatus.UN_PASS.toString())); } @@ -297,7 +297,7 @@ public class ReviewFunctionalCaseControllerTests extends BaseTest { List reviewers = new ArrayList<>(); reviewers.add("admin"); List caseReviews = addReview("创建用例评审4", caseIds, reviewers, CaseReviewPassRule.SINGLE.toString()); - String reviewId = caseReviews.get(0).getId(); + String reviewId = caseReviews.getFirst().getId(); ReviewFunctionalCaseRequest reviewFunctionalCaseRequest = new ReviewFunctionalCaseRequest(); reviewFunctionalCaseRequest.setReviewId(reviewId); reviewFunctionalCaseRequest.setCaseId("gyqReviewCaseTestFour"); @@ -313,7 +313,7 @@ public class ReviewFunctionalCaseControllerTests extends BaseTest { @Order(4) public void getListSuccess() throws Exception { List caseReviews = getCaseReviews("创建用例评审1"); - String reviewId = caseReviews.get(0).getId(); + String reviewId = caseReviews.getFirst().getId(); CaseReviewHistory caseReviewHistory = new CaseReviewHistory(); caseReviewHistory.setReviewId(reviewId); caseReviewHistory.setCaseId("gyqReviewCaseTest"); diff --git a/backend/services/project-management/src/main/java/io/metersphere/project/dto/environment/ssl/KeyStoreConfig.java b/backend/services/project-management/src/main/java/io/metersphere/project/dto/environment/ssl/KeyStoreConfig.java index 1a499cd4d1..78acadf9c7 100644 --- a/backend/services/project-management/src/main/java/io/metersphere/project/dto/environment/ssl/KeyStoreConfig.java +++ b/backend/services/project-management/src/main/java/io/metersphere/project/dto/environment/ssl/KeyStoreConfig.java @@ -19,10 +19,10 @@ public class KeyStoreConfig { if (CollectionUtils.isNotEmpty(entry)) { List entryList = this.entry.stream().filter(KeyStoreEntry::isDefault).collect(Collectors.toList()); if (CollectionUtils.isNotEmpty(entryList)) { - if (StringUtils.isNotEmpty(entryList.get(0).getNewAsName())) { - return entryList.get(0).getNewAsName(); + if (StringUtils.isNotEmpty(entryList.getFirst().getNewAsName())) { + return entryList.getFirst().getNewAsName(); } else { - return entryList.get(0).getOriginalAsName(); + return entryList.getFirst().getOriginalAsName(); } } } @@ -33,7 +33,7 @@ public class KeyStoreConfig { if (CollectionUtils.isNotEmpty(entry)) { List entryList = this.entry.stream().filter(ks -> StringUtils.equals(asName, ks.getNewAsName())).collect(Collectors.toList()); if (CollectionUtils.isNotEmpty(entryList) && CollectionUtils.isNotEmpty(files) && files.size() == 1) { - return entryList.get(0).getOriginalAsName(); + return entryList.getFirst().getOriginalAsName(); } } return asName; diff --git a/backend/services/project-management/src/main/java/io/metersphere/project/service/MessageTaskLogService.java b/backend/services/project-management/src/main/java/io/metersphere/project/service/MessageTaskLogService.java index dc6ad65b15..7f25b32181 100644 --- a/backend/services/project-management/src/main/java/io/metersphere/project/service/MessageTaskLogService.java +++ b/backend/services/project-management/src/main/java/io/metersphere/project/service/MessageTaskLogService.java @@ -60,7 +60,7 @@ public class MessageTaskLogService { dto.setPath("/notice/message/task/save"); dto.setMethod(HttpMethodConstants.POST.name()); if (CollectionUtils.isNotEmpty(messageTasks)) { - dto.setOriginalValue(JSON.toJSONBytes(messageTasks.get(0))); + dto.setOriginalValue(JSON.toJSONBytes(messageTasks.getFirst())); } return dto; } @@ -136,7 +136,7 @@ public class MessageTaskLogService { ProjectRobotExample projectRobotExample = new ProjectRobotExample(); projectRobotExample.createCriteria().andProjectIdEqualTo(projectId).andPlatformEqualTo(NoticeConstants.Type.IN_SITE); List projectRobots = projectRobotMapper.selectByExample(projectRobotExample); - robotId = projectRobots.get(0).getId(); + robotId = projectRobots.getFirst().getId(); } return robotId; } diff --git a/backend/services/project-management/src/main/java/io/metersphere/project/service/NoticeMessageTaskService.java b/backend/services/project-management/src/main/java/io/metersphere/project/service/NoticeMessageTaskService.java index ae5ae5a066..a445c3b15e 100644 --- a/backend/services/project-management/src/main/java/io/metersphere/project/service/NoticeMessageTaskService.java +++ b/backend/services/project-management/src/main/java/io/metersphere/project/service/NoticeMessageTaskService.java @@ -85,7 +85,7 @@ public class NoticeMessageTaskService { sqlSession.flushStatements(); SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory); if (CollectionUtils.isNotEmpty(stringListMap.get(NO_USER_NAMES))) { - String message = Translator.get("alert_others") + stringListMap.get(NO_USER_NAMES).get(0) + Translator.get("user.remove"); + String message = Translator.get("alert_others") + stringListMap.get(NO_USER_NAMES).getFirst() + Translator.get("user.remove"); return ResultHolder.successCodeErrorInfo(ProjectResultCode.SAVE_MESSAGE_TASK_USER_NO_EXIST.getCode(), message); } return ResultHolder.success("OK"); @@ -130,7 +130,7 @@ public class NoticeMessageTaskService { ProjectRobotExample projectRobotExample = new ProjectRobotExample(); projectRobotExample.createCriteria().andProjectIdEqualTo(projectId).andPlatformEqualTo(NoticeConstants.Type.IN_SITE); List projectRobots = projectRobotMapper.selectByExample(projectRobotExample); - return projectRobots.get(0); + return projectRobots.getFirst(); } else { return projectRobotMapper.selectByPrimaryKey(robotId); } @@ -503,9 +503,9 @@ public class NoticeMessageTaskService { } Map> messageRobotMap = messageTasks.stream().collect(Collectors.groupingBy(MessageTask::getProjectRobotId)); if (CollectionUtils.isNotEmpty(messageRobotMap.get(robotId))) { - messageTask = messageRobotMap.get(robotId).get(0); + messageTask = messageRobotMap.get(robotId).getFirst(); } else { - messageTask = messageTasks.get(0); + messageTask = messageTasks.getFirst(); messageTask.setEnable(false); messageTask.setUseDefaultTemplate(true); messageTask.setUseDefaultSubject(true); diff --git a/backend/services/project-management/src/main/java/io/metersphere/project/service/ProjectApplicationService.java b/backend/services/project-management/src/main/java/io/metersphere/project/service/ProjectApplicationService.java index 2e7bfbe49e..085ac81bb7 100644 --- a/backend/services/project-management/src/main/java/io/metersphere/project/service/ProjectApplicationService.java +++ b/backend/services/project-management/src/main/java/io/metersphere/project/service/ProjectApplicationService.java @@ -422,7 +422,7 @@ public class ProjectApplicationService { example.createCriteria().andTypeEqualTo(String.valueOf(module)).andProjectIdEqualTo(projectId); List applications = projectApplicationMapper.selectByExample(example); if (CollectionUtils.isNotEmpty(applications)) { - moduleMap.put(String.valueOf(module), Boolean.valueOf(applications.get(0).getTypeValue())); + moduleMap.put(String.valueOf(module), Boolean.valueOf(applications.getFirst().getTypeValue())); } else { moduleMap.put(String.valueOf(module), Boolean.TRUE); } @@ -542,7 +542,7 @@ public class ProjectApplicationService { example.createCriteria().andProjectIdEqualTo(projectId).andTypeLike(ProjectApplicationType.BUG.BUG_SYNC.name() + "_" + ProjectApplicationType.PLATFORM_BUG_CONFIG.BUG_PLATFORM_CONFIG.name()); List list = projectApplicationMapper.selectByExample(example); if (CollectionUtils.isNotEmpty(list)) { - return list.get(0).getTypeValue().replaceAll("\\\\", ""); + return list.getFirst().getTypeValue().replaceAll("\\\\", ""); } return null; } @@ -559,7 +559,7 @@ public class ProjectApplicationService { example.createCriteria().andProjectIdEqualTo(projectId).andTypeLike(ProjectApplicationType.CASE_RELATED_CONFIG.CASE_RELATED.name() + "_" + ProjectApplicationType.PLATFORM_DEMAND_CONFIG.DEMAND_PLATFORM_CONFIG.name()); List list = projectApplicationMapper.selectByExample(example); if (CollectionUtils.isNotEmpty(list)) { - return list.get(0).getTypeValue().replaceAll("\\\\", ""); + return list.getFirst().getTypeValue().replaceAll("\\\\", ""); } return null; } @@ -568,7 +568,7 @@ public class ProjectApplicationService { ProjectApplicationExample example = new ProjectApplicationExample(); example.createCriteria().andProjectIdEqualTo(projectId).andTypeEqualTo(type); List projectApplications = projectApplicationMapper.selectByExample(example); - return CollectionUtils.isEmpty(projectApplications) ? null : projectApplications.get(0); + return CollectionUtils.isEmpty(projectApplications) ? null : projectApplications.getFirst(); } /** @@ -604,7 +604,7 @@ public class ProjectApplicationService { example.createCriteria().andProjectIdEqualTo(projectId).andTypeEqualTo(ProjectApplicationType.BUG.BUG_SYNC.name() + "_MECHANISM"); List list = projectApplicationMapper.selectByExample(example); if (CollectionUtils.isNotEmpty(list)) { - return StringUtils.equals(list.get(0).getTypeValue(), "increment"); + return StringUtils.equals(list.getFirst().getTypeValue(), "increment"); } else { return false; } diff --git a/backend/services/project-management/src/main/java/io/metersphere/project/service/ProjectRobotService.java b/backend/services/project-management/src/main/java/io/metersphere/project/service/ProjectRobotService.java index 1c3279d8e5..3d1998074d 100644 --- a/backend/services/project-management/src/main/java/io/metersphere/project/service/ProjectRobotService.java +++ b/backend/services/project-management/src/main/java/io/metersphere/project/service/ProjectRobotService.java @@ -128,11 +128,11 @@ public class ProjectRobotService { List newProjectRobots = new ArrayList<>(list.stream().sorted(Comparator.comparing(ProjectRobot::getCreateTime).reversed()).toList()); List mailRobot = collect.get(NoticeConstants.Type.MAIL); if (CollectionUtils.isNotEmpty(mailRobot)) { - newProjectRobots.add(0, mailRobot.get(0)); + newProjectRobots.add(0, mailRobot.getFirst()); } List inSiteRobot = collect.get(NoticeConstants.Type.IN_SITE); if (CollectionUtils.isNotEmpty(inSiteRobot)) { - newProjectRobots.add(0, inSiteRobot.get(0)); + newProjectRobots.add(0, inSiteRobot.getFirst()); } return newProjectRobots; } diff --git a/backend/services/project-management/src/main/java/io/metersphere/project/service/ProjectTemplateService.java b/backend/services/project-management/src/main/java/io/metersphere/project/service/ProjectTemplateService.java index e216cac076..1dd9975c95 100644 --- a/backend/services/project-management/src/main/java/io/metersphere/project/service/ProjectTemplateService.java +++ b/backend/services/project-management/src/main/java/io/metersphere/project/service/ProjectTemplateService.java @@ -212,7 +212,7 @@ public class ProjectTemplateService extends BaseTemplateService { .andScopeIdEqualTo(projectId) .andSceneEqualTo(scene) .andInternalEqualTo(true); - return templateMapper.selectByExample(example).get(0); + return templateMapper.selectByExample(example).getFirst(); } /** diff --git a/backend/services/project-management/src/main/java/io/metersphere/project/service/ProjectUserRoleLogService.java b/backend/services/project-management/src/main/java/io/metersphere/project/service/ProjectUserRoleLogService.java index 166fb01980..345a60be25 100644 --- a/backend/services/project-management/src/main/java/io/metersphere/project/service/ProjectUserRoleLogService.java +++ b/backend/services/project-management/src/main/java/io/metersphere/project/service/ProjectUserRoleLogService.java @@ -68,7 +68,7 @@ public class ProjectUserRoleLogService { UserRoleExample example = new UserRoleExample(); example.createCriteria().andIdEqualTo(request.getId()); - UserRole userRole = userRoleMapper.selectByExample(example).get(0); + UserRole userRole = userRoleMapper.selectByExample(example).getFirst(); dto.setOriginalValue(JSON.toJSONBytes(userRole.getName())); dto.setModifiedValue(JSON.toJSONBytes(request.getName())); return dto; diff --git a/backend/services/project-management/src/main/java/io/metersphere/project/service/ProjectUserRoleService.java b/backend/services/project-management/src/main/java/io/metersphere/project/service/ProjectUserRoleService.java index f98fa0add8..8d6b3b7e9d 100644 --- a/backend/services/project-management/src/main/java/io/metersphere/project/service/ProjectUserRoleService.java +++ b/backend/services/project-management/src/main/java/io/metersphere/project/service/ProjectUserRoleService.java @@ -124,7 +124,7 @@ public class ProjectUserRoleService extends BaseUserRoleService { } public void removeMember(ProjectUserRoleMemberEditRequest request) { - String removeUserId = request.getUserIds().get(0); + String removeUserId = request.getUserIds().getFirst(); checkMemberParam(removeUserId, request.getUserRoleId()); //检查移除的是不是管理员 if (StringUtils.equals(request.getUserRoleId(),InternalUserRole.PROJECT_ADMIN.getValue())) { diff --git a/backend/services/project-management/src/test/java/io/metersphere/project/controller/CreateEnvironmentTests.java b/backend/services/project-management/src/test/java/io/metersphere/project/controller/CreateEnvironmentTests.java index 94ff4540fa..57be242086 100644 --- a/backend/services/project-management/src/test/java/io/metersphere/project/controller/CreateEnvironmentTests.java +++ b/backend/services/project-management/src/test/java/io/metersphere/project/controller/CreateEnvironmentTests.java @@ -55,7 +55,7 @@ public class CreateEnvironmentTests extends BaseTest { environmentExample.createCriteria().andProjectIdEqualTo(initProject.getId()).andNameEqualTo("Mock环境"); List environments = environmentMapper.selectByExample(environmentExample); assert environments.size() == 1; - EnvironmentBlob environmentBlob = environmentBlobMapper.selectByPrimaryKey(environments.get(0).getId()); + EnvironmentBlob environmentBlob = environmentBlobMapper.selectByPrimaryKey(environments.getFirst().getId()); assert environmentBlob != null; } 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 40fd88fa3e..49e934f28c 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 @@ -1142,8 +1142,8 @@ public class EnvironmentControllerTests extends BaseTest { MvcResult mvcResult = requestGetWithOkAndReturn(SCRIPTS, DEFAULT_PROJECT_ID); List envScripts = getResultDataArray(mvcResult, EnvironmentPluginScriptDTO.class); Assertions.assertEquals(envScripts.size(), 1); - Assertions.assertEquals(envScripts.get(0).getPluginId(), "tcp-sampler"); - Assertions.assertEquals(((Map) envScripts.get(0).getScript()).get("id"), "environment"); + Assertions.assertEquals(envScripts.getFirst().getPluginId(), "tcp-sampler"); + Assertions.assertEquals(((Map) envScripts.getFirst().getScript()).get("id"), "environment"); // 删除环境脚本,测试是否正常执行 pluginScriptMapper.deleteByPrimaryKey(plugin.getId(), "environment"); diff --git a/backend/services/project-management/src/test/java/io/metersphere/project/controller/FakeErrorControllerTests.java b/backend/services/project-management/src/test/java/io/metersphere/project/controller/FakeErrorControllerTests.java index 769d5accfe..88fa2fc7c5 100644 --- a/backend/services/project-management/src/test/java/io/metersphere/project/controller/FakeErrorControllerTests.java +++ b/backend/services/project-management/src/test/java/io/metersphere/project/controller/FakeErrorControllerTests.java @@ -111,7 +111,7 @@ public class FakeErrorControllerTests extends BaseTest { List fakeErrors = fakeErrorMapper.selectByExample(new FakeErrorExample()); List dtoList = new ArrayList<>(); FakeErrorDTO dto = new FakeErrorDTO(); - dto.setId(fakeErrors.get(0).getId()); + dto.setId(fakeErrors.getFirst().getId()); dto.setName("测试新增误报规则更新"); dto.setExpression("ok"); dto.setProjectId(DEFAULT_PROJECT_ID); @@ -125,7 +125,7 @@ public class FakeErrorControllerTests extends BaseTest { ResultHolder resultHolder = JSON.parseObject(returnData, ResultHolder.class); Assertions.assertNotNull(resultHolder); fakeErrors = fakeErrorMapper.selectByExample(new FakeErrorExample()); - Assertions.assertTrue(fakeErrors.get(0).getEnable()); + Assertions.assertTrue(fakeErrors.getFirst().getEnable()); mvcResult = this.requestPostWithOkAndReturn(ADD, dtoList); returnData = mvcResult.getResponse().getContentAsString(StandardCharsets.UTF_8); @@ -168,7 +168,7 @@ public class FakeErrorControllerTests extends BaseTest { Assertions.assertNotNull(resultHolder); //名字重复不更新 fakeErrors = fakeErrorMapper.selectByExample(new FakeErrorExample()); - Assertions.assertFalse(StringUtils.equalsIgnoreCase(fakeErrors.get(0).getName(),fakeErrors.get(1).getName())); + Assertions.assertFalse(StringUtils.equalsIgnoreCase(fakeErrors.getFirst().getName(),fakeErrors.get(1).getName())); } @Test @@ -201,7 +201,7 @@ public class FakeErrorControllerTests extends BaseTest { fakeErrors = fakeErrorMapper.selectByExample(new FakeErrorExample()); list = fakeErrors.stream().filter(FakeError::getEnable).toList(); Assertions.assertEquals(0,list.size()); - String oneId = ids.get(0); + String oneId = ids.getFirst(); fakeErrorStatusRequest = new FakeErrorStatusRequest(); fakeErrorStatusRequest.setProjectId(DEFAULT_PROJECT_ID); fakeErrorStatusRequest.setEnable(true); @@ -237,7 +237,7 @@ public class FakeErrorControllerTests extends BaseTest { FakeErrorExample fakeErrorExample = new FakeErrorExample(); fakeErrorExample.createCriteria().andNameLike("用来删除"); List fakeErrors = fakeErrorMapper.selectByExample(fakeErrorExample); - String deleteId = fakeErrors.get(0).getId(); + String deleteId = fakeErrors.getFirst().getId(); Assertions.assertEquals(1,fakeErrors.size()); FakeErrorDelRequest request = new FakeErrorDelRequest(); request.setProjectId(DEFAULT_PROJECT_ID); diff --git a/backend/services/project-management/src/test/java/io/metersphere/project/controller/NoticeMessageTaskControllerTests.java b/backend/services/project-management/src/test/java/io/metersphere/project/controller/NoticeMessageTaskControllerTests.java index e2b56b6789..28e18a91b7 100644 --- a/backend/services/project-management/src/test/java/io/metersphere/project/controller/NoticeMessageTaskControllerTests.java +++ b/backend/services/project-management/src/test/java/io/metersphere/project/controller/NoticeMessageTaskControllerTests.java @@ -141,8 +141,8 @@ public class NoticeMessageTaskControllerTests extends BaseTest { messageTaskExample.createCriteria() .andProjectIdEqualTo("project-message-test").andProjectRobotIdEqualTo("test_message_robot2").andTaskTypeEqualTo(NoticeConstants.TaskType.API_DEFINITION_TASK).andEventEqualTo(NoticeConstants.Event.CREATE); List messageTasks1 = messageTaskMapper.selectByExample(messageTaskExample); - Assertions.assertTrue(messageTasks1.get(0).getEnable()); - Assertions.assertTrue(StringUtils.equalsIgnoreCase(messageTasks1.get(0).getSubject(), "看看改不改")); + Assertions.assertTrue(messageTasks1.getFirst().getEnable()); + Assertions.assertTrue(StringUtils.equalsIgnoreCase(messageTasks1.getFirst().getSubject(), "看看改不改")); messageTaskExample = new MessageTaskExample(); messageTaskExample.createCriteria().andProjectIdEqualTo("project-message-test").andTaskTypeEqualTo(NoticeConstants.TaskType.API_DEFINITION_TASK).andEventEqualTo(NoticeConstants.Event.CREATE); @@ -267,8 +267,8 @@ public class NoticeMessageTaskControllerTests extends BaseTest { } } - Assertions.assertEquals("test_message_robot2", messageTasks.get(0).getProjectRobotId()); - Assertions.assertEquals(false, messageTasks.get(0).getEnable()); + Assertions.assertEquals("test_message_robot2", messageTasks.getFirst().getProjectRobotId()); + Assertions.assertEquals(false, messageTasks.getFirst().getEnable()); } @Test @@ -364,7 +364,7 @@ public class NoticeMessageTaskControllerTests extends BaseTest { String contentAsString = mvcResult.getResponse().getContentAsString(StandardCharsets.UTF_8); ResultHolder resultHolder = JSON.parseObject(contentAsString, ResultHolder.class); List messageTaskDetailDTOList = JSON.parseArray(JSON.toJSONString(resultHolder.getData()), MessageTaskDTO.class); - MessageTaskDetailDTO messageTaskDetailDTO = messageTaskDetailDTOList.get(0).getMessageTaskTypeDTOList().get(0).getMessageTaskDetailDTOList().get(0); + MessageTaskDetailDTO messageTaskDetailDTO = messageTaskDetailDTOList.getFirst().getMessageTaskTypeDTOList().getFirst().getMessageTaskDetailDTOList().getFirst(); Map projectRobotConfigMap = messageTaskDetailDTO.getProjectRobotConfigMap(); System.out.println(projectRobotConfigMap); // Assertions.assertTrue(StringUtils.isBlank(robotId)); @@ -498,11 +498,11 @@ public class NoticeMessageTaskControllerTests extends BaseTest { Assertions.assertTrue(CollectionUtils.isNotEmpty(messageTaskDetailDTOList)); System.out.println(messageTaskDetailDTOList); List collect = messageTaskDetailDTOList.stream().filter(t -> t.type.equals(NoticeConstants.Module.API_TEST_MANAGEMENT)).toList(); - List messageTaskTypeDTOList = collect.get(0).getMessageTaskTypeDTOList(); + List messageTaskTypeDTOList = collect.getFirst().getMessageTaskTypeDTOList(); List collect1 = messageTaskTypeDTOList.stream().filter(t -> t.getTaskType().equals(NoticeConstants.TaskType.API_DEFINITION_TASK)).toList(); - List messageTaskDetailDTOList1 = collect1.get(0).getMessageTaskDetailDTOList(); + List messageTaskDetailDTOList1 = collect1.getFirst().getMessageTaskDetailDTOList(); List collect2 = messageTaskDetailDTOList1.stream().filter(t -> t.event.equals(NoticeConstants.Event.CREATE)).toList(); - Map projectRobotConfigMap = collect2.get(0).getProjectRobotConfigMap(); + Map projectRobotConfigMap = collect2.getFirst().getProjectRobotConfigMap(); ProjectRobotConfigDTO projectRobotConfigDTO = projectRobotConfigMap.get("test_message_robot2"); Assertions.assertTrue(StringUtils.equals(projectRobotConfigDTO.getTemplate(),"发送消息测试")); } diff --git a/backend/services/project-management/src/test/java/io/metersphere/project/controller/ProjectCustomFieldControllerTests.java b/backend/services/project-management/src/test/java/io/metersphere/project/controller/ProjectCustomFieldControllerTests.java index 5235d2ed43..3ee8e34609 100644 --- a/backend/services/project-management/src/test/java/io/metersphere/project/controller/ProjectCustomFieldControllerTests.java +++ b/backend/services/project-management/src/test/java/io/metersphere/project/controller/ProjectCustomFieldControllerTests.java @@ -191,12 +191,12 @@ public class ProjectCustomFieldControllerTests extends BaseTest { CustomFieldExample example = new CustomFieldExample(); example.createCriteria().andScopeIdEqualTo(DEFAULT_PROJECT_ID).andNameEqualTo("functional_priority"); - CustomFieldUpdateRequest internalRequest = BeanUtils.copyBean(new CustomFieldUpdateRequest(), customFieldMapper.selectByExample(example).get(0)); + CustomFieldUpdateRequest internalRequest = BeanUtils.copyBean(new CustomFieldUpdateRequest(), customFieldMapper.selectByExample(example).getFirst()); internalRequest.setName("aaaa"); this.requestPostWithOk(DEFAULT_UPDATE, internalRequest); - Assertions.assertEquals(customFieldMapper.selectByExample(example).get(0).getInternal(), true); + Assertions.assertEquals(customFieldMapper.selectByExample(example).getFirst().getInternal(), true); // 内置字段名称不能修改 - Assertions.assertEquals(customFieldMapper.selectByExample(example).get(0).getName(), "functional_priority"); + Assertions.assertEquals(customFieldMapper.selectByExample(example).getFirst().getName(), "functional_priority"); // @校验是否开启项目模板 changeOrgTemplateEnable(true); @@ -246,8 +246,8 @@ public class ProjectCustomFieldControllerTests extends BaseTest { if (StringUtils.equalsAny(resultItem.getType(), CustomFieldType.MEMBER.name(), CustomFieldType.MULTIPLE_MEMBER.name())) { List options = resultList.get(i).getOptions(); Assertions.assertEquals(options.size(), 1); - Assertions.assertEquals(options.get(0).getValue(), "CREATE_USER"); - Assertions.assertEquals(options.get(0).getText(), "创建人"); + Assertions.assertEquals(options.getFirst().getValue(), "CREATE_USER"); + Assertions.assertEquals(options.getFirst().getText(), "创建人"); } else if (CustomFieldType.getHasOptionValueSet().contains(resultItem.getType())) { // 有下拉框选项的校验选项 Assertions.assertEquals(resultList.get(i).getOptions().stream().sorted(Comparator.comparing(CustomFieldOption::getValue)).toList(), @@ -300,7 +300,7 @@ public class ProjectCustomFieldControllerTests extends BaseTest { CustomFieldExample example = new CustomFieldExample(); example.createCriteria() .andInternalEqualTo(true); - CustomField internalCustomField = customFieldMapper.selectByExample(example).get(0); + CustomField internalCustomField = customFieldMapper.selectByExample(example).getFirst(); assertErrorCode(this.requestGet(DEFAULT_DELETE, internalCustomField.getId()), INTERNAL_CUSTOM_FIELD_PERMISSION); // @@校验 NOT_FOUND 异常 diff --git a/backend/services/project-management/src/test/java/io/metersphere/project/controller/ProjectMemberControllerTests.java b/backend/services/project-management/src/test/java/io/metersphere/project/controller/ProjectMemberControllerTests.java index ca2f9bed1f..acea10380e 100644 --- a/backend/services/project-management/src/test/java/io/metersphere/project/controller/ProjectMemberControllerTests.java +++ b/backend/services/project-management/src/test/java/io/metersphere/project/controller/ProjectMemberControllerTests.java @@ -63,7 +63,7 @@ public class ProjectMemberControllerTests extends BaseTest { // 返回的数据量不超过规定要返回的数据量相同 Assertions.assertTrue(JSON.parseArray(JSON.toJSONString(pageData.getList())).size() <= request.getPageSize()); // 返回值中取出第一条数据, 并判断name, email, phone是否包含关键字default - ProjectUserDTO projectUserDTO = JSON.parseArray(JSON.toJSONString(pageData.getList()), ProjectUserDTO.class).get(0); + ProjectUserDTO projectUserDTO = JSON.parseArray(JSON.toJSONString(pageData.getList()), ProjectUserDTO.class).getFirst(); Assertions.assertTrue(StringUtils.contains(projectUserDTO.getName(), request.getKeyword()) || StringUtils.contains(projectUserDTO.getEmail(), request.getKeyword()) || StringUtils.contains(projectUserDTO.getPhone(), request.getKeyword())); diff --git a/backend/services/project-management/src/test/java/io/metersphere/project/controller/ProjectRobotControllerTests.java b/backend/services/project-management/src/test/java/io/metersphere/project/controller/ProjectRobotControllerTests.java index d987ead68d..5383301f89 100644 --- a/backend/services/project-management/src/test/java/io/metersphere/project/controller/ProjectRobotControllerTests.java +++ b/backend/services/project-management/src/test/java/io/metersphere/project/controller/ProjectRobotControllerTests.java @@ -394,7 +394,7 @@ public class ProjectRobotControllerTests extends BaseTest { for (MessageTaskDTO messageTaskDTO : messageTaskDetailDTOList) { for (MessageTaskTypeDTO messageTaskTypeDTO : messageTaskDTO.getMessageTaskTypeDTOList()) { if (StringUtils.equalsIgnoreCase(messageTaskTypeDTO.getTaskType(),NoticeConstants.TaskType.API_DEFINITION_TASK)) { - Boolean testRobotMessageRobot1 = messageTaskTypeDTO.getMessageTaskDetailDTOList().get(0).getProjectRobotConfigMap().get(projectRobotId).getEnable(); + Boolean testRobotMessageRobot1 = messageTaskTypeDTO.getMessageTaskDetailDTOList().getFirst().getProjectRobotConfigMap().get(projectRobotId).getEnable(); Assertions.assertTrue(testRobotMessageRobot1); } } @@ -513,7 +513,7 @@ public class ProjectRobotControllerTests extends BaseTest { ProjectRobotExample projectRobotExample = new ProjectRobotExample(); projectRobotExample.createCriteria().andProjectIdEqualTo(projectId).andNameEqualTo(keyWord); List projectRobots = projectRobotMapper.selectByExample(projectRobotExample); - return projectRobots.get(0); + return projectRobots.getFirst(); } public void setMessageTask(String projectId, String defaultRobotId) throws Exception { diff --git a/backend/services/project-management/src/test/java/io/metersphere/project/controller/ProjectTemplateControllerTests.java b/backend/services/project-management/src/test/java/io/metersphere/project/controller/ProjectTemplateControllerTests.java index 195f74be38..f9958ace94 100644 --- a/backend/services/project-management/src/test/java/io/metersphere/project/controller/ProjectTemplateControllerTests.java +++ b/backend/services/project-management/src/test/java/io/metersphere/project/controller/ProjectTemplateControllerTests.java @@ -99,7 +99,7 @@ public class ProjectTemplateControllerTests extends BaseTest { // @@校验没有数据的情况 MvcResult mvcResult = this.requestGetWithOkAndReturn(LIST, DEFAULT_PROJECT_ID, TemplateScene.FUNCTIONAL.name()); List