BUG-4688: eliminate SimpleDateFormatUtil.DEFAULT_DATE_REV
[yangtools.git] / yang / yang-parser-impl / src / test / java / org / opendaylight / yangtools / yang / stmt / Bug8597Test.java
1 /*
2  * Copyright (c) 2017 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.assertEquals;
11 import static org.junit.Assert.assertNotNull;
12 import static org.junit.Assert.fail;
13
14 import java.util.Set;
15 import org.junit.Test;
16 import org.opendaylight.yangtools.yang.common.QName;
17 import org.opendaylight.yangtools.yang.model.api.Module;
18 import org.opendaylight.yangtools.yang.model.api.ModuleImport;
19 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
20
21 public class Bug8597Test {
22     @Test
23     public void test() throws Exception {
24         final SchemaContext context = StmtTestUtils.parseYangSources("/bugs/bug8597");
25         assertNotNull(context);
26
27         final Module foo = context.findModule("foo", null).get();
28         final Set<ModuleImport> imports = foo.getImports();
29
30         for (final ModuleImport moduleImport : imports) {
31             switch (moduleImport.getModuleName()) {
32                 case "bar":
33                     assertEquals(QName.parseRevision("1970-01-01"), moduleImport.getRevision());
34                     assertEquals("bar-ref", moduleImport.getReference());
35                     assertEquals("bar-desc", moduleImport.getDescription());
36                     break;
37                 case "baz":
38                     assertEquals(QName.parseRevision("2010-10-10"), moduleImport.getRevision());
39                     assertEquals("baz-ref", moduleImport.getReference());
40                     assertEquals("baz-desc", moduleImport.getDescription());
41                     break;
42                 default:
43                     fail("Module 'foo' should only contains import of module 'bar' and 'baz'");
44             }
45         }
46     }
47 }