Replace calls of StmtTestUtils.parseYangSource(String)
[yangtools.git] / parser / yang-parser-rfc7950 / src / test / java / org / opendaylight / yangtools / yang / parser / stmt / rfc7950 / IdentityStatementTest.java
1 /*
2  * Copyright (c) 2017 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.parser.stmt.rfc7950;
9
10 import static org.hamcrest.CoreMatchers.startsWith;
11 import static org.junit.Assert.assertEquals;
12
13 import java.util.Collection;
14 import org.junit.Test;
15 import org.opendaylight.yangtools.yang.common.Revision;
16 import org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode;
17 import org.opendaylight.yangtools.yang.model.api.Module;
18 import org.opendaylight.yangtools.yang.stmt.AbstractYangTest;
19
20 public class IdentityStatementTest extends AbstractYangTest {
21
22     @Test
23     public void testMultipleBaseIdentities() {
24         final var context = assertEffectiveModel("/rfc7950/identity-stmt/foo.yang");
25
26         final Module foo = context.findModule("foo", Revision.of("2016-12-21")).get();
27         for (final IdentitySchemaNode identity : foo.getIdentities()) {
28             if ("derived-id".equals(identity.getQName().getLocalName())) {
29                 final Collection<? extends IdentitySchemaNode> baseIdentities = identity.getBaseIdentities();
30                 assertEquals(3, baseIdentities.size());
31             }
32         }
33     }
34
35     @Test
36     public void testInvalidYang10() {
37         assertInvalidSubstatementException(startsWith("Maximal count of BASE for IDENTITY is 1, detected 3."),
38                 "/rfc7950/identity-stmt/foo10.yang");
39     }
40 }