parent
74ed29ed7e
commit
cd6bd6c0f0
|
@ -43,8 +43,7 @@ public class HarParser extends HarAbstractParser {
|
|||
public ApiDefinitionImport parse(InputStream source, ApiTestImportRequest request) {
|
||||
Har har = null;
|
||||
try {
|
||||
String sourceStr = getApiTestStr(source);
|
||||
har = HarUtils.read(sourceStr);
|
||||
har = HarUtils.read(source);
|
||||
} catch (Exception e) {
|
||||
MSException.throwException(e.getMessage());
|
||||
LogUtil.error(e.getMessage(), e);
|
||||
|
|
|
@ -28,6 +28,7 @@ import org.apache.commons.lang3.StringUtils;
|
|||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* Utility class for working with HAR files.
|
||||
|
@ -42,11 +43,11 @@ public class HarUtils {
|
|||
}
|
||||
|
||||
|
||||
public static Har read(String harJson) throws JsonSyntaxException, IOException {
|
||||
if (StringUtils.isEmpty(harJson)) {
|
||||
public static Har read(InputStream source) throws JsonSyntaxException, IOException {
|
||||
if (source == null) {
|
||||
throw new IllegalArgumentException("HAR Json cannot be null/empty");
|
||||
}
|
||||
Har har = JSON.parseObject(harJson, Har.class);
|
||||
Har har = JSON.parseObject(source, Har.class);
|
||||
return har;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,8 +27,7 @@ public class HarScenarioParser extends HarScenarioAbstractParser<ScenarioImport>
|
|||
public ScenarioImport parse(InputStream source, ApiTestImportRequest request) {
|
||||
Har har = null;
|
||||
try {
|
||||
String sourceStr = getApiTestStr(source);
|
||||
har = HarUtils.read(sourceStr);
|
||||
har = HarUtils.read(source);
|
||||
} catch (Exception e) {
|
||||
MSException.throwException(e.getMessage());
|
||||
LogUtil.error(e.getMessage(), e);
|
||||
|
|
Loading…
Reference in New Issue