Search in sources :

Example 16 with TopLevelList

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelList in project mdsal by opendaylight.

the class ManagedNewTransactionRunnerImplTest method testCallWithNewTypedWriteOnlyTransactionAndSubmitPutSuccessfully.

@Test
public void testCallWithNewTypedWriteOnlyTransactionAndSubmitPutSuccessfully() throws Exception {
    TopLevelList data = newTestDataObject();
    managedNewTransactionRunner.callWithNewWriteOnlyTransactionAndSubmit(OPERATIONAL, writeTx -> writeTx.put(TEST_PATH, data)).get();
    assertEquals(data, syncRead(LogicalDatastoreType.OPERATIONAL, TEST_PATH));
}
Also used : Assert.assertThrows(org.junit.Assert.assertThrows) ListsBindingUtils.topLevelList(org.opendaylight.mdsal.binding.test.model.util.ListsBindingUtils.topLevelList) TreeComplexUsesAugment(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.TreeComplexUsesAugment) AbstractConcurrentDataBrokerTest(org.opendaylight.mdsal.binding.dom.adapter.test.AbstractConcurrentDataBrokerTest) DataBrokerFailuresImpl(org.opendaylight.mdsal.binding.testutils.DataBrokerFailuresImpl) CoreMatchers.instanceOf(org.hamcrest.CoreMatchers.instanceOf) Future(java.util.concurrent.Future) ReadTransaction(org.opendaylight.mdsal.binding.api.ReadTransaction) TopLevelList(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelList) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) DataObject(org.opendaylight.yangtools.yang.binding.DataObject) TreeComplexUsesAugmentBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.TreeComplexUsesAugmentBuilder) Before(org.junit.Before) ListsBindingUtils.path(org.opendaylight.mdsal.binding.test.model.util.ListsBindingUtils.path) IOException(java.io.IOException) Test(org.junit.Test) TransactionCommitFailedException(org.opendaylight.mdsal.common.api.TransactionCommitFailedException) ExecutionException(java.util.concurrent.ExecutionException) OptimisticLockFailedException(org.opendaylight.mdsal.common.api.OptimisticLockFailedException) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) ContainerWithUsesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.complex.from.grouping.ContainerWithUsesBuilder) LogicalDatastoreType(org.opendaylight.mdsal.common.api.LogicalDatastoreType) Optional(java.util.Optional) TOP_FOO_KEY(org.opendaylight.mdsal.binding.test.model.util.ListsBindingUtils.TOP_FOO_KEY) Assert.assertEquals(org.junit.Assert.assertEquals) OPERATIONAL(org.opendaylight.mdsal.binding.util.Datastore.OPERATIONAL) DataBroker(org.opendaylight.mdsal.binding.api.DataBroker) TopLevelList(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelList) AbstractConcurrentDataBrokerTest(org.opendaylight.mdsal.binding.dom.adapter.test.AbstractConcurrentDataBrokerTest) Test(org.junit.Test)

Example 17 with TopLevelList

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelList in project mdsal by opendaylight.

the class ManagedNewTransactionRunnerImplTest method testCallWithNewReadTransactionAndCloseReadSuccessfully.

@Test
public void testCallWithNewReadTransactionAndCloseReadSuccessfully() throws Exception {
    TopLevelList data = newTestDataObject();
    managedNewTransactionRunner.callWithNewWriteOnlyTransactionAndSubmit(OPERATIONAL, tx -> tx.put(TEST_PATH, data)).get();
    assertEquals(data, managedNewTransactionRunner.applyWithNewReadOnlyTransactionAndClose(OPERATIONAL, tx -> tx.read(TEST_PATH)).get().get());
}
Also used : Assert.assertThrows(org.junit.Assert.assertThrows) ListsBindingUtils.topLevelList(org.opendaylight.mdsal.binding.test.model.util.ListsBindingUtils.topLevelList) TreeComplexUsesAugment(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.TreeComplexUsesAugment) AbstractConcurrentDataBrokerTest(org.opendaylight.mdsal.binding.dom.adapter.test.AbstractConcurrentDataBrokerTest) DataBrokerFailuresImpl(org.opendaylight.mdsal.binding.testutils.DataBrokerFailuresImpl) CoreMatchers.instanceOf(org.hamcrest.CoreMatchers.instanceOf) Future(java.util.concurrent.Future) ReadTransaction(org.opendaylight.mdsal.binding.api.ReadTransaction) TopLevelList(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelList) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) DataObject(org.opendaylight.yangtools.yang.binding.DataObject) TreeComplexUsesAugmentBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.TreeComplexUsesAugmentBuilder) Before(org.junit.Before) ListsBindingUtils.path(org.opendaylight.mdsal.binding.test.model.util.ListsBindingUtils.path) IOException(java.io.IOException) Test(org.junit.Test) TransactionCommitFailedException(org.opendaylight.mdsal.common.api.TransactionCommitFailedException) ExecutionException(java.util.concurrent.ExecutionException) OptimisticLockFailedException(org.opendaylight.mdsal.common.api.OptimisticLockFailedException) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) ContainerWithUsesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.complex.from.grouping.ContainerWithUsesBuilder) LogicalDatastoreType(org.opendaylight.mdsal.common.api.LogicalDatastoreType) Optional(java.util.Optional) TOP_FOO_KEY(org.opendaylight.mdsal.binding.test.model.util.ListsBindingUtils.TOP_FOO_KEY) Assert.assertEquals(org.junit.Assert.assertEquals) OPERATIONAL(org.opendaylight.mdsal.binding.util.Datastore.OPERATIONAL) DataBroker(org.opendaylight.mdsal.binding.api.DataBroker) TopLevelList(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelList) AbstractConcurrentDataBrokerTest(org.opendaylight.mdsal.binding.dom.adapter.test.AbstractConcurrentDataBrokerTest) Test(org.junit.Test)

