parent
9685d988d0
commit
4a63c924a7
|
@ -0,0 +1,48 @@
|
|||
package io.metersphere.api.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.metersphere.api.dto.definition.request.assertions.MsAssertions;
|
||||
import io.metersphere.base.domain.ErrorReportLibraryExample;
|
||||
import io.metersphere.base.domain.ErrorReportLibraryWithBLOBs;
|
||||
import io.metersphere.base.mapper.ErrorReportLibraryMapper;
|
||||
import io.metersphere.commons.utils.LogUtil;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author song.tianyang
|
||||
* @Date 2022/1/3 3:51 下午
|
||||
*/
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class ExtErrorReportLibraryService {
|
||||
@Resource
|
||||
private ErrorReportLibraryMapper errorReportLibraryMapper;
|
||||
|
||||
public List<MsAssertions> getAssertionByProjectIdAndStatusIsOpen(String projectId) {
|
||||
List<MsAssertions> returnList = new ArrayList<>();
|
||||
ErrorReportLibraryExample example = new ErrorReportLibraryExample();
|
||||
example.createCriteria().andProjectIdEqualTo(projectId).andStatusEqualTo(true);
|
||||
List<ErrorReportLibraryWithBLOBs> bloBs = errorReportLibraryMapper.selectByExampleWithBLOBs(example);
|
||||
bloBs.forEach(item -> {
|
||||
if (StringUtils.isNotEmpty(item.getContent())) {
|
||||
try {
|
||||
MsAssertions assertions = JSONObject.parseObject(item.getContent(), MsAssertions.class);
|
||||
if (assertions != null && CollectionUtils.isNotEmpty(assertions.getRegex())) {
|
||||
assertions.getRegex().get(0).setDescription("Error report:" + item.getErrorCode());
|
||||
returnList.add(assertions);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
return returnList;
|
||||
}
|
||||
}
|
|
@ -6,8 +6,8 @@ import io.metersphere.api.dto.RunningParamKeys;
|
|||
import io.metersphere.api.dto.definition.request.assertions.MsAssertionRegex;
|
||||
import io.metersphere.api.dto.definition.request.assertions.MsAssertions;
|
||||
import io.metersphere.api.service.ApiTestEnvironmentService;
|
||||
import io.metersphere.api.service.ExtErrorReportLibraryService;
|
||||
import io.metersphere.base.domain.ApiTestEnvironmentWithBLOBs;
|
||||
import io.metersphere.xpack.errorreportlibrary.service.ErrorReportLibraryService;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.jmeter.config.Argument;
|
||||
|
@ -224,7 +224,7 @@ public class HashTreeUtil {
|
|||
break;
|
||||
}
|
||||
}
|
||||
if(!isExit){
|
||||
if (!isExit) {
|
||||
duplicatedList.add(regex);
|
||||
}
|
||||
}
|
||||
|
@ -234,7 +234,7 @@ public class HashTreeUtil {
|
|||
}
|
||||
|
||||
public static List<MsAssertions> getErrorReportByProjectId(String projectId) {
|
||||
ErrorReportLibraryService service = CommonBeanFactory.getBean(ErrorReportLibraryService.class);
|
||||
ExtErrorReportLibraryService service = CommonBeanFactory.getBean(ExtErrorReportLibraryService.class);
|
||||
return service.getAssertionByProjectIdAndStatusIsOpen(projectId);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue