From 43a96032b96786d3cd3e9973b9999d0a48c1daba Mon Sep 17 00:00:00 2001 From: song-tianyang Date: Tue, 18 Oct 2022 15:15:55 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=9B=A0=E6=9B=B4=E6=8D=A2json=E8=A7=A3?= =?UTF-8?q?=E6=9E=90=E5=8C=85=E5=AF=BC=E8=87=B4=E7=9A=84=E8=A7=A3=E6=9E=90?= =?UTF-8?q?=E8=AF=AF=E6=8A=A5=E5=86=85=E5=AE=B9=E5=87=BA=E9=94=99=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1017901 --user=宋天阳 【接口测试】开启误报-执行接口case和场景后误报设置不生效 https://www.tapd.cn/55049933/s/1265938 --- .../service/ExtErrorReportLibraryService.java | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/api-test/backend/src/main/java/io/metersphere/service/ExtErrorReportLibraryService.java b/api-test/backend/src/main/java/io/metersphere/service/ExtErrorReportLibraryService.java index 145e4ee7cf..f1260d4321 100644 --- a/api-test/backend/src/main/java/io/metersphere/service/ExtErrorReportLibraryService.java +++ b/api-test/backend/src/main/java/io/metersphere/service/ExtErrorReportLibraryService.java @@ -1,13 +1,13 @@ package io.metersphere.service; +import io.metersphere.api.dto.definition.request.assertions.MsAssertionDuration; +import io.metersphere.api.dto.definition.request.assertions.MsAssertionRegex; import io.metersphere.api.dto.definition.request.assertions.MsAssertions; +import io.metersphere.api.dto.definition.request.assertions.document.MsAssertionDocument; import io.metersphere.base.domain.ErrorReportLibraryExample; import io.metersphere.base.domain.ErrorReportLibraryWithBLOBs; -import io.metersphere.commons.utils.CommonBeanFactory; -import io.metersphere.commons.utils.LogUtil; -import io.metersphere.commons.utils.ErrorReportLibraryUtil; -import io.metersphere.commons.utils.JSONUtil; +import io.metersphere.commons.utils.*; import io.metersphere.xpack.fake.error.ErrorReportLibraryService; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; @@ -16,6 +16,7 @@ import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; import java.util.List; +import java.util.Map; /** * @author song.tianyang @@ -33,7 +34,16 @@ public class ExtErrorReportLibraryService { bloBs.forEach(item -> { if (StringUtils.isNotEmpty(item.getContent())) { try { - MsAssertions assertions = JSONUtil.parseObject(item.getContent(), MsAssertions.class); + MsAssertions assertions = new MsAssertions(); + Map assertionMap = JSON.parseObject(item.getContent(), Map.class); + if (assertionMap != null) { + MsAssertionDuration duration = JSONUtil.parseObject(JSONUtil.toJSONString(assertionMap.get("duration")), MsAssertionDuration.class); + List regexList = JSON.parseArray(JSONUtil.toJSONString(assertionMap.get("regex")), MsAssertionRegex.class); + MsAssertionDocument document = JSONUtil.parseObject(JSONUtil.toJSONString(assertionMap.get("document")), MsAssertionDocument.class); + assertions.setDuration(duration); + assertions.setRegex(regexList); + assertions.setDocument(document); + } if (assertions != null && CollectionUtils.isNotEmpty(assertions.getRegex())) { if (StringUtils.isEmpty(assertions.getRegex().get(0).getDescription())) { String desc = assertions.getRegex().get(0).getSubject() + ":" + assertions.getRegex().get(0).getExpression()