Search in sources :

Example 16 with TopLevelListKey

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelListKey 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 17 with TopLevelListKey

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelListKey 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 18 with TopLevelListKey

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelListKey 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)

Example 19 with TopLevelListKey

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

the class Bug1418AugmentationTest method leafOnlyAugmentationUpdatedTest.

@Test
public void leafOnlyAugmentationUpdatedTest() {
    WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
    writeTx.put(CONFIGURATION, TOP, top());
    writeTx.put(CONFIGURATION, TOP_FOO, topLevelList(new TopLevelListKey(TOP_FOO_KEY)));
    TreeLeafOnlyUsesAugment leafOnlyUsesAugmentBefore = leafOnlyUsesAugment("test leaf");
    writeTx.put(CONFIGURATION, SIMPLE_AUGMENT, leafOnlyUsesAugmentBefore);
    assertCommit(writeTx.commit());
    TreeLeafOnlyUsesAugment leafOnlyUsesAugmentAfter = leafOnlyUsesAugment("test leaf changed");
    final TestListener<TreeLeafOnlyUsesAugment> listener = createListener(CONFIGURATION, SIMPLE_AUGMENT, added(path(TOP_FOO_KEY, TreeLeafOnlyUsesAugment.class), leafOnlyUsesAugmentBefore), replaced(path(TOP_FOO_KEY, TreeLeafOnlyUsesAugment.class), leafOnlyUsesAugmentBefore, leafOnlyUsesAugmentAfter));
    writeTx = getDataBroker().newWriteOnlyTransaction();
    writeTx.put(CONFIGURATION, SIMPLE_AUGMENT, leafOnlyUsesAugmentAfter);
    assertCommit(writeTx.commit());
    listener.verify();
}
Also used : WriteTransaction(org.opendaylight.mdsal.binding.api.WriteTransaction) TreeLeafOnlyUsesAugment(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.TreeLeafOnlyUsesAugment) 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)

Example 20 with TopLevelListKey

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

the class Bug4494Test method testDelete.

@Test
public void testDelete() throws Exception {
    DataBroker dataBroker = getDataBroker();
    WriteTransaction writeTransaction = dataBroker.newWriteOnlyTransaction();
    TopLevelList list = new TopLevelListBuilder().setName("name").build();
    TopBuilder builder = new TopBuilder().setTopLevelList(Map.of(list.key(), list));
    writeTransaction.put(LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.create(Top.class), builder.build());
    assertCommit(writeTransaction.commit());
    InstanceIdentifier<TopLevelList> id = InstanceIdentifier.builder(Top.class).child(TopLevelList.class, new TopLevelListKey("name")).build();
    ReadWriteTransaction writeTransaction1 = dataBroker.newReadWriteTransaction();
    writeTransaction1.delete(LogicalDatastoreType.OPERATIONAL, id);
    assertCommit(writeTransaction1.commit());
    ReadWriteTransaction writeTransaction2 = dataBroker.newReadWriteTransaction();
    writeTransaction2.delete(LogicalDatastoreType.OPERATIONAL, id);
    assertCommit(writeTransaction2.commit());
}
Also used : ReadWriteTransaction(org.opendaylight.mdsal.binding.api.ReadWriteTransaction) WriteTransaction(org.opendaylight.mdsal.binding.api.WriteTransaction) 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) Top(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.Top) TopLevelList(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelList) ReadWriteTransaction(org.opendaylight.mdsal.binding.api.ReadWriteTransaction) DataBroker(org.opendaylight.mdsal.binding.api.DataBroker) TopLevelListKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelListKey) Test(org.junit.Test) AbstractDataBrokerTest(org.opendaylight.mdsal.binding.dom.adapter.test.AbstractDataBrokerTest)

Aggregations

Test (org.junit.Test)14 TopLevelListKey (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelListKey)11 WriteTransaction (org.opendaylight.mdsal.binding.api.WriteTransaction)7 TopLevelListKey (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListKey)7 TopLevelList (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelList)6 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)5 AbstractDataChangeListenerTest (org.opendaylight.controller.md.sal.binding.test.AbstractDataChangeListenerTest)5 AbstractDataTreeChangeListenerTest (org.opendaylight.mdsal.binding.dom.adapter.test.AbstractDataTreeChangeListenerTest)5 TopLevelListBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelListBuilder)5 DataObject (org.opendaylight.yangtools.yang.binding.DataObject)5 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)5 TopLevelListBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListBuilder)4 TreeLeafOnlyUsesAugment (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.TreeLeafOnlyUsesAugment)3 TopBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.TopBuilder)3 DataBroker (org.opendaylight.mdsal.binding.api.DataBroker)2 ReadWriteTransaction (org.opendaylight.mdsal.binding.api.ReadWriteTransaction)2 AbstractDataBrokerTest (org.opendaylight.mdsal.binding.dom.adapter.test.AbstractDataBrokerTest)2 ListViaUses (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.complex.from.grouping.ListViaUses)2 TwoLevelListChangedBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.TwoLevelListChangedBuilder)2 TreeComplexUsesAugment (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.TreeComplexUsesAugment)2