389ada9b369db3ce9b641142b76d8042c3f0dd06
[yangtools.git] / parser / yang-parser-rfc7950 / 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.Optional;
15 import org.junit.Test;
16 import org.opendaylight.yangtools.yang.common.Revision;
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").get();
28         for (final ModuleImport moduleImport : foo.getImports()) {
29             switch (moduleImport.getModuleName()) {
30                 case "bar":
31                     assertEquals(Revision.ofNullable("1970-01-01"), moduleImport.getRevision());
32                     assertEquals(Optional.of("bar-ref"), moduleImport.getReference());
33                     assertEquals(Optional.of("bar-desc"), moduleImport.getDescription());
34                     break;
35                 case "baz":
36                     assertEquals(Revision.ofNullable("2010-10-10"), moduleImport.getRevision());
37                     assertEquals(Optional.of("baz-ref"), moduleImport.getReference());
38                     assertEquals(Optional.of("baz-desc"), moduleImport.getDescription());
39                     break;
40                 default:
41                     fail("Module 'foo' should only contains import of module 'bar' and 'baz'");
42             }
43         }
44     }
45 }