*/
package org.opendaylight.yangtools.yang.parser.impl;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
-import java.io.FileNotFoundException;
import java.net.URI;
import java.text.DateFormat;
import java.text.ParseException;
import java.util.Date;
import java.util.List;
import java.util.Set;
-
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.model.api.*;
+import org.opendaylight.yangtools.yang.model.api.AnyXmlSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.ConstraintDefinition;
+import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.GroupingDefinition;
+import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.Module;
+import org.opendaylight.yangtools.yang.model.api.MustDefinition;
+import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+import org.opendaylight.yangtools.yang.model.api.Status;
+import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.UsesNode;
public class YangParserSimpleTest {
private final URI snNS = URI.create("urn:opendaylight:simple-nodes");
private Set<Module> modules;
@Before
- public void init() throws FileNotFoundException, ParseException {
+ public void init() throws Exception {
snRev = simpleDateFormat.parse("2013-07-30");
- modules = TestUtils.loadModules(getClass().getResource("/simple-test").getPath());
+ modules = TestUtils.loadModules(getClass().getResource("/simple-test").toURI());
}
@Test
// test SchemaNode args
QName qname = data.getQName();
assertEquals("data", qname.getLocalName());
- assertEquals(snPref, qname.getPrefix());
assertEquals(snNS, qname.getNamespace());
assertEquals(snRev, qname.getRevision());
assertEquals("anyxml desc", data.getDescription());
ContainerSchemaNode nodes = (ContainerSchemaNode) test.getDataChildByName("nodes");
// test SchemaNode args
- QName expectedQName = new QName(snNS, snRev, snPref, "nodes");
+ QName expectedQName = QName.create(snNS, snRev, "nodes");
assertEquals(expectedQName, nodes.getQName());
SchemaPath expectedPath = TestUtils.createPath(true, snNS, snRev, snPref, "nodes");
assertEquals(expectedPath, nodes.getPath());
Set<TypeDefinition<?>> typedefs = nodes.getTypeDefinitions();
assertEquals(1, typedefs.size());
TypeDefinition<?> nodesType = typedefs.iterator().next();
- QName typedefQName = new QName(snNS, snRev, snPref, "nodes-type");
+ QName typedefQName = QName.create(snNS, snRev, "nodes-type");
assertEquals(typedefQName, nodesType.getQName());
SchemaPath nodesTypePath = TestUtils.createPath(true, snNS, snRev, snPref, "nodes", "nodes-type");
assertEquals(nodesTypePath, nodesType.getPath());
- assertNull(nodesType.getDescription());
- assertNull(nodesType.getReference());
+ assertTrue(nodesType.getDescription().isEmpty());
+ assertTrue(nodesType.getReference().isEmpty());
assertEquals(Status.CURRENT, nodesType.getStatus());
assertEquals(0, nodesType.getUnknownSchemaNodes().size());
Set<GroupingDefinition> groupings = nodes.getGroupings();
assertEquals(1, groupings.size());
GroupingDefinition nodeGroup = groupings.iterator().next();
- QName groupQName = new QName(snNS, snRev, snPref, "node-group");
+ QName groupQName = QName.create(snNS, snRev, "node-group");
assertEquals(groupQName, nodeGroup.getQName());
SchemaPath nodeGroupPath = TestUtils.createPath(true, snNS, snRev, snPref, "nodes", "node-group");
assertEquals(nodeGroupPath, nodeGroup.getPath());
private Date rev;
private final String prefix = "sn";
- private SchemaPath createPath(String... names) {
+ private SchemaPath createPath(final String... names) {
try {
rev = new SimpleDateFormat("yyyy-MM-dd").parse("2013-07-30");
} catch (ParseException e) {
List<QName> path = new ArrayList<>();
for (String name : names) {
- path.add(new QName(ns, rev, prefix, name));
+ path.add(QName.create(ns, rev, name));
}
- return new SchemaPath(path, true);
+ return SchemaPath.create(path, true);
}
}