Adjust test suite parser update to conform with API changes
[yangtools.git] / yang / yang-parser-rfc7950 / src / test / java / org / opendaylight / yangtools / yang / stmt / Bug6491Test.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 package org.opendaylight.yangtools.yang.stmt;
9
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertNotNull;
12
13 import java.util.Optional;
14 import java.util.Set;
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 Bug6491Test {
22     private static final Revision DATE = Revision.of("2016-01-01");
23
24     @Test
25     public void tetststs() throws Exception {
26         testRevision("withoutRevision", null, Optional.empty());
27         testRevision("withRevision", DATE, Optional.of(DATE));
28         testRevision("importedModuleRevisionOnly", null, Optional.of(DATE));
29         testRevision("moduleRevisionOnly", DATE, Optional.empty());
30     }
31
32     private static void testRevision(final String path, final Revision moduleRevision,
33             final Optional<Revision> importedRevision) throws Exception {
34         final SchemaContext context = StmtTestUtils.parseYangSources("/bugs/bug6491/".concat(path));
35         assertNotNull(context);
36         final Module module = context.findModule("bar", moduleRevision).get();
37         final Set<ModuleImport> imports = module.getImports();
38         assertNotNull(imports);
39         assertEquals(1, imports.size());
40         assertEquals(importedRevision, imports.iterator().next().getRevision());
41     }
42 }