*/
package org.opendaylight.yangtools.yang.stmt;
-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.Collection;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.common.QNameModule;
import org.opendaylight.yangtools.yang.common.Revision;
import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute;
import org.opendaylight.yangtools.yang.model.api.type.TypeDefinitions;
-public class AugmentTest extends AbstractYangTest {
+class AugmentTest extends AbstractYangTest {
private static final QNameModule FOO = QNameModule.create(
XMLNamespace.of("urn:opendaylight.foo"), Revision.of("2013-10-13"));
private static final QNameModule BAR = QNameModule.create(
private static EffectiveModelContext AUGMENT_IN_AUGMENT;
- @BeforeClass
- public static void beforeClass() throws Exception {
+ @BeforeAll
+ static void beforeClass() throws Exception {
AUGMENT_IN_AUGMENT = assertEffectiveModelDir("/augment-test/augment-in-augment");
}
@Test
- public void testAugmentParsing() {
+ void testAugmentParsing() {
// foo.yang
final Module module1 = AUGMENT_IN_AUGMENT.findModules("foo").iterator().next();
- Collection<? extends AugmentationSchemaNode> augmentations = module1.getAugmentations();
+ var augmentations = module1.getAugmentations();
assertEquals(1, augmentations.size());
final AugmentationSchemaNode augment = augmentations.iterator().next();
assertNotNull(augment);
assertEquals(Absolute.of(Q0, Q1, Q2), augment.getTargetPath());
- final Collection<? extends DataSchemaNode> augmentChildren = augment.getChildNodes();
+ final var augmentChildren = augment.getChildNodes();
assertEquals(4, augmentChildren.size());
for (final DataSchemaNode dsn : augmentChildren) {
checkIsAugmenting(dsn, false);
}
final LeafSchemaNode ds0ChannelNumber = (LeafSchemaNode) augment.getDataChildByName(QName.create(
- module1.getQNameModule(), "ds0ChannelNumber"));
+ module1.getQNameModule(), "ds0ChannelNumber"));
final LeafSchemaNode interfaceId = (LeafSchemaNode) augment.getDataChildByName(QName.create(
- module1.getQNameModule(), "interface-id"));
+ module1.getQNameModule(), "interface-id"));
final ContainerSchemaNode schemas = (ContainerSchemaNode) augment.getDataChildByName(QName.create(
- module1.getQNameModule(), "schemas"));
+ module1.getQNameModule(), "schemas"));
final ChoiceSchemaNode odl = (ChoiceSchemaNode) augment.getDataChildByName(QName.create(
- module1.getQNameModule(), "odl"));
+ module1.getQNameModule(), "odl"));
assertNotNull(ds0ChannelNumber);
assertNotNull(interfaceId);
assertEquals(1, augment1.getChildNodes().size());
final ContainerSchemaNode augmentHolder = (ContainerSchemaNode) augment1.getDataChildByName(QName.create(
- module3.getQNameModule(), "augment-holder"));
+ module3.getQNameModule(), "augment-holder"));
assertNotNull(augmentHolder);
assertEquals(1, augment2.getChildNodes().size());
final ContainerSchemaNode augmentHolder2 = (ContainerSchemaNode) augment2.getDataChildByName(QName.create(
- module3.getQNameModule(), "augment-holder2"));
+ module3.getQNameModule(), "augment-holder2"));
assertNotNull(augmentHolder2);
assertEquals(1, augment3.getChildNodes().size());
final CaseSchemaNode pause = (CaseSchemaNode) augment3.getDataChildByName(QName.create(
- module3.getQNameModule(), "pause"));
+ module3.getQNameModule(), "pause"));
assertNotNull(pause);
}
@Test
- public void testAugmentResolving() {
+ void testAugmentResolving() {
final Module module2 = AUGMENT_IN_AUGMENT.findModules("bar").iterator().next();
final ContainerSchemaNode interfaces = (ContainerSchemaNode) module2.getDataChildByName(QName.create(
- module2.getQNameModule(), "interfaces"));
+ module2.getQNameModule(), "interfaces"));
final ListSchemaNode ifEntry = (ListSchemaNode) interfaces.getDataChildByName(QName.create(
- module2.getQNameModule(), "ifEntry"));
+ module2.getQNameModule(), "ifEntry"));
// baz.yang
// augment "/br:interfaces/br:ifEntry" {
final ContainerSchemaNode augmentHolder = (ContainerSchemaNode) ifEntry.getDataChildByName(QName.create(BAZ,
- "augment-holder"));
+ "augment-holder"));
checkIsAugmenting(augmentHolder, true);
assertEquals(Q2, augmentHolder.getQName());
// foo.yang
// augment "/br:interfaces/br:ifEntry/bz:augment-holder"
final LeafSchemaNode ds0ChannelNumber = (LeafSchemaNode) augmentHolder.getDataChildByName(QName.create(FOO,
- "ds0ChannelNumber"));
+ "ds0ChannelNumber"));
final LeafSchemaNode interfaceId = (LeafSchemaNode) augmentHolder.getDataChildByName(QName.create(FOO,
- "interface-id"));
+ "interface-id"));
final ContainerSchemaNode schemas = (ContainerSchemaNode) augmentHolder.getDataChildByName(QName.create(FOO,
- "schemas"));
+ "schemas"));
final ChoiceSchemaNode odl = (ChoiceSchemaNode) augmentHolder.getDataChildByName(QName.create(FOO, "odl"));
assertNotNull(ds0ChannelNumber);
}
@Test
- public void testAugmentedChoice() {
+ void testAugmentedChoice() {
final Module module2 = AUGMENT_IN_AUGMENT.findModules("bar").iterator().next();
final ContainerSchemaNode interfaces = (ContainerSchemaNode) module2.getDataChildByName(QName.create(
- module2.getQNameModule(), "interfaces"));
+ module2.getQNameModule(), "interfaces"));
final ListSchemaNode ifEntry = (ListSchemaNode) interfaces.getDataChildByName(QName.create(
- module2.getQNameModule(), "ifEntry"));
+ module2.getQNameModule(), "ifEntry"));
final ContainerSchemaNode augmentedHolder = (ContainerSchemaNode) ifEntry.getDataChildByName(QName.create(
- BAZ, "augment-holder"));
+ BAZ, "augment-holder"));
checkIsAugmenting(augmentedHolder, true);
// foo.yang
// augment "/br:interfaces/br:ifEntry/bz:augment-holder"
final ChoiceSchemaNode odl = (ChoiceSchemaNode) augmentedHolder.getDataChildByName(QName.create(FOO, "odl"));
assertNotNull(odl);
- final Collection<? extends CaseSchemaNode> cases = odl.getCases();
+ final var cases = odl.getCases();
assertEquals(4, cases.size());
CaseSchemaNode id = null;
// case id
assertEquals(QName.create(FOO, "id"), id.getQName());
- final Collection<? extends DataSchemaNode> idChildren = id.getChildNodes();
+ final var idChildren = id.getChildNodes();
assertEquals(1, idChildren.size());
// case node1
assertEquals(QName.create(FOO, "node1"), node1.getQName());
- final Collection<? extends DataSchemaNode> node1Children = node1.getChildNodes();
+ final var node1Children = node1.getChildNodes();
assertTrue(node1Children.isEmpty());
// case node2
assertEquals(QName.create(FOO, "node2"), node2.getQName());
- final Collection<? extends DataSchemaNode> node2Children = node2.getChildNodes();
+ final var node2Children = node2.getChildNodes();
assertTrue(node2Children.isEmpty());
// case node3
assertEquals(QName.create(FOO, "node3"), node3.getQName());
- final Collection<? extends DataSchemaNode> node3Children = node3.getChildNodes();
+ final var node3Children = node3.getChildNodes();
assertEquals(1, node3Children.size());
// test cases
}
@Test
- public void testAugmentRpc() throws Exception {
+ void testAugmentRpc() throws Exception {
final EffectiveModelContext context = assertEffectiveModelDir("/augment-test/rpc");
final XMLNamespace NS_BAR = XMLNamespace.of("urn:opendaylight:bar");
final XMLNamespace NS_FOO = XMLNamespace.of("urn:opendaylight:foo");
final Revision revision = Revision.of("2013-10-11");
final Module bar = context.findModules("bar").iterator().next();
- final Collection<? extends RpcDefinition> rpcs = bar.getRpcs();
+ final var rpcs = bar.getRpcs();
assertEquals(2, rpcs.size());
RpcDefinition submit = null;
final QName inputQName = QName.create(NS_BAR, revision, "input");
assertEquals(inputQName, input.getQName());
final ChoiceSchemaNode arguments = (ChoiceSchemaNode) input.getDataChildByName(QName.create(NS_BAR, revision,
- "arguments"));
+ "arguments"));
final QName argumentsQName = QName.create(NS_BAR, revision, "arguments");
assertEquals(argumentsQName, arguments.getQName());
assertFalse(arguments.isAugmenting());
- final Collection<? extends CaseSchemaNode> cases = arguments.getCases();
+ final var cases = arguments.getCases();
assertEquals(3, cases.size());
CaseSchemaNode attach = null;
// case attach
assertEquals(QName.create(NS_FOO, revision, "attach"), attach.getQName());
- final Collection<? extends DataSchemaNode> attachChildren = attach.getChildNodes();
+ final var attachChildren = attach.getChildNodes();
assertEquals(1, attachChildren.size());
// case create
assertEquals(QName.create(NS_FOO, revision, "create"), create.getQName());
- final Collection<? extends DataSchemaNode> createChildren = create.getChildNodes();
+ final var createChildren = create.getChildNodes();
assertEquals(1, createChildren.size());
// case attach
assertEquals(QName.create(NS_FOO, revision, "destroy"), destroy.getQName());
- final Collection<? extends DataSchemaNode> destroyChildren = destroy.getChildNodes();
+ final var destroyChildren = destroy.getChildNodes();
assertEquals(1, destroyChildren.size());
}
@Test
- public void testAugmentInUsesResolving() throws Exception {
+ void testAugmentInUsesResolving() throws Exception {
final EffectiveModelContext context = assertEffectiveModelDir("/augment-test/augment-in-uses");
assertEquals(1, context.getModules().size());
final Module test = context.getModules().iterator().next();
final DataNodeContainer links = (DataNodeContainer) test.getDataChildByName(QName.create(test.getQNameModule(),
- "links"));
+ "links"));
final DataNodeContainer link = (DataNodeContainer) links.getDataChildByName(QName.create(test.getQNameModule(),
- "link"));
+ "link"));
final DataNodeContainer nodes = (DataNodeContainer) link.getDataChildByName(QName.create(test.getQNameModule(),
- "nodes"));
+ "nodes"));
final ContainerSchemaNode node = (ContainerSchemaNode) nodes.getDataChildByName(QName.create(
- test.getQNameModule(), "node"));
- final Collection<? extends AugmentationSchemaNode> augments = node.getAvailableAugmentations();
+ test.getQNameModule(), "node"));
+ final var augments = node.getAvailableAugmentations();
assertEquals(1, augments.size());
assertEquals(1, node.getChildNodes().size());
final LeafSchemaNode id = (LeafSchemaNode) node.getDataChildByName(QName.create(test.getQNameModule(), "id"));