Package org.mockserver.imports
Class HarImporter
java.lang.Object
org.mockserver.imports.HarImporter
Imports expectations from HAR (HTTP Archive) format JSON files.
For each entry in log.entries[], builds a request matcher (method + path + query
string parameters) and a response (status, filtered headers, body). The generated matchers
are intentionally permissive: volatile headers (Date, Set-Cookie, etc.) are excluded from
request matching, and request body matching is only applied when postData.text is
present and reasonably sized.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionimportExpectations(String harJson) Parses a HAR JSON string and returns one expectation per entry.
-
Constructor Details
-
HarImporter
public HarImporter()
-
-
Method Details
-
importExpectations
Parses a HAR JSON string and returns one expectation per entry.- Parameters:
harJson- the HAR document as a JSON string- Returns:
- the generated expectations (may be empty if there are no entries)
- Throws:
IllegalArgumentException- if the JSON is null, blank, or not a valid HAR
-