3f7463a1d5d4542c5707e18ce6e89e11e10b02e0
[mdsal.git] / binding / mdsal-binding-dom-codec / src / test / java / org / opendaylight / mdsal / binding / dom / codec / impl / Mdsal668Test.java
1 /*
2  * Copyright (c) 2021 PANTHEON.tech, s.r.o. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.mdsal.binding.dom.codec.impl;
9
10 import static org.junit.Assert.assertEquals;
11
12 import java.util.List;
13 import org.junit.Test;
14 import org.opendaylight.yang.gen.v1.mdsal668.norev.Foo;
15 import org.opendaylight.yang.gen.v1.mdsal668.norev.FooBuilder;
16 import org.opendaylight.yang.gen.v1.mdsal668.norev.bar.Bar;
17 import org.opendaylight.yang.gen.v1.mdsal668.norev.bar.BarBuilder;
18 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
19 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
20 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue;
21 import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
22
23 public class Mdsal668Test extends AbstractBindingCodecTest {
24     private static final NodeIdentifier FOO = new NodeIdentifier(Foo.QNAME);
25     private static final InstanceIdentifier<Foo> FOO_IID = InstanceIdentifier.create(Foo.class);
26
27     @Test
28     public void testLeaflistLeafref() {
29         assertEquals(Builders.containerBuilder()
30             .withNodeIdentifier(FOO)
31             .withChild(Builders.containerBuilder()
32                 .withNodeIdentifier(new NodeIdentifier(Bar.QNAME))
33                 .withChild(Builders.leafSetBuilder()
34                     .withNodeIdentifier(new NodeIdentifier(Bar.QNAME))
35                     .withChild(Builders.leafSetEntryBuilder()
36                         // FIXME: MDSAL-670: these should get translated to YangInstanceIdentifier.create(FOO)
37                         .withNodeIdentifier(new NodeWithValue<>(Bar.QNAME, FOO_IID))
38                         .withValue(FOO_IID)
39                         .build())
40                     .build())
41                 .build())
42             .build(), codecContext.toNormalizedNode(FOO_IID,
43                 new FooBuilder().setBar(new BarBuilder().setBar(List.of(FOO_IID)).build()).build())
44             .getValue());
45     }
46 }