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