Example 18 with TopLevelList

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelList in project mdsal by opendaylight.

the class ManagedNewTransactionRunnerImplTest method testCallWithNewTypedReadWriteTransactionAndSubmitPutSuccessfully.

@Test
public void testCallWithNewTypedReadWriteTransactionAndSubmitPutSuccessfully() throws Exception {
    TopLevelList data = newTestDataObject();
    managedNewTransactionRunner.callWithNewReadWriteTransactionAndSubmit(OPERATIONAL, tx -> tx.put(TEST_PATH, data)).get();
    assertEquals(data, syncRead(LogicalDatastoreType.OPERATIONAL, TEST_PATH));
}
Also used : Assert.assertThrows(org.junit.Assert.assertThrows) ListsBindingUtils.topLevelList(org.opendaylight.mdsal.binding.test.model.util.ListsBindingUtils.topLevelList) TreeComplexUsesAugment(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.TreeComplexUsesAugment) AbstractConcurrentDataBrokerTest(org.opendaylight.mdsal.binding.dom.adapter.test.AbstractConcurrentDataBrokerTest) DataBrokerFailuresImpl(org.opendaylight.mdsal.binding.testutils.DataBrokerFailuresImpl) CoreMatchers.instanceOf(org.hamcrest.CoreMatchers.instanceOf) Future(java.util.concurrent.Future) ReadTransaction(org.opendaylight.mdsal.binding.api.ReadTransaction) TopLevelList(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelList) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) DataObject(org.opendaylight.yangtools.yang.binding.DataObject) TreeComplexUsesAugmentBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.TreeComplexUsesAugmentBuilder) Before(org.junit.Before) ListsBindingUtils.path(org.opendaylight.mdsal.binding.test.model.util.ListsBindingUtils.path) IOException(java.io.IOException) Test(org.junit.Test) TransactionCommitFailedException(org.opendaylight.mdsal.common.api.TransactionCommitFailedException) ExecutionException(java.util.concurrent.ExecutionException) OptimisticLockFailedException(org.opendaylight.mdsal.common.api.OptimisticLockFailedException) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) ContainerWithUsesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.complex.from.grouping.ContainerWithUsesBuilder) LogicalDatastoreType(org.opendaylight.mdsal.common.api.LogicalDatastoreType) Optional(java.util.Optional) TOP_FOO_KEY(org.opendaylight.mdsal.binding.test.model.util.ListsBindingUtils.TOP_FOO_KEY) Assert.assertEquals(org.junit.Assert.assertEquals) OPERATIONAL(org.opendaylight.mdsal.binding.util.Datastore.OPERATIONAL) DataBroker(org.opendaylight.mdsal.binding.api.DataBroker) TopLevelList(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelList) AbstractConcurrentDataBrokerTest(org.opendaylight.mdsal.binding.dom.adapter.test.AbstractConcurrentDataBrokerTest) Test(org.junit.Test)

Example 19 with TopLevelList

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelList in project mdsal by opendaylight.

the class ManagedNewTransactionRunnerImplTest method testApplyWithNewReadWriteTransactionAndSubmitPutSuccessfully.

