X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-binding-broker%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fmd%2Fsal%2Fbinding%2Fimpl%2Ftest%2FBug2562DeserializedUnkeyedListTest.java;h=6d6b16e1299ffec4b347204ff0da16db3e7f4896;hp=57d390b176aa8a8f15d29fa0c918bd813fef7a34;hb=8e4580f8989c7a40861be1c025822ebba4f1cb07;hpb=258d8039ac144aeee2efa7943228c0fc6cdaf651 diff --git a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/test/Bug2562DeserializedUnkeyedListTest.java b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/test/Bug2562DeserializedUnkeyedListTest.java index 57d390b176..6d6b16e129 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/test/Bug2562DeserializedUnkeyedListTest.java +++ b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/test/Bug2562DeserializedUnkeyedListTest.java @@ -8,16 +8,11 @@ package org.opendaylight.controller.md.sal.binding.impl.test; -import static org.junit.Assert.assertNotNull; -import static org.opendaylight.controller.md.sal.binding.test.AssertCollections.assertContains; -import static org.opendaylight.controller.md.sal.binding.test.AssertCollections.assertEmpty; - -import java.util.ArrayList; +import com.google.common.collect.ImmutableSet; +import java.util.Arrays; import org.junit.Test; import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction; -import org.opendaylight.controller.md.sal.binding.test.AbstractDataChangeListenerTest; -import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker; -import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent; +import org.opendaylight.controller.md.sal.binding.test.AbstractDataTreeChangeListenerTest; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; import org.opendaylight.yang.gen.v1.opendaylight.test.bug._2562.namespace.rev160101.Root; import org.opendaylight.yang.gen.v1.opendaylight.test.bug._2562.namespace.rev160101.RootBuilder; @@ -26,36 +21,31 @@ import org.opendaylight.yang.gen.v1.opendaylight.test.bug._2562.namespace.rev160 import org.opendaylight.yang.gen.v1.opendaylight.test.bug._2562.namespace.rev160101.root.fooroot.Barroot; import org.opendaylight.yang.gen.v1.opendaylight.test.bug._2562.namespace.rev160101.root.fooroot.BarrootBuilder; import org.opendaylight.yang.gen.v1.opendaylight.test.bug._2562.namespace.rev160101.root.fooroot.BarrootKey; -import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +import org.opendaylight.yangtools.yang.binding.YangModuleInfo; +import org.opendaylight.yangtools.yang.binding.util.BindingReflections; -public class Bug2562DeserializedUnkeyedListTest extends AbstractDataChangeListenerTest { +public class Bug2562DeserializedUnkeyedListTest extends AbstractDataTreeChangeListenerTest { private static final InstanceIdentifier ROOT_PATH = InstanceIdentifier.create(Root.class); - private void writeRoot(final LogicalDatastoreType store) { - final ReadWriteTransaction readWriteTransaction = getDataBroker().newReadWriteTransaction(); - final Barroot barRoot = new BarrootBuilder().setType(2).setValue(2).setKey(new BarrootKey(2)).build(); - final ArrayList barRootList = new ArrayList<>(); - barRootList.add(barRoot); - final Fooroot fooRoot = new FoorootBuilder().setBarroot(barRootList).build(); - final ArrayList fooRootList = new ArrayList<>(); - fooRootList.add(fooRoot); - final Root root = new RootBuilder().setFooroot(fooRootList).build(); - - readWriteTransaction.put(store, ROOT_PATH, root); - assertCommit(readWriteTransaction.submit()); + @Override + protected Iterable getModuleInfos() throws Exception { + return ImmutableSet.of(BindingReflections.getModuleInfo(Root.class)); } @Test public void writeListToList2562Root() { - final AbstractDataChangeListenerTest.TestListener listenerRoot = - createListener(LogicalDatastoreType.CONFIGURATION, ROOT_PATH, AsyncDataBroker.DataChangeScope.ONE, false); - writeRoot(LogicalDatastoreType.CONFIGURATION); - final AsyncDataChangeEvent, DataObject> eventRoot = listenerRoot.event(); - - assertContains(eventRoot.getCreatedData(), ROOT_PATH); - assertEmpty(eventRoot.getUpdatedData()); - assertEmpty(eventRoot.getRemovedPaths()); - assertNotNull(eventRoot.toString()); + final Barroot barRoot = new BarrootBuilder().setType(2).setValue(2).setKey(new BarrootKey(2)).build(); + final Fooroot fooRoot = new FoorootBuilder().setBarroot(Arrays.asList(barRoot)).build(); + final Root root = new RootBuilder().setFooroot(Arrays.asList(fooRoot)).build(); + + final TestListener listenerRoot = createListener(LogicalDatastoreType.CONFIGURATION, ROOT_PATH, + added(ROOT_PATH, root)); + + final ReadWriteTransaction readWriteTransaction = getDataBroker().newReadWriteTransaction(); + readWriteTransaction.put(LogicalDatastoreType.CONFIGURATION, ROOT_PATH, root); + assertCommit(readWriteTransaction.submit()); + + listenerRoot.verify(); } }