Replace calls of StmtTestUtils.parseYangSource(String) two
[yangtools.git] / parser / yang-parser-rfc7950 / src / test / java / org / opendaylight / yangtools / yang / parser / stmt / rfc7950 / Bug6885Test.java
1 /*
2  * Copyright (c) 2017 Opendaylight.  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
9 package org.opendaylight.yangtools.yang.parser.stmt.rfc7950;
10
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 Bug6885Test extends AbstractYangTest {
17
18     @Test
19     public void validYang10Test() {
20         // Yang 1.0 allows "if-feature" and "when" on list keys
21         assertEffectiveModel("/rfc7950/list-keys-test/correct-list-keys-test.yang");
22     }
23
24     @Test
25     public void invalidListLeafKeyTest1() {
26         final String exceptionMessage = "(urn:ietf:params:xml:ns:yang:yin:1)when statement is not allowed in "
27                 + "(incorrect-list-keys-test?revision=2017-02-06)a2 leaf statement which is specified as a list key.";
28         assertSourceException(startsWith(exceptionMessage), "/rfc7950/list-keys-test/incorrect-list-keys-test.yang");
29     }
30
31     @Test
32     public void invalidListLeafKeyTest2() {
33         final String exceptionMessage = "(urn:ietf:params:xml:ns:yang:yin:1)if-feature statement is not allowed in "
34                 + "(incorrect-list-keys-test1?revision=2017-02-06)b leaf statement which is specified as a list key.";
35         assertSourceException(startsWith(exceptionMessage), "/rfc7950/list-keys-test/incorrect-list-keys-test1.yang");
36     }
37
38     @Test
39     public void invalidListUsesLeafKeyTest() {
40         final String exceptionMessage = "(urn:ietf:params:xml:ns:yang:yin:1)if-feature statement is not allowed in "
41                 + "(incorrect-list-keys-test2?revision=2017-02-06)a1 leaf statement which is specified as a list key.";
42         assertSourceException(startsWith(exceptionMessage), "/rfc7950/list-keys-test/incorrect-list-keys-test2.yang");
43     }
44
45     @Test
46     public void invalidListUsesLeafKeyTest1() {
47         final String exceptionMessage = "(urn:ietf:params:xml:ns:yang:yin:1)when statement is not allowed in "
48                 + "(incorrect-list-keys-test3?revision=2017-02-06)a2 leaf statement which is specified as a list key.";
49         assertSourceException(startsWith(exceptionMessage), "/rfc7950/list-keys-test/incorrect-list-keys-test3.yang");
50     }
51
52     @Test
53     public void invalidListUsesLeafKeyTest2() {
54         final String exceptionMessage = "(urn:ietf:params:xml:ns:yang:yin:1)if-feature statement is not allowed in "
55                 + "(incorrect-list-keys-test4?revision=2017-02-06)a1 leaf statement which is specified as a list key.";
56         assertSourceException(startsWith(exceptionMessage), "/rfc7950/list-keys-test/incorrect-list-keys-test4.yang");
57     }
58
59     @Test
60     public void invalidListUsesRefineLeafKeyTest() {
61         final String exceptionMessage = "(urn:ietf:params:xml:ns:yang:yin:1)if-feature statement is not allowed in "
62                 + "(incorrect-list-keys-test5?revision=2017-02-06)a1 leaf statement which is specified as a list key.";
63         assertSourceException(startsWith(exceptionMessage), "/rfc7950/list-keys-test/incorrect-list-keys-test5.yang");
64     }
65 }