Search in sources :

Example 56 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 copyBuilderWithAugmenationsTest.

@Test
public void copyBuilderWithAugmenationsTest() {
    final TopLevelList manuallyConstructed = new TopLevelListBuilder().withKey(TOP_FOO_KEY).addAugmentation(new TreeComplexUsesAugmentBuilder(createComplexData()).build()).build();
    final Entry<YangInstanceIdentifier, NormalizedNode> entry = codecContext.toNormalizedNode(BA_TOP_LEVEL_LIST, manuallyConstructed);
    final TopLevelList deserialized = (TopLevelList) codecContext.fromNormalizedNode(entry.getKey(), entry.getValue()).getValue();
    assertEquals(manuallyConstructed, deserialized);
    final TopLevelList copiedFromDeserialized = new TopLevelListBuilder(deserialized).build();
    assertEquals(manuallyConstructed, copiedFromDeserialized);
}
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) 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) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) Test(org.junit.Test)

Example 57 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 LazyBindingListTest method testSingletonList.

@Test
public void testSingletonList() {
    final TopLevelList expected = new TopLevelListBuilder().setName("test").setNestedList(List.of(new NestedListBuilder().setName(String.valueOf("one")).build())).build();
    final TopLevelList actual = thereAndBackAgain(InstanceIdentifier.create(Top.class).child(TopLevelList.class, expected.key()), expected);
    final List<NestedList> list = actual.getNestedList();
    assertThat(list, not(instanceOf(LazyBindingList.class)));
    assertEquals(expected.getNestedList(), list);
}
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) NestedList(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.top.level.list.NestedList) 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 58 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 LazyBindingMapTest method testLookupValue.

@Test
public void testLookupValue() {
    final Map<TopLevelListKey, TopLevelList> list = prepareData().getTopLevelList();
    for (TopLevelList val : TOP.getTopLevelList().values()) {
        assertTrue(list.containsValue(val));
    }
    assertFalse(list.containsValue(new TopLevelListBuilder().setName("blah").build()));
    // We checked this key, but this is a different object
    assertFalse(list.containsValue(new TopLevelListBuilder(TOP.getTopLevelList().values().iterator().next()).setNestedList(List.of(new NestedListBuilder().setName("foo").build())).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) NestedListBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.top.level.list.NestedListBuilder) TopLevelListKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelListKey) Test(org.junit.Test)

Example 59 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 LazyBindingMapTest method prepareTop.

@BeforeClass
public static void prepareTop() {
    final Map<TopLevelListKey, TopLevelList> map = new HashMap<>();
    for (int i = 0; i < 2 * LazyBindingMap.LAZY_CUTOFF; i++) {
        final TopLevelList item = new TopLevelListBuilder().setName(String.valueOf(i)).build();
        map.put(item.key(), item);
    }
    TOP = new TopBuilder().setTopLevelList(map).build();
}
Also used : TopLevelListBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelListBuilder) TopBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.TopBuilder) HashMap(java.util.HashMap) TopLevelList(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelList) TopLevelListKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelListKey) BeforeClass(org.junit.BeforeClass)

Example 60 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 LazyBindingMapTest method testLookupKey.

@Test
public void testLookupKey() {
    final Map<TopLevelListKey, TopLevelList> list = prepareData().getTopLevelList();
    for (TopLevelListKey key : TOP.getTopLevelList().keySet()) {
        assertTrue(list.containsKey(key));
    }
    assertFalse(list.containsKey(new TopLevelListKey("blah")));
}
Also used : TopLevelList(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelList) TopLevelListKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelListKey) 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