Search in sources :

Example 11 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 CachingCodecTest method createList.

private static Map<TopLevelListKey, TopLevelList> createList(final int num) {
    final ImmutableMap.Builder<TopLevelListKey, TopLevelList> builder = ImmutableMap.builder();
    for (int i = 0; i < num; i++) {
        final TopLevelListKey key = new TopLevelListKey("test-" + i);
        builder.put(key, new TopLevelListBuilder().withKey(key).build());
    }
    return builder.build();
}
Also used : TopLevelListBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelListBuilder) TopLevelList(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelList) ImmutableMap(com.google.common.collect.ImmutableMap) TopLevelListKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelListKey)

Example 12 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 RetryingManagedNewTransactionRunnerTest method testApplyWithNewReadWriteTransactionReadFailedException.

@Test
public void testApplyWithNewReadWriteTransactionReadFailedException() throws Exception {
    testableDataBroker.failReads(2, new ReadFailedException("bada boum bam!"));
    TopLevelList data = newTestDataObject();
    assertEquals(data, managedNewTransactionRunner.applyWithNewReadWriteTransactionAndSubmit(OPERATIONAL, tx -> {
        tx.put(TEST_PATH, data);
        return tx.read(TEST_PATH).get().get();
    }).get());
    assertEquals(data, syncRead(LogicalDatastoreType.OPERATIONAL, TEST_PATH));
}
Also used : ReadFailedException(org.opendaylight.mdsal.common.api.ReadFailedException) TopLevelList(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelList) Test(org.junit.Test)

Example 13 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 RetryingManagedNewTransactionRunnerTest method testCallWithNewTypedWriteOnlyTransactionOptimisticLockFailedException.

@Override
public void testCallWithNewTypedWriteOnlyTransactionOptimisticLockFailedException() throws Exception {
    // contrary to the super() test implementation for (just) ManagedNewTransactionRunnerImpl, in the parent class
    // here we expect the x2 OptimisticLockFailedException to be retried, and then eventually succeed:
    testableDataBroker.failCommits(2, new OptimisticLockFailedException("bada boum bam!"));
    TopLevelList data = newTestDataObject();
    managedNewTransactionRunner.callWithNewWriteOnlyTransactionAndSubmit(OPERATIONAL, writeTx -> writeTx.put(TEST_PATH, data)).get();
    assertEquals(data, syncRead(LogicalDatastoreType.OPERATIONAL, TEST_PATH));
}
Also used : ReadFailedException(org.opendaylight.mdsal.common.api.ReadFailedException) OptimisticLockFailedException(org.opendaylight.mdsal.common.api.OptimisticLockFailedException) TopLevelList(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelList) LogicalDatastoreType(org.opendaylight.mdsal.common.api.LogicalDatastoreType) Test(org.junit.Test) 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) OptimisticLockFailedException(org.opendaylight.mdsal.common.api.OptimisticLockFailedException)

Example 14 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 TransactionAdapterTest method testAdaptedReadWriteTransactionPutsSuccessfully.

@Test
public void testAdaptedReadWriteTransactionPutsSuccessfully() throws Exception {
    TopLevelList data = newTestDataObject();
    managedNewTransactionRunner.callWithNewReadWriteTransactionAndSubmit(OPERATIONAL, writeTx -> TransactionAdapter.toReadWriteTransaction(writeTx).put(LogicalDatastoreType.OPERATIONAL, TEST_PATH, data)).get();
    assertEquals(data, syncRead(LogicalDatastoreType.OPERATIONAL, TEST_PATH));
}
Also used : Assert.assertThrows(org.junit.Assert.assertThrows) ListsBindingUtils.path(org.opendaylight.mdsal.binding.test.model.util.ListsBindingUtils.path) ListsBindingUtils.topLevelList(org.opendaylight.mdsal.binding.test.model.util.ListsBindingUtils.topLevelList) Test(org.junit.Test) 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) ExecutionException(java.util.concurrent.ExecutionException) 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) 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) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) TOP_FOO_KEY(org.opendaylight.mdsal.binding.test.model.util.ListsBindingUtils.TOP_FOO_KEY) DataObject(org.opendaylight.yangtools.yang.binding.DataObject) Assert.assertEquals(org.junit.Assert.assertEquals) OPERATIONAL(org.opendaylight.mdsal.binding.util.Datastore.OPERATIONAL) TreeComplexUsesAugmentBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.TreeComplexUsesAugmentBuilder) Before(org.junit.Before) 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) Test(org.junit.Test) AbstractConcurrentDataBrokerTest(org.opendaylight.mdsal.binding.dom.adapter.test.AbstractConcurrentDataBrokerTest)

Example 15 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 TransactionAdapterTest method testAdaptedWriteTransactionPutsSuccessfully.

@Test
public void testAdaptedWriteTransactionPutsSuccessfully() throws Exception {
    TopLevelList data = newTestDataObject();
    managedNewTransactionRunner.callWithNewWriteOnlyTransactionAndSubmit(OPERATIONAL, writeTx -> TransactionAdapter.toWriteTransaction(writeTx).put(LogicalDatastoreType.OPERATIONAL, TEST_PATH, data)).get();
    assertEquals(data, syncRead(LogicalDatastoreType.OPERATIONAL, TEST_PATH));
}
Also used : Assert.assertThrows(org.junit.Assert.assertThrows) ListsBindingUtils.path(org.opendaylight.mdsal.binding.test.model.util.ListsBindingUtils.path) ListsBindingUtils.topLevelList(org.opendaylight.mdsal.binding.test.model.util.ListsBindingUtils.topLevelList) Test(org.junit.Test) 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) ExecutionException(java.util.concurrent.ExecutionException) 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) 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) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) TOP_FOO_KEY(org.opendaylight.mdsal.binding.test.model.util.ListsBindingUtils.TOP_FOO_KEY) DataObject(org.opendaylight.yangtools.yang.binding.DataObject) Assert.assertEquals(org.junit.Assert.assertEquals) OPERATIONAL(org.opendaylight.mdsal.binding.util.Datastore.OPERATIONAL) TreeComplexUsesAugmentBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.TreeComplexUsesAugmentBuilder) Before(org.junit.Before) 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) Test(org.junit.Test) AbstractConcurrentDataBrokerTest(org.opendaylight.mdsal.binding.dom.adapter.test.AbstractConcurrentDataBrokerTest)

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