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%2FWriteParentReadChildTest.java;h=153d9d27203200cc66d46e3b1546df93106ed5af;hb=8e4580f8989c7a40861be1c025822ebba4f1cb07;hp=de7445ee70299b8da7d6dc40d3b7a8bacde2f014;hpb=f39ec0eea4ce3f2a9be935887097a7e974adf5e0;p=controller.git diff --git a/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/WriteParentReadChildTest.java b/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/WriteParentReadChildTest.java index de7445ee70..153d9d2720 100644 --- a/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/WriteParentReadChildTest.java +++ b/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/WriteParentReadChildTest.java @@ -11,10 +11,14 @@ package org.opendaylight.controller.sal.binding.test.bugfix; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; + +import com.google.common.base.Optional; import com.google.common.collect.ImmutableList; +import java.util.concurrent.TimeUnit; import org.junit.Test; -import org.opendaylight.controller.md.sal.common.api.TransactionStatus; -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.LogicalDatastoreType; import org.opendaylight.controller.sal.binding.test.AbstractDataServiceTest; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.TllComplexAugment; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.aug.grouping.List1; @@ -28,7 +32,6 @@ 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.two.level.list.TopLevelListKey; import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.common.RpcResult; public class WriteParentReadChildTest extends AbstractDataServiceTest { @@ -41,7 +44,7 @@ public class WriteParentReadChildTest extends AbstractDataServiceTest { private static final List1Key LIST1_KEY = new List1Key(LIST1_NAME); private static final InstanceIdentifier TLL_INSTANCE_ID_BA = InstanceIdentifier.builder(Top.class) // - .child(TopLevelList.class, TLL_KEY).toInstance(); + .child(TopLevelList.class, TLL_KEY).build(); private static final InstanceIdentifier LIST1_INSTANCE_ID_BA = // TLL_INSTANCE_ID_BA.builder() // @@ -49,43 +52,36 @@ public class WriteParentReadChildTest extends AbstractDataServiceTest { private static final InstanceIdentifier LIST11_INSTANCE_ID_BA = // LIST1_INSTANCE_ID_BA.child(List11.class, LIST11_KEY); + /** - * * The scenario tests writing parent node, which also contains child items * and then reading child directly, by specifying path to the child. - * * Expected behaviour is child is returned. - * - * @throws Exception */ @Test public void writeParentReadChild() throws Exception { - DataModificationTransaction modification = baDataService.beginTransaction(); + DataBroker dataBroker = testContext.getDataBroker(); + final WriteTransaction transaction = dataBroker.newWriteOnlyTransaction(); List11 list11 = new List11Builder() // .setKey(LIST11_KEY) // .setAttrStr("primary") .build(); - List1 list1 = new List1Builder() - .setKey(LIST1_KEY) - .setList11(ImmutableList.of(list11)) - .build(); + List1 list1 = new List1Builder().setKey(LIST1_KEY).setList11(ImmutableList.of(list11)).build(); - modification.putConfigurationData(LIST1_INSTANCE_ID_BA, list1); - RpcResult ret = modification.commit().get(); - assertNotNull(ret); - assertEquals(TransactionStatus.COMMITED, ret.getResult()); + transaction.put(LogicalDatastoreType.OPERATIONAL, LIST1_INSTANCE_ID_BA, list1, true); + transaction.submit().get(5, TimeUnit.SECONDS); - DataObject readList1 = baDataService.readConfigurationData(LIST1_INSTANCE_ID_BA); - assertNotNull("Readed table should not be nul.", readList1); - assertTrue(readList1 instanceof List1); + Optional readList1 = dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.OPERATIONAL, + LIST1_INSTANCE_ID_BA).get(1000, TimeUnit.MILLISECONDS); + assertTrue(readList1.isPresent()); - DataObject readList11 = baDataService.readConfigurationData(LIST11_INSTANCE_ID_BA); + Optional readList11 = dataBroker.newReadOnlyTransaction().read( + LogicalDatastoreType.OPERATIONAL, LIST11_INSTANCE_ID_BA).get(5, TimeUnit.SECONDS); assertNotNull("Readed flow should not be null.",readList11); - assertTrue(readList11 instanceof List11); - assertEquals(list11, readList11); - + assertTrue(readList11.isPresent()); + assertEquals(list11, readList11.get()); } }