Remove unneeded throws
[yangtools.git] / parser / yang-parser-rfc7950 / src / test / java / org / opendaylight / yangtools / yang / stmt / SubstatementValidatorTest.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.hamcrest.CoreMatchers.startsWith;
11 import static org.junit.Assert.assertEquals;
12
13 import org.junit.Test;
14 import org.opendaylight.yangtools.yang.parser.spi.meta.MissingSubstatementException;
15
16 public class SubstatementValidatorTest extends AbstractYangTest {
17     @Test
18     public void noException() throws Exception {
19         assertEquals(3, assertEffectiveModelDir("/augment-test/augment-in-augment").getModules().size());
20     }
21
22     @Test
23     public void undesirableElementException() throws Exception {
24         assertInvalidSubstatementExceptionDir("/substatement-validator/undesirable-element",
25             startsWith("TYPE is not valid for REVISION. Error in module undesirable "
26                 + "(QNameModule{ns=urn:opendaylight.undesirable, rev=2015-11-11}) [at "));
27     }
28
29     @Test
30     public void maximalElementCountException() throws Exception {
31         assertInvalidSubstatementExceptionDir("/substatement-validator/maximal-element",
32             startsWith("Maximal count of DESCRIPTION for AUGMENT is 1, detected 2. Error in module baz "
33                 + "(QNameModule{ns=urn:opendaylight.baz, rev=2015-11-11}) [at "));
34     }
35
36     @Test
37     public void missingElementException() {
38         // FIXME: should be MissingSubstatementException?
39         assertSourceExceptionDir("/substatement-validator/missing-element",
40             startsWith("Missing prefix statement [at "));
41     }
42
43     @Test
44     public void bug6173Test() throws Exception {
45         assertEquals(1, assertEffectiveModelDir("/substatement-validator/empty-element").getModules().size());
46     }
47
48     @Test
49     public void bug4310test() throws Exception {
50         assertExceptionDir("/substatement-validator/bug-4310", MissingSubstatementException.class,
51             startsWith("TYPE is missing TYPE. Minimal count is 1. Error in module bug4310 "
52                 + "(QNameModule{ns=urn:opendaylight.bug4310}) [at "));
53     }
54 }