Further cleanup of tests
[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.fail;
12
13 import java.util.Optional;
14 import org.junit.Test;
15 import org.opendaylight.yangtools.yang.common.Revision;
16 import org.opendaylight.yangtools.yang.model.api.ModuleImport;
17
18 public class Bug8597Test extends AbstractYangTest {
19     @Test
20     public void test() throws Exception {
21         final var foo = assertEffectiveModelDir("/bugs/bug8597").findModule("foo").orElseThrow();
22         for (ModuleImport moduleImport : foo.getImports()) {
23             switch (moduleImport.getModuleName()) {
24                 case "bar":
25                     assertEquals(Revision.ofNullable("1970-01-01"), moduleImport.getRevision());
26                     assertEquals(Optional.of("bar-ref"), moduleImport.getReference());
27                     assertEquals(Optional.of("bar-desc"), moduleImport.getDescription());
28                     break;
29                 case "baz":
30                     assertEquals(Revision.ofNullable("2010-10-10"), moduleImport.getRevision());
31                     assertEquals(Optional.of("baz-ref"), moduleImport.getReference());
32                     assertEquals(Optional.of("baz-desc"), moduleImport.getDescription());
33                     break;
34                 default:
35                     fail("Module 'foo' should only contains import of module 'bar' and 'baz'");
36             }
37         }
38     }
39 }