1 package org.opendaylight.controller.sal.restconf.impl.test;
3 import static org.junit.Assert.assertEquals;
4 import static org.junit.Assert.assertNotNull;
5 import java.io.FileNotFoundException;
6 import org.junit.BeforeClass;
8 import org.opendaylight.controller.sal.restconf.impl.ControllerContext;
9 import org.opendaylight.controller.sal.restconf.impl.InstanceIdentifierContext;
10 import org.opendaylight.yangtools.yang.common.QName;
11 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
12 import org.opendaylight.yangtools.yang.model.api.Module;
13 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
15 public class Bug3595Test {
17 private static final QName CONT_QNAME = QName.create("leafref:module", "2014-04-17", "cont");
18 private static final QName LST_WITH_LFREF_KEY_QNAME = QName.create(CONT_QNAME, "lst-with-lfref-key");
19 private static final QName LFREF_KEY_QNAME = QName.create(CONT_QNAME, "lfref-key");
22 private static ControllerContext controllerContext = ControllerContext.getInstance();
25 public static void initialize() throws FileNotFoundException {
26 SchemaContext schemaContext = TestUtils.loadSchemaContext("/leafref/yang");
27 Module module = TestUtils.findModule(schemaContext.getModules(), "leafref-module");
28 assertNotNull(module);
29 module = TestUtils.findModule(schemaContext.getModules(), "referenced-module");
30 assertNotNull(module);
32 controllerContext.setGlobalSchema(schemaContext);
36 public void testLeafrefListKeyDeserializtion() {
37 final YangInstanceIdentifier node1IIexpected = YangInstanceIdentifier.of(CONT_QNAME)
38 .node(LST_WITH_LFREF_KEY_QNAME).node(new YangInstanceIdentifier.NodeIdentifierWithPredicates(
39 LST_WITH_LFREF_KEY_QNAME, LFREF_KEY_QNAME, "node1"));
40 final InstanceIdentifierContext<?> iiContext =
41 controllerContext.toInstanceIdentifier("leafref-module:cont/lst-with-lfref-key/node1");
42 iiContext.getInstanceIdentifier();
43 assertEquals(node1IIexpected, iiContext.getInstanceIdentifier());