diff --git a/src/main/java/com/adobe/campaign/tests/logparser/core/LogData.java b/src/main/java/com/adobe/campaign/tests/logparser/core/LogData.java index d682ee5..54fc484 100644 --- a/src/main/java/com/adobe/campaign/tests/logparser/core/LogData.java +++ b/src/main/java/com/adobe/campaign/tests/logparser/core/LogData.java @@ -551,8 +551,7 @@ public File exportLogDataToJSON(Collection in_headerSet, String in_jsonF ObjectMapper objectMapper = new ObjectMapper(); - objectMapper.writeValue(l_exportFile, - objectMapper.writeValueAsString(jsonList)); + objectMapper.writeValue(l_exportFile, jsonList); } catch (IOException e) { throw new LogDataExportToFileException("Encountered error while exporting the log data to a JSON file.", e); } diff --git a/src/test/java/com/adobe/campaign/tests/logparser/ExecutionTests.java b/src/test/java/com/adobe/campaign/tests/logparser/ExecutionTests.java index 12b6c2d..3b7851c 100644 --- a/src/test/java/com/adobe/campaign/tests/logparser/ExecutionTests.java +++ b/src/test/java/com/adobe/campaign/tests/logparser/ExecutionTests.java @@ -124,10 +124,10 @@ public void testSTDMain_printJSON() throws IOException, StringParseException { Matchers.endsWith(l_parseDefinition.fetchEscapedTitle() + "-export.json")); ObjectMapper objectMapper = new ObjectMapper(); - String values = objectMapper.readValue(l_exportedFile, String.class); + List> values = objectMapper.readValue(l_exportedFile, List.class); - assertThat("JSON file contains correct verb definition", values.contains(l_parseDefinition.getDefinitionEntries().get(0).getTitle())); - assertThat("JSON file contains correct api definition", values.contains(l_parseDefinition.getDefinitionEntries().get(1).getTitle())); + assertThat("JSON file contains correct verb definition", values.get(0).keySet().contains(l_parseDefinition.getDefinitionEntries().get(0).getTitle())); + assertThat("JSON file contains correct api definition", values.get(0).keySet().contains(l_parseDefinition.getDefinitionEntries().get(1).getTitle())); } finally { l_exportedFile.delete(); diff --git a/src/test/java/com/adobe/campaign/tests/logparser/core/LogDataTest.java b/src/test/java/com/adobe/campaign/tests/logparser/core/LogDataTest.java index 9bc2b0f..83d72a9 100644 --- a/src/test/java/com/adobe/campaign/tests/logparser/core/LogDataTest.java +++ b/src/test/java/com/adobe/campaign/tests/logparser/core/LogDataTest.java @@ -1524,10 +1524,10 @@ public void testExportDataToJSON() throws StringParseException, IOException { try { ObjectMapper objectMapper = new ObjectMapper(); - String values = objectMapper.readValue(l_exportedFile, String.class); + List> values = objectMapper.readValue(l_exportedFile, List.class); - assertThat("JSON file contains correct verb definition", values.contains(l_verbDefinition2.getTitle())); - assertThat("JSON file contains correct api definition", values.contains(l_apiDefinition.getTitle())); + assertThat("JSON file contains correct verb definition", values.get(0).keySet().contains(l_verbDefinition2.getTitle())); + assertThat("JSON file contains correct api definition", values.get(0).keySet().contains(l_apiDefinition.getTitle())); } finally { l_exportedFile.delete(); @@ -1570,11 +1570,12 @@ public void testExportDataToJSON_givenFileName() throws StringParseException, IO assertThat("Created JSON file is no Empty", l_exportedFile.length() > 0); try { + ObjectMapper objectMapper = new ObjectMapper(); - String values = objectMapper.readValue(l_exportedFile, String.class); + List> values = objectMapper.readValue(l_exportedFile, List.class); - assertThat("JSON file contains correct verb definition", values.contains(l_verbDefinition2.getTitle())); - assertThat("JSON file contains correct api definition", values.contains(l_apiDefinition.getTitle())); + assertThat("JSON file contains correct verb definition", values.get(0).keySet().contains(l_verbDefinition2.getTitle())); + assertThat("JSON file contains correct api definition", values.get(0).keySet().contains(l_apiDefinition.getTitle())); } finally { l_exportedFile.delete(); diff --git a/src/test/java/com/adobe/campaign/tests/logparser/core/SDKTests.java b/src/test/java/com/adobe/campaign/tests/logparser/core/SDKTests.java index cfa8556..e4b5869 100644 --- a/src/test/java/com/adobe/campaign/tests/logparser/core/SDKTests.java +++ b/src/test/java/com/adobe/campaign/tests/logparser/core/SDKTests.java @@ -22,6 +22,8 @@ import java.io.IOException; import java.time.ZonedDateTime; import java.util.Arrays; +import java.util.List; +import java.util.Map; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; @@ -232,13 +234,9 @@ public void testSimpleLogACC_SDK_exportDateTimeJSON() throws StringParseExceptio try { ObjectMapper objectMapper = new ObjectMapper(); - String values = objectMapper.readValue(l_exportedFile, String.class); + List> values = objectMapper.readValue(l_exportedFile, List.class); - assertThat("JSON file contains correct verb definition and is not prettified", values.contains("\"timeStamp\":\"2024-06-13T03:00:19.727Z\"")); - assertThat("JSON file does not contain prettified elements", !values.contains("\n")); - assertThat("JSON file does not contain prettified elements", !values.contains("\t")); - boolean containsNewline = values.contains("\n"); - System.out.println("Contains newline: " + containsNewline); + assertThat("JSON file contains correct verb definition", values.get(0).keySet().contains("timeStamp")); } finally { l_exportedFile.delete();