Remove unneeded throws
[yangtools.git] / parser / yang-parser-rfc7950 / src / test / java / org / opendaylight / yangtools / yang / stmt / Bug7440Test.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;
9
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertNotNull;
12
13 import java.util.Collection;
14 import org.junit.Test;
15 import org.opendaylight.yangtools.yang.common.QName;
16 import org.opendaylight.yangtools.yang.common.Revision;
17 import org.opendaylight.yangtools.yang.model.api.DeviateDefinition;
18 import org.opendaylight.yangtools.yang.model.api.Deviation;
19 import org.opendaylight.yangtools.yang.model.api.Module;
20 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
21 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
22
23 public class Bug7440Test {
24     @Test
25     public void testRestrictedTypeParentSchemaPathInDeviate() throws Exception {
26         final SchemaContext schemaContext = StmtTestUtils.parseYangSources("/bugs/bug7440");
27         assertNotNull(schemaContext);
28
29         final Revision revision = Revision.of("2016-12-23");
30         final Module foo = schemaContext.findModule("foo", revision).get();
31         final Module bar = schemaContext.findModule("bar", revision).get();
32
33         final Collection<? extends Deviation> deviations = foo.getDeviations();
34         assertEquals(1, deviations.size());
35         final Deviation deviation = deviations.iterator().next();
36
37         final Collection<? extends DeviateDefinition> deviates = deviation.getDeviates();
38         assertEquals(1, deviates.size());
39         final DeviateDefinition deviateReplace = deviates.iterator().next();
40
41         final TypeDefinition<?> deviatedType = deviateReplace.getDeviatedType();
42         assertEquals(QName.create(bar.getQNameModule(), "uint32"), deviatedType.getQName());
43     }
44 }