Remove unneeded throws
[yangtools.git] / parser / yang-parser-rfc7950 / src / test / java / org / opendaylight / yangtools / yang / stmt / ImportRevisionsTest.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.junit.Assert.assertNotNull;
11 import static org.opendaylight.yangtools.yang.stmt.StmtTestUtils.sourceForResource;
12
13 import org.junit.Test;
14 import org.opendaylight.yangtools.yang.parser.rfc7950.reactor.RFC7950Reactors;
15 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
16 import org.opendaylight.yangtools.yang.parser.spi.meta.SomeModifiersUnresolvedException;
17 import org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource;
18 import org.opendaylight.yangtools.yang.parser.stmt.reactor.ReactorDeclaredModel;
19
20 public class ImportRevisionsTest {
21
22     private static final StatementStreamSource ROOT_WITH_EQUAL_DATE = sourceForResource(
23         "/import-revision-date-test/root-with-equal-revision-date.yang");
24     private static final StatementStreamSource IMPORTED_WITH_EQUAL_DATE = sourceForResource(
25             "/import-revision-date-test/imported-module-with-equal-revision-date.yang");
26     private static final StatementStreamSource ROOT_WITH_UNEQUAL_DATE = sourceForResource(
27             "/import-revision-date-test/root-with-unequal-revision-date.yang");
28     private static final StatementStreamSource IMPORTED_WITH_UNEQUAL_DATE = sourceForResource(
29             "/import-revision-date-test/imported-module-with-unequal-revision-date.yang");
30     private static final StatementStreamSource ROOT_WITH_DATE = sourceForResource(
31             "/import-revision-date-test/root-with-revision-date.yang");
32     private static final StatementStreamSource IMPORTED_WITHOUT_DATE = sourceForResource(
33             "/import-revision-date-test/imported-module-without-revision-date.yang");
34     private static final StatementStreamSource ROOT_WITHOUT_DATE = sourceForResource(
35             "/import-revision-date-test/root-without-revision-date.yang");
36     private static final StatementStreamSource IMPORTED_WITH_DATE = sourceForResource(
37             "/import-revision-date-test/imported-module-with-revision-date.yang");
38     private static final StatementStreamSource ROOT_WITH_NO_DATE = sourceForResource(
39             "/import-revision-date-test/root-with-no-revision-date.yang");
40     private static final StatementStreamSource IMPORTED_WITH_NO_DATE = sourceForResource(
41             "/import-revision-date-test/imported-module-with-no-revision-date.yang");
42
43     @Test
44     public void equalRevisionDatesTest() throws ReactorException {
45         ReactorDeclaredModel result = RFC7950Reactors.defaultReactor().newBuild()
46                 .addSources(ROOT_WITH_EQUAL_DATE, IMPORTED_WITH_EQUAL_DATE)
47                 .build();
48         assertNotNull(result);
49     }
50
51     @Test(expected = SomeModifiersUnresolvedException.class)
52     public void unequalRevisionDatesTest() throws ReactorException {
53         RFC7950Reactors.defaultReactor().newBuild()
54                 .addSources(ROOT_WITH_UNEQUAL_DATE, IMPORTED_WITH_UNEQUAL_DATE)
55                 .build();
56     }
57
58     @Test(expected = SomeModifiersUnresolvedException.class)
59     public void revisionDatesInRootOnlyTest() throws ReactorException {
60         ReactorDeclaredModel result = RFC7950Reactors.defaultReactor().newBuild()
61                 .addSources(ROOT_WITH_DATE, IMPORTED_WITHOUT_DATE)
62                 .build();
63         assertNotNull(result);
64     }
65
66     @Test
67     public void revisionDatesInImportedOnlyTest() throws ReactorException {
68         ReactorDeclaredModel result = RFC7950Reactors.defaultReactor().newBuild()
69                 .addSources(ROOT_WITHOUT_DATE, IMPORTED_WITH_DATE)
70                 .build();
71         assertNotNull(result);
72     }
73
74     @Test
75     public void noRevisionInRootAndImportedTest() throws ReactorException {
76         ReactorDeclaredModel result = RFC7950Reactors.defaultReactor().newBuild()
77                 .addSources(ROOT_WITH_NO_DATE, IMPORTED_WITH_NO_DATE)
78                 .build();
79         assertNotNull(result);
80     }
81 }