adobe/log-parser

json export is failing if the directory log_parser_output/exports is not existing

Closed this issue · 1 comments

Expected Behaviour

By calling the methods exportLogDataToJSON, if the log_parser_output/exports directory is not existing, we expect to have this one created by the log-parser.

It's the case for HTML and csv export, and it's working.

Actual Behaviour

Currently, if the job calling the lob parser didn't create explicitly the directory log_parser_output/exports, it's failing.

The log parser directory for extraction (log_parser_output/exports) is defined here:

public static final String LOG_PARSER_EXPORTS = "log_parser_output/exports";

In the case of Json export, if the directory is not explicity created before, it's failing with the issue:

[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:3.4.1:java (default-cli) 
on project parseCampaignLogs: An exception occurred while executing the Java class. 
Encountered error while exporting the log data to a JSON file.: 
log_parser_output/exports/logsExtraction.json (No such file or directory) -> [Help 1]

The stack trace is:

com.adobe.campaign.tests.logparser.exceptions.LogDataExportToFileException: Encountered error while exporting the log data to a JSON file.
    at com.adobe.campaign.tests.logparser.core.LogData.exportLogDataToJSON (LogData.java:548)
    at com.adobe.campaign.tests.logparser.core.LogData.exportLogDataToJSON (LogData.java:521)
    at com.adobe.campaign.tests.logs.ExtractACCLogs.main (ExtractACCLogs.java:74)
    at org.codehaus.mojo.exec.ExecJavaMojo.doMain (ExecJavaMojo.java:358)
    at org.codehaus.mojo.exec.ExecJavaMojo.doExec (ExecJavaMojo.java:347)
    at org.codehaus.mojo.exec.ExecJavaMojo.lambda$execute$0 (ExecJavaMojo.java:269)
    at java.lang.Thread.run (Thread.java:834)
Caused by: java.io.FileNotFoundException: log_parser_output/exports/logsExtraction.json (No such file or directory)

Problem reproduced for CSV as well.