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.hamcrest.CoreMatchers.startsWith;
11 import static org.junit.Assert.assertEquals;
12 import static org.junit.Assert.assertNotEquals;
14 import java.util.Collection;
15 import org.junit.Test;
16 import org.opendaylight.yangtools.yang.model.api.Module;
17 import org.opendaylight.yangtools.yang.model.api.ModuleImport;
19 public class YangParserIdentityTest extends AbstractYangTest {
21 // base identity name equals identity name
23 public void testParsingIdentityTestModule() {
24 assertInferenceException(startsWith("Unable to resolve identity (urn:test.identitytest?revision="
25 + "2014-09-17)test and base identity"), "/identity/identitytest.yang");
28 // same module prefixed base identity name equals identity name
30 public void testParsingPrefixIdentityTestModule() {
31 assertInferenceException(startsWith("Unable to resolve identity (urn:test.prefixidentitytest?revision="
32 + "2014-09-24)prefixtest and base identity"), "/identity/prefixidentitytest.yang");
35 // imported module prefixed base identity name equals identity name, but
38 public void testParsingImportPrefixIdentityTestModule() throws Exception {
39 Module module = StmtTestUtils.parseYangSources("/identity/import").findModules("prefiximportidentitytest")
41 Collection<? extends ModuleImport> imports = module.getImports();
42 assertEquals(imports.size(), 1);
43 ModuleImport dummy = TestUtils.findImport(imports, "dummy");
44 assertNotEquals(dummy.getPrefix(), module.getPrefix());