2 * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.yangtools.yang.stmt;
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertNotNull;
13 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;
21 public class Bug6491Test {
22 private static final Revision DATE = Revision.of("2016-01-01");
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());
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());