BindingDOMDataTreeChangeServiceAdapter extends AbstractBindingAdapter<DOMDataTreeChangeService> implements DataTreeChangeService { @Override public <T extends DataObject, L extends DataTreeChangeListener<T>> ListenerRegistration<L> registerDataTreeChangeListener(final DataTreeIdentifier<T> treeId, final L listener) { final DOMDataTreeIdentifier domIdentifier = toDomTreeIdentifier(treeId); final LogicalDatastoreType storeType = treeId.getDatastoreType(); final BindingDOMDataTreeChangeListenerAdapter<T> domListener = listener instanceof ClusteredDataTreeChangeListener ? new BindingClusteredDOMDataTreeChangeListenerAdapter<>( adapterContext(), (ClusteredDataTreeChangeListener<T>) listener, storeType) : new BindingDOMDataTreeChangeListenerAdapter<>(adapterContext(), listener, storeType); final ListenerRegistration<BindingDOMDataTreeChangeListenerAdapter<T>> domReg = getDelegate().registerDataTreeChangeListener(domIdentifier, domListener); return new BindingDataTreeChangeListenerRegistration<>(listener, domReg); } BindingDOMDataTreeChangeServiceAdapter(final AdapterContext adapterContext,
            final DOMDataTreeChangeService dataTreeChangeService); @Override ListenerRegistration<L> registerDataTreeChangeListener(final DataTreeIdentifier<T> treeId, final L listener);  }
@Test public void testRegisterDataTreeChangeListener() { final AdapterContext codec = new ConstantAdapterContext(services); final DataTreeChangeService service = new BindingDOMDataTreeChangeServiceAdapter(codec, mockDOMService); doReturn(mockDOMReg).when(mockDOMService).registerDataTreeChangeListener( domDataTreeIdentifier(mockYangID), any(DOMDataTreeChangeListener.class)); final DataTreeIdentifier<Top> treeId = DataTreeIdentifier.create(LogicalDatastoreType.CONFIGURATION, TOP_PATH); final TestClusteredDataTreeChangeListener mockClusteredListener = new TestClusteredDataTreeChangeListener(); service.registerDataTreeChangeListener(treeId , mockClusteredListener); verify(mockDOMService).registerDataTreeChangeListener(domDataTreeIdentifier(this.mockYangID), isA(ClusteredDOMDataTreeChangeListener.class)); reset(mockDOMService); doReturn(mockDOMReg).when(mockDOMService).registerDataTreeChangeListener( domDataTreeIdentifier(mockYangID), any(DOMDataTreeChangeListener.class)); final TestDataTreeChangeListener mockNonClusteredListener = new TestDataTreeChangeListener(); service.registerDataTreeChangeListener(treeId , mockNonClusteredListener); verify(this.mockDOMService).registerDataTreeChangeListener(domDataTreeIdentifier(this.mockYangID), not(isA(ClusteredDOMDataTreeChangeListener.class))); }