Skip to content

Commit 04cd60a

Browse files
authored
1.0.9 Cleanup + Nested search of log files (#70)
* Adding wildcard search fo files * Fixed issue #67 * replaced PowerMock with the version 4.11.0 of Mockito that supports static mocks (Java 8 and 11 compatible) * Updating TestNG * Removing unnecessary stacktrace and upgraded libraries * Fixed issue #68, we now log the findings
1 parent c8c4908 commit 04cd60a

19 files changed

+490
-133
lines changed

.github/workflows/maven-pr-analyze.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,22 +26,23 @@ jobs:
2626
runs-on: ubuntu-latest
2727
steps:
2828
# Check out Git repository
29-
- uses: actions/checkout@v2
29+
- uses: actions/checkout@v3
3030

3131
# Set up environment with Java and Maven
3232
- name: Set up JDK
33-
uses: actions/setup-java@v1
33+
uses: actions/setup-java@v3
3434
with:
35-
java-version: 11
35+
java-version: 17
36+
distribution: temurin
3637
- name: Cache SonarCloud packages
37-
uses: actions/cache@v1
38+
uses: actions/cache@v3
3839
with:
3940
path: ~/.sonar/cache
4041
key: ${{ runner.os }}-sonar
4142
restore-keys: ${{ runner.os }}-sonar
4243
# Set up dependency cache
4344
- name: Cache local Maven repository
44-
uses: actions/cache@v2
45+
uses: actions/cache@v3
4546
with:
4647
path: ~/.m2/repository
4748
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ Below is a diagram representing the class structure:
129129

130130
![The Class relationship](diagrams/Log_Parser-Classes.png)
131131

132-
## Searching a organizing log data
132+
## Searching and organizing log data
133133
As of versions 1.0.4 & 1.0.5 we have a series of search and organizing the log data.
134134

135135
### Search and Filter Mechanisms
@@ -229,6 +229,9 @@ AssertLogData.assertLogContains(List<String> in_filePathList, ParseDefinition in
229229
`AssertLogData.assertLogContains(List<String>, ParseDefinition, String, String)` allows you to perform an assertion directly on a file.
230230

231231
## Release Notes
232+
### 1.0.9
233+
- [#67](https://github.com/adobe/log-parser/issues/67) We can now select the files using a wild card. Given a directory we can now look for files in the sub-directory given a wild-card. The wildcards are implemented using Adobe Commons IO. Youcan read more on this in the [WildcardFilter JavaDoc](https://commons.apache.org/proper/commons-io/apidocs/org/apache/commons/io/filefilter/WildcardFilter.html)
234+
- [#68](https://github.com/adobe/log-parser/issues/68) We now present a report of the findings at the end of the analysis.
232235

233236
### 1.0.8.2
234237
- Building with java8.

pom.xml

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<!-- | MIT License | © Copyright 2020 Adobe. All rights reserved. | Permission
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<!-- | MIT License | © Copyright 2020 Adobe. All rights reserved. | Permission
24
is hereby granted, free of charge, to any person obtaining a copy of this
35
software and associated documentation files (the "Software"), to deal in
46
the Software without restriction, including without limitation the rights
@@ -283,16 +285,16 @@
283285
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
284286
<sonar.organization>adobeinc</sonar.organization>
285287
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
286-
<powermock.version>2.0.2</powermock.version>
287288
</properties>
288289
<reporting>
289290
<plugins>
290291
<plugin>
291292
<groupId>org.apache.maven.plugins</groupId>
292293
<artifactId>maven-javadoc-plugin</artifactId>
293-
<version>2.10.4</version>
294+
<version>2.10.3</version>
294295
<configuration>
295296
<stylesheet>java</stylesheet>
297+
<source>11</source>
296298
</configuration>
297299
</plugin>
298300
</plugins>
@@ -301,18 +303,18 @@
301303
<dependency>
302304
<groupId>org.testng</groupId>
303305
<artifactId>testng</artifactId>
304-
<version>7.4.0</version>
306+
<version>7.5.1</version>
305307
<scope>test</scope>
306308
</dependency>
307309
<dependency>
308310
<groupId>org.apache.logging.log4j</groupId>
309311
<artifactId>log4j-core</artifactId>
310-
<version>2.17.1</version>
312+
<version>2.20.0</version>
311313
</dependency>
312314
<dependency>
313315
<groupId>org.apache.logging.log4j</groupId>
314316
<artifactId>log4j-api</artifactId>
315-
<version>2.17.1</version>
317+
<version>2.20.0</version>
316318
</dependency>
317319
<dependency>
318320
<groupId>commons-lang</groupId>
@@ -332,25 +334,19 @@
332334
<dependency>
333335
<groupId>com.fasterxml.jackson.core</groupId>
334336
<artifactId>jackson-databind</artifactId>
335-
<version>2.13.4.1</version>
337+
<version>2.15.2</version>
336338
</dependency>
339+
<!-- Using 4.11.0 because we want to keep Java8 compatibility -->
337340
<dependency>
338341
<groupId>org.mockito</groupId>
339-
<artifactId>mockito-core</artifactId>
340-
<version>3.0.0</version>
342+
<artifactId>mockito-inline</artifactId>
343+
<version>4.11.0</version>
341344
<scope>test</scope>
342345
</dependency>
343346
<dependency>
344-
<groupId>org.powermock</groupId>
345-
<artifactId>powermock-module-testng</artifactId>
346-
<version>${powermock.version}</version>
347-
<scope>test</scope>
348-
</dependency>
349-
<dependency>
350-
<groupId>org.powermock</groupId>
351-
<artifactId>powermock-api-mockito2</artifactId>
352-
<version>${powermock.version}</version>
353-
<scope>test</scope>
347+
<groupId>org.apache.commons</groupId>
348+
<artifactId>commons-io</artifactId>
349+
<version>1.3.2</version>
354350
</dependency>
355351
</dependencies>
356352
</project>

src/main/java/com/adobe/campaign/tests/logparser/AssertLogData.java

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,21 @@
1515

1616
import com.adobe.campaign.tests.logparser.exceptions.StringParseException;
1717

18+
/**
19+
* Assertion mechanisms for logs. Using this class you can perform assertions on log data
20+
*/
1821
public class AssertLogData {
19-
22+
2023
protected AssertLogData() {
2124
throw new IllegalStateException("Utility class");
2225
}
2326

2427
/**
2528
* An assert that lets us see if the log data contains an entry with a given
2629
* value for a definition
27-
*
30+
* <p>
2831
* Author : gandomi
29-
*
32+
* <p>
3033
* @param in_logData
3134
* A Log data object
3235
* @param in_parseDefinitionEntry
@@ -47,9 +50,9 @@ public static <T extends StdLogEntry> void assertLogContains(LogData<T> in_logDa
4750
/**
4851
* An assert that lets us see if the log data contains an entry with a given
4952
* value for a definition
50-
*
53+
* <p>
5154
* Author : gandomi
52-
*
55+
* <p>
5356
* @param in_comment
5457
* A comment that is presented whenever the assertion fails
5558
* @param in_logData
@@ -72,9 +75,9 @@ public static <T extends StdLogEntry> void assertLogContains(String in_comment,
7275
/**
7376
* An assert that lets us see if the log data contains an entry with a given
7477
* value for a definition
75-
*
78+
* <p>
7679
* Author : gandomi
77-
*
80+
* <p>
7881
* @param in_logData
7982
* A Log data object
8083
* @param in_parseDefinitionEntryTitle
@@ -98,9 +101,9 @@ public static <T extends StdLogEntry> void assertLogContains(LogData<T> in_logDa
98101
/**
99102
* An assert that lets us see if the log data contains an entry with a given
100103
* value for a definition
101-
*
104+
* <p>
102105
* Author : gandomi
103-
*
106+
* <p>
104107
* @param in_comment
105108
* A comment that is presented whenever the assertion fails
106109
* @param in_logData
@@ -124,9 +127,9 @@ public static <T extends StdLogEntry> void assertLogContains(String in_comment,
124127
/**
125128
* This is an assertion at a file level. Given a set of log files it will
126129
* let you know if a given entry can be found
127-
*
130+
* <p>
128131
* Author : gandomi
129-
*
132+
* <p>
130133
* @param in_filePathList
131134
* A list of file paths containing log/generated data
132135
* @param in_parseDefinition
@@ -144,8 +147,6 @@ public static void assertLogContains(List<String> in_filePathList, ParseDefiniti
144147
assertLogContains(LogDataFactory.generateLogData(in_filePathList, in_parseDefinition),
145148
in_parseDefinitionEntryTitle, in_expectedValue);
146149
} catch (InstantiationException | IllegalAccessException | StringParseException e) {
147-
148-
e.printStackTrace();
149150
throw new AssertionError("Caught unexpected exception", e);
150151
}
151152

src/main/java/com/adobe/campaign/tests/logparser/GenericEntry.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,22 @@
1919
* The generic entry is a standard string based definition where the values are
2020
* stored as is. I.e. strings. All definitions are based on the ParseDefinition
2121
* class
22-
*
23-
*
22+
* <p>
2423
* Author : gandomi
25-
*
2624
*/
2725
public class GenericEntry extends StdLogEntry {
2826

27+
/**
28+
* Constructor accepting a @{@link ParseDefinition object}
29+
* @param in_definition A @{@link ParseDefinition object}
30+
*/
2931
public GenericEntry(ParseDefinition in_definition) {
3032
super(in_definition);
3133
}
3234

35+
/**
36+
* Default constructor
37+
*/
3338
public GenericEntry() {
3439
super(new ParseDefinition("Created By Default"));
3540
}

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

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,39 @@
2222

2323
import com.adobe.campaign.tests.logparser.exceptions.IncorrectParseDefinitionException;
2424

25+
/**
26+
* The main log object that contains the log information
27+
* @param <T> The log information is always of the type @{@link StdLogEntry}
28+
*/
2529
public class LogData<T extends StdLogEntry> {
2630

2731
protected static Logger log = LogManager.getLogger();
32+
2833
/**
2934
* This value is both csv header, and a JSON selector
3035
*/
3136
private Map<String, T> entries = new HashMap<>();
3237

38+
/**
39+
* A standard LogData constructor
40+
*
41+
* @param in_stdLogEnDataData An object of the type @{@link StdLogEntry}
42+
*/
3343
public LogData(T in_stdLogEnDataData) {
3444
this.addEntry(in_stdLogEnDataData);
3545
}
3646

47+
/**
48+
* A map of String and @{@link StdLogEntry}
49+
* @param in_logMap A Map of generated Keys and @{@link StdLogEntry data}
50+
*/
3751
public LogData(Map<String, T> in_logMap) {
3852
this.setEntries(in_logMap);
3953
}
4054

55+
/**
56+
* Default constructor
57+
*/
4158
public LogData() {
4259
}
4360

@@ -52,9 +69,9 @@ public void setEntries(Map<String, T> in_logMap) {
5269
/**
5370
* This method adds an entry to the log data. If the entry already exists we
5471
* just increment the frequence
55-
*
72+
* <p>
5673
* Author : gandomi
57-
*
74+
* <p>
5875
* @param lt_cubeEntry
5976
* An object of the type {@link StdLogEntry}
6077
*
@@ -74,7 +91,7 @@ public void addEntry(T lt_cubeEntry) {
7491
/**
7592
* This method allows you to access an entry in the log data. For this you
7693
* need the key of the Data
77-
*
94+
* <p>
7895
* Author : gandomi
7996
*
8097
* @param in_dataEntryKey
@@ -89,7 +106,7 @@ public T get(String in_dataEntryKey) {
89106
/**
90107
* This method allows you to access a value within the cube map. For this
91108
* you need the key of the Data and the title of the value
92-
*
109+
* <p>
93110
* Author : gandomi
94111
*
95112
* @param in_dataEntryKey
@@ -121,7 +138,7 @@ public Object get(String in_dataEntryKey, String in_valueKey) throws IncorrectPa
121138
/**
122139
* This method allows you to change a specific value in the log data. For
123140
* this, you need the key and the parse definition title to find the value
124-
*
141+
* <p>
125142
* Author : gandomi
126143
*
127144
* @param in_dataEntryKey
@@ -175,7 +192,7 @@ public boolean equals(Object obj) {
175192
* Here we create a new LogDataObject with the given ParseDefinitionEntry.
176193
* This method performs a groupby for the given value. The frequence will
177194
* also take into account the original frequence
178-
*
195+
* <p>
179196
* Author : gandomi
180197
*
181198
* @param in_parseDefinitionEntryKey
@@ -207,7 +224,7 @@ public <U extends StdLogEntry> LogData<U> groupBy(String in_parseDefinitionEntry
207224
* Here we create a new LogDataObject with the given ParseDefinitionEntry.
208225
* This method performs a groupby for the given value. The frequence will
209226
* also take into account the original frequence
210-
*
227+
* <p>
211228
* Author : gandomi
212229
*
213230
* @param in_parseDefinitionEntryKeyList
@@ -270,7 +287,7 @@ public <U extends StdLogEntry> LogData<U> groupBy(List<String> in_parseDefinitio
270287
* Here we create a new LogDataObject with the given ParseDefinitionEntry.
271288
* This method performs a groupby for the given value. The frequence will
272289
* also take into account the original frequence
273-
*
290+
* <p>
274291
* Author : gandomi
275292
*
276293
* @param in_parseDefinitionEntryKeyList
@@ -297,7 +314,7 @@ public LogData<GenericEntry> groupBy(List<String> in_parseDefinitionEntryKeyList
297314
* Here we create a new LogDataObject with the given ParseDefinitionEntry.
298315
* This method performs a groupby for the given value. The frequence will
299316
* also take into account the original frequence
300-
*
317+
* <p>
301318
* Author : gandomi
302319
*
303320
* @param in_parseDefinitionEntryKey
@@ -321,7 +338,7 @@ public LogData<GenericEntry> groupBy(String in_parseDefinitionEntryKey)
321338

322339
/**
323340
* This method filters the LogData with the given properties
324-
*
341+
* <p>
325342
* Author : gandomi
326343
*
327344
* @param in_filterKeyValues
@@ -345,7 +362,7 @@ public LogData<T> filterBy(Map<String, Object> in_filterKeyValues) {
345362
/**
346363
* This method searches the LogData for an enry with a specific value for a
347364
* parse definition entry name
348-
*
365+
* <p>
349366
* Author : gandomi
350367
*
351368
* @param in_parseDefinitionName
@@ -365,7 +382,7 @@ public LogData<T> searchEntries(String in_parseDefinitionName, String in_searchV
365382

366383
/**
367384
* This method searches the LogData with the given properties
368-
*
385+
* <p>
369386
* Author : gandomi
370387
*
371388
* @param in_searchKeyValues
@@ -381,7 +398,7 @@ public LogData<T> searchEntries(Map<String, Object> in_searchKeyValues) {
381398

382399
/**
383400
* Lets us know if the given search term could be found.
384-
*
401+
* <p>
385402
* Author : gandomi
386403
*
387404
* @param in_parseDefinitionName
@@ -401,7 +418,7 @@ public boolean isEntryPresent(String in_parseDefinitionName, String in_searchVal
401418

402419
/**
403420
* Lets us know if the given search terms could be found.
404-
*
421+
* <p>
405422
* Author : gandomi
406423
*
407424
* @param in_searchKeyValues A map of &lt;String,Object&gt; representation the values we want

0 commit comments

Comments
 (0)