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.assertNotEquals;
13 import java.util.Collection;
14 import org.junit.Test;
15 import org.opendaylight.yangtools.yang.model.api.Module;
16 import org.opendaylight.yangtools.yang.model.api.ModuleImport;
17 import org.opendaylight.yangtools.yang.parser.spi.meta.SomeModifiersUnresolvedException;
19 public class YangParserIdentityTest {
21 // base identity name equals identity name
22 @Test(expected = SomeModifiersUnresolvedException.class)
23 public void testParsingIdentityTestModule() throws Exception {
25 StmtTestUtils.parseYangSource("/identity/identitytest.yang");
26 } catch (SomeModifiersUnresolvedException e) {
27 StmtTestUtils.log(e, " ");
32 // same module prefixed base identity name equals identity name
33 @Test(expected = SomeModifiersUnresolvedException.class)
34 public void testParsingPrefixIdentityTestModule() throws Exception {
36 StmtTestUtils.parseYangSource("/identity/prefixidentitytest.yang");
37 } catch (SomeModifiersUnresolvedException e) {
38 StmtTestUtils.log(e, " ");
43 // imported module prefixed base identity name equals identity name, but
46 public void testParsingImportPrefixIdentityTestModule() throws Exception {
47 Module module = TestUtils.findModule(StmtTestUtils.parseYangSources("/identity/import"),
48 "prefiximportidentitytest").get();
49 Collection<? extends ModuleImport> imports = module.getImports();
50 assertEquals(imports.size(), 1);
51 ModuleImport dummy = TestUtils.findImport(imports, "dummy");
52 assertNotEquals(dummy.getPrefix(), module.getPrefix());