Vidyashree Rama
Committed by Gerrit Code Review

UT for checking default values of list sub-statements

Change-Id: I79312afcae98aa8b26f6f33bc42c5dcb86073f4a
......@@ -150,4 +150,29 @@ public class MaxElementsListenerTest {
assertThat(leafListInfo.getLeafName(), is("invalid-interval"));
assertThat(leafListInfo.getMaxElelements(), is(2147483647));
}
/**
* Checks default value of max-elements statement.
*/
@Test
public void processMaxElementsDefaultValue() throws IOException, ParserException {
YangNode node = manager.getDataModel("src/test/resources/MaxElementsDefaultValue.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<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator();
YangLeafList leafListInfo = leafListIterator.next();
assertThat(leafListInfo.getLeafName(), is("invalid-interval"));
assertThat(leafListInfo.getMaxElelements(), is(2147483647));
}
}
\ No newline at end of file
......
......@@ -137,4 +137,29 @@ public class MinElementsListenerTest {
"Internal parser error detected: Invalid cardinality in" + " min-elements before processing.");
YangNode node = manager.getDataModel("src/test/resources/MinElementsInvalidCardinality.yang");
}
/**
* Checks min-element's default value.
*/
@Test
public void processMinElementsDefaultValue() throws IOException, ParserException {
YangNode node = manager.getDataModel("src/test/resources/MinElementsDefaultValue.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<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator();
YangLeafList leafListInfo = leafListIterator.next();
assertThat(leafListInfo.getLeafName(), is("invalid-interval"));
assertThat(leafListInfo.getMinElements(), is(0));
}
}
\ No newline at end of file
......
......@@ -259,4 +259,31 @@ public class StatusListenerTest {
assertThat(leafListInfo.isConfig(), is(true));
assertThat(leafListInfo.getStatus(), is(YangStatusType.CURRENT));
}
/**
* Checks default value of status statement.
*/
@Test
public void processStatusDefaultValue() throws IOException, ParserException {
YangNode node = manager.getDataModel("src/test/resources/StatusDefaultValue.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<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator();
YangLeafList leafListInfo = leafListIterator.next();
// Check whether status is set correctly.
assertThat(leafListInfo.getLeafName(), is("invalid-interval"));
assertThat(leafListInfo.isConfig(), is(true));
assertThat(leafListInfo.getStatus(), is(YangStatusType.CURRENT));
}
}
\ No newline at end of file
......
module Test {
yang-version 1;
namespace http://huawei.com;
prefix Ant;
leaf-list invalid-interval {
type "uint16";
}
}
module Test {
yang-version 1;
namespace http://huawei.com;
prefix Ant;
leaf-list invalid-interval {
type "uint16";
}
}
module Test {
yang-version 1;
namespace http://huawei.com;
prefix Ant;
leaf-list invalid-interval {
type "uint16";
units "seconds";
description "Interval before a route is declared invalid";
config true;
reference "RFC 6020";
}
}