diff --git a/.github/workflows/maven-pr-analyze.yml b/.github/workflows/maven-pr-analyze.yml index cad4f92..7158646 100644 --- a/.github/workflows/maven-pr-analyze.yml +++ b/.github/workflows/maven-pr-analyze.yml @@ -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') }} diff --git a/README.md b/README.md index 4d6ffee..9770a8d 100644 --- a/README.md +++ b/README.md @@ -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 @@ -229,6 +229,9 @@ AssertLogData.assertLogContains(List in_filePathList, ParseDefinition in `AssertLogData.assertLogContains(List, 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. diff --git a/pom.xml b/pom.xml index 78d5a63..6433d81 100644 --- a/pom.xml +++ b/pom.xml @@ -1,4 +1,6 @@ - org.mockito - mockito-core - 3.0.0 + mockito-inline + 4.11.0 test - org.powermock - powermock-module-testng - ${powermock.version} - test - - - org.powermock - powermock-api-mockito2 - ${powermock.version} - test + org.apache.commons + commons-io + 1.3.2 diff --git a/src/main/java/com/adobe/campaign/tests/logparser/AssertLogData.java b/src/main/java/com/adobe/campaign/tests/logparser/AssertLogData.java index 77d7edc..b7b7f70 100644 --- a/src/main/java/com/adobe/campaign/tests/logparser/AssertLogData.java +++ b/src/main/java/com/adobe/campaign/tests/logparser/AssertLogData.java @@ -15,8 +15,11 @@ 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"); } @@ -24,9 +27,9 @@ protected AssertLogData() { /** * An assert that lets us see if the log data contains an entry with a given * value for a definition - * + *

* Author : gandomi - * + *

