Gaurav Agrawal
Committed by Gerrit Code Review

YANG: Line number and character position addition for cardinality failure + Incr…

…ease readability of Error message and function name

Change-Id: I467a536a9d2a6cbb29873491fdb0a91f211deefd
......@@ -38,7 +38,7 @@ import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorTyp
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.UNHANDLED_PARSED_DATA;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.validateCardinality;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.validateCardinalityMaxOne;
import static org.onosproject.yangutils.utils.YangConstructType.CONFIG_DATA;
import static org.onosproject.yangutils.utils.YangConstructType.CONTAINER_DATA;
import static org.onosproject.yangutils.utils.YangConstructType.DESCRIPTION_DATA;
......@@ -174,11 +174,12 @@ public final class ContainerListener {
*/
private static void validateSubStatementsCardinality(GeneratedYangParser.ContainerStatementContext ctx) {
validateCardinality(ctx.presenceStatement(), PRESENCE_DATA, CONTAINER_DATA, ctx.identifier().getText());
validateCardinality(ctx.configStatement(), CONFIG_DATA, CONTAINER_DATA, ctx.identifier().getText());
validateCardinality(ctx.descriptionStatement(), DESCRIPTION_DATA, CONTAINER_DATA, ctx.identifier().getText());
validateCardinality(ctx.referenceStatement(), REFERENCE_DATA, CONTAINER_DATA, ctx.identifier().getText());
validateCardinality(ctx.statusStatement(), STATUS_DATA, CONTAINER_DATA, ctx.identifier().getText());
validateCardinalityMaxOne(ctx.presenceStatement(), PRESENCE_DATA, CONTAINER_DATA, ctx.identifier().getText());
validateCardinalityMaxOne(ctx.configStatement(), CONFIG_DATA, CONTAINER_DATA, ctx.identifier().getText());
validateCardinalityMaxOne(ctx.descriptionStatement(), DESCRIPTION_DATA, CONTAINER_DATA,
ctx.identifier().getText());
validateCardinalityMaxOne(ctx.referenceStatement(), REFERENCE_DATA, CONTAINER_DATA, ctx.identifier().getText());
validateCardinalityMaxOne(ctx.statusStatement(), STATUS_DATA, CONTAINER_DATA, ctx.identifier().getText());
// TODO when, grouping, typedef.
}
}
......
......@@ -32,8 +32,8 @@ import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorTyp
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_CURRENT_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.validateCardinality;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.validateCardinalityEqualsOne;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.validateCardinalityMaxOne;
import static org.onosproject.yangutils.utils.YangConstructType.CONFIG_DATA;
import static org.onosproject.yangutils.utils.YangConstructType.DESCRIPTION_DATA;
import static org.onosproject.yangutils.utils.YangConstructType.LEAF_LIST_DATA;
......@@ -150,14 +150,17 @@ public final class LeafListListener {
*/
private static void validateSubStatementsCardinality(GeneratedYangParser.LeafListStatementContext ctx) {
validateCardinalityEqualsOne(ctx.typeStatement(), TYPE_DATA, LEAF_LIST_DATA, ctx.identifier().getText());
validateCardinality(ctx.unitsStatement(), UNITS_DATA, LEAF_LIST_DATA, ctx.identifier().getText());
validateCardinality(ctx.configStatement(), CONFIG_DATA, LEAF_LIST_DATA, ctx.identifier().getText());
validateCardinality(ctx.maxElementsStatement(), MAX_ELEMENT_DATA, LEAF_LIST_DATA, ctx.identifier().getText());
validateCardinality(ctx.minElementsStatement(), MIN_ELEMENT_DATA, LEAF_LIST_DATA, ctx.identifier().getText());
validateCardinality(ctx.descriptionStatement(), DESCRIPTION_DATA, LEAF_LIST_DATA, ctx.identifier().getText());
validateCardinality(ctx.referenceStatement(), REFERENCE_DATA, LEAF_LIST_DATA, ctx.identifier().getText());
validateCardinality(ctx.statusStatement(), STATUS_DATA, LEAF_LIST_DATA, ctx.identifier().getText());
validateCardinalityEqualsOne(ctx.typeStatement(), TYPE_DATA, LEAF_LIST_DATA, ctx.identifier().getText(), ctx);
validateCardinalityMaxOne(ctx.unitsStatement(), UNITS_DATA, LEAF_LIST_DATA, ctx.identifier().getText());
validateCardinalityMaxOne(ctx.configStatement(), CONFIG_DATA, LEAF_LIST_DATA, ctx.identifier().getText());
validateCardinalityMaxOne(ctx.maxElementsStatement(), MAX_ELEMENT_DATA, LEAF_LIST_DATA,
ctx.identifier().getText());
validateCardinalityMaxOne(ctx.minElementsStatement(), MIN_ELEMENT_DATA, LEAF_LIST_DATA,
ctx.identifier().getText());
validateCardinalityMaxOne(ctx.descriptionStatement(), DESCRIPTION_DATA, LEAF_LIST_DATA,
ctx.identifier().getText());
validateCardinalityMaxOne(ctx.referenceStatement(), REFERENCE_DATA, LEAF_LIST_DATA, ctx.identifier().getText());
validateCardinalityMaxOne(ctx.statusStatement(), STATUS_DATA, LEAF_LIST_DATA, ctx.identifier().getText());
//TODO ordered by
}
}
......
......@@ -36,8 +36,8 @@ import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorTyp
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_CURRENT_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.validateCardinality;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.validateCardinalityEqualsOne;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.validateCardinalityMaxOne;
import static org.onosproject.yangutils.utils.YangConstructType.CONFIG_DATA;
import static org.onosproject.yangutils.utils.YangConstructType.DESCRIPTION_DATA;
import static org.onosproject.yangutils.utils.YangConstructType.LEAF_DATA;
......@@ -153,13 +153,13 @@ public final class LeafListener {
*/
private static void validateSubStatementsCardinality(GeneratedYangParser.LeafStatementContext ctx) {
validateCardinalityEqualsOne(ctx.typeStatement(), TYPE_DATA, LEAF_DATA, ctx.identifier().getText());
validateCardinality(ctx.unitsStatement(), UNITS_DATA, LEAF_DATA, ctx.identifier().getText());
validateCardinality(ctx.configStatement(), CONFIG_DATA, LEAF_DATA, ctx.identifier().getText());
validateCardinality(ctx.mandatoryStatement(), MANDATORY_DATA, LEAF_DATA, ctx.identifier().getText());
validateCardinality(ctx.descriptionStatement(), DESCRIPTION_DATA, LEAF_DATA, ctx.identifier().getText());
validateCardinality(ctx.referenceStatement(), REFERENCE_DATA, LEAF_DATA, ctx.identifier().getText());
validateCardinality(ctx.statusStatement(), STATUS_DATA, LEAF_DATA, ctx.identifier().getText());
validateCardinalityEqualsOne(ctx.typeStatement(), TYPE_DATA, LEAF_DATA, ctx.identifier().getText(), ctx);
validateCardinalityMaxOne(ctx.unitsStatement(), UNITS_DATA, LEAF_DATA, ctx.identifier().getText());
validateCardinalityMaxOne(ctx.configStatement(), CONFIG_DATA, LEAF_DATA, ctx.identifier().getText());
validateCardinalityMaxOne(ctx.mandatoryStatement(), MANDATORY_DATA, LEAF_DATA, ctx.identifier().getText());
validateCardinalityMaxOne(ctx.descriptionStatement(), DESCRIPTION_DATA, LEAF_DATA, ctx.identifier().getText());
validateCardinalityMaxOne(ctx.referenceStatement(), REFERENCE_DATA, LEAF_DATA, ctx.identifier().getText());
validateCardinalityMaxOne(ctx.statusStatement(), STATUS_DATA, LEAF_DATA, ctx.identifier().getText());
//TODO when.
}
}
......
......@@ -38,8 +38,8 @@ import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorTyp
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.UNHANDLED_PARSED_DATA;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.validateCardinality;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.validateCardinalityNonNull;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.validateCardinalityMaxOne;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.validateCardinalityNonZero;
import static org.onosproject.yangutils.utils.YangConstructType.CONFIG_DATA;
import static org.onosproject.yangutils.utils.YangConstructType.DATA_DEF_DATA;
import static org.onosproject.yangutils.utils.YangConstructType.DESCRIPTION_DATA;
......@@ -180,14 +180,14 @@ public final class ListListener {
*/
private static void validateSubStatementsCardinality(GeneratedYangParser.ListStatementContext ctx) {
validateCardinality(ctx.keyStatement(), KEY_DATA, LIST_DATA, ctx.identifier().getText());
validateCardinality(ctx.configStatement(), CONFIG_DATA, LIST_DATA, ctx.identifier().getText());
validateCardinality(ctx.maxElementsStatement(), MAX_ELEMENT_DATA, LIST_DATA, ctx.identifier().getText());
validateCardinality(ctx.minElementsStatement(), MIN_ELEMENT_DATA, LIST_DATA, ctx.identifier().getText());
validateCardinality(ctx.descriptionStatement(), DESCRIPTION_DATA, LIST_DATA, ctx.identifier().getText());
validateCardinality(ctx.referenceStatement(), REFERENCE_DATA, LIST_DATA, ctx.identifier().getText());
validateCardinality(ctx.statusStatement(), STATUS_DATA, LIST_DATA, ctx.identifier().getText());
validateCardinalityNonNull(ctx.dataDefStatement(), DATA_DEF_DATA, LIST_DATA, ctx.identifier().getText());
validateCardinalityMaxOne(ctx.keyStatement(), KEY_DATA, LIST_DATA, ctx.identifier().getText());
validateCardinalityMaxOne(ctx.configStatement(), CONFIG_DATA, LIST_DATA, ctx.identifier().getText());
validateCardinalityMaxOne(ctx.maxElementsStatement(), MAX_ELEMENT_DATA, LIST_DATA, ctx.identifier().getText());
validateCardinalityMaxOne(ctx.minElementsStatement(), MIN_ELEMENT_DATA, LIST_DATA, ctx.identifier().getText());
validateCardinalityMaxOne(ctx.descriptionStatement(), DESCRIPTION_DATA, LIST_DATA, ctx.identifier().getText());
validateCardinalityMaxOne(ctx.referenceStatement(), REFERENCE_DATA, LIST_DATA, ctx.identifier().getText());
validateCardinalityMaxOne(ctx.statusStatement(), STATUS_DATA, LIST_DATA, ctx.identifier().getText());
validateCardinalityNonZero(ctx.dataDefStatement(), DATA_DEF_DATA, LIST_DATA, ctx.identifier().getText(), ctx);
//TODO when, typedef, grouping, unique
}
}
......
......@@ -16,37 +16,6 @@
package org.onosproject.yangutils.parser.impl.listeners;
/*
* Reference: RFC6020 and YANG ANTLR Grammar
*
* body-stmts = *((extension-stmt /
* feature-stmt /
* identity-stmt /
* typedef-stmt /
* grouping-stmt /
* data-def-stmt /
* augment-stmt /
* rpc-stmt /
* notification-stmt /
* deviation-stmt) stmtsep)
*
* typedef-stmt = typedef-keyword sep identifier-arg-str optsep
* "{" stmtsep
* ;; these stmts can appear in any order
* type-stmt stmtsep
* [units-stmt stmtsep]
* [default-stmt stmtsep]
* [status-stmt stmtsep]
* [description-stmt stmtsep]
* [reference-stmt stmtsep]
* "}"
*
* ANTLR grammar rule
* typedefStatement : TYPEDEF_KEYWORD identifier LEFT_CURLY_BRACE
* (typeStatement | unitsStatement | defaultStatement | statusStatement
* | descriptionStatement | referenceStatement)* RIGHT_CURLY_BRACE;
*/
import org.onosproject.yangutils.datamodel.YangContainer;
import org.onosproject.yangutils.datamodel.YangDataTypes;
import org.onosproject.yangutils.datamodel.YangDerivedType;
......@@ -73,8 +42,8 @@ import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorTyp
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.UNHANDLED_PARSED_DATA;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.validateCardinality;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.validateCardinalityEqualsOne;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.validateCardinalityMaxOne;
import static org.onosproject.yangutils.utils.YangConstructType.DEFAULT_DATA;
import static org.onosproject.yangutils.utils.YangConstructType.DESCRIPTION_DATA;
import static org.onosproject.yangutils.utils.YangConstructType.REFERENCE_DATA;
......@@ -83,6 +52,37 @@ import static org.onosproject.yangutils.utils.YangConstructType.TYPEDEF_DATA;
import static org.onosproject.yangutils.utils.YangConstructType.TYPE_DATA;
import static org.onosproject.yangutils.utils.YangConstructType.UNITS_DATA;
/*
* Reference: RFC6020 and YANG ANTLR Grammar
*
* body-stmts = *((extension-stmt /
* feature-stmt /
* identity-stmt /
* typedef-stmt /
* grouping-stmt /
* data-def-stmt /
* augment-stmt /
* rpc-stmt /
* notification-stmt /
* deviation-stmt) stmtsep)
*
* typedef-stmt = typedef-keyword sep identifier-arg-str optsep
* "{" stmtsep
* ;; these stmts can appear in any order
* type-stmt stmtsep
* [units-stmt stmtsep]
* [default-stmt stmtsep]
* [status-stmt stmtsep]
* [description-stmt stmtsep]
* [reference-stmt stmtsep]
* "}"
*
* ANTLR grammar rule
* typedefStatement : TYPEDEF_KEYWORD identifier LEFT_CURLY_BRACE
* (typeStatement | unitsStatement | defaultStatement | statusStatement
* | descriptionStatement | referenceStatement)* RIGHT_CURLY_BRACE;
*/
/**
* Implements listener based call back function corresponding to the "typedef"
* rule defined in ANTLR grammar file for corresponding ABNF rule in RFC 6020.
......@@ -181,11 +181,12 @@ public final class TypeDefListener {
*/
private static void validateSubStatementsCardinality(GeneratedYangParser.TypedefStatementContext ctx) {
validateCardinality(ctx.unitsStatement(), UNITS_DATA, TYPEDEF_DATA, ctx.identifier().getText());
validateCardinality(ctx.defaultStatement(), DEFAULT_DATA, TYPEDEF_DATA, ctx.identifier().getText());
validateCardinalityEqualsOne(ctx.typeStatement(), TYPE_DATA, TYPEDEF_DATA, ctx.identifier().getText());
validateCardinality(ctx.descriptionStatement(), DESCRIPTION_DATA, TYPEDEF_DATA, ctx.identifier().getText());
validateCardinality(ctx.referenceStatement(), REFERENCE_DATA, TYPEDEF_DATA, ctx.identifier().getText());
validateCardinality(ctx.statusStatement(), STATUS_DATA, TYPEDEF_DATA, ctx.identifier().getText());
validateCardinalityMaxOne(ctx.unitsStatement(), UNITS_DATA, TYPEDEF_DATA, ctx.identifier().getText());
validateCardinalityMaxOne(ctx.defaultStatement(), DEFAULT_DATA, TYPEDEF_DATA, ctx.identifier().getText());
validateCardinalityEqualsOne(ctx.typeStatement(), TYPE_DATA, TYPEDEF_DATA, ctx.identifier().getText(), ctx);
validateCardinalityMaxOne(ctx.descriptionStatement(), DESCRIPTION_DATA, TYPEDEF_DATA,
ctx.identifier().getText());
validateCardinalityMaxOne(ctx.referenceStatement(), REFERENCE_DATA, TYPEDEF_DATA, ctx.identifier().getText());
validateCardinalityMaxOne(ctx.statusStatement(), STATUS_DATA, TYPEDEF_DATA, ctx.identifier().getText());
}
}
......
......@@ -16,19 +16,20 @@
package org.onosproject.yangutils.parser.impl.parserutils;
import java.util.List;
import org.antlr.v4.runtime.ParserRuleContext;
import org.onosproject.yangutils.datamodel.YangContainer;
import org.onosproject.yangutils.datamodel.YangList;
import org.onosproject.yangutils.datamodel.YangNode;
import org.onosproject.yangutils.parser.Parsable;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
import org.onosproject.yangutils.utils.YangConstructType;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
import org.onosproject.yangutils.utils.YangConstructType;
import static org.onosproject.yangutils.utils.YangConstructType.getYangConstructType;
import java.util.Iterator;
import java.util.List;
/**
* It's a utility to carry out listener validation.
*/
......@@ -123,14 +124,18 @@ public final class ListenerValidation {
* @param parentName parent name
* @throws ParserException exception if cardinality check fails
*/
public static void validateCardinality(List<?> childContext, YangConstructType yangChildConstruct,
YangConstructType yangParentConstruct, String parentName)
throws ParserException {
public static void validateCardinalityMaxOne(List<?> childContext, YangConstructType yangChildConstruct,
YangConstructType yangParentConstruct, String parentName)
throws ParserException {
if (!childContext.isEmpty() && childContext.size() != 1) {
ParserException parserException = new ParserException("YANG file error: Invalid cardinality of "
+ getYangConstructType(yangChildConstruct) + " in " + getYangConstructType(yangParentConstruct)
+ " \"" + parentName + "\".");
ParserException parserException = new ParserException("YANG file error: \""
+ getYangConstructType(yangChildConstruct) + "\" is defined more than once in \""
+ getYangConstructType(yangParentConstruct) + " " + parentName + "\".");
Iterator<?> context = childContext.iterator();
parserException.setLine(((ParserRuleContext) context.next()).getStart().getLine());
parserException.setCharPosition(((ParserRuleContext) context.next()).getStart().getCharPositionInLine());
throw parserException;
}
}
......@@ -140,18 +145,32 @@ public final class ListenerValidation {
*
* @param childContext child's context
* @param yangChildConstruct child construct for whom cardinality is to be
* validated
* validated
* @param yangParentConstruct parent construct
* @param parentName parent name
* @param parentContext parents's context
* @throws ParserException exception if cardinality check fails
*/
public static void validateCardinalityEqualsOne(List<?> childContext, YangConstructType yangChildConstruct,
YangConstructType yangParentConstruct, String parentName) throws ParserException {
YangConstructType yangParentConstruct, String parentName,
ParserRuleContext parentContext)
throws ParserException {
if (childContext.isEmpty() || childContext.size() != 1) {
ParserException parserException = new ParserException("YANG file error: Invalid cardinality of "
+ getYangConstructType(yangChildConstruct) + " in " + getYangConstructType(yangParentConstruct)
+ " \"" + parentName + "\".");
if (childContext.isEmpty()) {
ParserException parserException = new ParserException("YANG file error: Missing \""
+ getYangConstructType(yangChildConstruct) + "\" in \"" + getYangConstructType(yangParentConstruct)
+ " " + parentName + "\".");
parserException.setLine(parentContext.getStart().getLine());
parserException.setCharPosition(parentContext.getStart().getCharPositionInLine());
throw parserException;
} else if (!childContext.isEmpty() && childContext.size() != 1) {
Iterator<?> childcontext = childContext.iterator();
ParserException parserException = new ParserException("YANG file error: \""
+ getYangConstructType(yangChildConstruct) + "\" is present more than once in \""
+ getYangConstructType(yangParentConstruct) + " " + parentName + "\".");
parserException.setLine(((ParserRuleContext) childcontext.next()).getStart().getLine());
parserException.setCharPosition(((ParserRuleContext) childcontext.next()).getStart()
.getCharPositionInLine());
throw parserException;
}
}
......@@ -161,18 +180,54 @@ public final class ListenerValidation {
*
* @param childContext child's context
* @param yangChildConstruct child construct for whom cardinality is to be
* validated
* validated
* @param yangParentConstruct parent construct
* @param parentName parent name
* @param parentContext parents's context
* @throws ParserException exception if cardinality check fails
*/
public static void validateCardinalityNonNull(List<?> childContext, YangConstructType yangChildConstruct,
YangConstructType yangParentConstruct, String parentName) throws ParserException {
public static void validateCardinalityNonZero(List<?> childContext, YangConstructType yangChildConstruct,
YangConstructType yangParentConstruct, String parentName,
ParserRuleContext parentContext)
throws ParserException {
if (childContext.isEmpty()) {
ParserException parserException = new ParserException("YANG file error: Invalid cardinality of "
+ getYangConstructType(yangChildConstruct) + " in " + getYangConstructType(yangParentConstruct)
+ " \"" + parentName + "\".");
ParserException parserException = new ParserException("YANG file error: Missing \""
+ getYangConstructType(yangChildConstruct) + "\" in \"" + getYangConstructType(yangParentConstruct)
+ " " + parentName + "\".");
parserException.setLine(parentContext.getStart().getLine());
parserException.setCharPosition(parentContext.getStart().getCharPositionInLine());
throw parserException;
}
}
/**
* Checks if a either of one construct occurrence.
*
* @param child1Context first optional child's context
* @param yangChild1Construct first child construct for whom cardinality is
* to be validated
* @param child2Context second optional child's context
* @param yangChild2Construct second child construct for whom cardinality is
* to be validated
* @param yangParentConstruct parent construct
* @param parentName parent name
* @throws ParserException exception if cardinality check fails
*/
public static void validateMutuallyExclusiveChilds(List<?> child1Context, YangConstructType yangChild1Construct,
List<?> child2Context, YangConstructType yangChild2Construct,
YangConstructType yangParentConstruct, String parentName)
throws ParserException {
if (!child1Context.isEmpty() && !child2Context.isEmpty()) {
ParserException parserException = new ParserException("YANG file error: \""
+ getYangConstructType(yangChild1Construct) + "\" & \"" + getYangConstructType(yangChild2Construct)
+ "\" should be mutually exclusive in \"" + getYangConstructType(yangParentConstruct) + " "
+ parentName + "\".");
parserException.setLine(((ParserRuleContext) child2Context).getStart().getLine());
parserException.setCharPosition(((ParserRuleContext) child2Context).getStart().getCharPositionInLine());
throw parserException;
}
}
......
......@@ -206,7 +206,7 @@ public class ContainerListenerTest {
@Test
public void processContainerSubStatementCardinality() throws IOException, ParserException {
thrown.expect(ParserException.class);
thrown.expectMessage("YANG file error: Invalid cardinality of reference in container \"valid\".");
thrown.expectMessage("YANG file error: \"reference\" is defined more than once in \"container valid\".");
YangNode node = manager.getDataModel("src/test/resources/ContainerSubStatementCardinality.yang");
}
......
......@@ -120,7 +120,8 @@ public class LeafListListenerTest {
@Test
public void processLeafListConfigInvalidCardinality() throws IOException, ParserException {
thrown.expect(ParserException.class);
thrown.expectMessage("YANG file error: Invalid cardinality of config in leaf-list \"invalid-interval\".");
thrown.expectMessage("YANG file error: \"config\" is defined more than once in \"leaf-list " +
"invalid-interval\".");
YangNode node = manager.getDataModel("src/test/resources/LeafListConfigInvalidCardinality.yang");
}
......@@ -131,7 +132,7 @@ public class LeafListListenerTest {
@Test
public void processLeafListUnitsInvalidCardinality() throws IOException, ParserException {
thrown.expect(ParserException.class);
thrown.expectMessage("YANG file error: Invalid cardinality of units in leaf-list \"invalid-interval\".");
thrown.expectMessage("YANG file error: \"units\" is defined more than once in \"leaf-list invalid-interval\"");
YangNode node = manager.getDataModel("src/test/resources/LeafListUnitsInvalidCardinality.yang");
}
......
......@@ -120,7 +120,7 @@ public class LeafListenerTest {
@Test
public void processLeafConfigInvalidCardinality() throws IOException, ParserException {
thrown.expect(ParserException.class);
thrown.expectMessage("YANG file error: Invalid cardinality of config in leaf \"invalid-interval\".");
thrown.expectMessage("YANG file error: \"config\" is defined more than once in \"leaf invalid-interval\".");
YangNode node = manager.getDataModel("src/test/resources/LeafConfigInvalidCardinality.yang");
}
......@@ -131,7 +131,7 @@ public class LeafListenerTest {
@Test
public void processLeafMandatoryInvalidCardinality() throws IOException, ParserException {
thrown.expect(ParserException.class);
thrown.expectMessage("YANG file error: Invalid cardinality of mandatory in leaf \"invalid-interval\".");
thrown.expectMessage("YANG file error: \"mandatory\" is defined more than once in \"leaf invalid-interval\".");
YangNode node = manager.getDataModel("src/test/resources/LeafMandatoryInvalidCardinality.yang");
}
......
......@@ -175,7 +175,7 @@ public class ListListenerTest {
@Test
public void processListSubStatementsCardinality() throws IOException, ParserException {
thrown.expect(ParserException.class);
thrown.expectMessage("YANG file error: Invalid cardinality of reference in list \"valid\".");
thrown.expectMessage("YANG file error: \"reference\" is defined more than once in \"list valid\".");
YangNode node = manager.getDataModel("src/test/resources/ListSubStatementsCardinality.yang");
}
......@@ -185,7 +185,7 @@ public class ListListenerTest {
@Test
public void processListStatementWithoutChild() throws IOException, ParserException {
thrown.expect(ParserException.class);
thrown.expectMessage("YANG file error: Invalid cardinality of data-def-substatements in list \"valid\".");
thrown.expectMessage("YANG file error: Missing \"data-def-substatements\" in \"list valid\".");
YangNode node = manager.getDataModel("src/test/resources/ListStatementWithoutChild.yang");
}
......
......@@ -122,7 +122,8 @@ public class MaxElementsListenerTest {
@Test
public void processMaxElementsCardinality() throws IOException, ParserException {
thrown.expect(ParserException.class);
thrown.expectMessage("YANG file error: Invalid cardinality of max-elements in leaf-list \"invalid-interval\".");
thrown.expectMessage("YANG file error: \"max-elements\" is defined more than once in \"leaf-list " +
"invalid-interval\".");
YangNode node = manager.getDataModel("src/test/resources/MaxElementsCardinality.yang");
}
......
......@@ -133,7 +133,8 @@ public class MinElementsListenerTest {
@Test
public void processMinElementsInvalidCardinality() throws IOException, ParserException {
thrown.expect(ParserException.class);
thrown.expectMessage("YANG file error: Invalid cardinality of min-elements in leaf-list \"invalid-interval\".");
thrown.expectMessage("YANG file error: \"min-elements\" is defined more than once in \"leaf-list " +
"invalid-interval\".");
YangNode node = manager.getDataModel("src/test/resources/MinElementsInvalidCardinality.yang");
}
......
......@@ -157,7 +157,7 @@ public class UnitsListenerTest {
@Test
public void processUnitsStatementCardinality() throws IOException, ParserException {
thrown.expect(ParserException.class);
thrown.expectMessage("YANG file error: Invalid cardinality of units in leaf \"invalid-interval\".");
thrown.expectMessage("YANG file error: \"units\" is defined more than once in \"leaf invalid-interval\".");
YangNode node = manager.getDataModel("src/test/resources/UnitsStatementCardinality.yang");
}
......