Search in sources :

Example 51 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 genius 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, singleTransactionDataBroker.syncRead(LogicalDatastoreType.OPERATIONAL, TEST_PATH));
}
Also used : SingleTransactionDataBroker(org.opendaylight.genius.datastoreutils.SingleTransactionDataBroker) Assert.assertThrows(org.junit.Assert.assertThrows) ListsBindingUtils.topLevelList(org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.topLevelList) ContainerWithUsesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.complex.from.grouping.ContainerWithUsesBuilder) TopLevelList(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList) DataBrokerTestModule(org.opendaylight.mdsal.binding.testutils.DataBrokerTestModule) ManagedNewTransactionRunnerImpl(org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl) Assert.fail(org.junit.Assert.fail) Before(org.junit.Before) TreeComplexUsesAugmentBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.TreeComplexUsesAugmentBuilder) TOP_FOO_KEY(org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.TOP_FOO_KEY) ManagedNewTransactionRunner(org.opendaylight.genius.infra.ManagedNewTransactionRunner) WriteTransaction(org.opendaylight.mdsal.binding.api.WriteTransaction) Assert.assertTrue(org.junit.Assert.assertTrue) IOException(java.io.IOException) Test(org.junit.Test) TreeComplexUsesAugment(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.TreeComplexUsesAugment) Truth.assertThat(com.google.common.truth.Truth.assertThat) DataBrokerFailuresImpl(org.opendaylight.genius.datastoreutils.testutils.DataBrokerFailuresImpl) ListsBindingUtils.path(org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.path) LogRule(org.opendaylight.infrautils.testutils.LogRule) TransactionCommitFailedException(org.opendaylight.mdsal.common.api.TransactionCommitFailedException) OPERATIONAL(org.opendaylight.genius.infra.Datastore.OPERATIONAL) ExecutionException(java.util.concurrent.ExecutionException) OptimisticLockFailedException(org.opendaylight.mdsal.common.api.OptimisticLockFailedException) Rule(org.junit.Rule) LogCaptureRule(org.opendaylight.infrautils.testutils.LogCaptureRule) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) LogicalDatastoreType(org.opendaylight.mdsal.common.api.LogicalDatastoreType) Assert(org.junit.Assert) Assert.assertEquals(org.junit.Assert.assertEquals) DataBroker(org.opendaylight.mdsal.binding.api.DataBroker) TopLevelList(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList) Test(org.junit.Test)

Example 52 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 genius 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 : SingleTransactionDataBroker(org.opendaylight.genius.datastoreutils.SingleTransactionDataBroker) Assert.assertThrows(org.junit.Assert.assertThrows) ListsBindingUtils.topLevelList(org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.topLevelList) ContainerWithUsesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.complex.from.grouping.ContainerWithUsesBuilder) TopLevelList(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList) DataBrokerTestModule(org.opendaylight.mdsal.binding.testutils.DataBrokerTestModule) ManagedNewTransactionRunnerImpl(org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl) Assert.fail(org.junit.Assert.fail) Before(org.junit.Before) TreeComplexUsesAugmentBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.TreeComplexUsesAugmentBuilder) TOP_FOO_KEY(org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.TOP_FOO_KEY) ManagedNewTransactionRunner(org.opendaylight.genius.infra.ManagedNewTransactionRunner) WriteTransaction(org.opendaylight.mdsal.binding.api.WriteTransaction) Assert.assertTrue(org.junit.Assert.assertTrue) IOException(java.io.IOException) Test(org.junit.Test) TreeComplexUsesAugment(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.TreeComplexUsesAugment) Truth.assertThat(com.google.common.truth.Truth.assertThat) DataBrokerFailuresImpl(org.opendaylight.genius.datastoreutils.testutils.DataBrokerFailuresImpl) ListsBindingUtils.path(org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.path) LogRule(org.opendaylight.infrautils.testutils.LogRule) TransactionCommitFailedException(org.opendaylight.mdsal.common.api.TransactionCommitFailedException) OPERATIONAL(org.opendaylight.genius.infra.Datastore.OPERATIONAL) ExecutionException(java.util.concurrent.ExecutionException) OptimisticLockFailedException(org.opendaylight.mdsal.common.api.OptimisticLockFailedException) Rule(org.junit.Rule) LogCaptureRule(org.opendaylight.infrautils.testutils.LogCaptureRule) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) LogicalDatastoreType(org.opendaylight.mdsal.common.api.LogicalDatastoreType) Assert(org.junit.Assert) Assert.assertEquals(org.junit.Assert.assertEquals) DataBroker(org.opendaylight.mdsal.binding.api.DataBroker) TopLevelList(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList) Test(org.junit.Test)

