Further cleanup of tests
[yangtools.git] / parser / yang-parser-rfc7950 / src / test / java / org / opendaylight / yangtools / yang / stmt / YangParserIdentityTest.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.hamcrest.CoreMatchers.startsWith;
11 import static org.junit.Assert.assertEquals;
12 import static org.junit.Assert.assertNotEquals;
13
14 import org.junit.Test;
15 import org.opendaylight.yangtools.yang.model.api.ModuleImport;
16
17 public class YangParserIdentityTest extends AbstractYangTest {
18
19     // base identity name equals identity name
20     @Test
21     public void testParsingIdentityTestModule() {
22         assertInferenceException(startsWith("Unable to resolve identity (urn:test.identitytest?revision="
23                 + "2014-09-17)test and base identity"), "/identity/identitytest.yang");
24     }
25
26     // same module prefixed base identity name equals identity name
27     @Test
28     public void testParsingPrefixIdentityTestModule() {
29         assertInferenceException(startsWith("Unable to resolve identity (urn:test.prefixidentitytest?revision="
30                 + "2014-09-24)prefixtest and base identity"), "/identity/prefixidentitytest.yang");
31     }
32
33     // imported module prefixed base identity name equals identity name, but
34     // prefix differs
35     @Test
36     public void testParsingImportPrefixIdentityTestModule() {
37         final var module = assertEffectiveModelDir("/identity/import").findModules("prefiximportidentitytest")
38             .iterator().next();
39         final var imports = module.getImports();
40         assertEquals(imports.size(), 1);
41         ModuleImport dummy = TestUtils.findImport(imports, "dummy");
42         assertNotEquals(dummy.getPrefix(), module.getPrefix());
43     }
44 }