Convert more tests to use AbstractYangTest's assertions.
Change-Id: Ib6efc701ba59d3c5323b8e69cfb51a2d22700e53
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
43 files changed:
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import com.google.common.collect.ImmutableList;
import static org.junit.Assert.assertTrue;
import com.google.common.collect.ImmutableList;
import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
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.TypeDefinition;
import org.opendaylight.yangtools.yang.model.api.type.PatternConstraint;
import org.opendaylight.yangtools.yang.model.api.type.StringTypeDefinition;
-import org.opendaylight.yangtools.yang.stmt.StmtTestUtils;
+import org.opendaylight.yangtools.yang.stmt.AbstractYangTest;
-public class Bug5410Test {
+public class Bug5410Test extends AbstractYangTest {
private static final String FOO_NS = "foo";
@Test
private static final String FOO_NS = "foo";
@Test
- public void testYangPattern() throws Exception {
- final SchemaContext context = StmtTestUtils.parseYangSources("/bugs/bug5410");
- assertNotNull(context);
+ public void testYangPattern() {
+ final var context = assertEffectiveModelDir("/bugs/bug5410");
final PatternConstraint pattern = getPatternConstraintOf(context, "leaf-with-pattern");
final PatternConstraint pattern = getPatternConstraintOf(context, "leaf-with-pattern");
package org.opendaylight.yangtools.yang.parser.stmt.rfc7950;
import static org.hamcrest.CoreMatchers.anyOf;
package org.opendaylight.yangtools.yang.parser.stmt.rfc7950;
import static org.hamcrest.CoreMatchers.anyOf;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.startsWith;
import static org.hamcrest.CoreMatchers.startsWith;
-import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThrows;
import static org.opendaylight.yangtools.yang.stmt.StmtTestUtils.sourceForResource;
import java.util.Optional;
import static org.opendaylight.yangtools.yang.stmt.StmtTestUtils.sourceForResource;
import java.util.Optional;
import org.opendaylight.yangtools.yang.model.api.stmt.ModuleStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.ReferenceStatement;
import org.opendaylight.yangtools.yang.parser.rfc7950.reactor.RFC7950Reactors;
import org.opendaylight.yangtools.yang.model.api.stmt.ModuleStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.ReferenceStatement;
import org.opendaylight.yangtools.yang.parser.rfc7950.reactor.RFC7950Reactors;
-import org.opendaylight.yangtools.yang.parser.spi.meta.InvalidSubstatementException;
import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
-import org.opendaylight.yangtools.yang.parser.spi.meta.SomeModifiersUnresolvedException;
import org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource;
import org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource;
-import org.opendaylight.yangtools.yang.stmt.StmtTestUtils;
-
-public class Bug6874Test {
+import org.opendaylight.yangtools.yang.stmt.AbstractYangTest;
+public class Bug6874Test extends AbstractYangTest {
private static final StatementStreamSource ROOT_MODULE = sourceForResource(
"/rfc7950/include-import-stmt-test/valid-11/root-module.yang");
private static final StatementStreamSource CHILD_MODULE = sourceForResource(
private static final StatementStreamSource ROOT_MODULE = sourceForResource(
"/rfc7950/include-import-stmt-test/valid-11/root-module.yang");
private static final StatementStreamSource CHILD_MODULE = sourceForResource(
"/rfc7950/include-import-stmt-test/valid-11/imported-module.yang");
@Test
"/rfc7950/include-import-stmt-test/valid-11/imported-module.yang");
@Test
- public void valid11Test() throws Exception {
- final var schemaContext = StmtTestUtils.parseYangSources("/rfc7950/include-import-stmt-test/valid-11");
- assertNotNull(schemaContext);
+ public void valid11Test() {
+ final var schemaContext = assertEffectiveModelDir("/rfc7950/include-import-stmt-test/valid-11");
// Test for valid include statement
final Module testModule = schemaContext.findModules("root-module").iterator().next();
// Test for valid include statement
final Module testModule = schemaContext.findModules("root-module").iterator().next();
@Test
public void invalid10IncludeStmtTest() {
@Test
public void invalid10IncludeStmtTest() {
- final var ex = assertThrows(SomeModifiersUnresolvedException.class,
- () -> StmtTestUtils.parseYangSources("/rfc7950/include-import-stmt-test/invalid-include-10")).getCause();
- assertThat(ex, instanceOf(InvalidSubstatementException.class));
- assertThat(ex.getMessage(), anyOf(
+ assertInvalidSubstatementExceptionDir("/rfc7950/include-import-stmt-test/invalid-include-10", anyOf(
startsWith("DESCRIPTION is not valid for INCLUDE"),
startsWith("REFERENCE is not valid for INCLUDE")));
}
@Test
startsWith("DESCRIPTION is not valid for INCLUDE"),
startsWith("REFERENCE is not valid for INCLUDE")));
}
@Test
- public void invalid10ImportStmtTest() throws Exception {
- final var ex = assertThrows(SomeModifiersUnresolvedException.class,
- () -> StmtTestUtils.parseYangSources("/rfc7950/include-import-stmt-test/invalid-import-10")).getCause();
- assertThat(ex, instanceOf(InvalidSubstatementException.class));
- assertThat(ex.getMessage(), anyOf(
+ public void invalid10ImportStmtTest() {
+ assertInvalidSubstatementExceptionDir("/rfc7950/include-import-stmt-test/invalid-import-10", anyOf(
startsWith("DESCRIPTION is not valid for IMPORT"),
startsWith("REFERENCE is not valid for IMPORT")));
}
startsWith("DESCRIPTION is not valid for IMPORT"),
startsWith("REFERENCE is not valid for IMPORT")));
}
- @SuppressWarnings("rawtypes")
- private static void verifyDescAndRef(final DeclaredStatement stmt) {
+ private static void verifyDescAndRef(final DeclaredStatement<?> stmt) {
if (stmt instanceof DescriptionStatement) {
assertEquals("Yang 1.1: Allow description and reference in include and import.",
((DescriptionStatement) stmt).argument());
if (stmt instanceof DescriptionStatement) {
assertEquals("Yang 1.1: Allow description and reference in include and import.",
((DescriptionStatement) stmt).argument());
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.startsWith;
import static org.hamcrest.MatcherAssert.assertThat;
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.LeafSchemaNode;
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.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.AbstractYangTest;
import org.opendaylight.yangtools.yang.stmt.AbstractYangTest;
-import org.opendaylight.yangtools.yang.stmt.StmtTestUtils;
public class Bug6876Test extends AbstractYangTest {
@Test
public class Bug6876Test extends AbstractYangTest {
@Test
@Test
public void yang10Test() {
@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(
+ assertInferenceExceptionDir("/rfc7950/bug6876/yang10", startsWith(
"An augment cannot add node 'mandatory-leaf' because it is mandatory and in module different than target"));
}
"An augment cannot add node 'mandatory-leaf' because it is mandatory and in module different than target"));
}
package org.opendaylight.yangtools.yang.stmt;
import static org.junit.Assert.assertEquals;
package org.opendaylight.yangtools.yang.stmt;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
import org.opendaylight.yangtools.yang.common.XMLNamespace;
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
import org.opendaylight.yangtools.yang.common.XMLNamespace;
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
import org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition;
import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
import org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition;
-public class Bug2872Test {
-
+public class Bug2872Test extends AbstractYangTest {
- public void test() throws Exception {
- final SchemaContext schema = StmtTestUtils.parseYangSources("/bugs/bug2872");
- assertNotNull(schema);
+ public void test() {
+ final var schema = assertEffectiveModelDir("/bugs/bug2872");
final QNameModule bug2872module = QNameModule.create(XMLNamespace.of("bug2872"), Revision.of("2016-06-08"));
final QName foo = QName.create(bug2872module, "bar");
final QNameModule bug2872module = QNameModule.create(XMLNamespace.of("bug2872"), Revision.of("2016-06-08"));
final QName foo = QName.create(bug2872module, "bar");
import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.NotificationDefinition;
import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.NotificationDefinition;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.model.api.Submodule;
import org.opendaylight.yangtools.yang.model.api.Submodule;
-public class Bug3799Test {
-
+public class Bug3799Test extends AbstractYangTest {
- public void test() throws Exception {
- SchemaContext schema = StmtTestUtils.parseYangSources("/bugs/bug3799");
- assertNotNull(schema);
+ public void test() {
+ final var schema = assertEffectiveModelDir("/bugs/bug3799");
Collection<? extends Module> modules = schema.getModules();
assertNotNull(modules);
Collection<? extends Module> modules = schema.getModules();
assertNotNull(modules);
*/
package org.opendaylight.yangtools.yang.stmt;
*/
package org.opendaylight.yangtools.yang.stmt;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.hamcrest.CoreMatchers.allOf;
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.CoreMatchers.instanceOf;
+import static org.hamcrest.CoreMatchers.startsWith;
+import static org.hamcrest.MatcherAssert.assertThat;
-import com.google.common.base.Throwables;
import org.junit.Test;
import org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException;
import org.junit.Test;
import org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException;
-import org.opendaylight.yangtools.yang.parser.spi.meta.SomeModifiersUnresolvedException;
-
-public class Bug4410Test {
+public class Bug4410Test extends AbstractYangTest {
- public void test() throws Exception {
- try {
- StmtTestUtils.parseYangSources("/bugs/bug4410");
- fail("SomeModifiersUnresolvedException should be thrown.");
- } catch (SomeModifiersUnresolvedException e) {
- Throwable rootCause = Throwables.getRootCause(e);
- assertTrue(rootCause instanceof InferenceException);
- final String message = rootCause.getMessage();
- assertTrue(message.startsWith("Type [(foo)"));
- assertTrue(message.contains("was not found"));
- }
+ public void test() {
+ final var cause = assertInferenceExceptionDir("/bugs/bug4410",
+ startsWith("Yang model processing phase EFFECTIVE_MODEL failed [at ")).getCause();
+ assertThat(cause, instanceOf(InferenceException.class));
+ assertThat(cause.getMessage(), allOf(startsWith("Type [(foo)"), containsString("was not found")));
package org.opendaylight.yangtools.yang.stmt;
import static org.junit.Assert.assertEquals;
package org.opendaylight.yangtools.yang.stmt;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
import java.util.Collection;
import static org.junit.Assert.fail;
import java.util.Collection;
import org.opendaylight.yangtools.yang.common.XMLNamespace;
import org.opendaylight.yangtools.yang.model.api.ExtensionDefinition;
import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.common.XMLNamespace;
import org.opendaylight.yangtools.yang.model.api.ExtensionDefinition;
import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.model.api.stmt.UnrecognizedStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.UnrecognizedStatement;
-public class Bug4456Test {
+public class Bug4456Test extends AbstractYangTest {
- public void test() throws Exception {
- SchemaContext schema = StmtTestUtils.parseYangSources("/bugs/bug4456");
- assertNotNull(schema);
+ public void test() {
+ final var schema = assertEffectiveModelDir("/bugs/bug4456");
Set<Module> modules = (Set<Module>) schema.findModules(XMLNamespace.of("foo"));
assertEquals(1, modules.size());
Set<Module> modules = (Set<Module>) schema.findModules(XMLNamespace.of("foo"));
assertEquals(1, modules.size());
import org.opendaylight.yangtools.yang.model.api.stmt.ModuleEffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.SchemaTreeEffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.ModuleEffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.SchemaTreeEffectiveStatement;
-public class Bug4610Test {
+public class Bug4610Test extends AbstractYangTest {
- public void test() throws Exception {
- final EffectiveModelContext context = StmtTestUtils.parseYangSources("/bugs/bug4610");
+ public void test() {
+ final var context = assertEffectiveModelDir("/bugs/bug4610");
final Revision revision = Revision.of("2015-12-12");
// Original
final Revision revision = Revision.of("2015-12-12");
// Original
*/
package org.opendaylight.yangtools.yang.stmt;
*/
package org.opendaylight.yangtools.yang.stmt;
-import static org.junit.Assert.assertNotNull;
-
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-public class Bug5059Test {
+public class Bug5059Test extends AbstractYangTest {
- public void test() throws Exception {
- SchemaContext context = StmtTestUtils.parseYangSources("/bugs/bug5059");
- assertNotNull(context);
+ public void test() {
+ assertEffectiveModelDir("/bugs/bug5059");
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.startsWith;
import static org.hamcrest.MatcherAssert.assertThat;
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.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 extends AbstractYangTest {
private static final String FOO = "foo";
public class Bug5335Test extends AbstractYangTest {
private static final String FOO = "foo";
@Test
public void incorrectTest1() {
@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() {
"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() {
"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"));
}
"An augment cannot add node 'mandatory-leaf' because it is mandatory and in module different than target"));
}
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
import java.util.List;
import org.junit.Test;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
import java.util.List;
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.SchemaContext;
import org.opendaylight.yangtools.yang.model.api.SchemaNode;
import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
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.UnionTypeDefinition;
import org.opendaylight.yangtools.yang.model.api.SchemaNode;
import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
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.UnionTypeDefinition;
-public class Bug5396Test {
+public class Bug5396Test extends AbstractYangTest {
- public void test() throws Exception {
- SchemaContext context = StmtTestUtils.parseYangSources("/bugs/bug5396");
- assertNotNull(context);
+ public void test() {
+ final var context = assertEffectiveModelDir("/bugs/bug5396");
QName root = QName.create("foo", "root");
QName myLeaf2 = QName.create("foo", "my-leaf2");
QName root = QName.create("foo", "root");
QName myLeaf2 = QName.create("foo", "my-leaf2");
*/
package org.opendaylight.yangtools.yang.stmt;
*/
package org.opendaylight.yangtools.yang.stmt;
+import static org.hamcrest.CoreMatchers.instanceOf;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.util.Optional;
import static org.junit.Assert.assertTrue;
import java.util.Optional;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
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.model.api.LeafSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.model.api.Status;
import org.opendaylight.yangtools.yang.xpath.api.YangXPathExpression.QualifiedBound;
import org.opendaylight.yangtools.yang.model.api.Status;
import org.opendaylight.yangtools.yang.xpath.api.YangXPathExpression.QualifiedBound;
-public class Bug5481Test {
+public class Bug5481Test extends AbstractYangTest {
@Test
public void test() throws Exception {
@Test
public void test() throws Exception {
- SchemaContext context = StmtTestUtils.parseYangSources("/bugs/bug5481");
- assertNotNull(context);
-
+ final var context = assertEffectiveModelDir("/bugs/bug5481");
ContainerSchemaNode topContainer = verifyTopContainer(context);
verifyExtendedLeaf(topContainer);
}
ContainerSchemaNode topContainer = verifyTopContainer(context);
verifyExtendedLeaf(topContainer);
}
- private static ContainerSchemaNode verifyTopContainer(final SchemaContext context) {
+ private static ContainerSchemaNode verifyTopContainer(final EffectiveModelContext context) {
QName top = QName.create("http://example.com/module1", "2016-03-09", "top");
DataSchemaNode dataChildByName = context.getDataChildByName(top);
QName top = QName.create("http://example.com/module1", "2016-03-09", "top");
DataSchemaNode dataChildByName = context.getDataChildByName(top);
- assertTrue(dataChildByName instanceof ContainerSchemaNode);
+ assertThat(dataChildByName, instanceOf(ContainerSchemaNode.class));
ContainerSchemaNode topContainer = (ContainerSchemaNode) dataChildByName;
ContainerSchemaNode topContainer = (ContainerSchemaNode) dataChildByName;
*/
package org.opendaylight.yangtools.yang.stmt;
*/
package org.opendaylight.yangtools.yang.stmt;
+import static org.hamcrest.CoreMatchers.instanceOf;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
import java.util.Collection;
import org.junit.Test;
import java.util.Collection;
import org.junit.Test;
import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
import org.opendaylight.yangtools.yang.model.api.MustDefinition;
import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
import org.opendaylight.yangtools.yang.model.api.MustDefinition;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-public class Bug5518Test {
+public class Bug5518Test extends AbstractYangTest {
- public void test() throws Exception {
- final SchemaContext context = StmtTestUtils.parseYangSources("/bugs/bug5518");
- assertNotNull(context);
-
+ public void test() {
+ final var context = assertEffectiveModelDir("/bugs/bug5518");
final DataSchemaNode dataChildByName = context.getDataChildByName(QName.create("foo", "root"));
final DataSchemaNode dataChildByName = context.getDataChildByName(QName.create("foo", "root"));
- assertTrue(dataChildByName instanceof ContainerSchemaNode);
+ assertThat(dataChildByName, instanceOf(ContainerSchemaNode.class));
final ContainerSchemaNode root = (ContainerSchemaNode) dataChildByName;
final Collection<? extends MustDefinition> mustConstraints = root.getMustConstraints();
assertEquals(1, mustConstraints.size());
final ContainerSchemaNode root = (ContainerSchemaNode) dataChildByName;
final Collection<? extends MustDefinition> mustConstraints = root.getMustConstraints();
assertEquals(1, mustConstraints.size());
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertNotNull;
import org.junit.Test;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
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.SchemaContext;
import org.opendaylight.yangtools.yang.model.api.SchemaNode;
import org.opendaylight.yangtools.yang.model.api.SchemaNode;
-public class Bug5550Test {
+public class Bug5550Test extends AbstractYangTest {
private static final String NS = "foo";
private static final String REV = "2016-03-18";
@Test
private static final String NS = "foo";
private static final String REV = "2016-03-18";
@Test
- public void test() throws Exception {
- SchemaContext context = StmtTestUtils.parseYangSources("/bugs/bug5550");
- assertNotNull(context);
+ public void test() {
+ final var context = assertEffectiveModelDir("/bugs/bug5550");
QName root = QName.create(NS, REV, "root");
QName containerInGrouping = QName.create(NS, REV, "container-in-grouping");
QName root = QName.create(NS, REV, "root");
QName containerInGrouping = QName.create(NS, REV, "container-in-grouping");
import org.junit.Test;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.Module;
import org.junit.Test;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
-public class Bug5712Test {
-
+public class Bug5712Test extends AbstractYangTest {
- public void testTypedefWithNewStatementParser() throws Exception {
- SchemaContext schemaContext = StmtTestUtils.parseYangSources("/bugs/bug5712");
- assertNotNull(schemaContext);
-
- Module badModule = schemaContext.findModules("bad").iterator().next();
+ public void testTypedefWithNewStatementParser() {
+ final var badModule = assertEffectiveModelDir("/bugs/bug5712").findModules("bad").iterator().next();
assertNotNull(badModule);
checkThing2TypeDef(badModule);
}
assertNotNull(badModule);
checkThing2TypeDef(badModule);
}
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.isA;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.isA;
-import static org.junit.Assert.assertNotNull;
import java.util.Iterator;
import org.junit.Test;
import java.util.Iterator;
import org.junit.Test;
import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-public class Bug5884Test {
+public class Bug5884Test extends AbstractYangTest {
private static final String NS = "urn:yang.foo";
private static final String REV = "2016-01-01";
@Test
private static final String NS = "urn:yang.foo";
private static final String REV = "2016-01-01";
@Test
- public void testBug5884() throws Exception {
- final SchemaContext context = StmtTestUtils.parseYangSources("/bugs/bug5884");
- assertNotNull(context);
+ public void testBug5884() {
+ final var context = assertEffectiveModelDir("/bugs/bug5884");
final QName root = QName.create(NS, REV, "main-container");
final QName choice = QName.create(NS, REV, "test-choice");
final QName root = QName.create(NS, REV, "main-container");
final QName choice = QName.create(NS, REV, "test-choice");
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
package org.opendaylight.yangtools.yang.stmt;
package org.opendaylight.yangtools.yang.stmt;
-import static org.junit.Assert.assertNotNull;
-
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-
-public class Bug5899Test {
+public class Bug5899Test extends AbstractYangTest {
- public void testBug5899() throws Exception {
- final SchemaContext schemaContext = StmtTestUtils.parseYangSources("/bugs/bug5899");
- assertNotNull(schemaContext);
+ public void testBug5899() {
+ assertEffectiveModelDir("/bugs/bug5899");
}
}
\ No newline at end of file
}
}
\ No newline at end of file
package org.opendaylight.yangtools.yang.stmt;
import static org.junit.Assert.assertEquals;
package org.opendaylight.yangtools.yang.stmt;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.util.Collection;
import static org.junit.Assert.assertTrue;
import java.util.Collection;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.model.api.Status;
import org.opendaylight.yangtools.yang.model.api.UsesNode;
import org.opendaylight.yangtools.yang.model.api.stmt.UnrecognizedStatement;
import org.opendaylight.yangtools.yang.model.api.Status;
import org.opendaylight.yangtools.yang.model.api.UsesNode;
import org.opendaylight.yangtools.yang.model.api.stmt.UnrecognizedStatement;
-public class Bug5942Test {
+public class Bug5942Test extends AbstractYangTest {
- public void test() throws Exception {
- final SchemaContext schemaContext = StmtTestUtils.parseYangSources("/bugs/bug5942");
- assertNotNull(schemaContext);
+ public void test() {
+ final var schemaContext = assertEffectiveModelDir("/bugs/bug5942");
final DataSchemaNode root = schemaContext.getDataChildByName(QName.create("foo", "2016-06-02", "root"));
assertTrue(root instanceof ContainerSchemaNode);
final DataSchemaNode root = schemaContext.getDataChildByName(QName.create("foo", "2016-06-02", "root"));
assertTrue(root instanceof ContainerSchemaNode);
package org.opendaylight.yangtools.yang.stmt;
package org.opendaylight.yangtools.yang.stmt;
-import java.io.IOException;
-import java.net.URISyntaxException;
+import static org.junit.Assert.assertThrows;
+
-import org.opendaylight.yangtools.yang.parser.api.YangSyntaxErrorException;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
-import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
-public class Bug6131Test {
- @Test(expected = NullPointerException.class)
- public void test() throws ReactorException, URISyntaxException, SourceException, IOException,
- YangSyntaxErrorException {
- StmtTestUtils.parseYangSources("/bugs/bug6131");
+public class Bug6131Test extends AbstractYangTest {
+ @Test
+ public void test() {
+ assertThrows(NullPointerException.class, () -> TestUtils.loadModules("/bugs/bug6131"));
}
}
\ No newline at end of file
}
}
\ No newline at end of file
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
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.ContainerSchemaNode;
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
import org.opendaylight.yangtools.yang.model.api.Module;
import org.junit.Test;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.parser.spi.meta.SomeModifiersUnresolvedException;
-import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
public class Bug6240Test extends AbstractYangTest {
private static final String NS = "bar";
public class Bug6240Test extends AbstractYangTest {
private static final String NS = "bar";
@Test
public void testInvalidModels() {
@Test
public void testInvalidModels() {
- final var ex = assertThrows(SomeModifiersUnresolvedException.class,
- () -> StmtTestUtils.parseYangSources("/bugs/bug6240/incorrect"));
- final var cause = ex.getCause();
- assertThat(cause, instanceOf(SourceException.class));
- assertThat(cause.getMessage(), startsWith("Grouping '(bar?revision=2016-07-19)foo-imp-grp' was not resolved."));
+ assertInferenceExceptionDir("/bugs/bug6240/incorrect",
+ startsWith("Grouping '(bar?revision=2016-07-19)foo-imp-grp' was not resolved."));
package org.opendaylight.yangtools.yang.stmt;
import static org.junit.Assert.assertEquals;
package org.opendaylight.yangtools.yang.stmt;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition;
import org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition.EnumPair;
import org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition;
import org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition.EnumPair;
-public class Bug6316Test {
+public class Bug6316Test extends AbstractYangTest {
- public void test() throws Exception {
- final SchemaContext context = StmtTestUtils.parseYangSources("/bugs/bug6316");
- assertNotNull(context);
+ public void test() {
+ final var context = assertEffectiveModelDir("/bugs/bug6316");
verifyEnumTypedefinition(context);
verifyBitsTypedefinition(context);
}
verifyEnumTypedefinition(context);
verifyBitsTypedefinition(context);
}
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.startsWith;
import static org.hamcrest.MatcherAssert.assertThat;
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.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.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";
private static final String REV = "2016-09-08";
private static final String FOO_NS = "foo";
private static final String BAR_NS = "bar";
@Test
public void testInvalidAugment() {
@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() {
"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() {
"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
"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
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 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));
final SchemaNode findDataSchemaNode = context.findDataTreeChild(ROOT, BAR, BAR_1, BAR_2,
QName.create(BAR_NS, REV, "l")).get();
assertThat(findDataSchemaNode, instanceOf(ListSchemaNode.class));
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.stmt.UnrecognizedStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.UnrecognizedStatement;
-public class Bug7037Test {
+public class Bug7037Test extends AbstractYangTest {
private static final String FOO_NS = "foo";
private static final String BAR_NS = "bar";
@Test
private static final String FOO_NS = "foo";
private static final String BAR_NS = "bar";
@Test
- public void test() throws Exception {
- final EffectiveModelContext context = StmtTestUtils.parseYangSources("/bugs/bug7037");
- assertNotNull(context);
+ public void test() {
+ final var context = assertEffectiveModelDir("/bugs/bug7037");
- final Collection<? extends UnrecognizedStatement> unknownSchemaNodes = context.getModuleStatement(foo("foo"))
- .getDeclared().declaredSubstatements(UnrecognizedStatement.class);
+ final var unknownSchemaNodes = context.getModuleStatement(foo("foo")) .getDeclared()
+ .declaredSubstatements(UnrecognizedStatement.class);
assertEquals(1, unknownSchemaNodes.size());
final UnrecognizedStatement first = unknownSchemaNodes.iterator().next();
assertEquals(1, unknownSchemaNodes.size());
final UnrecognizedStatement first = unknownSchemaNodes.iterator().next();
package org.opendaylight.yangtools.yang.stmt;
import static org.hamcrest.CoreMatchers.instanceOf;
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.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
import org.junit.Test;
import org.opendaylight.yangtools.yang.common.QName;
import org.junit.Test;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.stmt.ModuleStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.UnrecognizedStatement;
import org.opendaylight.yangtools.yang.model.api.type.LeafrefTypeDefinition;
import org.opendaylight.yangtools.yang.model.api.stmt.ModuleStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.UnrecognizedStatement;
import org.opendaylight.yangtools.yang.model.api.type.LeafrefTypeDefinition;
-import org.opendaylight.yangtools.yang.parser.spi.meta.SomeModifiersUnresolvedException;
-public class Bug7038Test {
+public class Bug7038Test extends AbstractYangTest {
- public void unknownNodeTest() throws Exception {
- final ModuleStatement bar = StmtTestUtils.parseYangSources("/bugs/bug7038")
+ public void unknownNodeTest() {
+ final ModuleStatement bar = assertEffectiveModelDir("/bugs/bug7038")
.getModuleStatement(QNameModule.create(XMLNamespace.of("bar"))).getDeclared();
final UnrecognizedStatement decimal64 = bar.findFirstDeclaredSubstatement(UnrecognizedStatement.class)
.orElseThrow();
.getModuleStatement(QNameModule.create(XMLNamespace.of("bar"))).getDeclared();
final UnrecognizedStatement decimal64 = bar.findFirstDeclaredSubstatement(UnrecognizedStatement.class)
.orElseThrow();
@Test
public void testYang11() throws Exception {
@Test
public void testYang11() throws Exception {
- final ContainerSchemaNode root = (ContainerSchemaNode) StmtTestUtils.parseYangSources("/bugs/bug7038/yang11")
+ final ContainerSchemaNode root = (ContainerSchemaNode) assertEffectiveModelDir("/bugs/bug7038/yang11")
.getDataChildByName(QName.create("foo", "root"));
final TypeDefinition<?> typedef = ((LeafSchemaNode) root.getDataChildByName(QName.create("foo", "my-leafref")))
.getType();
.getDataChildByName(QName.create("foo", "root"));
final TypeDefinition<?> typedef = ((LeafSchemaNode) root.getDataChildByName(QName.create("foo", "my-leafref")))
.getType();
@Test
public void testYang10() throws Exception {
@Test
public void testYang10() throws Exception {
- try {
- StmtTestUtils.parseYangSources("/bugs/bug7038/yang10");
- } catch (final SomeModifiersUnresolvedException e) {
- assertTrue(e.getCause().getMessage().startsWith("REQUIRE_INSTANCE is not valid for TYPE"));
- }
+ assertInvalidSubstatementExceptionDir("/bugs/bug7038/yang10",
+ startsWith("REQUIRE_INSTANCE is not valid for TYPE"));
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.Optional;
import org.junit.Test;
import java.util.Optional;
import org.junit.Test;
import org.opendaylight.yangtools.yang.common.QNameModule;
import org.opendaylight.yangtools.yang.common.XMLNamespace;
import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
import org.opendaylight.yangtools.yang.common.QNameModule;
import org.opendaylight.yangtools.yang.common.XMLNamespace;
import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.stmt.ModuleEffectiveStatement;
-import org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
-public class Bug8126Test {
+public class Bug8126Test extends AbstractYangTest {
private static final XMLNamespace FOO_NS = XMLNamespace.of("foo");
private static final XMLNamespace BAR_NS = XMLNamespace.of("bar");
@Test
private static final XMLNamespace FOO_NS = XMLNamespace.of("foo");
private static final XMLNamespace BAR_NS = XMLNamespace.of("bar");
@Test
- public void testValidAugments() throws Exception {
- final ModuleEffectiveStatement fooModule = StmtTestUtils.parseYangSources("/bugs/bug8126/valid")
+ public void testValidAugments() {
+ final var fooModule = assertEffectiveModelDir("/bugs/bug8126/valid")
.getModuleStatement(QNameModule.create(FOO_NS));
assertThat(fooModule.findSchemaTreeNode(
foo("root"), bar("my-container"), bar("my-choice"), bar("one"), bar("one"), bar("mandatory-leaf"))
.getModuleStatement(QNameModule.create(FOO_NS));
assertThat(fooModule.findSchemaTreeNode(
foo("root"), bar("my-container"), bar("my-choice"), bar("one"), bar("one"), bar("mandatory-leaf"))
@Test
public void testAugmentMandatoryChoice() {
@Test
public void testAugmentMandatoryChoice() {
- final ReactorException ex = assertThrows(ReactorException.class,
- () -> StmtTestUtils.parseYangSources("/bugs/bug8126/inv-choice"));
- final Throwable cause = ex.getCause();
- assertThat(cause, instanceOf(InferenceException.class));
- assertThat(cause.getMessage(), startsWith(
+ assertInferenceExceptionDir("/bugs/bug8126/inv-choice", startsWith(
"An augment cannot add node 'mandatory-choice' because it is mandatory and in module different than "));
}
@Test
public void testAugmentMandatoryList() {
"An augment cannot add node 'mandatory-choice' because it is mandatory and in module different than "));
}
@Test
public void testAugmentMandatoryList() {
- final ReactorException ex = assertThrows(ReactorException.class,
- () -> StmtTestUtils.parseYangSources("/bugs/bug8126/inv-list"));
- final Throwable cause = ex.getCause();
- assertThat(cause, instanceOf(InferenceException.class));
- assertThat(cause.getMessage(), startsWith(
+ assertInferenceExceptionDir("/bugs/bug8126/inv-list", startsWith(
"An augment cannot add node 'mandatory-list' because it is mandatory and in module different than "));
}
@Test
public void testAugmentMandatoryContainer() {
"An augment cannot add node 'mandatory-list' because it is mandatory and in module different than "));
}
@Test
public void testAugmentMandatoryContainer() {
- final ReactorException ex = assertThrows(ReactorException.class,
- () -> StmtTestUtils.parseYangSources("/bugs/bug8126/inv-cont"));
- final Throwable cause = ex.getCause();
- assertThat(cause, instanceOf(InferenceException.class));
- assertThat(cause.getMessage(), startsWith(
+ assertInferenceExceptionDir("/bugs/bug8126/inv-cont", startsWith(
"An augment cannot add node 'mandatory-leaf-3' because it is mandatory and in module different than "));
}
"An augment cannot add node 'mandatory-leaf-3' because it is mandatory and in module different than "));
}
package org.opendaylight.yangtools.yang.stmt;
import static org.junit.Assert.assertEquals;
package org.opendaylight.yangtools.yang.stmt;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
import java.util.Optional;
import org.junit.Test;
import org.opendaylight.yangtools.yang.common.Revision;
import static org.junit.Assert.fail;
import java.util.Optional;
import org.junit.Test;
import org.opendaylight.yangtools.yang.common.Revision;
-import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.ModuleImport;
import org.opendaylight.yangtools.yang.model.api.ModuleImport;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-public class Bug8597Test {
+public class Bug8597Test extends AbstractYangTest {
@Test
public void test() throws Exception {
@Test
public void test() throws Exception {
- final SchemaContext context = StmtTestUtils.parseYangSources("/bugs/bug8597");
- assertNotNull(context);
-
- final Module foo = context.findModule("foo").get();
- for (final ModuleImport moduleImport : foo.getImports()) {
+ final var foo = assertEffectiveModelDir("/bugs/bug8597").findModule("foo").orElseThrow();
+ for (ModuleImport moduleImport : foo.getImports()) {
switch (moduleImport.getModuleName()) {
case "bar":
assertEquals(Revision.ofNullable("1970-01-01"), moduleImport.getRevision());
switch (moduleImport.getModuleName()) {
case "bar":
assertEquals(Revision.ofNullable("1970-01-01"), moduleImport.getRevision());
package org.opendaylight.yangtools.yang.stmt;
import static org.junit.Assert.assertEquals;
package org.opendaylight.yangtools.yang.stmt;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
import java.util.Collection;
import org.junit.Test;
import org.opendaylight.yangtools.yang.common.Revision;
import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.ModuleImport;
import java.util.Collection;
import org.junit.Test;
import org.opendaylight.yangtools.yang.common.Revision;
import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.ModuleImport;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.model.api.Submodule;
import org.opendaylight.yangtools.yang.model.api.Submodule;
-public class Bug9005Test {
+public class Bug9005Test extends AbstractYangTest {
- public void test() throws Exception {
- final SchemaContext context = StmtTestUtils.parseYangSources("/bugs/bug9005");
- assertNotNull(context);
+ public void test() {
+ final var context = assertEffectiveModelDir("/bugs/bug9005");
final Module foo = context.findModule("foo", Revision.of("2017-07-07")).get();
final Module foo = context.findModule("foo", Revision.of("2017-07-07")).get();
import org.opendaylight.yangtools.yang.model.api.Deviation;
import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.Deviation;
import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
-public class Bug9242Test {
+public class Bug9242Test extends AbstractYangTest {
- public void testDeviateReplaceWithUserDefinedTypes() throws Exception {
- final SchemaContext schemaContext = StmtTestUtils.parseYangSources("/bugs/bug9242/");
- assertNotNull(schemaContext);
+ public void testDeviateReplaceWithUserDefinedTypes() {
+ final var schemaContext = assertEffectiveModelDir("/bugs/bug9242/");
final Revision revision = Revision.of("2017-10-13");
final Revision revision = Revision.of("2017-10-13");
- final Module rootModule = schemaContext.findModule("root-module", revision).get();
- final Module impModule = schemaContext.findModule("imp-module", revision).get();
+ final Module rootModule = schemaContext.findModule("root-module", revision).orElseThrow();
+ final Module impModule = schemaContext.findModule("imp-module", revision).orElseThrow();
TypeDefinition<?> deviatedMyLeafType = null;
TypeDefinition<?> deviatedMyLeaf2Type = null;
TypeDefinition<?> deviatedMyLeafType = null;
TypeDefinition<?> deviatedMyLeaf2Type = null;
import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode;
import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode;
import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-
-public class Bug9244Test {
+public class Bug9244Test extends AbstractYangTest {
- public void testDeviateReplaceOfImplicitSubstatements() throws Exception {
- final SchemaContext schemaContext = StmtTestUtils.parseYangSources("/bugs/bug9244/");
- assertNotNull(schemaContext);
+ public void testDeviateReplaceOfImplicitSubstatements() {
+ final var schemaContext = assertEffectiveModelDir("/bugs/bug9244/");
final Module barModule = schemaContext.findModule("bar", Revision.of("2017-10-13")).get();
final ContainerSchemaNode barCont = (ContainerSchemaNode) barModule.getDataChildByName(
final Module barModule = schemaContext.findModule("bar", Revision.of("2017-10-13")).get();
final ContainerSchemaNode barCont = (ContainerSchemaNode) barModule.getDataChildByName(
*/
package org.opendaylight.yangtools.yang.stmt;
*/
package org.opendaylight.yangtools.yang.stmt;
+import static org.hamcrest.CoreMatchers.startsWith;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThrows;
import java.util.Optional;
import org.junit.Before;
import java.util.Optional;
import org.junit.Before;
import org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode;
import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
import org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode;
import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
-public class CaseStmtTest {
+public class CaseStmtTest extends AbstractYangTest {
private static final Optional<Boolean> OPT_FALSE = Optional.of(Boolean.FALSE);
private static final Optional<Boolean> OPT_TRUE = Optional.of(Boolean.TRUE);
private static final Optional<Boolean> OPT_FALSE = Optional.of(Boolean.FALSE);
private static final Optional<Boolean> OPT_TRUE = Optional.of(Boolean.TRUE);
- private SchemaContext schema;
+ private EffectiveModelContext schema;
private Module rootFoo;
private Module rootBar;
private QNameModule qnameFoo;
private Module rootFoo;
private Module rootBar;
private QNameModule qnameFoo;
private CaseSchemaNode tempChoice;
@Before
private CaseSchemaNode tempChoice;
@Before
- public void setup() throws Exception {
- schema = StmtTestUtils.parseYangSources("/case-test");
+ public void setup() {
+ schema = assertEffectiveModelDir("/case-test");
Revision rev = Revision.of("2015-09-09");
rootFoo = schema.findModule("foo", rev).get();
rootBar = schema.findModule("bar", rev).get();
Revision rev = Revision.of("2015-09-09");
rootFoo = schema.findModule("foo", rev).get();
rootBar = schema.findModule("bar", rev).get();
@Test
public void testInferenceExceptionChoice() {
@Test
public void testInferenceExceptionChoice() {
- assertThrows(ReactorException.class,
- () -> StmtTestUtils.parseYangSources("/case-test/case-test-exceptions/choice"));
+ assertInferenceExceptionDir("/case-test/case-test-exceptions/choice",
+ startsWith("Parent node has config=false, this node must not be specifed as config=true [at "));
- public void testInferenceExceptionCase() throws Exception {
- assertThrows(ReactorException.class,
- () -> StmtTestUtils.parseYangSources("/case-test/case-test-exceptions/case"));
+ public void testInferenceExceptionCase() {
+ assertInferenceExceptionDir("/case-test/case-test-exceptions/case",
+ startsWith("Parent node has config=false, this node must not be specifed as config=true [at "));
}
}
\ No newline at end of file
}
}
\ No newline at end of file
import org.opendaylight.yangtools.yang.model.api.stmt.UnrecognizedStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.UsesEffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.UnrecognizedStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.UsesEffectiveStatement;
-public class ControllerStmtParserTest {
-
+public class ControllerStmtParserTest extends AbstractYangTest {
- public void test() throws Exception {
- final SchemaContext context = StmtTestUtils.parseYangSources("/sal-broker-impl");
- assertNotNull(context);
-
+ public void test() {
+ final var context = assertEffectiveModelDir("/sal-broker-impl");
salDomBrokerImplModuleTest(context);
configModuleTest(context);
}
salDomBrokerImplModuleTest(context);
configModuleTest(context);
}
import org.opendaylight.yangtools.yang.parser.spi.meta.InvalidSubstatementException;
import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
import org.opendaylight.yangtools.yang.parser.spi.meta.InvalidSubstatementException;
import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
-public class DeviationResolutionTest {
-
+public class DeviationResolutionTest extends AbstractYangTest {
@Test
public void testDeviateNotSupported() throws Exception {
@Test
public void testDeviateNotSupported() throws Exception {
- final EffectiveModelContext schemaContext = StmtTestUtils.parseYangSources(
- "/deviation-resolution-test/deviation-not-supported");
+ final var schemaContext = assertEffectiveModelDir("/deviation-resolution-test/deviation-not-supported");
assertNotNull(schemaContext);
final Module importedModule = schemaContext.findModule("imported", Revision.of("2017-01-20")).get();
assertNotNull(schemaContext);
final Module importedModule = schemaContext.findModule("imported", Revision.of("2017-01-20")).get();
*/
package org.opendaylight.yangtools.yang.stmt;
*/
package org.opendaylight.yangtools.yang.stmt;
-import static org.junit.Assert.assertNotNull;
-
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-public class IdentityIssueIetfRoutingTest {
+public class IdentityIssueIetfRoutingTest extends AbstractYangTest {
- public void test() throws Exception {
- final SchemaContext context = StmtTestUtils.parseYangSources("/bugs/identity-ietf-routing-test/");
- assertNotNull(context);
+ public void test() {
+ assertEffectiveModelDir("/bugs/identity-ietf-routing-test/");
return parseYangSources(config, supportedFeatures, sources);
}
return parseYangSources(config, supportedFeatures, sources);
}
- public static EffectiveModelContext parseYangSources(final String yangSourcesDirectoryPath)
- throws ReactorException, URISyntaxException, IOException, YangSyntaxErrorException {
- return parseYangSources(yangSourcesDirectoryPath, YangParserConfiguration.DEFAULT);
- }
-
public static EffectiveModelContext parseYangSources(final String yangSourcesDirectoryPath,
final YangParserConfiguration config) throws ReactorException, URISyntaxException, IOException,
YangSyntaxErrorException {
public static EffectiveModelContext parseYangSources(final String yangSourcesDirectoryPath,
final YangParserConfiguration config) throws ReactorException, URISyntaxException, IOException,
YangSyntaxErrorException {
-public class YT1039Test {
+public class YT1039Test extends AbstractYangTest {
- public void testUsesRefineAnyxml() throws Exception {
- assertEquals(2, StmtTestUtils.parseYangSources("/bugs/YT1039").getModuleStatements().size());
+ public void testUsesRefineAnyxml() {
+ assertEquals(2, assertEffectiveModelDir("/bugs/YT1039").getModuleStatements().size());
*/
package org.opendaylight.yangtools.yang.stmt;
*/
package org.opendaylight.yangtools.yang.stmt;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.isA;
import static org.hamcrest.Matchers.startsWith;
import static org.hamcrest.Matchers.startsWith;
-import static org.junit.Assert.fail;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
-import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
-public class YT1042Test {
+public class YT1042Test extends AbstractYangTest {
- public void testSubmoduleConflict() throws Exception {
- try {
- StmtTestUtils.parseYangSources("/bugs/YT1042");
- fail("Sechema assembly should have failed");
- } catch (ReactorException e) {
- final Throwable cause = e.getCause();
- assertThat(cause, isA(SourceException.class));
- assertThat(cause.getMessage(),
- startsWith("Cannot add data tree child with name (foo)foo, a conflicting child already exists"));
- }
+ public void testSubmoduleConflict() {
+ assertSourceExceptionDir("/bugs/YT1042",
+ startsWith("Cannot add data tree child with name (foo)foo, a conflicting child already exists"));
import org.junit.Test;
import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.junit.Test;
import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
-public class YT1133Test {
+public class YT1133Test extends AbstractYangTest {
@Test
@SuppressWarnings("checkstyle:regexpSinglelineJava")
public void testAugmentKeys() throws Exception {
@Test
@SuppressWarnings("checkstyle:regexpSinglelineJava")
public void testAugmentKeys() throws Exception {
try (PrintStream out = new PrintStream(output, true, StandardCharsets.UTF_8)) {
System.setOut(out);
try (PrintStream out = new PrintStream(output, true, StandardCharsets.UTF_8)) {
System.setOut(out);
- ctx = StmtTestUtils.parseYangSources("/bugs/YT1133");
+ ctx = assertEffectiveModelDir("/bugs/YT1133");
} finally {
System.setOut(stdout);
}
} finally {
System.setOut(stdout);
}
import org.opendaylight.yangtools.yang.xpath.api.YangLocationPath.Relative;
import org.opendaylight.yangtools.yang.xpath.api.YangXPathAxis;
import org.opendaylight.yangtools.yang.xpath.api.YangLocationPath.Relative;
import org.opendaylight.yangtools.yang.xpath.api.YangXPathAxis;
-public class YT1201Test {
+public class YT1201Test extends AbstractYangTest {
private static final QName FOO = QName.create("foo", "foo");
private static final QName BAR = QName.create("foo", "bar");
@Test
private static final QName FOO = QName.create("foo", "foo");
private static final QName BAR = QName.create("foo", "bar");
@Test
- public void testWhenPrefixes() throws Exception {
- final DataSchemaNode bar = StmtTestUtils.parseYangSources("/bugs/YT1201/").getDataChildByName(BAR);
+ public void testWhenPrefixes() {
+ final DataSchemaNode bar = assertEffectiveModelDir("/bugs/YT1201/").getDataChildByName(BAR);
assertThat(bar, instanceOf(ContainerSchemaNode.class));
final YangExpr when = ((ContainerSchemaNode) bar).getWhenCondition().get().getRootExpr();
assertThat(when, instanceOf(Relative.class));
assertThat(bar, instanceOf(ContainerSchemaNode.class));
final YangExpr when = ((ContainerSchemaNode) bar).getWhenCondition().get().getRootExpr();
assertThat(when, instanceOf(Relative.class));
import org.opendaylight.yangtools.yang.model.api.stmt.RpcEffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.TypedefNamespace;
import org.opendaylight.yangtools.yang.model.api.stmt.RpcEffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.TypedefNamespace;
-public class YT1262Test {
+public class YT1262Test extends AbstractYangTest {
- public void testTypedefNamespaces() throws Exception {
- final var modelContext = StmtTestUtils.parseYangSources("/bugs/YT1262");
+ public void testTypedefNamespaces() {
+ final var modelContext = assertEffectiveModelDir("/bugs/YT1262");
final var module = modelContext.getModuleStatement(QNameModule.create(XMLNamespace.of("foo")));
assertTypedef(module, "fdef");
assertTypedef(module, "sdef");
final var module = modelContext.getModuleStatement(QNameModule.create(XMLNamespace.of("foo")));
assertTypedef(module, "fdef");
assertTypedef(module, "sdef");
import org.opendaylight.yangtools.yang.model.api.stmt.InputEffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.SchemaTreeEffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.InputEffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.SchemaTreeEffectiveStatement;
-public class YT841Test {
+public class YT841Test extends AbstractYangTest {
private static final QName FOO = QName.create("foo", "2018-01-02", "foo");
@Test
public void testFindDataSchemaNode() throws Exception {
private static final QName FOO = QName.create("foo", "2018-01-02", "foo");
@Test
public void testFindDataSchemaNode() throws Exception {
- final SchemaTreeEffectiveStatement<?> input = StmtTestUtils.parseYangSources("/bugs/YT841/")
+ final SchemaTreeEffectiveStatement<?> input = assertEffectiveModelDir("/bugs/YT841/")
.getModuleStatement(FOO)
.findSchemaTreeNode(FOO, FOO, FOO, QName.create(FOO, "input"))
.orElse(null);
.getModuleStatement(FOO)
.findSchemaTreeNode(FOO, FOO, FOO, QName.create(FOO, "input"))
.orElse(null);
import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
-public class YT956Test {
+public class YT956Test extends AbstractYangTest {
private static final QName ANOTHER_CONTAINER = QName.create("http://www.example.com/anothermodule",
"another-container");
private static final QName FIRST_AUGMENT = QName.create("http://www.example.com/mainmodule", "first-augment");
@Test
private static final QName ANOTHER_CONTAINER = QName.create("http://www.example.com/anothermodule",
"another-container");
private static final QName FIRST_AUGMENT = QName.create("http://www.example.com/mainmodule", "first-augment");
@Test
- public void testAugmentationConditional() throws Exception {
- final DataSchemaNode another = StmtTestUtils.parseYangSources("/bugs/YT956/")
- .findDataChildByName(ANOTHER_CONTAINER).get();
+ public void testAugmentationConditional() {
+ final DataSchemaNode another = assertEffectiveModelDir("/bugs/YT956/")
+ .getDataChildByName(ANOTHER_CONTAINER);
assertThat(another, isA(ContainerSchemaNode.class));
final ContainerSchemaNode anotherContainer = (ContainerSchemaNode) another;
assertThat(another, isA(ContainerSchemaNode.class));
final ContainerSchemaNode anotherContainer = (ContainerSchemaNode) another;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
-import java.util.Collection;
-import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.ModuleImport;
public class YangParserIdentityTest extends AbstractYangTest {
import org.opendaylight.yangtools.yang.model.api.ModuleImport;
public class YangParserIdentityTest extends AbstractYangTest {
// imported module prefixed base identity name equals identity name, but
// prefix differs
@Test
// imported module prefixed base identity name equals identity name, but
// prefix differs
@Test
- public void testParsingImportPrefixIdentityTestModule() throws Exception {
- Module module = StmtTestUtils.parseYangSources("/identity/import").findModules("prefiximportidentitytest")
+ public void testParsingImportPrefixIdentityTestModule() {
+ final var module = assertEffectiveModelDir("/identity/import").findModules("prefiximportidentitytest")
- Collection<? extends ModuleImport> imports = module.getImports();
+ final var imports = module.getImports();
assertEquals(imports.size(), 1);
ModuleImport dummy = TestUtils.findImport(imports, "dummy");
assertNotEquals(dummy.getPrefix(), module.getPrefix());
assertEquals(imports.size(), 1);
ModuleImport dummy = TestUtils.findImport(imports, "dummy");
assertNotEquals(dummy.getPrefix(), module.getPrefix());
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
import java.util.List;
import java.util.Optional;
import org.junit.Test;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
import java.util.List;
import java.util.Optional;
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.SchemaContext;
import org.opendaylight.yangtools.yang.model.api.SchemaNode;
import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
import org.opendaylight.yangtools.yang.model.api.type.Int32TypeDefinition;
import org.opendaylight.yangtools.yang.model.api.SchemaNode;
import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
import org.opendaylight.yangtools.yang.model.api.type.Int32TypeDefinition;
import org.opendaylight.yangtools.yang.model.api.type.PatternConstraint;
import org.opendaylight.yangtools.yang.model.api.type.RangeConstraint;
import org.opendaylight.yangtools.yang.model.api.type.StringTypeDefinition;
import org.opendaylight.yangtools.yang.model.api.type.PatternConstraint;
import org.opendaylight.yangtools.yang.model.api.type.RangeConstraint;
import org.opendaylight.yangtools.yang.model.api.type.StringTypeDefinition;
-import org.opendaylight.yangtools.yang.stmt.StmtTestUtils;
+import org.opendaylight.yangtools.yang.stmt.AbstractYangTest;
-public class Bug5200Test {
+public class Bug5200Test extends AbstractYangTest {
private static final String NS = "foo";
private static final String REV = "2016-05-05";
@Test
private static final String NS = "foo";
private static final String REV = "2016-05-05";
@Test
- public void test() throws Exception {
- SchemaContext context = StmtTestUtils.parseYangSources("/bugs/bug5200");
- assertNotNull(context);
+ public void test() {
+ final var context = assertEffectiveModelDir("/bugs/bug5200");
QName root = QName.create(NS, REV, "root");
QName myLeaf = QName.create(NS, REV, "my-leaf");
QName root = QName.create(NS, REV, "root");
QName myLeaf = QName.create(NS, REV, "my-leaf");