protected void print( Document doc ) { if (print) { try { Json.writePretty(doc, System.out); System.out.flush(); } catch (IOException err) { throw new AssertionError(err); } } }
@Test public void shouldMergeTwoDocuments() throws Exception { Document doc1 = Json.read(stream("json/merge-1.json")); Document doc2 = Json.read(stream("json/merge-2.json")); Document doc3 = Json.read(stream("json/merge-3.json")); EditableDocument editor = new DocumentEditor((MutableDocument)doc1); assertThat(Json.writePretty(editor).equals(Json.writePretty(doc3)), is(false)); editor.merge(doc2); assertThat(Json.writePretty(editor).equals(Json.writePretty(doc3)), is(true)); } }
protected void print( Document doc, boolean deep ) { if (print) { try { Json.writePretty(doc, System.out); System.out.flush(); if (deep) { Document info = doc.getDocument(DocumentTranslator.CHILDREN_INFO); if (info != null) { String nextBlockKey = info.getString(DocumentTranslator.NEXT_BLOCK); if (nextBlockKey != null) { Document next = schematicDb.get(nextBlockKey); if (next != null) { print(next, true); } } } } } catch (IOException err) { throw new AssertionError(err); } } }