use of org.opendaylight.controller.md.sal.binding.api.DataChangeListener in project controller by opendaylight.
the class Bug4513Test method testDataChangeListener.
@SuppressWarnings({ "rawtypes", "unchecked" })
@Test
public void testDataChangeListener() throws Exception {
DataChangeListener listener = mock(DataChangeListener.class);
InstanceIdentifier<ListItem> wildCard = InstanceIdentifier.builder(ListenerTest.class).child(ListItem.class).build();
ListenerRegistration<DataChangeListener> reg = getDataBroker().registerDataChangeListener(LogicalDatastoreType.OPERATIONAL, wildCard, listener, AsyncDataBroker.DataChangeScope.SUBTREE);
final ListItem item = writeListItem();
ArgumentCaptor<AsyncDataChangeEvent> captor = ArgumentCaptor.forClass(AsyncDataChangeEvent.class);
verify(listener, timeout(100)).onDataChanged(captor.capture());
AsyncDataChangeEvent event = captor.getValue();
assertEquals("createdData", 1, event.getCreatedData().size());
assertEquals("ListItem", item, event.getCreatedData().values().iterator().next());
}
Aggregations