2 * Copyright (c) 2014 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
8 package org.opendaylight.controller.sal.restconf.impl.test;
10 import static org.hamcrest.CoreMatchers.containsString;
11 import static org.hamcrest.MatcherAssert.assertThat;
12 import static org.junit.Assert.assertEquals;
13 import static org.junit.Assert.assertThrows;
15 import java.io.FileNotFoundException;
16 import org.junit.BeforeClass;
17 import org.junit.Test;
18 import org.opendaylight.controller.md.sal.rest.common.TestRestconfUtils;
19 import org.opendaylight.netconf.sal.restconf.impl.ControllerContext;
20 import org.opendaylight.restconf.common.context.InstanceIdentifierContext;
21 import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
22 import org.opendaylight.yangtools.yang.common.XMLNamespace;
23 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
25 public class RestGetAugmentedElementWhenEqualNamesTest {
27 private static EffectiveModelContext schemaContext;
29 private final ControllerContext controllerContext = TestRestconfUtils.newControllerContext(schemaContext);
32 public static void init() throws FileNotFoundException {
33 schemaContext = TestUtils.loadSchemaContext("/common/augment/yang");
37 public void augmentedNodesInUri() {
38 InstanceIdentifierContext iiWithData =
39 controllerContext.toInstanceIdentifier("main:cont/augment-main-a:cont1");
40 assertEquals(XMLNamespace.of("ns:augment:main:a"), iiWithData.getSchemaNode().getQName().getNamespace());
41 iiWithData = controllerContext.toInstanceIdentifier("main:cont/augment-main-b:cont1");
42 assertEquals(XMLNamespace.of("ns:augment:main:b"), iiWithData.getSchemaNode().getQName().getNamespace());
46 public void nodeWithoutNamespaceHasMoreAugments() {
47 final var ex = assertThrows(RestconfDocumentedException.class,
48 () -> controllerContext.toInstanceIdentifier("main:cont/cont1"));
49 assertThat(ex.getErrors().get(0).getErrorMessage(),
50 containsString("is added as augment from more than one module"));