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.core.Is.is;
12 import static org.junit.Assert.assertEquals;
13 import static org.junit.Assert.assertNotNull;
14 import static org.junit.Assert.assertNull;
15 import static org.junit.Assert.assertThat;
17 import java.net.URISyntaxException;
18 import java.util.Iterator;
20 import org.junit.Before;
21 import org.junit.Test;
22 import org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode;
23 import org.opendaylight.yangtools.yang.model.api.Module;
24 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
25 import org.opendaylight.yangtools.yang.stmt.TestUtils;
27 public class YinFileIdentityStmtTest {
29 private Set<Module> modules;
32 public void init() throws URISyntaxException, ReactorException {
33 modules = TestUtils.loadYinModules(getClass().getResource("/semantic-statement-parser/yin/modules").toURI());
34 assertEquals(9, modules.size());
38 public void testIdentity() throws URISyntaxException {
39 Module testModule = TestUtils.findModule(modules, "config");
40 assertNotNull(testModule);
42 Set<IdentitySchemaNode> identities = testModule.getIdentities();
43 assertEquals(2, identities.size());
45 Iterator<IdentitySchemaNode> idIterator = identities.iterator();
46 IdentitySchemaNode id = idIterator.next();
48 assertThat(id.getQName().getLocalName(), anyOf(is("module-type"), is("service-type")));
49 assertNull(id.getBaseIdentity());
51 id = idIterator.next();
52 assertThat(id.getQName().getLocalName(), anyOf(is("module-type"), is("service-type")));
53 assertNull(id.getBaseIdentity());