Committed by
Gerrit Code Review
UT for checking default values of list sub-statements
Change-Id: I79312afcae98aa8b26f6f33bc42c5dcb86073f4a
Showing
6 changed files
with
105 additions
and
0 deletions
| ... | @@ -150,4 +150,29 @@ public class MaxElementsListenerTest { | ... | @@ -150,4 +150,29 @@ public class MaxElementsListenerTest { |
| 150 | assertThat(leafListInfo.getLeafName(), is("invalid-interval")); | 150 | assertThat(leafListInfo.getLeafName(), is("invalid-interval")); |
| 151 | assertThat(leafListInfo.getMaxElelements(), is(2147483647)); | 151 | assertThat(leafListInfo.getMaxElelements(), is(2147483647)); |
| 152 | } | 152 | } |
| 153 | + | ||
| 154 | + /** | ||
| 155 | + * Checks default value of max-elements statement. | ||
| 156 | + */ | ||
| 157 | + @Test | ||
| 158 | + public void processMaxElementsDefaultValue() throws IOException, ParserException { | ||
| 159 | + | ||
| 160 | + YangNode node = manager.getDataModel("src/test/resources/MaxElementsDefaultValue.yang"); | ||
| 161 | + | ||
| 162 | + // Check whether the data model tree returned is of type module. | ||
| 163 | + assertThat((node instanceof YangModule), is(true)); | ||
| 164 | + | ||
| 165 | + // Check whether the node type is set properly to module. | ||
| 166 | + assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE)); | ||
| 167 | + | ||
| 168 | + // Check whether the module name is set correctly. | ||
| 169 | + YangModule yangNode = (YangModule) node; | ||
| 170 | + assertThat(yangNode.getName(), is("Test")); | ||
| 171 | + | ||
| 172 | + ListIterator<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator(); | ||
| 173 | + YangLeafList leafListInfo = leafListIterator.next(); | ||
| 174 | + | ||
| 175 | + assertThat(leafListInfo.getLeafName(), is("invalid-interval")); | ||
| 176 | + assertThat(leafListInfo.getMaxElelements(), is(2147483647)); | ||
| 177 | + } | ||
| 153 | } | 178 | } |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| ... | @@ -137,4 +137,29 @@ public class MinElementsListenerTest { | ... | @@ -137,4 +137,29 @@ public class MinElementsListenerTest { |
| 137 | "Internal parser error detected: Invalid cardinality in" + " min-elements before processing."); | 137 | "Internal parser error detected: Invalid cardinality in" + " min-elements before processing."); |
| 138 | YangNode node = manager.getDataModel("src/test/resources/MinElementsInvalidCardinality.yang"); | 138 | YangNode node = manager.getDataModel("src/test/resources/MinElementsInvalidCardinality.yang"); |
| 139 | } | 139 | } |
| 140 | + | ||
| 141 | + /** | ||
| 142 | + * Checks min-element's default value. | ||
| 143 | + */ | ||
| 144 | + @Test | ||
| 145 | + public void processMinElementsDefaultValue() throws IOException, ParserException { | ||
| 146 | + | ||
| 147 | + YangNode node = manager.getDataModel("src/test/resources/MinElementsDefaultValue.yang"); | ||
| 148 | + | ||
| 149 | + // Check whether the data model tree returned is of type module. | ||
| 150 | + assertThat((node instanceof YangModule), is(true)); | ||
| 151 | + | ||
| 152 | + // Check whether the node type is set properly to module. | ||
| 153 | + assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE)); | ||
| 154 | + | ||
| 155 | + // Check whether the module name is set correctly. | ||
| 156 | + YangModule yangNode = (YangModule) node; | ||
| 157 | + assertThat(yangNode.getName(), is("Test")); | ||
| 158 | + | ||
| 159 | + ListIterator<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator(); | ||
| 160 | + YangLeafList leafListInfo = leafListIterator.next(); | ||
| 161 | + | ||
| 162 | + assertThat(leafListInfo.getLeafName(), is("invalid-interval")); | ||
| 163 | + assertThat(leafListInfo.getMinElements(), is(0)); | ||
| 164 | + } | ||
| 140 | } | 165 | } |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| ... | @@ -259,4 +259,31 @@ public class StatusListenerTest { | ... | @@ -259,4 +259,31 @@ public class StatusListenerTest { |
| 259 | assertThat(leafListInfo.isConfig(), is(true)); | 259 | assertThat(leafListInfo.isConfig(), is(true)); |
| 260 | assertThat(leafListInfo.getStatus(), is(YangStatusType.CURRENT)); | 260 | assertThat(leafListInfo.getStatus(), is(YangStatusType.CURRENT)); |
| 261 | } | 261 | } |
| 262 | + | ||
| 263 | + /** | ||
| 264 | + * Checks default value of status statement. | ||
| 265 | + */ | ||
| 266 | + @Test | ||
| 267 | + public void processStatusDefaultValue() throws IOException, ParserException { | ||
| 268 | + | ||
| 269 | + YangNode node = manager.getDataModel("src/test/resources/StatusDefaultValue.yang"); | ||
| 270 | + | ||
| 271 | + // Check whether the data model tree returned is of type module. | ||
| 272 | + assertThat((node instanceof YangModule), is(true)); | ||
| 273 | + | ||
| 274 | + // Check whether the node type is set properly to module. | ||
| 275 | + assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE)); | ||
| 276 | + | ||
| 277 | + // Check whether the module name is set correctly. | ||
| 278 | + YangModule yangNode = (YangModule) node; | ||
| 279 | + assertThat(yangNode.getName(), is("Test")); | ||
| 280 | + | ||
| 281 | + ListIterator<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator(); | ||
| 282 | + YangLeafList leafListInfo = leafListIterator.next(); | ||
| 283 | + | ||
| 284 | + // Check whether status is set correctly. | ||
| 285 | + assertThat(leafListInfo.getLeafName(), is("invalid-interval")); | ||
| 286 | + assertThat(leafListInfo.isConfig(), is(true)); | ||
| 287 | + assertThat(leafListInfo.getStatus(), is(YangStatusType.CURRENT)); | ||
| 288 | + } | ||
| 262 | } | 289 | } |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
-
Please register or login to post a comment