1 package org.opendaylight.controller.sal.restconf.impl.test;
3 import static org.junit.Assert.assertEquals;
4 import static org.junit.Assert.assertTrue;
6 import java.io.FileNotFoundException;
8 import org.junit.BeforeClass;
10 import org.junit.Test;
11 import org.junit.rules.ExpectedException;
12 import org.opendaylight.controller.sal.restconf.impl.ControllerContext;
13 import org.opendaylight.controller.sal.restconf.impl.InstanceIdWithSchemaNode;
14 import org.opendaylight.controller.sal.restconf.impl.ResponseException;
15 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
17 public class RestGetAugmentedElementWhenEqualNamesTest {
19 private static ControllerContext controllerContext = ControllerContext.getInstance();
22 public ExpectedException exception = ExpectedException.none();
25 public static void init() throws FileNotFoundException {
26 SchemaContext schemaContextTestModule = TestUtils.loadSchemaContext("/common/augment/yang");
27 controllerContext.setSchemas(schemaContextTestModule);
31 public void augmentedNodesInUri() {
32 InstanceIdWithSchemaNode iiWithData = controllerContext.toInstanceIdentifier("main:cont/augment-main-a:cont1");
33 assertEquals("ns:augment:main:a", iiWithData.getSchemaNode().getQName().getNamespace().toString());
34 iiWithData = controllerContext.toInstanceIdentifier("main:cont/augment-main-b:cont1");
35 assertEquals("ns:augment:main:b", iiWithData.getSchemaNode().getQName().getNamespace().toString());
39 public void nodeWithoutNamespaceHasMoreAugments() {
40 boolean exceptionCaught = false;
42 controllerContext.toInstanceIdentifier("main:cont/cont1");
43 } catch (ResponseException e) {
44 assertTrue(((String) e.getResponse().getEntity()).contains("is added as augment from more than one module"));
45 exceptionCaught = true;
47 assertTrue(exceptionCaught);