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.yin;
10 import static org.hamcrest.CoreMatchers.anyOf;
11 import static org.hamcrest.MatcherAssert.assertThat;
12 import static org.hamcrest.core.Is.is;
13 import static org.junit.Assert.assertEquals;
14 import static org.junit.Assert.assertNotNull;
15 import static org.junit.Assert.assertTrue;
17 import java.util.Collection;
18 import java.util.Iterator;
19 import org.junit.Test;
20 import org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode;
21 import org.opendaylight.yangtools.yang.model.api.Module;
23 public class YinFileIdentityStmtTest extends AbstractYinModulesTest {
25 public void testIdentity() {
26 Module testModule = context.findModules("config").iterator().next();
27 assertNotNull(testModule);
29 Collection<? extends IdentitySchemaNode> identities = testModule.getIdentities();
30 assertEquals(2, identities.size());
32 Iterator<? extends IdentitySchemaNode> idIterator = identities.iterator();
33 IdentitySchemaNode id = idIterator.next();
35 assertThat(id.getQName().getLocalName(), anyOf(is("module-type"), is("service-type")));
36 assertTrue(id.getBaseIdentities().isEmpty());
38 id = idIterator.next();
39 assertThat(id.getQName().getLocalName(), anyOf(is("module-type"), is("service-type")));
40 assertTrue(id.getBaseIdentities().isEmpty());