Skip to content

148 groupby is parsedefinition driven only it needs to also work with sdk #150

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,7 @@ We now have the possibility to export the log data results into a CSV file. The
- [#55](https://github.com/adobe/log-parser/issues/55) We can now export the log parsing results into a CSV file.
- [#102](https://github.com/adobe/log-parser/issues/102) Corrected bug where Log parser could silently stop with no error when confronted with CharSet incompatibilities.
- [#120](https://github.com/adobe/log-parser/issues/120) Corrected the export system as it did not work well with SDK defined entries.
- [#148](https://github.com/adobe/log-parser/issues/148) The LogData#groupBy method did not work well when it is based on an SDK. We now look at the headers and values of the SDK. Also the target for a groupBy will have to be a GenricEntry as cannot guarantee that the target class can support a groupBy.
- Removed ambiguities in the methods for StdLogEntry. For example "fetchValueMap" is no longer abstract, but it can be overriden.
### 1.0.8.2
- Building with java8.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ 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
*/
public <U extends StdLogEntry> LogData<U> groupBy(String in_parseDefinitionEntryKey,
<U extends StdLogEntry> LogData<U> groupBy(String in_parseDefinitionEntryKey,
Class<U> in_transformationClass)
throws IncorrectParseDefinitionException {

Expand All @@ -215,7 +215,7 @@ 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
*/
public <U extends StdLogEntry> LogData<U> groupBy(List<String> in_parseDefinitionEntryKeyList,
<U extends StdLogEntry> LogData<U> groupBy(List<String> in_parseDefinitionEntryKeyList,
Class<U> in_transformationClass)
throws IncorrectParseDefinitionException {
LogData<U> lr_cubeData = new LogData<>();
Expand All @@ -240,7 +240,8 @@ public <U extends StdLogEntry> LogData<U> groupBy(List<String> in_parseDefinitio
lt_cubeEntry.setParseDefinition(l_cubeDefinition);

for (String lt_parseDefinitionEntryKey : in_parseDefinitionEntryKeyList) {
if (!lt_entry.getParseDefinition().fetchHeaders().contains(lt_parseDefinitionEntryKey)) {
//Merge with original headers
if (!lt_entry.fetchHeaders().contains(lt_parseDefinitionEntryKey)) {
throw new IncorrectParseDefinitionException("The given header name "
+ lt_parseDefinitionEntryKey + " was not among the stored data");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ public void put(String in_dataTitle, String in_value) {
}

public Object get(String in_dataTitle) {
return this.getValuesMap().get(in_dataTitle);
return this.fetchValueMap().get(in_dataTitle);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -419,9 +419,9 @@ public void testgroupBy()
l_cubeData.addEntry(l_inputData3);

assertThrows(IncorrectParseDefinitionException.class,
() -> l_cubeData.groupBy("KAU", GenericEntry.class));
() -> l_cubeData.groupBy("KAU"));

LogData<GenericEntry> l_myCube = l_cubeData.groupBy("BAU", GenericEntry.class);
LogData<GenericEntry> l_myCube = l_cubeData.groupBy("BAU");

assertThat(l_myCube.getEntries().values().iterator().next().getParseDefinition()
.getDefinitionEntries().size(), is(equalTo(1)));
Expand Down Expand Up @@ -531,7 +531,7 @@ public void testMultipleGroupBy()
l_cubeData.addEntry(l_inputData2);
l_cubeData.addEntry(l_inputData3);

LogData<GenericEntry> l_myCube = l_cubeData.groupBy(Arrays.asList("BAU", "DAT"), GenericEntry.class);
LogData<GenericEntry> l_myCube = l_cubeData.groupBy(Arrays.asList("BAU", "DAT"));

final ParseDefinition l_gpParseDefinition = l_myCube.getEntries().values().iterator().next()
.getParseDefinition();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.adobe.campaign.tests.logparser.data.SDKCasePrivateDefConstructor;
import com.adobe.campaign.tests.logparser.data.SDKCaseNoDefConstructor;
import com.adobe.campaign.tests.logparser.data.SDKCaseSTD;
import com.adobe.campaign.tests.logparser.exceptions.IncorrectParseDefinitionException;
import com.adobe.campaign.tests.logparser.exceptions.LogDataExportToFileException;
import com.adobe.campaign.tests.logparser.exceptions.LogParserSDKDefinitionException;
import com.adobe.campaign.tests.logparser.exceptions.StringParseException;
Expand Down Expand Up @@ -70,8 +71,34 @@ public void testSimpleLogACC_SDK()
assertThat("We should have a file name", l_entries.getEntries().values().iterator().next().getFileName(),
is(equalTo("useCase1.log")));

//l_entries.exportLogDataToCSV(l_entries.getEntries().values().iterator().next().fetchHeaders(),
// "./z.csv");
}

@Test
public void testSimpleLogACC_groupBy_SDK()
throws StringParseException, LogDataExportToFileException, IncorrectParseDefinitionException {

ParseDefinition l_pDefinition = getTestParseDefinition();
l_pDefinition.setStoreFileName(true);

String l_file = "src/test/resources/sdk/";

LogData<SDKCaseSTD> l_entries = LogDataFactory.generateLogData(l_file, "*.log", l_pDefinition,
SDKCaseSTD.class);


assertThat("We should have a correct number of errors", l_entries.getEntries().size(), is(equalTo(14)));
AssertLogData.assertLogContains(l_entries, "errorMessage",
"The HTTP query returned a 'Internal Server Error' type error (500) (iRc=16384)");

assertThat("We should have a file name", l_entries.getEntries().values().iterator().next().getFileName(),
is(equalTo("useCase1.log")));

LogData<GenericEntry> l_gbEntry = l_entries.groupBy("fileName");

assertThat("We should get one entry", l_gbEntry.getEntries().size(), is(equalTo(1)));
assertThat("The entry should have the value useCase1.log",
l_gbEntry.getEntries().values().iterator().next().getValuesMap().get("fileName"),
is(equalTo("useCase1.log")));
}

@Test
Expand Down