Example 53 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 EmptyLeafTest method testCaseWithEmptyLeafType.

@Test
public void testCaseWithEmptyLeafType() {
    final TopLevelList withEmptyCase = new TopLevelListBuilder().withKey(TOP_FOO_KEY).setChoiceInList(new EmptyLeafBuilder().setEmptyType(Empty.value()).build()).build();
    final Entry<YangInstanceIdentifier, NormalizedNode> dom = codecContext.toNormalizedNode(BA_TOP_LEVEL_LIST, withEmptyCase);
    final Entry<InstanceIdentifier<?>, DataObject> readed = codecContext.fromNormalizedNode(dom.getKey(), dom.getValue());
    final ChoiceInList list = ((TopLevelList) readed.getValue()).getChoiceInList();
    assertTrue(list instanceof EmptyLeaf);
    assertNotNull(((EmptyLeaf) list).getEmptyType());
}
Also used : TopLevelListBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelListBuilder) EmptyLeaf(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.top.top.level.list.choice.in.list.EmptyLeaf) DataObject(org.opendaylight.yangtools.yang.binding.DataObject) 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) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) ChoiceInList(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.top.level.list.ChoiceInList) EmptyLeafBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.top.top.level.list.choice.in.list.EmptyLeafBuilder) NormalizedNode(org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) Test(org.junit.Test)

Example 54 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 NormalizedNodeSerializeDeserializeTest method orderedLisFromNormalized.

@Test
public void orderedLisFromNormalized() {
    final MapEntryNode foo = mapEntryBuilder().withNodeIdentifier(NodeIdentifierWithPredicates.of(TOP_LEVEL_LIST_QNAME, TOP_LEVEL_LIST_KEY_QNAME, TOP_LEVEL_LIST_FOO_KEY_VALUE)).withChild(leafNode(TOP_LEVEL_LIST_KEY_QNAME, TOP_LEVEL_LIST_FOO_KEY_VALUE)).withChild(ImmutableUserMapNodeBuilder.create().withNodeIdentifier(new NodeIdentifier(NESTED_LIST_QNAME)).withChild(mapEntry(NESTED_LIST_QNAME, NESTED_LIST_KEY_QNAME, "foo")).withChild(mapEntry(NESTED_LIST_QNAME, NESTED_LIST_KEY_QNAME, "bar")).build()).build();
    final Entry<InstanceIdentifier<?>, DataObject> entry = codecContext.fromNormalizedNode(BI_TOP_LEVEL_LIST_FOO_PATH, foo);
    final TopLevelList topLevelList = new TopLevelListBuilder().withKey(TOP_LEVEL_LIST_FOO_KEY).setNestedList(List.of(new NestedListBuilder().withKey(new NestedListKey("foo")).build(), new NestedListBuilder().withKey(new NestedListKey("bar")).build())).build();
    assertEquals(topLevelList, entry.getValue());
}
Also used : TopLevelListBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelListBuilder) NestedListKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.top.level.list.NestedListKey) DataObject(org.opendaylight.yangtools.yang.binding.DataObject) TopLevelList(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelList) NodeIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) MapEntryNode(org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode) NestedListBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.top.level.list.NestedListBuilder) Test(org.junit.Test)

Example 55 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 AugmentationSubstitutionTest method augmentationInGroupingSubstituted.

@Test
public void augmentationInGroupingSubstituted() {
    final TopLevelList baRpc = new TopLevelListBuilder().withKey(TOP_FOO_KEY).addAugmentation(new RpcComplexUsesAugmentBuilder(createComplexData()).build()).build();
    final TopLevelList baTree = new TopLevelListBuilder().withKey(TOP_FOO_KEY).addAugmentation(new TreeComplexUsesAugmentBuilder(createComplexData()).build()).build();
    final NormalizedNode domTreeEntry = codecContext.toNormalizedNode(BA_TOP_LEVEL_LIST, baTree).getValue();
    final NormalizedNode domRpcEntry = codecContext.toNormalizedNode(BA_TOP_LEVEL_LIST, baRpc).getValue();
    assertEquals(domTreeEntry, domRpcEntry);
}
Also used : TopLevelListBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelListBuilder) RpcComplexUsesAugmentBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.RpcComplexUsesAugmentBuilder) TopLevelList(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelList) TreeComplexUsesAugmentBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.TreeComplexUsesAugmentBuilder) NormalizedNode(org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode) 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