@Test
public void testApplyWithNewReadWriteTransactionAndSubmitPutSuccessfully() throws Exception {
    TopLevelList data = newTestDataObject();
    assertEquals(1, (long) managedNewTransactionRunner.applyWithNewReadWriteTransactionAndSubmit(OPERATIONAL, tx -> {
        tx.put(TEST_PATH, data);
        return 1;
    }).get());
    assertEquals(data, syncRead(LogicalDatastoreType.OPERATIONAL, TEST_PATH));
}
Also used : Assert.assertThrows(org.junit.Assert.assertThrows) ListsBindingUtils.topLevelList(org.opendaylight.mdsal.binding.test.model.util.ListsBindingUtils.topLevelList) TreeComplexUsesAugment(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.TreeComplexUsesAugment) AbstractConcurrentDataBrokerTest(org.opendaylight.mdsal.binding.dom.adapter.test.AbstractConcurrentDataBrokerTest) DataBrokerFailuresImpl(org.opendaylight.mdsal.binding.testutils.DataBrokerFailuresImpl) CoreMatchers.instanceOf(org.hamcrest.CoreMatchers.instanceOf) Future(java.util.concurrent.Future) ReadTransaction(org.opendaylight.mdsal.binding.api.ReadTransaction) TopLevelList(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelList) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) DataObject(org.opendaylight.yangtools.yang.binding.DataObject) TreeComplexUsesAugmentBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.TreeComplexUsesAugmentBuilder) Before(org.junit.Before) ListsBindingUtils.path(org.opendaylight.mdsal.binding.test.model.util.ListsBindingUtils.path) IOException(java.io.IOException) Test(org.junit.Test) TransactionCommitFailedException(org.opendaylight.mdsal.common.api.TransactionCommitFailedException) ExecutionException(java.util.concurrent.ExecutionException) OptimisticLockFailedException(org.opendaylight.mdsal.common.api.OptimisticLockFailedException) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) ContainerWithUsesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.complex.from.grouping.ContainerWithUsesBuilder) LogicalDatastoreType(org.opendaylight.mdsal.common.api.LogicalDatastoreType) Optional(java.util.Optional) TOP_FOO_KEY(org.opendaylight.mdsal.binding.test.model.util.ListsBindingUtils.TOP_FOO_KEY) Assert.assertEquals(org.junit.Assert.assertEquals) OPERATIONAL(org.opendaylight.mdsal.binding.util.Datastore.OPERATIONAL) DataBroker(org.opendaylight.mdsal.binding.api.DataBroker) TopLevelList(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelList) AbstractConcurrentDataBrokerTest(org.opendaylight.mdsal.binding.dom.adapter.test.AbstractConcurrentDataBrokerTest) Test(org.junit.Test)

Example 20 with TopLevelList

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelList in project mdsal by opendaylight.

the class Bug1418AugmentationTest method complexAugmentationCreatedTest.

@Test
public void complexAugmentationCreatedTest() {
    TreeComplexUsesAugment complexUsesAugment = complexUsesAugment(LIST_VIA_USES_KEY);
    final TestListener<TreeComplexUsesAugment> listener = createListener(CONFIGURATION, COMPLEX_AUGMENT, added(path(TOP_FOO_KEY, TreeComplexUsesAugment.class), complexUsesAugment));
    WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
    writeTx.put(CONFIGURATION, TOP, top());
    writeTx.put(CONFIGURATION, TOP_FOO, topLevelList(new TopLevelListKey(TOP_FOO_KEY)));
    writeTx.put(CONFIGURATION, COMPLEX_AUGMENT, complexUsesAugment);
    assertCommit(writeTx.commit());
    listener.verify();
}
Also used : WriteTransaction(org.opendaylight.mdsal.binding.api.WriteTransaction) TreeComplexUsesAugment(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.TreeComplexUsesAugment) TopLevelListKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelListKey) AbstractDataTreeChangeListenerTest(org.opendaylight.mdsal.binding.dom.adapter.test.AbstractDataTreeChangeListenerTest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)61 TopLevelList (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelList)32 DataBroker (org.opendaylight.mdsal.binding.api.DataBroker)26 Assert.assertEquals (org.junit.Assert.assertEquals)23 LogicalDatastoreType (org.opendaylight.mdsal.common.api.LogicalDatastoreType)23 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)22 OptimisticLockFailedException (org.opendaylight.mdsal.common.api.OptimisticLockFailedException)21 TopLevelList (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList)20 WriteTransaction (org.opendaylight.mdsal.binding.api.WriteTransaction)18 DataObject (org.opendaylight.yangtools.yang.binding.DataObject)14 ManagedNewTransactionRunner (org.opendaylight.genius.infra.ManagedNewTransactionRunner)13 ExecutionException (java.util.concurrent.ExecutionException)12 Assert.assertThrows (org.junit.Assert.assertThrows)12 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)12 Before (org.junit.Before)11 AbstractDataTreeChangeListenerTest (org.opendaylight.mdsal.binding.dom.adapter.test.AbstractDataTreeChangeListenerTest)11 TopLevelListKey (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelListKey)11 IOException (java.io.IOException)10 OPERATIONAL (org.opendaylight.mdsal.binding.util.Datastore.OPERATIONAL)10 TreeComplexUsesAugmentBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.TreeComplexUsesAugmentBuilder)10