refactor(接口测试): 接口定义导入部分字段进行trim处理
This commit is contained in:
parent
d5c739a4da
commit
8d65802488
|
@ -77,12 +77,12 @@ public abstract class HttpApiDefinitionImportAbstractParser<T> implements ApiDef
|
||||||
protected ApiDefinitionDetail buildApiDefinition(String name, String path, String method, String modulePath, ImportRequest importRequest) {
|
protected ApiDefinitionDetail buildApiDefinition(String name, String path, String method, String modulePath, ImportRequest importRequest) {
|
||||||
ApiDefinitionDetail apiDefinition = new ApiDefinitionDetail();
|
ApiDefinitionDetail apiDefinition = new ApiDefinitionDetail();
|
||||||
apiDefinition.setId(IDGenerator.nextStr());
|
apiDefinition.setId(IDGenerator.nextStr());
|
||||||
apiDefinition.setName(name);
|
apiDefinition.setName(StringUtils.trim(name));
|
||||||
apiDefinition.setPath(formatPath(path));
|
apiDefinition.setPath(formatPath(StringUtils.trim(path)));
|
||||||
apiDefinition.setProtocol(importRequest.getProtocol());
|
apiDefinition.setProtocol(StringUtils.trim(importRequest.getProtocol()));
|
||||||
apiDefinition.setMethod(method);
|
apiDefinition.setMethod(StringUtils.trim(method));
|
||||||
apiDefinition.setProjectId(importRequest.getProjectId());
|
apiDefinition.setProjectId(StringUtils.trim(importRequest.getProjectId()));
|
||||||
apiDefinition.setModulePath(modulePath);
|
apiDefinition.setModulePath(StringUtils.trim(modulePath));
|
||||||
apiDefinition.setResponse(new ArrayList<>());
|
apiDefinition.setResponse(new ArrayList<>());
|
||||||
return apiDefinition;
|
return apiDefinition;
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,10 +100,10 @@ public class JmeterParserApiDefinition implements ApiDefinitionImportParser<ApiI
|
||||||
|
|
||||||
for (AbstractMsProtocolTestElement protocolTestElement : msElement) {
|
for (AbstractMsProtocolTestElement protocolTestElement : msElement) {
|
||||||
ApiDefinitionDetail definition = new ApiDefinitionDetail();
|
ApiDefinitionDetail definition = new ApiDefinitionDetail();
|
||||||
definition.setName(protocolTestElement.getName());
|
definition.setName(StringUtils.trim(protocolTestElement.getName()));
|
||||||
if (protocolTestElement instanceof MsHTTPElement msHTTPElement) {
|
if (protocolTestElement instanceof MsHTTPElement msHTTPElement) {
|
||||||
definition.setMethod(msHTTPElement.getMethod());
|
definition.setMethod(StringUtils.trim(msHTTPElement.getMethod()));
|
||||||
definition.setPath(msHTTPElement.getPath());
|
definition.setPath(StringUtils.trim(msHTTPElement.getPath()));
|
||||||
definition.setProtocol(ApiConstants.HTTP_PROTOCOL);
|
definition.setProtocol(ApiConstants.HTTP_PROTOCOL);
|
||||||
} else {
|
} else {
|
||||||
definition.setProtocol(polymorphicNameMap.get(protocolTestElement.getClass().getSimpleName()));
|
definition.setProtocol(polymorphicNameMap.get(protocolTestElement.getClass().getSimpleName()));
|
||||||
|
|
|
@ -532,6 +532,10 @@ public class ApiDefinitionImportService {
|
||||||
ApiDefinitionDetail importApi = existenceApiDefinitionDetail.getImportApiDefinition();
|
ApiDefinitionDetail importApi = existenceApiDefinitionDetail.getImportApiDefinition();
|
||||||
ApiDefinitionDetail existenceApi = existenceApiDefinitionDetail.getExistenceApiDefinition();
|
ApiDefinitionDetail existenceApi = existenceApiDefinitionDetail.getExistenceApiDefinition();
|
||||||
|
|
||||||
|
if (StringUtils.isNotBlank(importApi.getModulePath()) && !StringUtils.startsWith(importApi.getModulePath(), "/")) {
|
||||||
|
importApi.setModulePath("/" + importApi.getModulePath());
|
||||||
|
}
|
||||||
|
|
||||||
boolean isSameRequest = false;
|
boolean isSameRequest = false;
|
||||||
ApiDefinitionBlob apiDefinitionBlob = existenceApiDefinitionBlobMap.get(existenceApi.getId());
|
ApiDefinitionBlob apiDefinitionBlob = existenceApiDefinitionBlobMap.get(existenceApi.getId());
|
||||||
MsHTTPElement existenceMsHTTPElement = null;
|
MsHTTPElement existenceMsHTTPElement = null;
|
||||||
|
|
Loading…
Reference in New Issue