}
+ @Test
+ public void leafListNodeInContainerMultiline() throws IOException, URISyntaxException {
+ Writer writer = new StringWriter();
+ NormalizedNode<?, ?> leafListNodeInContainer = TestingNormalizedNodeStructuresCreator.leafListNodeInContainerMultiline();
+ String jsonOutput = normalizedNodeToJsonStreamTransformation(writer, leafListNodeInContainer);
+ new JsonValidator() {
+
+ @Override
+ public void validate(String jsonOutput) {
+ JsonObject cont1 = resolveCont1(jsonOutput);
+ assertNotNull(cont1);
+ JsonArray lflst11 = childArray(cont1, "complexjson:lflst11", "lflst11");
+ assertNotNull(lflst11);
+
+ HashSet<Object> lflst11Values = Sets.newHashSet();
+ for (JsonElement jsonElement : lflst11) {
+ assertTrue(jsonElement instanceof JsonPrimitive);
+ lflst11Values.add(((JsonPrimitive) jsonElement).getAsString());
+ }
+
+ assertEquals(Sets.newHashSet("lflst11 value2\r\nanother line 2", "lflst11 value1\nanother line 1"), lflst11Values);
+ }
+ }.validate(jsonOutput);
+
+ }
+
@Test
public void leafNodeViaAugmentationInContainer() throws IOException, URISyntaxException {
Writer writer = new StringWriter();
assertNotNull(lf111);
assertEquals("key111 value", key111.getAsString());
- assertEquals("/complexjson:cont1/complexjson:lflst11", lf112.getAsString());
+ assertEquals("/complexjson:cont1/complexjson:lflst11[.='foo']", lf112.getAsString());
assertEquals("lf113 value", lf113.getAsString());
assertEquals("lf111 value", lf111.getAsString());
}
private String normalizedNodeToJsonStreamTransformation(final Writer writer,
final NormalizedNode<?, ?> inputStructure) throws IOException {
- writer.write("{\n");
+
final NormalizedNodeStreamWriter jsonStream = JSONNormalizedNodeStreamWriter.create(schemaContext, writer, 2);
final NormalizedNodeWriter nodeWriter = NormalizedNodeWriter.forStreamWriter(jsonStream);
nodeWriter.write(inputStructure);
- writer.write("\n}");
+
nodeWriter.close();
return writer.toString();
}