import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.startsWith;
import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertThrows;
import org.junit.Test;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
-import org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
-public class Bug5335Test {
+public class Bug5335Test extends AbstractYangTest {
private static final String FOO = "foo";
private static final String BAR = "bar";
private static final String REV = "2016-03-04";
@Test
public void incorrectTest1() {
- final ReactorException ex = assertThrows(ReactorException.class,
- () -> StmtTestUtils.parseYangSources("/bugs/bug5335/incorrect/case-1"));
- final Throwable cause = ex.getCause();
- assertThat(cause, instanceOf(InferenceException.class));
- assertThat(cause.getMessage(), startsWith(
+ assertInferenceExceptionDir("/bugs/bug5335/incorrect/case-1", startsWith(
"An augment cannot add node 'mandatory-leaf' because it is mandatory and in module different than target"));
}
@Test
public void incorrectTest2() {
- final ReactorException ex = assertThrows(ReactorException.class,
- () -> StmtTestUtils.parseYangSources("/bugs/bug5335/incorrect/case-2"));
- final Throwable cause = ex.getCause();
- assertThat(cause, instanceOf(InferenceException.class));
- assertThat(cause.getMessage(), startsWith(
+ assertInferenceExceptionDir("/bugs/bug5335/incorrect/case-2", startsWith(
"An augment cannot add node 'mandatory-leaf' because it is mandatory and in module different than target"));
}
@Test
public void incorrectTest3() {
- final ReactorException ex = assertThrows(ReactorException.class,
- () -> StmtTestUtils.parseYangSources("/bugs/bug5335/incorrect/case-2"));
- final Throwable cause = ex.getCause();
- assertThat(cause, instanceOf(InferenceException.class));
- assertThat(cause.getMessage(), startsWith(
+ assertInferenceExceptionDir("/bugs/bug5335/incorrect/case-3", startsWith(
"An augment cannot add node 'mandatory-leaf' because it is mandatory and in module different than target"));
}
@Test
- public void correctTest1() throws Exception {
- final EffectiveModelContext context = StmtTestUtils.parseYangSources("/bugs/bug5335/correct/case-1");
+ public void correctTest1() {
+ final EffectiveModelContext context = assertEffectiveModelDir("/bugs/bug5335/correct/case-1");
final DataSchemaNode mandatoryLeaf = context.findDataTreeChild(ROOT, PRESENCE_CONTAINER_B, MANDATORY_LEAF_B)
.orElse(null);
assertThat(mandatoryLeaf, instanceOf(LeafSchemaNode.class));
}
@Test
- public void correctTest2() throws Exception {
- final EffectiveModelContext context = StmtTestUtils.parseYangSources("/bugs/bug5335/correct/case-2");
+ public void correctTest2() {
+ final EffectiveModelContext context = assertEffectiveModelDir("/bugs/bug5335/correct/case-2");
final DataSchemaNode mandatoryLeaf = context.findDataTreeChild(ROOT, PRESENCE_CONTAINER_B,
NON_PRESENCE_CONTAINER_B, MANDATORY_LEAF_B).orElse(null);
assertThat(mandatoryLeaf, instanceOf(LeafSchemaNode.class));
}
@Test
- public void correctTest3() throws Exception {
- final EffectiveModelContext context = StmtTestUtils.parseYangSources("/bugs/bug5335/correct/case-3");
+ public void correctTest3() {
+ final EffectiveModelContext context = assertEffectiveModelDir("/bugs/bug5335/correct/case-3");
final DataSchemaNode mandatoryLeaf = context.findDataTreeChild(ROOT, PRESENCE_CONTAINER_B,
NON_PRESENCE_CONTAINER_B, MANDATORY_LEAF_B).orElse(null);
assertThat(mandatoryLeaf, instanceOf(LeafSchemaNode.class));
}
@Test
- public void correctTest4() throws Exception {
- final EffectiveModelContext context = StmtTestUtils.parseYangSources("/bugs/bug5335/correct/case-4");
+ public void correctTest4() {
+ final EffectiveModelContext context = assertEffectiveModelDir("/bugs/bug5335/correct/case-4");
final DataSchemaNode mandatoryLeaf = context.findDataTreeChild(ROOT, NON_PRESENCE_CONTAINER_F, MANDATORY_LEAF_F)
.orElse(null);
assertThat(mandatoryLeaf, instanceOf(LeafSchemaNode.class));