[ONOS-5516] Intra file augment linking, with and without prefix.
Change-Id: I8e303247f8b000ca631a6862cf6b41dbeb51b731
diff --git a/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangAugment.java b/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangAugment.java
index 28d0d3a..1459149 100644
--- a/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangAugment.java
+++ b/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangAugment.java
@@ -15,17 +15,16 @@
*/
package org.onosproject.yangutils.datamodel;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
import org.onosproject.yangutils.datamodel.utils.Parsable;
import org.onosproject.yangutils.datamodel.utils.ResolvableStatus;
import org.onosproject.yangutils.datamodel.utils.YangConstructType;
-import static org.onosproject.yangutils.datamodel.utils.DataModelUtils
- .detectCollidingChildUtil;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+
+import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCollidingChildUtil;
/*-
* Reference RFC 6020.
@@ -146,6 +145,13 @@
private List<YangIfFeature> ifFeatureList;
/**
+ * Name of augment when prefix is removed if it is in the same file. For
+ * linking purpose the name with same prefix of the file is removed and
+ * maintained.
+ */
+ private String prefixRemovedName;
+
+ /**
* Create a YANG augment node.
*/
public YangAugment() {
@@ -223,6 +229,26 @@
}
/**
+ * Returns the name of augment after removing the prefix, in each atomic
+ * content, which is equal to the root prefix.
+ *
+ * @return prefix removed augment name
+ */
+ public String getPrefixRemovedName() {
+ return prefixRemovedName;
+ }
+
+ /**
+ * Sets the name of augment after removing the prefix, in each atomic
+ * content, which is equal to the root prefix.
+ *
+ * @param prefixRemovedName augment name
+ */
+ public void setPrefixRemovedName(String prefixRemovedName) {
+ this.prefixRemovedName = prefixRemovedName;
+ }
+
+ /**
* Returns the when.
*
* @return the when
diff --git a/generator/src/main/java/org/onosproject/yangutils/linker/impl/YangXpathLinker.java b/generator/src/main/java/org/onosproject/yangutils/linker/impl/YangXpathLinker.java
index f049dbd..4418012 100644
--- a/generator/src/main/java/org/onosproject/yangutils/linker/impl/YangXpathLinker.java
+++ b/generator/src/main/java/org/onosproject/yangutils/linker/impl/YangXpathLinker.java
@@ -639,18 +639,20 @@
}
/**
- * Searches augment node in root node.
+ * Searches augment node in root node by name of the augment. For intra
+ * file augment, target augment name without prefix is taken and checked.
*
- * @param node root node
- * @param tempNodeId node identifier
+ * @param root root node
+ * @param augName current augment name
* @return target augment node
*/
-
- private YangNode searchAugmentNode(YangNode node, String tempNodeId) {
+ private YangNode searchAugmentNode(YangNode root, String augName) {
+ YangNode node = root;
node = node.getChild();
while (node != null) {
if (node instanceof YangAugment) {
- if (node.getName().equals(tempNodeId)) {
+ String name = ((YangAugment) node).getPrefixRemovedName();
+ if (node.getName().equals(augName) || name.equals(augName)) {
return node;
}
}
diff --git a/parser/src/main/java/org/onosproject/yangutils/parser/impl/listeners/AugmentListener.java b/parser/src/main/java/org/onosproject/yangutils/parser/impl/listeners/AugmentListener.java
index 124f275..dedbb82 100644
--- a/parser/src/main/java/org/onosproject/yangutils/parser/impl/listeners/AugmentListener.java
+++ b/parser/src/main/java/org/onosproject/yangutils/parser/impl/listeners/AugmentListener.java
@@ -16,8 +16,6 @@
package org.onosproject.yangutils.parser.impl.listeners;
-import java.util.List;
-
import org.onosproject.yangutils.datamodel.YangAtomicPath;
import org.onosproject.yangutils.datamodel.YangAugment;
import org.onosproject.yangutils.datamodel.YangModule;
@@ -27,10 +25,12 @@
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
import org.onosproject.yangutils.datamodel.utils.Parsable;
import org.onosproject.yangutils.linker.impl.YangResolutionInfoImpl;
-import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
+import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser.AugmentStatementContext;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
+import java.util.List;
+
import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.addResolutionInfo;
import static org.onosproject.yangutils.datamodel.utils.GeneratedLanguage.JAVA_GENERATION;
import static org.onosproject.yangutils.datamodel.utils.YangConstructType.AUGMENT_DATA;
@@ -49,12 +49,14 @@
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.ListenerErrorType.UNHANDLED_PARSED_DATA;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerUtil.getPrefixRemovedName;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerUtil.getValidAbsoluteSchemaNodeId;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerUtil.removeQuotesAndHandleConcat;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.validateCardinalityEitherOne;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.validateCardinalityMaxOne;
import static org.onosproject.yangutils.translator.tojava.YangDataModelFactory.getYangAugmentNode;
+import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING;
/*
* Reference: RFC6020 and YANG ANTLR Grammar
@@ -73,8 +75,9 @@
* "}"
*
* ANTLR grammar rule
- * augmentStatement : AUGMENT_KEYWORD augment LEFT_CURLY_BRACE (whenStatement | ifFeatureStatement | statusStatement
- * | descriptionStatement | referenceStatement | dataDefStatement | caseStatement)* RIGHT_CURLY_BRACE;
+ * augmentStatement : AUGMENT_KEYWORD augment LEFT_CURLY_BRACE (whenStatement |
+ * ifFeatureStatement | statusStatement | descriptionStatement |
+ * referenceStatement | dataDefStatement | caseStatement)* RIGHT_CURLY_BRACE;
*/
/**
@@ -83,90 +86,93 @@
*/
public final class AugmentListener {
- /**
- * Creates a new augment listener.
- */
+ // No instantiation.
private AugmentListener() {
}
/**
- * It is called when parser receives an input matching the grammar rule
- * (augment), performs validation and updates the data model tree.
+ * Performs validation and updates the data model tree when parser
+ * receives an input matching the grammar rule (augment), performs
+ * validation and updates the data model tree.
*
* @param listener listener's object
- * @param ctx context object of the grammar rule
+ * @param ctx context object
*/
public static void processAugmentEntry(TreeWalkListener listener,
- GeneratedYangParser.AugmentStatementContext ctx) {
+ AugmentStatementContext ctx) {
- // Check for stack to be non empty.
- checkStackIsNotEmpty(listener, MISSING_HOLDER, AUGMENT_DATA, ctx.augment().getText(), ENTRY);
-
- // Validate augment argument string
- List<YangAtomicPath> targetNodes = getValidAbsoluteSchemaNodeId(ctx.augment().getText(),
- AUGMENT_DATA, ctx);
-
- // Validate sub statement cardinality.
- validateSubStatementsCardinality(ctx);
-
- // Check for identifier collision
- int line = ctx.getStart().getLine();
- int charPositionInLine = ctx.getStart().getCharPositionInLine();
- detectCollidingChildUtil(listener, line, charPositionInLine, "", AUGMENT_DATA);
+ checkStackIsNotEmpty(listener, MISSING_HOLDER, AUGMENT_DATA,
+ ctx.augment().getText(), ENTRY);
Parsable curData = listener.getParsedDataStack().peek();
- if (curData instanceof YangModule || curData instanceof YangSubModule) {
- YangNode curNode = (YangNode) curData;
- YangAugment yangAugment = getYangAugmentNode(JAVA_GENERATION);
- yangAugment.setLineNumber(line);
- yangAugment.setCharPosition(charPositionInLine);
- yangAugment.setFileName(listener.getFileName());
- //validateTargetNodePath(targetNodes, curNode, ctx);
- // TODO: handle in linker.
- yangAugment.setTargetNode(targetNodes);
- yangAugment.setName(removeQuotesAndHandleConcat(ctx.augment().getText()));
-
- try {
- curNode.addChild(yangAugment);
- } catch (DataModelException e) {
- throw new ParserException(constructExtendedListenerErrorMessage(UNHANDLED_PARSED_DATA,
- AUGMENT_DATA, ctx.augment().getText(), ENTRY, e.getMessage()));
- }
- listener.getParsedDataStack().push(yangAugment);
-
- // Add resolution information to the list
- YangResolutionInfoImpl resolutionInfo = new YangResolutionInfoImpl<YangAugment>(yangAugment,
- curNode, line,
- charPositionInLine);
- addToResolutionList(resolutionInfo, ctx);
-
- } else if (curData instanceof YangUses) {
- throw new ParserException(constructListenerErrorMessage(UNHANDLED_PARSED_DATA, AUGMENT_DATA,
- ctx.augment().getText(), ENTRY));
- }
- else {
- throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, AUGMENT_DATA,
+ if (curData instanceof YangUses) {
+ throw new ParserException(constructListenerErrorMessage(
+ UNHANDLED_PARSED_DATA, AUGMENT_DATA,
ctx.augment().getText(), ENTRY));
}
+ if (!(curData instanceof YangModule) &&
+ !(curData instanceof YangSubModule)) {
+ throw new ParserException(constructListenerErrorMessage(
+ INVALID_HOLDER, AUGMENT_DATA,
+ ctx.augment().getText(), ENTRY));
+ }
+
+ // Validates augment argument string
+ List<YangAtomicPath> atomics =
+ getValidAbsoluteSchemaNodeId(ctx.augment().getText(),
+ AUGMENT_DATA, ctx);
+ valSubStatCardinality(ctx);
+
+ int line = ctx.getStart().getLine();
+ int pos = ctx.getStart().getCharPositionInLine();
+
+ detectCollidingChildUtil(listener, line, pos, EMPTY_STRING,
+ AUGMENT_DATA);
+
+ YangNode root = (YangNode) curData;
+ String name = getPrefixRemovedName(atomics, root);
+ YangAugment augment = getYangAugmentNode(JAVA_GENERATION);
+ augment.setLineNumber(line);
+ augment.setCharPosition(pos);
+ augment.setFileName(listener.getFileName());
+ augment.setTargetNode(atomics);
+ augment.setName(removeQuotesAndHandleConcat(ctx.augment().getText()));
+ augment.setPrefixRemovedName(name);
+
+ try {
+ root.addChild(augment);
+ } catch (DataModelException e) {
+ throw new ParserException(constructExtendedListenerErrorMessage(
+ UNHANDLED_PARSED_DATA, AUGMENT_DATA,
+ ctx.augment().getText(), ENTRY, e.getMessage()));
+ }
+ listener.getParsedDataStack().push(augment);
+
+ // Adds resolution info to the list
+ YangResolutionInfoImpl<YangAugment> info =
+ new YangResolutionInfoImpl<>(augment, root, line, pos);
+ addToResolution(info, ctx);
}
/**
- * It is called when parser exits from grammar rule (augment), it perform
- * validations and updates the data model tree.
+ * Performs validations and update the data model tree when parser exits
+ * from grammar rule (augment).
*
* @param listener listener's object
* @param ctx context object of the grammar rule
*/
public static void processAugmentExit(TreeWalkListener listener,
- GeneratedYangParser.AugmentStatementContext ctx) {
+ AugmentStatementContext ctx) {
//Check for stack to be non empty.
- checkStackIsNotEmpty(listener, MISSING_HOLDER, AUGMENT_DATA, ctx.augment().getText(), EXIT);
+ checkStackIsNotEmpty(listener, MISSING_HOLDER, AUGMENT_DATA,
+ ctx.augment().getText(), EXIT);
if (!(listener.getParsedDataStack().peek() instanceof YangAugment)) {
- throw new ParserException(constructListenerErrorMessage(MISSING_CURRENT_HOLDER, AUGMENT_DATA,
+ throw new ParserException(constructListenerErrorMessage(
+ MISSING_CURRENT_HOLDER, AUGMENT_DATA,
ctx.augment().getText(), EXIT));
}
listener.getParsedDataStack().pop();
@@ -175,31 +181,42 @@
/**
* Validates the cardinality of augment sub-statements as per grammar.
*
- * @param ctx context object of the grammar rule
+ * @param ctx context object
*/
- private static void validateSubStatementsCardinality(GeneratedYangParser.AugmentStatementContext ctx) {
- validateCardinalityMaxOne(ctx.statusStatement(), STATUS_DATA, AUGMENT_DATA, ctx.augment().getText());
- validateCardinalityMaxOne(ctx.descriptionStatement(), DESCRIPTION_DATA, AUGMENT_DATA, ctx.augment().getText());
- validateCardinalityMaxOne(ctx.referenceStatement(), REFERENCE_DATA, AUGMENT_DATA, ctx.augment().getText());
- validateCardinalityMaxOne(ctx.whenStatement(), WHEN_DATA, AUGMENT_DATA, ctx.augment().getText());
- validateCardinalityEitherOne(ctx.dataDefStatement(), DATA_DEF_DATA, ctx.caseStatement(),
- CASE_DATA, AUGMENT_DATA, ctx.augment().getText(), ctx);
+ private static void valSubStatCardinality(AugmentStatementContext ctx) {
+
+ validateCardinalityMaxOne(ctx.statusStatement(), STATUS_DATA,
+ AUGMENT_DATA, ctx.augment().getText());
+
+ validateCardinalityMaxOne(ctx.descriptionStatement(), DESCRIPTION_DATA,
+ AUGMENT_DATA, ctx.augment().getText());
+
+ validateCardinalityMaxOne(ctx.referenceStatement(), REFERENCE_DATA,
+ AUGMENT_DATA, ctx.augment().getText());
+
+ validateCardinalityMaxOne(ctx.whenStatement(), WHEN_DATA, AUGMENT_DATA,
+ ctx.augment().getText());
+
+ validateCardinalityEitherOne(ctx.dataDefStatement(), DATA_DEF_DATA,
+ ctx.caseStatement(), CASE_DATA,
+ AUGMENT_DATA, ctx.augment().getText(),
+ ctx);
}
/**
* Add to resolution list.
*
- * @param resolutionInfo resolution information.
- * @param ctx context object of the grammar rule
+ * @param info resolution info
+ * @param ctx context object
*/
- private static void addToResolutionList(YangResolutionInfoImpl<YangAugment> resolutionInfo,
- GeneratedYangParser.AugmentStatementContext ctx) {
-
+ private static void addToResolution(YangResolutionInfoImpl<YangAugment> info,
+ AugmentStatementContext ctx) {
try {
- addResolutionInfo(resolutionInfo);
+ addResolutionInfo(info);
} catch (DataModelException e) {
- throw new ParserException(constructExtendedListenerErrorMessage(UNHANDLED_PARSED_DATA,
- AUGMENT_DATA, ctx.augment().getText(), EXIT, e.getMessage()));
+ throw new ParserException(constructExtendedListenerErrorMessage(
+ UNHANDLED_PARSED_DATA, AUGMENT_DATA,
+ ctx.augment().getText(), EXIT, e.getMessage()));
}
}
}
diff --git a/parser/src/main/java/org/onosproject/yangutils/parser/impl/parserutils/ListenerUtil.java b/parser/src/main/java/org/onosproject/yangutils/parser/impl/parserutils/ListenerUtil.java
index 3c3e08d..493ec09 100644
--- a/parser/src/main/java/org/onosproject/yangutils/parser/impl/parserutils/ListenerUtil.java
+++ b/parser/src/main/java/org/onosproject/yangutils/parser/impl/parserutils/ListenerUtil.java
@@ -405,7 +405,7 @@
/**
* Returns the root node from the current node.
*
- * @param node current node
+ * @param node YANG node
* @return root node
*/
private static YangNode getRootNode(YangNode node) {
@@ -458,7 +458,7 @@
public static void validateUniqueInList(YangList yangList, ParserRuleContext ctx) {
YangLeaf leaf;
// Returns the prefix for the file where unique is present.
- String prefixOfTheFile = getPrefixInFileOfTheCurrentNode(yangList);
+ String prefixOfTheFile = getRootPrefix(yangList);
List<String> uniques = yangList.getUniqueList();
if (uniques != null && !uniques.isEmpty()) {
Iterator<String> uniqueList = uniques.listIterator();
@@ -554,27 +554,23 @@
}
/**
- * Returns the prefix of the current file.
+ * Returns the prefix of the root node from any node inside it.
*
- * @param node node where it needs to find the root node
- * @return prefix of root node
+ * @param curNode YANG node
+ * @return prefix of the root node
*/
- public static String getPrefixInFileOfTheCurrentNode(YangNode node) {
- String prefixInFile;
- while (!(node instanceof YangReferenceResolver)) {
- node = node.getParent();
- if (node == null) {
- throw new ParserException("Internal datamodel error: Datamodel tree is not correct");
- }
- }
+ public static String getRootPrefix(YangNode curNode) {
+
+ String prefix;
+ YangNode node = getRootNode(curNode);
if (node instanceof YangModule) {
YangModule yangModule = (YangModule) node;
- prefixInFile = yangModule.getPrefix();
+ prefix = yangModule.getPrefix();
} else {
YangSubModule yangSubModule = (YangSubModule) node;
- prefixInFile = yangSubModule.getPrefix();
+ prefix = yangSubModule.getPrefix();
}
- return prefixInFile;
+ return prefix;
}
/**
@@ -972,4 +968,31 @@
exception.setCharPosition(pathCtx.getStart().getCharPositionInLine());
return exception;
}
+
+ /**
+ * Returns the augment name, after removing the prefix, in each atomic
+ * content, which is equal to the root prefix.
+ *
+ * @param atomics atomic content list
+ * @param root root node
+ * @return prefix removed augment name
+ */
+ public static String getPrefixRemovedName(List<YangAtomicPath> atomics,
+ YangNode root) {
+
+ String rootPrefix = getRootPrefix(root);
+ StringBuilder builder = new StringBuilder();
+ for (YangAtomicPath atomic : atomics) {
+ String id;
+ String prefix = atomic.getNodeIdentifier().getPrefix();
+ String name = atomic.getNodeIdentifier().getName();
+ if (rootPrefix.equals(prefix) || prefix == null) {
+ id = SLASH_FOR_STRING + name;
+ } else {
+ id = SLASH_FOR_STRING + prefix + COLON + name;
+ }
+ builder.append(id);
+ }
+ return builder.toString();
+ }
}
diff --git a/plugin/maven/src/test/java/org/onosproject/yangutils/plugin/manager/YangXpathLinkerTest.java b/plugin/maven/src/test/java/org/onosproject/yangutils/plugin/manager/YangXpathLinkerTest.java
index 43cb983..3cf52b5 100644
--- a/plugin/maven/src/test/java/org/onosproject/yangutils/plugin/manager/YangXpathLinkerTest.java
+++ b/plugin/maven/src/test/java/org/onosproject/yangutils/plugin/manager/YangXpathLinkerTest.java
@@ -48,7 +48,7 @@
private static final String INTER_FILE_PATH = "src/test/resources/xPathLinker/InterFile/";
private static final String CASE_FILE_PATH = "src/test/resources/xPathLinker/Case/";
private YangUtilManager utilManager = new YangUtilManager();
- private YangXpathLinker linker = new YangXpathLinker();
+ private YangXpathLinker<?> linker = new YangXpathLinker();
private YangLinkerManager linkerManager = new YangLinkerManager();
/**
@@ -139,13 +139,16 @@
}
/**
- * Unit test case for intra file linking for multiple level augment.
+ * Unit test case for intra file linking for multiple level augment
+ * without prefix.
*
- * @throws IOException when fails to do IO operations
+ * @throws IOException if fails to do IO operations
*/
@Test
- public void processIntraFileLinkingInAugmentMultiLevel() throws IOException {
- utilManager.createYangFileInfoSet(getYangFiles(INTRA_FILE_PATH + "IntraMultiAugment/"));
+ public void processIntraFileMultiLevelWithoutPrefix() throws IOException {
+
+ utilManager.createYangFileInfoSet(getYangFiles(
+ INTRA_FILE_PATH + "IntraMultiAugment/withoutprefix"));
utilManager.parseYangFileInfoSet();
utilManager.createYangNodeSet();
linkerManager.createYangNodeSet(utilManager.getYangNodeSet());
@@ -153,21 +156,89 @@
linkerManager.addRefToYangFilesIncludeList(utilManager.getYangNodeSet());
linkerManager.processInterFileLinking(utilManager.getYangNodeSet());
- YangNode targetNode = null;
- String targetNodeName = null;
+ YangNode target = null;
+ String name = null;
for (YangNode node : utilManager.getYangNodeSet()) {
List<YangAugment> augments = linker.getListOfYangAugment(node);
-
for (YangAugment augment : augments) {
- targetNodeName = augment.getTargetNode().get(augment.getTargetNode().size() - 1).getNodeIdentifier()
- .getName();
- targetNode = linker.processXpathLinking(augment.getTargetNode(), node, AUGMENT_LINKING);
+ name = augment.getTargetNode()
+ .get(augment.getTargetNode().size() - 1)
+ .getNodeIdentifier().getName();
+ target = linker.processXpathLinking(augment.getTargetNode(),
+ node, AUGMENT_LINKING);
}
}
+ assertThat(true, is(target.getName().equals(name)));
+ }
- assertThat(true, is(targetNode.getName().equals(targetNodeName)));
+ /**
+ * Unit test case for intra file linking for multiple level augment with
+ * prefix.
+ *
+ * @throws IOException if fails to do IO operations
+ */
+ @Test
+ public void processIntraFileWithPrefix() throws IOException {
+ utilManager.createYangFileInfoSet(getYangFiles(
+ INTRA_FILE_PATH + "IntraMultiAugment/withprefix"));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ linkerManager.createYangNodeSet(utilManager.getYangNodeSet());
+ linkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
+ linkerManager.addRefToYangFilesIncludeList(utilManager.getYangNodeSet());
+ linkerManager.processInterFileLinking(utilManager.getYangNodeSet());
+
+ YangNode target = null;
+ String name = null;
+
+ for (YangNode node : utilManager.getYangNodeSet()) {
+ List<YangAugment> augments = linker.getListOfYangAugment(node);
+ for (YangAugment augment : augments) {
+ name = augment.getTargetNode()
+ .get(augment.getTargetNode().size() - 1)
+ .getNodeIdentifier().getName();
+ target = linker.processXpathLinking(augment.getTargetNode(),
+ node, AUGMENT_LINKING);
+ }
+ }
+ assertThat(true, is(target.getName().equals(name)));
+
+ }
+
+ /**
+ * Unit test case for intra file linking for multiple level augment with
+ * partial prefix.
+ *
+ * @throws IOException if fails to do IO operations
+ */
+ @Test
+ public void processIntraFileWithPartialPrefix() throws IOException {
+
+ utilManager.createYangFileInfoSet(getYangFiles(
+ INTRA_FILE_PATH + "IntraMultiAugment/withpartialprefix"));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ linkerManager.createYangNodeSet(utilManager.getYangNodeSet());
+ linkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
+ linkerManager.addRefToYangFilesIncludeList(utilManager.getYangNodeSet());
+ linkerManager.processInterFileLinking(utilManager.getYangNodeSet());
+
+ YangNode target = null;
+ String name = null;
+
+ for (YangNode node : utilManager.getYangNodeSet()) {
+ List<YangAugment> augments = linker.getListOfYangAugment(node);
+ for (YangAugment augment : augments) {
+ name = augment.getTargetNode()
+ .get(augment.getTargetNode().size() - 1)
+ .getNodeIdentifier().getName();
+ target = linker.processXpathLinking(augment.getTargetNode(),
+ node, AUGMENT_LINKING);
+ }
+ }
+ assertThat(true, is(target.getName().equals(name)));
}
/**
diff --git a/plugin/maven/src/test/resources/xPathLinker/IntraFile/IntraMultiAugment/test.yang b/plugin/maven/src/test/resources/xPathLinker/IntraFile/IntraMultiAugment/withoutprefix/test.yang
similarity index 69%
rename from plugin/maven/src/test/resources/xPathLinker/IntraFile/IntraMultiAugment/test.yang
rename to plugin/maven/src/test/resources/xPathLinker/IntraFile/IntraMultiAugment/withoutprefix/test.yang
index b53012c..b634ab6 100644
--- a/plugin/maven/src/test/resources/xPathLinker/IntraFile/IntraMultiAugment/test.yang
+++ b/plugin/maven/src/test/resources/xPathLinker/IntraFile/IntraMultiAugment/withoutprefix/test.yang
@@ -1,16 +1,16 @@
-module test {
- namespace "xpath:intra:multi";
- prefix test ;
-
- organization "";
- contact "";
-
- description
- "Defines basic service types for L3VPN service.";
-
- revision "2015-12-16" {
- reference "";
- }
+module test {
+ namespace "xpath:intra:multi";
+ prefix test ;
+
+ organization "";
+ contact "";
+
+ description
+ "Defines basic service types for L3VPN service.";
+
+ revision "2015-12-16" {
+ reference "";
+ }
container cont1 {
leaf leaf1 {
@@ -51,4 +51,3 @@
}
}
}
-
diff --git a/plugin/maven/src/test/resources/xPathLinker/IntraFile/IntraMultiAugment/withpartialprefix/augmentpartialprefix.yang b/plugin/maven/src/test/resources/xPathLinker/IntraFile/IntraMultiAugment/withpartialprefix/augmentpartialprefix.yang
new file mode 100644
index 0000000..7a84927
--- /dev/null
+++ b/plugin/maven/src/test/resources/xPathLinker/IntraFile/IntraMultiAugment/withpartialprefix/augmentpartialprefix.yang
@@ -0,0 +1,44 @@
+module agumentpartial {
+ namespace "http://example.com/augment1";
+ prefix "au";
+ container interfaces {
+ list ifEntry {
+ key "ifIndex";
+ leaf ifIndex {
+ type uint32;
+ }
+ leaf ifDescr {
+ type string;
+ }
+ leaf ifType {
+ type int32;
+ }
+ leaf ifMtu {
+ type int32;
+ }
+ }
+ }
+ augment "/au:interfaces/au:ifEntry" {
+ when "au:ifType='ds0'";
+ leaf ifType1 {
+ type int8;
+ }
+ leaf uid {
+ type uint16;
+ }
+ container sub_interfaces {
+ list ifEntry1 {
+ key "ifIndex1";
+ leaf ifIndex1 {
+ type uint32;
+ }
+ }
+ }
+ }
+
+ augment "/interfaces/au:ifEntry/au:sub_interfaces/ifEntry1" {
+ leaf ifType2{
+ type int8;
+ }
+ }
+}
\ No newline at end of file
diff --git a/plugin/maven/src/test/resources/xPathLinker/IntraFile/IntraMultiAugment/withprefix/augment.yang b/plugin/maven/src/test/resources/xPathLinker/IntraFile/IntraMultiAugment/withprefix/augment.yang
new file mode 100644
index 0000000..be666b3
--- /dev/null
+++ b/plugin/maven/src/test/resources/xPathLinker/IntraFile/IntraMultiAugment/withprefix/augment.yang
@@ -0,0 +1,46 @@
+module agument {
+ namespace "http://example.com/augment1";
+ prefix "au";
+ container interfaces {
+ list ifEntry {
+ key "ifIndex";
+ leaf ifIndex {
+ type uint32;
+ }
+ leaf ifDescr {
+ type string;
+ }
+ leaf ifType {
+ type int32;
+ }
+ leaf ifMtu {
+ type int32;
+ }
+ }
+ }
+ augment "/au:interfaces/au:ifEntry" {
+ when "au:ifType='ds0'";
+ leaf ifType1 {
+ type int8;
+ }
+ leaf uid {
+ type uint16 {
+ range "1000 .. 30000";
+ }
+ }
+ container sub_interfaces {
+ list ifEntry1 {
+ key "ifIndex1";
+ leaf ifIndex1 {
+ type uint32;
+ }
+ }
+ }
+ }
+
+ augment "/au:interfaces/au:ifEntry/au:sub_interfaces/au:ifEntry1" {
+ leaf ifType2{
+ type int8;
+ }
+ }
+}
\ No newline at end of file