X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-binding-dom-it%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Fbinding%2Ftest%2Fbugfix%2FWriteParentListenAugmentTest.java;h=a74b6ea2461c5efcfd233a7618e52425485872e0;hp=591effbe03cdca28175938fd3611dbdf5e82f740;hb=3a25fec0b812950c61d2fb6018407a2a6ceb5090;hpb=2727bea09c83646b6cbd2ef9672d0b7f6cf3b22f diff --git a/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/WriteParentListenAugmentTest.java b/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/WriteParentListenAugmentTest.java index 591effbe03..a74b6ea246 100644 --- a/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/WriteParentListenAugmentTest.java +++ b/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/WriteParentListenAugmentTest.java @@ -10,12 +10,15 @@ package org.opendaylight.controller.sal.binding.test.bugfix; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; + import com.google.common.util.concurrent.SettableFuture; import java.util.concurrent.TimeUnit; import org.junit.Test; -import org.opendaylight.controller.md.sal.common.api.data.DataChangeEvent; -import org.opendaylight.controller.sal.binding.api.data.DataChangeListener; -import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction; +import org.opendaylight.controller.md.sal.binding.api.DataBroker; +import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; +import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope; +import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent; +import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; import org.opendaylight.controller.sal.binding.test.AbstractDataServiceTest; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.TreeComplexUsesAugment; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.TreeComplexUsesAugmentBuilder; @@ -45,37 +48,32 @@ public class WriteParentListenAugmentTest extends AbstractDataServiceTest { @Test public void writeNodeListenAugment() throws Exception { - final SettableFuture, DataObject>> event = SettableFuture.create(); - - ListenerRegistration dclRegistration = baDataService.registerDataChangeListener( - AUGMENT_WILDCARDED_PATH, new DataChangeListener() { + final SettableFuture, DataObject>> event = SettableFuture.create(); + DataBroker dataBroker = testContext.getDataBroker(); + ListenerRegistration dclRegistration = + dataBroker.registerDataChangeListener(LogicalDatastoreType.OPERATIONAL, AUGMENT_WILDCARDED_PATH, + change -> event.set(change), DataChangeScope.SUBTREE); - @Override - public void onDataChanged(final DataChangeEvent, DataObject> change) { - event.set(change); - } - }); - - DataModificationTransaction modification = baDataService.beginTransaction(); + final WriteTransaction transaction = dataBroker.newWriteOnlyTransaction(); TopLevelList tll = new TopLevelListBuilder() // .setKey(TLL_KEY) // .addAugmentation(TreeComplexUsesAugment.class, treeComplexUsesAugment("one")).build(); - modification.putOperationalData(TLL_INSTANCE_ID_BA, tll); - modification.commit().get(); + transaction.put(LogicalDatastoreType.OPERATIONAL, TLL_INSTANCE_ID_BA, tll, true); + transaction.submit().get(5, TimeUnit.SECONDS); - DataChangeEvent, DataObject> receivedEvent = event.get(1000, TimeUnit.MILLISECONDS); - assertTrue(receivedEvent.getCreatedOperationalData().containsKey(AUGMENT_TLL_PATH)); + AsyncDataChangeEvent, DataObject> receivedEvent = event.get(1000, TimeUnit.MILLISECONDS); + assertTrue(receivedEvent.getCreatedData().containsKey(AUGMENT_TLL_PATH)); dclRegistration.close(); - DataModificationTransaction mod2 = baDataService.beginTransaction(); - mod2.putOperationalData(AUGMENT_TLL_PATH, treeComplexUsesAugment("two")); - mod2.commit().get(); + final WriteTransaction transaction2 = dataBroker.newWriteOnlyTransaction(); + transaction2.put(LogicalDatastoreType.OPERATIONAL, AUGMENT_TLL_PATH, treeComplexUsesAugment("two")); + transaction2.submit().get(5, TimeUnit.SECONDS); - TreeComplexUsesAugment readedAug = (TreeComplexUsesAugment) baDataService.readOperationalData(AUGMENT_TLL_PATH); + TreeComplexUsesAugment readedAug = dataBroker.newReadOnlyTransaction().read( + LogicalDatastoreType.OPERATIONAL, AUGMENT_TLL_PATH).checkedGet(5, TimeUnit.SECONDS).get(); assertEquals("two", readedAug.getContainerWithUses().getLeafFromGrouping()); - } private TreeComplexUsesAugment treeComplexUsesAugment(final String value) { @@ -83,4 +81,4 @@ public class WriteParentListenAugmentTest extends AbstractDataServiceTest { .setContainerWithUses(new ContainerWithUsesBuilder().setLeafFromGrouping(value).build()) // .build(); } -} \ No newline at end of file +}