import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
+import static org.opendaylight.yangtools.yang.stmt.StmtTestUtils.assertPathEquals;
import java.io.IOException;
-import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayDeque;
import java.util.Collection;
import java.util.Deque;
-import java.util.Set;
import org.junit.Before;
import org.junit.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.common.XMLNamespace;
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.type.Uint8TypeDefinition;
import org.opendaylight.yangtools.yang.model.api.type.UnionTypeDefinition;
import org.opendaylight.yangtools.yang.model.parser.api.YangSyntaxErrorException;
-import org.opendaylight.yangtools.yang.model.util.type.BaseTypes;
+import org.opendaylight.yangtools.yang.model.ri.type.BaseTypes;
import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
public class UsesAugmentTest {
private static final QNameModule UG = QNameModule.create(
- URI.create("urn:opendaylight:params:xml:ns:yang:uses-grouping"), Revision.of("2013-07-30"));
+ XMLNamespace.of("urn:opendaylight:params:xml:ns:yang:uses-grouping"), Revision.of("2013-07-30"));
private static final QNameModule GD = QNameModule.create(
- URI.create("urn:opendaylight:params:xml:ns:yang:grouping-definitions"), Revision.of("2013-09-04"));
+ XMLNamespace.of("urn:opendaylight:params:xml:ns:yang:grouping-definitions"), Revision.of("2013-09-04"));
private SchemaContext context;
final Deque<QName> path = new ArrayDeque<>();
// * notification pcreq
- final Set<NotificationDefinition> notifications = testModule.getNotifications();
+ final Collection<? extends NotificationDefinition> notifications = testModule.getNotifications();
assertEquals(1, notifications.size());
final NotificationDefinition pcreq = notifications.iterator().next();
assertNotNull(pcreq);
QName expectedQName = QName.create(UG, "pcreq");
path.offer(expectedQName);
SchemaPath expectedPath = SchemaPath.create(path, true);
- assertEquals(expectedPath, pcreq.getPath());
- Collection<DataSchemaNode> childNodes = pcreq.getChildNodes();
+ assertPathEquals(expectedPath, pcreq);
+ Collection<? extends DataSchemaNode> childNodes = pcreq.getChildNodes();
assertEquals(4, childNodes.size());
// * |-- leaf version
LeafSchemaNode version = (LeafSchemaNode) pcreq.getDataChildByName(QName.create(testModule.getQNameModule(),
expectedQName = QName.create(UG, "version");
path.offer(expectedQName);
expectedPath = SchemaPath.create(path, true);
- assertEquals(expectedPath, version.getPath());
+ assertPathEquals(expectedPath, version);
expectedQName = QName.create(UG, "version");
path.offer(expectedQName);
- expectedPath = SchemaPath.create(true, pcreq.getQName(), expectedQName);
- assertEquals(expectedPath, version.getType().getPath());
+ assertEquals(expectedQName, version.getType().getQName());
assertEquals(BaseTypes.uint8Type(), version.getType().getBaseType().getBaseType());
assertTrue(version.isAddedByUses());
// * |-- leaf type
path.pollLast();
path.offer(expectedQName);
expectedPath = SchemaPath.create(path, true);
- assertEquals(expectedPath, type.getPath());
+ assertPathEquals(expectedPath, type);
expectedQName = QName.create(GD, "int-ext");
path.offer(expectedQName);
- expectedPath = SchemaPath.create(true, expectedQName);
- assertEquals(expectedPath, type.getType().getPath());
+ assertEquals(expectedQName, type.getType().getQName());
final UnionTypeDefinition union = (UnionTypeDefinition) type.getType().getBaseType();
- assertEquals(SchemaPath.create(true, expectedQName, QName.create(expectedQName, "union")), union.getPath());
+ assertEquals(QName.create(expectedQName, "union"), union.getQName());
assertEquals(2, union.getTypes().size());
// * |-- list requests
final ListSchemaNode requests = (ListSchemaNode) pcreq.getDataChildByName(QName.create(
path.pollLast();
path.offer(expectedQName);
expectedPath = SchemaPath.create(path, true);
- assertEquals(expectedPath, requests.getPath());
+ assertPathEquals(expectedPath, requests);
assertFalse(requests.isAddedByUses());
childNodes = requests.getChildNodes();
assertEquals(3, childNodes.size());
expectedQName = QName.create(UG, "rp");
path.offer(expectedQName);
expectedPath = SchemaPath.create(path, true);
- assertEquals(expectedPath, rp.getPath());
+ assertPathEquals(expectedPath, rp);
assertFalse(rp.isAddedByUses());
childNodes = rp.getChildNodes();
assertEquals(4, childNodes.size());
assertEquals(expectedQName, processingRule.getQName());
path.offer(expectedQName);
expectedPath = SchemaPath.create(path, true);
- assertEquals(expectedPath, processingRule.getPath());
+ assertPathEquals(expectedPath, processingRule);
assertEquals(BaseTypes.booleanType(), processingRule.getType());
assertTrue(processingRule.isAddedByUses());
// * |-- |-- |-- leaf ignore
path.pollLast();
path.offer(expectedQName);
expectedPath = SchemaPath.create(path, true);
- assertEquals(expectedPath, ignore.getPath());
+ assertPathEquals(expectedPath, ignore);
assertEquals(BaseTypes.booleanType(), ignore.getType());
assertTrue(ignore.isAddedByUses());
// * |-- |-- |-- leaf priority
path.pollLast();
path.offer(expectedQName);
expectedPath = SchemaPath.create(path, true);
- assertEquals(expectedPath, priority.getPath());
+ assertPathEquals(expectedPath, priority);
expectedQName = QName.create(UG, "uint8");
path.offer(expectedQName);
expectedPath = SchemaPath.create(path, true);
path.pollLast();
path.offer(expectedQName);
expectedPath = SchemaPath.create(path, true);
- assertEquals(expectedPath, box.getPath());
+ assertPathEquals(expectedPath, box);
assertTrue(box.isAddedByUses());
// * |-- |-- |-- |-- container order
final ContainerSchemaNode order = (ContainerSchemaNode) box.getDataChildByName(QName.create(
assertEquals(expectedQName, order.getQName());
path.offer(expectedQName);
expectedPath = SchemaPath.create(path, true);
- assertEquals(expectedPath, order.getPath());
+ assertPathEquals(expectedPath, order);
assertTrue(order.isAddedByUses());
assertTrue(order.isAugmenting());
assertEquals(2, order.getChildNodes().size());
assertEquals(expectedQName, delete.getQName());
path.offer(expectedQName);
expectedPath = SchemaPath.create(path, true);
- assertEquals(expectedPath, delete.getPath());
+ assertPathEquals(expectedPath, delete);
assertEquals(BaseTypes.uint32Type(), delete.getType());
assertTrue(delete.isAddedByUses());
// * |-- |-- |-- |-- |-- leaf setup
path.pollLast();
path.offer(expectedQName);
expectedPath = SchemaPath.create(path, true);
- assertEquals(expectedPath, setup.getPath());
+ assertPathEquals(expectedPath, setup);
assertEquals(BaseTypes.uint32Type(), setup.getType());
assertTrue(setup.isAddedByUses());
// * |-- |-- path-key-expansion
path.pollLast();
path.offer(expectedQName);
expectedPath = SchemaPath.create(path, true);
- assertEquals(expectedPath, pke.getPath());
+ assertPathEquals(expectedPath, pke);
assertFalse(pke.isAddedByUses());
// * |-- |-- |-- path-key
final ContainerSchemaNode pathKey = (ContainerSchemaNode) pke.getDataChildByName(QName.create(
assertEquals(expectedQName, pathKey.getQName());
path.offer(expectedQName);
expectedPath = SchemaPath.create(path, true);
- assertEquals(expectedPath, pathKey.getPath());
+ assertPathEquals(expectedPath, pathKey);
assertFalse(pathKey.isAddedByUses());
assertEquals(3, pathKey.getChildNodes().size());
// * |-- |-- |-- |-- leaf processing-rule
assertEquals(expectedQName, processingRule.getQName());
path.offer(expectedQName);
expectedPath = SchemaPath.create(path, true);
- assertEquals(expectedPath, processingRule.getPath());
+ assertPathEquals(expectedPath, processingRule);
assertEquals(BaseTypes.booleanType(), processingRule.getType());
assertTrue(processingRule.isAddedByUses());
// * |-- |-- |-- |-- leaf ignore
path.pollLast();
path.offer(expectedQName);
expectedPath = SchemaPath.create(path, true);
- assertEquals(expectedPath, ignore.getPath());
+ assertPathEquals(expectedPath, ignore);
assertEquals(BaseTypes.booleanType(), ignore.getType());
assertTrue(ignore.isAddedByUses());
// * |-- |-- |-- |-- list path-keys
path.pollLast();
path.offer(expectedQName);
expectedPath = SchemaPath.create(path, true);
- assertEquals(expectedPath, pathKeys.getPath());
+ assertPathEquals(expectedPath, pathKeys);
assertTrue(pathKeys.isAddedByUses());
childNodes = pathKeys.getChildNodes();
assertEquals(2, childNodes.size());
assertEquals(expectedQName, version.getQName());
path.offer(expectedQName);
expectedPath = SchemaPath.create(path, true);
- assertEquals(expectedPath, version.getPath());
+ assertPathEquals(expectedPath, version);
assertTrue(version.getType() instanceof Uint8TypeDefinition);
assertEquals(BaseTypes.uint8Type(), version.getType().getBaseType().getBaseType());
assertTrue(version.isAddedByUses());
path.pollLast();
path.offer(expectedQName);
expectedPath = SchemaPath.create(path, true);
- assertEquals(expectedPath, type.getPath());
+ assertPathEquals(expectedPath, type);
assertTrue(type.getType() instanceof UnionTypeDefinition);
assertTrue(type.isAddedByUses());
assertTrue(type.isAugmenting());
path.pollLast();
path.offer(expectedQName);
expectedPath = SchemaPath.create(path, true);
- assertEquals(expectedPath, sc.getPath());
+ assertPathEquals(expectedPath, sc);
assertFalse(sc.isAddedByUses());
// * |-- |-- |-- container p2p
final ContainerSchemaNode p2p = (ContainerSchemaNode) sc.getDataChildByName(QName.create(
assertEquals(expectedQName, p2p.getQName());
path.offer(expectedQName);
expectedPath = SchemaPath.create(path, true);
- assertEquals(expectedPath, p2p.getPath());
+ assertPathEquals(expectedPath, p2p);
assertFalse(p2p.isAddedByUses());
// * |-- |-- |-- |-- container endpoints
final ContainerSchemaNode endpoints = (ContainerSchemaNode) p2p.getDataChildByName(QName.create(
assertEquals(expectedQName, endpoints.getQName());
path.offer(expectedQName);
expectedPath = SchemaPath.create(path, true);
- assertEquals(expectedPath, endpoints.getPath());
+ assertPathEquals(expectedPath, endpoints);
assertFalse(endpoints.isAddedByUses());
// * |-- |-- |-- |-- |-- leaf processing-rule
processingRule = (LeafSchemaNode) endpoints.getDataChildByName(QName.create(testModule.getQNameModule(),
assertEquals(expectedQName, processingRule.getQName());
path.offer(expectedQName);
expectedPath = SchemaPath.create(path, true);
- assertEquals(expectedPath, processingRule.getPath());
+ assertPathEquals(expectedPath, processingRule);
assertEquals(BaseTypes.booleanType(), processingRule.getType());
assertTrue(processingRule.isAddedByUses());
// * |-- |-- |-- |-- |-- leaf ignore
path.pollLast();
path.offer(expectedQName);
expectedPath = SchemaPath.create(path, true);
- assertEquals(expectedPath, ignore.getPath());
+ assertPathEquals(expectedPath, ignore);
assertEquals(BaseTypes.booleanType(), ignore.getType());
assertTrue(ignore.isAddedByUses());
// * |-- |-- |-- |-- |-- container box
path.pollLast();
path.offer(expectedQName);
expectedPath = SchemaPath.create(path, true);
- assertEquals(expectedPath, box.getPath());
+ assertPathEquals(expectedPath, box);
assertTrue(box.isAddedByUses());
// * |-- |-- |-- |-- |-- choice address-family
final ChoiceSchemaNode af = (ChoiceSchemaNode) endpoints.getDataChildByName(QName.create(
path.pollLast();
path.offer(expectedQName);
expectedPath = SchemaPath.create(path, true);
- assertEquals(expectedPath, af.getPath());
+ assertPathEquals(expectedPath, af);
assertTrue(af.isAddedByUses());
// * |-- |-- |-- |-- container reported-route
final ContainerSchemaNode reportedRoute = (ContainerSchemaNode) p2p.getDataChildByName(QName.create(
path.pollLast();
path.offer(expectedQName);
expectedPath = SchemaPath.create(path, true);
- assertEquals(expectedPath, reportedRoute.getPath());
+ assertPathEquals(expectedPath, reportedRoute);
assertFalse(reportedRoute.isAddedByUses());
// * |-- |-- |-- |-- |-- leaf processing-rule
processingRule = (LeafSchemaNode) reportedRoute.getDataChildByName(QName.create(testModule.getQNameModule(),
assertEquals(expectedQName, processingRule.getQName());
path.offer(expectedQName);
expectedPath = SchemaPath.create(path, true);
- assertEquals(expectedPath, processingRule.getPath());
+ assertPathEquals(expectedPath, processingRule);
assertEquals(BaseTypes.booleanType(), processingRule.getType());
assertTrue(processingRule.isAddedByUses());
// * |-- |-- |-- |-- |-- leaf ignore
path.pollLast();
path.offer(expectedQName);
expectedPath = SchemaPath.create(path, true);
- assertEquals(expectedPath, ignore.getPath());
+ assertPathEquals(expectedPath, ignore);
assertEquals(BaseTypes.booleanType(), ignore.getType());
assertTrue(ignore.isAddedByUses());
// * |-- |-- |-- |-- |-- list subobjects
path.pollLast();
path.offer(expectedQName);
expectedPath = SchemaPath.create(path, true);
- assertEquals(expectedPath, subobjects.getPath());
+ assertPathEquals(expectedPath, subobjects);
assertTrue(subobjects.isAddedByUses());
// * |-- |-- |-- |-- |-- container bandwidth
ContainerSchemaNode bandwidth = (ContainerSchemaNode) reportedRoute.getDataChildByName(QName.create(
path.pollLast();
path.offer(expectedQName);
expectedPath = SchemaPath.create(path, true);
- assertEquals(expectedPath, bandwidth.getPath());
+ assertPathEquals(expectedPath, bandwidth);
assertFalse(bandwidth.isAddedByUses());
// * |-- |-- |-- |-- container bandwidth
bandwidth = (ContainerSchemaNode) p2p
path.pollLast();
path.offer(expectedQName);
expectedPath = SchemaPath.create(path, true);
- assertEquals(expectedPath, bandwidth.getPath());
+ assertPathEquals(expectedPath, bandwidth);
assertTrue(bandwidth.isAddedByUses());
// * |-- |-- |-- |-- |-- leaf processing-rule
processingRule = (LeafSchemaNode) bandwidth.getDataChildByName(QName.create(testModule.getQNameModule(),
assertEquals(expectedQName, processingRule.getQName());
path.offer(expectedQName);
expectedPath = SchemaPath.create(path, true);
- assertEquals(expectedPath, processingRule.getPath());
+ assertPathEquals(expectedPath, processingRule);
assertEquals(BaseTypes.booleanType(), processingRule.getType());
assertTrue(processingRule.isAddedByUses());
// * |-- |-- |-- |-- |-- leaf ignore
path.pollLast();
path.offer(expectedQName);
expectedPath = SchemaPath.create(path, true);
- assertEquals(expectedPath, ignore.getPath());
+ assertPathEquals(expectedPath, ignore);
assertEquals(BaseTypes.booleanType(), ignore.getType());
assertTrue(ignore.isAddedByUses());
// * |-- |-- |-- |-- |-- container bandwidth
path.pollLast();
path.offer(expectedQName);
expectedPath = SchemaPath.create(path, true);
- assertEquals(expectedPath, bandwidthInner.getPath());
+ assertPathEquals(expectedPath, bandwidthInner);
assertTrue(bandwidthInner.isAddedByUses());
// * |-- list svec
final ListSchemaNode svec = (ListSchemaNode) pcreq.getDataChildByName(QName.create(testModule.getQNameModule(),
path.pollLast();
path.offer(expectedQName);
expectedPath = SchemaPath.create(path, true);
- assertEquals(expectedPath, svec.getPath());
+ assertPathEquals(expectedPath, svec);
assertFalse(svec.isAddedByUses());
// * |-- |-- leaf link-diverse
final LeafSchemaNode linkDiverse = (LeafSchemaNode) svec.getDataChildByName(QName.create(
assertEquals(expectedQName, linkDiverse.getQName());
path.offer(expectedQName);
expectedPath = SchemaPath.create(path, true);
- assertEquals(expectedPath, linkDiverse.getPath());
+ assertPathEquals(expectedPath, linkDiverse);
assertEquals(BaseTypes.booleanType(), linkDiverse.getType().getBaseType());
assertTrue(linkDiverse.isAddedByUses());
// * |-- |-- leaf processing-rule
path.pollLast();
path.offer(expectedQName);
expectedPath = SchemaPath.create(path, true);
- assertEquals(expectedPath, processingRule.getPath());
+ assertPathEquals(expectedPath, processingRule);
assertEquals(BaseTypes.booleanType(), processingRule.getType());
assertTrue(processingRule.isAddedByUses());
// * |-- |-- leaf ignore
path.pollLast();
path.offer(expectedQName);
expectedPath = SchemaPath.create(path, true);
- assertEquals(expectedPath, ignore.getPath());
+ assertPathEquals(expectedPath, ignore);
assertEquals(BaseTypes.booleanType(), ignore.getType());
assertTrue(ignore.isAddedByUses());
// * |-- |-- list metric
path.pollLast();
path.offer(expectedQName);
expectedPath = SchemaPath.create(path, true);
- assertEquals(expectedPath, metric.getPath());
+ assertPathEquals(expectedPath, metric);
assertFalse(metric.isAddedByUses());
// * |-- |-- |-- leaf metric-type
final LeafSchemaNode metricType = (LeafSchemaNode) metric.getDataChildByName(QName.create(
assertEquals(expectedQName, metricType.getQName());
path.offer(expectedQName);
expectedPath = SchemaPath.create(path, true);
- assertEquals(expectedPath, metricType.getPath());
+ assertPathEquals(expectedPath, metricType);
assertEquals(BaseTypes.uint8Type(), metricType.getType());
assertTrue(metricType.isAddedByUses());
// * |-- |-- |-- box
path.pollLast();
path.offer(expectedQName);
expectedPath = SchemaPath.create(path, true);
- assertEquals(expectedPath, box.getPath());
+ assertPathEquals(expectedPath, box);
assertTrue(box.isAddedByUses());
// * |-- |-- |-- leaf processing-rule
processingRule = (LeafSchemaNode) metric.getDataChildByName(QName.create(testModule.getQNameModule(),
path.pollLast();
path.offer(expectedQName);
expectedPath = SchemaPath.create(path, true);
- assertEquals(expectedPath, processingRule.getPath());
+ assertPathEquals(expectedPath, processingRule);
assertEquals(BaseTypes.booleanType(), processingRule.getType());
assertTrue(processingRule.isAddedByUses());
// * |-- |-- |-- leaf ignore
path.pollLast();
path.offer(expectedQName);
expectedPath = SchemaPath.create(path, true);
- assertEquals(expectedPath, ignore.getPath());
+ assertPathEquals(expectedPath, ignore);
assertEquals(BaseTypes.booleanType(), ignore.getType());
assertTrue(ignore.isAddedByUses());
}
@Test
public void testTypedefs() throws Exception {
final Module testModule = TestUtils.findModule(context, "grouping-definitions").get();
- final Set<TypeDefinition<?>> types = testModule.getTypeDefinitions();
+ final Collection<? extends TypeDefinition<?>> types = testModule.getTypeDefinitions();
TypeDefinition<?> intExt = null;
for (final TypeDefinition<?> td : types) {
}
assertNotNull(intExt);
- SchemaPath expectedPath = SchemaPath.create(true, QName.create(GD, "int-ext"));
- assertEquals(expectedPath, intExt.getPath());
+ assertEquals(QName.create(GD, "int-ext"), intExt.getQName());
final UnionTypeDefinition union = (UnionTypeDefinition) intExt.getBaseType();
}
assertNotNull(uint8);
assertNotNull(pv);
-
- expectedPath = SchemaPath.create(true, QName.create(GD, "int-ext"), QName.create(GD, "union"));
- assertEquals(expectedPath, union.getPath());
+ assertEquals(QName.create(GD, "union"), union.getQName());
}
}