c87205066ea9b02dad6a6fc49085f4196100dd11
[yangtools.git] / parser / yang-parser-rfc7950 / src / test / java / org / opendaylight / yangtools / yang / stmt / YT1189Test.java
1 /*
2  * Copyright (c) 2020 PANTHEON.tech, s.r.o. 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.instanceOf;
11 import static org.hamcrest.CoreMatchers.startsWith;
12 import static org.hamcrest.MatcherAssert.assertThat;
13 import static org.junit.Assert.assertThrows;
14
15 import org.junit.Test;
16 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
17 import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
18
19 public class YT1189Test {
20     @Test
21     public void testDescendantAugment() {
22         final ReactorException ex = assertThrows(ReactorException.class,
23             () -> StmtTestUtils.parseYangSource("/bugs/YT1189/foo.yang"));
24         final Throwable cause = ex.getCause();
25         assertThat(cause, instanceOf(SourceException.class));
26         assertThat(cause.getMessage(),
27             startsWith("Descendant schema node identifier is not allowed when used outside of a uses statement [at "));
28     }
29
30     @Test
31     public void testAbsoluteUsesAugment() {
32         final ReactorException ex = assertThrows(ReactorException.class,
33             () -> StmtTestUtils.parseYangSource("/bugs/YT1189/bar.yang"));
34         final Throwable cause = ex.getCause();
35         assertThat(cause, instanceOf(SourceException.class));
36         assertThat(cause.getMessage(),
37             startsWith("Absolute schema node identifier is not allowed when used within a uses statement [at "));
38     }
39 }