NodeStateEntryWriter { public String toString(NodeStateEntry e) { return toString(e.getPath(), asJson(e.getNodeState())); } NodeStateEntryWriter(BlobStore blobStore); String toString(NodeStateEntry e); String toString(String path, String nodeStateAsJson); String toString(List<String> pathElements, String nodeStateAsJson); String asJson(NodeState nodeState); static String getPath(String entryLine); static String[] getParts(String line);  }
@Test public void multipleEntries() { NodeStateEntryWriter nw = new NodeStateEntryWriter(blobStore); NodeBuilder b1 = EMPTY_NODE.builder(); b1.setProperty("foo", "bar"); NodeBuilder b2 = EMPTY_NODE.builder(); b2.setProperty("foo2", "bar2"); NodeStateEntry e1 = new NodeStateEntry(b1.getNodeState(), "/a"); NodeStateEntry e2 = new NodeStateEntry(b2.getNodeState(), "/a"); String line1 = nw.toString(e1); String line2 = nw.toString(e2); NodeStateEntryReader nr = new NodeStateEntryReader(blobStore); assertEquals(e1, nr.read(line1)); assertEquals(e2, nr.read(line2)); }
@Test public void childOrderNotWritten(){ NodeStateEntryWriter nw = new NodeStateEntryWriter(blobStore); NodeBuilder b1 = EMPTY_NODE.builder(); b1.setProperty("foo", "bar"); b1.setProperty(":childOrder", "bar"); b1.setProperty(":hidden", "bar"); NodeStateEntry e1 = new NodeStateEntry(b1.getNodeState(), "/a"); String line = nw.toString(e1); NodeStateEntryReader nr = new NodeStateEntryReader(blobStore); NodeStateEntry r1 = nr.read(line); assertTrue(r1.getNodeState().hasProperty(":hidden")); assertFalse(r1.getNodeState().hasProperty(":childOrder")); }