Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/main/java/api_assured/Caller.java
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,12 @@ protected static <SuccessModel, ErrorModel> ResponsePair<Response<SuccessModel>,
private static <T> Response<T> getResponse(Call<T> call, boolean printBody) throws IOException {
Response<T> response = call.execute();
if (response.isSuccessful()) {
String contentType = response.headers().get("content-type");
boolean printableResponse = contentType != null && contentType.contains("application/json");
T body = response.body();
if (keepLogs) log.success("The response code is: " + response.code());
if (keepLogs && response.message().length()>0) log.info(response.message());
if (printBody) log.info("The response body is: \n" + getJsonString(body));
if (keepLogs && !response.message().isEmpty()) log.info(response.message());
if (printBody && printableResponse) log.info("The response body is: \n" + getJsonString(body));
return Response.success(body, response.raw());
}
else {
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/utils/FileUtilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,16 @@ public static String getPDFFileText(URL url, String fileDestinationPath) throws
} catch (IOException exception) {
log.error(exception.getMessage(), exception);
}
return parsePDFFileToText(fileDestinationPath);
}

/**
* Returns a text of the PDF file.
*
* @param fileDestinationPath The destination path for the PDF file.
* @return The text of PDF.
*/
public static String parsePDFFileToText(String fileDestinationPath) throws IOException {
File file = new File(fileDestinationPath);
PDDocument document = Loader.loadPDF(file);
PDFTextStripper stripper = new PDFTextStripper();
Expand Down