use of org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener in project controller by opendaylight.
the class Bug4513Test method testDataTreeChangeListener.
@SuppressWarnings({ "rawtypes", "unchecked" })
@Test
public void testDataTreeChangeListener() throws Exception {
DataBroker dataBroker = getDataBroker();
DataTreeChangeListener<ListItem> listener = mock(DataTreeChangeListener.class);
InstanceIdentifier<ListItem> wildCard = InstanceIdentifier.builder(ListenerTest.class).child(ListItem.class).build();
ListenerRegistration<DataTreeChangeListener<ListItem>> reg = dataBroker.registerDataTreeChangeListener(new DataTreeIdentifier(LogicalDatastoreType.OPERATIONAL, wildCard), listener);
final ListItem item = writeListItem();
ArgumentCaptor<Collection> captor = ArgumentCaptor.forClass(Collection.class);
verify(listener, timeout(100)).onDataTreeChanged(captor.capture());
Collection<DataTreeModification<ListItem>> mods = captor.getValue();
assertEquals("ListItem", item, mods.iterator().next().getRootNode().getDataAfter());
}
use of org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener in project genius by opendaylight.
the class TestableDataTreeChangeListenerModule method getTestableDataTreeChangeListener.
@SuppressWarnings({ "unchecked", "rawtypes" })
protected TestableDataTreeChangeListener getTestableDataTreeChangeListener(Injector injector) {
TestableDataTreeChangeListener beforeTestableDataTreeChangeListener = new TestableDataTreeChangeListener();
DataTreeChangeListener afterTestableDataTreeChangeListener = new DecrementingTestableDataTreeChangeDecoratorListener(beforeTestableDataTreeChangeListener);
for (Key<?> key : injector.getAllBindings().keySet()) {
if (ChainableDataTreeChangeListener.class.isAssignableFrom(key.getTypeLiteral().getRawType())) {
ChainableDataTreeChangeListener chainableListener = (ChainableDataTreeChangeListener) injector.getInstance(key);
chainableListener.addBeforeListener(beforeTestableDataTreeChangeListener);
chainableListener.addAfterListener(afterTestableDataTreeChangeListener);
LOG.info("AsyncEventsWaiter: {}", chainableListener);
}
}
return beforeTestableDataTreeChangeListener;
}
Aggregations