d8236937610a2e8f38bbb2237564ec9085553477
[yangtools.git] / yang / yang-parser-impl / src / test / java / org / opendaylight / yangtools / yang / stmt / yin / YinFileFeatureStmtTest.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.yin;
9
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.assertThat;
15
16 import java.net.URISyntaxException;
17 import java.util.Iterator;
18 import java.util.Set;
19 import org.junit.Before;
20 import org.junit.Test;
21 import org.opendaylight.yangtools.yang.model.api.FeatureDefinition;
22 import org.opendaylight.yangtools.yang.model.api.Module;
23 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
24 import org.opendaylight.yangtools.yang.stmt.TestUtils;
25
26 public class YinFileFeatureStmtTest {
27
28     private Set<Module> modules;
29
30     @Before
31     public void init() throws URISyntaxException, ReactorException {
32         modules = TestUtils.loadYinModules(getClass().getResource
33                 ("/semantic-statement-parser/yin/feature-test/").toURI());
34         assertEquals(1, modules.size());
35     }
36
37     @Test
38     public void testFeature() {
39         Module testModule = TestUtils.findModule(modules, "yang-with-features");
40         assertNotNull(testModule);
41
42         Set<FeatureDefinition> features = testModule.getFeatures();
43         assertEquals(2, features.size());
44
45         Iterator<FeatureDefinition> featuresIterator = features.iterator();
46         FeatureDefinition feature = featuresIterator.next();
47
48         assertThat(feature.getQName().getLocalName(), anyOf(is("arbitrary-names"), is("pre-provisioning")));
49
50         feature = featuresIterator.next();
51
52         assertThat(feature.getQName().getLocalName(), anyOf(is("arbitrary-names"), is("pre-provisioning")));
53     }
54 }