* 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");
.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();
this.instanceIdentifierDTO.deserialize(valuesDTO);
assertNull(deserializedIdentifier);
}
-}
\ No newline at end of file
+}