import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
-import com.google.common.collect.Lists;
import java.io.FileNotFoundException;
import java.net.URI;
import java.net.URISyntaxException;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
+import java.util.ArrayDeque;
import java.util.Collection;
import java.util.Date;
-import java.util.LinkedList;
-import java.util.List;
+import java.util.Deque;
import java.util.Set;
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.yangtools.yang.model.api.NotificationDefinition;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
-import org.opendaylight.yangtools.yang.model.util.BaseTypes;
-import org.opendaylight.yangtools.yang.model.util.BooleanType;
-import org.opendaylight.yangtools.yang.model.util.ExtendedType;
-import org.opendaylight.yangtools.yang.model.util.Uint32;
-import org.opendaylight.yangtools.yang.model.util.Uint8;
-import org.opendaylight.yangtools.yang.model.util.UnionType;
+import org.opendaylight.yangtools.yang.model.api.type.UnionTypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.UnsignedIntegerTypeDefinition;
+import org.opendaylight.yangtools.yang.model.util.type.BaseTypes;
import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
modules = TestUtils.loadModules(getClass().getResource("/grouping-test").toURI());
Module testModule = TestUtils.findModule(modules, "uses-grouping");
- LinkedList<QName> path = new LinkedList<>();
+ Deque<QName> path = new ArrayDeque<>();
// * notification pcreq
Set<NotificationDefinition> notifications = testModule.getNotifications();
path.offer(expectedQName);
expectedPath = SchemaPath.create(path, true);
assertEquals(expectedPath, version.getPath());
- expectedQName = QName.create(GD_NS, GD_REV, "protocol-version");
+ expectedQName = QName.create(UG_NS, UG_REV, "version");
path.offer(expectedQName);
- expectedPath = SchemaPath.create(Lists.newArrayList(expectedQName), true);
+ expectedPath = SchemaPath.create(true, pcreq.getQName(), expectedQName);
assertEquals(expectedPath, version.getType().getPath());
- assertEquals(Uint8.getInstance(), version.getType().getBaseType());
+ assertEquals(BaseTypes.uint8Type(), version.getType().getBaseType().getBaseType());
assertTrue(version.isAddedByUses());
// * |-- leaf type
LeafSchemaNode type = (LeafSchemaNode) pcreq.getDataChildByName("type");
assertEquals(expectedPath, type.getPath());
expectedQName = QName.create(GD_NS, GD_REV, "int-ext");
path.offer(expectedQName);
- expectedPath = SchemaPath.create(Lists.newArrayList(expectedQName), true);
+ expectedPath = SchemaPath.create(true, expectedQName);
assertEquals(expectedPath, type.getType().getPath());
- UnionType union = (UnionType)type.getType().getBaseType();
- assertEquals(SchemaPath.create(true, BaseTypes.constructQName("union")), union.getPath());
+ UnionTypeDefinition union = (UnionTypeDefinition) type.getType().getBaseType();
+ assertEquals(SchemaPath.create(true, expectedQName, QName.create(expectedQName, "union")), union.getPath());
assertEquals(2, union.getTypes().size());
// * |-- list requests
ListSchemaNode requests = (ListSchemaNode) pcreq.getDataChildByName("requests");
path.offer(expectedQName);
expectedPath = SchemaPath.create(path, true);
assertEquals(expectedPath, processingRule.getPath());
- assertEquals(BooleanType.getInstance(), processingRule.getType());
+ assertEquals(BaseTypes.booleanType(), processingRule.getType());
assertTrue(processingRule.isAddedByUses());
// * |-- |-- |-- leaf ignore
LeafSchemaNode ignore = (LeafSchemaNode) rp.getDataChildByName("ignore");
path.offer(expectedQName);
expectedPath = SchemaPath.create(path, true);
assertEquals(expectedPath, ignore.getPath());
- assertEquals(BooleanType.getInstance(), ignore.getType());
+ assertEquals(BaseTypes.booleanType(), ignore.getType());
assertTrue(ignore.isAddedByUses());
// * |-- |-- |-- leaf priority
LeafSchemaNode priority = (LeafSchemaNode) rp.getDataChildByName("priority");
expectedPath = SchemaPath.create(path, true);
// TODO
//assertEquals(expectedPath, priority.getType().getPath());
- assertEquals(Uint8.getInstance(), priority.getType().getBaseType());
+ assertEquals(BaseTypes.uint8Type(), priority.getType().getBaseType());
assertTrue(priority.isAddedByUses());
// * |-- |-- |-- container box
ContainerSchemaNode box = (ContainerSchemaNode) rp.getDataChildByName("box");
path.offer(expectedQName);
expectedPath = SchemaPath.create(path, true);
assertEquals(expectedPath, delete.getPath());
- assertEquals(Uint32.getInstance(), delete.getType());
+ assertEquals(BaseTypes.uint32Type(), delete.getType());
assertTrue(delete.isAddedByUses());
// * |-- |-- |-- |-- |-- leaf setup
LeafSchemaNode setup = (LeafSchemaNode) order.getDataChildByName("setup");
path.offer(expectedQName);
expectedPath = SchemaPath.create(path, true);
assertEquals(expectedPath, setup.getPath());
- assertEquals(Uint32.getInstance(), setup.getType());
+ assertEquals(BaseTypes.uint32Type(), setup.getType());
assertTrue(setup.isAddedByUses());
// * |-- |-- path-key-expansion
ContainerSchemaNode pke = (ContainerSchemaNode) requests.getDataChildByName("path-key-expansion");
path.offer(expectedQName);
expectedPath= SchemaPath.create(path, true);
assertEquals(expectedPath, processingRule.getPath());
- assertEquals(BooleanType.getInstance(), processingRule.getType());
+ assertEquals(BaseTypes.booleanType(), processingRule.getType());
assertTrue(processingRule.isAddedByUses());
// * |-- |-- |-- |-- leaf ignore
ignore = (LeafSchemaNode) pathKey.getDataChildByName("ignore");
path.offer(expectedQName);
expectedPath= SchemaPath.create(path, true);
assertEquals(expectedPath, ignore.getPath());
- assertEquals(BooleanType.getInstance(), ignore.getType());
+ assertEquals(BaseTypes.booleanType(), ignore.getType());
assertTrue(ignore.isAddedByUses());
// * |-- |-- |-- |-- list path-keys
ListSchemaNode pathKeys = (ListSchemaNode) pathKey.getDataChildByName("path-keys");
path.offer(expectedQName);
expectedPath= SchemaPath.create(path, true);
assertEquals(expectedPath, version.getPath());
- assertTrue(version.getType() instanceof ExtendedType);
- assertEquals(Uint8.getInstance(), version.getType().getBaseType());
+ assertTrue(version.getType() instanceof UnsignedIntegerTypeDefinition);
+ assertEquals(BaseTypes.uint8Type(), version.getType().getBaseType().getBaseType());
assertTrue(version.isAddedByUses());
assertTrue(version.isAugmenting());
// * |-- |-- |-- |-- |-- leaf type
path.offer(expectedQName);
expectedPath= SchemaPath.create(path, true);
assertEquals(expectedPath, type.getPath());
- assertTrue(type.getType() instanceof ExtendedType);
+ assertTrue(type.getType() instanceof UnionTypeDefinition);
assertTrue(type.isAddedByUses());
assertTrue(type.isAugmenting());
// * |-- |-- container segment-computation
path.offer(expectedQName);
expectedPath= SchemaPath.create(path, true);
assertEquals(expectedPath, processingRule.getPath());
- assertEquals(BooleanType.getInstance(), processingRule.getType());
+ assertEquals(BaseTypes.booleanType(), processingRule.getType());
assertTrue(processingRule.isAddedByUses());
// * |-- |-- |-- |-- |-- leaf ignore
ignore = (LeafSchemaNode) endpoints.getDataChildByName("ignore");
path.offer(expectedQName);
expectedPath= SchemaPath.create(path, true);
assertEquals(expectedPath, ignore.getPath());
- assertEquals(BooleanType.getInstance(), ignore.getType());
+ assertEquals(BaseTypes.booleanType(), ignore.getType());
assertTrue(ignore.isAddedByUses());
// * |-- |-- |-- |-- |-- container box
box = (ContainerSchemaNode) endpoints.getDataChildByName("box");
path.offer(expectedQName);
expectedPath= SchemaPath.create(path, true);
assertEquals(expectedPath, processingRule.getPath());
- assertEquals(BooleanType.getInstance(), processingRule.getType());
+ assertEquals(BaseTypes.booleanType(), processingRule.getType());
assertTrue(processingRule.isAddedByUses());
// * |-- |-- |-- |-- |-- leaf ignore
ignore = (LeafSchemaNode) reportedRoute.getDataChildByName("ignore");
path.offer(expectedQName);
expectedPath= SchemaPath.create(path, true);
assertEquals(expectedPath, ignore.getPath());
- assertEquals(BooleanType.getInstance(), ignore.getType());
+ assertEquals(BaseTypes.booleanType(), ignore.getType());
assertTrue(ignore.isAddedByUses());
// * |-- |-- |-- |-- |-- list subobjects
ListSchemaNode subobjects = (ListSchemaNode) reportedRoute.getDataChildByName("subobjects");
path.offer(expectedQName);
expectedPath= SchemaPath.create(path, true);
assertEquals(expectedPath, processingRule.getPath());
- assertEquals(BooleanType.getInstance(), processingRule.getType());
+ assertEquals(BaseTypes.booleanType(), processingRule.getType());
assertTrue(processingRule.isAddedByUses());
// * |-- |-- |-- |-- |-- leaf ignore
ignore = (LeafSchemaNode) bandwidth.getDataChildByName("ignore");
path.offer(expectedQName);
expectedPath= SchemaPath.create(path, true);
assertEquals(expectedPath, ignore.getPath());
- assertEquals(BooleanType.getInstance(), ignore.getType());
+ assertEquals(BaseTypes.booleanType(), ignore.getType());
assertTrue(ignore.isAddedByUses());
// * |-- |-- |-- |-- |-- container bandwidth
ContainerSchemaNode bandwidthInner = (ContainerSchemaNode) bandwidth.getDataChildByName("bandwidth");
path.offer(expectedQName);
expectedPath= SchemaPath.create(path, true);
assertEquals(expectedPath, linkDiverse.getPath());
- assertEquals(BooleanType.getInstance(), linkDiverse.getType());
+ assertEquals(BaseTypes.booleanType(), linkDiverse.getType().getBaseType());
assertTrue(linkDiverse.isAddedByUses());
// * |-- |-- leaf processing-rule
processingRule = (LeafSchemaNode) svec.getDataChildByName("processing-rule");
path.offer(expectedQName);
expectedPath= SchemaPath.create(path, true);
assertEquals(expectedPath, processingRule.getPath());
- assertEquals(BooleanType.getInstance(), processingRule.getType());
+ assertEquals(BaseTypes.booleanType(), processingRule.getType());
assertTrue(processingRule.isAddedByUses());
// * |-- |-- leaf ignore
ignore = (LeafSchemaNode) svec.getDataChildByName("ignore");
path.offer(expectedQName);
expectedPath= SchemaPath.create(path, true);
assertEquals(expectedPath, ignore.getPath());
- assertEquals(BooleanType.getInstance(), ignore.getType());
+ assertEquals(BaseTypes.booleanType(), ignore.getType());
assertTrue(ignore.isAddedByUses());
// * |-- |-- list metric
ListSchemaNode metric = (ListSchemaNode) svec.getDataChildByName("metric");
path.offer(expectedQName);
expectedPath= SchemaPath.create(path, true);
assertEquals(expectedPath, metricType.getPath());
- assertEquals(Uint8.getInstance(), metricType.getType());
+ assertEquals(BaseTypes.uint8Type(), metricType.getType());
assertTrue(metricType.isAddedByUses());
// * |-- |-- |-- box
box = (ContainerSchemaNode) metric.getDataChildByName("box");
path.offer(expectedQName);
expectedPath= SchemaPath.create(path, true);
assertEquals(expectedPath, processingRule.getPath());
- assertEquals(BooleanType.getInstance(), processingRule.getType());
+ assertEquals(BaseTypes.booleanType(), processingRule.getType());
assertTrue(processingRule.isAddedByUses());
// * |-- |-- |-- leaf ignore
ignore = (LeafSchemaNode) metric.getDataChildByName("ignore");
path.offer(expectedQName);
expectedPath= SchemaPath.create(path, true);
assertEquals(expectedPath, ignore.getPath());
- assertEquals(BooleanType.getInstance(), ignore.getType());
+ assertEquals(BaseTypes.booleanType(), ignore.getType());
assertTrue(ignore.isAddedByUses());
}
}
assertNotNull(intExt);
- List<QName> path = Lists.newArrayList(QName.create(GD_NS, GD_REV, "int-ext"));
- SchemaPath expectedPath = SchemaPath.create(path, true);
+ SchemaPath expectedPath = SchemaPath.create(true, QName.create(GD_NS, GD_REV, "int-ext"));
assertEquals(expectedPath, intExt.getPath());
- UnionType union = (UnionType)intExt.getBaseType();
+ UnionTypeDefinition union = (UnionTypeDefinition)intExt.getBaseType();
TypeDefinition<?> uint8 = null;
TypeDefinition<?> pv = null;
assertNotNull(uint8);
assertNotNull(pv);
- QName q1 = BaseTypes.constructQName("union");
- expectedPath = SchemaPath.create(Lists.newArrayList(q1), true);
+ expectedPath = SchemaPath.create(true, QName.create(GD_NS, GD_REV, "int-ext"), QName.create(GD_NS, GD_REV, "union"));
assertEquals(expectedPath, union.getPath());
}