X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=parser%2Fyang-parser-rfc7950%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fyangtools%2Fyang%2Fstmt%2FBug6669Test.java;h=197c5846934ec6e2d1a612875fde30cb46b6bdb6;hb=ad338ff278f137696478df3d27675f1d1e78a8eb;hp=51ee39dd54da656b6279fbda0376d1543d24eb20;hpb=0b7e89ec225d50e73ad09817b95faa005cc0b815;p=yangtools.git diff --git a/parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug6669Test.java b/parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug6669Test.java index 51ee39dd54..197c584693 100644 --- a/parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug6669Test.java +++ b/parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug6669Test.java @@ -10,19 +10,14 @@ package org.opendaylight.yangtools.yang.stmt; import static org.hamcrest.CoreMatchers.instanceOf; import static org.hamcrest.CoreMatchers.startsWith; import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertThrows; import org.junit.Test; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode; import org.opendaylight.yangtools.yang.model.api.ListSchemaNode; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; import org.opendaylight.yangtools.yang.model.api.SchemaNode; -import org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException; -import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException; -public class Bug6669Test { +public class Bug6669Test extends AbstractYangTest { private static final String REV = "2016-09-08"; private static final String FOO_NS = "foo"; private static final String BAR_NS = "bar"; @@ -34,57 +29,39 @@ public class Bug6669Test { @Test public void testInvalidAugment() { - final ReactorException ex = assertThrows(ReactorException.class, - () -> StmtTestUtils.parseYangSources("/bugs/bug6669/invalid/test1")); - final Throwable cause = ex.getCause(); - assertThat(cause, instanceOf(InferenceException.class)); - assertThat(cause.getMessage(), startsWith( + assertInferenceExceptionDir("/bugs/bug6669/invalid/test1", startsWith( "An augment cannot add node 'm' because it is mandatory and in module different than target")); } @Test public void testInvalidAugment2() { - final ReactorException ex = assertThrows(ReactorException.class, - () -> StmtTestUtils.parseYangSources("/bugs/bug6669/invalid/test2")); - final Throwable cause = ex.getCause(); - assertThat(cause, instanceOf(InferenceException.class)); - assertThat(cause.getMessage(), startsWith( + assertInferenceExceptionDir("/bugs/bug6669/invalid/test2", startsWith( "An augment cannot add node 'm' because it is mandatory and in module different than target")); } @Test public void testInvalidAugment3() { - final ReactorException ex = assertThrows(ReactorException.class, - () -> StmtTestUtils.parseYangSources("/bugs/bug6669/invalid/test3")); - final Throwable cause = ex.getCause(); - assertThat(cause, instanceOf(InferenceException.class)); - assertThat(cause.getMessage(), startsWith( + assertInferenceExceptionDir("/bugs/bug6669/invalid/test3", startsWith( "An augment cannot add node 'l' because it is mandatory and in module different than target")); } @Test - public void testValidAugment() throws Exception { - final SchemaContext context = StmtTestUtils.parseYangSources("/bugs/bug6669/valid/test1"); - assertNotNull(context); - + public void testValidAugment() { + final var context = assertEffectiveModelDir("/bugs/bug6669/valid/test1"); final SchemaNode findDataSchemaNode = context.findDataTreeChild(ROOT, BAR, BAR_1, M).get(); assertThat(findDataSchemaNode, instanceOf(LeafSchemaNode.class)); } @Test - public void testValidAugment2() throws Exception { - final SchemaContext context = StmtTestUtils.parseYangSources("/bugs/bug6669/valid/test2"); - assertNotNull(context); - + public void testValidAugment2() { + final var context = assertEffectiveModelDir("/bugs/bug6669/valid/test2"); final SchemaNode findDataSchemaNode = context.findDataTreeChild(ROOT, BAR, BAR_1, BAR_2, M).get(); assertThat(findDataSchemaNode, instanceOf(LeafSchemaNode.class)); } @Test public void testValidAugment3() throws Exception { - final SchemaContext context = StmtTestUtils.parseYangSources("/bugs/bug6669/valid/test3"); - assertNotNull(context); - + final var context = assertEffectiveModelDir("/bugs/bug6669/valid/test3"); final SchemaNode findDataSchemaNode = context.findDataTreeChild(ROOT, BAR, BAR_1, BAR_2, QName.create(BAR_NS, REV, "l")).get(); assertThat(findDataSchemaNode, instanceOf(ListSchemaNode.class));