*/
package org.opendaylight.yangtools.odlext.parser;
-import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertSame;
-import java.util.List;
-import java.util.stream.Collectors;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.opendaylight.yangtools.odlext.model.api.ContextInstanceEffectiveStatement;
import org.opendaylight.yangtools.odlext.model.api.ContextReferenceEffectiveStatement;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.common.QNameModule;
import org.opendaylight.yangtools.yang.common.XMLNamespace;
-import org.opendaylight.yangtools.yang.model.api.stmt.DataTreeEffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.GroupingEffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.LeafEffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.LeafListEffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.ListEffectiveStatement;
-import org.opendaylight.yangtools.yang.model.api.stmt.ModuleEffectiveStatement;
import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
import org.opendaylight.yangtools.yang.parser.api.YangParserConfiguration;
import org.opendaylight.yangtools.yang.parser.rfc7950.reactor.RFC7950Reactors;
import org.opendaylight.yangtools.yang.parser.rfc7950.repo.YangStatementStreamSource;
import org.opendaylight.yangtools.yang.parser.spi.meta.ModelProcessingPhase;
-import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor;
-public class ContextReferenceTest {
+class ContextReferenceTest {
private static final QNameModule FOO = QNameModule.create(XMLNamespace.of("foo"));
private static final QName LEAF_TYPE = QName.create(FOO, "leaf-type");
private static final QName LIST_TYPE = QName.create(FOO, "list-type");
- private static CrossSourceStatementReactor reactor;
-
- @BeforeClass
- public static void createReactor() {
- reactor = RFC7950Reactors.vanillaReactorBuilder()
+ @Test
+ void test() throws Exception {
+ final var reactor = RFC7950Reactors.vanillaReactorBuilder()
.addStatementSupport(ModelProcessingPhase.FULL_DECLARATION,
new ContextInstanceStatementSupport(YangParserConfiguration.DEFAULT))
.addStatementSupport(ModelProcessingPhase.FULL_DECLARATION,
new ContextReferenceStatementSupport(YangParserConfiguration.DEFAULT))
.build();
- }
- @AfterClass
- public static void freeReactor() {
- reactor = null;
- }
-
- @Test
- public void test() throws Exception {
- final ModuleEffectiveStatement foo = reactor.newBuild()
+ final var foo = reactor.newBuild()
.addSource(YangStatementStreamSource.create(YangTextSchemaSource.forResource("/yang-ext.yang")))
.addSource(YangStatementStreamSource.create(YangTextSchemaSource.forResource("/ctxref.yang")))
.buildEffective()
.getModuleStatements()
.get(FOO);
- final DataTreeEffectiveStatement<?> list = foo.findDataTreeNode(QName.create(FOO, "list")).orElseThrow();
- assertThat(list, instanceOf(ListEffectiveStatement.class));
+ final var list = assertInstanceOf(ListEffectiveStatement.class,
+ foo.findDataTreeNode(QName.create(FOO, "list")).orElseThrow());
- final ContextInstanceEffectiveStatement listType = list
- .findFirstEffectiveSubstatement(ContextInstanceEffectiveStatement.class).orElseThrow();
+ final var listType = list.findFirstEffectiveSubstatement(ContextInstanceEffectiveStatement.class).orElseThrow();
assertEquals(LIST_TYPE, listType.argument());
assertEquals(LIST_TYPE, listType.contextType().argument());
- final ContextInstanceEffectiveStatement leafType = list
+ final var leafType = list
.findFirstEffectiveSubstatement(LeafEffectiveStatement.class).orElseThrow()
.findFirstEffectiveSubstatement(ContextInstanceEffectiveStatement.class).orElseThrow();
assertEquals(LEAF_TYPE, leafType.argument());
assertEquals(LEAF_TYPE, leafType.contextType().argument());
- final List<GroupingEffectiveStatement> groupings = foo
- .streamEffectiveSubstatements(GroupingEffectiveStatement.class).collect(Collectors.toList());
+ final var groupings = foo.streamEffectiveSubstatements(GroupingEffectiveStatement.class).toList();
assertEquals(2, groupings.size());
- final ContextReferenceEffectiveStatement listRef = groupings.get(1)
+ final var listRef = groupings.get(1)
.findFirstEffectiveSubstatement(LeafEffectiveStatement.class).orElseThrow()
.findFirstEffectiveSubstatement(ContextReferenceEffectiveStatement.class).orElseThrow();
assertEquals(LIST_TYPE, listType.argument());
assertSame(listType.contextType(), listRef.contextType());
- final ContextReferenceEffectiveStatement leafRef = groupings.get(0)
+ final var leafRef = groupings.get(0)
.findFirstEffectiveSubstatement(LeafListEffectiveStatement.class).orElseThrow()
.findFirstEffectiveSubstatement(ContextReferenceEffectiveStatement.class).orElseThrow();
assertEquals(LEAF_TYPE, leafType.argument());
*/
package org.opendaylight.yangtools.odlext.parser;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertTrue;
-import java.util.Optional;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.opendaylight.yangtools.odlext.model.api.MountEffectiveStatement;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.common.QNameModule;
import org.opendaylight.yangtools.yang.common.XMLNamespace;
-import org.opendaylight.yangtools.yang.model.api.stmt.ModuleEffectiveStatement;
import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
import org.opendaylight.yangtools.yang.parser.api.YangParserConfiguration;
import org.opendaylight.yangtools.yang.parser.rfc7950.reactor.RFC7950Reactors;
import org.opendaylight.yangtools.yang.parser.rfc7950.repo.YangStatementStreamSource;
import org.opendaylight.yangtools.yang.parser.spi.meta.ModelProcessingPhase;
-import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor;
-public class MountTest {
+class MountTest {
private static final QNameModule FOO = QNameModule.create(XMLNamespace.of("foo"));
- private static CrossSourceStatementReactor reactor;
-
- @BeforeClass
- public static void createReactor() {
- reactor = RFC7950Reactors.vanillaReactorBuilder()
+ @Test
+ void test() throws Exception {
+ final var reactor = RFC7950Reactors.vanillaReactorBuilder()
.addStatementSupport(ModelProcessingPhase.FULL_DECLARATION,
new MountStatementSupport(YangParserConfiguration.DEFAULT))
.build();
- }
-
- @AfterClass
- public static void freeReactor() {
- reactor = null;
- }
-
- @Test
- public void test() throws Exception {
- final ModuleEffectiveStatement foo = reactor.newBuild()
+ final var foo = reactor.newBuild()
.addSource(YangStatementStreamSource.create(YangTextSchemaSource.forResource("/yang-ext.yang")))
.addSource(YangStatementStreamSource.create(YangTextSchemaSource.forResource("/mount.yang")))
.buildEffective()
.getModuleStatements()
.get(FOO);
- final Optional<MountEffectiveStatement> fooMount = foo.findDataTreeNode(QName.create(FOO, "foo")).orElseThrow()
- .findFirstEffectiveSubstatement(MountEffectiveStatement.class);
- assertTrue(fooMount.isPresent());
-
- final Optional<MountEffectiveStatement> barMount = foo.findDataTreeNode(QName.create(FOO, "bar")).orElseThrow()
- .findFirstEffectiveSubstatement(MountEffectiveStatement.class);
- assertTrue(barMount.isPresent());
+ assertTrue(foo.findDataTreeNode(QName.create(FOO, "foo")).orElseThrow()
+ .findFirstEffectiveSubstatement(MountEffectiveStatement.class)
+ .isPresent());
+ assertTrue(foo.findDataTreeNode(QName.create(FOO, "bar")).orElseThrow()
+ .findFirstEffectiveSubstatement(MountEffectiveStatement.class)
+ .isPresent());
}
}