Search in sources :

Example 1 with DOMImmutableDataChangeEvent

use of org.opendaylight.controller.md.sal.dom.store.impl.DOMImmutableDataChangeEvent in project controller by opendaylight.

the class DataChangedTest method testSerialization.

@Test
public void testSerialization() {
    DOMImmutableDataChangeEvent change = DOMImmutableDataChangeEvent.builder(DataChangeScope.SUBTREE).addCreated(TestModel.TEST_PATH, ImmutableContainerNodeBuilder.create().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TestModel.TEST_QNAME)).withChild(ImmutableNodes.leafNode(TestModel.DESC_QNAME, "foo")).build()).addUpdated(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME), ImmutableContainerNodeBuilder.create().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TestModel.TEST_QNAME)).withChild(ImmutableNodes.leafNode(TestModel.NAME_QNAME, "bar")).build()).addRemoved(TestModel.OUTER_LIST_PATH, ImmutableNodes.mapNodeBuilder(TestModel.OUTER_LIST_QNAME).build()).setBefore(ImmutableNodes.containerNode(TestModel.TEST_QNAME)).setAfter(ImmutableContainerNodeBuilder.create().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TestModel.TEST_QNAME)).withChild(ImmutableNodes.leafNode(TestModel.DESC_QNAME, "foo")).withChild(ImmutableNodes.leafNode(TestModel.NAME_QNAME, "bar")).build()).build();
    DataChanged expected = new DataChanged(change);
    DataChanged actual = (DataChanged) SerializationUtils.clone(expected);
    assertEquals("getCreatedData", change.getCreatedData(), actual.getChange().getCreatedData());
    assertEquals("getOriginalData", change.getOriginalData(), actual.getChange().getOriginalData());
    assertEquals("getOriginalSubtree", change.getOriginalSubtree(), actual.getChange().getOriginalSubtree());
    assertEquals("getRemovedPaths", change.getRemovedPaths(), actual.getChange().getRemovedPaths());
    assertEquals("getUpdatedData", change.getUpdatedData(), actual.getChange().getUpdatedData());
    assertEquals("getUpdatedSubtree", change.getUpdatedSubtree(), actual.getChange().getUpdatedSubtree());
}
Also used : DOMImmutableDataChangeEvent(org.opendaylight.controller.md.sal.dom.store.impl.DOMImmutableDataChangeEvent) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) Test(org.junit.Test)

Example 2 with DOMImmutableDataChangeEvent

use of org.opendaylight.controller.md.sal.dom.store.impl.DOMImmutableDataChangeEvent in project controller by opendaylight.

the class DefaultShardDataChangeListenerPublisher method submitNotifications.

@Override
public void submitNotifications(final DataChangeListenerRegistration<?> listener, final Iterable<DOMImmutableDataChangeEvent> notifications) {
    final AsyncDataChangeListener<YangInstanceIdentifier, NormalizedNode<?, ?>> instance = listener.getInstance();
    LOG.debug("{}: Notifying listener {} about {}", logContext, instance, notifications);
    for (DOMImmutableDataChangeEvent n : notifications) {
        instance.onDataChanged(n);
    }
}
Also used : DOMImmutableDataChangeEvent(org.opendaylight.controller.md.sal.dom.store.impl.DOMImmutableDataChangeEvent) NormalizedNode(org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)

Aggregations

DOMImmutableDataChangeEvent (org.opendaylight.controller.md.sal.dom.store.impl.DOMImmutableDataChangeEvent)2 YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)2 Test (org.junit.Test)1 NormalizedNode (org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode)1