* @param in_logData * A Log data object * @param in_parseDefinitionEntry @@ -47,9 +50,9 @@ public static void assertLogContains(LogData in_logDa /** * An assert that lets us see if the log data contains an entry with a given * value for a definition - * + *

* Author : gandomi - * + *

* @param in_comment * A comment that is presented whenever the assertion fails * @param in_logData @@ -72,9 +75,9 @@ public static 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 - * + *

* Author : gandomi - * + *

* @param in_logData * A Log data object * @param in_parseDefinitionEntryTitle @@ -98,9 +101,9 @@ public static void assertLogContains(LogData in_logDa /** * An assert that lets us see if the log data contains an entry with a given * value for a definition - * + *

* Author : gandomi - * + *

* @param in_comment * A comment that is presented whenever the assertion fails * @param in_logData @@ -124,9 +127,9 @@ public static 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 - * + *

* Author : gandomi - * + *

* @param in_filePathList * A list of file paths containing log/generated data * @param in_parseDefinition @@ -144,8 +147,6 @@ public static void assertLogContains(List 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); } diff --git a/src/main/java/com/adobe/campaign/tests/logparser/GenericEntry.java b/src/main/java/com/adobe/campaign/tests/logparser/GenericEntry.java index 5bac9e3..1dd84bf 100644 --- a/src/main/java/com/adobe/campaign/tests/logparser/GenericEntry.java +++ b/src/main/java/com/adobe/campaign/tests/logparser/GenericEntry.java @@ -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 - * - * + *

* 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")); } diff --git a/src/main/java/com/adobe/campaign/tests/logparser/LogData.java b/src/main/java/com/adobe/campaign/tests/logparser/LogData.java index c0e8b29..ef69b8d 100644 --- a/src/main/java/com/adobe/campaign/tests/logparser/LogData.java +++ b/src/main/java/com/adobe/campaign/tests/logparser/LogData.java @@ -22,22 +22,39 @@ import com.adobe.campaign.tests.logparser.exceptions.IncorrectParseDefinitionException; +/** + * The main log object that contains the log information + * @param The log information is always of the type @{@link StdLogEntry} + */ public class LogData { protected static Logger log = LogManager.getLogger(); + /** * This value is both csv header, and a JSON selector */ private Map 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 in_logMap) { this.setEntries(in_logMap); } + /** + * Default constructor + */ public LogData() { } @@ -52,9 +69,9 @@ public void setEntries(Map in_logMap) { /** * This method adds an entry to the log data. If the entry already exists we * just increment the frequence - * + *

* Author : gandomi - * + *

* @param lt_cubeEntry * An object of the type {@link StdLogEntry} * @@ -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 - * + *

* Author : gandomi * * @param in_dataEntryKey @@ -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 - * + *

* Author : gandomi * * @param in_dataEntryKey @@ -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 - * + *

* Author : gandomi * * @param in_dataEntryKey @@ -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 - * + *

* Author : gandomi * * @param in_parseDefinitionEntryKey @@ -207,7 +224,7 @@ public LogData 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 - * + *

* Author : gandomi * * @param in_parseDefinitionEntryKeyList @@ -270,7 +287,7 @@ public LogData groupBy(List 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 - * + *

* Author : gandomi * * @param in_parseDefinitionEntryKeyList @@ -297,7 +314,7 @@ public LogData groupBy(List 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 - * + *

* Author : gandomi * * @param in_parseDefinitionEntryKey @@ -321,7 +338,7 @@ public LogData groupBy(String in_parseDefinitionEntryKey) /** * This method filters the LogData with the given properties - * + *

* Author : gandomi * * @param in_filterKeyValues @@ -345,7 +362,7 @@ public LogData filterBy(Map in_filterKeyValues) { /** * This method searches the LogData for an enry with a specific value for a * parse definition entry name - * + *

* Author : gandomi * * @param in_parseDefinitionName @@ -365,7 +382,7 @@ public LogData searchEntries(String in_parseDefinitionName, String in_searchV /** * This method searches the LogData with the given properties - * + *

* Author : gandomi * * @param in_searchKeyValues @@ -381,7 +398,7 @@ public LogData searchEntries(Map in_searchKeyValues) { /** * Lets us know if the given search term could be found. - * + *

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

* Author : gandomi * * @param in_searchKeyValues A map of <String,Object> representation the values we want diff --git a/src/main/java/com/adobe/campaign/tests/logparser/LogDataFactory.java b/src/main/java/com/adobe/campaign/tests/logparser/LogDataFactory.java index 08c547a..e0929d7 100644 --- a/src/main/java/com/adobe/campaign/tests/logparser/LogDataFactory.java +++ b/src/main/java/com/adobe/campaign/tests/logparser/LogDataFactory.java @@ -14,10 +14,18 @@ */ package com.adobe.campaign.tests.logparser; +import java.io.File; +import java.util.ArrayList; +import java.util.Iterator; import java.util.List; import com.adobe.campaign.tests.logparser.exceptions.ParseDefinitionImportExportException; import com.adobe.campaign.tests.logparser.exceptions.StringParseException; +import org.apache.commons.io.FileUtils; +import org.apache.commons.io.filefilter.TrueFileFilter; +import org.apache.commons.io.filefilter.WildcardFileFilter; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; /** * Factory class for creating log data @@ -26,6 +34,7 @@ * */ public class LogDataFactory { + protected static Logger log = LogManager.getLogger(); protected LogDataFactory() { throw new IllegalStateException("Utility class"); @@ -171,4 +180,85 @@ public static LogData generateLogData(List in_filePathList GenericEntry.class); } + /** + * A factory method for LogData. By default we create GenricEntries. Given a root directory path and a wildcard for + * finding files, it generates a LogDataObject containing all the data the log parser finds in the files matching + * the search query + *

+ * Author : gandomi + * + * @param in_rootDir A list of file paths containing log/generated data + * @param in_fileFilter A wildcard to be used for filtering the files + * @param in_parseDefinition A ParseDefinition Object defining the parsing rules + * @return A LogData Object containing the found entries from the logs + * @throws ParseDefinitionImportExportException Thrown if there is a problem with the given parseDefinition file + * @throws InstantiationException if this {@code Class} represents an abstract class, an interface, an + * array class, a primitive type, or void; or if the class has no + * nullary constructor; or if the instantiation fails for some other + * reason. + * @throws IllegalAccessException if the class or its nullary constructor is not accessible. + * @throws StringParseException When there are logical rules when parsing the given string + */ + public static LogData generateLogData(String in_rootDir, String in_fileFilter, + ParseDefinition in_parseDefinition) + throws StringParseException, InstantiationException, IllegalAccessException { + List l_foundFilesList = findFilePaths(in_rootDir, in_fileFilter); + return generateLogData(l_foundFilesList, in_parseDefinition); + + } + + + /** + * A factory method for LogData. By default we create GenricEntries. Given a root directory path and a wildcard for + * finding files, it generates a LogDataObject containing all the data the log parser finds in the files matching + * the search query defined as a json + *

+ * Author : gandomi + * + * @param in_rootDir A starting directory to start our file search + * @param in_fileFilter A wild card pattern to start our searches + * @param in_jsonParseDefinitionFilePath The file path of a ParseDefinition + * @return A LogData Object containing the found entries from the logs + * @throws ParseDefinitionImportExportException Thrown if there is a problem with the given parseDefinition file + * @throws InstantiationException if this {@code Class} represents an abstract class, an interface, an + * array class, a primitive type, or void; or if the class has no + * nullary constructor; or if the instantiation fails for some other + * reason. + * @throws IllegalAccessException if the class or its nullary constructor is not accessible. + * @throws StringParseException When there are logical rules when parsing the given string + */ + public static LogData generateLogData(String in_rootDir, String in_fileFilter, + String in_jsonParseDefinitionFilePath) throws InstantiationException, IllegalAccessException, + StringParseException, ParseDefinitionImportExportException { + + return LogDataFactory.generateLogData(in_rootDir, in_fileFilter, + ParseDefinitionFactory.importParseDefinition(in_jsonParseDefinitionFilePath)); + } + + /** + * Given a root directory and a filter, we return a list of files that correspond to our search mechanism + * + * @param in_rootDir A starting directory to start our file search + * @param in_fileFilter A wild card pattern to start our searches + * @return a list of file paths that can be used for + */ + public static List findFilePaths(String in_rootDir, String in_fileFilter) { + File l_rootDir = new File(in_rootDir); + + if (!l_rootDir.exists()) { + throw new IllegalArgumentException("The given root path directory " + in_rootDir + " does not exist."); + } + + if (!l_rootDir.isDirectory()) { + throw new IllegalArgumentException("The given root path " + in_rootDir + " is not a directory."); + } + + Iterator l_foundFilesIterator = FileUtils.iterateFiles(l_rootDir, new WildcardFileFilter(in_fileFilter), + TrueFileFilter.INSTANCE); + List l_foundFilesList = new ArrayList<>(); + l_foundFilesIterator.forEachRemaining(f -> l_foundFilesList.add(f.getAbsolutePath())); + log.info("Searching within the {} matching files :", l_foundFilesList.size()); + l_foundFilesList.stream().forEach(log::info); + return l_foundFilesList; + } } diff --git a/src/main/java/com/adobe/campaign/tests/logparser/ParseDefinitionFactory.java b/src/main/java/com/adobe/campaign/tests/logparser/ParseDefinitionFactory.java index 46575b8..f570c51 100644 --- a/src/main/java/com/adobe/campaign/tests/logparser/ParseDefinitionFactory.java +++ b/src/main/java/com/adobe/campaign/tests/logparser/ParseDefinitionFactory.java @@ -170,12 +170,10 @@ protected static void createParents(File in_file) { * @param mapper * a mapper object for testing * @return The file containing the exported data - * @throws ParseDefinitionImportExportException - * when we face problems managing the export * */ protected static File exportParseDefinitionToJSON(ParseDefinition in_parseDefinition, File in_jsonFile, - ObjectMapper mapper) throws ParseDefinitionImportExportException { + ObjectMapper mapper) { try { mapper.writeValue(in_jsonFile, in_parseDefinition); diff --git a/src/main/java/com/adobe/campaign/tests/logparser/StdLogEntry.java b/src/main/java/com/adobe/campaign/tests/logparser/StdLogEntry.java index 26a651e..d5a65e4 100644 --- a/src/main/java/com/adobe/campaign/tests/logparser/StdLogEntry.java +++ b/src/main/java/com/adobe/campaign/tests/logparser/StdLogEntry.java @@ -41,6 +41,10 @@ public abstract class StdLogEntry { protected static final String STD_DATA_FREQUENCE = "frequence"; + /** + * A method that creates the key to identify each stored entry + * @return A constructed key + */ public abstract String makeKey(); public StdLogEntry(ParseDefinition in_definition) { @@ -70,8 +74,8 @@ public StdLogEntry() { public abstract StdLogEntry copy(); /** - * Returns the aw unchanged value map - * @return + * Returns the naw unchanged value map + * @return a map of generated keys and stored values */ public Map getValuesMap() { return valuesMap; diff --git a/src/main/java/com/adobe/campaign/tests/logparser/StringParseFactory.java b/src/main/java/com/adobe/campaign/tests/logparser/StringParseFactory.java index 8d6bc47..f6157a9 100644 --- a/src/main/java/com/adobe/campaign/tests/logparser/StringParseFactory.java +++ b/src/main/java/com/adobe/campaign/tests/logparser/StringParseFactory.java @@ -69,11 +69,13 @@ public static > Map lr_entries = new HashMap<>(); - int i = 0; + Map l_foundEntries = new HashMap<>(); //Fetch File for (String l_currentLogFile : in_logFiles) { - + int lt_foundEntryCount = 0; + int i = 0; + log.info("Parsing file {}", l_currentLogFile); try (Scanner scanner = new Scanner(new File(l_currentLogFile))) { while (scanner.hasNextLine()) { @@ -84,18 +86,22 @@ public static > Map log.info("Found {} entries in file {}", v, k)); + log.info("RESULT : Found {} unique keys", lr_entries.keySet().size()); return lr_entries; } diff --git a/src/main/java/com/adobe/campaign/tests/logparser/exceptions/IncorrectParseDefinitionException.java b/src/main/java/com/adobe/campaign/tests/logparser/exceptions/IncorrectParseDefinitionException.java index 3ca0890..990ee93 100644 --- a/src/main/java/com/adobe/campaign/tests/logparser/exceptions/IncorrectParseDefinitionException.java +++ b/src/main/java/com/adobe/campaign/tests/logparser/exceptions/IncorrectParseDefinitionException.java @@ -11,14 +11,17 @@ */ package com.adobe.campaign.tests.logparser.exceptions; +/** + * Thrown when there is an incompatibility between stored values and d keys comprising the Entry key + */ public class IncorrectParseDefinitionException extends Exception { + private static final long serialVersionUID = 6462690423575172063L; + /** - * + * The exception thrown when there is a problem in the parse definition + * @param in_message A message to be presented to the user */ - private static final long serialVersionUID = 6462690423575172063L; - - public IncorrectParseDefinitionException(String in_message) { super(in_message); } diff --git a/src/main/java/com/adobe/campaign/tests/logparser/exceptions/ParseDefinitionImportExportException.java b/src/main/java/com/adobe/campaign/tests/logparser/exceptions/ParseDefinitionImportExportException.java index 8b01da0..15fad04 100644 --- a/src/main/java/com/adobe/campaign/tests/logparser/exceptions/ParseDefinitionImportExportException.java +++ b/src/main/java/com/adobe/campaign/tests/logparser/exceptions/ParseDefinitionImportExportException.java @@ -11,7 +11,7 @@ */ package com.adobe.campaign.tests.logparser.exceptions; -public class ParseDefinitionImportExportException extends Exception { +public class ParseDefinitionImportExportException extends RuntimeException { /** * diff --git a/src/test/java/com/adobe/campaign/tests/logparser/AssertionTests.java b/src/test/java/com/adobe/campaign/tests/logparser/AssertionTests.java index 82fef5c..a3c261d 100644 --- a/src/test/java/com/adobe/campaign/tests/logparser/AssertionTests.java +++ b/src/test/java/com/adobe/campaign/tests/logparser/AssertionTests.java @@ -11,36 +11,26 @@ */ package com.adobe.campaign.tests.logparser; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.equalTo; -import static org.hamcrest.Matchers.notNullValue; -import static org.testng.Assert.assertThrows; - -import java.util.Arrays; +import com.adobe.campaign.tests.logparser.exceptions.StringParseException; import org.hamcrest.Matchers; -import org.powermock.api.mockito.PowerMockito; -import org.powermock.core.classloader.annotations.PowerMockIgnore; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.testng.PowerMockTestCase; + +import org.mockito.MockedStatic; +import org.mockito.Mockito; import org.testng.Assert; import org.testng.annotations.Test; -import com.adobe.campaign.tests.logparser.LogData; -import com.adobe.campaign.tests.logparser.GenericEntry; -import com.adobe.campaign.tests.logparser.ParseDefinition; -import com.adobe.campaign.tests.logparser.ParseDefinitionEntry; -import com.adobe.campaign.tests.logparser.exceptions.StringParseException; +import java.util.Arrays; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.*; +import static org.testng.Assert.assertThrows; -@PowerMockIgnore("javax.management.*") -@PrepareForTest(LogDataFactory.class) -public class AssertionTests extends PowerMockTestCase { +public class AssertionTests { /** * Testing that we correctly create a cube - * + *

* Author : gandomi - * */ @Test public void testSimpleAssertion() { @@ -80,22 +70,21 @@ public void testSimpleAssertion() { AssertLogData.assertLogContains("But this should not", l_cubeData, l_parseDefinitionEntryKey.getTitle(), "112"); } catch (AssertionError ae) { - assertThat("The comment should contain the passed string", ae.getMessage(), Matchers.containsString("But this should not")); - assertThat("The comment should contain the name of the parseDefinition title", ae.getMessage(), Matchers.containsString(l_parseDefinitionEntryKey.getTitle())); + assertThat("The comment should contain the passed string", ae.getMessage(), + Matchers.containsString("But this should not")); + assertThat("The comment should contain the name of the parseDefinition title", ae.getMessage(), + Matchers.containsString(l_parseDefinitionEntryKey.getTitle())); } } - - - + /** * Testing a possible usecase. This test is a copy of the test {@link LogDataTest#testLogDataFactory()} - * + *

* Author : gandomi * * @throws InstantiationException * @throws IllegalAccessException * @throws StringParseException - * */ @Test public void testLogDataFactory() @@ -130,52 +119,57 @@ public void testLogDataFactory() assertThat("We should have the key for nms:delivery#PrepareFromId", l_logData.getEntries().containsKey("nms:delivery#PrepareFromId")); - AssertLogData.assertLogContains("We should have gound the entry PrepareFromId", Arrays.asList(apacheLogFile), l_pDefinition, "verb", "PrepareFromId"); + AssertLogData.assertLogContains("We should have gound the entry PrepareFromId", Arrays.asList(apacheLogFile), + l_pDefinition, "verb", "PrepareFromId"); AssertLogData.assertLogContains(Arrays.asList(apacheLogFile), l_pDefinition, "verb", "PrepareFromId"); } - - + /** - * Testing a possible usecase. This test is a copy of the test {@link LogDataTest#testLogDataFactory()}. Testing Exception - * + * Testing a possible usecase. This test is a copy of the test {@link LogDataTest#testLogDataFactory()}. Testing + * Exception + *

* Author : gandomi * * @throws InstantiationException * @throws IllegalAccessException * @throws StringParseException - * */ @Test public void testLogDataFactory_NegativeExceptionThrown() throws InstantiationException, IllegalAccessException, StringParseException { - PowerMockito.mockStatic(LogDataFactory.class); + try (MockedStatic mockedLogFactory = Mockito.mockStatic(LogDataFactory.class)) { - //Create a parse definition - ParseDefinitionEntry l_apiDefinition = new ParseDefinitionEntry(); + //Create a parse definition + ParseDefinitionEntry l_apiDefinition = new ParseDefinitionEntry(); - l_apiDefinition.setTitle("path"); - l_apiDefinition.setStart("HEADER ACTION "); - l_apiDefinition.setEnd("#"); + l_apiDefinition.setTitle("path"); + l_apiDefinition.setStart("HEADER ACTION "); + l_apiDefinition.setEnd("#"); - ParseDefinitionEntry l_verbDefinition = new ParseDefinitionEntry(); + ParseDefinitionEntry l_verbDefinition = new ParseDefinitionEntry(); - l_verbDefinition.setTitle("verb"); - l_verbDefinition.setStart("#"); - l_verbDefinition.setEnd(null); + l_verbDefinition.setTitle("verb"); + l_verbDefinition.setStart("#"); + l_verbDefinition.setEnd(null); - ParseDefinition l_pDefinition = new ParseDefinition("ACC Coverage"); - l_pDefinition.setDefinitionEntries(Arrays.asList(l_apiDefinition, l_verbDefinition)); + ParseDefinition l_pDefinition = new ParseDefinition("ACC Coverage"); + l_pDefinition.setDefinitionEntries(Arrays.asList(l_apiDefinition, l_verbDefinition)); - final String apacheLogFile = "src/test/resources/logTests/acc/acc_integro_jenkins_log_exerpt.txt"; - - PowerMockito.when(LogDataFactory.generateLogData(Arrays.asList(apacheLogFile), l_pDefinition)).thenThrow( new InstantiationException("Duuh")); - - assertThrows(AssertionError.class, () -> AssertLogData.assertLogContains("We should have found the entry PrepareFromId", Arrays.asList(apacheLogFile), l_pDefinition, "verb", "PrepareFromId")); - - assertThrows(AssertionError.class, () -> AssertLogData.assertLogContains(Arrays.asList(apacheLogFile), l_pDefinition, "verb", "PrepareFromId")); + final String apacheLogFile = "src/test/resources/logTests/acc/acc_integro_jenkins_log_exerpt.txt"; + + mockedLogFactory.when(() -> LogDataFactory.generateLogData(Arrays.asList(apacheLogFile), l_pDefinition)) + .thenThrow(new InstantiationException("Duuh")); + + assertThrows(AssertionError.class, + () -> AssertLogData.assertLogContains("We should have found the entry PrepareFromId", + Arrays.asList(apacheLogFile), l_pDefinition, "verb", "PrepareFromId")); + + assertThrows(AssertionError.class, + () -> AssertLogData.assertLogContains(Arrays.asList(apacheLogFile), l_pDefinition, "verb", + "PrepareFromId")); + } } - - + @Test public void testLogDataFactory_NegativeInstatiation() { assertThrows(IllegalStateException.class, () -> new AssertLogData()); diff --git a/src/test/java/com/adobe/campaign/tests/logparser/LogDataTest.java b/src/test/java/com/adobe/campaign/tests/logparser/LogDataTest.java index 9488fcf..134563d 100644 --- a/src/test/java/com/adobe/campaign/tests/logparser/LogDataTest.java +++ b/src/test/java/com/adobe/campaign/tests/logparser/LogDataTest.java @@ -12,17 +12,15 @@ package com.adobe.campaign.tests.logparser; import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.not; -import static org.hamcrest.Matchers.equalTo; -import static org.hamcrest.Matchers.nullValue; -import static org.hamcrest.Matchers.notNullValue; +import static org.hamcrest.Matchers.*; import static org.testng.Assert.assertThrows; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; +import java.io.File; +import java.util.*; +import org.apache.commons.io.FileUtils; +import org.apache.commons.io.filefilter.TrueFileFilter; +import org.apache.commons.io.filefilter.WildcardFileFilter; import org.hamcrest.Matchers; import org.testng.Assert; import org.testng.annotations.Test; @@ -1135,4 +1133,185 @@ public void testIsPresent() { assertThat("We should state that an entry is NOT present", !l_cubeData.isEntryPresent("BAU","999")); } + + + @Test + public void testNestedFileAccess() + throws InstantiationException, IllegalAccessException, StringParseException { + + //Create a parse definition + + ParseDefinitionEntry l_verbDefinition2 = new ParseDefinitionEntry(); + + l_verbDefinition2.setTitle("verb"); + l_verbDefinition2.setStart("\""); + l_verbDefinition2.setEnd(" /"); + + ParseDefinitionEntry l_apiDefinition = new ParseDefinitionEntry(); + + l_apiDefinition.setTitle("path"); + l_apiDefinition.setStart(" /rest/head/"); + l_apiDefinition.setEnd(" "); + + ParseDefinition l_pDefinition = new ParseDefinition("Simple log"); + l_pDefinition.setDefinitionEntries(Arrays.asList(l_verbDefinition2, l_apiDefinition)); + l_pDefinition.defineKeys(Arrays.asList(l_apiDefinition, l_verbDefinition2)); + + final String apacheLogFile = "src/test/resources/nestedDirs/dirA/simpleLog.log"; + + Map l_entries = StringParseFactory + .extractLogEntryMap(Arrays.asList(apacheLogFile), l_pDefinition, GenericEntry.class); + + assertThat(l_entries, is(notNullValue())); + assertThat("We should have entries", l_entries.size(), is(greaterThan(0))); + assertThat("We should have entries", l_entries.size(), is(lessThan(19))); + String l_searchItem1 = "extAccount/destroySharedAudience#GET"; + assertThat("We should have the key for amcDataSource", + l_entries.containsKey(l_searchItem1)); + + GenericEntry l_ge = l_entries.get(l_searchItem1); + assertThat("We should only have one entry for the "+l_searchItem1, l_ge.getFrequence(), Matchers.equalTo(1)); + + LogData l_logData = LogDataFactory.generateLogData(Arrays.asList(apacheLogFile), + l_pDefinition); + + assertThat("We should have the key for amcDataSource", + l_logData.getEntries().containsKey(l_searchItem1)); + + GenericEntry l_logDataItem = l_logData.get(l_searchItem1); + assertThat("We should only have one entry for the "+l_searchItem1, l_logDataItem.getFrequence(), Matchers.equalTo(1)); + + String l_searchItem2 = "extAccount/importSharedAudience#GET"; + + assertThat("We should have the key for amcDataSource", + l_logData.getEntries().containsKey(l_searchItem2)); + + GenericEntry l_logDataItem2 = l_logData.get(l_searchItem2); + assertThat("We should only have one entry for the "+l_searchItem2, l_logDataItem2.getFrequence(), Matchers.equalTo(1)); + + File l_rootDir = new File("src/test/resources/nestedDirs/"); + + assertThat("The directory should exist", l_rootDir.exists()); + assertThat("The directory should be a directory", l_rootDir.isDirectory()); + String l_fileFilter = "simple*.log"; + Iterator l_foundFilesIterator = FileUtils.iterateFiles(l_rootDir, new WildcardFileFilter(l_fileFilter), TrueFileFilter.INSTANCE); + + l_foundFilesIterator.forEachRemaining(f -> System.out.println(f.getAbsolutePath())); + + //Nested search + + LogData l_logData2 = LogDataFactory.generateLogData("src/test/resources/nestedDirs/", l_fileFilter, + l_pDefinition); + + + assertThat("We should have the key for amcDataSource", + l_logData2.getEntries().containsKey(l_searchItem1)); + + GenericEntry l_logDataItem2_1 = l_logData2.get(l_searchItem1); + assertThat("We should only have one entry for the "+l_searchItem1, l_logDataItem2_1.getFrequence(), Matchers.equalTo(1)); + + assertThat("We should have the key for amcDataSource", + l_logData2.getEntries().containsKey(l_searchItem2)); + + GenericEntry l_logDataItem2_2 = l_logData2.get(l_searchItem2); + assertThat("We should only have one entry for the "+l_searchItem2, l_logDataItem2_2.getFrequence(), Matchers.equalTo(2)); + } + + @Test + public void testLogDataFactoryWithJSONFileForParseDefinitionAndSearchFile() + throws InstantiationException, IllegalAccessException, StringParseException, + ParseDefinitionImportExportException { + + String l_rootPath = "src/test/resources/nestedDirs/"; + String l_fileFilter = "simple*.log"; + + final String l_jsonPath = "src/test/resources/parseDefinitions/simpleParseDefinitionLogDataFactory.json"; + + LogData l_logData = LogDataFactory.generateLogData(l_rootPath, l_fileFilter, + l_jsonPath); + + String l_searchItem1 = "extAccount/destroySharedAudience#GET"; + String l_searchItem2 = "extAccount/importSharedAudience#GET"; + + + assertThat("We should have the key for amcDataSource", + l_logData.getEntries().containsKey(l_searchItem1)); + + GenericEntry l_logDataItem2_1 = l_logData.get(l_searchItem1); + assertThat("We should only have one entry for the "+l_searchItem1, l_logDataItem2_1.getFrequence(), equalTo(1)); + + assertThat("We should have the key for amcDataSource", + l_logData.getEntries().containsKey(l_searchItem2)); + + GenericEntry l_logDataItem2_2 = l_logData.get(l_searchItem2); + assertThat("We should only have one entry for the "+l_searchItem2, l_logDataItem2_2.getFrequence(), equalTo(2)); + } + + + /******************** Search file tests ***********************/ + + @Test + public void testFileSearch() { + String l_fileFilter = "simple*.log"; + String l_rootPath = "src/test/resources/nestedDirs/"; + + List l_foundFilePaths = LogDataFactory.findFilePaths(l_rootPath, l_fileFilter); + + assertThat("We should have found 2 files", l_foundFilePaths, + Matchers.containsInAnyOrder(Matchers.endsWith("dirA/simpleLog.log"), + Matchers.endsWith("dirB/simpleLog.log"))); + } + + @Test + public void testFileSearch_negative() { + String l_fileFilter = "simple*.log"; + String l_rootPath = "src/test/resources/nonexistantDir/"; + + Assert.assertThrows(IllegalArgumentException.class, () -> LogDataFactory.findFilePaths(l_rootPath, l_fileFilter)); + } + + @Test + public void testFileSearch_negative2() { + String l_fileFilter = "simple*.log"; + String l_rootPath = "src/test/resources/testng.xml"; + + Assert.assertThrows(IllegalArgumentException.class, () -> LogDataFactory.findFilePaths(l_rootPath, l_fileFilter)); + } + + @Test + public void testFileSearch_negative3() { + String l_fileFilter=null; + String l_rootPath = "src/test/resources/nestedDirs"; + Assert.assertThrows(IllegalArgumentException.class, () -> LogDataFactory.findFilePaths(l_rootPath, l_fileFilter)); + } + + @Test + public void testFileSearch_negative4() { + String l_fileFilter="nonExistantFile.notLog"; + String l_rootPath = "src/test/resources/nestedDirs"; + List l_foundFilePaths = LogDataFactory.findFilePaths(l_rootPath, l_fileFilter); + + assertThat("We should have found no files", l_foundFilePaths.size(), + Matchers.equalTo(0)); + } + + @Test + public void testFileSearch_negative5() { + String l_fileFilter = "simple*.log"; + String l_rootPath = "null"; + + Assert.assertThrows(IllegalArgumentException.class, () -> LogDataFactory.findFilePaths(l_rootPath, l_fileFilter)); + } + + @Test + public void testFileSearch_specific() { + String l_fileFilter = "simpleLog.log"; + String l_rootPath = "src/test/resources/nestedDirs"; + + List l_foundFilePaths = LogDataFactory.findFilePaths(l_rootPath, l_fileFilter); + assertThat("We should have found 2 files", l_foundFilePaths, + Matchers.containsInAnyOrder(Matchers.endsWith("dirA/simpleLog.log"), + Matchers.endsWith("dirB/simpleLog.log"))); + } + } diff --git a/src/test/java/com/adobe/campaign/tests/logparser/ParseDefinitionTests.java b/src/test/java/com/adobe/campaign/tests/logparser/ParseDefinitionTests.java index bed6453..415e2ca 100644 --- a/src/test/java/com/adobe/campaign/tests/logparser/ParseDefinitionTests.java +++ b/src/test/java/com/adobe/campaign/tests/logparser/ParseDefinitionTests.java @@ -265,7 +265,7 @@ public void testImportExportToJSONKeyOrder() throws ParseDefinitionImportExportE @SuppressWarnings("unchecked") @Test public void testImportExportToJSON_negative() throws ParseDefinitionImportExportException, - JsonGenerationException, JsonMappingException, IOException { + JsonGenerationException, IOException { ObjectMapper mapper = Mockito.mock(ObjectMapper.class); Mockito.doThrow(IOException.class).when(mapper).writeValue(ArgumentMatchers.any(File.class), ArgumentMatchers.any(ParseDefinition.class)); diff --git a/src/test/resources/nestedDirs/dirA/irrelevantLog.log b/src/test/resources/nestedDirs/dirA/irrelevantLog.log new file mode 100644 index 0000000..000d957 --- /dev/null +++ b/src/test/resources/nestedDirs/dirA/irrelevantLog.log @@ -0,0 +1,19 @@ +afthost32.qa.campaign.adobe.com:443 10.10.247.85 - - [02/Apr/2020:06:25:43 +0200] "POST /rest/head/session HTTP/1.1" 201 5385 "-" "Apache-HttpClient/4.5.2 (Java/1.8.0_242)" +afthost32.qa.campaign.adobe.com:443 10.10.247.85 - - [02/Apr/2020:06:25:43 +0200] "GET /rest/head/amcDataSource/defaultDataSource HTTP/1.1" 200 6620 "-" "Apache-HttpClient/4.5.2 (Java/1.8.0_242)" +afthost32.qa.campaign.adobe.com:443 10.10.247.85 - - [02/Apr/2020:06:25:43 +0200] "PATCH /rest/head/amcDataSource/@gJNdKh6RoiB5WKazixArykoRENKfh17hklWqAsGRsiLVG5hypg-4oXq-je6fkgkrswnQruvvs4V7eJb8bweiuIXlR2f6vPY1ZfTEsPlCm6RZSGVf HTTP/1.1" 200 5652 "-" "Apache-HttpClient/4.5.2 (Java/1.8.0_242)" +afthost32.qa.campaign.adobe.com:443 10.10.247.85 - - [02/Apr/2020:06:25:43 +0200] "GET /rest/head/extAccount/importSharedAudience HTTP/1.1" 200 9315 "-" "Apache-HttpClient/4.5.2 (Java/1.8.0_242)" +afthost32.qa.campaign.adobe.com:443 10.10.247.85 - - [02/Apr/2020:06:25:43 +0200] "PATCH /rest/head/extAccount/@4OhAmQJGtATA5EloNm7vTP70WRParl0eG99WglIZss4IH6e8d5_0noigY3X3JvXy6_mFbWwfhAFipcZpnEIemAgTOD2inAhIYtYbywt_6oxG9uwu HTTP/1.1" 200 5093 "-" "Apache-HttpClient/4.5.2 (Java/1.8.0_242)" +afthost32.qa.campaign.adobe.com:443 10.10.247.85 - - [02/Apr/2020:06:25:43 +0200] "GET /rest/head/extAccount/exportSharedAudience HTTP/1.1" 200 9310 "-" "Apache-HttpClient/4.5.2 (Java/1.8.0_242)" +afthost32.qa.campaign.adobe.com:443 10.10.247.85 - - [02/Apr/2020:06:25:44 +0200] "PATCH /rest/head/extAccount/@pqwdIKZXFUXCzLQ_Te6LuTWqRr-jYATtWNT9RYn78u8-hTrOr5As2E0NeL58HQbZ6_yj7Wxofo25DojIOEgc-BY6gD6png-bcXzCYBhtPbEA8smn HTTP/1.1" 200 5093 "-" "Apache-HttpClient/4.5.2 (Java/1.8.0_242)" +afthost32.qa.campaign.adobe.com:443 10.10.247.85 - - [02/Apr/2020:06:25:44 +0200] "POST /rest/head/session HTTP/1.1" 201 5385 "-" "Apache-HttpClient/4.5.2 (Java/1.8.0_242)" +afthost32.qa.campaign.adobe.com:443 10.10.247.85 - - [02/Apr/2020:06:25:44 +0200] "GET /rest/head/option/MAC_EndPoint HTTP/1.1" 200 5517 "-" "Apache-HttpClient/4.5.2 (Java/1.8.0_242)" +afthost32.qa.campaign.adobe.com:443 10.10.247.85 - - [02/Apr/2020:06:25:44 +0200] "PATCH /rest/head/option/@09JqNPcQUA-II8OpEkUQ6c4mm4JY22w9lWLWeUzZNZx9TNYmZumEeDl6Bp5yYqPD-ciL5vDIeRFMHvtuz6zNbC0r7Ok HTTP/1.1" 200 5047 "-" "Apache-HttpClient/4.5.2 (Java/1.8.0_242)" +afthost32.qa.campaign.adobe.com:443 10.10.247.85 - - [02/Apr/2020:06:25:44 +0200] "GET /rest/head/option/@09JqNPcQUA-II8OpEkUQ6c4mm4JY22w9lWLWeUzZNZx9TNYmZumEeDl6Bp5yYqPD-ciL5vDIeRFMHvtuz6zNbC0r7Ok HTTP/1.1" 200 5517 "-" "Apache-HttpClient/4.5.2 (Java/1.8.0_242)" +afthost32.qa.campaign.adobe.com:443 10.10.247.85 - - [02/Apr/2020:06:25:44 +0200] "GET /rest/head/emailConfig/ HTTP/1.1" 200 5111 "-" "Apache-HttpClient/4.5.2 (Java/1.8.0_242)" +afthost32.qa.campaign.adobe.com:443 10.10.247.85 - - [02/Apr/2020:06:25:44 +0200] "POST /rest/head/profile/ HTTP/1.1" 201 8001 "-" "Apache-HttpClient/4.5.2 (Java/1.8.0_242)" +afthost32.qa.campaign.adobe.com:443 10.10.247.85 - - [02/Apr/2020:06:25:44 +0200] "GET /rest/head/emailConfig/ HTTP/1.1" 200 5111 "-" "Apache-HttpClient/4.5.2 (Java/1.8.0_242)" +afthost32.qa.campaign.adobe.com:443 10.10.247.85 - - [02/Apr/2020:06:25:47 +0200] "GET /rest/head/emailConfig/ HTTP/1.1" 200 5111 "-" "Apache-HttpClient/4.5.2 (Java/1.8.0_242)" +afthost32.qa.campaign.adobe.com:443 10.10.247.85 - - [02/Apr/2020:06:25:48 +0200] "POST /rest/head/amcDataSource/ HTTP/1.1" 201 6149 "-" "Apache-HttpClient/4.5.2 (Java/1.8.0_242)" +afthost32.qa.campaign.adobe.com:443 10.10.247.85 - - [02/Apr/2020:06:25:48 +0200] "GET /rest/head/amcDataSource/AMCDS745177 HTTP/1.1" 200 6931 "-" "Apache-HttpClient/4.5.2 (Java/1.8.0_242)" +afthost32.qa.campaign.adobe.com:443 10.10.247.61 - - [02/Apr/2020:06:25:48 +0200] "GET /xtk/logon.jssp HTTP/1.1" 302 5435 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36" +afthost32.qa.campaign.adobe.com:443 10.10.247.61 - - [02/Apr/2020:06:26:09 +0200] "GET /xtk/logon.jssp?code=eyJ4NXUiOiJpbXNfbmExLXN0ZzEta2V5LTEuY2VyIiwiYWxnIjoiUlMyNTYifQ.eyJpZCI6IjE1ODU4MDE1Njk1MTZfOTgwMWZmNTgtZDQzYi00ZWJlLThlNGMtZTc3ZTQ2NzA3OTRkX3VlMSIsImNsaWVudF9pZCI6IkNhbXBhaWduUkQxIiwidXNlcl9pZCI6IjEzNTkzMkI3NTlCOTAwMjYwQTQ5NDIxNkBBZG9iZUlEIiwic3RhdGUiOiJ7XCJzZXNzaW9uXCI6XCJodHRwczovL2ltcy1uYTEtc3RnMS5hZG9iZWxvZ2luLmNvbS9pbXMvc2Vzc2lvbi92MS9OMlUwTlRBeE9XVXRZVFF4WmkwME1XUTVMV0UyWWpjdFlUVXdZakk1TmpWaU9UbGhMUzB4TXpVNU16SkNOelU1UWprd01ESTJNRUUwT1RReU1UWkFRV1J2WW1WSlJBXCJ9IiwidHlwZSI6ImF1dGhvcml6YXRpb25fY29kZSIsImFzIjoiaW1zLW5hMS1zdGcxIiwiZmciOiJVS0VTVllTQjZKWkpGNjM3NUVTTkw0SUFGND09PT09PSIsInNpZCI6IjE1ODU4MDE1Njk1MTZfOWMxMGFiMTItYzg2MS00MWUwLTk1YmUtM2YzYzY5OTI5YWYwX3VlMSIsIm90byI6InRydWUiLCJleHBpcmVzX2luIjoiMTgwMDAwMCIsImNyZWF0ZWRfYXQiOiIxNTg1ODAxNTY5NTE2Iiwic2NvcGUiOiJBZG9iZUlELHBlcnNvbixzZXNzaW9uLGFkZGl0aW9uYWxfaW5mby5wcm9qZWN0ZWRQcm9kdWN0Q29udGV4dCxyZWFkX29yZ2FuaXphdGlvbnMsYWRkaXRpb25hbF9pbmZvLnVzZXJfaW1hZ2VfdXJsLHdyaXRlX3BjLG9wZW5pZCx0cmlnZ2VycyxhdWRpZW5jZW1hbmFnZXJfYXBpIn0.a4Ss8sDS5spV4EDxUGPuEQHQ4WCiTlKSn-ak01OrL23RHdYAidOEyN3R86tOZZNtJ6XJM8Va5GkfesW4dDrcGkyKEY9o0lzHgC8wnqURCABZB-7-MZa9j_BTqRoi82cICCZQ7mfpYgGN3elHHvi_2CIlVDjXq0f33d5G-D4C89vHhLLCL_yJguuL3kiR3PRM0T-UaOCk_Q162y6HIbdL2YA9L1ErbA2NLnen-Fnbd3es9W2LiEgLMdXk9Cm7wxaOq54Oa-kpzrmm5lUUDgIjgfiD4EXRINtEnOlun9ZbO7yDhXke2uWqCiAZXmY5YWcocj_SDGkmucPLnw8_Qn7PXQ HTTP/1.1" 302 938 "https://auth-stg1.services.adobe.com/en_US/index.html?callback=https%3A%2F%2Fims-na1-stg1.adobelogin.com%2Fims%2Fadobeid%2FCampaignRD1%2FAdobeID%2Fcode%3Fredirect_uri%3Dhttps%253A%252F%252Fafthost32.qa.campaign.adobe.com%252Fxtk%252Flogon.jssp&client_id=CampaignRD1&scope=AdobeID%2Cperson%2Csession%2Cadditional_info.projectedProductContext%2Cread_organizations%2Cadditional_info.user_image_url%2Cwrite_pc%2Copenid%2Ctriggers%2Caudiencemanager_api&denied_callback=https%3A%2F%2Fims-na1-stg1.adobelogin.com%2Fims%2Fdenied%2FCampaignRD1%3Fredirect_uri%3Dhttps%253A%252F%252Fafthost32.qa.campaign.adobe.com%252Fxtk%252Flogon.jssp%26response_type%3Dcode&relay=f1cff3df-18ac-44a2-bc5f-b89331c11084&locale=en_US&flow_type=code&idp_flow_type=login" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36" diff --git a/src/test/resources/nestedDirs/dirA/simpleLog.log b/src/test/resources/nestedDirs/dirA/simpleLog.log new file mode 100644 index 0000000..df9a076 --- /dev/null +++ b/src/test/resources/nestedDirs/dirA/simpleLog.log @@ -0,0 +1,21 @@ +afthost32.qa.campaign.adobe.com:443 10.10.247.85 - - [02/Apr/2020:06:25:43 +0200] "POST /rest/head/session HTTP/1.1" 201 5385 "-" "Apache-HttpClient/4.5.2 (Java/1.8.0_242)" +afthost32.qa.campaign.adobe.com:443 10.10.247.85 - - [02/Apr/2020:06:25:43 +0200] "GET /rest/head/amcDataSource/defaultDataSource HTTP/1.1" 200 6620 "-" "Apache-HttpClient/4.5.2 (Java/1.8.0_242)" +afthost32.qa.campaign.adobe.com:443 10.10.247.85 - - [02/Apr/2020:06:25:43 +0200] "PATCH /rest/head/amcDataSource/@gJNdKh6RoiB5WKazixArykoRENKfh17hklWqAsGRsiLVG5hypg-4oXq-je6fkgkrswnQruvvs4V7eJb8bweiuIXlR2f6vPY1ZfTEsPlCm6RZSGVf HTTP/1.1" 200 5652 "-" "Apache-HttpClient/4.5.2 (Java/1.8.0_242)" +afthost32.qa.campaign.adobe.com:443 10.10.247.85 - - [02/Apr/2020:06:25:43 +0200] "GET /rest/head/extAccount/importSharedAudience HTTP/1.1" 200 9315 "-" "Apache-HttpClient/4.5.2 (Java/1.8.0_242)" +afthost32.qa.campaign.adobe.com:443 10.10.247.85 - - [02/Apr/2020:06:25:43 +0200] "PATCH /rest/head/extAccount/@4OhAmQJGtATA5EloNm7vTP70WRParl0eG99WglIZss4IH6e8d5_0noigY3X3JvXy6_mFbWwfhAFipcZpnEIemAgTOD2inAhIYtYbywt_6oxG9uwu HTTP/1.1" 200 5093 "-" "Apache-HttpClient/4.5.2 (Java/1.8.0_242)" +afthost32.qa.campaign.adobe.com:443 10.10.247.85 - - [02/Apr/2020:06:25:43 +0200] "GET /rest/head/extAccount/exportSharedAudience HTTP/1.1" 200 9310 "-" "Apache-HttpClient/4.5.2 (Java/1.8.0_242)" +afthost32.qa.campaign.adobe.com:443 10.10.247.85 - - [02/Apr/2020:06:25:43 +0200] "GET /rest/head/extAccount/destroySharedAudience HTTP/1.1" 200 9310 "-" "Apache-HttpClient/4.5.2 (Java/1.8.0_242)" +afthost32.qa.campaign.adobe.com:443 10.10.247.85 - - [02/Apr/2020:06:25:44 +0200] "PATCH /rest/head/extAccount/@pqwdIKZXFUXCzLQ_Te6LuTWqRr-jYATtWNT9RYn78u8-hTrOr5As2E0NeL58HQbZ6_yj7Wxofo25DojIOEgc-BY6gD6png-bcXzCYBhtPbEA8smn HTTP/1.1" 200 5093 "-" "Apache-HttpClient/4.5.2 (Java/1.8.0_242)" +afthost32.qa.campaign.adobe.com:443 10.10.247.85 - - [02/Apr/2020:06:25:44 +0200] "POST /rest/head/session HTTP/1.1" 201 5385 "-" "Apache-HttpClient/4.5.2 (Java/1.8.0_242)" +afthost32.qa.campaign.adobe.com:443 10.10.247.85 - - [02/Apr/2020:06:25:44 +0200] "GET /rest/head/option/MAC_EndPoint HTTP/1.1" 200 5517 "-" "Apache-HttpClient/4.5.2 (Java/1.8.0_242)" +afthost32.qa.campaign.adobe.com:443 10.10.247.85 - - [02/Apr/2020:06:25:44 +0200] "PATCH /rest/head/option/@09JqNPcQUA-II8OpEkUQ6c4mm4JY22w9lWLWeUzZNZx9TNYmZumEeDl6Bp5yYqPD-ciL5vDIeRFMHvtuz6zNbC0r7Ok HTTP/1.1" 200 5047 "-" "Apache-HttpClient/4.5.2 (Java/1.8.0_242)" +afthost32.qa.campaign.adobe.com:443 10.10.247.85 - - [02/Apr/2020:06:25:44 +0200] "GET /rest/head/option/@09JqNPcQUA-II8OpEkUQ6c4mm4JY22w9lWLWeUzZNZx9TNYmZumEeDl6Bp5yYqPD-ciL5vDIeRFMHvtuz6zNbC0r7Ok HTTP/1.1" 200 5517 "-" "Apache-HttpClient/4.5.2 (Java/1.8.0_242)" +afthost32.qa.campaign.adobe.com:443 10.10.247.85 - - [02/Apr/2020:06:25:44 +0200] "GET /rest/head/emailConfig/ HTTP/1.1" 200 5111 "-" "Apache-HttpClient/4.5.2 (Java/1.8.0_242)" +afthost32.qa.campaign.adobe.com:443 10.10.247.85 - - [02/Apr/2020:06:25:44 +0200] "POST /rest/head/profile/ HTTP/1.1" 201 8001 "-" "Apache-HttpClient/4.5.2 (Java/1.8.0_242)" +afthost32.qa.campaign.adobe.com:443 10.10.247.85 - - [02/Apr/2020:06:25:44 +0200] "GET /rest/head/emailConfig/ HTTP/1.1" 200 5111 "-" "Apache-HttpClient/4.5.2 (Java/1.8.0_242)" +afthost32.qa.campaign.adobe.com:443 10.10.247.85 - - [02/Apr/2020:06:25:47 +0200] "GET /rest/head/emailConfig/ HTTP/1.1" 200 5111 "-" "Apache-HttpClient/4.5.2 (Java/1.8.0_242)" +afthost32.qa.campaign.adobe.com:443 10.10.247.85 - - [02/Apr/2020:06:25:48 +0200] "POST /rest/head/amcDataSource/ HTTP/1.1" 201 6149 "-" "Apache-HttpClient/4.5.2 (Java/1.8.0_242)" +afthost32.qa.campaign.adobe.com:443 10.10.247.85 - - [02/Apr/2020:06:25:48 +0200] "GET /rest/head/amcDataSource/AMCDS745177 HTTP/1.1" 200 6931 "-" "Apache-HttpClient/4.5.2 (Java/1.8.0_242)" +afthost32.qa.campaign.adobe.com:443 10.10.247.61 - - [02/Apr/2020:06:25:48 +0200] "GET /xtk/logon.jssp HTTP/1.1" 302 5435 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36" +afthost32.qa.campaign.adobe.com:443 10.10.247.61 - - [02/Apr/2020:06:26:09 +0200] "GET /xtk/logon.jssp?code=eyJ4NXUiOiJpbXNfbmExLXN0ZzEta2V5LTEuY2VyIiwiYWxnIjoiUlMyNTYifQ.eyJpZCI6IjE1ODU4MDE1Njk1MTZfOTgwMWZmNTgtZDQzYi00ZWJlLThlNGMtZTc3ZTQ2NzA3OTRkX3VlMSIsImNsaWVudF9pZCI6IkNhbXBhaWduUkQxIiwidXNlcl9pZCI6IjEzNTkzMkI3NTlCOTAwMjYwQTQ5NDIxNkBBZG9iZUlEIiwic3RhdGUiOiJ7XCJzZXNzaW9uXCI6XCJodHRwczovL2ltcy1uYTEtc3RnMS5hZG9iZWxvZ2luLmNvbS9pbXMvc2Vzc2lvbi92MS9OMlUwTlRBeE9XVXRZVFF4WmkwME1XUTVMV0UyWWpjdFlUVXdZakk1TmpWaU9UbGhMUzB4TXpVNU16SkNOelU1UWprd01ESTJNRUUwT1RReU1UWkFRV1J2WW1WSlJBXCJ9IiwidHlwZSI6ImF1dGhvcml6YXRpb25fY29kZSIsImFzIjoiaW1zLW5hMS1zdGcxIiwiZmciOiJVS0VTVllTQjZKWkpGNjM3NUVTTkw0SUFGND09PT09PSIsInNpZCI6IjE1ODU4MDE1Njk1MTZfOWMxMGFiMTItYzg2MS00MWUwLTk1YmUtM2YzYzY5OTI5YWYwX3VlMSIsIm90byI6InRydWUiLCJleHBpcmVzX2luIjoiMTgwMDAwMCIsImNyZWF0ZWRfYXQiOiIxNTg1ODAxNTY5NTE2Iiwic2NvcGUiOiJBZG9iZUlELHBlcnNvbixzZXNzaW9uLGFkZGl0aW9uYWxfaW5mby5wcm9qZWN0ZWRQcm9kdWN0Q29udGV4dCxyZWFkX29yZ2FuaXphdGlvbnMsYWRkaXRpb25hbF9pbmZvLnVzZXJfaW1hZ2VfdXJsLHdyaXRlX3BjLG9wZW5pZCx0cmlnZ2VycyxhdWRpZW5jZW1hbmFnZXJfYXBpIn0.a4Ss8sDS5spV4EDxUGPuEQHQ4WCiTlKSn-ak01OrL23RHdYAidOEyN3R86tOZZNtJ6XJM8Va5GkfesW4dDrcGkyKEY9o0lzHgC8wnqURCABZB-7-MZa9j_BTqRoi82cICCZQ7mfpYgGN3elHHvi_2CIlVDjXq0f33d5G-D4C89vHhLLCL_yJguuL3kiR3PRM0T-UaOCk_Q162y6HIbdL2YA9L1ErbA2NLnen-Fnbd3es9W2LiEgLMdXk9Cm7wxaOq54Oa-kpzrmm5lUUDgIjgfiD4EXRINtEnOlun9ZbO7yDhXke2uWqCiAZXmY5YWcocj_SDGkmucPLnw8_Qn7PXQ HTTP/1.1" 302 938 "https://auth-stg1.services.adobe.com/en_US/index.html?callback=https%3A%2F%2Fims-na1-stg1.adobelogin.com%2Fims%2Fadobeid%2FCampaignRD1%2FAdobeID%2Fcode%3Fredirect_uri%3Dhttps%253A%252F%252Fafthost32.qa.campaign.adobe.com%252Fxtk%252Flogon.jssp&client_id=CampaignRD1&scope=AdobeID%2Cperson%2Csession%2Cadditional_info.projectedProductContext%2Cread_organizations%2Cadditional_info.user_image_url%2Cwrite_pc%2Copenid%2Ctriggers%2Caudiencemanager_api&denied_callback=https%3A%2F%2Fims-na1-stg1.adobelogin.com%2Fims%2Fdenied%2FCampaignRD1%3Fredirect_uri%3Dhttps%253A%252F%252Fafthost32.qa.campaign.adobe.com%252Fxtk%252Flogon.jssp%26response_type%3Dcode&relay=f1cff3df-18ac-44a2-bc5f-b89331c11084&locale=en_US&flow_type=code&idp_flow_type=login" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36" + diff --git a/src/test/resources/nestedDirs/dirB/simpleLog.log b/src/test/resources/nestedDirs/dirB/simpleLog.log new file mode 100644 index 0000000..000d957 --- /dev/null +++ b/src/test/resources/nestedDirs/dirB/simpleLog.log @@ -0,0 +1,19 @@ +afthost32.qa.campaign.adobe.com:443 10.10.247.85 - - [02/Apr/2020:06:25:43 +0200] "POST /rest/head/session HTTP/1.1" 201 5385 "-" "Apache-HttpClient/4.5.2 (Java/1.8.0_242)" +afthost32.qa.campaign.adobe.com:443 10.10.247.85 - - [02/Apr/2020:06:25:43 +0200] "GET /rest/head/amcDataSource/defaultDataSource HTTP/1.1" 200 6620 "-" "Apache-HttpClient/4.5.2 (Java/1.8.0_242)" +afthost32.qa.campaign.adobe.com:443 10.10.247.85 - - [02/Apr/2020:06:25:43 +0200] "PATCH /rest/head/amcDataSource/@gJNdKh6RoiB5WKazixArykoRENKfh17hklWqAsGRsiLVG5hypg-4oXq-je6fkgkrswnQruvvs4V7eJb8bweiuIXlR2f6vPY1ZfTEsPlCm6RZSGVf HTTP/1.1" 200 5652 "-" "Apache-HttpClient/4.5.2 (Java/1.8.0_242)" +afthost32.qa.campaign.adobe.com:443 10.10.247.85 - - [02/Apr/2020:06:25:43 +0200] "GET /rest/head/extAccount/importSharedAudience HTTP/1.1" 200 9315 "-" "Apache-HttpClient/4.5.2 (Java/1.8.0_242)" +afthost32.qa.campaign.adobe.com:443 10.10.247.85 - - [02/Apr/2020:06:25:43 +0200] "PATCH /rest/head/extAccount/@4OhAmQJGtATA5EloNm7vTP70WRParl0eG99WglIZss4IH6e8d5_0noigY3X3JvXy6_mFbWwfhAFipcZpnEIemAgTOD2inAhIYtYbywt_6oxG9uwu HTTP/1.1" 200 5093 "-" "Apache-HttpClient/4.5.2 (Java/1.8.0_242)" +afthost32.qa.campaign.adobe.com:443 10.10.247.85 - - [02/Apr/2020:06:25:43 +0200] "GET /rest/head/extAccount/exportSharedAudience HTTP/1.1" 200 9310 "-" "Apache-HttpClient/4.5.2 (Java/1.8.0_242)" +afthost32.qa.campaign.adobe.com:443 10.10.247.85 - - [02/Apr/2020:06:25:44 +0200] "PATCH /rest/head/extAccount/@pqwdIKZXFUXCzLQ_Te6LuTWqRr-jYATtWNT9RYn78u8-hTrOr5As2E0NeL58HQbZ6_yj7Wxofo25DojIOEgc-BY6gD6png-bcXzCYBhtPbEA8smn HTTP/1.1" 200 5093 "-" "Apache-HttpClient/4.5.2 (Java/1.8.0_242)" +afthost32.qa.campaign.adobe.com:443 10.10.247.85 - - [02/Apr/2020:06:25:44 +0200] "POST /rest/head/session HTTP/1.1" 201 5385 "-" "Apache-HttpClient/4.5.2 (Java/1.8.0_242)" +afthost32.qa.campaign.adobe.com:443 10.10.247.85 - - [02/Apr/2020:06:25:44 +0200] "GET /rest/head/option/MAC_EndPoint HTTP/1.1" 200 5517 "-" "Apache-HttpClient/4.5.2 (Java/1.8.0_242)" +afthost32.qa.campaign.adobe.com:443 10.10.247.85 - - [02/Apr/2020:06:25:44 +0200] "PATCH /rest/head/option/@09JqNPcQUA-II8OpEkUQ6c4mm4JY22w9lWLWeUzZNZx9TNYmZumEeDl6Bp5yYqPD-ciL5vDIeRFMHvtuz6zNbC0r7Ok HTTP/1.1" 200 5047 "-" "Apache-HttpClient/4.5.2 (Java/1.8.0_242)" +afthost32.qa.campaign.adobe.com:443 10.10.247.85 - - [02/Apr/2020:06:25:44 +0200] "GET /rest/head/option/@09JqNPcQUA-II8OpEkUQ6c4mm4JY22w9lWLWeUzZNZx9TNYmZumEeDl6Bp5yYqPD-ciL5vDIeRFMHvtuz6zNbC0r7Ok HTTP/1.1" 200 5517 "-" "Apache-HttpClient/4.5.2 (Java/1.8.0_242)" +afthost32.qa.campaign.adobe.com:443 10.10.247.85 - - [02/Apr/2020:06:25:44 +0200] "GET /rest/head/emailConfig/ HTTP/1.1" 200 5111 "-" "Apache-HttpClient/4.5.2 (Java/1.8.0_242)" +afthost32.qa.campaign.adobe.com:443 10.10.247.85 - - [02/Apr/2020:06:25:44 +0200] "POST /rest/head/profile/ HTTP/1.1" 201 8001 "-" "Apache-HttpClient/4.5.2 (Java/1.8.0_242)" +afthost32.qa.campaign.adobe.com:443 10.10.247.85 - - [02/Apr/2020:06:25:44 +0200] "GET /rest/head/emailConfig/ HTTP/1.1" 200 5111 "-" "Apache-HttpClient/4.5.2 (Java/1.8.0_242)" +afthost32.qa.campaign.adobe.com:443 10.10.247.85 - - [02/Apr/2020:06:25:47 +0200] "GET /rest/head/emailConfig/ HTTP/1.1" 200 5111 "-" "Apache-HttpClient/4.5.2 (Java/1.8.0_242)" +afthost32.qa.campaign.adobe.com:443 10.10.247.85 - - [02/Apr/2020:06:25:48 +0200] "POST /rest/head/amcDataSource/ HTTP/1.1" 201 6149 "-" "Apache-HttpClient/4.5.2 (Java/1.8.0_242)" +afthost32.qa.campaign.adobe.com:443 10.10.247.85 - - [02/Apr/2020:06:25:48 +0200] "GET /rest/head/amcDataSource/AMCDS745177 HTTP/1.1" 200 6931 "-" "Apache-HttpClient/4.5.2 (Java/1.8.0_242)" +afthost32.qa.campaign.adobe.com:443 10.10.247.61 - - [02/Apr/2020:06:25:48 +0200] "GET /xtk/logon.jssp HTTP/1.1" 302 5435 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36" +afthost32.qa.campaign.adobe.com:443 10.10.247.61 - - [02/Apr/2020:06:26:09 +0200] "GET /xtk/logon.jssp?code=eyJ4NXUiOiJpbXNfbmExLXN0ZzEta2V5LTEuY2VyIiwiYWxnIjoiUlMyNTYifQ.eyJpZCI6IjE1ODU4MDE1Njk1MTZfOTgwMWZmNTgtZDQzYi00ZWJlLThlNGMtZTc3ZTQ2NzA3OTRkX3VlMSIsImNsaWVudF9pZCI6IkNhbXBhaWduUkQxIiwidXNlcl9pZCI6IjEzNTkzMkI3NTlCOTAwMjYwQTQ5NDIxNkBBZG9iZUlEIiwic3RhdGUiOiJ7XCJzZXNzaW9uXCI6XCJodHRwczovL2ltcy1uYTEtc3RnMS5hZG9iZWxvZ2luLmNvbS9pbXMvc2Vzc2lvbi92MS9OMlUwTlRBeE9XVXRZVFF4WmkwME1XUTVMV0UyWWpjdFlUVXdZakk1TmpWaU9UbGhMUzB4TXpVNU16SkNOelU1UWprd01ESTJNRUUwT1RReU1UWkFRV1J2WW1WSlJBXCJ9IiwidHlwZSI6ImF1dGhvcml6YXRpb25fY29kZSIsImFzIjoiaW1zLW5hMS1zdGcxIiwiZmciOiJVS0VTVllTQjZKWkpGNjM3NUVTTkw0SUFGND09PT09PSIsInNpZCI6IjE1ODU4MDE1Njk1MTZfOWMxMGFiMTItYzg2MS00MWUwLTk1YmUtM2YzYzY5OTI5YWYwX3VlMSIsIm90byI6InRydWUiLCJleHBpcmVzX2luIjoiMTgwMDAwMCIsImNyZWF0ZWRfYXQiOiIxNTg1ODAxNTY5NTE2Iiwic2NvcGUiOiJBZG9iZUlELHBlcnNvbixzZXNzaW9uLGFkZGl0aW9uYWxfaW5mby5wcm9qZWN0ZWRQcm9kdWN0Q29udGV4dCxyZWFkX29yZ2FuaXphdGlvbnMsYWRkaXRpb25hbF9pbmZvLnVzZXJfaW1hZ2VfdXJsLHdyaXRlX3BjLG9wZW5pZCx0cmlnZ2VycyxhdWRpZW5jZW1hbmFnZXJfYXBpIn0.a4Ss8sDS5spV4EDxUGPuEQHQ4WCiTlKSn-ak01OrL23RHdYAidOEyN3R86tOZZNtJ6XJM8Va5GkfesW4dDrcGkyKEY9o0lzHgC8wnqURCABZB-7-MZa9j_BTqRoi82cICCZQ7mfpYgGN3elHHvi_2CIlVDjXq0f33d5G-D4C89vHhLLCL_yJguuL3kiR3PRM0T-UaOCk_Q162y6HIbdL2YA9L1ErbA2NLnen-Fnbd3es9W2LiEgLMdXk9Cm7wxaOq54Oa-kpzrmm5lUUDgIjgfiD4EXRINtEnOlun9ZbO7yDhXke2uWqCiAZXmY5YWcocj_SDGkmucPLnw8_Qn7PXQ HTTP/1.1" 302 938 "https://auth-stg1.services.adobe.com/en_US/index.html?callback=https%3A%2F%2Fims-na1-stg1.adobelogin.com%2Fims%2Fadobeid%2FCampaignRD1%2FAdobeID%2Fcode%3Fredirect_uri%3Dhttps%253A%252F%252Fafthost32.qa.campaign.adobe.com%252Fxtk%252Flogon.jssp&client_id=CampaignRD1&scope=AdobeID%2Cperson%2Csession%2Cadditional_info.projectedProductContext%2Cread_organizations%2Cadditional_info.user_image_url%2Cwrite_pc%2Copenid%2Ctriggers%2Caudiencemanager_api&denied_callback=https%3A%2F%2Fims-na1-stg1.adobelogin.com%2Fims%2Fdenied%2FCampaignRD1%3Fredirect_uri%3Dhttps%253A%252F%252Fafthost32.qa.campaign.adobe.com%252Fxtk%252Flogon.jssp%26response_type%3Dcode&relay=f1cff3df-18ac-44a2-bc5f-b89331c11084&locale=en_US&flow_type=code&idp_flow_type=login" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36" diff --git a/src/test/resources/parseDefinitions/simpleParseDefinitionLogDataFactory.json b/src/test/resources/parseDefinitions/simpleParseDefinitionLogDataFactory.json new file mode 100644 index 0000000..01c423e --- /dev/null +++ b/src/test/resources/parseDefinitions/simpleParseDefinitionLogDataFactory.json @@ -0,0 +1 @@ +{"title":"Simple log","definitionEntries":[{"title":"verb","start":"\"","end":" /","caseSensitive":true,"trimQuotes":false,"toPreserve":true},{"title":"path","start":" /rest/head/","end":" ","caseSensitive":true,"trimQuotes":false,"toPreserve":true}],"keyPadding":"#","keyOrder":["path","verb"]} \ No newline at end of file