BUG-4688: eliminate SimpleDateFormatUtil.DEFAULT_DATE_REV
[yangtools.git] / yang / yang-parser-impl / 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.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.CrossSourceStatementReactor;
19 import org.opendaylight.yangtools.yang.parser.stmt.reactor.EffectiveModelContext;
20 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline;
21
22 public class ImportRevisionsTest {
23
24     private static final StatementStreamSource ROOT_WITH_EQUAL_DATE = sourceForResource(
25         "/import-revision-date-test/root-with-equal-revision-date.yang");
26     private static final StatementStreamSource IMPORTED_WITH_EQUAL_DATE = sourceForResource(
27             "/import-revision-date-test/imported-module-with-equal-revision-date.yang");
28     private static final StatementStreamSource ROOT_WITH_UNEQUAL_DATE = sourceForResource(
29             "/import-revision-date-test/root-with-unequal-revision-date.yang");
30     private static final StatementStreamSource IMPORTED_WITH_UNEQUAL_DATE = sourceForResource(
31             "/import-revision-date-test/imported-module-with-unequal-revision-date.yang");
32     private static final StatementStreamSource ROOT_WITH_DATE = sourceForResource(
33             "/import-revision-date-test/root-with-revision-date.yang");
34     private static final StatementStreamSource IMPORTED_WITHOUT_DATE = sourceForResource(
35             "/import-revision-date-test/imported-module-without-revision-date.yang");
36     private static final StatementStreamSource ROOT_WITHOUT_DATE = sourceForResource(
37             "/import-revision-date-test/root-without-revision-date.yang");
38     private static final StatementStreamSource IMPORTED_WITH_DATE = sourceForResource(
39             "/import-revision-date-test/imported-module-with-revision-date.yang");
40     private static final StatementStreamSource ROOT_WITH_NO_DATE = sourceForResource(
41             "/import-revision-date-test/root-with-no-revision-date.yang");
42     private static final StatementStreamSource IMPORTED_WITH_NO_DATE = sourceForResource(
43             "/import-revision-date-test/imported-module-with-no-revision-date.yang");
44
45     @Test
46     public void equalRevisionDatesTest() throws ReactorException {
47         CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
48         reactor.addSources(ROOT_WITH_EQUAL_DATE, IMPORTED_WITH_EQUAL_DATE);
49
50         EffectiveModelContext result = reactor.build();
51         assertNotNull(result);
52     }
53
54     @Test(expected = SomeModifiersUnresolvedException.class)
55     public void unequalRevisionDatesTest() throws ReactorException {
56         CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
57         reactor.addSources(ROOT_WITH_UNEQUAL_DATE, IMPORTED_WITH_UNEQUAL_DATE);
58
59         EffectiveModelContext result = reactor.build();
60         assertNotNull(result);
61
62     }
63
64     @Test(expected = SomeModifiersUnresolvedException.class)
65     public void revisionDatesInRootOnlyTest() throws ReactorException {
66         CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
67         reactor.addSources(ROOT_WITH_DATE, IMPORTED_WITHOUT_DATE);
68
69         EffectiveModelContext result = reactor.build();
70         assertNotNull(result);
71     }
72
73     @Test
74     public void revisionDatesInImportedOnlyTest() throws ReactorException {
75         CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
76         reactor.addSources( ROOT_WITHOUT_DATE, IMPORTED_WITH_DATE);
77
78         EffectiveModelContext result = reactor.build();
79         assertNotNull(result);
80     }
81
82     @Test
83     public void noRevisionInRootAndImportedTest() throws ReactorException {
84         CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
85         reactor.addSources(ROOT_WITH_NO_DATE, IMPORTED_WITH_NO_DATE);
86
87         EffectiveModelContext result = reactor.build();
88         assertNotNull(result);
89     }
90 }