/** * Parse the given filename and returns the Fixture object. * * @param fileName filename should not contain extension or relative path. ie: login * @param parser parser is required for parsing operation, it should not be null */ public static Fixture parseFrom(String fileName, Parser parser) { if (fileName == null) { throw new NullPointerException("File name should not be null"); } String path = "fixtures/" + fileName + ".yaml"; InputStream inputStream = openPathAsStream(path); Fixture result = parser.parse(inputStream); if (result.body != null && !result.body.startsWith("{")) { String bodyPath = "fixtures/" + result.body; try { result.body = readPathIntoString(bodyPath); } catch (IOException e) { throw new IllegalStateException("Error reading body: " + bodyPath, e); } } return result; }