Skip to content

Commit cb07dc6

Browse files
committed
Finished changes in docs
2 parents f4a71b4 + ac844b6 commit cb07dc6

File tree

7 files changed

+67
-26
lines changed

7 files changed

+67
-26
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ The following dependency needs to be added to your pom file:
7171
<dependency>
7272
<groupId>com.adobe.campaign.tests</groupId>
7373
<artifactId>log-parser</artifactId>
74-
<version>1.0.10</version>
74+
<version>1.11.1</version>
7575
</dependency>
7676
```
7777
## Running the Log Parser
@@ -470,6 +470,9 @@ You can get a print out of the command line options by running the command with
470470
All reports are stored in the directory `log-parser-reports/export/`.
471471

472472
## Changelog
473+
### 1.11.1
474+
- [#188](https://github.com/adobe/log-parser/issues/188) We solved problems with exporting when the directory hierarchy is not present.
475+
473476
### 1.11.0
474477
- **(new feature)** [#10](https://github.com/adobe/log-parser/issues/10) We now have an executable for the log-parser. You can perform a log parsing using the command line. For more information please read the section on [Command-line Execution of the Log-Parser](#command-line-execution-of-the-log-parser).
475478
- **(new feature)** [#127](https://github.com/adobe/log-parser/issues/127) You can now compare two LogData Objects. This is a light compare that checks that for a given key, if it is absent, added or changes in frequency.
4.01 KB
Loading

diagrams/Log_Parser.drawio

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<mxfile host="Electron" modified="2024-08-06T21:48:41.274Z" agent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/21.5.0 Chrome/112.0.5615.204 Electron/24.5.1 Safari/537.36" etag="IxRyfKH6_R-m68x0ZdZq" version="21.5.0" type="device" pages="3">
1+
<mxfile host="Electron" modified="2024-10-04T10:09:17.651Z" agent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/21.5.0 Chrome/112.0.5615.204 Electron/24.5.1 Safari/537.36" etag="vQgtGz6c1c2_e02nvOvv" version="21.5.0" type="device" pages="3">
22
<diagram id="GF7U1PxuMcIbTAeL1bwN" name="Classes">
33
<mxGraphModel dx="1114" dy="824" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="850" pageHeight="1100" background="#FFFFFF" math="0" shadow="0">
44
<root>
@@ -310,6 +310,15 @@
310310
<mxCell id="GjdqCvJivDHMyhRgbLtD-0" value="enrich" style="strokeWidth=2;html=1;shape=mxgraph.flowchart.terminator;whiteSpace=wrap;shadow=1;labelBackgroundColor=#FFFFFF;" parent="dgaH53lybmkEFGB52cs7-1" vertex="1">
311311
<mxGeometry x="970" y="366" width="100" height="60" as="geometry" />
312312
</mxCell>
313+
<mxCell id="Optskv5YCS5HUoDn0TRo-0" value="JSON" style="shape=document;whiteSpace=wrap;html=1;boundedLbl=1;labelBackgroundColor=#FFFFFF;strokeColor=#000000;fillColor=#FFFFFF;fontSize=12;align=center;" vertex="1" parent="dgaH53lybmkEFGB52cs7-1">
314+
<mxGeometry x="840" y="630" width="110" height="63" as="geometry" />
315+
</mxCell>
316+
<mxCell id="Optskv5YCS5HUoDn0TRo-1" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.75;exitDx=0;exitDy=0;entryX=0;entryY=0.25;entryDx=0;entryDy=0;dashed=1;" edge="1" parent="dgaH53lybmkEFGB52cs7-1" source="dgaH53lybmkEFGB52cs7-42" target="Optskv5YCS5HUoDn0TRo-0">
317+
<mxGeometry relative="1" as="geometry">
318+
<mxPoint x="730" y="282" as="sourcePoint" />
319+
<mxPoint x="850" y="582" as="targetPoint" />
320+
</mxGeometry>
321+
</mxCell>
313322
</root>
314323
</mxGraphModel>
315324
</diagram>

src/main/java/com/adobe/campaign/tests/logparser/core/LogData.java

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -415,20 +415,25 @@ public File exportLogDataToCSV(String in_fileName) {
415415
*/
416416
public File exportLogDataToCSV(Collection<String> in_headerSet, String in_csvFileName)
417417
throws LogDataExportToFileException {
418-
File l_exportFile = LogParserFileUtils.createNewFile(in_csvFileName);
418+
File l_exportFile = null;
419+
try {
420+
l_exportFile = LogParserFileUtils.createNewFile(in_csvFileName);
419421

420-
try (CSVPrinter printer = new CSVPrinter(new FileWriter(l_exportFile), CSVFormat.DEFAULT)) {
421-
printer.printRecord(in_headerSet);
422+
try (CSVPrinter printer = new CSVPrinter(new FileWriter(l_exportFile), CSVFormat.DEFAULT)) {
423+
printer.printRecord(in_headerSet);
422424

423-
for (StdLogEntry lt_entry : this.getEntries().values()) {
424-
Map lt_values = lt_entry.fetchValueMapPrintable();
425-
printer.printRecord(in_headerSet.stream().map(h -> lt_values.get(h)).collect(Collectors.toList()));
425+
for (StdLogEntry lt_entry : this.getEntries().values()) {
426+
Map lt_values = lt_entry.fetchValueMapPrintable();
427+
printer.printRecord(in_headerSet.stream().map(h -> lt_values.get(h)).collect(Collectors.toList()));
428+
}
426429
}
427430

428431
} catch (IOException ex) {
429432
throw new LogDataExportToFileException("Encountered error while exporting the log data to a CSV file.", ex);
430433
}
431434

435+
436+
432437
return l_exportFile;
433438
}
434439

@@ -459,9 +464,10 @@ public File exportLogDataToHTML(String in_reportTitle, String in_htmlFileName) {
459464
* @return an HTML file containing the LogData as a table
460465
*/
461466
public File exportLogDataToHTML(Collection<String> in_headerSet, String in_reportTitle, String in_htmlFileName) {
462-
File l_exportFile = LogParserFileUtils.createNewFile(in_htmlFileName);
467+
File l_exportFile;
463468

464469
try {
470+
l_exportFile = LogParserFileUtils.createNewFile(in_htmlFileName);
465471
StringBuilder sb = new StringBuilder();
466472
sb.append(HTMLReportUtils.fetchSTDPageStart("diffTable.css"));
467473
//Creating the overview report
@@ -485,7 +491,7 @@ public File exportLogDataToHTML(Collection<String> in_headerSet, String in_repor
485491

486492
FileUtils.writeStringToFile(l_exportFile, sb.toString(), "UTF-8");
487493
} catch (IOException e) {
488-
throw new LogDataExportToFileException("We were unable to write to the file " + l_exportFile.getPath());
494+
throw new LogDataExportToFileException("We were unable to write to the file " + in_htmlFileName, e);
489495
}
490496

491497
return l_exportFile;
@@ -535,15 +541,18 @@ public File exportLogDataToJSON(String in_jsonFileName) throws LogDataExportToFi
535541
*/
536542
public File exportLogDataToJSON(Collection<String> in_headerSet, String in_jsonFileName)
537543
throws LogDataExportToFileException {
538-
File l_exportFile = LogParserFileUtils.createNewFile(in_jsonFileName);
539-
List<Map<String, String>> jsonList = new ArrayList<>();
540-
jsonList.addAll(this.getEntries().values().stream().map(StdLogEntry::fetchValueMapPrintable)
541-
.collect(Collectors.toList()));
544+
File l_exportFile;
542545

543546
try {
544-
ObjectMapper objectMapper = new ObjectMapper();
545-
objectMapper.writeValue(l_exportFile,
546-
objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(jsonList));
547+
l_exportFile= LogParserFileUtils.createNewFile(in_jsonFileName);
548+
List<Map<String, String>> jsonList = new ArrayList<>();
549+
jsonList.addAll(this.getEntries().values().stream().map(StdLogEntry::fetchValueMapPrintable)
550+
.collect(Collectors.toList()));
551+
552+
553+
ObjectMapper objectMapper = new ObjectMapper();
554+
objectMapper.writeValue(l_exportFile,
555+
objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(jsonList));
547556
} catch (IOException e) {
548557
throw new LogDataExportToFileException("Encountered error while exporting the log data to a JSON file.", e);
549558
}

src/main/java/com/adobe/campaign/tests/logparser/core/LogDataFactory.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -266,9 +266,11 @@ public static <T extends StdLogEntry> File generateDiffReport(LogData<T> in_logD
266266
public static <T extends StdLogEntry> File generateDiffReport(Map<String, LogDataComparison<T>> in_comparisonReport,
267267
List<String> in_headers, String in_reportName) {
268268
StringBuilder sb = new StringBuilder();
269-
File l_exportFile = LogParserFileUtils.createNewFile(in_reportName + ".html");
270-
269+
File l_exportFile = null;
270+
String l_exportFilePath = in_reportName + ".html";
271271
try {
272+
l_exportFile = LogParserFileUtils.createNewFile(l_exportFilePath);
273+
l_exportFilePath = l_exportFile.getPath();
272274
sb.append(HTMLReportUtils.fetchSTDPageStart("diffTable.css"));
273275

274276
//Creating the overview report
@@ -319,8 +321,9 @@ public static <T extends StdLogEntry> File generateDiffReport(Map<String, LogDat
319321
sb.append("</html>");
320322

321323
FileUtils.writeStringToFile(l_exportFile, sb.toString(), "UTF-8");
324+
322325
} catch (IOException e) {
323-
throw new LogDataExportToFileException("We were unable to write to the file "+ l_exportFile.getPath());
326+
throw new LogDataExportToFileException("We were unable to write to the file "+ l_exportFilePath);
324327
}
325328
return l_exportFile;
326329
}

src/main/java/com/adobe/campaign/tests/logparser/utils/LogParserFileUtils.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
import org.apache.logging.log4j.Logger;
1414

1515
import java.io.File;
16+
import java.io.IOException;
17+
import java.nio.file.Files;
18+
import java.nio.file.Paths;
1619

1720
public class LogParserFileUtils {
1821
public static final String LOG_PARSER_EXPORTS = "log_parser_output/exports";
@@ -34,8 +37,8 @@ public static void cleanFile(File in_file) {
3437
* @param in_fileName a file name
3538
* @return the file object
3639
*/
37-
public static File createFile(String in_fileName) {
38-
40+
public static File createFile(String in_fileName) throws IOException {
41+
Files.createDirectories(Paths.get(LOG_PARSER_EXPORTS));
3942
return new File(LOG_PARSER_EXPORTS,in_fileName);
4043
}
4144

@@ -44,7 +47,7 @@ public static File createFile(String in_fileName) {
4447
* @param in_fileName A file name
4548
* @return a file object which is completely new and empty
4649
*/
47-
public static File createNewFile(String in_fileName) {
50+
public static File createNewFile(String in_fileName) throws IOException {
4851
File lr_file = createFile(in_fileName);
4952
cleanFile(lr_file);
5053
return lr_file;

src/test/java/com/adobe/campaign/tests/logparser/core/LogDataTest.java

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@
2121
import org.hamcrest.Matcher;
2222
import org.hamcrest.Matchers;
2323
import org.testng.Assert;
24+
import org.testng.annotations.AfterClass;
25+
import org.testng.annotations.BeforeMethod;
2426
import org.testng.annotations.Test;
2527

26-
import java.io.BufferedReader;
2728
import java.io.File;
28-
import java.io.FileReader;
2929
import java.io.IOException;
3030
import java.util.*;
3131

@@ -35,6 +35,18 @@
3535

3636
public class LogDataTest {
3737

38+
@BeforeMethod(alwaysRun = true)
39+
@AfterClass
40+
public void CleanUp() throws IOException {
41+
File l_stdOutPutFile = new File(LogParser.OUTPUT_ROOT);
42+
43+
if (l_stdOutPutFile.exists()) {
44+
FileUtils.deleteDirectory(l_stdOutPutFile);
45+
}
46+
47+
}
48+
49+
3850
/**
3951
* Testing that we correctly create a cube
4052
* <p>
@@ -1397,7 +1409,9 @@ public void testExportDataFileExists()
13971409

13981410
//Create the file so it is deleted
13991411
File l_duplicateFile = new File(LogParserFileUtils.LOG_PARSER_EXPORTS, l_fileNameToExpect);
1400-
l_duplicateFile.createNewFile();
1412+
//Files.
1413+
//l_duplicateFile.createNewFile();
1414+
LogParserFileUtils.createNewFile(LogParserFileUtils.LOG_PARSER_EXPORTS+"/"+l_fileNameToExpect);
14011415

14021416
assertThat("We should have the key for amcDataSource",
14031417
l_logData.getEntries().containsKey(l_searchItem1));

0 commit comments

Comments
 (0)