Clean up use of Augmentation generics
[yangtools.git] / parser / yang-parser-rfc7950 / src / test / java / org / opendaylight / yangtools / yang / stmt / ImportResolutionBasicTest.java
1 /*
2  * Copyright (c) 2016 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.stmt;
9
10 import static org.hamcrest.CoreMatchers.allOf;
11 import static org.hamcrest.CoreMatchers.containsString;
12 import static org.hamcrest.CoreMatchers.startsWith;
13
14 import org.junit.jupiter.api.Test;
15
16 class ImportResolutionBasicTest extends AbstractYangTest {
17     private static final String ROOT_WITHOUT_IMPORT = "/semantic-statement-parser/import-arg-parsing/nature.yang";
18     private static final String IMPORT_ROOT = "/semantic-statement-parser/import-arg-parsing/mammal.yang";
19     private static final String IMPORT_DERIVED = "/semantic-statement-parser/import-arg-parsing/human.yang";
20
21     @Test
22     void inImportOrderTest() {
23         assertEffectiveModel(ROOT_WITHOUT_IMPORT, IMPORT_ROOT, IMPORT_DERIVED);
24     }
25
26     @Test
27     void inInverseOfImportOrderTest() {
28         assertEffectiveModel(IMPORT_DERIVED, IMPORT_ROOT, ROOT_WITHOUT_IMPORT);
29     }
30
31     @Test
32     void missingImportedSourceTest() {
33         assertFailedPreLinkage("mammal", IMPORT_DERIVED, ROOT_WITHOUT_IMPORT);
34     }
35
36     @Test
37     void circularImportsTest() {
38         assertFailedPreLinkage("cycle-",
39             "/semantic-statement-parser/import-arg-parsing/cycle-yin.yang",
40             "/semantic-statement-parser/import-arg-parsing/cycle-yang.yang");
41     }
42
43     @Test
44     void selfImportTest() {
45         assertFailedPreLinkage("egocentric",
46             "/semantic-statement-parser/import-arg-parsing/egocentric.yang", IMPORT_ROOT, ROOT_WITHOUT_IMPORT);
47     }
48
49     @Test
50     void bug2649Test() {
51         assertEffectiveModel(
52             "/semantic-statement-parser/bug2649/foo.yang",
53             "/semantic-statement-parser/bug2649/import-module.yang");
54     }
55
56     private static void assertFailedPreLinkage(final String name, final String... sources) {
57         assertInferenceException(allOf(
58             startsWith("Imported module [" + name),
59             containsString("] was not found. [at ")),
60             sources);
61     }
62 }