Search in sources :

Example 6 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 RpcDataSerializationTest method testRpcInputToNormalized.

@Test
public void testRpcInputToNormalized() {
    final PutTopInput bindingOriginal = new PutTopInputBuilder().setTopLevelList(ImmutableMap.of(LIST_KEY, new TopLevelListBuilder().withKey(LIST_KEY).build())).build();
    final ContainerNode dom = codecContext.toNormalizedNodeRpcData(bindingOriginal);
    assertNotNull(dom);
    assertEquals(PutTopInput.QNAME, dom.getIdentifier().getNodeType());
    final DataObject bindingDeserialized = codecContext.fromNormalizedNodeRpcData(PUT_TOP_INPUT, dom);
    assertEquals(bindingOriginal, bindingDeserialized);
}
Also used : PutTopInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.PutTopInputBuilder) TopLevelListBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelListBuilder) DataObject(org.opendaylight.yangtools.yang.binding.DataObject) ContainerNode(org.opendaylight.yangtools.yang.data.api.schema.ContainerNode) PutTopInput(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.PutTopInput) Test(org.junit.Test)

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

@Test
public void orderedLisToNormalized() {
    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();
    final Entry<YangInstanceIdentifier, NormalizedNode> entry = codecContext.toNormalizedNode(BA_TOP_LEVEL_LIST, topLevelList);
    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();
    assertEquals(foo, 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) 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) NormalizedNode(org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode) 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) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) Test(org.junit.Test)

Example 8 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 LazyBindingListTest method testLazyList.

@Test
public void testLazyList() {
    final List<NestedList> nested = new ArrayList<>();
    for (int i = 0; i < 2 * LazyBindingList.LAZY_CUTOFF; ++i) {
        nested.add(new NestedListBuilder().setName(String.valueOf(i)).build());
    }
    final TopLevelList expected = new TopLevelListBuilder().setName("test").setNestedList(nested).build();
    final TopLevelList actual = thereAndBackAgain(InstanceIdentifier.create(Top.class).child(TopLevelList.class, expected.key()), expected);
    final List<NestedList> list = actual.getNestedList();
    assertThat(list, instanceOf(LazyBindingList.class));
    // Equality does all the right things to check happy paths
    assertEquals(expected.getNestedList(), list);
    assertEquals(expected.getNestedList().hashCode(), list.hashCode());
    // Make sure the list performs proper caching
    assertSame(list.get(LazyBindingList.LAZY_CUTOFF), list.get(LazyBindingList.LAZY_CUTOFF));
    // Test throws, just for completeness' sake
    assertThrows(UnsupportedOperationException.class, () -> list.add(null));
    assertThrows(UnsupportedOperationException.class, () -> list.addAll(null));
    assertThrows(UnsupportedOperationException.class, () -> list.addAll(0, null));
    assertThrows(UnsupportedOperationException.class, () -> list.remove(null));
    assertThrows(UnsupportedOperationException.class, () -> list.removeAll(null));
    assertThrows(UnsupportedOperationException.class, () -> list.replaceAll(null));
    assertThrows(UnsupportedOperationException.class, () -> list.retainAll(null));
    assertThrows(UnsupportedOperationException.class, () -> list.sort(null));
    assertThrows(UnsupportedOperationException.class, () -> list.clear());
}
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) ArrayList(java.util.ArrayList) 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 9 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 BrokerIntegrationTest method createTll.

private static TopLevelList createTll(final TopLevelListKey key) {
    TopLevelListBuilder ret = new TopLevelListBuilder();
    ret.setKey(key);
    return ret.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)

Example 10 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 ConcurrentImplicitCreateTest method testConcurrentCreate.

@Test
public void testConcurrentCreate() throws InterruptedException, ExecutionException, TimeoutException {
    DataBroker dataBroker = testContext.getDataBroker();
    WriteTransaction fooTx = dataBroker.newWriteOnlyTransaction();
    WriteTransaction barTx = dataBroker.newWriteOnlyTransaction();
    fooTx.put(LogicalDatastoreType.OPERATIONAL, FOO_PATH, new TopLevelListBuilder().setKey(FOO_KEY).build());
    barTx.put(LogicalDatastoreType.OPERATIONAL, BAR_PATH, new TopLevelListBuilder().setKey(BAR_KEY).build());
    fooTx.submit().get(5, TimeUnit.SECONDS);
    barTx.submit().get(5, TimeUnit.SECONDS);
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) TopLevelListBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListBuilder) DataBroker(org.opendaylight.controller.md.sal.binding.api.DataBroker) AbstractDataServiceTest(org.opendaylight.controller.sal.binding.test.AbstractDataServiceTest) Test(org.junit.Test)

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