Update MRI projects for Aluminium
[netconf.git] / restconf / restconf-nb-bierman02 / src / test / java / org / opendaylight / netconf / sal / restconf / impl / InstanceIdentifierCodecImplTest.java
index 0c7ab15b533e4e9d5a03b6a9da696ea331d0826b..e0d48bb6daf733a2051d393750473ad2063ee558 100644 (file)
@@ -5,37 +5,43 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 package org.opendaylight.netconf.sal.restconf.impl;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNull;
 
+import java.io.FileNotFoundException;
 import org.junit.Before;
+import org.junit.BeforeClass;
 import org.junit.Test;
 import org.opendaylight.controller.md.sal.rest.common.TestRestconfUtils;
 import org.opendaylight.netconf.sal.restconf.impl.RestCodec.InstanceIdentifierCodecImpl;
 import org.opendaylight.restconf.common.util.IdentityValuesDTO;
-import org.opendaylight.yangtools.concepts.Codec;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
 public class InstanceIdentifierCodecImplTest {
+    private static EffectiveModelContext schemaContext;
 
-    private Codec<IdentityValuesDTO, YangInstanceIdentifier> instanceIdentifierDTO;
+    private InstanceIdentifierCodecImpl instanceIdentifierDTO;
     private YangInstanceIdentifier instanceIdentifierBadNamespace;
     private YangInstanceIdentifier instanceIdentifierOKList;
     private YangInstanceIdentifier instanceIdentifierOKLeafList;
-    private SchemaContext schemaContext;
+
+    @BeforeClass
+    public static void init() throws FileNotFoundException {
+        schemaContext = YangParserTestUtils.parseYangFiles(
+                TestRestconfUtils.loadFiles("/restconf/parser/deserializer"));
+    }
 
     @Before
     public void setUp() throws Exception {
-        this.schemaContext =
-                YangParserTestUtils.parseYangSources(TestRestconfUtils.loadFiles("/restconf/parser/deserializer"));
-        this.instanceIdentifierDTO = new InstanceIdentifierCodecImpl(null);
-        ControllerContext.getInstance().setGlobalSchema(this.schemaContext);
+        ControllerContext controllerContext = TestRestconfUtils.newControllerContext(schemaContext);
+
+        this.instanceIdentifierDTO = new InstanceIdentifierCodecImpl(null, controllerContext);
 
         final QName baseQName = QName.create("deserializer:test", "2016-06-06", "deserializer-test");
         final QName contA = QName.create(baseQName, "contA");
@@ -47,7 +53,7 @@ public class InstanceIdentifierCodecImplTest {
                 .build();
 
         this.instanceIdentifierOKList = YangInstanceIdentifier.builder()
-                .node(new YangInstanceIdentifier.NodeIdentifierWithPredicates(
+                .node(NodeIdentifierWithPredicates.of(
                         QName.create(baseQName, "list-one-key"),
                         QName.create(QName.create(baseQName, "list-one-key"), "name"), "value"))
                 .build();
@@ -90,4 +96,4 @@ public class InstanceIdentifierCodecImplTest {
                 this.instanceIdentifierDTO.deserialize(valuesDTO);
         assertNull(deserializedIdentifier);
     }
-}
\ No newline at end of file
+}