use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.listener.rev150825.listener.test.ListItem 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.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.listener.rev150825.listener.test.ListItem in project controller by opendaylight.
the class Bug4513Test method writeListItem.
private ListItem writeListItem() {
WriteTransaction writeTransaction = getDataBroker().newWriteOnlyTransaction();
final ListItem item = new ListItemBuilder().setSip("name").setOp(43L).build();
ListenerTestBuilder builder = new ListenerTestBuilder().setListItem(Arrays.asList(item));
writeTransaction.put(LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.builder(ListenerTest.class).build(), builder.build());
assertCommit(writeTransaction.submit());
return item;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.listener.rev150825.listener.test.ListItem 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