X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-binding-dom-it%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Fbinding%2Ftest%2Fbugfix%2FDeleteNestedAugmentationListenParentTest.java;h=d91267454aea067254771d13eb00b40b24478057;hb=70cd4b01dd47a66c5591e6f8151430bb9c274a09;hp=6e6ae9a8847e422dcd20b3aadda38b958ee225a3;hpb=254f1a1188e0d83c8aeb2b9a94339b708d2ee280;p=controller.git diff --git a/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/DeleteNestedAugmentationListenParentTest.java b/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/DeleteNestedAugmentationListenParentTest.java index 6e6ae9a884..d91267454a 100644 --- a/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/DeleteNestedAugmentationListenParentTest.java +++ b/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/DeleteNestedAugmentationListenParentTest.java @@ -8,14 +8,16 @@ package org.opendaylight.controller.sal.binding.test.bugfix; -import static org.junit.Assert.assertFalse; -import com.google.common.util.concurrent.SettableFuture; +import com.google.common.collect.ImmutableSet; import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; 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.sal.binding.test.AbstractDataServiceTest; +import org.opendaylight.controller.md.sal.binding.api.DataBroker; +import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; +import org.opendaylight.controller.md.sal.binding.test.AbstractDataTreeChangeListenerTest; +import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.List11SimpleAugment; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.List11SimpleAugmentBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.TllComplexAugment; @@ -27,10 +29,10 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controll import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListKey; -import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +import org.opendaylight.yangtools.yang.binding.YangModuleInfo; -public class DeleteNestedAugmentationListenParentTest extends AbstractDataServiceTest { +public class DeleteNestedAugmentationListenParentTest extends AbstractDataTreeChangeListenerTest { private static final TopLevelListKey FOO_KEY = new TopLevelListKey("foo"); @@ -38,7 +40,8 @@ public class DeleteNestedAugmentationListenParentTest extends AbstractDataServic private static final List11Key LIST11_KEY = new List11Key(100); - private static final InstanceIdentifier TLL_COMPLEX_AUGMENT_PATH = InstanceIdentifier.builder(Top.class) + private static final InstanceIdentifier TLL_COMPLEX_AUGMENT_PATH = InstanceIdentifier + .builder(Top.class) .child(TopLevelList.class,FOO_KEY) .augmentation(TllComplexAugment.class) .build(); @@ -48,39 +51,39 @@ public class DeleteNestedAugmentationListenParentTest extends AbstractDataServic .child(List11.class,LIST11_KEY) .build(); + @Override + protected Iterable getModuleInfos() throws Exception { + return ImmutableSet.of(BindingReflections.getModuleInfo(Top.class), + BindingReflections.getModuleInfo(List11SimpleAugment.class)); + } @Test - public void deleteChildListenParent() throws InterruptedException, ExecutionException { - DataModificationTransaction initTx = baDataService.beginTransaction(); - - initTx.putOperationalData(LIST11_PATH, createList11()); - initTx.commit().get(); + public void deleteChildListenParent() throws InterruptedException, ExecutionException, TimeoutException { + DataBroker dataBroker = getDataBroker(); + final WriteTransaction initTx = dataBroker.newWriteOnlyTransaction(); - final SettableFuture, DataObject>> event = SettableFuture.create(); + List11 list11Before = createList11(); + initTx.put(LogicalDatastoreType.OPERATIONAL, LIST11_PATH, list11Before, true); + initTx.submit().get(5, TimeUnit.SECONDS); - baDataService.registerDataChangeListener(LIST11_PATH, new DataChangeListener() { + List11 list11After = new List11Builder().withKey(LIST11_KEY).setAttrStr("good").build(); - @Override - public void onDataChanged(final DataChangeEvent, DataObject> change) { - event.set(change); - } - }); + final TestListener listener = createListener(LogicalDatastoreType.OPERATIONAL, LIST11_PATH, + added(LIST11_PATH, list11Before), subtreeModified(LIST11_PATH, list11Before, list11After)); - DataModificationTransaction deleteTx = baDataService.beginTransaction(); - deleteTx.removeOperationalData(LIST11_PATH.augmentation(List11SimpleAugment.class)); - deleteTx.commit().get(); + final WriteTransaction deleteTx = dataBroker.newWriteOnlyTransaction(); + deleteTx.delete(LogicalDatastoreType.OPERATIONAL, LIST11_PATH.augmentation(List11SimpleAugment.class)); + deleteTx.submit().get(5, TimeUnit.SECONDS); - DataChangeEvent, DataObject> receivedEvent = event.get(); - assertFalse(receivedEvent.getRemovedOperationalData().contains(TLL_COMPLEX_AUGMENT_PATH)); + listener.verify(); } - private List11 createList11() { + private static List11 createList11() { List11Builder builder = new List11Builder() - .setKey(LIST11_KEY) + .withKey(LIST11_KEY) .addAugmentation(List11SimpleAugment.class,new List11SimpleAugmentBuilder() .setAttrStr2("bad").build()) .setAttrStr("good"); return builder.build(); } - }