Skip to content

Commit

Permalink
Next batch (#125)
Browse files Browse the repository at this point in the history
* Fixed #123 Adding the size of the files being parsed, and total size in bytes being parsed.
* Fixed #119 : We have now fixed the deprecated newInstance() method. Also we have encpsulated exceptions into a try catch
* Fixed #119 : We have now fixed the deprecated newInstance() method. Also we have encpsulated exceptions into a try catch
* Fixed issue with hard-coded Generic entry in LogData
* First fix for issues #117 & #116 we can now also include the files and their paths in the results
* Fixed #117 tested with JSON
* Fixing javadoc
* Raising coverage, and added an SDK example for the tests
* Clarified some of the exceptions
* Adding missing log file
  • Loading branch information
baubakg authored Jun 15, 2024
1 parent 1965149 commit 9940f80
Show file tree
Hide file tree
Showing 22 changed files with 1,003 additions and 301 deletions.
12 changes: 12 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,18 @@ process that must reach lazy consensus (silence is approval) before invitations
are issued. If you feel you are qualified and want to get more deeply involved,
feel free to reach out to existing committers to have a conversation about that.

### Commit Rules
All code pushed onto the repository must pass te following quality gates:
* Passed Unit Tests
* Code Coverage may not go down
* The sonar quality gate should remain green
* All new files need to ontain the license header. This can be acheived by running `mvn license:format`.

These validations are done automatically through github actions.

### Java Version
We have now moved to java 11, therefor the code needs to be able to compile in that version.

## Security Issues

Security issues shouldn't be reported on this issue tracker. Instead, [file an issue to our security experts](https://helpx.adobe.com/security/alertus.html).
15 changes: 10 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ Each Parse Definition consists of :
- A set of entries
- A Padding allowing us to create a legible key
- A key Order which is used for defining the Key
- If you want the result to include the log file name and path

### Defining an entry
Each entry for a Parse Definition allows us to define:
Expand Down Expand Up @@ -192,11 +193,11 @@ LogData<MyImplementationOfStdLogEntry> l_myGroupedData = logData.groupBy(Arrays.

In this case we get :

Definition 1 | Definition 4 | Frequence
------------ | ------------ | ------------
12 | AA | 1
112 | AAA | 1
120 | AA | 1
| Definition 1 | Definition 4 | Frequence |
|--------------|--------------|-----------|
| 12 | AA | 1 |
| 112 | AAA | 1 |
| 120 | AA | 1 |


#### Chaining GroupBy
Expand Down Expand Up @@ -235,7 +236,11 @@ We now have the possibility to export the log data results into a CSV file. The

### 1.11.0 (next version)
- [#110](https://github.com/adobe/log-parser/issues/110) Moved to Java 11
- [#117](https://github.com/adobe/log-parser/issues/117) You can now include the file name in the result of the analysis.
- [#123](https://github.com/adobe/log-parser/issues/123) We now log the total number and size of the parsed files.
- [#112](https://github.com/adobe/log-parser/issues/112) Updating License Headers
- [#119](https://github.com/adobe/log-parser/issues/119) Cleanup of deprecated methods, and the consequences thereof.


### 1.0.10
- Moved main code and tests to the package "core"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ 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) {
} catch (StringParseException e) {
throw new AssertionError("Caught unexpected exception", e);
}

Expand Down Expand Up @@ -174,7 +174,7 @@ public static void assertLogContains(String in_comment, List<String> in_filePath

assertLogContains(in_comment, LogDataFactory.generateLogData(in_filePathList, in_parseDefinition),
in_parseDefinitionEntryTitle, in_expectedValue);
} catch (InstantiationException | IllegalAccessException | StringParseException e) {
} catch (StringParseException e) {

//e.printStackTrace();
throw new AssertionError("Caught unexpected exception", e);
Expand Down
48 changes: 14 additions & 34 deletions src/main/java/com/adobe/campaign/tests/logparser/core/LogData.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.util.*;

import com.adobe.campaign.tests.logparser.exceptions.LogDataExportToFileException;
Expand Down Expand Up @@ -203,18 +204,11 @@ public boolean equals(Object obj) {
* @return a new LogData Object containing the groupBy values
* @throws IncorrectParseDefinitionException
* If the key is not in the ParseDefinitions of the Log data entry
* @throws IllegalAccessException
* if the class or its nullary constructor is not accessible.
* @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.
*
*/
public <U extends StdLogEntry> LogData<U> groupBy(String in_parseDefinitionEntryKey,
Class<U> in_transformationClass)
throws IncorrectParseDefinitionException, InstantiationException, IllegalAccessException {
throws IncorrectParseDefinitionException {

return groupBy(Arrays.asList(in_parseDefinitionEntryKey), in_transformationClass);
}
Expand All @@ -236,19 +230,12 @@ public <U extends StdLogEntry> LogData<U> groupBy(String in_parseDefinitionEntry
* @return a new LogData Object containing the groupBy values
* @throws IncorrectParseDefinitionException
* If the key is not in the ParseDefinitions of the Log data entry
* @throws IllegalAccessException
* if the class or its nullary constructor is not accessible.
* @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.
*
*/
public <U extends StdLogEntry> LogData<U> groupBy(List<String> in_parseDefinitionEntryKeyList,
Class<U> in_transformationClass)
throws IncorrectParseDefinitionException, InstantiationException, IllegalAccessException {
LogData<U> lr_cubeData = new LogData<U>();
throws IncorrectParseDefinitionException {
LogData<U> lr_cubeData = new LogData<>();

//Creating new Definition
ParseDefinition l_cubeDefinition = new ParseDefinition(
Expand All @@ -261,7 +248,12 @@ public <U extends StdLogEntry> LogData<U> groupBy(List<String> in_parseDefinitio
//Filling STDLogData
for (T lt_entry : getEntries().values()) {
Map<String, String> lt_cubeEntryValues = new HashMap<>();
U lt_cubeEntry = in_transformationClass.newInstance();
U lt_cubeEntry = null;
try {
lt_cubeEntry = in_transformationClass.getDeclaredConstructor().newInstance();
} catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
throw new RuntimeException(e);
}
lt_cubeEntry.setParseDefinition(l_cubeDefinition);

for (String lt_parseDefinitionEntryKey : in_parseDefinitionEntryKeyList) {
Expand Down Expand Up @@ -295,17 +287,10 @@ public <U extends StdLogEntry> LogData<U> groupBy(List<String> in_parseDefinitio
* @return a new LogData Object containing the groupBy values
* @throws IncorrectParseDefinitionException
* If the key is not in the ParseDefinitions of the Log data entry
* @throws IllegalAccessException
* if the class or its nullary constructor is not accessible.
* @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.
*
*/
public LogData<GenericEntry> groupBy(List<String> in_parseDefinitionEntryKeyList)
throws InstantiationException, IllegalAccessException, IncorrectParseDefinitionException {
throws IncorrectParseDefinitionException {
return groupBy(in_parseDefinitionEntryKeyList, GenericEntry.class);
}

Expand All @@ -321,17 +306,10 @@ public LogData<GenericEntry> groupBy(List<String> in_parseDefinitionEntryKeyList
* @return a new LogData Object containing the groupBy values
* @throws IncorrectParseDefinitionException
* If the key is not in the ParseDefinitions of the Log data entry
* @throws IllegalAccessException
* if the class or its nullary constructor is not accessible.
* @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.
*
*/
public LogData<GenericEntry> groupBy(String in_parseDefinitionEntryKey)
throws InstantiationException, IllegalAccessException, IncorrectParseDefinitionException {
throws IncorrectParseDefinitionException {
return groupBy(in_parseDefinitionEntryKey, GenericEntry.class);
}

Expand Down Expand Up @@ -434,6 +412,7 @@ public boolean isEntryPresent(Map<String, Object> in_searchKeyValues) {
* Definition as the name
*
* @return a CSV file containing the LogData
* @throws LogDataExportToFileException If the file could not be exported
*/
public File exportLogDataToCSV() throws LogDataExportToFileException {
Optional<T> l_firstEntry = this.getEntries().values().stream().findFirst();
Expand All @@ -455,6 +434,7 @@ public File exportLogDataToCSV() throws LogDataExportToFileException {
* @param in_headerSet A set of headers to be used as keys for exporting
* @param in_csvFileName The file name to export
* @return a CSV file containing the LogData
* @throws LogDataExportToFileException If the file could not be exported
*/
public File exportLogDataToCSV(Set<String> in_headerSet, String in_csvFileName)
throws LogDataExportToFileException {
Expand Down
Loading

0 comments on commit 9940f80

Please sign in to comment.