Search in sources :

Example 1 with TopLevelListBuilder

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

the class DataTreeChangeListenerTest method testWildcardNotificationOfPreexistingData.

@SuppressWarnings("unchecked")
@Test
public void testWildcardNotificationOfPreexistingData() throws Exception {
    InstanceIdentifier<Top> id = InstanceIdentifier.builder(Top.class).build();
    ArrayList<TopLevelList> list = new ArrayList<>();
    list.add(new TopLevelListBuilder().setName("name").build());
    TopBuilder builder = new TopBuilder().setTopLevelList(list);
    DataBroker dataBroker = getDataBroker();
    WriteTransaction writeTransaction = dataBroker.newWriteOnlyTransaction();
    writeTransaction.put(LogicalDatastoreType.OPERATIONAL, id, builder.build());
    assertCommit(writeTransaction.submit());
    DataTreeChangeListener<TopLevelList> listener = mock(DataTreeChangeListener.class);
    InstanceIdentifier<TopLevelList> wildcard = InstanceIdentifier.builder(Top.class).child(TopLevelList.class).build();
    dataBroker.registerDataTreeChangeListener(new DataTreeIdentifier<>(LogicalDatastoreType.OPERATIONAL, wildcard), listener);
    verify(listener, timeout(1000)).onDataTreeChanged(Matchers.anyObject());
}
Also used : TopLevelListBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListBuilder) WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) TopBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.TopBuilder) Top(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top) TopLevelList(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList) ArrayList(java.util.ArrayList) DataBroker(org.opendaylight.controller.md.sal.binding.api.DataBroker) AbstractConcurrentDataBrokerTest(org.opendaylight.controller.md.sal.binding.test.AbstractConcurrentDataBrokerTest) Test(org.junit.Test)

Example 2 with TopLevelListBuilder

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

the class ForwardedNotificationAdapterTest method createTestData.

private TwoLevelListChanged createTestData() {
    final TwoLevelListChangedBuilder tb = new TwoLevelListChangedBuilder();
    tb.setTopLevelList(ImmutableList.of(new TopLevelListBuilder().setKey(new TopLevelListKey("test")).build()));
    return tb.build();
}
Also used : TopLevelListBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListBuilder) TwoLevelListChangedBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.TwoLevelListChangedBuilder) TopLevelListKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListKey)

Example 3 with TopLevelListBuilder

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

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

the class ListInsertionDataChangeListenerTest method topSubtreeModified.

private static Function<DataTreeModification<Top>, Boolean> topSubtreeModified(final TopLevelList topFoo, final TopLevelList topBar) {
    return match(ModificationType.SUBTREE_MODIFIED, TOP, (Function<Top, Boolean>) dataBefore -> Objects.equals(top(topFoo), dataBefore), dataAfter -> {
        Set<TopLevelList> expList = new HashSet<>(top(topBar, topFoo).getTopLevelList().values());
        Set<TopLevelList> actualList = dataAfter.getTopLevelList().values().stream().map(list -> new TopLevelListBuilder(list).build()).collect(Collectors.toSet());
        return expList.equals(actualList);
    });
}
Also used : AbstractDataTreeChangeListenerTest(org.opendaylight.mdsal.binding.dom.adapter.test.AbstractDataTreeChangeListenerTest) ImmutableSet(com.google.common.collect.ImmutableSet) ReadWriteTransaction(org.opendaylight.mdsal.binding.api.ReadWriteTransaction) ListsBindingUtils.top(org.opendaylight.mdsal.binding.test.model.util.ListsBindingUtils.top) ListsBindingUtils.topLevelList(org.opendaylight.mdsal.binding.test.model.util.ListsBindingUtils.topLevelList) CONFIGURATION(org.opendaylight.mdsal.common.api.LogicalDatastoreType.CONFIGURATION) WriteTransaction(org.opendaylight.mdsal.binding.api.WriteTransaction) BindingReflections(org.opendaylight.mdsal.binding.spec.reflect.BindingReflections) Set(java.util.Set) Test(org.junit.Test) Top(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.Top) Function(java.util.function.Function) Collectors(java.util.stream.Collectors) TopLevelListBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelListBuilder) HashSet(java.util.HashSet) Objects(java.util.Objects) YangModuleInfo(org.opendaylight.yangtools.yang.binding.YangModuleInfo) 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) DataTreeModification(org.opendaylight.mdsal.binding.api.DataTreeModification) TOP_FOO_KEY(org.opendaylight.mdsal.binding.test.model.util.ListsBindingUtils.TOP_FOO_KEY) TOP_BAR_KEY(org.opendaylight.mdsal.binding.test.model.util.ListsBindingUtils.TOP_BAR_KEY) ModificationType(org.opendaylight.mdsal.binding.api.DataObjectModification.ModificationType) Before(org.junit.Before) TopLevelListBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelListBuilder) 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) HashSet(java.util.HashSet)

Example 5 with TopLevelListBuilder

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

the class Mdsal108Test method testDelete.

@Test
public void testDelete() {
    DataBroker dataBroker = getDataBroker();
    WriteTransaction writeTransaction = dataBroker.newWriteOnlyTransaction();
    final TopLevelList item = new TopLevelListBuilder().setName("name").build();
    TopBuilder builder = new TopBuilder().setTopLevelList(Collections.singletonMap(item.key(), item));
    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)16 TopLevelListBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelListBuilder)15 TopLevelList (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelList)13 TopLevelListBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListBuilder)7 TopLevelListKey (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelListKey)5 NestedListBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.top.level.list.NestedListBuilder)5 DataObject (org.opendaylight.yangtools.yang.binding.DataObject)4 DataBroker (org.opendaylight.controller.md.sal.binding.api.DataBroker)3 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)3 ReadWriteTransaction (org.opendaylight.mdsal.binding.api.ReadWriteTransaction)3 WriteTransaction (org.opendaylight.mdsal.binding.api.WriteTransaction)3 Top (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.Top)3 TopBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.TopBuilder)3 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)3 YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)3 NormalizedNode (org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode)3 ArrayList (java.util.ArrayList)2 AbstractDataServiceTest (org.opendaylight.controller.sal.binding.test.AbstractDataServiceTest)2 DataBroker (org.opendaylight.mdsal.binding.api.DataBroker)2 AbstractDataBrokerTest (org.opendaylight.mdsal.binding.dom.adapter.test.AbstractDataBrokerTest)2