- public void testAugmentResolving() {
- // testfile1
- Module module1 = TestUtils.findModule(modules, "types1");
-
- Set<AugmentationSchema> module1Augmentations = module1
- .getAugmentations();
- AugmentationSchema augment1 = module1Augmentations.iterator().next();
- LeafSchemaNode augmentedLeafDefinition = (LeafSchemaNode) augment1
- .getDataChildByName("ds0ChannelNumber");
- assertTrue(augmentedLeafDefinition.isAugmenting());
-
- // testfile2
- Module module2 = TestUtils.findModule(modules, "types2");
-
- ContainerSchemaNode interfaces = (ContainerSchemaNode) module2
- .getDataChildByName("interfaces");
- ListSchemaNode ifEntry = (ListSchemaNode) interfaces
- .getDataChildByName("ifEntry");
- ContainerSchemaNode augmentedContainer = (ContainerSchemaNode) ifEntry
- .getDataChildByName("augment-holder");
-
- // augmentation defined in testfile1 and augmentation returned from
- // augmented container have to be same
- Set<AugmentationSchema> augmentedContainerAugments = augmentedContainer
- .getAvailableAugmentations();
- AugmentationSchema augmentDefinition = augmentedContainerAugments
- .iterator().next();
- assertEquals(augment1, augmentDefinition);
-
- LeafSchemaNode augmentedLeaf = (LeafSchemaNode) augmentedContainer
- .getDataChildByName("ds0ChannelNumber");
- assertTrue(augmentedLeaf.isAugmenting());
- assertEquals(augmentedLeafDefinition, augmentedLeaf);
-
- Set<AugmentationSchema> ifEntryAugments = ifEntry
- .getAvailableAugmentations();
- assertEquals(2, ifEntryAugments.size());
-
- // testfile3
- Module module3 = TestUtils.findModule(modules, "types3");
-
- Set<AugmentationSchema> module3Augmentations = module3
- .getAugmentations();
- assertEquals(2, module3Augmentations.size());
- AugmentationSchema augment3 = null;
- for (AugmentationSchema as : module3Augmentations) {
- if ("if:ifType='ds0'".equals(as.getWhenCondition().toString())) {
- augment3 = as;
- }
- }
- ContainerSchemaNode augmentedContainerDefinition = (ContainerSchemaNode) augment3
- .getDataChildByName("augment-holder");
- assertTrue(augmentedContainerDefinition.isAugmenting());
-
- // check
- assertEquals(augmentedContainer, augmentedContainerDefinition);
- assertEquals(augmentedLeaf, augmentedLeafDefinition);
- }
-
- @Test
- public void testAugmentTarget() {
- Module test = TestUtils.findModule(modules, "types2");
-
- ContainerSchemaNode interfaces = (ContainerSchemaNode) test
- .getDataChildByName("interfaces");
- ListSchemaNode ifEntry = (ListSchemaNode) interfaces
- .getDataChildByName("ifEntry");
- Set<AugmentationSchema> augmentations = ifEntry
- .getAvailableAugmentations();
- assertEquals(2, augmentations.size());
-
- AugmentationSchema augment = null;
- for (AugmentationSchema as : augmentations) {
- if ("if:ifType='ds0'".equals(as.getWhenCondition().toString())) {
- augment = as;
- }
- }
- ContainerSchemaNode augmentHolder = (ContainerSchemaNode) augment
- .getDataChildByName("augment-holder");
- assertNotNull(augmentHolder);
- assertTrue(augmentHolder.isAugmenting());
- QName augmentHolderQName = augmentHolder.getQName();
- assertEquals("augment-holder", augmentHolderQName.getLocalName());
- assertEquals("t3", augmentHolderQName.getPrefix());
- assertEquals("Description for augment holder",
- augmentHolder.getDescription());
- }
-
- @Test
- public void testTypedefRangesResolving() {
- Module testModule = TestUtils.findModule(modules, "types1");
-
- LeafSchemaNode testleaf = (LeafSchemaNode) testModule
- .getDataChildByName("testleaf");
- ExtendedType leafType = (ExtendedType) testleaf.getType();
- assertEquals("my-type1", leafType.getQName().getLocalName());
- assertEquals("t2", leafType.getQName().getPrefix());
- ExtendedType baseType = (ExtendedType) leafType.getBaseType();
- assertEquals("my-base-int32-type", baseType.getQName().getLocalName());
- assertEquals("t2", baseType.getQName().getPrefix());
-
+ public void testTypedefRangesResolving() throws ParseException {
+ Module testModule = TestUtils.findModule(modules, "nodes");
+ LeafSchemaNode int32Leaf = (LeafSchemaNode) testModule.getDataChildByName("int32-leaf");
+
+ ExtendedType leafType = (ExtendedType) int32Leaf.getType();
+ QName leafTypeQName = leafType.getQName();
+ assertEquals("int32-ext2", leafTypeQName.getLocalName());
+ assertEquals("n", leafTypeQName.getPrefix());
+ assertEquals(nodesNS, leafTypeQName.getNamespace());
+ assertEquals(nodesRev, leafTypeQName.getRevision());
+ assertNull(leafType.getUnits());
+ assertNull(leafType.getDefaultValue());
+ assertTrue(leafType.getLengths().isEmpty());
+ assertTrue(leafType.getPatterns().isEmpty());