Replace calls of StmtTestUtils.parseYangSource(String) two
[yangtools.git] / parser / yang-parser-rfc7950 / src / test / java / org / opendaylight / yangtools / yang / parser / stmt / rfc7950 / Bug6901Test.java
1 /*
2  * Copyright (c) 2017 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.parser.stmt.rfc7950;
9
10 import static org.hamcrest.CoreMatchers.containsString;
11 import static org.hamcrest.CoreMatchers.startsWith;
12
13 import org.junit.Test;
14 import org.opendaylight.yangtools.yang.stmt.AbstractYangTest;
15
16 public class Bug6901Test extends AbstractYangTest {
17     @Test
18     public void ifFeature11EnumBitTest() {
19         assertEffectiveModel("/rfc7950/bug6901/foo.yang");
20     }
21
22     @Test
23     public void ifFeatureOnDefaultValueEnumTest() {
24         assertSourceException(
25             startsWith("Leaf '(foo)enum-leaf' has default value 'two' marked with an if-feature statement."),
26             "/rfc7950/bug6901/invalid-foo-enum.yang");
27     }
28
29     @Test
30     public void ifFeatureOnDefaultValueEnumTest2() {
31         assertSourceException(
32             startsWith("Leaf '(foo)enum-leaf' has default value 'two' marked with an if-feature statement."),
33             "/rfc7950/bug6901/invalid-foo-enum-2.yang");
34     }
35
36     @Test
37     public void ifFeatureOnDefaultValueEnumTest3() {
38         assertSourceException(startsWith(
39             "Leaf '(foo)enum-leaf' has default value 'two' marked with an if-feature statement."),
40             "/rfc7950/bug6901/invalid-foo-enum-3.yang");
41     }
42
43     @Test
44     public void ifFeatureOnDefaultValueBitTest() {
45         assertSourceException(
46             startsWith("Typedef '(foo)bits-typedef-2' has default value 'two' marked with an if-feature statement."),
47             "/rfc7950/bug6901/invalid-foo-bit.yang");
48     }
49
50     @Test
51     public void ifFeatureOnDefaultValueUnionTest() {
52         assertSourceException(
53             startsWith("Leaf '(foo)union-leaf' has default value 'two' marked with an if-feature statement."),
54             "/rfc7950/bug6901/invalid-foo-union.yang");
55     }
56
57     @Test
58     public void unsupportedFeatureTest() {
59         assertSourceException(containsString("has default value 'two' marked with an if-feature statement"),
60             "/rfc7950/bug6901/invalid-foo-enum.yang");
61     }
62
63     @Test
64     public void ifFeature10EnumTest() {
65         assertInvalidSubstatementException(startsWith("IF_FEATURE is not valid for ENUM"),
66             "/rfc7950/bug6901/invalid-foo-10-enum.yang");
67     }
68
69     @Test
70     public void ifFeature10BitTest() {
71         assertInvalidSubstatementException(startsWith("IF_FEATURE is not valid for BIT"),
72             "/rfc7950/bug6901/invalid-foo-10-bit.yang");
73     }
74 }