Bump versions to 4.0.0-SNAPSHOT
[netconf.git] / restconf / restconf-nb-bierman02 / src / test / java / org / opendaylight / controller / sal / rest / impl / InstanceIdentifierTypeLeafTest.java
index 23eab0435ceaf33285029c810bd6f232b6cb55fb..3c4620157321073316dcc4fe5bde3cc7f9074f3b 100644 (file)
@@ -7,46 +7,49 @@
  */
 package org.opendaylight.controller.sal.rest.impl;
 
-import org.junit.Assert;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
 import org.junit.Test;
 import org.opendaylight.controller.md.sal.rest.common.TestRestconfUtils;
 import org.opendaylight.netconf.sal.restconf.impl.ControllerContext;
-import org.opendaylight.netconf.sal.restconf.impl.InstanceIdentifierContext;
+import org.opendaylight.restconf.common.context.InstanceIdentifierContext;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
 public class InstanceIdentifierTypeLeafTest {
 
     @Test
     public void stringToInstanceIdentifierTest() throws Exception {
-        final SchemaContext schemaContext =
-                YangParserTestUtils.parseYangSources(TestRestconfUtils.loadFiles("/instanceidentifier"));
-        ControllerContext.getInstance().setGlobalSchema(schemaContext);
-        final InstanceIdentifierContext<?> instanceIdentifier =
-                ControllerContext.getInstance().toInstanceIdentifier(
+        final EffectiveModelContext schemaContext =
+                YangParserTestUtils.parseYangFiles(TestRestconfUtils.loadFiles("/instanceidentifier"));
+        ControllerContext controllerContext = TestRestconfUtils.newControllerContext(schemaContext);
+        final InstanceIdentifierContext instanceIdentifier =
+                controllerContext.toInstanceIdentifier(
                         "/iid-value-module:cont-iid/iid-list/%2Fiid-value-module%3Acont-iid%2Fiid-value-module%3A"
                                 + "values-iid%5Biid-value-module:value-iid='value'%5D");
         final YangInstanceIdentifier yiD = instanceIdentifier.getInstanceIdentifier();
-        Assert.assertNotNull(yiD);
+        assertNotNull(yiD);
         final PathArgument lastPathArgument = yiD.getLastPathArgument();
-        Assert.assertTrue(lastPathArgument.getNodeType().getNamespace().toString().equals("iid:value:module"));
-        Assert.assertTrue(lastPathArgument.getNodeType().getLocalName().equals("iid-list"));
+        assertTrue(lastPathArgument.getNodeType().getNamespace().toString().equals("iid:value:module"));
+        assertTrue(lastPathArgument.getNodeType().getLocalName().equals("iid-list"));
 
         final NodeIdentifierWithPredicates list = (NodeIdentifierWithPredicates) lastPathArgument;
-        final YangInstanceIdentifier value = (YangInstanceIdentifier) list.getKeyValues()
-                .get(QName.create(lastPathArgument.getNodeType(), "iid-leaf"));
+        final YangInstanceIdentifier value = (YangInstanceIdentifier) list.getValue(
+            QName.create(lastPathArgument.getNodeType(), "iid-leaf"));
         final PathArgument lastPathArgumentOfValue = value.getLastPathArgument();
-        Assert.assertTrue(lastPathArgumentOfValue.getNodeType().getNamespace().toString().equals("iid:value:module"));
-        Assert.assertTrue(lastPathArgumentOfValue.getNodeType().getLocalName().equals("values-iid"));
+        assertTrue(lastPathArgumentOfValue.getNodeType().getNamespace().toString().equals("iid:value:module"));
+        assertTrue(lastPathArgumentOfValue.getNodeType().getLocalName().equals("values-iid"));
 
         final NodeIdentifierWithPredicates valueList = (NodeIdentifierWithPredicates) lastPathArgumentOfValue;
-        final String valueIid = (String) valueList.getKeyValues()
-                .get(QName.create(lastPathArgumentOfValue.getNodeType(), "value-iid"));
-        Assert.assertEquals("value", valueIid);
+        final String valueIid = (String) valueList.getValue(
+                QName.create(lastPathArgumentOfValue.getNodeType(), "value-iid"));
+        assertEquals("value", valueIid);
     }
 
 }