[ONOS-4838] Decimal64 Range Restrictions Modification
Change-Id: I4d79c0da5ef400a188bfc5a85830e1187602e698
diff --git a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/BitListenerTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/BitListenerTest.java
index ef25c97..a4410a7 100644
--- a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/BitListenerTest.java
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/BitListenerTest.java
@@ -21,6 +21,7 @@
import org.junit.Test;
import org.onosproject.yangutils.datamodel.YangBit;
import org.onosproject.yangutils.datamodel.YangBits;
+import org.onosproject.yangutils.datamodel.YangDerivedInfo;
import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes;
import org.onosproject.yangutils.datamodel.YangLeaf;
import org.onosproject.yangutils.datamodel.YangModule;
@@ -168,6 +169,117 @@
}
/**
+ * Checks bit statement with typedef with referred leaf.
+ */
+ @Test
+ public void processBitTypedefReferredLeafStatement() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/BitTypedefReferredLeafStatement.yang");
+
+ // Check whether the data model tree returned is of type module.
+ assertThat((node instanceof YangModule), is(true));
+
+ // Check whether the node type is set properly to module.
+ assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) node;
+ assertThat(yangNode.getName(), is("Test"));
+
+ YangTypeDef typedef = (YangTypeDef) yangNode.getChild();
+ assertThat(typedef.getName(), is("topBits"));
+
+ YangType type = typedef.getTypeList().iterator().next();
+ assertThat(type.getDataType(), is(YangDataTypes.BITS));
+ assertThat(type.getDataTypeName(), is("bits"));
+
+ // Check bit name map
+ Map<String, YangBit> bitNameMap = ((YangBits) type.getDataTypeExtendedInfo()).getBitNameMap();
+ assertThat(bitNameMap.size(), is(3));
+ for (Map.Entry<String, YangBit> element : bitNameMap.entrySet()) {
+ String bitName = element.getKey();
+ YangBit yangBit = element.getValue();
+ if (bitName.equals("disable-nagle")) {
+ assertThat(yangBit.getPosition(), is(0));
+ } else if (bitName.equals("auto-sense-speed")) {
+ assertThat(yangBit.getPosition(), is(1));
+ } else if (bitName.equals("Mb-only")) {
+ assertThat(yangBit.getPosition(), is(2));
+ } else {
+ throw new IOException("Invalid bit name: " + bitName);
+ }
+ }
+
+ // Check bit position map
+ Map<Integer, YangBit> bitPositionMap = ((YangBits) type.getDataTypeExtendedInfo()).getBitPositionMap();
+ assertThat(bitPositionMap.size(), is(3));
+ for (Map.Entry<Integer, YangBit> element : bitPositionMap.entrySet()) {
+ int position = element.getKey();
+ YangBit yangBit = element.getValue();
+ if (position == 0) {
+ assertThat(yangBit.getBitName(), is("disable-nagle"));
+ } else if (position == 1) {
+ assertThat(yangBit.getBitName(), is("auto-sense-speed"));
+ } else if (position == 2) {
+ assertThat(yangBit.getBitName(), is("Mb-only"));
+ } else {
+ throw new IOException("Invalid bit position: " + position);
+ }
+ }
+
+ // Check leaf reffered typedef
+ ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getName(), is("myBits"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("topBits"));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.DERIVED));
+ YangType<YangDerivedInfo> typeDerived = (YangType<YangDerivedInfo>) leafInfo.getDataType();
+ YangDerivedInfo derivedInfo = (YangDerivedInfo) typeDerived.getDataTypeExtendedInfo();
+ YangTypeDef prevTypedef = (YangTypeDef) derivedInfo.getReferredTypeDef();
+ assertThat(prevTypedef.getName(), is("topBits"));
+ YangType topType = prevTypedef.getTypeList().iterator().next();
+ assertThat(topType.getDataType(), is(YangDataTypes.BITS));
+ assertThat(topType.getDataTypeName(), is("bits"));
+ YangType<YangBits> typeBits = (YangType<YangBits>) topType;
+ YangBits bits = typeBits.getDataTypeExtendedInfo();
+
+ // Check bit name map
+ bitNameMap = bits.getBitNameMap();
+ assertThat(bitNameMap.size(), is(3));
+ for (Map.Entry<String, YangBit> element : bitNameMap.entrySet()) {
+ String bitName = element.getKey();
+ YangBit yangBit = element.getValue();
+ if (bitName.equals("disable-nagle")) {
+ assertThat(yangBit.getPosition(), is(0));
+ } else if (bitName.equals("auto-sense-speed")) {
+ assertThat(yangBit.getPosition(), is(1));
+ } else if (bitName.equals("Mb-only")) {
+ assertThat(yangBit.getPosition(), is(2));
+ } else {
+ throw new IOException("Invalid bit name: " + bitName);
+ }
+ }
+
+ // Check bit position map
+ bitPositionMap = bits.getBitPositionMap();
+ assertThat(bitPositionMap.size(), is(3));
+ for (Map.Entry<Integer, YangBit> element : bitPositionMap.entrySet()) {
+ int position = element.getKey();
+ YangBit yangBit = element.getValue();
+ if (position == 0) {
+ assertThat(yangBit.getBitName(), is("disable-nagle"));
+ } else if (position == 1) {
+ assertThat(yangBit.getBitName(), is("auto-sense-speed"));
+ } else if (position == 2) {
+ assertThat(yangBit.getBitName(), is("Mb-only"));
+ } else {
+ throw new IOException("Invalid bit position: " + position);
+ }
+ }
+ }
+
+ /**
* Checks bit statement with union.
*/
@Test
diff --git a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/Decimal64ListenerTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/Decimal64ListenerTest.java
index ec5b3fc..303a3e6 100644
--- a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/Decimal64ListenerTest.java
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/Decimal64ListenerTest.java
@@ -33,6 +33,7 @@
import org.onosproject.yangutils.datamodel.YangType;
import org.onosproject.yangutils.datamodel.YangTypeDef;
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
+import org.onosproject.yangutils.linker.exceptions.LinkerException;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes;
@@ -56,7 +57,7 @@
@Test
public void processDecimal64TypeStatement() throws IOException, ParserException {
- YangNode node = manager.getDataModel("src/test/resources/Decimal64TypeStatement.yang");
+ YangNode node = manager.getDataModel("src/test/resources/decimal64/Decimal64TypeStatement.yang");
// Check whether the data model tree returned is of type module.
assertThat((node instanceof YangModule), is(true));
@@ -84,7 +85,7 @@
@Test
public void processDecimal64TypeWithRangeStatement() throws IOException, ParserException {
- YangNode node = manager.getDataModel("src/test/resources/Decimal64TypeWithRangeStatement.yang");
+ YangNode node = manager.getDataModel("src/test/resources/decimal64/Decimal64TypeWithRangeStatement.yang");
// Check whether the data model tree returned is of type module.
assertThat((node instanceof YangModule), is(true));
@@ -122,7 +123,7 @@
@Test
public void processDecimal64ValueSuccessfulValidation() throws IOException, ParserException, DataModelException {
- YangNode node = manager.getDataModel("src/test/resources/Decimal64TypeValidation.yang");
+ YangNode node = manager.getDataModel("src/test/resources/decimal64/Decimal64TypeValidation.yang");
// Check whether the data model tree returned is of type module.
assertThat((node instanceof YangModule), is(true));
@@ -157,7 +158,7 @@
thrown.expect(DataModelException.class);
thrown.expectMessage("YANG file error : decimal64 validation failed.");
- YangNode node = manager.getDataModel("src/test/resources/Decimal64TypeValidation.yang");
+ YangNode node = manager.getDataModel("src/test/resources/decimal64/Decimal64TypeValidation.yang");
// Check whether the data model tree returned is of type module.
assertThat((node instanceof YangModule), is(true));
@@ -191,7 +192,7 @@
thrown.expect(ParserException.class);
thrown.expectMessage("YANG file error : fraction-digits value should be between 1 and 18.");
- manager.getDataModel("src/test/resources/Decimal64TypeInvalidMaxValueFraction.yang");
+ manager.getDataModel("src/test/resources/decimal64/Decimal64TypeInvalidMaxValueFraction.yang");
}
/**
@@ -202,7 +203,7 @@
thrown.expect(ParserException.class);
thrown.expectMessage("YANG file error : fraction-digits value should be between 1 and 18.");
- manager.getDataModel("src/test/resources/Decimal64TypeInvalidMinValueFraction1.yang");
+ manager.getDataModel("src/test/resources/decimal64/Decimal64TypeInvalidMinValueFraction1.yang");
}
/**
@@ -213,7 +214,7 @@
thrown.expect(ParserException.class);
thrown.expectMessage("YANG file error : fraction-digits value should be between 1 and 18.");
- manager.getDataModel("src/test/resources/Decimal64TypeInvalidMinValueFraction2.yang");
+ manager.getDataModel("src/test/resources/decimal64/Decimal64TypeInvalidMinValueFraction2.yang");
}
/**
@@ -222,7 +223,7 @@
@Test
public void processDecimal64TypeWithMultiValueRangeStatement() throws IOException, ParserException {
- YangNode node = manager.getDataModel("src/test/resources/Decimal64TypeWithMultiValueRangeStmnt.yang");
+ YangNode node = manager.getDataModel("src/test/resources/decimal64/Decimal64TypeWithMultiValueRangeStmnt.yang");
// Check whether the data model tree returned is of type module.
assertThat((node instanceof YangModule), is(true));
@@ -272,7 +273,7 @@
thrown.expect(ParserException.class);
thrown.expectMessage("YANG file error : decimal64 validation failed.");
- manager.getDataModel("src/test/resources/Decimal64TypeInvalidRangeStmnt.yang");
+ manager.getDataModel("src/test/resources/decimal64/Decimal64TypeInvalidRangeStmnt.yang");
}
/**
@@ -283,7 +284,7 @@
thrown.expect(ParserException.class);
thrown.expectMessage("YANG file error : a type decimal64 must have fraction-digits statement.");
- manager.getDataModel("src/test/resources/Decimal64TypeWithoutFraction.yang");
+ manager.getDataModel("src/test/resources/decimal64/Decimal64TypeWithoutFraction.yang");
}
/**
@@ -292,7 +293,7 @@
@Test
public void processDecimal64TypedefStatement() throws IOException, ParserException {
- YangNode node = manager.getDataModel("src/test/resources/Decimal64TypedefStatement.yang");
+ YangNode node = manager.getDataModel("src/test/resources/decimal64/Decimal64TypedefStatement.yang");
// Check whether the data model tree returned is of type module.
assertThat((node instanceof YangModule), is(true));
@@ -329,7 +330,7 @@
@Test
public void processDecimal64MultiTypedefStatement() throws IOException, ParserException {
- YangNode node = manager.getDataModel("src/test/resources/Decimal64MultiTypedefStatement.yang");
+ YangNode node = manager.getDataModel("src/test/resources/decimal64/Decimal64MultiTypedefStatement.yang");
// Check whether the data model tree returned is of type module.
assertThat((node instanceof YangModule), is(true));
@@ -345,15 +346,15 @@
YangLeaf leafInfo = leafIterator.next();
// check leaf type
- assertThat(leafInfo.getName(), is("setFourDecimal"));
- assertThat(leafInfo.getDataType().getDataTypeName(), is("validDecimal"));
+ assertThat(leafInfo.getName(), is("lowerDecimal"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("midDecimal"));
YangType<YangDerivedInfo> derivedInfoType = (YangType<YangDerivedInfo>) leafInfo.getDataType();
assertThat(derivedInfoType.getDataType(), is(YangDataTypes.DERIVED));
YangDerivedInfo derivedInfo = (YangDerivedInfo) derivedInfoType.getDataTypeExtendedInfo();
// check previous typedef
YangTypeDef prevTypedef = (YangTypeDef) derivedInfo.getReferredTypeDef();
- assertThat(prevTypedef.getName(), is("validDecimal"));
+ assertThat(prevTypedef.getName(), is("midDecimal"));
YangType type = prevTypedef.getTypeList().iterator().next();
assertThat(type.getDataType(), is(YangDataTypes.DERIVED));
derivedInfo = (YangDerivedInfo) type.getDataTypeExtendedInfo();
@@ -368,4 +369,260 @@
YangDecimal64 decimal64 = decimal64Type.getDataTypeExtendedInfo();
assertThat(decimal64.getFractionDigit(), is(4));
}
+
+ /**
+ * Checks decimal64 with multiple typedef with single range statement.
+ * Range value in typedef statement.
+ */
+ @Test
+ public void processDecimal64MultiTypedefRangeStatement() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/decimal64/Decimal64MultiTypedefRangeStatement.yang");
+
+ // Check whether the data model tree returned is of type module.
+ assertThat((node instanceof YangModule), is(true));
+
+ // Check whether the node type is set properly to module.
+ assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) node;
+ assertThat(yangNode.getName(), is("Test"));
+
+ ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ // check leaf type
+ assertThat(leafInfo.getName(), is("lowerDecimal"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("midDecimal"));
+ YangType<YangDerivedInfo> derivedInfoType = (YangType<YangDerivedInfo>) leafInfo.getDataType();
+ assertThat(derivedInfoType.getDataType(), is(YangDataTypes.DERIVED));
+ YangDerivedInfo derivedInfo = (YangDerivedInfo) derivedInfoType.getDataTypeExtendedInfo();
+
+ // Check range restriction
+ YangRangeRestriction rangeRestriction = (YangRangeRestriction) derivedInfo.getResolvedExtendedInfo();
+ ListIterator<YangRangeInterval> rangeListIterator = rangeRestriction.getAscendingRangeIntervals()
+ .listIterator();
+ YangRangeInterval rangeInterval = rangeListIterator.next();
+ assertThat(((YangDecimal64) rangeInterval.getStartValue()).getValue().doubleValue(), is(1.0));
+ assertThat(((YangDecimal64) rangeInterval.getEndValue()).getValue().doubleValue(), is(12.0));
+
+ // check previous typedef
+ YangTypeDef prevTypedef = (YangTypeDef) derivedInfo.getReferredTypeDef();
+ assertThat(prevTypedef.getName(), is("midDecimal"));
+ YangType type = prevTypedef.getTypeList().iterator().next();
+ assertThat(type.getDataType(), is(YangDataTypes.DERIVED));
+ derivedInfo = (YangDerivedInfo) type.getDataTypeExtendedInfo();
+
+ // check top typedef
+ YangTypeDef topTypedef = (YangTypeDef) derivedInfo.getReferredTypeDef();
+ assertThat(topTypedef.getName(), is("topDecimal"));
+ type = topTypedef.getTypeList().iterator().next();
+ assertThat(type.getDataType(), is(YangDataTypes.DECIMAL64));
+ assertThat(type.getDataTypeName(), is("decimal64"));
+ YangType<YangDecimal64> decimal64Type = (YangType<YangDecimal64>) type;
+ YangDecimal64 decimal64 = decimal64Type.getDataTypeExtendedInfo();
+ assertThat(decimal64.getFractionDigit(), is(4));
+
+ // Check range restriction
+ rangeRestriction = (YangRangeRestriction) decimal64.getRangeRestrictedExtendedInfo();
+ rangeListIterator = rangeRestriction.getAscendingRangeIntervals().listIterator();
+ rangeInterval = rangeListIterator.next();
+ assertThat(((YangDecimal64) rangeInterval.getStartValue()).getValue().doubleValue(), is(1.0));
+ assertThat(((YangDecimal64) rangeInterval.getEndValue()).getValue().doubleValue(), is(12.0));
+ }
+
+ /**
+ * Checks decimal64 with multiple typedef with single range statement.
+ * Range value in leaf statement.
+ */
+ @Test
+ public void processDecimal64MultiTypedefRangeInLeafStatement() throws IOException, ParserException {
+
+ YangNode node = manager
+ .getDataModel("src/test/resources/decimal64/Decimal64MultiTypedefRangeInLeafStatement.yang");
+
+ // Check whether the data model tree returned is of type module.
+ assertThat((node instanceof YangModule), is(true));
+
+ // Check whether the node type is set properly to module.
+ assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) node;
+ assertThat(yangNode.getName(), is("Test"));
+
+ ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ // check leaf type
+ assertThat(leafInfo.getName(), is("lowerDecimal"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("midDecimal"));
+ YangType<YangDerivedInfo> derivedInfoType = (YangType<YangDerivedInfo>) leafInfo.getDataType();
+ assertThat(derivedInfoType.getDataType(), is(YangDataTypes.DERIVED));
+ YangDerivedInfo derivedInfo = (YangDerivedInfo) derivedInfoType.getDataTypeExtendedInfo();
+
+ // Check range restriction
+ YangRangeRestriction rangeRestriction = (YangRangeRestriction) derivedInfo.getResolvedExtendedInfo();
+ ListIterator<YangRangeInterval> rangeListIterator = rangeRestriction.getAscendingRangeIntervals()
+ .listIterator();
+ YangRangeInterval rangeInterval = rangeListIterator.next();
+ assertThat(((YangDecimal64) rangeInterval.getStartValue()).getValue().doubleValue(), is(1.0));
+ assertThat(((YangDecimal64) rangeInterval.getEndValue()).getValue().doubleValue(), is(12.0));
+
+ // check previous typedef
+ YangTypeDef prevTypedef = (YangTypeDef) derivedInfo.getReferredTypeDef();
+ assertThat(prevTypedef.getName(), is("midDecimal"));
+ YangType type = prevTypedef.getTypeList().iterator().next();
+ assertThat(type.getDataType(), is(YangDataTypes.DERIVED));
+ derivedInfo = (YangDerivedInfo) type.getDataTypeExtendedInfo();
+
+ // check top typedef
+ YangTypeDef topTypedef = (YangTypeDef) derivedInfo.getReferredTypeDef();
+ assertThat(topTypedef.getName(), is("topDecimal"));
+ type = topTypedef.getTypeList().iterator().next();
+ assertThat(type.getDataType(), is(YangDataTypes.DECIMAL64));
+ assertThat(type.getDataTypeName(), is("decimal64"));
+ YangType<YangDecimal64> decimal64Type = (YangType<YangDecimal64>) type;
+ YangDecimal64 decimal64 = decimal64Type.getDataTypeExtendedInfo();
+ assertThat(decimal64.getFractionDigit(), is(4));
+ }
+
+ /**
+ * Checks decimal64 with multiple typedef with multiple range statement.
+ * Having more restricted range at leaf.
+ */
+ @Test
+ public void processDecimal64MultiTypedefMultipleRangeStatement() throws IOException, ParserException {
+
+ YangNode node = manager
+ .getDataModel("src/test/resources/decimal64/Decimal64MultiTypedefMultiRangeStatement.yang");
+
+ // Check whether the data model tree returned is of type module.
+ assertThat((node instanceof YangModule), is(true));
+
+ // Check whether the node type is set properly to module.
+ assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) node;
+ assertThat(yangNode.getName(), is("Test"));
+
+ ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ // check leaf type
+ assertThat(leafInfo.getName(), is("lowerDecimal"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("midDecimal"));
+ YangType<YangDerivedInfo> derivedInfoType = (YangType<YangDerivedInfo>) leafInfo.getDataType();
+ assertThat(derivedInfoType.getDataType(), is(YangDataTypes.DERIVED));
+ YangDerivedInfo derivedInfo = (YangDerivedInfo) derivedInfoType.getDataTypeExtendedInfo();
+
+ // Check range restriction
+ YangRangeRestriction rangeRestriction = (YangRangeRestriction) derivedInfo.getResolvedExtendedInfo();
+
+ ListIterator<YangRangeInterval> rangeListIterator = rangeRestriction.getAscendingRangeIntervals()
+ .listIterator();
+ YangRangeInterval rangeInterval = rangeListIterator.next();
+ assertThat(((YangDecimal64) rangeInterval.getStartValue()).getValue().doubleValue(), is(4.0));
+ assertThat(((YangDecimal64) rangeInterval.getEndValue()).getValue().doubleValue(), is(11.0));
+
+ // check previous typedef
+ YangTypeDef prevTypedef = (YangTypeDef) derivedInfo.getReferredTypeDef();
+ assertThat(prevTypedef.getName(), is("midDecimal"));
+ YangType type = prevTypedef.getTypeList().iterator().next();
+ assertThat(type.getDataType(), is(YangDataTypes.DERIVED));
+ derivedInfo = (YangDerivedInfo) type.getDataTypeExtendedInfo();
+
+ // check top typedef
+ YangTypeDef topTypedef = (YangTypeDef) derivedInfo.getReferredTypeDef();
+ assertThat(topTypedef.getName(), is("topDecimal"));
+ type = topTypedef.getTypeList().iterator().next();
+ assertThat(type.getDataType(), is(YangDataTypes.DECIMAL64));
+ assertThat(type.getDataTypeName(), is("decimal64"));
+ YangType<YangDecimal64> decimal64Type = (YangType<YangDecimal64>) type;
+ YangDecimal64 decimal64 = decimal64Type.getDataTypeExtendedInfo();
+ assertThat(decimal64.getFractionDigit(), is(4));
+
+ // Check range restriction
+ rangeRestriction = (YangRangeRestriction) decimal64.getRangeRestrictedExtendedInfo();
+ rangeListIterator = rangeRestriction.getAscendingRangeIntervals().listIterator();
+ rangeInterval = rangeListIterator.next();
+ assertThat(((YangDecimal64) rangeInterval.getStartValue()).getValue().doubleValue(), is(1.0));
+ assertThat(((YangDecimal64) rangeInterval.getEndValue()).getValue().doubleValue(), is(12.0));
+ }
+
+ /**
+ * Checks decimal64 with multiple typedef with multiple range statement.
+ * But having more restricted range at top of typedef.
+ */
+ @Test
+ public void processDecimal64MultiTypedefMultiInvalidRangeStatement() throws IOException, LinkerException {
+ thrown.expect(LinkerException.class);
+ thrown.expectMessage(" Range interval doesn't fall within the referred restriction ranges");
+
+ manager.getDataModel("src/test/resources/decimal64/Decimal64MultiTypedefMultiInvalidRangeStatement.yang");
+ }
+
+ /**
+ * Checks decimal64 with multiple typedef with max range statement.
+ */
+ @Test
+ public void processDecimal64MultiTypedefWithMaxRange() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/decimal64/Decimal64MultiTypedefWithMaxRange.yang");
+
+ // Check whether the data model tree returned is of type module.
+ assertThat((node instanceof YangModule), is(true));
+
+ // Check whether the node type is set properly to module.
+ assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) node;
+ assertThat(yangNode.getName(), is("Test"));
+
+ ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ // check leaf type
+ assertThat(leafInfo.getName(), is("lowerDecimal"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("midDecimal"));
+ YangType<YangDerivedInfo> derivedInfoType = (YangType<YangDerivedInfo>) leafInfo.getDataType();
+ assertThat(derivedInfoType.getDataType(), is(YangDataTypes.DERIVED));
+ YangDerivedInfo derivedInfo = (YangDerivedInfo) derivedInfoType.getDataTypeExtendedInfo();
+
+ // Check range restriction
+ YangRangeRestriction rangeRestriction = (YangRangeRestriction) derivedInfo.getResolvedExtendedInfo();
+
+ ListIterator<YangRangeInterval> rangeListIterator = rangeRestriction.getAscendingRangeIntervals()
+ .listIterator();
+ YangRangeInterval rangeInterval = rangeListIterator.next();
+ assertThat(((YangDecimal64) rangeInterval.getStartValue()).getValue().doubleValue(), is(4.0));
+ assertThat(((YangDecimal64) rangeInterval.getEndValue()).getValue().doubleValue(), is(12.0));
+
+ // check previous typedef
+ YangTypeDef prevTypedef = (YangTypeDef) derivedInfo.getReferredTypeDef();
+ assertThat(prevTypedef.getName(), is("midDecimal"));
+ YangType type = prevTypedef.getTypeList().iterator().next();
+ assertThat(type.getDataType(), is(YangDataTypes.DERIVED));
+ derivedInfo = (YangDerivedInfo) type.getDataTypeExtendedInfo();
+
+ // check top typedef
+ YangTypeDef topTypedef = (YangTypeDef) derivedInfo.getReferredTypeDef();
+ assertThat(topTypedef.getName(), is("topDecimal"));
+ type = topTypedef.getTypeList().iterator().next();
+ assertThat(type.getDataType(), is(YangDataTypes.DECIMAL64));
+ assertThat(type.getDataTypeName(), is("decimal64"));
+ YangType<YangDecimal64> decimal64Type = (YangType<YangDecimal64>) type;
+ YangDecimal64 decimal64 = decimal64Type.getDataTypeExtendedInfo();
+ assertThat(decimal64.getFractionDigit(), is(4));
+
+ // Check range restriction
+ rangeRestriction = (YangRangeRestriction) decimal64.getRangeRestrictedExtendedInfo();
+ rangeListIterator = rangeRestriction.getAscendingRangeIntervals().listIterator();
+ rangeInterval = rangeListIterator.next();
+ assertThat(((YangDecimal64) rangeInterval.getStartValue()).getValue().doubleValue(), is(1.0));
+ assertThat(((YangDecimal64) rangeInterval.getEndValue()).getValue().doubleValue(), is(12.0));
+ }
}
diff --git a/utils/yangutils/plugin/src/test/resources/BitTypedefReferredLeafStatement.yang b/utils/yangutils/plugin/src/test/resources/BitTypedefReferredLeafStatement.yang
new file mode 100644
index 0000000..cda6381
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/BitTypedefReferredLeafStatement.yang
@@ -0,0 +1,22 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ typedef topBits {
+ type bits {
+ bit disable-nagle {
+ position 0;
+ }
+ bit auto-sense-speed {
+ position 1;
+ }
+ bit Mb-only {
+ position 2;
+ }
+ }
+ }
+
+ leaf myBits {
+ type topBits;
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/decimal64/Decimal64MultiTypedefMultiInvalidRangeStatement.yang b/utils/yangutils/plugin/src/test/resources/decimal64/Decimal64MultiTypedefMultiInvalidRangeStatement.yang
new file mode 100644
index 0000000..966b387
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/decimal64/Decimal64MultiTypedefMultiInvalidRangeStatement.yang
@@ -0,0 +1,22 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+
+ typedef topDecimal {
+ type decimal64 {
+ fraction-digits 4;
+ range 4..11;
+ }
+ }
+
+ typedef midDecimal {
+ type topDecimal;
+ }
+
+ leaf lowerDecimal {
+ type midDecimal {
+ range 1..12;
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/decimal64/Decimal64MultiTypedefMultiRangeStatement.yang b/utils/yangutils/plugin/src/test/resources/decimal64/Decimal64MultiTypedefMultiRangeStatement.yang
new file mode 100644
index 0000000..76f215a
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/decimal64/Decimal64MultiTypedefMultiRangeStatement.yang
@@ -0,0 +1,22 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+
+ typedef topDecimal {
+ type decimal64 {
+ fraction-digits 4;
+ range 1..12;
+ }
+ }
+
+ typedef midDecimal {
+ type topDecimal;
+ }
+
+ leaf lowerDecimal {
+ type midDecimal {
+ range 4..11;
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/decimal64/Decimal64MultiTypedefRangeInLeafStatement.yang b/utils/yangutils/plugin/src/test/resources/decimal64/Decimal64MultiTypedefRangeInLeafStatement.yang
new file mode 100644
index 0000000..eea48f4
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/decimal64/Decimal64MultiTypedefRangeInLeafStatement.yang
@@ -0,0 +1,21 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+
+ typedef topDecimal {
+ type decimal64 {
+ fraction-digits 4;
+ }
+ }
+
+ typedef midDecimal {
+ type topDecimal;
+ }
+
+ leaf lowerDecimal {
+ type midDecimal {
+ range 1..12;
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/Decimal64MultiTypedefStatement.yang b/utils/yangutils/plugin/src/test/resources/decimal64/Decimal64MultiTypedefRangeStatement.yang
similarity index 69%
copy from utils/yangutils/plugin/src/test/resources/Decimal64MultiTypedefStatement.yang
copy to utils/yangutils/plugin/src/test/resources/decimal64/Decimal64MultiTypedefRangeStatement.yang
index fdce08e..b4c0a36 100644
--- a/utils/yangutils/plugin/src/test/resources/Decimal64MultiTypedefStatement.yang
+++ b/utils/yangutils/plugin/src/test/resources/decimal64/Decimal64MultiTypedefRangeStatement.yang
@@ -6,14 +6,15 @@
typedef topDecimal {
type decimal64 {
fraction-digits 4;
+ range 1..12;
}
}
- typedef validDecimal {
+ typedef midDecimal {
type topDecimal;
}
- leaf setFourDecimal {
- type validDecimal;
+ leaf lowerDecimal {
+ type midDecimal;
}
}
diff --git a/utils/yangutils/plugin/src/test/resources/Decimal64MultiTypedefStatement.yang b/utils/yangutils/plugin/src/test/resources/decimal64/Decimal64MultiTypedefStatement.yang
similarity index 73%
rename from utils/yangutils/plugin/src/test/resources/Decimal64MultiTypedefStatement.yang
rename to utils/yangutils/plugin/src/test/resources/decimal64/Decimal64MultiTypedefStatement.yang
index fdce08e..8682aac 100644
--- a/utils/yangutils/plugin/src/test/resources/Decimal64MultiTypedefStatement.yang
+++ b/utils/yangutils/plugin/src/test/resources/decimal64/Decimal64MultiTypedefStatement.yang
@@ -9,11 +9,11 @@
}
}
- typedef validDecimal {
+ typedef midDecimal {
type topDecimal;
}
- leaf setFourDecimal {
- type validDecimal;
+ leaf lowerDecimal {
+ type midDecimal;
}
}
diff --git a/utils/yangutils/plugin/src/test/resources/decimal64/Decimal64MultiTypedefWithMaxRange.yang b/utils/yangutils/plugin/src/test/resources/decimal64/Decimal64MultiTypedefWithMaxRange.yang
new file mode 100644
index 0000000..405d08c
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/decimal64/Decimal64MultiTypedefWithMaxRange.yang
@@ -0,0 +1,22 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+
+ typedef topDecimal {
+ type decimal64 {
+ fraction-digits 4;
+ range 1..12;
+ }
+ }
+
+ typedef midDecimal {
+ type topDecimal;
+ }
+
+ leaf lowerDecimal {
+ type midDecimal {
+ range 4..max;
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/Decimal64TypeInvalidMaxValueFraction.yang b/utils/yangutils/plugin/src/test/resources/decimal64/Decimal64TypeInvalidMaxValueFraction.yang
similarity index 100%
rename from utils/yangutils/plugin/src/test/resources/Decimal64TypeInvalidMaxValueFraction.yang
rename to utils/yangutils/plugin/src/test/resources/decimal64/Decimal64TypeInvalidMaxValueFraction.yang
diff --git a/utils/yangutils/plugin/src/test/resources/Decimal64TypeInvalidMinValueFraction1.yang b/utils/yangutils/plugin/src/test/resources/decimal64/Decimal64TypeInvalidMinValueFraction1.yang
similarity index 100%
rename from utils/yangutils/plugin/src/test/resources/Decimal64TypeInvalidMinValueFraction1.yang
rename to utils/yangutils/plugin/src/test/resources/decimal64/Decimal64TypeInvalidMinValueFraction1.yang
diff --git a/utils/yangutils/plugin/src/test/resources/Decimal64TypeInvalidMinValueFraction2.yang b/utils/yangutils/plugin/src/test/resources/decimal64/Decimal64TypeInvalidMinValueFraction2.yang
similarity index 100%
rename from utils/yangutils/plugin/src/test/resources/Decimal64TypeInvalidMinValueFraction2.yang
rename to utils/yangutils/plugin/src/test/resources/decimal64/Decimal64TypeInvalidMinValueFraction2.yang
diff --git a/utils/yangutils/plugin/src/test/resources/Decimal64TypeInvalidRangeStmnt.yang b/utils/yangutils/plugin/src/test/resources/decimal64/Decimal64TypeInvalidRangeStmnt.yang
similarity index 100%
rename from utils/yangutils/plugin/src/test/resources/Decimal64TypeInvalidRangeStmnt.yang
rename to utils/yangutils/plugin/src/test/resources/decimal64/Decimal64TypeInvalidRangeStmnt.yang
diff --git a/utils/yangutils/plugin/src/test/resources/Decimal64TypeStatement.yang b/utils/yangutils/plugin/src/test/resources/decimal64/Decimal64TypeStatement.yang
similarity index 100%
rename from utils/yangutils/plugin/src/test/resources/Decimal64TypeStatement.yang
rename to utils/yangutils/plugin/src/test/resources/decimal64/Decimal64TypeStatement.yang
diff --git a/utils/yangutils/plugin/src/test/resources/Decimal64TypeValidation.yang b/utils/yangutils/plugin/src/test/resources/decimal64/Decimal64TypeValidation.yang
similarity index 100%
rename from utils/yangutils/plugin/src/test/resources/Decimal64TypeValidation.yang
rename to utils/yangutils/plugin/src/test/resources/decimal64/Decimal64TypeValidation.yang
diff --git a/utils/yangutils/plugin/src/test/resources/Decimal64TypeWithMultiValueRangeStmnt.yang b/utils/yangutils/plugin/src/test/resources/decimal64/Decimal64TypeWithMultiValueRangeStmnt.yang
similarity index 100%
rename from utils/yangutils/plugin/src/test/resources/Decimal64TypeWithMultiValueRangeStmnt.yang
rename to utils/yangutils/plugin/src/test/resources/decimal64/Decimal64TypeWithMultiValueRangeStmnt.yang
diff --git a/utils/yangutils/plugin/src/test/resources/Decimal64TypeWithRangeStatement.yang b/utils/yangutils/plugin/src/test/resources/decimal64/Decimal64TypeWithRangeStatement.yang
similarity index 100%
rename from utils/yangutils/plugin/src/test/resources/Decimal64TypeWithRangeStatement.yang
rename to utils/yangutils/plugin/src/test/resources/decimal64/Decimal64TypeWithRangeStatement.yang
diff --git a/utils/yangutils/plugin/src/test/resources/Decimal64TypeWithoutFraction.yang b/utils/yangutils/plugin/src/test/resources/decimal64/Decimal64TypeWithoutFraction.yang
similarity index 100%
rename from utils/yangutils/plugin/src/test/resources/Decimal64TypeWithoutFraction.yang
rename to utils/yangutils/plugin/src/test/resources/decimal64/Decimal64TypeWithoutFraction.yang
diff --git a/utils/yangutils/plugin/src/test/resources/Decimal64TypedefStatement.yang b/utils/yangutils/plugin/src/test/resources/decimal64/Decimal64TypedefStatement.yang
similarity index 100%
rename from utils/yangutils/plugin/src/test/resources/Decimal64TypedefStatement.yang
rename to utils/yangutils/plugin/src/test/resources/decimal64/Decimal64TypedefStatement.yang
diff --git a/utils/yangutils/plugin/src/test/resources/interfileietf/ietf-te-topology.yang b/utils/yangutils/plugin/src/test/resources/interfileietf/ietf-te-topology.yang
index 10b6c11..5b65dff 100644
--- a/utils/yangutils/plugin/src/test/resources/interfileietf/ietf-te-topology.yang
+++ b/utils/yangutils/plugin/src/test/resources/interfileietf/ietf-te-topology.yang
@@ -1723,7 +1723,6 @@
uses tet:te-link-state-derived;
}
-
augment "/te-link-event/te-link-attributes/underlay" {
description "Add state attributes to te-link underlay.";
uses te-link-state-underlay-attributes;