@Test public void basicTest() throws Exception { final DataTreeModificationCursor dataTreeModificationCursor = mock(DataTreeModificationCursor.class); final DataTreeModificationCursorAdaptor dataTreeModificationCursorAdaptor = DataTreeModificationCursorAdaptor.of(dataTreeModificationCursor); final ShardRootModificationContext shardRootModificationContext = mock(ShardRootModificationContext.class); final Map<PathArgument, WriteableModificationNode> children = new HashMap<>(); children.put(PATH_ARGUMENT, WRITEABLE_MODIFICATION_NODE); final ShardDataModification root = new ShardDataModification(shardRootModificationContext, children, ImmutableMap.of()); doReturn(dataTreeModificationCursorAdaptor).when(shardRootModificationContext).cursor(); InmemoryDOMDataTreeShardWriteTransaction inmemoryDOMDataTreeShardWriteTransaction = mock(InmemoryDOMDataTreeShardWriteTransaction.class); InMemoryShardDataModificationCursor shardDataModificationCursor = new InMemoryShardDataModificationCursor(root, inmemoryDOMDataTreeShardWriteTransaction); final Field stackField = AbstractDataModificationCursor.class.getDeclaredField("stack"); stackField.setAccessible(true); final Deque<WriteCursorStrategy> stack = (Deque<WriteCursorStrategy>) stackField.get(shardDataModificationCursor); stack.clear(); stack.push(WRITE_CURSOR_STRATEGY); stackField.set(shardDataModificationCursor, stack); doNothing().when(WRITE_CURSOR_STRATEGY).delete(PATH_ARGUMENT); doNothing().when(WRITE_CURSOR_STRATEGY).merge(PATH_ARGUMENT, NORMALIZED_NODE); doNothing().when(WRITE_CURSOR_STRATEGY).write(PATH_ARGUMENT, NORMALIZED_NODE); doReturn("testPathArgument").when(PATH_ARGUMENT).toString(); shardDataModificationCursor.delete(PATH_ARGUMENT); verify(WRITE_CURSOR_STRATEGY).delete(PATH_ARGUMENT); shardDataModificationCursor.merge(PATH_ARGUMENT, NORMALIZED_NODE); verify(WRITE_CURSOR_STRATEGY).merge(PATH_ARGUMENT, NORMALIZED_NODE); shardDataModificationCursor.write(PATH_ARGUMENT, NORMALIZED_NODE); verify(WRITE_CURSOR_STRATEGY).write(PATH_ARGUMENT, NORMALIZED_NODE); doReturn(WRITE_CURSOR_STRATEGY).when(WRITE_CURSOR_STRATEGY).enter(PATH_ARGUMENT); shardDataModificationCursor.enter(ImmutableList.of(PATH_ARGUMENT)); shardDataModificationCursor.enter(PATH_ARGUMENT, PATH_ARGUMENT); verify(WRITE_CURSOR_STRATEGY, times(3)).enter(PATH_ARGUMENT); doNothing().when(inmemoryDOMDataTreeShardWriteTransaction).cursorClosed(); shardDataModificationCursor.close(); verify(inmemoryDOMDataTreeShardWriteTransaction).cursorClosed(); doNothing().when(WRITE_CURSOR_STRATEGY).exit(); shardDataModificationCursor.exit(1); verify(WRITE_CURSOR_STRATEGY).exit(); }
@Override public void close() { parent.cursorClosed(); }
InMemoryShardDataModificationCursor extends AbstractDataModificationCursor<ShardDataModification> { @Override public void close() { parent.cursorClosed(); } }
InMemoryShardDataModificationCursor extends AbstractDataModificationCursor<ShardDataModification> { @Override public void close() { parent.cursorClosed(); } InMemoryShardDataModificationCursor(final ShardDataModification root,
                                        final InmemoryDOMDataTreeShardWriteTransaction parent); }
InMemoryShardDataModificationCursor extends AbstractDataModificationCursor<ShardDataModification> { @Override public void close() { parent.cursorClosed(); } InMemoryShardDataModificationCursor(final ShardDataModification root,
                                        final InmemoryDOMDataTreeShardWriteTransaction parent); @Override void close(); }
InMemoryShardDataModificationCursor extends AbstractDataModificationCursor<ShardDataModification> { @Override public void close() { parent.cursorClosed(); } InMemoryShardDataModificationCursor(final ShardDataModification root,
                                        final InmemoryDOMDataTreeShardWriteTransaction parent); @Override void close();  }