refactor: 去警告
This commit is contained in:
parent
cbdefab47b
commit
1aac4684dd
|
@ -11,6 +11,7 @@ import java.io.BufferedReader;
|
|||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
@ -18,12 +19,12 @@ import java.util.Optional;
|
|||
public abstract class ApiImportAbstractParser implements ApiImportParser {
|
||||
|
||||
protected String getApiTestStr(InputStream source) {
|
||||
BufferedReader bufferedReader = null;
|
||||
BufferedReader bufferedReader;
|
||||
StringBuilder testStr = null;
|
||||
try {
|
||||
bufferedReader = new BufferedReader(new InputStreamReader(source, "UTF-8"));
|
||||
bufferedReader = new BufferedReader(new InputStreamReader(source, StandardCharsets.UTF_8));
|
||||
testStr = new StringBuilder();
|
||||
String inputStr = null;
|
||||
String inputStr;
|
||||
while ((inputStr = bufferedReader.readLine()) != null) {
|
||||
testStr.append(inputStr);
|
||||
}
|
||||
|
|
|
@ -2,17 +2,15 @@ package io.metersphere.api.parse;
|
|||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import io.metersphere.api.dto.parse.ApiImport;
|
||||
import io.metersphere.commons.exception.MSException;
|
||||
import io.metersphere.commons.utils.LogUtil;
|
||||
|
||||
import java.io.*;
|
||||
import java.io.InputStream;
|
||||
|
||||
public class MsParser extends ApiImportAbstractParser {
|
||||
|
||||
@Override
|
||||
public ApiImport parse(InputStream source) {
|
||||
String testStr = getApiTestStr(source);
|
||||
return JSON.parseObject(testStr.toString(), ApiImport.class);
|
||||
return JSON.parseObject(testStr, ApiImport.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package io.metersphere.api.parse;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.metersphere.api.dto.parse.ApiImport;
|
||||
import io.metersphere.api.dto.parse.postman.*;
|
||||
|
@ -11,15 +10,9 @@ import io.metersphere.api.dto.scenario.Request;
|
|||
import io.metersphere.api.dto.scenario.Scenario;
|
||||
import io.metersphere.commons.constants.MsRequestBodyType;
|
||||
import io.metersphere.commons.constants.PostmanRequestBodyMode;
|
||||
import io.metersphere.commons.exception.MSException;
|
||||
import io.metersphere.commons.utils.LogUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.eclipse.jetty.http.HttpHeader;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -28,7 +21,7 @@ public class PostmanParser extends ApiImportAbstractParser {
|
|||
@Override
|
||||
public ApiImport parse(InputStream source) {
|
||||
String testStr = getApiTestStr(source);
|
||||
PostmanCollection postmanCollection = JSON.parseObject(testStr.toString(), PostmanCollection.class);
|
||||
PostmanCollection postmanCollection = JSON.parseObject(testStr, PostmanCollection.class);
|
||||
PostmanCollectionInfo info = postmanCollection.getInfo();
|
||||
List<Request> requests = parseRequests(postmanCollection);
|
||||
ApiImport apiImport = new ApiImport();
|
||||
|
@ -46,9 +39,7 @@ public class PostmanParser extends ApiImportAbstractParser {
|
|||
return null;
|
||||
}
|
||||
List<KeyValue> keyValues = new ArrayList<>();
|
||||
postmanKeyValues.forEach(item -> {
|
||||
keyValues.add(new KeyValue(item.getKey(), item.getValue()));
|
||||
});
|
||||
postmanKeyValues.forEach(item -> keyValues.add(new KeyValue(item.getKey(), item.getValue())));
|
||||
return keyValues;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue