YANG: Restriction resolution implementation
Change-Id: I69503e8229def07b289a0c8c762bfe0ae5530232
diff --git a/src/test/java/org/onosproject/yangutils/linker/IntraFileTypeLinkingTest.java b/src/test/java/org/onosproject/yangutils/linker/IntraFileTypeLinkingTest.java
index 82e9c3a..a4cb0a5 100644
--- a/src/test/java/org/onosproject/yangutils/linker/IntraFileTypeLinkingTest.java
+++ b/src/test/java/org/onosproject/yangutils/linker/IntraFileTypeLinkingTest.java
@@ -18,23 +18,26 @@
import java.io.IOException;
import java.util.ListIterator;
-
import org.junit.Test;
-import org.onosproject.yangutils.datamodel.ResolvableStatus;
import org.onosproject.yangutils.datamodel.YangContainer;
-import org.onosproject.yangutils.datamodel.YangDataTypes;
import org.onosproject.yangutils.datamodel.YangDerivedInfo;
import org.onosproject.yangutils.datamodel.YangLeaf;
import org.onosproject.yangutils.datamodel.YangList;
import org.onosproject.yangutils.datamodel.YangModule;
import org.onosproject.yangutils.datamodel.YangNode;
-import org.onosproject.yangutils.datamodel.YangNodeType;
import org.onosproject.yangutils.datamodel.YangTypeDef;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
+import static org.onosproject.yangutils.datamodel.ResolvableStatus.INTRA_FILE_RESOLVED;
+import static org.onosproject.yangutils.datamodel.ResolvableStatus.RESOLVED;
+import static org.onosproject.yangutils.datamodel.YangDataTypes.DERIVED;
+import static org.onosproject.yangutils.datamodel.YangDataTypes.INT32;
+import static org.onosproject.yangutils.datamodel.YangDataTypes.STRING;
+import static org.onosproject.yangutils.datamodel.YangNodeType.MODULE_NODE;
/**
* Test cases for testing "type" intra file linking.
@@ -56,7 +59,7 @@
assertThat(node instanceof YangModule, is(true));
// Check whether the node type is set properly to module.
- assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+ assertThat(node.getNodeType(), is(MODULE_NODE));
// Check whether the module name is set correctly.
YangModule yangNode = (YangModule) node;
@@ -67,13 +70,23 @@
assertThat(leafInfo.getName(), is("invalid-interval"));
assertThat(leafInfo.getDataType().getDataTypeName(), is("hello"));
- assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.DERIVED));
+ assertThat(leafInfo.getDataType().getDataType(), is(DERIVED));
assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
is((YangTypeDef) node.getChild()));
- assertThat(leafInfo.getDataType().getResolvableStatus(),
- is(ResolvableStatus.RESOLVED));
+ assertThat(leafInfo.getDataType().getResolvableStatus(), is(RESOLVED));
+
+ YangDerivedInfo<?> derivedInfo = (YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo();
+
+ // Check for the effective built-in type.
+ assertThat(derivedInfo.getEffectiveBuiltInType(), is(STRING));
+
+ // Check for the restriction.
+ assertThat(derivedInfo.getLengthRestrictionString(), is(nullValue()));
+ assertThat(derivedInfo.getRangeRestrictionString(), is(nullValue()));
+ assertThat(derivedInfo.getPatternRestriction(), is(nullValue()));
+ assertThat(derivedInfo.getResolvedExtendedInfo(), is(nullValue()));
}
/**
@@ -91,7 +104,7 @@
assertThat((node instanceof YangModule), is(true));
// Check whether the node type is set properly to module.
- assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+ assertThat(node.getNodeType(), is(MODULE_NODE));
// Check whether the module name is set correctly.
YangModule yangNode = (YangModule) node;
@@ -106,13 +119,23 @@
assertThat(leafInfo.getName(), is("invalid-interval"));
assertThat(leafInfo.getDataType().getDataTypeName(), is("hello"));
- assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.DERIVED));
+ assertThat(leafInfo.getDataType().getDataType(), is(DERIVED));
assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
is((YangTypeDef) node.getChild()));
- assertThat(leafInfo.getDataType().getResolvableStatus(),
- is(ResolvableStatus.RESOLVED));
+ assertThat(leafInfo.getDataType().getResolvableStatus(), is(RESOLVED));
+
+ YangDerivedInfo<?> derivedInfo = (YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo();
+
+ // Check for the effective built-in type.
+ assertThat(derivedInfo.getEffectiveBuiltInType(), is(STRING));
+
+ // Check for the restriction.
+ assertThat(derivedInfo.getLengthRestrictionString(), is(nullValue()));
+ assertThat(derivedInfo.getRangeRestrictionString(), is(nullValue()));
+ assertThat(derivedInfo.getPatternRestriction(), is(nullValue()));
+ assertThat(derivedInfo.getResolvedExtendedInfo(), is(nullValue()));
}
/**
@@ -131,7 +154,7 @@
assertThat((node instanceof YangModule), is(true));
// Check whether the node type is set properly to module.
- assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+ assertThat(node.getNodeType(), is(MODULE_NODE));
// Check whether the module name is set correctly.
YangModule yangNode = (YangModule) node;
@@ -146,13 +169,23 @@
assertThat(leafInfo.getName(), is("invalid-interval"));
assertThat(leafInfo.getDataType().getDataTypeName(), is("hello"));
- assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.DERIVED));
+ assertThat(leafInfo.getDataType().getDataType(), is(DERIVED));
assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
is((YangTypeDef) node.getChild().getNextSibling()));
- assertThat(leafInfo.getDataType().getResolvableStatus(),
- is(ResolvableStatus.RESOLVED));
+ assertThat(leafInfo.getDataType().getResolvableStatus(), is(RESOLVED));
+
+ YangDerivedInfo<?> derivedInfo = (YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo();
+
+ // Check for the effective built-in type.
+ assertThat(derivedInfo.getEffectiveBuiltInType(), is(STRING));
+
+ // Check for the restriction.
+ assertThat(derivedInfo.getLengthRestrictionString(), is(nullValue()));
+ assertThat(derivedInfo.getRangeRestrictionString(), is(nullValue()));
+ assertThat(derivedInfo.getPatternRestriction(), is(nullValue()));
+ assertThat(derivedInfo.getResolvedExtendedInfo(), is(nullValue()));
}
/**
@@ -171,7 +204,7 @@
assertThat((node instanceof YangModule), is(true));
// Check whether the node type is set properly to module.
- assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+ assertThat(node.getNodeType(), is(MODULE_NODE));
// Check whether the module name is set correctly.
YangModule yangNode = (YangModule) node;
@@ -186,13 +219,23 @@
assertThat(leafInfo.getName(), is("invalid-interval"));
assertThat(leafInfo.getDataType().getDataTypeName(), is("hello"));
- assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.DERIVED));
+ assertThat(leafInfo.getDataType().getDataType(), is(DERIVED));
assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
is((YangTypeDef) yangContainer.getChild().getNextSibling()));
- assertThat(leafInfo.getDataType().getResolvableStatus(),
- is(ResolvableStatus.RESOLVED));
+ assertThat(leafInfo.getDataType().getResolvableStatus(), is(RESOLVED));
+
+ YangDerivedInfo<?> derivedInfo = (YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo();
+
+ // Check for the effective built-in type.
+ assertThat(derivedInfo.getEffectiveBuiltInType(), is(STRING));
+
+ // Check for the restriction.
+ assertThat(derivedInfo.getLengthRestrictionString(), is(nullValue()));
+ assertThat(derivedInfo.getRangeRestrictionString(), is(nullValue()));
+ assertThat(derivedInfo.getPatternRestriction(), is(nullValue()));
+ assertThat(derivedInfo.getResolvedExtendedInfo(), is(nullValue()));
}
/**
@@ -209,7 +252,7 @@
assertThat((node instanceof YangModule), is(true));
// Check whether the node type is set properly to module.
- assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+ assertThat(node.getNodeType(), is(MODULE_NODE));
// Check whether the module name is set correctly.
YangModule yangNode = (YangModule) node;
@@ -224,26 +267,37 @@
assertThat(leafInfo.getName(), is("invalid-interval"));
assertThat(leafInfo.getDataType().getDataTypeName(), is("FirstClass"));
- assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.DERIVED));
+ assertThat(leafInfo.getDataType().getDataType(), is(DERIVED));
assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
is((YangTypeDef) yangList.getChild()));
assertThat(leafInfo.getDataType().getResolvableStatus(),
- is(ResolvableStatus.RESOLVED));
+ is(RESOLVED));
YangTypeDef typeDef1 = (YangTypeDef) yangList.getChild();
assertThat(((YangDerivedInfo<?>) typeDef1.getTypeDefBaseType().getDataTypeExtendedInfo()).getReferredTypeDef(),
is((YangTypeDef) yangContainer.getChild().getNextSibling()));
assertThat(typeDef1.getTypeDefBaseType().getResolvableStatus(),
- is(ResolvableStatus.RESOLVED));
+ is(RESOLVED));
YangTypeDef typeDef2 = (YangTypeDef) yangContainer.getChild().getNextSibling();
assertThat(((YangDerivedInfo<?>) typeDef2.getTypeDefBaseType().getDataTypeExtendedInfo()).getReferredTypeDef(),
is((YangTypeDef) node.getChild()));
assertThat(typeDef2.getTypeDefBaseType().getResolvableStatus(),
- is(ResolvableStatus.RESOLVED));
+ is(RESOLVED));
+
+ YangDerivedInfo<?> derivedInfo = (YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo();
+
+ // Check for the effective built-in type.
+ assertThat(derivedInfo.getEffectiveBuiltInType(), is(INT32));
+
+ // Check for the restriction.
+ assertThat(derivedInfo.getLengthRestrictionString(), is(nullValue()));
+ assertThat(derivedInfo.getRangeRestrictionString(), is(nullValue()));
+ assertThat(derivedInfo.getPatternRestriction(), is(nullValue()));
+ assertThat(derivedInfo.getResolvedExtendedInfo(), is(nullValue()));
}
/**
@@ -261,7 +315,7 @@
assertThat((node instanceof YangModule), is(true));
// Check whether the node type is set properly to module.
- assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+ assertThat(node.getNodeType(), is(MODULE_NODE));
// Check whether the module name is set correctly.
YangModule yangNode = (YangModule) node;
@@ -276,26 +330,37 @@
assertThat(leafInfo.getName(), is("invalid-interval"));
assertThat(leafInfo.getDataType().getDataTypeName(), is("FirstClass"));
- assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.DERIVED));
+ assertThat(leafInfo.getDataType().getDataType(), is(DERIVED));
assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
is((YangTypeDef) yangList.getChild()));
assertThat(leafInfo.getDataType().getResolvableStatus(),
- is(ResolvableStatus.INTRA_FILE_RESOLVED));
+ is(INTRA_FILE_RESOLVED));
YangTypeDef typeDef1 = (YangTypeDef) yangList.getChild();
assertThat(((YangDerivedInfo<?>) typeDef1.getTypeDefBaseType().getDataTypeExtendedInfo()).getReferredTypeDef(),
is((YangTypeDef) yangContainer.getChild().getNextSibling()));
assertThat(typeDef1.getTypeDefBaseType().getResolvableStatus(),
- is(ResolvableStatus.INTRA_FILE_RESOLVED));
+ is(INTRA_FILE_RESOLVED));
YangTypeDef typeDef2 = (YangTypeDef) yangContainer.getChild().getNextSibling();
assertThat(((YangDerivedInfo<?>) typeDef2.getTypeDefBaseType().getDataTypeExtendedInfo()).getReferredTypeDef(),
is((YangTypeDef) node.getChild()));
assertThat(typeDef2.getTypeDefBaseType().getResolvableStatus(),
- is(ResolvableStatus.INTRA_FILE_RESOLVED));
+ is(INTRA_FILE_RESOLVED));
+
+ YangDerivedInfo<?> derivedInfo = (YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo();
+
+ // Check for the effective built-in type.
+ assertThat(derivedInfo.getEffectiveBuiltInType(), is(nullValue()));
+
+ // Check for the restriction.
+ assertThat(derivedInfo.getLengthRestrictionString(), is(nullValue()));
+ assertThat(derivedInfo.getRangeRestrictionString(), is(nullValue()));
+ assertThat(derivedInfo.getPatternRestriction(), is(nullValue()));
+ assertThat(derivedInfo.getResolvedExtendedInfo(), is(nullValue()));
}
/**
@@ -312,7 +377,7 @@
assertThat((node instanceof YangModule), is(true));
// Check whether the node type is set properly to module.
- assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+ assertThat(node.getNodeType(), is(MODULE_NODE));
// Check whether the module name is set correctly.
YangModule yangNode = (YangModule) node;
@@ -327,26 +392,37 @@
assertThat(leafInfo.getName(), is("invalid-interval"));
assertThat(leafInfo.getDataType().getDataTypeName(), is("FirstClass"));
- assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.DERIVED));
+ assertThat(leafInfo.getDataType().getDataType(), is(DERIVED));
assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
is((YangTypeDef) yangList.getChild()));
assertThat(leafInfo.getDataType().getResolvableStatus(),
- is(ResolvableStatus.RESOLVED));
+ is(RESOLVED));
YangTypeDef typeDef1 = (YangTypeDef) yangList.getChild();
assertThat(((YangDerivedInfo<?>) typeDef1.getTypeDefBaseType().getDataTypeExtendedInfo()).getReferredTypeDef(),
is((YangTypeDef) yangContainer.getChild().getNextSibling()));
assertThat(typeDef1.getTypeDefBaseType().getResolvableStatus(),
- is(ResolvableStatus.RESOLVED));
+ is(RESOLVED));
YangTypeDef typeDef2 = (YangTypeDef) yangContainer.getChild().getNextSibling();
assertThat(((YangDerivedInfo<?>) typeDef2.getTypeDefBaseType().getDataTypeExtendedInfo()).getReferredTypeDef(),
is((YangTypeDef) node.getChild()));
assertThat(typeDef2.getTypeDefBaseType().getResolvableStatus(),
- is(ResolvableStatus.RESOLVED));
+ is(RESOLVED));
+
+ YangDerivedInfo<?> derivedInfo = (YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo();
+
+ // Check for the effective built-in type.
+ assertThat(derivedInfo.getEffectiveBuiltInType(), is(INT32));
+
+ // Check for the restriction.
+ assertThat(derivedInfo.getLengthRestrictionString(), is(nullValue()));
+ assertThat(derivedInfo.getRangeRestrictionString(), is(nullValue()));
+ assertThat(derivedInfo.getPatternRestriction(), is(nullValue()));
+ assertThat(derivedInfo.getResolvedExtendedInfo(), is(nullValue()));
}
/**
@@ -364,7 +440,7 @@
assertThat((node instanceof YangModule), is(true));
// Check whether the node type is set properly to module.
- assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+ assertThat(node.getNodeType(), is(MODULE_NODE));
// Check whether the module name is set correctly.
YangModule yangNode = (YangModule) node;
@@ -379,12 +455,12 @@
assertThat(leafInfo.getName(), is("invalid-interval"));
assertThat(leafInfo.getDataType().getDataTypeName(), is("FirstClass"));
- assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.DERIVED));
+ assertThat(leafInfo.getDataType().getDataType(), is(DERIVED));
assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
is((YangTypeDef) yangList.getChild()));
assertThat(leafInfo.getDataType().getResolvableStatus(),
- is(ResolvableStatus.INTRA_FILE_RESOLVED));
+ is(INTRA_FILE_RESOLVED));
YangTypeDef typeDef1 = (YangTypeDef) yangList.getChild();
@@ -393,7 +469,18 @@
assertThat(((YangDerivedInfo<?>) typeDef2.getTypeDefBaseType().getDataTypeExtendedInfo()).getReferredTypeDef(),
is((YangTypeDef) node.getChild()));
assertThat(typeDef2.getTypeDefBaseType().getResolvableStatus(),
- is(ResolvableStatus.RESOLVED));
+ is(RESOLVED));
+
+ YangDerivedInfo<?> derivedInfo = (YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo();
+
+ // Check for the effective built-in type.
+ assertThat(derivedInfo.getEffectiveBuiltInType(), is(nullValue()));
+
+ // Check for the restriction.
+ assertThat(derivedInfo.getLengthRestrictionString(), is(nullValue()));
+ assertThat(derivedInfo.getRangeRestrictionString(), is(nullValue()));
+ assertThat(derivedInfo.getPatternRestriction(), is(nullValue()));
+ assertThat(derivedInfo.getResolvedExtendedInfo(), is(nullValue()));
}
/**
diff --git a/src/test/java/org/onosproject/yangutils/linker/IntraFileUsesLinkingTest.java b/src/test/java/org/onosproject/yangutils/linker/IntraFileUsesLinkingTest.java
index 352b3d0..85c3840 100644
--- a/src/test/java/org/onosproject/yangutils/linker/IntraFileUsesLinkingTest.java
+++ b/src/test/java/org/onosproject/yangutils/linker/IntraFileUsesLinkingTest.java
@@ -18,7 +18,6 @@
import java.io.IOException;
import java.util.ListIterator;
-
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
@@ -81,7 +80,7 @@
// Check whether the information in the leaf is correct under grouping.
assertThat(leafInfo.getName(), is("hello"));
- assertThat(leafInfo.getDataType().getDataTypeName(), is("String"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("string"));
assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING));
// Check whether uses is module's child.
@@ -97,7 +96,7 @@
// Check whether the information in the leaf is correct under module.
assertThat(leafInfo.getName(), is("hello"));
- assertThat(leafInfo.getDataType().getDataTypeName(), is("String"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("string"));
assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING));
}
@@ -135,7 +134,7 @@
// Check whether the information in the leaf is correct under grouping.
assertThat(leafInfo.getName(), is("treat"));
- assertThat(leafInfo.getDataType().getDataTypeName(), is("String"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("string"));
assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING));
// Check whether container is the child of grouping.
@@ -150,7 +149,7 @@
// Check whether the information in the leaf is correct under container which is under grouping.
assertThat(leafInfo.getName(), is("leaf2"));
- assertThat(leafInfo.getDataType().getDataTypeName(), is("String"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("string"));
assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING));
// Check whether uses is module's child.
@@ -166,7 +165,7 @@
// Check whether the information in the leaf is correct under module.
assertThat(leafInfo.getName(), is("treat"));
- assertThat(leafInfo.getDataType().getDataTypeName(), is("String"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("string"));
assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING));
// Check whether container is the child of module.
@@ -181,7 +180,7 @@
// Check whether the information in the leaf is correct under container which is under module.
assertThat(leafInfo.getName(), is("leaf2"));
- assertThat(leafInfo.getDataType().getDataTypeName(), is("String"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("string"));
assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING));
}
@@ -688,7 +687,7 @@
// Check whether the information in the leaf is correct under grouping.
assertThat(leafInfo.getName(), is("hello"));
- assertThat(leafInfo.getDataType().getDataTypeName(), is("String"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("string"));
assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING));
}
@@ -762,7 +761,7 @@
// Check whether the information in the leaf is correct under grouping.
assertThat(leafInfo.getName(), is("hello"));
- assertThat(leafInfo.getDataType().getDataTypeName(), is("String"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("string"));
assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING));
}
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 513c7ed..3c01335 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
@@ -19,20 +19,18 @@
import java.io.IOException;
import java.math.BigInteger;
import java.util.ListIterator;
-
import org.junit.Rule;
import org.junit.Test;
-
import org.junit.rules.ExpectedException;
-import org.onosproject.yangutils.datamodel.YangNode;
-import org.onosproject.yangutils.datamodel.YangModule;
-import org.onosproject.yangutils.datamodel.YangNodeType;
+import org.onosproject.yangutils.datamodel.YangDataTypes;
import org.onosproject.yangutils.datamodel.YangLeaf;
import org.onosproject.yangutils.datamodel.YangLeafList;
-import org.onosproject.yangutils.datamodel.YangDataTypes;
-import org.onosproject.yangutils.datamodel.YangStringRestriction;
+import org.onosproject.yangutils.datamodel.YangModule;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.datamodel.YangNodeType;
import org.onosproject.yangutils.datamodel.YangRangeInterval;
import org.onosproject.yangutils.datamodel.YangRangeRestriction;
+import org.onosproject.yangutils.datamodel.YangStringRestriction;
import org.onosproject.yangutils.datamodel.YangTypeDef;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
@@ -71,11 +69,11 @@
assertThat(leafInfo.getDataType().getDataTypeName(), is("string"));
assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING));
YangStringRestriction stringRestriction = (YangStringRestriction) leafInfo
- .getDataType().getDataTypeExtendedInfo();
+ .getDataType().getDataTypeExtendedInfo();
YangRangeRestriction lengthRestriction = stringRestriction.getLengthRestriction();
ListIterator<YangRangeInterval> lengthListIterator = lengthRestriction.getAscendingRangeIntervals()
- .listIterator();
+ .listIterator();
YangRangeInterval rangeInterval = lengthListIterator.next();
@@ -220,7 +218,7 @@
@Test
public void processLengthWithInvalidIntegerPattern() throws IOException, ParserException {
thrown.expect(ParserException.class);
- thrown.expectMessage("YANG file error : a is not valid.");
+ thrown.expectMessage("YANG file error : Input value \"a\" is not a valid uint64.");
YangNode node = manager.getDataModel("src/test/resources/LengthWithInvalidIntegerPattern.yang");
}
diff --git a/src/test/java/org/onosproject/yangutils/parser/impl/listeners/RangeRestrictionListenerTest.java b/src/test/java/org/onosproject/yangutils/parser/impl/listeners/RangeRestrictionListenerTest.java
index 7935abc..76da997 100644
--- a/src/test/java/org/onosproject/yangutils/parser/impl/listeners/RangeRestrictionListenerTest.java
+++ b/src/test/java/org/onosproject/yangutils/parser/impl/listeners/RangeRestrictionListenerTest.java
@@ -18,18 +18,17 @@
import java.io.IOException;
import java.util.ListIterator;
-
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
-import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.datamodel.YangDataTypes;
import org.onosproject.yangutils.datamodel.YangLeaf;
import org.onosproject.yangutils.datamodel.YangLeafList;
-import org.onosproject.yangutils.datamodel.YangRangeRestriction;
-import org.onosproject.yangutils.datamodel.YangRangeInterval;
import org.onosproject.yangutils.datamodel.YangModule;
+import org.onosproject.yangutils.datamodel.YangNode;
import org.onosproject.yangutils.datamodel.YangNodeType;
-import org.onosproject.yangutils.datamodel.YangDataTypes;
+import org.onosproject.yangutils.datamodel.YangRangeInterval;
+import org.onosproject.yangutils.datamodel.YangRangeRestriction;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
import org.onosproject.yangutils.utils.builtindatatype.YangInt32;
@@ -70,7 +69,7 @@
.getDataType().getDataTypeExtendedInfo();
ListIterator<YangRangeInterval> rangeListIterator = rangeRestriction.getAscendingRangeIntervals()
- .listIterator();
+ .listIterator();
YangRangeInterval rangeInterval = rangeListIterator.next();
assertThat(((YangInt32) rangeInterval.getStartValue()).getValue(), is(1));
assertThat(((YangInt32) rangeInterval.getEndValue()).getValue(), is(4));
@@ -172,7 +171,7 @@
@Test
public void processRangeWithInvalidIntegerPattern() throws IOException, ParserException {
thrown.expect(ParserException.class);
- thrown.expectMessage("YANG file error : a is not valid.");
+ thrown.expectMessage("YANG file error : Input value \"a\" is not a valid int32.");
YangNode node = manager.getDataModel("src/test/resources/RangeWithInvalidIntegerPattern.yang");
}
}
diff --git a/src/test/resources/SelfFileLinkingTypedefAtMiddleLevelAfterParentHolder.yang b/src/test/resources/SelfFileLinkingTypedefAtMiddleLevelAfterParentHolder.yang
index c372bfa..812a528 100644
--- a/src/test/resources/SelfFileLinkingTypedefAtMiddleLevelAfterParentHolder.yang
+++ b/src/test/resources/SelfFileLinkingTypedefAtMiddleLevelAfterParentHolder.yang
@@ -10,7 +10,7 @@
}
}
typedef hello {
- type String;
+ type string;
}
}
}
diff --git a/src/test/resources/SelfFileLinkingTypedefAtRootIsAfterContainerHavingType.yang b/src/test/resources/SelfFileLinkingTypedefAtRootIsAfterContainerHavingType.yang
index 052cb7e..10ccab6 100644
--- a/src/test/resources/SelfFileLinkingTypedefAtRootIsAfterContainerHavingType.yang
+++ b/src/test/resources/SelfFileLinkingTypedefAtRootIsAfterContainerHavingType.yang
@@ -11,6 +11,6 @@
}
}
typedef hello {
- type String;
+ type string;
}
}
diff --git a/src/test/resources/SelfFileLinkingTypedefAtRootTypeTwoLevelInHierarchy.yang b/src/test/resources/SelfFileLinkingTypedefAtRootTypeTwoLevelInHierarchy.yang
index 2b4a1e8..eddb649 100644
--- a/src/test/resources/SelfFileLinkingTypedefAtRootTypeTwoLevelInHierarchy.yang
+++ b/src/test/resources/SelfFileLinkingTypedefAtRootTypeTwoLevelInHierarchy.yang
@@ -3,7 +3,7 @@
namespace http://huawei.com;
prefix Ant;
typedef hello {
- type String;
+ type string;
}
container ospf {
list valid {
diff --git a/src/test/resources/SelfFileLinkingWithGroupingWithSelfAndExternalPrefixMix.yang b/src/test/resources/SelfFileLinkingWithGroupingWithSelfAndExternalPrefixMix.yang
index 84236a2..b6e3b45 100644
--- a/src/test/resources/SelfFileLinkingWithGroupingWithSelfAndExternalPrefixMix.yang
+++ b/src/test/resources/SelfFileLinkingWithGroupingWithSelfAndExternalPrefixMix.yang
@@ -7,14 +7,14 @@
}
grouping Percentage {
leaf hello{
- type String;
+ type string;
}
}
container ospf {
list valid {
key "invalid";
- leaf invalid{
- type String;
+ leaf invalid{
+ type string;
}
uses Ant:FirstClass;
grouping FirstClass {
diff --git a/src/test/resources/SelfFileLinkingWithGroupingWithSelfModulePrefix.yang b/src/test/resources/SelfFileLinkingWithGroupingWithSelfModulePrefix.yang
index 23f197b..956ba50 100644
--- a/src/test/resources/SelfFileLinkingWithGroupingWithSelfModulePrefix.yang
+++ b/src/test/resources/SelfFileLinkingWithGroupingWithSelfModulePrefix.yang
@@ -3,15 +3,15 @@
namespace http://huawei.com;
prefix Ant;
grouping Percentage {
- leaf hello{
- type String;
+ leaf hello{
+ type string;
}
}
container ospf {
list valid {
key "invalid";
- leaf invalid{
- type String;
+ leaf invalid{
+ type string;
}
uses Ant:FirstClass;
grouping FirstClass {
diff --git a/src/test/resources/SelfResolutionWhenTypeAndTypedefAtRootLevel.yang b/src/test/resources/SelfResolutionWhenTypeAndTypedefAtRootLevel.yang
index b6b08a7..da6795b 100644
--- a/src/test/resources/SelfResolutionWhenTypeAndTypedefAtRootLevel.yang
+++ b/src/test/resources/SelfResolutionWhenTypeAndTypedefAtRootLevel.yang
@@ -6,6 +6,6 @@
type hello;
}
typedef hello {
- type String;
+ type string;
}
}
diff --git a/src/test/resources/SelfResolutionWhenUsesAndGroupingAtRootLevel.yang b/src/test/resources/SelfResolutionWhenUsesAndGroupingAtRootLevel.yang
index 52641d8..f6e9197 100644
--- a/src/test/resources/SelfResolutionWhenUsesAndGroupingAtRootLevel.yang
+++ b/src/test/resources/SelfResolutionWhenUsesAndGroupingAtRootLevel.yang
@@ -4,8 +4,8 @@
prefix Ant;
uses hello;
grouping hello {
- leaf hello{
- type String;
+ leaf hello{
+ type string;
}
}
}
diff --git a/src/test/resources/SelfResolutionWhenUsesAndGroupingAtRootLevelGroupingWithChild.yang b/src/test/resources/SelfResolutionWhenUsesAndGroupingAtRootLevelGroupingWithChild.yang
index f4f12b0..13cc4a5 100644
--- a/src/test/resources/SelfResolutionWhenUsesAndGroupingAtRootLevelGroupingWithChild.yang
+++ b/src/test/resources/SelfResolutionWhenUsesAndGroupingAtRootLevelGroupingWithChild.yang
@@ -4,12 +4,12 @@
prefix Ant;
uses treat;
grouping treat {
- leaf treat{
- type String;
+ leaf treat{
+ type string;
}
container test{
leaf leaf2{
- type String;
+ type string;
}
}
}