YANG Grouping Linker Support
Change-Id: I2fec0c0bb4d1584e82ffba3228106897ccad2bf5
diff --git a/src/test/java/org/onosproject/yangutils/linker/IntraFileTypeLinkingTest.java b/src/test/java/org/onosproject/yangutils/linker/IntraFileTypeLinkingTest.java
index eaf4076..52fb4ff 100644
--- a/src/test/java/org/onosproject/yangutils/linker/IntraFileTypeLinkingTest.java
+++ b/src/test/java/org/onosproject/yangutils/linker/IntraFileTypeLinkingTest.java
@@ -18,6 +18,7 @@
import java.io.IOException;
import java.util.ListIterator;
+
import org.junit.Test;
import org.onosproject.yangutils.datamodel.ResolvableStatus;
import org.onosproject.yangutils.datamodel.YangContainer;
@@ -46,7 +47,8 @@
* Checks self resolution when typedef and leaf using type are siblings.
*/
@Test
- public void processSelfResolutionWhenTypeAndTypedefAtRootLevel() throws IOException, ParserException {
+ public void processSelfResolutionWhenTypeAndTypedefAtRootLevel()
+ throws IOException, ParserException {
YangNode node = manager.getDataModel("src/test/resources/SelfResolutionWhenTypeAndTypedefAtRootLevel.yang");
@@ -79,7 +81,8 @@
* level where typedef is at the root.
*/
@Test
- public void processSelfFileLinkingTypedefAtRootTypeTwoLevelInHierarchy() throws IOException, ParserException {
+ public void processSelfFileLinkingTypedefAtRootTypeTwoLevelInHierarchy()
+ throws IOException, ParserException {
YangNode node =
manager.getDataModel("src/test/resources/SelfFileLinkingTypedefAtRootTypeTwoLevelInHierarchy.yang");
@@ -118,7 +121,8 @@
* of type.
*/
@Test
- public void processSelfFileLinkingTypedefAtRootIsAfterContainerHavingType() throws IOException, ParserException {
+ public void processSelfFileLinkingTypedefAtRootIsAfterContainerHavingType()
+ throws IOException, ParserException {
YangNode node =
manager.getDataModel("src/test/resources/SelfFileLinkingTypedefAtRootIsAfterContainerHavingType.yang");
@@ -157,7 +161,8 @@
* holder of type.
*/
@Test
- public void processSelfFileLinkingTypedefAtMiddleLevelAfterParentHolder() throws IOException, ParserException {
+ public void processSelfFileLinkingTypedefAtMiddleLevelAfterParentHolder()
+ throws IOException, ParserException {
YangNode node =
manager.getDataModel("src/test/resources/SelfFileLinkingTypedefAtMiddleLevelAfterParentHolder.yang");
@@ -194,7 +199,8 @@
* Checks self resolution when typedef hierarchical references are present.
*/
@Test
- public void processSelfFileLinkingWithTypdefHierarchicalReference() throws IOException, ParserException {
+ public void processSelfFileLinkingWithTypdefHierarchicalReference()
+ throws IOException, ParserException {
YangNode node =
manager.getDataModel("src/test/resources/SelfFileLinkingWithTypdefHierarchicalReference.yang");
@@ -227,16 +233,16 @@
YangTypeDef typeDef1 = (YangTypeDef) yangList.getChild();
- assertThat(((YangDerivedInfo<?>) typeDef1.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
+ assertThat(((YangDerivedInfo<?>) typeDef1.getTypeDefBaseType().getDataTypeExtendedInfo()).getReferredTypeDef(),
is((YangTypeDef) yangContainer.getChild().getNextSibling()));
- assertThat((typeDef1.getDataType().getResolvableStatus()),
+ assertThat((typeDef1.getTypeDefBaseType().getResolvableStatus()),
is(ResolvableStatus.RESOLVED));
YangTypeDef typeDef2 = (YangTypeDef) yangContainer.getChild().getNextSibling();
- assertThat(((YangDerivedInfo<?>) typeDef2.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
+ assertThat(((YangDerivedInfo<?>) typeDef2.getTypeDefBaseType().getDataTypeExtendedInfo()).getReferredTypeDef(),
is((YangTypeDef) node.getChild()));
- assertThat((typeDef2.getDataType().getResolvableStatus()),
+ assertThat((typeDef2.getTypeDefBaseType().getResolvableStatus()),
is(ResolvableStatus.RESOLVED));
}
@@ -245,7 +251,8 @@
* with last type is unresolved.
*/
@Test
- public void processSelfFileLinkingWithTypdefHierarchicalRefUnresolved() throws IOException, ParserException {
+ public void processSelfFileLinkingWithTypdefHierarchicalRefUnresolved()
+ throws IOException, ParserException {
YangNode node =
manager.getDataModel("src/test/resources/SelfFileLinkingWithTypdefHierarchicalRefUnresolved.yang");
@@ -274,28 +281,29 @@
assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
is((YangTypeDef) yangList.getChild()));
assertThat((leafInfo.getDataType().getResolvableStatus()),
- is(ResolvableStatus.PARTIALLY_RESOLVED));
+ is(ResolvableStatus.INTRA_FILE_RESOLVED));
YangTypeDef typeDef1 = (YangTypeDef) yangList.getChild();
- assertThat(((YangDerivedInfo<?>) typeDef1.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
+ assertThat(((YangDerivedInfo<?>) typeDef1.getTypeDefBaseType().getDataTypeExtendedInfo()).getReferredTypeDef(),
is((YangTypeDef) yangContainer.getChild().getNextSibling()));
- assertThat((typeDef1.getDataType().getResolvableStatus()),
- is(ResolvableStatus.PARTIALLY_RESOLVED));
+ assertThat((typeDef1.getTypeDefBaseType().getResolvableStatus()),
+ is(ResolvableStatus.INTRA_FILE_RESOLVED));
YangTypeDef typeDef2 = (YangTypeDef) yangContainer.getChild().getNextSibling();
- assertThat(((YangDerivedInfo<?>) typeDef2.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
+ assertThat(((YangDerivedInfo<?>) typeDef2.getTypeDefBaseType().getDataTypeExtendedInfo()).getReferredTypeDef(),
is((YangTypeDef) node.getChild()));
- assertThat((typeDef2.getDataType().getResolvableStatus()),
- is(ResolvableStatus.PARTIALLY_RESOLVED));
+ assertThat((typeDef2.getTypeDefBaseType().getResolvableStatus()),
+ is(ResolvableStatus.INTRA_FILE_RESOLVED));
}
/**
* Checks self resolution when type uses prefix of self module.
*/
@Test
- public void processSelfFileLinkingWithTypeWithSelfModulePrefix() throws IOException, ParserException {
+ public void processSelfFileLinkingWithTypeWithSelfModulePrefix()
+ throws IOException, ParserException {
YangNode node =
manager.getDataModel("src/test/resources/SelfFileLinkingWithTypeWithSelfModulePrefix.yang");
@@ -328,16 +336,16 @@
YangTypeDef typeDef1 = (YangTypeDef) yangList.getChild();
- assertThat(((YangDerivedInfo<?>) typeDef1.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
+ assertThat(((YangDerivedInfo<?>) typeDef1.getTypeDefBaseType().getDataTypeExtendedInfo()).getReferredTypeDef(),
is((YangTypeDef) yangContainer.getChild().getNextSibling()));
- assertThat((typeDef1.getDataType().getResolvableStatus()),
+ assertThat((typeDef1.getTypeDefBaseType().getResolvableStatus()),
is(ResolvableStatus.RESOLVED));
YangTypeDef typeDef2 = (YangTypeDef) yangContainer.getChild().getNextSibling();
- assertThat(((YangDerivedInfo<?>) typeDef2.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
+ assertThat(((YangDerivedInfo<?>) typeDef2.getTypeDefBaseType().getDataTypeExtendedInfo()).getReferredTypeDef(),
is((YangTypeDef) node.getChild()));
- assertThat((typeDef2.getDataType().getResolvableStatus()),
+ assertThat((typeDef2.getTypeDefBaseType().getResolvableStatus()),
is(ResolvableStatus.RESOLVED));
}
@@ -346,7 +354,8 @@
* some uses external prefix.
*/
@Test
- public void processSelfFileLinkingWithTypeWithSelfAndExternalPrefixMix() throws IOException, ParserException {
+ public void processSelfFileLinkingWithTypeWithSelfAndExternalPrefixMix()
+ throws IOException, ParserException {
YangNode node =
manager.getDataModel("src/test/resources/SelfFileLinkingWithTypeWithSelfAndExternalPrefixMix.yang");
@@ -375,15 +384,15 @@
assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
is((YangTypeDef) yangList.getChild()));
assertThat((leafInfo.getDataType().getResolvableStatus()),
- is(ResolvableStatus.PARTIALLY_RESOLVED));
+ is(ResolvableStatus.INTRA_FILE_RESOLVED));
YangTypeDef typeDef1 = (YangTypeDef) yangList.getChild();
YangTypeDef typeDef2 = (YangTypeDef) yangContainer.getChild().getNextSibling();
- assertThat(((YangDerivedInfo<?>) typeDef2.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
+ assertThat(((YangDerivedInfo<?>) typeDef2.getTypeDefBaseType().getDataTypeExtendedInfo()).getReferredTypeDef(),
is((YangTypeDef) node.getChild()));
- assertThat((typeDef2.getDataType().getResolvableStatus()),
+ assertThat((typeDef2.getTypeDefBaseType().getResolvableStatus()),
is(ResolvableStatus.RESOLVED));
}
@@ -392,7 +401,8 @@
* file.
*/
@Test(expected = ParserException.class)
- public void processSelfResolutionWhenTypeReferredTypedefNotDefined() throws IOException, ParserException {
+ public void processSelfResolutionWhenTypeReferredTypedefNotDefined()
+ throws IOException, ParserException {
YangNode node =
manager.getDataModel("src/test/resources/SelfResolutionWhenTypeReferredTypedefNotDefined.yang");
@@ -403,7 +413,8 @@
* level where typedef is is not an ancestor of type.
*/
@Test(expected = ParserException.class)
- public void processSelfFileLinkingTypedefNotFound() throws IOException, ParserException {
+ public void processSelfFileLinkingTypedefNotFound()
+ throws IOException, ParserException {
YangNode node = manager.getDataModel("src/test/resources/SelfFileLinkingTypedefNotFound.yang");
}
@@ -412,7 +423,8 @@
* Checks hierarchical self resolution with self resolution failure scenario.
*/
@Test(expected = ParserException.class)
- public void processSelfFileLinkingWithHierarchicalTypeFailureScenario() throws IOException, ParserException {
+ public void processSelfFileLinkingWithHierarchicalTypeFailureScenario()
+ throws IOException, ParserException {
YangNode node =
manager.getDataModel("src/test/resources/SelfFileLinkingWithHierarchicalTypeFailureScenario.yang");
diff --git a/src/test/java/org/onosproject/yangutils/parser/impl/listeners/InputListenerTest.java b/src/test/java/org/onosproject/yangutils/parser/impl/listeners/InputListenerTest.java
index 7ec10cf..95c402a 100644
--- a/src/test/java/org/onosproject/yangutils/parser/impl/listeners/InputListenerTest.java
+++ b/src/test/java/org/onosproject/yangutils/parser/impl/listeners/InputListenerTest.java
@@ -106,6 +106,6 @@
YangTypeDef typeDef = (YangTypeDef) yangInput.getChild();
assertThat(typeDef.getName(), is("my-type"));
assertThat(typeDef.getStatus(), is(YangStatusType.DEPRECATED));
- assertThat(typeDef.getDataType().getDataType(), is(YangDataTypes.INT32));
+ assertThat(typeDef.getTypeDefBaseType().getDataType(), is(YangDataTypes.INT32));
}
}
diff --git a/src/test/java/org/onosproject/yangutils/parser/impl/listeners/LengthRestrictionListenerTest.java b/src/test/java/org/onosproject/yangutils/parser/impl/listeners/LengthRestrictionListenerTest.java
index e5e647a..a8f494b 100644
--- a/src/test/java/org/onosproject/yangutils/parser/impl/listeners/LengthRestrictionListenerTest.java
+++ b/src/test/java/org/onosproject/yangutils/parser/impl/listeners/LengthRestrictionListenerTest.java
@@ -128,7 +128,7 @@
assertThat(yangNode.getName(), is("Test"));
YangTypeDef typedef = (YangTypeDef) yangNode.getChild();
- YangStringRestriction stringRestriction = (YangStringRestriction) typedef.getDataType()
+ YangStringRestriction stringRestriction = (YangStringRestriction) typedef.getTypeDefBaseType()
.getDataTypeExtendedInfo();
YangRangeRestriction lengthRestriction = stringRestriction.getLengthRestriction();
@@ -234,4 +234,4 @@
" 18446744073709551615.");
YangNode node = manager.getDataModel("src/test/resources/LengthWithInvalidInterval.yang");
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/onosproject/yangutils/parser/impl/listeners/OutputListenerTest.java b/src/test/java/org/onosproject/yangutils/parser/impl/listeners/OutputListenerTest.java
index f6a5437..ded5c49 100644
--- a/src/test/java/org/onosproject/yangutils/parser/impl/listeners/OutputListenerTest.java
+++ b/src/test/java/org/onosproject/yangutils/parser/impl/listeners/OutputListenerTest.java
@@ -108,6 +108,6 @@
assertThat(typeDef.getStatus(), is(YangStatusType.DEPRECATED));
assertThat(typeDef.getName(), is("my-type"));
assertThat(typeDef.getStatus(), is(YangStatusType.DEPRECATED));
- assertThat(typeDef.getDataType().getDataType(), is(YangDataTypes.INT32));
+ assertThat(typeDef.getTypeDefBaseType().getDataType(), is(YangDataTypes.INT32));
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/onosproject/yangutils/parser/impl/listeners/PatternRestrictionListenerTest.java b/src/test/java/org/onosproject/yangutils/parser/impl/listeners/PatternRestrictionListenerTest.java
index ffd8470..fb0ec72 100644
--- a/src/test/java/org/onosproject/yangutils/parser/impl/listeners/PatternRestrictionListenerTest.java
+++ b/src/test/java/org/onosproject/yangutils/parser/impl/listeners/PatternRestrictionListenerTest.java
@@ -108,7 +108,7 @@
assertThat(yangNode.getName(), is("Test"));
YangTypeDef typedef = (YangTypeDef) yangNode.getChild();
- YangStringRestriction stringRestriction = (YangStringRestriction) typedef.getDataType()
+ YangStringRestriction stringRestriction = (YangStringRestriction) typedef.getTypeDefBaseType()
.getDataTypeExtendedInfo();
YangPatternRestriction yangPatternRestriction = stringRestriction.getPatternRestriction();
@@ -166,4 +166,4 @@
.getPatternList().listIterator();
assertThat(patternListIterator.next(), is("-[0-9]+|[0-9]+"));
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/onosproject/yangutils/parser/impl/listeners/RpcListenerTest.java b/src/test/java/org/onosproject/yangutils/parser/impl/listeners/RpcListenerTest.java
index adb88dc..3af045d 100644
--- a/src/test/java/org/onosproject/yangutils/parser/impl/listeners/RpcListenerTest.java
+++ b/src/test/java/org/onosproject/yangutils/parser/impl/listeners/RpcListenerTest.java
@@ -61,6 +61,6 @@
YangTypeDef typeDef = (YangTypeDef) yangRpc.getChild();
assertThat(typeDef.getName(), is("my-type"));
assertThat(typeDef.getStatus(), is(YangStatusType.DEPRECATED));
- assertThat(typeDef.getDataType().getDataType(), is(YangDataTypes.INT32));
+ assertThat(typeDef.getTypeDefBaseType().getDataType(), is(YangDataTypes.INT32));
}
}
diff --git a/src/test/resources/DerivedTypeStatement.yang b/src/test/resources/DerivedTypeStatement.yang
index 952b7d4..afbfd1d 100644
--- a/src/test/resources/DerivedTypeStatement.yang
+++ b/src/test/resources/DerivedTypeStatement.yang
@@ -2,6 +2,9 @@
yang-version 1;
namespace http://huawei.com;
prefix Ant;
+ import ietf-yang-types {
+ prefix "P";
+ }
leaf invalid-interval {
type P:hello;
}
diff --git a/src/test/resources/DuplicateGroupingInList.yang b/src/test/resources/DuplicateGroupingInList.yang
index 2457cbe..a9d1b3b 100644
--- a/src/test/resources/DuplicateGroupingInList.yang
+++ b/src/test/resources/DuplicateGroupingInList.yang
@@ -2,6 +2,9 @@
yang-version 1;
namespace http://huawei.com;
prefix Ant;
+ import ietf-yang-types {
+ prefix "P";
+ }
list valid {
key address;
grouping endpoint {
diff --git a/src/test/resources/DuplicateGroupingInModule.yang b/src/test/resources/DuplicateGroupingInModule.yang
index d18b166..ec01781 100644
--- a/src/test/resources/DuplicateGroupingInModule.yang
+++ b/src/test/resources/DuplicateGroupingInModule.yang
@@ -2,20 +2,23 @@
yang-version 1;
namespace http://huawei.com;
prefix Ant;
+ import ietf-yang-types {
+ prefix "P";
+ }
grouping endpoint {
leaf address {
- type ip-address;
+ type P:ip-address;
}
leaf port {
- type port-number;
+ type P:port-number;
}
}
grouping endpoint {
leaf address {
- type ip-address;
+ type P:pip-address;
}
leaf port {
- type port-number;
+ type P:port-number;
}
}
}
diff --git a/src/test/resources/GroupingAttributes.yang b/src/test/resources/GroupingAttributes.yang
index 977adc5..f04641f 100644
--- a/src/test/resources/GroupingAttributes.yang
+++ b/src/test/resources/GroupingAttributes.yang
@@ -2,6 +2,9 @@
yang-version 1;
namespace http://huawei.com;
prefix Ant;
+ import ietf-yang-types {
+ prefix "P";
+ }
list valid {
key address;
leaf address {
diff --git a/src/test/resources/GroupingInContainer.yang b/src/test/resources/GroupingInContainer.yang
index 7c51913..dfa8259 100644
--- a/src/test/resources/GroupingInContainer.yang
+++ b/src/test/resources/GroupingInContainer.yang
@@ -2,6 +2,9 @@
yang-version 1;
namespace http://huawei.com;
prefix Ant;
+ import ietf-yang-types {
+ prefix "P";
+ }
container valid {
grouping endpoint {
leaf address {
diff --git a/src/test/resources/GroupingInList.yang b/src/test/resources/GroupingInList.yang
index a8fad09..c5966fc 100644
--- a/src/test/resources/GroupingInList.yang
+++ b/src/test/resources/GroupingInList.yang
@@ -2,6 +2,9 @@
yang-version 1;
namespace http://huawei.com;
prefix Ant;
+ import ietf-yang-types {
+ prefix "P";
+ }
list valid {
key address;
leaf address {
diff --git a/src/test/resources/GroupingInModule.yang b/src/test/resources/GroupingInModule.yang
index 7d513a4..77fef1f 100644
--- a/src/test/resources/GroupingInModule.yang
+++ b/src/test/resources/GroupingInModule.yang
@@ -2,6 +2,9 @@
yang-version 1;
namespace http://huawei.com;
prefix Ant;
+ import ietf-yang-types {
+ prefix "P";
+ }
grouping endpoint {
leaf address {
type P:ip-address;
diff --git a/src/test/resources/SelfFileLinkingWithTypdefHierarchicalRefUnresolved.yang b/src/test/resources/SelfFileLinkingWithTypdefHierarchicalRefUnresolved.yang
index 35c28b6..a3e4379 100644
--- a/src/test/resources/SelfFileLinkingWithTypdefHierarchicalRefUnresolved.yang
+++ b/src/test/resources/SelfFileLinkingWithTypdefHierarchicalRefUnresolved.yang
@@ -2,6 +2,9 @@
yang-version 1;
namespace http://huawei.com;
prefix Ant;
+ import ietf-yang-types {
+ prefix "P";
+ }
typedef Percentage {
type P:Per;
}
diff --git a/src/test/resources/SelfFileLinkingWithTypeWithSelfAndExternalPrefixMix.yang b/src/test/resources/SelfFileLinkingWithTypeWithSelfAndExternalPrefixMix.yang
index 038c7de..d5f346e 100644
--- a/src/test/resources/SelfFileLinkingWithTypeWithSelfAndExternalPrefixMix.yang
+++ b/src/test/resources/SelfFileLinkingWithTypeWithSelfAndExternalPrefixMix.yang
@@ -2,6 +2,9 @@
yang-version 1;
namespace http://huawei.com;
prefix Ant;
+ import ietf-yang-types {
+ prefix "P";
+ }
typedef Percentage {
type int32;
}
diff --git a/src/test/resources/UsesInList.yang b/src/test/resources/UsesInList.yang
index c4fd47d..b79e7b1 100644
--- a/src/test/resources/UsesInList.yang
+++ b/src/test/resources/UsesInList.yang
@@ -2,6 +2,9 @@
yang-version 1;
namespace http://huawei.com;
prefix Ant;
+ import ietf-yang-types {
+ prefix "P";
+ }
list valid {
key address;
leaf address {
diff --git a/src/test/resources/ValidAugmentStatement.yang b/src/test/resources/ValidAugmentStatement.yang
index 59ebe67..6175c35 100644
--- a/src/test/resources/ValidAugmentStatement.yang
+++ b/src/test/resources/ValidAugmentStatement.yang
@@ -6,6 +6,9 @@
import interface-module {
prefix "if";
}
+ import ietf-yang-types {
+ prefix "P";
+ }
augment "/if:interfaces/if:ifEntry" {
when "if:ifType='ds0'";
leaf ds0ChannelNumber {
diff --git a/src/test/resources/ValidNotificationStatement.yang b/src/test/resources/ValidNotificationStatement.yang
index d588bb9..072df23 100644
--- a/src/test/resources/ValidNotificationStatement.yang
+++ b/src/test/resources/ValidNotificationStatement.yang
@@ -2,6 +2,9 @@
namespace "http://example.net/rock";
prefix "rock";
+ import ietf-yang-types {
+ prefix "P";
+ }
notification link-failure {
description "A link failure has been detected";
status deprecated;