Skip to content

Commit

Permalink
1.0.9 Cleanup + Nested search of log files (#70)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
baubakg authored Oct 3, 2023
1 parent c8c4908 commit 04cd60a
Show file tree
Hide file tree
Showing 19 changed files with 490 additions and 133 deletions.
11 changes: 6 additions & 5 deletions .github/workflows/maven-pr-analyze.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,23 @@ jobs:
runs-on: ubuntu-latest
steps:
# Check out Git repository
- uses: actions/checkout@v2
- uses: actions/checkout@v3

# Set up environment with Java and Maven
- name: Set up JDK
uses: actions/setup-java@v1
uses: actions/setup-java@v3
with:
java-version: 11
java-version: 17
distribution: temurin
- name: Cache SonarCloud packages
uses: actions/cache@v1
uses: actions/cache@v3
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
# Set up dependency cache
- name: Cache local Maven repository
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ Below is a diagram representing the class structure:

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

## Searching a organizing log data
## Searching and organizing log data
As of versions 1.0.4 & 1.0.5 we have a series of search and organizing the log data.

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

## Release Notes
### 1.0.9
- [#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)
- [#68](https://github.com/adobe/log-parser/issues/68) We now present a report of the findings at the end of the analysis.

### 1.0.8.2
- Building with java8.
Expand Down
34 changes: 15 additions & 19 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<!-- | MIT License | © Copyright 2020 Adobe. All rights reserved. | Permission
<?xml version="1.0" encoding="UTF-8"?>

<!-- | MIT License | © Copyright 2020 Adobe. All rights reserved. | Permission
is hereby granted, free of charge, to any person obtaining a copy of this
software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights
Expand Down Expand Up @@ -283,16 +285,16 @@
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<sonar.organization>adobeinc</sonar.organization>
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
<powermock.version>2.0.2</powermock.version>
</properties>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.4</version>
<version>2.10.3</version>
<configuration>
<stylesheet>java</stylesheet>
<source>11</source>
</configuration>
</plugin>
</plugins>
Expand All @@ -301,18 +303,18 @@
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>7.4.0</version>
<version>7.5.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.17.1</version>
<version>2.20.0</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.17.1</version>
<version>2.20.0</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
Expand All @@ -332,25 +334,19 @@
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.13.4.1</version>
<version>2.15.2</version>
</dependency>
<!-- Using 4.11.0 because we want to keep Java8 compatibility -->
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>3.0.0</version>
<artifactId>mockito-inline</artifactId>
<version>4.11.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-testng</artifactId>
<version>${powermock.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito2</artifactId>
<version>${powermock.version}</version>
<scope>test</scope>
<groupId>org.apache.commons</groupId>
<artifactId>commons-io</artifactId>
<version>1.3.2</version>
</dependency>
</dependencies>
</project>
27 changes: 14 additions & 13 deletions src/main/java/com/adobe/campaign/tests/logparser/AssertLogData.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,21 @@

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

/**
* Assertion mechanisms for logs. Using this class you can perform assertions on log data
*/
public class AssertLogData {

protected AssertLogData() {
throw new IllegalStateException("Utility class");
}

/**
* An assert that lets us see if the log data contains an entry with a given
* value for a definition
*
* <p>
* Author : gandomi
*
* <p>
* @param in_logData
* A Log data object
* @param in_parseDefinitionEntry
Expand All @@ -47,9 +50,9 @@ public static <T extends StdLogEntry> void assertLogContains(LogData<T> in_logDa
/**
* An assert that lets us see if the log data contains an entry with a given
* value for a definition
*
* <p>
* Author : gandomi
*
* <p>
* @param in_comment
* A comment that is presented whenever the assertion fails
* @param in_logData
Expand All @@ -72,9 +75,9 @@ public static <T extends StdLogEntry> void assertLogContains(String in_comment,
/**
* An assert that lets us see if the log data contains an entry with a given
* value for a definition
*
* <p>
* Author : gandomi
*
* <p>
* @param in_logData
* A Log data object
* @param in_parseDefinitionEntryTitle
Expand All @@ -98,9 +101,9 @@ public static <T extends StdLogEntry> void assertLogContains(LogData<T> in_logDa
/**
* An assert that lets us see if the log data contains an entry with a given
* value for a definition
*
* <p>
* Author : gandomi
*
* <p>
* @param in_comment
* A comment that is presented whenever the assertion fails
* @param in_logData
Expand All @@ -124,9 +127,9 @@ public static <T extends StdLogEntry> void assertLogContains(String in_comment,
/**
* This is an assertion at a file level. Given a set of log files it will
* let you know if a given entry can be found
*
* <p>
* Author : gandomi
*
* <p>
* @param in_filePathList
* A list of file paths containing log/generated data
* @param in_parseDefinition
Expand All @@ -144,8 +147,6 @@ public static void assertLogContains(List<String> in_filePathList, ParseDefiniti
assertLogContains(LogDataFactory.generateLogData(in_filePathList, in_parseDefinition),
in_parseDefinitionEntryTitle, in_expectedValue);
} catch (InstantiationException | IllegalAccessException | StringParseException e) {

e.printStackTrace();
throw new AssertionError("Caught unexpected exception", e);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,22 @@
* The generic entry is a standard string based definition where the values are
* stored as is. I.e. strings. All definitions are based on the ParseDefinition
* class
*
*
* <p>
* Author : gandomi
*
*/
public class GenericEntry extends StdLogEntry {

/**
* Constructor accepting a @{@link ParseDefinition object}
* @param in_definition A @{@link ParseDefinition object}
*/
public GenericEntry(ParseDefinition in_definition) {
super(in_definition);
}

/**
* Default constructor
*/
public GenericEntry() {
super(new ParseDefinition("Created By Default"));
}
Expand Down
45 changes: 31 additions & 14 deletions src/main/java/com/adobe/campaign/tests/logparser/LogData.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,39 @@

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

/**
* The main log object that contains the log information
* @param <T> The log information is always of the type @{@link StdLogEntry}
*/
public class LogData<T extends StdLogEntry> {

protected static Logger log = LogManager.getLogger();

/**
* This value is both csv header, and a JSON selector
*/
private Map<String, T> entries = new HashMap<>();

/**
* A standard LogData constructor
*
* @param in_stdLogEnDataData An object of the type @{@link StdLogEntry}
*/
public LogData(T in_stdLogEnDataData) {
this.addEntry(in_stdLogEnDataData);
}

/**
* A map of String and @{@link StdLogEntry}
* @param in_logMap A Map of generated Keys and @{@link StdLogEntry data}
*/
public LogData(Map<String, T> in_logMap) {
this.setEntries(in_logMap);
}

/**
* Default constructor
*/
public LogData() {
}

Expand All @@ -52,9 +69,9 @@ public void setEntries(Map<String, T> in_logMap) {
/**
* This method adds an entry to the log data. If the entry already exists we
* just increment the frequence
*
* <p>
* Author : gandomi
*
* <p>
* @param lt_cubeEntry
* An object of the type {@link StdLogEntry}
*
Expand All @@ -74,7 +91,7 @@ public void addEntry(T lt_cubeEntry) {
/**
* This method allows you to access an entry in the log data. For this you
* need the key of the Data
*
* <p>
* Author : gandomi
*
* @param in_dataEntryKey
Expand All @@ -89,7 +106,7 @@ public T get(String in_dataEntryKey) {
/**
* This method allows you to access a value within the cube map. For this
* you need the key of the Data and the title of the value
*
* <p>
* Author : gandomi
*
* @param in_dataEntryKey
Expand Down Expand Up @@ -121,7 +138,7 @@ public Object get(String in_dataEntryKey, String in_valueKey) throws IncorrectPa
/**
* This method allows you to change a specific value in the log data. For
* this, you need the key and the parse definition title to find the value
*
* <p>
* Author : gandomi
*
* @param in_dataEntryKey
Expand Down Expand Up @@ -175,7 +192,7 @@ public boolean equals(Object obj) {
* Here we create a new LogDataObject with the given ParseDefinitionEntry.
* This method performs a groupby for the given value. The frequence will
* also take into account the original frequence
*
* <p>
* Author : gandomi
*
* @param in_parseDefinitionEntryKey
Expand Down Expand Up @@ -207,7 +224,7 @@ public <U extends StdLogEntry> LogData<U> groupBy(String in_parseDefinitionEntry
* Here we create a new LogDataObject with the given ParseDefinitionEntry.
* This method performs a groupby for the given value. The frequence will
* also take into account the original frequence
*
* <p>
* Author : gandomi
*
* @param in_parseDefinitionEntryKeyList
Expand Down Expand Up @@ -270,7 +287,7 @@ public <U extends StdLogEntry> LogData<U> groupBy(List<String> in_parseDefinitio
* Here we create a new LogDataObject with the given ParseDefinitionEntry.
* This method performs a groupby for the given value. The frequence will
* also take into account the original frequence
*
* <p>
* Author : gandomi
*
* @param in_parseDefinitionEntryKeyList
Expand All @@ -297,7 +314,7 @@ public LogData<GenericEntry> groupBy(List<String> in_parseDefinitionEntryKeyList
* Here we create a new LogDataObject with the given ParseDefinitionEntry.
* This method performs a groupby for the given value. The frequence will
* also take into account the original frequence
*
* <p>
* Author : gandomi
*
* @param in_parseDefinitionEntryKey
Expand All @@ -321,7 +338,7 @@ public LogData<GenericEntry> groupBy(String in_parseDefinitionEntryKey)

/**
* This method filters the LogData with the given properties
*
* <p>
* Author : gandomi
*
* @param in_filterKeyValues
Expand All @@ -345,7 +362,7 @@ public LogData<T> filterBy(Map<String, Object> in_filterKeyValues) {
/**
* This method searches the LogData for an enry with a specific value for a
* parse definition entry name
*
* <p>
* Author : gandomi
*
* @param in_parseDefinitionName
Expand All @@ -365,7 +382,7 @@ public LogData<T> searchEntries(String in_parseDefinitionName, String in_searchV

/**
* This method searches the LogData with the given properties
*
* <p>
* Author : gandomi
*
* @param in_searchKeyValues
Expand All @@ -381,7 +398,7 @@ public LogData<T> searchEntries(Map<String, Object> in_searchKeyValues) {

/**
* Lets us know if the given search term could be found.
*
* <p>
* Author : gandomi
*
* @param in_parseDefinitionName
Expand All @@ -401,7 +418,7 @@ public boolean isEntryPresent(String in_parseDefinitionName, String in_searchVal

/**
* Lets us know if the given search terms could be found.
*
* <p>
* Author : gandomi
*
* @param in_searchKeyValues A map of &lt;String,Object&gt; representation the values we want
Expand Down
Loading

0 comments on commit 04cd60a

Please sign in to comment.