From 1248028981ae2868b324df1337962533152e4f3a Mon Sep 17 00:00:00 2001 From: guoyuqi Date: Fri, 17 May 2024 11:30:58 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92):?= =?UTF-8?q?=20=E5=A2=9E=E5=8A=A0=E5=8D=95=E5=85=83=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E8=A6=86=E7=9B=96=E7=8E=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TestPlanCaseControllerTests.java | 50 +++++++++++-------- 1 file changed, 30 insertions(+), 20 deletions(-) diff --git a/backend/services/test-plan/src/test/java/io/metersphere/plan/controller/TestPlanCaseControllerTests.java b/backend/services/test-plan/src/test/java/io/metersphere/plan/controller/TestPlanCaseControllerTests.java index 92e98872d2..8e4fcee0ec 100644 --- a/backend/services/test-plan/src/test/java/io/metersphere/plan/controller/TestPlanCaseControllerTests.java +++ b/backend/services/test-plan/src/test/java/io/metersphere/plan/controller/TestPlanCaseControllerTests.java @@ -279,6 +279,30 @@ public class TestPlanCaseControllerTests extends BaseTest { ResultHolder resultHolder = JSON.parseObject(returnData, ResultHolder.class); FunctionalCaseDetailDTO functionalCaseDetailDTO = JSON.parseObject(JSON.toJSONString(resultHolder.getData()), FunctionalCaseDetailDTO.class); Assertions.assertTrue(CollectionUtils.isEmpty(JSON.parseArray(functionalCaseDetailDTO.getSteps(), FunctionalCaseDetailDTO.class))); + FunctionalCaseStepDTO functionalCaseStepDTO = new FunctionalCaseStepDTO(); + functionalCaseStepDTO.setId("id_step"); + functionalCaseStepDTO.setNum(1); + functionalCaseStepDTO.setDesc("步骤一"); + functionalCaseStepDTO.setResult("步骤一结果"); + functionalCaseStepDTO.setActualResult("步骤一实际结果"); + functionalCaseStepDTO.setExecuteResult("SUCCESS"); + String jsonString = JSON.toJSONString(functionalCaseStepDTO); + FunctionalCaseBlob functionalCaseBlob = new FunctionalCaseBlob(); + functionalCaseBlob.setId("gyq_disassociate_fc_4"); + functionalCaseBlob.setSteps(jsonString.getBytes()); + String textDescription = "textDescription"; + String expectedResult = "expectedResult"; + String prerequisite = "prerequisite"; + String description = "description"; + functionalCaseBlob.setPrerequisite(prerequisite.getBytes(StandardCharsets.UTF_8)); + functionalCaseBlob.setTextDescription(textDescription.getBytes(StandardCharsets.UTF_8)); + functionalCaseBlob.setExpectedResult(expectedResult.getBytes(StandardCharsets.UTF_8)); + functionalCaseBlob.setDescription(description.getBytes(StandardCharsets.UTF_8)); + functionalCaseBlobMapper.updateByPrimaryKeyWithBLOBs(functionalCaseBlob); + mvcResult = this.requestGetWithOkAndReturn(FUNCTIONAL_CASE_DETAIL + "gyq_disassociate_case_4"); + returnData = mvcResult.getResponse().getContentAsString(StandardCharsets.UTF_8); + resultHolder = JSON.parseObject(returnData, ResultHolder.class); + Assertions.assertNotNull(resultHolder); TestPlanCaseExecuteHistory testPlanCaseExecuteHistory = new TestPlanCaseExecuteHistory(); testPlanCaseExecuteHistory.setCaseId("gyq_disassociate_fc_4"); testPlanCaseExecuteHistory.setTestPlanCaseId("gyq_disassociate_case_4"); @@ -293,28 +317,14 @@ public class TestPlanCaseControllerTests extends BaseTest { resultHolder = JSON.parseObject(returnData, ResultHolder.class); Assertions.assertNotNull(resultHolder); TestPlanCaseExecuteHistory testPlanCaseExecuteHistory1 = testPlanCaseExecuteHistoryMapper.selectByPrimaryKey("history_id"); - FunctionalCaseStepDTO functionalCaseStepDTO = new FunctionalCaseStepDTO(); - functionalCaseStepDTO.setId("id_step"); - functionalCaseStepDTO.setNum(1); - functionalCaseStepDTO.setDesc("步骤一"); - functionalCaseStepDTO.setResult("步骤一结果"); - functionalCaseStepDTO.setActualResult("步骤一实际结果"); - functionalCaseStepDTO.setExecuteResult("SUCCESS"); - String jsonString = JSON.toJSONString(functionalCaseStepDTO); + testPlanCaseExecuteHistory1.setSteps(new byte[0]); + testPlanCaseExecuteHistoryMapper.updateByPrimaryKeySelective(testPlanCaseExecuteHistory1); + mvcResult = this.requestGetWithOkAndReturn(FUNCTIONAL_CASE_DETAIL + "gyq_disassociate_case_4"); + returnData = mvcResult.getResponse().getContentAsString(StandardCharsets.UTF_8); + resultHolder = JSON.parseObject(returnData, ResultHolder.class); + Assertions.assertNotNull(resultHolder); testPlanCaseExecuteHistory1.setSteps(jsonString.getBytes()); testPlanCaseExecuteHistoryMapper.updateByPrimaryKeySelective(testPlanCaseExecuteHistory1); - FunctionalCaseBlob functionalCaseBlob = new FunctionalCaseBlob(); - functionalCaseBlob.setId("gyq_disassociate_fc_4"); - functionalCaseBlob.setSteps(jsonString.getBytes()); - String textDescription = "textDescription"; - String expectedResult = "expectedResult"; - String prerequisite = "prerequisite"; - String description = "description"; - functionalCaseBlob.setPrerequisite(prerequisite.getBytes(StandardCharsets.UTF_8)); - functionalCaseBlob.setTextDescription(textDescription.getBytes(StandardCharsets.UTF_8)); - functionalCaseBlob.setExpectedResult(expectedResult.getBytes(StandardCharsets.UTF_8)); - functionalCaseBlob.setDescription(description.getBytes(StandardCharsets.UTF_8)); - functionalCaseBlobMapper.updateByPrimaryKeyWithBLOBs(functionalCaseBlob); mvcResult = this.requestGetWithOkAndReturn(FUNCTIONAL_CASE_DETAIL + "gyq_disassociate_case_4"); returnData = mvcResult.getResponse().getContentAsString(StandardCharsets.UTF_8); resultHolder = JSON.parseObject(returnData, ResultHolder.class);