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.jupiter.api.Assertions.assertEquals;
12 import static org.junit.jupiter.api.Assertions.assertNotEquals;
14 import org.junit.jupiter.api.Test;
15 import org.opendaylight.yangtools.yang.model.api.ModuleImport;
17 class YangParserIdentityTest extends AbstractYangTest {
19 // base identity name equals identity name
21 void testParsingIdentityTestModule() {
22 assertInferenceException(startsWith("Unable to resolve identity (urn:test.identitytest?revision="
23 + "2014-09-17)test and base identity"), "/identity/identitytest.yang");
26 // same module prefixed base identity name equals identity name
28 void testParsingPrefixIdentityTestModule() {
29 assertInferenceException(startsWith("Unable to resolve identity (urn:test.prefixidentitytest?revision="
30 + "2014-09-24)prefixtest and base identity"), "/identity/prefixidentitytest.yang");
33 // imported module prefixed base identity name equals identity name, but
36 void testParsingImportPrefixIdentityTestModule() {
37 final var module = assertEffectiveModelDir("/identity/import").findModules("prefiximportidentitytest")
39 final var imports = module.getImports();
40 assertEquals(1, imports.size());
41 ModuleImport dummy = TestUtils.findImport(imports, "dummy");
42 assertNotEquals(dummy.getPrefix(), module.getPrefix());