790ac93225765de599801c56d41aaf4afe326d75
[yangtools.git] / yang / yang-data-impl / src / test / java / org / opendaylight / yangtools / yang / data / impl / schema / tree / TestModel.java
1 /*
2  * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.yangtools.yang.data.impl.schema.tree;
9
10 import java.io.InputStream;
11 import java.util.Arrays;
12 import java.util.Collections;
13
14 import org.opendaylight.yangtools.yang.common.QName;
15 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
16 import org.opendaylight.yangtools.yang.data.impl.TestUtils;
17 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
18 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
19
20 public class TestModel {
21
22     public static final QName TEST_QNAME = QName.create(
23             "urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test", "2014-03-13", "test");
24     public static final QName OUTER_LIST_QNAME = QName.create(TEST_QNAME, "outer-list");
25     public static final QName INNER_LIST_QNAME = QName.create(TEST_QNAME, "inner-list");
26     public static final QName OUTER_CHOICE_QNAME = QName.create(TEST_QNAME, "outer-choice");
27     public static final QName INNER_CONTAINER_QNAME = QName.create(TEST_QNAME, "inner-container");
28     public static final QName ID_QNAME = QName.create(TEST_QNAME, "id");
29     public static final QName NAME_QNAME = QName.create(TEST_QNAME, "name");
30     public static final QName VALUE_QNAME = QName.create(TEST_QNAME, "value");
31     private static final String DATASTORE_TEST_YANG = "/odl-datastore-test.yang";
32
33     public static final YangInstanceIdentifier TEST_PATH = YangInstanceIdentifier.of(TEST_QNAME);
34     public static final YangInstanceIdentifier OUTER_LIST_PATH = YangInstanceIdentifier.builder(TEST_PATH)
35             .node(OUTER_LIST_QNAME).build();
36     public static final YangInstanceIdentifier INNER_CONTAINER_PATH = YangInstanceIdentifier.builder(TEST_PATH).node(INNER_CONTAINER_QNAME).build();
37     public static final YangInstanceIdentifier VALUE_PATH = YangInstanceIdentifier.of(VALUE_QNAME);
38     public static final YangInstanceIdentifier INNER_VALUE_PATH = YangInstanceIdentifier.builder(INNER_CONTAINER_PATH).node(VALUE_QNAME).build();
39     public static final QName TWO_QNAME = QName.create(TEST_QNAME, "two");
40     public static final QName THREE_QNAME = QName.create(TEST_QNAME, "three");
41
42     public static InputStream getDatastoreTestInputStream() {
43         return TestModel.class.getResourceAsStream(DATASTORE_TEST_YANG);
44     }
45
46     public static SchemaContext createTestContext() throws ReactorException {
47         return TestUtils.parseYangStreams(Arrays.asList(getDatastoreTestInputStream()));
48     }
49
50     public static SchemaContext createTestContext(String resourcePath) throws ReactorException {
51         InputStream yangStream = TestModel.class.getResourceAsStream(resourcePath);
52         return TestUtils.parseYangStreams(Collections.singletonList(yangStream));
53     }
54 }