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