Use AbstractYangTest to reduce verbosity and duplication.
JIRA: YANGTOOLS-1345
Change-Id: I973b7c91f3fb33bc315fd6022eea1209e7bde22b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
import static org.hamcrest.CoreMatchers.startsWith;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
import static org.hamcrest.CoreMatchers.startsWith;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThrows;
import java.util.List;
import java.util.Optional;
import java.util.List;
import java.util.Optional;
import org.opendaylight.yangtools.yang.model.api.type.ModifierKind;
import org.opendaylight.yangtools.yang.model.api.type.PatternConstraint;
import org.opendaylight.yangtools.yang.model.api.type.StringTypeDefinition;
import org.opendaylight.yangtools.yang.model.api.type.ModifierKind;
import org.opendaylight.yangtools.yang.model.api.type.PatternConstraint;
import org.opendaylight.yangtools.yang.model.api.type.StringTypeDefinition;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
-import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
-import org.opendaylight.yangtools.yang.stmt.StmtTestUtils;
+import org.opendaylight.yangtools.yang.stmt.AbstractYangTest;
-public class Bug6870Test {
+public class Bug6870Test extends AbstractYangTest {
@Test
public void valid11Test() throws Exception {
@Test
public void valid11Test() throws Exception {
- final EffectiveModelContext schemaContext = StmtTestUtils.parseYangSource("/rfc7950/bug6870/foo.yang");
-
- assertModifier(schemaContext, ModifierKind.INVERT_MATCH, QName.create("foo", "root"),
- QName.create("foo", "my-leaf"));
- assertModifier(schemaContext, null, QName.create("foo", "root"), QName.create("foo", "my-leaf-2"));
+ final var context = assertEffectiveModel("/rfc7950/bug6870/foo.yang");
+ assertModifier(context, ModifierKind.INVERT_MATCH, QName.create("foo", "root"), QName.create("foo", "my-leaf"));
+ assertModifier(context, null, QName.create("foo", "root"), QName.create("foo", "my-leaf-2"));
}
private static void assertModifier(final EffectiveModelContext schemaContext,
}
private static void assertModifier(final EffectiveModelContext schemaContext,
@Test
public void invalid11Test() {
@Test
public void invalid11Test() {
- final ReactorException ex = assertThrows(ReactorException.class,
- () -> StmtTestUtils.parseYangSource("/rfc7950/bug6870/invalid11.yang"));
- final Throwable cause = ex.getCause();
- assertThat(cause, instanceOf(SourceException.class));
- assertThat(cause.getMessage(), startsWith("'Invert-match' is not valid argument of modifier statement"));
+ assertSourceException(startsWith("'Invert-match' is not valid argument of modifier statement"),
+ "/rfc7950/bug6870/invalid11.yang");
}
@Test
public void invalid10Test() {
}
@Test
public void invalid10Test() {
- final ReactorException ex = assertThrows(ReactorException.class,
- () -> StmtTestUtils.parseYangSource("/rfc7950/bug6870/invalid10.yang"));
- final Throwable cause = ex.getCause();
- assertThat(cause, instanceOf(SourceException.class));
- assertThat(cause.getMessage(), startsWith("modifier is not a YANG statement or use of extension"));
+ assertSourceException(startsWith("modifier is not a YANG statement or use of extension"),
+ "/rfc7950/bug6870/invalid10.yang");
}
}
\ No newline at end of file
}
}
\ No newline at end of file