2 * Copyright (c) 2017 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.parser.stmt.rfc7950;
10 import static org.hamcrest.CoreMatchers.startsWith;
11 import static org.junit.Assert.assertEquals;
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;
20 public class IdentityStatementTest extends AbstractYangTest {
23 public void testMultipleBaseIdentities() {
24 final var context = assertEffectiveModel("/rfc7950/identity-stmt/foo.yang");
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());
36 public void testInvalidYang10() {
37 assertInvalidSubstatementException(startsWith("Maximal count of BASE for IDENTITY is 1, detected 3."),
38 "/rfc7950/identity-stmt/foo10.yang");