@Test public void registerTreeChangeListenerTest() throws Exception { final DOMDataTreeChangeListener domDataTreeChangeListener = mock(DOMDataTreeChangeListener.class); final ListenerRegistration<?> listenerRegistration = mock(ListenerRegistration.class); final DataTreeSnapshot initialSnapshot = mock(DataTreeSnapshot.class); final DataContainerNode<?> initialData = ImmutableContainerNodeBuilder.create() .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(QName.create("", "test"))) .build(); doReturn(initialSnapshot).when(DATA_TREE).takeSnapshot(); doReturn(Optional.of(initialData)).when(initialSnapshot).readNode(any()); doNothing().when(domDataTreeChangeListener).onDataTreeChanged(any()); doReturn(listenerRegistration) .when(READABLE_WRITEABLE_DOM_DATA_TREE_SHARD).registerTreeChangeListener(any(), any()); assertNotNull(this.registerTreeChangeListener(YANG_INSTANCE_IDENTIFIER, domDataTreeChangeListener)); verify(READABLE_WRITEABLE_DOM_DATA_TREE_SHARD).registerTreeChangeListener(any(), any()); verify(domDataTreeChangeListener) .onDataTreeChanged(captorForChanges.capture()); final Collection<DataTreeCandidate> initialChange = captorForChanges.getValue(); assertTrue(initialChange.size() == 1); initialChange.forEach(dataTreeCandidate -> assertEquals(dataTreeCandidate.getRootPath(), YANG_INSTANCE_IDENTIFIER)); initialChange.forEach(dataTreeCandidate -> assertEquals(dataTreeCandidate.getRootNode().getModificationType(), ModificationType.UNMODIFIED)); }
@Override public <L extends DOMDataTreeChangeListener> AbstractDOMDataTreeChangeListenerRegistration<L> registerTreeChangeListener(final YangInstanceIdentifier path, final L listener) { takeLock(); try { return setupListenerContext(path, listener); } finally { releaseLock(); } }
AbstractDOMShardTreeChangePublisher extends AbstractDOMStoreTreeChangePublisher { @Override public <L extends DOMDataTreeChangeListener> AbstractDOMDataTreeChangeListenerRegistration<L> registerTreeChangeListener(final YangInstanceIdentifier path, final L listener) { takeLock(); try { return setupListenerContext(path, listener); } finally { releaseLock(); } } }
AbstractDOMShardTreeChangePublisher extends AbstractDOMStoreTreeChangePublisher { @Override public <L extends DOMDataTreeChangeListener> AbstractDOMDataTreeChangeListenerRegistration<L> registerTreeChangeListener(final YangInstanceIdentifier path, final L listener) { takeLock(); try { return setupListenerContext(path, listener); } finally { releaseLock(); } } protected  AbstractDOMShardTreeChangePublisher(final DataTree dataTree,
            final YangInstanceIdentifier shardPath, final Map<DOMDataTreeIdentifier, ChildShardContext> childShards); }
AbstractDOMShardTreeChangePublisher extends AbstractDOMStoreTreeChangePublisher { @Override public <L extends DOMDataTreeChangeListener> AbstractDOMDataTreeChangeListenerRegistration<L> registerTreeChangeListener(final YangInstanceIdentifier path, final L listener) { takeLock(); try { return setupListenerContext(path, listener); } finally { releaseLock(); } } protected  AbstractDOMShardTreeChangePublisher(final DataTree dataTree,
            final YangInstanceIdentifier shardPath, final Map<DOMDataTreeIdentifier, ChildShardContext> childShards); @Override AbstractDOMDataTreeChangeListenerRegistration<L> registerTreeChangeListener(final YangInstanceIdentifier path, final L listener); }
AbstractDOMShardTreeChangePublisher extends AbstractDOMStoreTreeChangePublisher { @Override public <L extends DOMDataTreeChangeListener> AbstractDOMDataTreeChangeListenerRegistration<L> registerTreeChangeListener(final YangInstanceIdentifier path, final L listener) { takeLock(); try { return setupListenerContext(path, listener); } finally { releaseLock(); } } protected  AbstractDOMShardTreeChangePublisher(final DataTree dataTree,
            final YangInstanceIdentifier shardPath, final Map<DOMDataTreeIdentifier, ChildShardContext> childShards); @Override AbstractDOMDataTreeChangeListenerRegistration<L> registerTreeChangeListener(final YangInstanceIdentifier path, final L listener);  }