Skip to content

Commit

Permalink
Removing escapes altogether
Browse files Browse the repository at this point in the history
  • Loading branch information
baubakg committed Oct 11, 2024
1 parent f493573 commit 994baab
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -551,8 +551,7 @@ public File exportLogDataToJSON(Collection<String> 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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Map<String, String>> 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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1524,10 +1524,10 @@ public void testExportDataToJSON() throws StringParseException, IOException {

try {
ObjectMapper objectMapper = new ObjectMapper();
String values = objectMapper.readValue(l_exportedFile, String.class);
List<Map<String, String>> 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();
Expand Down Expand Up @@ -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<Map<String, String>> 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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.*;
Expand Down Expand Up @@ -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<Map<String, String>> 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();
Expand Down

0 comments on commit 994baab

Please sign in to comment.