2 * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
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
9 package org.opendaylight.controller.sal.restconf.impl.test;
11 import static org.junit.Assert.assertEquals;
12 import static org.junit.Assert.assertNotNull;
13 import java.io.FileNotFoundException;
14 import org.junit.BeforeClass;
15 import org.junit.Test;
16 import org.opendaylight.controller.sal.restconf.impl.ControllerContext;
17 import org.opendaylight.controller.sal.restconf.impl.InstanceIdentifierContext;
18 import org.opendaylight.yangtools.yang.common.QName;
19 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
20 import org.opendaylight.yangtools.yang.model.api.Module;
21 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
23 public class Bug3595Test {
25 private static final QName CONT_QNAME = QName.create("leafref:module", "2014-04-17", "cont");
26 private static final QName LST_WITH_LFREF_KEY_QNAME = QName.create(CONT_QNAME, "lst-with-lfref-key");
27 private static final QName LFREF_KEY_QNAME = QName.create(CONT_QNAME, "lfref-key");
30 private static ControllerContext controllerContext = ControllerContext.getInstance();
33 public static void initialize() throws FileNotFoundException {
34 SchemaContext schemaContext = TestUtils.loadSchemaContext("/leafref/yang");
35 Module module = TestUtils.findModule(schemaContext.getModules(), "leafref-module");
36 assertNotNull(module);
37 module = TestUtils.findModule(schemaContext.getModules(), "referenced-module");
38 assertNotNull(module);
40 controllerContext.setGlobalSchema(schemaContext);
44 public void testLeafrefListKeyDeserializtion() {
45 final YangInstanceIdentifier node1IIexpected = YangInstanceIdentifier.of(CONT_QNAME)
46 .node(LST_WITH_LFREF_KEY_QNAME).node(new YangInstanceIdentifier.NodeIdentifierWithPredicates(
47 LST_WITH_LFREF_KEY_QNAME, LFREF_KEY_QNAME, "node1"));
48 final InstanceIdentifierContext<?> iiContext =
49 controllerContext.toInstanceIdentifier("leafref-module:cont/lst-with-lfref-key/node1");
50 iiContext.getInstanceIdentifier();
51 assertEquals(node1IIexpected, iiContext.getInstanceIdentifier());