*/
package org.opendaylight.yangtools.yang.parser.stmt.rfc7950;
-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 static org.junit.jupiter.api.Assertions.assertInstanceOf;
-import org.junit.Test;
+import org.junit.jupiter.api.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;
-import org.opendaylight.yangtools.yang.stmt.StmtTestUtils;
+import org.opendaylight.yangtools.yang.stmt.AbstractYangTest;
-public class Bug6876Test {
+class Bug6876Test extends AbstractYangTest {
@Test
- public void yang11Test() throws Exception {
- final EffectiveModelContext context = StmtTestUtils.parseYangSources("/rfc7950/bug6876/yang11");
+ void yang11Test() {
+ final var context = assertEffectiveModelDir("/rfc7950/bug6876/yang11");
DataSchemaNode node = context.findDataTreeChild(bar("augment-target"), bar("my-leaf")).orElse(null);
- assertThat(node, instanceOf(LeafSchemaNode.class));
+ assertInstanceOf(LeafSchemaNode.class, node);
node = context.findDataTreeChild(bar("augment-target"), foo("mandatory-leaf")).orElse(null);
- assertThat(node, instanceOf(LeafSchemaNode.class));
+ assertInstanceOf(LeafSchemaNode.class, node);
}
@Test
- public void yang10Test() {
- final ReactorException ex = assertThrows(ReactorException.class,
- () -> StmtTestUtils.parseYangSources("/rfc7950/bug6876/yang10"));
- final Throwable cause = ex.getCause();
- assertThat(cause, instanceOf(InferenceException.class));
- assertThat(cause.getMessage(), startsWith(
+ void yang10Test() {
+ assertInferenceExceptionDir("/rfc7950/bug6876/yang10", startsWith(
"An augment cannot add node 'mandatory-leaf' because it is mandatory and in module different than target"));
}