WritableNodeOperation implements WriteCursorStrategy { @Override @SuppressWarnings("rawtypes") public final void writeToCurrent(final NormalizedNodeContainer<?, ?, ?> data) { write(data.getIdentifier(), data); cursor.enter(data.getIdentifier()); for (NormalizedNode<?, ?> writtenChild : data.getValue()) { write(writtenChild.getIdentifier(), writtenChild); } node.getChildrenWithSubshards().entrySet() .stream().filter(entry -> entry.getValue() instanceof WriteableSubshardBoundaryNode).forEach(entry -> { @SuppressWarnings("unchecked") Optional<NormalizedNode<?, ?>> writtenValue = ((NormalizedNodeContainer) data).getChild(entry.getKey()); if (writtenValue.isPresent()) { cursor.delete(entry.getKey()); } }); cursor.exit(); } protected  WritableNodeOperation(final WriteableModificationNode node, final DOMDataTreeWriteCursor cursor); @Override final void delete(final PathArgument arg); @Override final void merge(final PathArgument arg, final NormalizedNode<?, ?> data); @Override final void write(final PathArgument arg, final NormalizedNode<?, ?> data); @Override final WriteCursorStrategy enter(final PathArgument arg); @Override final void mergeToCurrent(final NormalizedNodeContainer<?, ?, ?> data); @Override @SuppressWarnings("rawtypes") final void writeToCurrent(final NormalizedNodeContainer<?, ?, ?> data);  }
@Test public void writeToCurrentTest() throws Exception { returnNull(); Map<PathArgument, WriteableModificationNode> childrenWithSubShards = new HashMap<>(); childrenWithSubShards.put(TestUtils.PATH_ARGUMENT, TestUtils.WRITEABLE_MODIFICATION_NODE); doReturn(childrenWithSubShards).when(TestUtils.WRITEABLE_MODIFICATION_NODE).getChildrenWithSubshards(); doReturn(Optional.of(TestUtils.NORMALIZED_NODE)) .when(TestUtils.NORMALIZED_NODE_CONTAINER).getChild(TestUtils.PATH_ARGUMENT); this.writeToCurrent(TestUtils.NORMALIZED_NODE_CONTAINER); verify(TestUtils.DOM_DATA_TREE_WRITE_CURSOR).delete(TestUtils.PATH_ARGUMENT); verify(TestUtils.DOM_DATA_TREE_WRITE_CURSOR).exit(); }