[ONOS-5785] Refactor code into new folder structure
Change-Id: I115d5af1cd7bfbde71a3092973fe160ec1d9bae5
diff --git a/compiler/plugin/maven/pom.xml b/compiler/plugin/maven/pom.xml
new file mode 100644
index 0000000..afc4947
--- /dev/null
+++ b/compiler/plugin/maven/pom.xml
@@ -0,0 +1,150 @@
+<!--
+ ~ Copyright 2016-present Open Networking Laboratory
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-yang-compiler-plugin</artifactId>
+ <version>1.12-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>onos-yang-compiler-maven-plugin</artifactId>
+ <version>1.12-SNAPSHOT</version>
+ <packaging>maven-plugin</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-core</artifactId>
+ <version>3.3.9</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-plugin-api</artifactId>
+ <version>3.3.9</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-annotations</artifactId>
+ <version>3.4</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-scr-plugin</artifactId>
+ <version>1.21.0</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-artifact</artifactId>
+ <version>3.3.9</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-project</artifactId>
+ <version>3.0-alpha-2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-model</artifactId>
+ <version>3.3.9</version>
+ </dependency>
+ <dependency>
+ <groupId>org.sonatype.plexus</groupId>
+ <artifactId>plexus-build-api</artifactId>
+ <version>0.0.7</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <version>1.10</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>1.7.21</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.12</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-yang-compiler-tool</artifactId>
+ <version>1.12-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <version>1.10</version>
+ <executions>
+ <execution>
+ <id>add-source</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>add-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>
+ target/generated-sources/org/onosproject/yangutils/parser/antlrgencode
+ </source>
+ <sourceDirectory>
+ target/generated-sources/org/onosproject/yangutils/parser/antlrgencode
+ </sourceDirectory>
+ </sources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-plugin-plugin</artifactId>
+ <version>3.4</version>
+ <configuration>
+ <skipErrorNoDescriptorsFound>true
+ </skipErrorNoDescriptorsFound>
+ </configuration>
+ <executions>
+ <execution>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>descriptor</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <version>2.5.4</version>
+ <extensions>true</extensions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/compiler/plugin/maven/src/main/java/org/onosproject/yang/compiler/plugin/maven/YangPluginUtils.java b/compiler/plugin/maven/src/main/java/org/onosproject/yang/compiler/plugin/maven/YangPluginUtils.java
new file mode 100644
index 0000000..c5f0e69
--- /dev/null
+++ b/compiler/plugin/maven/src/main/java/org/onosproject/yang/compiler/plugin/maven/YangPluginUtils.java
@@ -0,0 +1,208 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yang.compiler.plugin.maven;
+
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.model.Dependency;
+import org.apache.maven.model.Plugin;
+import org.apache.maven.model.Resource;
+import org.apache.maven.project.MavenProject;
+import org.onosproject.yang.compiler.base.tool.YangToolManager;
+import org.onosproject.yang.compiler.datamodel.YangNode;
+import org.onosproject.yang.compiler.datamodel.utils.DataModelUtils;
+import org.onosproject.yang.compiler.utils.io.impl.YangIoUtils;
+import org.slf4j.Logger;
+import org.sonatype.plexus.build.incremental.BuildContext;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import static org.onosproject.yang.compiler.utils.UtilConstants.COLON;
+import static org.onosproject.yang.compiler.utils.UtilConstants.EMPTY_STRING;
+import static org.onosproject.yang.compiler.utils.UtilConstants.HYPHEN;
+import static org.onosproject.yang.compiler.utils.UtilConstants.JAR;
+import static org.onosproject.yang.compiler.utils.UtilConstants.PERIOD;
+import static org.onosproject.yang.compiler.utils.UtilConstants.SLASH;
+import static org.onosproject.yang.compiler.utils.UtilConstants.TEMP;
+import static org.slf4j.LoggerFactory.getLogger;
+
+/**
+ * Represents YANG plugin utilities.
+ */
+public final class YangPluginUtils {
+
+ private static final Logger log = getLogger(YangPluginUtils.class);
+
+ private static final String TEXT_FILE_EXTENSION = ".txt";
+ private static final String VERSION_META_DATA = "VersionMetaData";
+ private static final String PLUGIN_ARTIFACT = "onos-yang-maven-plugin";
+
+ private YangPluginUtils() {
+ }
+
+ /**
+ * Adds generated source directory to the compilation root.
+ *
+ * @param source directory
+ * @param project current maven project
+ * @param context current build context
+ */
+ static void addToCompilationRoot(String source, MavenProject project, BuildContext context) {
+ project.addCompileSourceRoot(source);
+ context.refresh(project.getBasedir());
+ log.info("Source directory added to compilation root: " + source);
+ }
+
+ /**
+ * Copies YANG files to the current project's output directory.
+ *
+ * @param outputDir project's output directory
+ * @param project maven project
+ * @throws IOException when fails to copy files to destination resource directory
+ */
+ static void copyYangFilesToTarget(String outputDir, MavenProject project)
+ throws IOException {
+
+ addToProjectResource(outputDir + SLASH + TEMP + SLASH, project);
+ }
+
+ /**
+ * Serializes data-model.
+ *
+ * @param directory base directory for serialized files
+ * @param project maven project
+ * @param operation true if need to add to resource
+ * @throws IOException when fails to do IO operations
+ */
+ public static void serializeDataModel(String directory,
+ MavenProject project,
+ boolean operation)
+ throws IOException {
+
+ String serFileDirPath = directory + YangToolManager.DEFAULT_JAR_RES_PATH;
+ File dir = new File(serFileDirPath);
+ dir.mkdirs();
+
+ if (operation) {
+ addToProjectResource(directory + SLASH + TEMP + SLASH, project);
+ }
+
+ if (operation) {
+ addVersionMetaDataFile(project, serFileDirPath);
+ }
+ }
+
+ /**
+ * Adds version meta data files for YSR to know version of YANG tools.
+ *
+ * @param project maven project
+ * @param dir directory
+ * @throws IOException when fails to do IO operations
+ */
+ private static void addVersionMetaDataFile(MavenProject project, String dir)
+ throws IOException {
+ List<Plugin> plugins = project.getBuildPlugins();
+ Iterator<Plugin> it = plugins.iterator();
+ Plugin plugin = it.next();
+ String data = EMPTY_STRING;
+ while (it.hasNext()) {
+ if (plugin.getArtifactId().equals(PLUGIN_ARTIFACT)) {
+ data = plugin.getGroupId() + COLON + plugin.getArtifactId()
+ + COLON + plugin.getVersion();
+ }
+ plugin = it.next();
+ }
+ if (data.equals(EMPTY_STRING)) {
+ throw new IOException("Invalid artifact for " + PLUGIN_ARTIFACT);
+ }
+ String verFileName = dir + VERSION_META_DATA + TEXT_FILE_EXTENSION;
+ PrintWriter out = new PrintWriter(verFileName);
+ out.print(data);
+ out.close();
+ }
+
+ /**
+ * Returns list of jar path.
+ *
+ * @param project maven project
+ * @param localRepository local repository
+ * @param remoteRepos remote repository
+ * @return list of jar paths
+ */
+ private static List<String> resolveDependencyJarPath(MavenProject project, ArtifactRepository localRepository,
+ List<ArtifactRepository> remoteRepos) {
+
+ StringBuilder path = new StringBuilder();
+ List<String> jarPaths = new ArrayList<>();
+ for (Object obj : project.getDependencies()) {
+
+ Dependency dependency = (Dependency) obj;
+ path.append(localRepository.getBasedir());
+ path.append(SLASH);
+ path.append(YangIoUtils.getPackageDirPathFromJavaJPackage(dependency.getGroupId()));
+ path.append(SLASH);
+ path.append(dependency.getArtifactId());
+ path.append(SLASH);
+ path.append(dependency.getVersion());
+ path.append(SLASH);
+ path.append(dependency.getArtifactId() + HYPHEN + dependency.getVersion() + PERIOD + JAR);
+ File jarFile = new File(path.toString());
+ if (jarFile.exists()) {
+ jarPaths.add(path.toString());
+ }
+ path.delete(0, path.length());
+ }
+
+ for (ArtifactRepository repo : remoteRepos) {
+ // TODO: add resolver for remote repo.
+ }
+ return jarPaths;
+ }
+
+ /**
+ * Resolves inter jar dependencies.
+ *
+ * @param project current maven project
+ * @param localRepository local maven repository
+ * @param remoteRepos list of remote repository
+ * @param directory directory for serialized files
+ * @return list of resolved datamodel nodes
+ * @throws IOException when fails to do IO operations
+ */
+ static List<YangNode> resolveInterJarDependencies(MavenProject project, ArtifactRepository localRepository,
+ List<ArtifactRepository> remoteRepos, String directory)
+ throws IOException {
+
+ List<String> dependenciesJarPaths = resolveDependencyJarPath(project, localRepository, remoteRepos);
+ List<YangNode> resolvedDataModelNodes = new ArrayList<>();
+ for (String dependency : dependenciesJarPaths) {
+ resolvedDataModelNodes.addAll(DataModelUtils.parseJarFile(dependency, directory));
+ }
+ return resolvedDataModelNodes;
+ }
+
+ /* Adds directory to resources of project */
+ private static void addToProjectResource(String dir, MavenProject project) {
+ Resource rsc = new Resource();
+ rsc.setDirectory(dir);
+ project.addResource(rsc);
+ }
+}
diff --git a/compiler/plugin/maven/src/main/java/org/onosproject/yang/compiler/plugin/maven/YangUtilManager.java b/compiler/plugin/maven/src/main/java/org/onosproject/yang/compiler/plugin/maven/YangUtilManager.java
new file mode 100644
index 0000000..a9d0ce0
--- /dev/null
+++ b/compiler/plugin/maven/src/main/java/org/onosproject/yang/compiler/plugin/maven/YangUtilManager.java
@@ -0,0 +1,430 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yang.compiler.plugin.maven;
+
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugins.annotations.Component;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.rtinfo.RuntimeInformation;
+import org.onosproject.yang.compiler.parser.YangUtilsParser;
+import org.onosproject.yang.compiler.parser.exceptions.ParserException;
+import org.onosproject.yang.compiler.parser.impl.YangUtilsParserManager;
+import org.onosproject.yang.compiler.base.tool.CallablePlugin;
+import org.onosproject.yang.compiler.base.tool.YangFileInfo;
+import org.onosproject.yang.compiler.base.tool.YangToolManager;
+import org.onosproject.yang.compiler.base.tool.exception.YangToolException;
+import org.onosproject.yang.compiler.datamodel.ResolvableType;
+import org.onosproject.yang.compiler.datamodel.YangNode;
+import org.onosproject.yang.compiler.datamodel.YangReferenceResolver;
+import org.onosproject.yang.compiler.datamodel.exceptions.DataModelException;
+import org.onosproject.yang.compiler.linker.YangLinker;
+import org.onosproject.yang.compiler.linker.exceptions.LinkerException;
+import org.onosproject.yang.compiler.linker.impl.YangLinkerManager;
+import org.onosproject.yang.compiler.translator.tojava.JavaCodeGeneratorUtil;
+import org.onosproject.yang.compiler.utils.io.YangPluginConfig;
+import org.onosproject.yang.compiler.utils.io.YangToJavaNamingConflictUtil;
+import org.sonatype.plexus.build.incremental.BuildContext;
+
+import java.io.IOException;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+
+import static java.util.Collections.sort;
+import static org.apache.maven.plugins.annotations.LifecyclePhase.PROCESS_SOURCES;
+import static org.apache.maven.plugins.annotations.ResolutionScope.COMPILE;
+import static org.onosproject.yang.compiler.linker.impl.YangLinkerUtils.resolveGroupingInDefinationScope;
+import static org.onosproject.yang.compiler.plugin.maven.YangPluginUtils.addToCompilationRoot;
+import static org.onosproject.yang.compiler.plugin.maven.YangPluginUtils.copyYangFilesToTarget;
+import static org.onosproject.yang.compiler.plugin.maven.YangPluginUtils.resolveInterJarDependencies;
+import static org.onosproject.yang.compiler.plugin.maven.YangPluginUtils.serializeDataModel;
+import static org.onosproject.yang.compiler.utils.UtilConstants.DEFAULT_BASE_PKG;
+import static org.onosproject.yang.compiler.utils.UtilConstants.EMPTY_STRING;
+import static org.onosproject.yang.compiler.utils.UtilConstants.IN;
+import static org.onosproject.yang.compiler.utils.UtilConstants.NEW_LINE;
+import static org.onosproject.yang.compiler.utils.UtilConstants.SLASH;
+import static org.onosproject.yang.compiler.utils.UtilConstants.TEMP;
+import static org.onosproject.yang.compiler.utils.UtilConstants.VERSION_ERROR;
+import static org.onosproject.yang.compiler.utils.UtilConstants.YANG_RESOURCES;
+import static org.onosproject.yang.compiler.utils.io.impl.YangFileScanner.getYangFiles;
+import static org.onosproject.yang.compiler.utils.io.impl.YangIoUtils.deleteDirectory;
+import static org.onosproject.yang.compiler.utils.io.impl.YangIoUtils.getDirectory;
+import static org.onosproject.yang.compiler.utils.io.impl.YangIoUtils.getPackageDirPathFromJavaJPackage;
+import static org.onosproject.yang.compiler.utils.io.impl.YangIoUtils.getVersionValue;
+
+/**
+ * Represents ONOS YANG utility maven plugin.
+ * Goal of plugin is yang2java.
+ * Execution phase is generate-sources.
+ * requiresDependencyResolution at compile time.
+ */
+@Mojo(name = "yang2java", defaultPhase = PROCESS_SOURCES,
+ requiresDependencyResolution = COMPILE)
+public class YangUtilManager extends AbstractMojo implements CallablePlugin {
+
+ private static final String DEFAULT_PKG =
+ getPackageDirPathFromJavaJPackage(DEFAULT_BASE_PKG);
+ private static final int SUPPORTED_VERSION = 339;
+ private final YangPluginConfig yangPlugin = new YangPluginConfig();
+ private final YangUtilsParser yangUtilsParser = new YangUtilsParserManager();
+ private final YangLinker yangLinker = new YangLinkerManager();
+ private final Set<YangNode> yangNodeSet = new HashSet<>();
+ private YangNode rootNode;
+ // YANG file information set.
+ private Set<YangFileInfo> yangFileInfoSet = new HashSet<>();
+ private YangFileInfo curYangFileInfo = new YangFileInfo();
+ /**
+ * Source directory for YANG files.
+ */
+ @Parameter(property = "yangFilesDir", defaultValue = "src/main/yang")
+ private String yangFilesDir;
+
+ /**
+ * Source directory for generated files.
+ */
+ @Parameter(property = "classFileDir", defaultValue = "target/generated-sources")
+ private String classFileDir;
+
+ /**
+ * Base directory for project.
+ */
+ @Parameter(property = "basedir", defaultValue = "${basedir}")
+ private String baseDir;
+
+ /**
+ * Output directory.
+ */
+ @Parameter(property = "project.build.outputDirectory", required = true,
+ defaultValue = "target/classes")
+ private String outputDirectory;
+
+ /**
+ * Current maven project.
+ */
+ @Parameter(property = "project", required = true, readonly = true,
+ defaultValue = "${project}")
+ private MavenProject project;
+
+ /**
+ * Replacement required for period special character in the identifier.
+ */
+ @Parameter(property = "replacementForPeriod")
+ private String replacementForPeriod;
+
+ /**
+ * Replacement required for underscore special character in the identifier.
+ */
+ @Parameter(property = "replacementForUnderscore")
+ private String replacementForUnderscore;
+
+ /**
+ * Replacement required for hyphen special character in the identifier.
+ */
+ @Parameter(property = "replacementForHyphen")
+ private String replacementForHyphen;
+
+ /**
+ * Prefix which is required for adding with the identifier.
+ */
+ @Parameter(property = "prefixForIdentifier")
+ private String prefixForIdentifier;
+
+ /**
+ * Build context.
+ */
+ @Component
+ private BuildContext context;
+
+ /**
+ * Local maven repository.
+ */
+ @Parameter(readonly = true, defaultValue = "${localRepository}")
+ private ArtifactRepository localRepository;
+
+ /**
+ * Remote maven repositories.
+ */
+ @Parameter(readonly = true, defaultValue = "${project.remoteArtifactRepositories}")
+ private List<ArtifactRepository> remoteRepository;
+
+ /**
+ * Code generation is for nbi or sbi.
+ */
+ @Parameter(property = "generateJavaFileForSbi", defaultValue = "nbi")
+ private String generateJavaFileForSbi;
+
+ /**
+ * The Runtime information for the current instance of Maven.
+ */
+ @Component
+ private RuntimeInformation runtime;
+
+ /**
+ * The name of the property in which to store the version of Maven.
+ */
+ @Parameter(defaultValue = "maven.version")
+ private String versionProperty;
+
+ private String outputDir;
+ private String codeGenDir;
+
+ @Override
+ public void execute()
+ throws MojoExecutionException, MojoFailureException {
+
+ try {
+ validateMavenVersion();
+ /*
+ * For deleting the generated code in previous build.
+ */
+ outputDir = getDirectory(baseDir, outputDirectory);
+ deleteDirectory(outputDir + SLASH + TEMP);
+ deleteDirectory(outputDir + SLASH + YANG_RESOURCES);
+ String searchDir = getDirectory(baseDir, yangFilesDir);
+ codeGenDir = getDirectory(baseDir, classFileDir) + SLASH;
+
+ // Creates conflict resolver and set values to it.
+ YangToJavaNamingConflictUtil conflictResolver = new YangToJavaNamingConflictUtil();
+ conflictResolver.setReplacementForPeriod(replacementForPeriod);
+ conflictResolver.setReplacementForHyphen(replacementForHyphen);
+ conflictResolver.setReplacementForUnderscore(replacementForUnderscore);
+ conflictResolver.setPrefixForIdentifier(prefixForIdentifier);
+ yangPlugin.setCodeGenDir(codeGenDir);
+ yangPlugin.setConflictResolver(conflictResolver);
+
+ yangPlugin.resourceGenDir(outputDir + YangToolManager.DEFAULT_JAR_RES_PATH);
+ yangPlugin.setCodeGenerateForSbi(generateJavaFileForSbi.toLowerCase());
+
+ /*
+ * Obtain the YANG files at a path mentioned in plugin and creates
+ * YANG file information set.
+ */
+
+ YangToolManager toolManager = new YangToolManager();
+
+ yangFileInfoSet = toolManager.createYangFileInfoSet(
+ getYangFiles(searchDir));
+ List<YangNode> interJarResolvedNodes =
+ resolveInterJarDependencies(project, localRepository,
+ remoteRepository, outputDir);
+ toolManager.compileYangFiles(yangFileInfoSet,
+ interJarResolvedNodes, yangPlugin,
+ this);
+ } catch (YangToolException e) {
+ String fileName = EMPTY_STRING;
+ if (e.getCurYangFile() != null) {
+ fileName = e.getCurYangFile().getYangFileName();
+ }
+ try {
+ deleteDirectory(codeGenDir + DEFAULT_PKG);
+ } catch (IOException ex) {
+ e.printStackTrace();
+ throw new MojoExecutionException(
+ "Error handler failed to delete files for data model node.");
+ }
+ getLog().info(e.getCause());
+ throw new MojoExecutionException(
+ "Exception occurred due to " + e.getLocalizedMessage() +
+ IN + fileName + " YANG file.");
+ } catch (IOException e) {
+ throw new MojoExecutionException(
+ "Failed to process files");
+ }
+ }
+
+ /**
+ * Validates current maven version of system.
+ *
+ * @throws MojoExecutionException when maven version is below 3.3.9
+ */
+ private void validateMavenVersion() throws MojoExecutionException {
+ String version = runtime.getMavenVersion();
+ if (getVersionValue(version) < SUPPORTED_VERSION) {
+ throw new MojoExecutionException(VERSION_ERROR + version);
+ }
+ }
+
+ /**
+ * Returns the YANG node set.
+ *
+ * @return YANG node set
+ */
+ public Set<YangNode> getYangNodeSet() {
+ return yangNodeSet;
+ }
+
+ /**
+ * TODO: Delete me and use the tool code for UT test cases
+ * Links all the provided with the YANG file info set.
+ *
+ * @throws MojoExecutionException a violation in mojo execution
+ */
+ public void resolveDependenciesUsingLinker()
+ throws MojoExecutionException {
+ createYangNodeSet();
+ try {
+ yangLinker.resolveDependencies(yangNodeSet);
+ } catch (LinkerException e) {
+ printLog(e.getFileName(), e.getLineNumber(), e.getCharPositionInLine(),
+ e.getMessage(), e.getLocalizedMessage());
+ throw new MojoExecutionException(e.getMessage());
+ }
+ }
+
+ /**
+ * TODO: Delete me and use the tool code for UT test cases
+ * Creates YANG nodes set.
+ */
+ protected void createYangNodeSet() {
+ for (YangFileInfo yangFileInfo : yangFileInfoSet) {
+ yangNodeSet.add(yangFileInfo.getRootNode());
+ }
+ }
+
+ /**
+ * TODO: Delete me and use the tool code for UT test cases
+ * Parses all the provided YANG files and generates YANG data model tree.
+ *
+ * @throws IOException a violation in IO
+ */
+ public void parseYangFileInfoSet()
+ throws IOException {
+ for (YangFileInfo yangFileInfo : yangFileInfoSet) {
+ curYangFileInfo = yangFileInfo;
+ if (yangFileInfo.isForTranslator()) {
+ try {
+ YangNode yangNode = yangUtilsParser.getDataModel(
+ yangFileInfo.getYangFileName());
+ yangFileInfo.setRootNode(yangNode);
+ rootNode = yangNode;
+ resolveGroupingInDefinationScope((YangReferenceResolver) yangNode);
+ try {
+ ((YangReferenceResolver) yangNode)
+ .resolveSelfFileLinking(ResolvableType.YANG_DERIVED_DATA_TYPE);
+ ((YangReferenceResolver) yangNode)
+ .resolveSelfFileLinking(ResolvableType.YANG_IDENTITYREF);
+ } catch (DataModelException e) {
+ printLog(e.getFileName(), e.getLineNumber(), e
+ .getCharPositionInLine(), e.getMessage(), e
+ .getLocalizedMessage());
+ }
+ } catch (ParserException e) {
+ printLog(e.getFileName(), e.getLineNumber(), e
+ .getCharPositionInLine(), e.getMessage(), e
+ .getLocalizedMessage());
+ throw e;
+ }
+ }
+ }
+ }
+
+ /**
+ * TODO: Delete me and use the tool code for UT test cases
+ * Translates to java code corresponding to the YANG schema.
+ *
+ * @param yangPlugin YANG plugin config
+ * @throws IOException when fails to generate java code file the current node
+ */
+ public void translateToJava(YangPluginConfig yangPlugin)
+ throws IOException {
+ List<YangNode> yangNodeSortedList = new LinkedList<>();
+ yangNodeSortedList.addAll(yangNodeSet);
+ sort(yangNodeSortedList);
+ for (YangNode node : yangNodeSortedList) {
+ if (node.isToTranslate()) {
+ JavaCodeGeneratorUtil.generateJavaCode(node, yangPlugin);
+ }
+ }
+ }
+
+ /**
+ * Creates a YANG file info set.
+ *
+ * @param yangFileList YANG files list
+ */
+ public void createYangFileInfoSet(List<String> yangFileList) {
+ for (String yangFile : yangFileList) {
+ YangFileInfo yangFileInfo = new YangFileInfo();
+ yangFileInfo.setYangFileName(yangFile);
+ yangFileInfoSet.add(yangFileInfo);
+ }
+ }
+
+ /**
+ * TODO: Delete me and use the tool code for UT test cases
+ * Returns the YANG file info set.
+ *
+ * @return the YANG file info set
+ */
+ public Set<YangFileInfo> getYangFileInfoSet() {
+ return yangFileInfoSet;
+ }
+
+ /**
+ * TODO: Delete me and use the tool code for UT test cases
+ * Sets the YANG file info set.
+ *
+ * @param yangFileInfoSet the YANG file info set
+ */
+ void setYangFileInfoSet(Set<YangFileInfo> yangFileInfoSet) {
+ this.yangFileInfoSet = yangFileInfoSet;
+ }
+
+ /**
+ * Adds log info for exception.
+ *
+ * @param fileName file name
+ * @param line line number
+ * @param position character position
+ * @param msg error message
+ * @param localMsg local message
+ */
+ private void printLog(String fileName, int line, int position, String
+ msg, String localMsg) {
+ String logInfo = "Error in file: " + fileName;
+ if (line != 0) {
+ logInfo = logInfo + " at line: " + line + " at position: "
+ + position;
+ }
+ if (msg != null) {
+ logInfo = logInfo + NEW_LINE + localMsg;
+ }
+ getLog().info(logInfo);
+ }
+
+ @Override
+ public void addGeneratedCodeToBundle() {
+ addToCompilationRoot(codeGenDir, project, context);
+ }
+
+
+ @Override
+ public void addCompiledSchemaToBundle() throws IOException {
+ serializeDataModel(outputDir, project, true);
+ }
+
+ @Override
+ public void addYangFilesToBundle() throws IOException {
+ copyYangFilesToTarget(outputDir, project);
+ }
+}
diff --git a/compiler/plugin/maven/src/main/java/org/onosproject/yang/compiler/plugin/maven/package-info.java b/compiler/plugin/maven/src/main/java/org/onosproject/yang/compiler/plugin/maven/package-info.java
new file mode 100644
index 0000000..4b67022
--- /dev/null
+++ b/compiler/plugin/maven/src/main/java/org/onosproject/yang/compiler/plugin/maven/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * YANG utility maven plugin.
+ */
+package org.onosproject.yang.compiler.plugin.maven;
diff --git a/compiler/plugin/maven/src/main/resources/CopyrightHeader.txt b/compiler/plugin/maven/src/main/resources/CopyrightHeader.txt
new file mode 100644
index 0000000..2cbed45
--- /dev/null
+++ b/compiler/plugin/maven/src/main/resources/CopyrightHeader.txt
@@ -0,0 +1,14 @@
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
diff --git a/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/AugmentTranslatorTest.java b/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/AugmentTranslatorTest.java
new file mode 100644
index 0000000..3d7a6e6
--- /dev/null
+++ b/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/AugmentTranslatorTest.java
@@ -0,0 +1,128 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yang.compiler.plugin.maven;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.junit.Test;
+import org.onosproject.yang.compiler.utils.io.YangPluginConfig;
+import org.onosproject.yang.compiler.utils.io.impl.YangFileScanner;
+import org.onosproject.yang.compiler.utils.io.impl.YangIoUtils;
+import org.onosproject.yang.compiler.parser.exceptions.ParserException;
+
+import java.io.File;
+import java.io.IOException;
+
+/**
+ * Unit test case for augment translator.
+ */
+public class AugmentTranslatorTest {
+
+ private final YangUtilManager utilManager = new YangUtilManager();
+ private static final String DIR = "target/augmentTranslator/";
+ private static final String COMP = System.getProperty("user.dir") + File
+ .separator + DIR;
+
+ /**
+ * Checks augment translation should not result in any exception.
+ *
+ * @throws MojoExecutionException
+ */
+ @Test
+ public void processAugmentTranslator() throws IOException, ParserException, MojoExecutionException {
+
+ YangIoUtils.deleteDirectory(DIR);
+ String searchDir = "src/test/resources/augmentTranslator";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ utilManager.resolveDependenciesUsingLinker();
+
+ YangPluginConfig yangPluginConfig = new YangPluginConfig();
+ yangPluginConfig.setCodeGenDir(DIR);
+ utilManager.translateToJava(yangPluginConfig);
+ YangPluginConfig.compileCode(COMP);
+ YangIoUtils.deleteDirectory(DIR);
+ }
+
+ /**
+ * Checks augment translation should not result in any exception.
+ * compiler not added because it contains a notification which depends on
+ * onos api.
+ *
+ * @throws MojoExecutionException
+ */
+ @Test
+ public void processRpcAugmentIntraTranslator() throws IOException,
+ ParserException, MojoExecutionException {
+ YangIoUtils.deleteDirectory(DIR);
+ String searchDir = "src/test/resources/rpcAugment/intra";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ utilManager.resolveDependenciesUsingLinker();
+
+ YangPluginConfig yangPluginConfig = new YangPluginConfig();
+ yangPluginConfig.setCodeGenDir(DIR);
+ utilManager.translateToJava(yangPluginConfig);
+ YangIoUtils.deleteDirectory(DIR);
+ }
+
+ /**
+ * Checks augment translation should not result in any exception.
+ *
+ * @throws MojoExecutionException
+ */
+ @Test
+ public void processRpcAugmentInterTranslator() throws IOException,
+ ParserException, MojoExecutionException {
+ YangIoUtils.deleteDirectory(DIR);
+ String searchDir = "src/test/resources/rpcAugment/inter";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ utilManager.resolveDependenciesUsingLinker();
+
+ YangPluginConfig yangPluginConfig = new YangPluginConfig();
+ yangPluginConfig.setCodeGenDir(DIR);
+ utilManager.translateToJava(yangPluginConfig);
+ YangPluginConfig.compileCode(COMP);
+ YangIoUtils.deleteDirectory(DIR);
+ }
+
+ /**
+ * Checks augment translation should not result in any exception.
+ *
+ * @throws MojoExecutionException
+ */
+ @Test
+ public void processChoiceAugmentInterTranslator() throws IOException,
+ ParserException, MojoExecutionException {
+ YangIoUtils.deleteDirectory(DIR);
+ String searchDir = "src/test/resources/choiceAugment";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ utilManager.resolveDependenciesUsingLinker();
+
+ YangPluginConfig yangPluginConfig = new YangPluginConfig();
+ yangPluginConfig.setCodeGenDir(DIR);
+ utilManager.translateToJava(yangPluginConfig);
+ YangPluginConfig.compileCode(COMP);
+ YangIoUtils.deleteDirectory(DIR);
+ }
+
+}
diff --git a/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/ChoiceCaseTranslatorTest.java b/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/ChoiceCaseTranslatorTest.java
new file mode 100644
index 0000000..395792a
--- /dev/null
+++ b/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/ChoiceCaseTranslatorTest.java
@@ -0,0 +1,83 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yang.compiler.plugin.maven;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.junit.Test;
+import org.onosproject.yang.compiler.parser.exceptions.ParserException;
+import org.onosproject.yang.compiler.parser.impl.YangUtilsParserManager;
+import org.onosproject.yang.compiler.datamodel.YangNode;
+import org.onosproject.yang.compiler.utils.io.YangPluginConfig;
+import org.onosproject.yang.compiler.utils.io.impl.YangFileScanner;
+import org.onosproject.yang.compiler.utils.io.impl.YangIoUtils;
+
+import java.io.File;
+import java.io.IOException;
+
+import static org.onosproject.yang.compiler.translator.tojava.JavaCodeGeneratorUtil.generateJavaCode;
+
+/**
+ * Unit tests for choice-case translator.
+ */
+public final class ChoiceCaseTranslatorTest {
+ private static final String DIR = "target/ChoiceCaseTestGenFile/";
+ private static final String COMP = System.getProperty("user.dir") + File
+ .separator + DIR;
+ private final YangUtilManager utilManager = new YangUtilManager();
+ private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+ /**
+ * Checks choice-case translation should not result in any exception.
+ */
+ @Test
+ public void processChoiceCaseTranslator() throws IOException, ParserException {
+
+ String dir = "target/ChoiceCaseTestGenFile/";
+ YangIoUtils.deleteDirectory(dir);
+ YangNode node = manager.getDataModel("src/test/resources/ChoiceCaseTranslator.yang");
+
+ YangPluginConfig yangPluginConfig = new YangPluginConfig();
+ yangPluginConfig.setCodeGenDir(dir);
+
+ generateJavaCode(node, yangPluginConfig);
+ String dir1 = System.getProperty("user.dir") + File.separator + dir;
+ YangPluginConfig.compileCode(dir1);
+ YangIoUtils.deleteDirectory(dir);
+ }
+
+ /**
+ * Checks augment translation should not result in any exception.
+ *
+ * @throws MojoExecutionException
+ */
+ @Test
+ public void processChoiceAllTranslator() throws IOException,
+ ParserException, MojoExecutionException {
+ YangIoUtils.deleteDirectory(DIR);
+ String searchDir = "src/test/resources/choiceTranslator";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ utilManager.resolveDependenciesUsingLinker();
+
+ YangPluginConfig yangPluginConfig = new YangPluginConfig();
+ yangPluginConfig.setCodeGenDir(DIR);
+ utilManager.translateToJava(yangPluginConfig);
+ YangPluginConfig.compileCode(COMP);
+ YangIoUtils.deleteDirectory(DIR);
+ }
+}
diff --git a/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/CompilerAnnotationTest.java b/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/CompilerAnnotationTest.java
new file mode 100644
index 0000000..d020cee
--- /dev/null
+++ b/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/CompilerAnnotationTest.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+package org.onosproject.yang.compiler.plugin.maven;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.junit.Test;
+import org.onosproject.yang.compiler.utils.io.YangPluginConfig;
+import org.onosproject.yang.compiler.utils.io.impl.YangFileScanner;
+import org.onosproject.yang.compiler.utils.io.impl.YangIoUtils;
+import org.onosproject.yang.compiler.parser.exceptions.ParserException;
+
+import java.io.File;
+import java.io.IOException;
+
+/**
+ * Unit test case for compiler annotation.
+ */
+public class CompilerAnnotationTest {
+ private final YangUtilManager utilManager = new YangUtilManager();
+ private static final String DIR = "target/compiler/";
+ private static final String COMP = System.getProperty("user.dir") + File
+ .separator + DIR;
+
+
+ /**
+ * Checks compiler annotation translation should not result in any exception.
+ *
+ * @throws MojoExecutionException
+ */
+ @Test
+ public void processTranslator() throws IOException,
+ ParserException, MojoExecutionException {
+ YangIoUtils.deleteDirectory(DIR);
+ String searchDir = "src/test/resources/compilerAnnotation";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ utilManager.resolveDependenciesUsingLinker();
+
+ YangPluginConfig yangPluginConfig = new YangPluginConfig();
+ yangPluginConfig.setCodeGenDir(DIR);
+ utilManager.translateToJava(yangPluginConfig);
+ YangPluginConfig.compileCode(COMP);
+ YangIoUtils.deleteDirectory(DIR);
+ }
+}
diff --git a/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/EnumTranslatorTest.java b/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/EnumTranslatorTest.java
new file mode 100644
index 0000000..6998d9b
--- /dev/null
+++ b/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/EnumTranslatorTest.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yang.compiler.plugin.maven;
+
+import org.junit.Test;
+import org.onosproject.yang.compiler.parser.exceptions.ParserException;
+import org.onosproject.yang.compiler.parser.impl.YangUtilsParserManager;
+import org.onosproject.yang.compiler.datamodel.YangNode;
+import org.onosproject.yang.compiler.translator.tojava.JavaCodeGeneratorUtil;
+import org.onosproject.yang.compiler.utils.io.YangPluginConfig;
+import org.onosproject.yang.compiler.utils.io.impl.YangIoUtils;
+
+import java.io.File;
+import java.io.IOException;
+
+/**
+ * Unit test case for enum translator.
+ */
+public final class EnumTranslatorTest {
+
+ private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+ /**
+ * Checks enum translation should not result in any exception.
+ */
+ @Test
+ public void processEnumTranslator()
+ throws IOException, ParserException {
+ YangNode node = manager.getDataModel("src/test/resources/EnumTranslator.yang");
+
+ String dir = "target/enumTranslator/";
+ YangIoUtils.deleteDirectory(dir);
+ YangPluginConfig yangPluginConfig = new YangPluginConfig();
+ yangPluginConfig.setCodeGenDir(dir);
+
+ JavaCodeGeneratorUtil.generateJavaCode(node, yangPluginConfig);
+ String dir1 = System.getProperty("user.dir") + File.separator + dir;
+ YangPluginConfig.compileCode(dir1);
+ YangIoUtils.deleteDirectory(dir);
+ }
+ // TODO enhance the test cases, after having a framework of translator test.
+}
diff --git a/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/GroupingTranslatorTest.java b/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/GroupingTranslatorTest.java
new file mode 100644
index 0000000..d7e6580
--- /dev/null
+++ b/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/GroupingTranslatorTest.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yang.compiler.plugin.maven;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.junit.Test;
+import org.onosproject.yang.compiler.utils.io.YangPluginConfig;
+import org.onosproject.yang.compiler.utils.io.impl.YangFileScanner;
+import org.onosproject.yang.compiler.utils.io.impl.YangIoUtils;
+import org.onosproject.yang.compiler.parser.exceptions.ParserException;
+
+import java.io.File;
+import java.io.IOException;
+
+/**
+ * Unit test case for grouping translator.
+ */
+public class GroupingTranslatorTest {
+
+ private final YangUtilManager utilManager = new YangUtilManager();
+ private static final String DIR = "target/groupingTranslator/";
+ private static final String COMP = System.getProperty("user.dir") + File
+ .separator + DIR;
+
+ /**
+ * Checks grouping translation should not result in any exception.
+ *
+ * @throws MojoExecutionException
+ */
+ @Test
+ public void processTranslator() throws IOException, ParserException, MojoExecutionException {
+
+ YangIoUtils.deleteDirectory(DIR);
+ String searchDir = "src/test/resources/grouping";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ utilManager.resolveDependenciesUsingLinker();
+
+ YangPluginConfig yangPluginConfig = new YangPluginConfig();
+ yangPluginConfig.setCodeGenDir(DIR);
+ utilManager.translateToJava(yangPluginConfig);
+ YangPluginConfig.compileCode(COMP);
+ YangIoUtils.deleteDirectory(DIR);
+ }
+
+}
diff --git a/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/IdentityTranslatorTest.java b/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/IdentityTranslatorTest.java
new file mode 100644
index 0000000..bb02522
--- /dev/null
+++ b/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/IdentityTranslatorTest.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yang.compiler.plugin.maven;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.junit.Test;
+import org.onosproject.yang.compiler.utils.io.YangPluginConfig;
+import org.onosproject.yang.compiler.utils.io.impl.YangFileScanner;
+import org.onosproject.yang.compiler.utils.io.impl.YangIoUtils;
+import org.onosproject.yang.compiler.parser.exceptions.ParserException;
+
+import java.io.File;
+import java.io.IOException;
+
+/**
+ * Translator test case for identity.
+ */
+public class IdentityTranslatorTest {
+
+ private final YangUtilManager utilManager = new YangUtilManager();
+ private static final String DIR = "target/identity/";
+ private static final String COMP = System.getProperty("user.dir") + File
+ .separator + DIR;
+
+ /**
+ * Checks translation should not result in any exception.
+ *
+ * @throws MojoExecutionException
+ */
+ @Test
+ public void processTranslator() throws IOException,
+ ParserException, MojoExecutionException {
+ YangIoUtils.deleteDirectory(DIR);
+ String searchDir = "src/test/resources/identityTranslator";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ utilManager.resolveDependenciesUsingLinker();
+
+ YangPluginConfig yangPluginConfig = new YangPluginConfig();
+ yangPluginConfig.setCodeGenDir(DIR);
+ utilManager.translateToJava(yangPluginConfig);
+ YangPluginConfig.compileCode(COMP);
+ YangIoUtils.deleteDirectory(DIR);
+ }
+}
diff --git a/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/IncludeReferenceWithPrefix.java b/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/IncludeReferenceWithPrefix.java
new file mode 100644
index 0000000..fc35b92
--- /dev/null
+++ b/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/IncludeReferenceWithPrefix.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yang.compiler.plugin.maven;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.junit.Test;
+import org.onosproject.yang.compiler.utils.io.YangPluginConfig;
+import org.onosproject.yang.compiler.utils.io.impl.YangFileScanner;
+import org.onosproject.yang.compiler.utils.io.impl.YangIoUtils;
+import org.onosproject.yang.compiler.parser.exceptions.ParserException;
+
+import java.io.File;
+import java.io.IOException;
+
+/**
+ * Test cases for testing YANG schema node.
+ */
+public class IncludeReferenceWithPrefix {
+
+ private final YangUtilManager utilManager = new YangUtilManager();
+
+ /**
+ * Checks method to get schema node from map.
+ *
+ * @throws MojoExecutionException
+ */
+ @Test
+ public void processRefToIncludeWithPrefix() throws IOException, ParserException, MojoExecutionException {
+
+ String dir = "target/refincludecontentwithprefix/";
+ YangIoUtils.deleteDirectory(dir);
+ String searchDir = "src/test/resources/refincludecontentwithprefix";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ utilManager.resolveDependenciesUsingLinker();
+ YangPluginConfig yangPluginConfig = new YangPluginConfig();
+ yangPluginConfig.setCodeGenDir(dir);
+ utilManager.translateToJava(yangPluginConfig);
+ String dir1 = System.getProperty("user.dir") + File.separator + dir;
+ YangPluginConfig.compileCode(dir1);
+ YangIoUtils.deleteDirectory(dir);
+ }
+}
diff --git a/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/InterFileIdentityLinkingTest.java b/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/InterFileIdentityLinkingTest.java
new file mode 100644
index 0000000..544047c
--- /dev/null
+++ b/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/InterFileIdentityLinkingTest.java
@@ -0,0 +1,684 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.yang.compiler.plugin.maven;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.onosproject.yang.compiler.datamodel.YangDerivedInfo;
+import org.onosproject.yang.compiler.datamodel.YangIdentity;
+import org.onosproject.yang.compiler.datamodel.YangIdentityRef;
+import org.onosproject.yang.compiler.datamodel.YangLeaf;
+import org.onosproject.yang.compiler.datamodel.YangLeafList;
+import org.onosproject.yang.compiler.datamodel.YangModule;
+import org.onosproject.yang.compiler.datamodel.YangNode;
+import org.onosproject.yang.compiler.datamodel.YangType;
+import org.onosproject.yang.compiler.datamodel.YangTypeDef;
+import org.onosproject.yang.compiler.datamodel.utils.ResolvableStatus;
+import org.onosproject.yang.compiler.datamodel.utils.builtindatatype.YangDataTypes;
+import org.onosproject.yang.compiler.linker.exceptions.LinkerException;
+import org.onosproject.yang.compiler.linker.impl.YangLinkerManager;
+import org.onosproject.yang.compiler.utils.io.YangPluginConfig;
+import org.onosproject.yang.compiler.utils.io.impl.YangFileScanner;
+import org.onosproject.yang.compiler.utils.io.impl.YangIoUtils;
+import org.onosproject.yang.compiler.parser.exceptions.ParserException;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ListIterator;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+import static org.onosproject.yang.compiler.datamodel.YangNodeType.MODULE_NODE;
+import static org.onosproject.yang.compiler.datamodel.utils.builtindatatype.YangDataTypes.IDENTITYREF;
+import static org.onosproject.yang.compiler.linker.impl.YangLinkerUtils.updateFilePriority;
+
+/**
+ * Test cases for testing inter file linking for identity.
+ */
+public class InterFileIdentityLinkingTest {
+
+ private final YangUtilManager utilManager = new YangUtilManager();
+ private final YangLinkerManager yangLinkerManager = new YangLinkerManager();
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ /**
+ * Checks inter file feature linking with imported file.
+ */
+ @Test
+ public void processIdentityInImportedFile()
+ throws IOException, ParserException, MojoExecutionException {
+
+ String searchDir = "src/test/resources/interfileidentityimport";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+
+ YangNode selfNode = null;
+ YangNode refNode1 = null;
+ YangNode refNode2 = null;
+
+ // Create YANG node set
+ yangLinkerManager.createYangNodeSet(utilManager.getYangNodeSet());
+
+ // Add references to import list.
+ yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
+
+ updateFilePriority(utilManager.getYangNodeSet());
+
+ // Carry out inter-file linking.
+ yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet());
+
+ for (YangNode rootNode : utilManager.getYangNodeSet()) {
+ if (rootNode.getName().equals("IdentityIntraFile")) {
+ selfNode = rootNode;
+ } else if (rootNode.getName().equals("IdentityInModule")) {
+ refNode1 = rootNode;
+ } else {
+ refNode2 = rootNode;
+ }
+ }
+
+ // Check whether the data model tree returned is of type module.
+ assertThat(selfNode instanceof YangModule, is(true));
+
+ // Check whether the node type is set properly to module.
+ assertThat(selfNode.getNodeType(), is(MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) selfNode;
+ assertThat(yangNode.getName(), is("IdentityIntraFile"));
+
+ YangIdentity yangIdentity = (YangIdentity) yangNode.getChild();
+ assertThat(yangIdentity.getName(), is("ipv4-address-family"));
+ assertThat(yangIdentity.getBaseNode().getBaseIdentifier().getName(), is("ref-address-family"));
+ assertThat(yangIdentity.getBaseNode().getReferredIdentity().getName(), is("ref-address-family"));
+ assertThat(yangIdentity.getBaseNode().getResolvableStatus(), is(ResolvableStatus.RESOLVED));
+
+ yangIdentity = (YangIdentity) yangNode.getChild().getNextSibling();
+ assertThat(yangIdentity.getName(), is("ipv6-address-family"));
+ assertThat(yangIdentity.getBaseNode().getBaseIdentifier().getName(), is("ref-address-family"));
+ assertThat(yangIdentity.getBaseNode().getReferredIdentity().getName(), is("ref-address-family"));
+ assertThat(yangIdentity.getBaseNode().getResolvableStatus(), is(ResolvableStatus.RESOLVED));
+
+ ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getName(), is("tunnel"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("identityref"));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.IDENTITYREF));
+ YangIdentityRef yangIdentityRef = (YangIdentityRef) leafInfo.getDataType().getDataTypeExtendedInfo();
+ assertThat(yangIdentityRef.getName(), is("ref-address-family"));
+ assertThat(yangIdentityRef.getBaseIdentity().getName(), is("ref-address-family"));
+ assertThat(yangIdentityRef.getReferredIdentity().getName(), is("ref-address-family"));
+ assertThat(yangIdentityRef.getResolvableStatus(), is(ResolvableStatus.RESOLVED));
+
+ ListIterator<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator();
+ YangLeafList leafListInfo = leafListIterator.next();
+
+ // Check whether the information in the leaf is correct.
+ assertThat(leafListInfo.getName(), is("network-ref"));
+ assertThat(leafListInfo.getDataType().getDataTypeName(), is("identityref"));
+ assertThat(leafListInfo.getDataType().getDataType(), is(YangDataTypes.IDENTITYREF));
+ yangIdentityRef = (YangIdentityRef) (leafListInfo.getDataType().getDataTypeExtendedInfo());
+ assertThat(yangIdentityRef.getBaseIdentity().getName(), is("ref-address-family"));
+ assertThat(yangIdentityRef.getReferredIdentity().getName(), is("ref-address-family"));
+ assertThat(yangIdentityRef.getResolvableStatus(), is(ResolvableStatus.RESOLVED));
+
+ }
+
+ @Test
+ public void processTranslator() throws IOException, ParserException, MojoExecutionException {
+
+ YangIoUtils.deleteDirectory("target/identityTranslator/");
+ String searchDir = "src/test/resources/interfileidentityimport";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ utilManager.resolveDependenciesUsingLinker();
+
+ YangPluginConfig yangPluginConfig = new YangPluginConfig();
+ yangPluginConfig.setCodeGenDir("target/identityTranslator/");
+ utilManager.translateToJava(yangPluginConfig);
+ YangPluginConfig.compileCode(System.getProperty("user.dir") + File
+ .separator + "target/identityTranslator/");
+ YangIoUtils.deleteDirectory("target/identityTranslator/");
+ }
+
+ /**
+ * Checks inter file feature linking with included file.
+ */
+ @Test
+ public void processIdentityInIncludedFile()
+ throws IOException, ParserException, MojoExecutionException {
+
+ String searchDir = "src/test/resources/interfileidentityinlude";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+
+ YangNode selfNode = null;
+ YangNode refNode1 = null;
+ YangNode refNode2 = null;
+
+ // Create YANG node set
+ yangLinkerManager.createYangNodeSet(utilManager.getYangNodeSet());
+
+ // Carry out linking of sub module with module.
+ yangLinkerManager.linkSubModulesToParentModule(utilManager.getYangNodeSet());
+
+ // Add references to import list.
+ yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
+
+ // Add references to include list.
+ yangLinkerManager.addRefToYangFilesIncludeList(utilManager.getYangNodeSet());
+
+ updateFilePriority(utilManager.getYangNodeSet());
+
+ // Carry out inter-file linking.
+ yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet());
+
+ for (YangNode rootNode : utilManager.getYangNodeSet()) {
+ if (rootNode.getName().equals("syslog3")) {
+ selfNode = rootNode;
+ } else if (rootNode.getName().equals("syslog4")) {
+ refNode1 = rootNode;
+ } else {
+ refNode2 = rootNode;
+ }
+ }
+
+ // Check whether the data model tree returned is of type module.
+ assertThat(selfNode instanceof YangModule, is(true));
+
+ // Check whether the node type is set properly to module.
+ assertThat(selfNode.getNodeType(), is(MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) selfNode;
+ assertThat(yangNode.getName(), is("syslog3"));
+
+ YangIdentity yangIdentity = (YangIdentity) yangNode.getChild();
+ assertThat(yangIdentity.getName(), is("ipv4-address-family"));
+ assertThat(yangIdentity.getBaseNode().getBaseIdentifier().getName(), is("ref-address-family"));
+ assertThat(yangIdentity.getBaseNode().getReferredIdentity().getName(), is("ref-address-family"));
+ assertThat(yangIdentity.getBaseNode().getResolvableStatus(), is(ResolvableStatus.RESOLVED));
+
+ yangIdentity = (YangIdentity) yangNode.getChild().getNextSibling();
+ assertThat(yangIdentity.getName(), is("ipv6-address-family"));
+ assertThat(yangIdentity.getBaseNode().getBaseIdentifier().getName(), is("ref-address-family"));
+ assertThat(yangIdentity.getBaseNode().getReferredIdentity().getName(), is("ref-address-family"));
+ assertThat(yangIdentity.getBaseNode().getResolvableStatus(), is(ResolvableStatus.RESOLVED));
+
+ ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getName(), is("tunnel"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("identityref"));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.IDENTITYREF));
+ YangIdentityRef yangIdentityRef = (YangIdentityRef) leafInfo.getDataType().getDataTypeExtendedInfo();
+ assertThat(yangIdentityRef.getName(), is("ref-address-family"));
+ assertThat(yangIdentityRef.getBaseIdentity().getName(), is("ref-address-family"));
+ assertThat(yangIdentityRef.getReferredIdentity().getName(), is("ref-address-family"));
+ assertThat(yangIdentityRef.getResolvableStatus(), is(ResolvableStatus.RESOLVED));
+
+ ListIterator<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator();
+ YangLeafList leafListInfo = leafListIterator.next();
+
+ // Check whether the information in the leaf is correct.
+ assertThat(leafListInfo.getName(), is("network-ref"));
+ assertThat(leafListInfo.getDataType().getDataTypeName(), is("identityref"));
+ assertThat(leafListInfo.getDataType().getDataType(), is(YangDataTypes.IDENTITYREF));
+ yangIdentityRef = (YangIdentityRef) (leafListInfo.getDataType().getDataTypeExtendedInfo());
+ assertThat(yangIdentityRef.getBaseIdentity().getName(), is("ref-address-family"));
+ assertThat(yangIdentityRef.getReferredIdentity().getName(), is("ref-address-family"));
+ assertThat(yangIdentityRef.getResolvableStatus(), is(ResolvableStatus.RESOLVED));
+ }
+
+ /**
+ * Checks inter file feature linking with imported file with dependency.
+ */
+ @Test
+ public void processIdentityInImportedFileWithDependency()
+ throws IOException, ParserException, MojoExecutionException {
+
+ String searchDir = "src/test/resources/interfileidentityimportdependency";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+
+ YangNode selfNode = null;
+ YangNode refNode1 = null;
+ YangNode refNode2 = null;
+
+ // Create YANG node set
+ yangLinkerManager.createYangNodeSet(utilManager.getYangNodeSet());
+
+ // Add references to import list.
+ yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
+
+ updateFilePriority(utilManager.getYangNodeSet());
+
+ // Carry out inter-file linking.
+ yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet());
+
+ for (YangNode rootNode : utilManager.getYangNodeSet()) {
+ if (rootNode.getName().equals("syslog1")) {
+ selfNode = rootNode;
+ } else if (rootNode.getName().equals("syslog2")) {
+ refNode1 = rootNode;
+ } else {
+ refNode2 = rootNode;
+ }
+ }
+
+ // Check whether the data model tree returned is of type module.
+ assertThat(selfNode instanceof YangModule, is(true));
+
+ // Check whether the node type is set properly to module.
+ assertThat(selfNode.getNodeType(), is(MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) selfNode;
+ assertThat(yangNode.getName(), is("syslog1"));
+
+ YangIdentity yangIdentity = (YangIdentity) yangNode.getChild();
+ assertThat(yangIdentity.getName(), is("ipv4-address-family"));
+ assertThat(yangIdentity.getBaseNode().getBaseIdentifier().getName(), is("ref-address-family"));
+ assertThat(yangIdentity.getBaseNode().getReferredIdentity().getName(), is("ref-address-family"));
+ assertThat(yangIdentity.getBaseNode().getResolvableStatus(), is(ResolvableStatus.RESOLVED));
+
+ yangIdentity = (YangIdentity) yangNode.getChild().getNextSibling();
+ assertThat(yangIdentity.getName(), is("ipv6-address-family"));
+ assertThat(yangIdentity.getBaseNode().getBaseIdentifier().getName(), is("ref-address-family"));
+ assertThat(yangIdentity.getBaseNode().getReferredIdentity().getName(), is("ref-address-family"));
+ assertThat(yangIdentity.getBaseNode().getResolvableStatus(), is(ResolvableStatus.RESOLVED));
+
+ ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getName(), is("tunnel"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("identityref"));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.IDENTITYREF));
+ YangIdentityRef yangIdentityRef = (YangIdentityRef) leafInfo.getDataType().getDataTypeExtendedInfo();
+ assertThat(yangIdentityRef.getName(), is("ref-address-family"));
+ assertThat(yangIdentityRef.getBaseIdentity().getName(), is("ref-address-family"));
+ assertThat(yangIdentityRef.getReferredIdentity().getName(), is("ref-address-family"));
+ assertThat(yangIdentityRef.getResolvableStatus(), is(ResolvableStatus.RESOLVED));
+
+ ListIterator<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator();
+ YangLeafList leafListInfo = leafListIterator.next();
+
+ // Check whether the information in the leaf is correct.
+ assertThat(leafListInfo.getName(), is("network-ref"));
+ assertThat(leafListInfo.getDataType().getDataTypeName(), is("identityref"));
+ assertThat(leafListInfo.getDataType().getDataType(), is(YangDataTypes.IDENTITYREF));
+ yangIdentityRef = (YangIdentityRef) (leafListInfo.getDataType().getDataTypeExtendedInfo());
+ assertThat(yangIdentityRef.getBaseIdentity().getName(), is("ref-address-family"));
+ assertThat(yangIdentityRef.getReferredIdentity().getName(), is("ref-address-family"));
+ assertThat(yangIdentityRef.getResolvableStatus(), is(ResolvableStatus.RESOLVED));
+ }
+
+ /**
+ * Checks inter file feature linking with included file with dependency.
+ */
+ @Test
+ public void processIdentityInIncludedFileWithDependency()
+ throws IOException, ParserException, MojoExecutionException {
+
+ String searchDir = "src/test/resources/interfileidentityincludedependency";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+
+ YangNode selfNode = null;
+ YangNode refNode1 = null;
+ YangNode refNode2 = null;
+
+ // Create YANG node set
+ yangLinkerManager.createYangNodeSet(utilManager.getYangNodeSet());
+
+ // Carry out linking of sub module with module.
+ yangLinkerManager.linkSubModulesToParentModule(utilManager.getYangNodeSet());
+
+ // Add references to include list.
+ yangLinkerManager.addRefToYangFilesIncludeList(utilManager.getYangNodeSet());
+
+ // Add references to import list.
+ yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
+
+ updateFilePriority(utilManager.getYangNodeSet());
+
+ // Carry out inter-file linking.
+ yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet());
+
+ for (YangNode rootNode : utilManager.getYangNodeSet()) {
+ if (rootNode.getName().equals("syslog1")) {
+ selfNode = rootNode;
+ } else if (rootNode.getName().equals("syslog2")) {
+ refNode1 = rootNode;
+ } else {
+ refNode2 = rootNode;
+ }
+ }
+
+ // Check whether the data model tree returned is of type module.
+ assertThat(selfNode instanceof YangModule, is(true));
+
+ // Check whether the node type is set properly to module.
+ assertThat(selfNode.getNodeType(), is(MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) selfNode;
+ assertThat(yangNode.getName(), is("syslog1"));
+
+ YangIdentity yangIdentity = (YangIdentity) yangNode.getChild();
+ assertThat(yangIdentity.getName(), is("ipv4-address-family"));
+ assertThat(yangIdentity.getBaseNode().getBaseIdentifier().getName(), is("ref-address-family"));
+ assertThat(yangIdentity.getBaseNode().getReferredIdentity().getName(), is("ref-address-family"));
+ assertThat(yangIdentity.getBaseNode().getResolvableStatus(), is(ResolvableStatus.RESOLVED));
+
+ yangIdentity = (YangIdentity) yangNode.getChild().getNextSibling();
+ assertThat(yangIdentity.getName(), is("ipv6-address-family"));
+ assertThat(yangIdentity.getBaseNode().getBaseIdentifier().getName(), is("ref-address-family"));
+ assertThat(yangIdentity.getBaseNode().getReferredIdentity().getName(), is("ref-address-family"));
+ assertThat(yangIdentity.getBaseNode().getResolvableStatus(), is(ResolvableStatus.RESOLVED));
+
+ ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getName(), is("tunnel"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("identityref"));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.IDENTITYREF));
+ YangIdentityRef yangIdentityRef = (YangIdentityRef) leafInfo.getDataType().getDataTypeExtendedInfo();
+ assertThat(yangIdentityRef.getName(), is("ref-address-family"));
+ assertThat(yangIdentityRef.getBaseIdentity().getName(), is("ref-address-family"));
+ assertThat(yangIdentityRef.getReferredIdentity().getName(), is("ref-address-family"));
+ assertThat(yangIdentityRef.getResolvableStatus(), is(ResolvableStatus.RESOLVED));
+
+ ListIterator<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator();
+ YangLeafList leafListInfo = leafListIterator.next();
+
+ // Check whether the information in the leaf is correct.
+ assertThat(leafListInfo.getName(), is("network-ref"));
+ assertThat(leafListInfo.getDataType().getDataTypeName(), is("identityref"));
+ assertThat(leafListInfo.getDataType().getDataType(), is(YangDataTypes.IDENTITYREF));
+ yangIdentityRef = (YangIdentityRef) (leafListInfo.getDataType().getDataTypeExtendedInfo());
+ assertThat(yangIdentityRef.getBaseIdentity().getName(), is("ref-address-family"));
+ assertThat(yangIdentityRef.getReferredIdentity().getName(), is("ref-address-family"));
+ assertThat(yangIdentityRef.getResolvableStatus(), is(ResolvableStatus.RESOLVED));
+ }
+
+ /**
+ * Checks inter file feature linking with imported file with dependency
+ * feature undefined.
+ */
+ @Test
+ public void processIdentityInImportedFileWithDependencyUndefined()
+ throws IOException, LinkerException, MojoExecutionException {
+ thrown.expect(LinkerException.class);
+ thrown.expectMessage("YANG file error: Unable to find base identity for given base");
+
+ String searchDir = "src/test/resources/interfileidentityimportdependencyUndefined";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+
+ YangNode selfNode = null;
+ YangNode refNode1 = null;
+ YangNode refNode2 = null;
+
+ // Create YANG node set
+ yangLinkerManager.createYangNodeSet(utilManager.getYangNodeSet());
+
+ // Add references to import list.
+ yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
+
+ updateFilePriority(utilManager.getYangNodeSet());
+
+ // Carry out inter-file linking.
+ yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet());
+ }
+
+ /**
+ * Checks inter file feature linking with included file with dependency
+ * feature undefined.
+ */
+ @Test
+ public void processIdentityInIncludedFileWithDependencyUndefined()
+ throws IOException, LinkerException, MojoExecutionException {
+ thrown.expect(LinkerException.class);
+ thrown.expectMessage("YANG file error: Unable to find base identity for given base");
+
+ String searchDir = "src/test/resources/interfileidentityincludedependencyUndefined";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+
+ // Create YANG node set
+ yangLinkerManager.createYangNodeSet(utilManager.getYangNodeSet());
+
+ // Carry out linking of sub module with module.
+ yangLinkerManager.linkSubModulesToParentModule(utilManager.getYangNodeSet());
+
+ // Add references to import list.
+ yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
+
+ // Add references to include list.
+ yangLinkerManager.addRefToYangFilesIncludeList(utilManager.getYangNodeSet());
+
+ // Update the priority for all the files.
+ updateFilePriority(utilManager.getYangNodeSet());
+
+ // Carry out inter-file linking.
+ yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet());
+ }
+
+ /**
+ * Checks inter file feature linking with imported file.
+ */
+ @Test
+ public void processIdentityTypedefUnresolvedInImportedFile()
+ throws IOException, ParserException, MojoExecutionException {
+
+ String searchDir = "src/test/resources/interfileidentitytypedef";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+
+ YangNode selfNode = null;
+ YangNode refNode1 = null;
+ YangNode refNode2 = null;
+
+ // Create YANG node set
+ yangLinkerManager.createYangNodeSet(utilManager.getYangNodeSet());
+
+ // Add references to import list.
+ yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
+
+ updateFilePriority(utilManager.getYangNodeSet());
+
+ // Carry out inter-file linking.
+ yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet());
+
+ for (YangNode rootNode : utilManager.getYangNodeSet()) {
+ if (rootNode.getName().equals("IdentityIntraFile")) {
+ selfNode = rootNode;
+ } else if (rootNode.getName().equals("IdentityInModule")) {
+ refNode1 = rootNode;
+ } else {
+ refNode2 = rootNode;
+ }
+ }
+ // Check whether the data model tree returned is of type module.
+ assertThat(selfNode instanceof YangModule, is(true));
+
+ // Check whether the node type is set properly to module.
+ assertThat(selfNode.getNodeType(), is(MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) selfNode;
+ assertThat(yangNode.getName(), is("IdentityIntraFile"));
+
+ YangIdentity yangIdentity = (YangIdentity) yangNode.getChild();
+ assertThat(yangIdentity.getName(), is("ipv4-address-family"));
+ assertThat(yangIdentity.getBaseNode().getBaseIdentifier().getName(), is("ref-address-family"));
+ assertThat(yangIdentity.getBaseNode().getReferredIdentity().getName(), is("ref-address-family"));
+ assertThat(yangIdentity.getBaseNode().getResolvableStatus(), is(ResolvableStatus.RESOLVED));
+
+ yangIdentity = (YangIdentity) yangNode.getChild().getNextSibling();
+ assertThat(yangIdentity.getName(), is("ipv6-address-family"));
+ assertThat(yangIdentity.getBaseNode().getBaseIdentifier().getName(), is("ref-address-family"));
+ assertThat(yangIdentity.getBaseNode().getReferredIdentity().getName(), is("ref-address-family"));
+ assertThat(yangIdentity.getBaseNode().getResolvableStatus(), is(ResolvableStatus.RESOLVED));
+
+ ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getName(), is("tunnel"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("identityref"));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.IDENTITYREF));
+ YangIdentityRef yangIdentityRef = (YangIdentityRef) leafInfo.getDataType().getDataTypeExtendedInfo();
+ assertThat(yangIdentityRef.getName(), is("ref-address-family"));
+ assertThat(yangIdentityRef.getBaseIdentity().getName(), is("ref-address-family"));
+ assertThat(yangIdentityRef.getReferredIdentity().getName(), is("ref-address-family"));
+ assertThat(yangIdentityRef.getResolvableStatus(), is(ResolvableStatus.RESOLVED));
+
+ ListIterator<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator();
+ YangLeafList leafListInfo = leafListIterator.next();
+
+ // Check whether the information in the leaf is correct.
+ assertThat(leafListInfo.getName(), is("network-ref"));
+ assertThat(leafListInfo.getDataType().getDataTypeName(), is("identityref"));
+ assertThat(leafListInfo.getDataType().getDataType(), is(YangDataTypes.IDENTITYREF));
+ yangIdentityRef = (YangIdentityRef) (leafListInfo.getDataType().getDataTypeExtendedInfo());
+ // Check whether leafref type got resolved.
+ assertThat(yangIdentityRef.getResolvableStatus(), is(ResolvableStatus.RESOLVED));
+
+ YangTypeDef typedef = (YangTypeDef) yangNode.getChild().getNextSibling().getNextSibling();
+ assertThat(typedef.getName(), is("type15"));
+
+ YangType type = typedef.getTypeList().iterator().next();
+ assertThat(type.getDataType(), is(YangDataTypes.IDENTITYREF));
+ assertThat(type.getDataTypeName(), is("identityref"));
+
+ YangIdentityRef identityRef = (YangIdentityRef) type.getDataTypeExtendedInfo();
+ assertThat(identityRef.getName(), is("ref-address-family"));
+ assertThat(identityRef.getBaseIdentity().getName(), is("ref-address-family"));
+ assertThat(identityRef.getResolvableStatus(),
+ is(ResolvableStatus.RESOLVED));
+ }
+
+ /**
+ * Checks inter file feature linking with imported file.
+ */
+ @Test
+ public void processIdentityTypedefInImportedFile()
+ throws IOException, ParserException, MojoExecutionException {
+
+ String searchDir = "src/test/resources/interfileidentitytypedef";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+
+ YangNode selfNode = null;
+ YangNode refNode1 = null;
+ YangNode refNode2 = null;
+
+ // Create YANG node set
+ yangLinkerManager.createYangNodeSet(utilManager.getYangNodeSet());
+
+ // Add references to import list.
+ yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
+
+ updateFilePriority(utilManager.getYangNodeSet());
+
+ // Carry out inter-file linking.
+ yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet());
+
+ for (YangNode rootNode : utilManager.getYangNodeSet()) {
+ if (rootNode.getName().equals("IdentityTypedef")) {
+ selfNode = rootNode;
+ } else if (rootNode.getName().equals("IdentityInModule")) {
+ refNode1 = rootNode;
+ } else {
+ refNode2 = rootNode;
+ }
+ }
+
+ // Check whether the data model tree returned is of type module.
+ assertThat(selfNode instanceof YangModule, is(true));
+
+ // Check whether the node type is set properly to module.
+ assertThat(selfNode.getNodeType(), is(MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) selfNode;
+ assertThat(yangNode.getName(), is("IdentityTypedef"));
+
+ YangIdentity yangIdentity = (YangIdentity) yangNode.getChild();
+ assertThat(yangIdentity.getName(), is("ipv4-address-family"));
+ assertThat(yangIdentity.getBaseNode().getBaseIdentifier().getName(), is("ref-address-family"));
+ assertThat(yangIdentity.getBaseNode().getReferredIdentity().getName(), is("ref-address-family"));
+ assertThat(yangIdentity.getBaseNode().getResolvableStatus(), is(ResolvableStatus.RESOLVED));
+
+ yangIdentity = (YangIdentity) yangNode.getChild().getNextSibling();
+ assertThat(yangIdentity.getName(), is("ipv6-address-family"));
+ assertThat(yangIdentity.getBaseNode().getBaseIdentifier().getName(), is("ref-address-family"));
+ assertThat(yangIdentity.getBaseNode().getReferredIdentity().getName(), is("ref-address-family"));
+ assertThat(yangIdentity.getBaseNode().getResolvableStatus(), is(ResolvableStatus.RESOLVED));
+
+ YangTypeDef typedef = (YangTypeDef) yangNode.getChild().getNextSibling().getNextSibling();
+ assertThat(typedef.getName(), is("type15"));
+
+ YangType type = typedef.getTypeList().iterator().next();
+ assertThat(type.getDataType(), is(YangDataTypes.IDENTITYREF));
+ assertThat(type.getDataTypeName(), is("identityref"));
+
+ YangIdentityRef identityRef = (YangIdentityRef) type.getDataTypeExtendedInfo();
+ assertThat(identityRef.getName(), is("ref-address-family"));
+ assertThat(identityRef.getBaseIdentity().getName(), is("ref-address-family"));
+
+ ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getName(), is("tunnel"));
+ YangDerivedInfo info = (YangDerivedInfo) leafInfo.getDataType()
+ .getDataTypeExtendedInfo();
+ assertThat(info.getEffectiveBuiltInType(), is(IDENTITYREF));
+ YangType type1 = info.getReferredTypeDef().getTypeList().get(0);
+ YangIdentityRef idRef1 =
+ (YangIdentityRef) type1.getDataTypeExtendedInfo();
+ assertThat(idRef1.getResolvableStatus(),
+ is(ResolvableStatus.RESOLVED));
+
+ ListIterator<YangLeafList> itr =
+ yangNode.getListOfLeafList().listIterator();
+ YangLeafList leafListInfo = itr.next();
+
+ // Check whether the information in the leaf is correct.
+ assertThat(leafListInfo.getName(), is("network-ref"));
+ info = (YangDerivedInfo) leafListInfo.getDataType()
+ .getDataTypeExtendedInfo();
+ assertThat(info.getEffectiveBuiltInType(), is(IDENTITYREF));
+ type1 = info.getReferredTypeDef().getTypeList().get(0);
+ idRef1 = (YangIdentityRef) type1.getDataTypeExtendedInfo();
+ assertThat(idRef1.getResolvableStatus(), is(ResolvableStatus.RESOLVED));
+ }
+}
diff --git a/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/InterFileIfFeatureLinkingTest.java b/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/InterFileIfFeatureLinkingTest.java
new file mode 100644
index 0000000..afcee89
--- /dev/null
+++ b/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/InterFileIfFeatureLinkingTest.java
@@ -0,0 +1,469 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yang.compiler.plugin.maven;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.hamcrest.core.Is;
+import org.junit.Test;
+import org.onosproject.yang.compiler.datamodel.YangContainer;
+import org.onosproject.yang.compiler.datamodel.YangFeature;
+import org.onosproject.yang.compiler.datamodel.YangIfFeature;
+import org.onosproject.yang.compiler.datamodel.YangLeaf;
+import org.onosproject.yang.compiler.datamodel.YangModule;
+import org.onosproject.yang.compiler.datamodel.YangNode;
+import org.onosproject.yang.compiler.datamodel.utils.ResolvableStatus;
+import org.onosproject.yang.compiler.linker.impl.YangLinkerManager;
+import org.onosproject.yang.compiler.linker.impl.YangLinkerUtils;
+import org.onosproject.yang.compiler.utils.io.impl.YangFileScanner;
+import org.onosproject.yang.compiler.parser.exceptions.ParserException;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.ListIterator;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+import static org.onosproject.yang.compiler.datamodel.YangNodeType.MODULE_NODE;
+
+/**
+ * Test cases for testing inter file linking.
+ */
+public class InterFileIfFeatureLinkingTest {
+
+ private final YangUtilManager utilManager = new YangUtilManager();
+ private final YangLinkerManager yangLinkerManager = new YangLinkerManager();
+
+ /**
+ * Checks inter file feature linking with imported file.
+ */
+ @Test
+ public void processFeatureInImportedFile()
+ throws IOException, ParserException, MojoExecutionException {
+
+ String searchDir = "src/test/resources/interfilefeatureimport";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+
+ YangNode selfNode = null;
+ YangNode refNode1 = null;
+ YangNode refNode2 = null;
+
+ // Create YANG node set
+ yangLinkerManager.createYangNodeSet(utilManager.getYangNodeSet());
+
+ // Add references to import list.
+ yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
+
+ YangLinkerUtils.updateFilePriority(utilManager.getYangNodeSet());
+
+ // Carry out inter-file linking.
+ yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet());
+
+ for (YangNode rootNode : utilManager.getYangNodeSet()) {
+ if (rootNode.getName().equals("syslog1")) {
+ selfNode = rootNode;
+ } else if (rootNode.getName().equals("syslog2")) {
+ refNode1 = rootNode;
+ } else {
+ refNode2 = rootNode;
+ }
+ }
+ // Check whether the data model tree returned is of type module.
+ assertThat(selfNode instanceof YangModule, is(true));
+
+ // Check whether the node type is set properly to module.
+ assertThat(selfNode.getNodeType(), is(MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) selfNode;
+ assertThat(yangNode.getName(), is("syslog1"));
+
+ ListIterator<YangFeature> featureIterator = yangNode.getFeatureList().listIterator();
+ YangFeature feature = featureIterator.next();
+ assertThat(feature.getName(), is("frr-te"));
+
+ YangIfFeature ifFeature = feature.getIfFeatureList().iterator().next();
+ assertThat(ifFeature.getName().getName(), is("p2mp-te"));
+ assertThat(ifFeature.getName().getPrefix(), is("sys2"));
+ assertThat(ifFeature.getResolvableStatus(), Is.is(ResolvableStatus.RESOLVED));
+
+ YangContainer container = (YangContainer) selfNode.getChild();
+ assertThat(container.getName(), is("speed"));
+ YangLeaf leaf = container.getListOfLeaf().iterator().next();
+ assertThat(leaf.getName(), is("local-storage-limit"));
+
+ List<YangIfFeature> ifFeatureList = leaf.getIfFeatureList();
+ ifFeature = ifFeatureList.iterator().next();
+ assertThat(ifFeature.getName().getName(), is("frr-te"));
+ assertThat(ifFeature.getResolvableStatus(), Is.is(ResolvableStatus.RESOLVED));
+ }
+
+ /**
+ * Checks inter file feature linking with included file.
+ */
+ @Test
+ public void processFeatureInIncludedFile()
+ throws IOException, ParserException, MojoExecutionException {
+
+ String searchDir = "src/test/resources/interfilefeatureinclude";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+
+ YangNode selfNode = null;
+ YangNode refNode1 = null;
+ YangNode refNode2 = null;
+
+ // Create YANG node set
+ yangLinkerManager.createYangNodeSet(utilManager.getYangNodeSet());
+
+ // Carry out linking of sub module with module.
+ yangLinkerManager.linkSubModulesToParentModule(utilManager.getYangNodeSet());
+
+ // Add references to import list.
+ yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
+
+ // Add references to include list.
+ yangLinkerManager.addRefToYangFilesIncludeList(utilManager.getYangNodeSet());
+
+ YangLinkerUtils.updateFilePriority(utilManager.getYangNodeSet());
+
+ // Carry out inter-file linking.
+ yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet());
+
+ for (YangNode rootNode : utilManager.getYangNodeSet()) {
+ if (rootNode.getName().equals("syslog3")) {
+ selfNode = rootNode;
+ } else if (rootNode.getName().equals("syslog4")) {
+ refNode1 = rootNode;
+ } else {
+ refNode2 = rootNode;
+ }
+ }
+
+ // Check whether the data model tree returned is of type module.
+ assertThat(selfNode instanceof YangModule, is(true));
+
+ // Check whether the node type is set properly to module.
+ assertThat(selfNode.getNodeType(), is(MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) selfNode;
+ assertThat(yangNode.getName(), is("syslog3"));
+
+ ListIterator<YangFeature> featureIterator = yangNode.getFeatureList().listIterator();
+ YangFeature feature = featureIterator.next();
+ assertThat(feature.getName(), is("frr-te"));
+
+ YangIfFeature ifFeature = feature.getIfFeatureList().iterator().next();
+ assertThat(ifFeature.getName().getName(), is("p2mp-te"));
+ assertThat(ifFeature.getResolvableStatus(), Is.is(ResolvableStatus.RESOLVED));
+
+ YangContainer container = (YangContainer) selfNode.getChild();
+ assertThat(container.getName(), is("speed"));
+ YangLeaf leaf = container.getListOfLeaf().iterator().next();
+ assertThat(leaf.getName(), is("local-storage-limit"));
+
+ List<YangIfFeature> ifFeatureList = leaf.getIfFeatureList();
+ ifFeature = ifFeatureList.iterator().next();
+ assertThat(ifFeature.getName().getName(), is("frr-te"));
+ assertThat(ifFeature.getResolvableStatus(), Is.is(ResolvableStatus.RESOLVED));
+ }
+
+ /**
+ * Checks inter file feature linking with imported file with dependency.
+ */
+ @Test
+ public void processFeatureInImportedFileWithDependency()
+ throws IOException, ParserException, MojoExecutionException {
+
+ String searchDir = "src/test/resources/interfilefeatureimportdependency";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+
+ YangNode selfNode = null;
+ YangNode refNode1 = null;
+ YangNode refNode2 = null;
+
+ // Create YANG node set
+ yangLinkerManager.createYangNodeSet(utilManager.getYangNodeSet());
+
+ // Add references to import list.
+ yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
+
+ // Update the priority for all the files.
+ YangLinkerUtils.updateFilePriority(utilManager.getYangNodeSet());
+
+ // Carry out inter-file linking.
+ yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet());
+
+ for (YangNode rootNode : utilManager.getYangNodeSet()) {
+ if (rootNode.getName().equals("syslog1")) {
+ selfNode = rootNode;
+ } else if (rootNode.getName().equals("syslog2")) {
+ refNode1 = rootNode;
+ } else {
+ refNode2 = rootNode;
+ }
+ }
+
+ // Check whether the data model tree returned is of type module.
+ assertThat(selfNode instanceof YangModule, is(true));
+
+ // Check whether the node type is set properly to module.
+ assertThat(selfNode.getNodeType(), is(MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) selfNode;
+ assertThat(yangNode.getName(), is("syslog1"));
+
+ ListIterator<YangFeature> featureIterator = yangNode.getFeatureList().listIterator();
+ YangFeature feature = featureIterator.next();
+ assertThat(feature.getName(), is("frr-te"));
+
+ YangIfFeature ifFeature = feature.getIfFeatureList().iterator().next();
+ assertThat(ifFeature.getName().getName(), is("p2mp-te"));
+ assertThat(ifFeature.getName().getPrefix(), is("sys2"));
+ assertThat(ifFeature.getResolvableStatus(), Is.is(ResolvableStatus.RESOLVED));
+
+ YangContainer container = (YangContainer) selfNode.getChild();
+ assertThat(container.getName(), is("speed"));
+ YangLeaf leaf = container.getListOfLeaf().iterator().next();
+ assertThat(leaf.getName(), is("local-storage-limit"));
+
+ List<YangIfFeature> ifFeatureList = leaf.getIfFeatureList();
+ ifFeature = ifFeatureList.iterator().next();
+ assertThat(ifFeature.getName().getName(), is("frr-te"));
+ assertThat(ifFeature.getResolvableStatus(), Is.is(ResolvableStatus.RESOLVED));
+ }
+
+ /**
+ * Checks inter file feature linking with included file with dependency.
+ */
+ @Test
+ public void processFeatureInIncludedFileWithDependency()
+ throws IOException, ParserException, MojoExecutionException {
+
+ String searchDir = "src/test/resources/interfilefeatureincludedependency";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+
+ YangNode selfNode = null;
+ YangNode refNode1 = null;
+ YangNode refNode2 = null;
+
+ // Create YANG node set
+ yangLinkerManager.createYangNodeSet(utilManager.getYangNodeSet());
+
+ // Carry out linking of sub module with module.
+ yangLinkerManager.linkSubModulesToParentModule(utilManager.getYangNodeSet());
+
+ // Add references to include list.
+ yangLinkerManager.addRefToYangFilesIncludeList(utilManager.getYangNodeSet());
+
+ // Add references to import list.
+ yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
+
+ YangLinkerUtils.updateFilePriority(utilManager.getYangNodeSet());
+
+ // Carry out inter-file linking.
+ yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet());
+
+ for (YangNode rootNode : utilManager.getYangNodeSet()) {
+ if (rootNode.getName().equals("syslog1")) {
+ selfNode = rootNode;
+ } else if (rootNode.getName().equals("syslog2")) {
+ refNode1 = rootNode;
+ } else {
+ refNode2 = rootNode;
+ }
+ }
+
+ // Check whether the data model tree returned is of type module.
+ assertThat(selfNode instanceof YangModule, is(true));
+
+ // Check whether the node type is set properly to module.
+ assertThat(selfNode.getNodeType(), is(MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) selfNode;
+ assertThat(yangNode.getName(), is("syslog1"));
+
+ ListIterator<YangFeature> featureIterator = yangNode.getFeatureList().listIterator();
+ YangFeature feature = featureIterator.next();
+ assertThat(feature.getName(), is("frr-te"));
+
+ YangIfFeature ifFeature = feature.getIfFeatureList().iterator().next();
+ assertThat(ifFeature.getName().getName(), is("p2mp-te"));
+ assertThat(ifFeature.getResolvableStatus(), Is.is(ResolvableStatus.RESOLVED));
+
+ YangContainer container = (YangContainer) selfNode.getChild();
+ assertThat(container.getName(), is("speed"));
+ YangLeaf leaf = container.getListOfLeaf().iterator().next();
+ assertThat(leaf.getName(), is("local-storage-limit"));
+
+ List<YangIfFeature> ifFeatureList = leaf.getIfFeatureList();
+ ifFeature = ifFeatureList.iterator().next();
+ assertThat(ifFeature.getName().getName(), is("frr-te"));
+ assertThat(ifFeature.getResolvableStatus(), Is.is(ResolvableStatus.RESOLVED));
+ }
+
+ /**
+ * Checks inter file feature linking with imported file with dependency
+ * feature undefined.
+ */
+ @Test
+ public void processFeatureInImportedFileWithDependencyUndefined()
+ throws IOException, ParserException, MojoExecutionException {
+
+ String searchDir = "src/test/resources/interfilefeatureimportdependencyUndefined";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+
+ YangNode selfNode = null;
+ YangNode refNode1 = null;
+ YangNode refNode2 = null;
+
+ // Create YANG node set
+ yangLinkerManager.createYangNodeSet(utilManager.getYangNodeSet());
+
+ // Add references to import list.
+ yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
+
+ YangLinkerUtils.updateFilePriority(utilManager.getYangNodeSet());
+
+ // Carry out inter-file linking.
+ yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet());
+
+ for (YangNode rootNode : utilManager.getYangNodeSet()) {
+ if (rootNode.getName().equals("syslog1")) {
+ selfNode = rootNode;
+ } else if (rootNode.getName().equals("syslog2")) {
+ refNode1 = rootNode;
+ } else {
+ refNode2 = rootNode;
+ }
+ }
+
+ // Check whether the data model tree returned is of type module.
+ assertThat(selfNode instanceof YangModule, is(true));
+
+ // Check whether the node type is set properly to module.
+ assertThat(selfNode.getNodeType(), is(MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) selfNode;
+ assertThat(yangNode.getName(), is("syslog1"));
+
+ ListIterator<YangFeature> featureIterator = yangNode.getFeatureList().listIterator();
+ YangFeature feature = featureIterator.next();
+ assertThat(feature.getName(), is("frr-te"));
+
+ YangIfFeature ifFeature = feature.getIfFeatureList().iterator().next();
+ assertThat(ifFeature.getName().getName(), is("p2mp-te"));
+ assertThat(ifFeature.getName().getPrefix(), is("sys2"));
+ assertThat(ifFeature.getResolvableStatus(), Is.is(ResolvableStatus.INTRA_FILE_RESOLVED));
+
+ YangContainer container = (YangContainer) selfNode.getChild();
+ assertThat(container.getName(), is("speed"));
+ YangLeaf leaf = container.getListOfLeaf().iterator().next();
+ assertThat(leaf.getName(), is("local-storage-limit"));
+
+ List<YangIfFeature> ifFeatureList = leaf.getIfFeatureList();
+ ifFeature = ifFeatureList.iterator().next();
+ assertThat(ifFeature.getName().getName(), is("frr-te"));
+ assertThat(ifFeature.getResolvableStatus(), Is.is(ResolvableStatus.INTRA_FILE_RESOLVED));
+ }
+
+ /**
+ * Checks inter file feature linking with included file with dependency
+ * feature undefined.
+ */
+ @Test
+ public void processFeatureInIncludedFileWithDependencyUndefined()
+ throws IOException, ParserException, MojoExecutionException {
+
+ String searchDir = "src/test/resources/interfilefeatureincludedependencyUndefined";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+
+ YangNode selfNode = null;
+ YangNode refNode1 = null;
+ YangNode refNode2 = null;
+
+ // Create YANG node set
+ yangLinkerManager.createYangNodeSet(utilManager.getYangNodeSet());
+
+ // Carry out linking of sub module with module.
+ yangLinkerManager.linkSubModulesToParentModule(utilManager.getYangNodeSet());
+
+ // Add references to import list.
+ yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
+
+ // Add references to include list.
+ yangLinkerManager.addRefToYangFilesIncludeList(utilManager.getYangNodeSet());
+
+ YangLinkerUtils.updateFilePriority(utilManager.getYangNodeSet());
+
+ // Carry out inter-file linking.
+ yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet());
+
+ for (YangNode rootNode : utilManager.getYangNodeSet()) {
+ if (rootNode.getName().equals("syslog1")) {
+ selfNode = rootNode;
+ } else if (rootNode.getName().equals("syslog2")) {
+ refNode1 = rootNode;
+ } else {
+ refNode2 = rootNode;
+ }
+ }
+
+ // Check whether the data model tree returned is of type module.
+ assertThat(selfNode instanceof YangModule, is(true));
+
+ // Check whether the node type is set properly to module.
+ assertThat(selfNode.getNodeType(), is(MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) selfNode;
+ assertThat(yangNode.getName(), is("syslog1"));
+
+ ListIterator<YangFeature> featureIterator = yangNode.getFeatureList().listIterator();
+ YangFeature feature = featureIterator.next();
+ assertThat(feature.getName(), is("frr-te"));
+
+ YangIfFeature ifFeature = feature.getIfFeatureList().iterator().next();
+ assertThat(ifFeature.getName().getName(), is("p2mp-te"));
+ assertThat(ifFeature.getResolvableStatus(), Is.is(ResolvableStatus.INTRA_FILE_RESOLVED));
+
+ YangContainer container = (YangContainer) selfNode.getChild();
+ assertThat(container.getName(), is("speed"));
+ YangLeaf leaf = container.getListOfLeaf().iterator().next();
+ assertThat(leaf.getName(), is("local-storage-limit"));
+
+ List<YangIfFeature> ifFeatureList = leaf.getIfFeatureList();
+ ifFeature = ifFeatureList.iterator().next();
+ assertThat(ifFeature.getName().getName(), is("frr-te"));
+ assertThat(ifFeature.getResolvableStatus(), Is.is(ResolvableStatus.INTRA_FILE_RESOLVED));
+ }
+}
+
diff --git a/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/InterFileLeafrefLinkingTest.java b/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/InterFileLeafrefLinkingTest.java
new file mode 100644
index 0000000..ebda757
--- /dev/null
+++ b/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/InterFileLeafrefLinkingTest.java
@@ -0,0 +1,438 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yang.compiler.plugin.maven;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.hamcrest.core.Is;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.onosproject.yang.compiler.datamodel.YangContainer;
+import org.onosproject.yang.compiler.datamodel.YangLeaf;
+import org.onosproject.yang.compiler.datamodel.YangLeafList;
+import org.onosproject.yang.compiler.datamodel.YangLeafRef;
+import org.onosproject.yang.compiler.datamodel.YangList;
+import org.onosproject.yang.compiler.datamodel.YangModule;
+import org.onosproject.yang.compiler.datamodel.YangNode;
+import org.onosproject.yang.compiler.datamodel.YangNodeType;
+import org.onosproject.yang.compiler.datamodel.utils.ResolvableStatus;
+import org.onosproject.yang.compiler.datamodel.utils.builtindatatype.YangDataTypes;
+import org.onosproject.yang.compiler.linker.impl.YangLinkerManager;
+import org.onosproject.yang.compiler.utils.io.impl.YangFileScanner;
+import org.onosproject.yang.compiler.parser.exceptions.ParserException;
+
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.ListIterator;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+import static org.onosproject.yang.compiler.datamodel.YangNodeType.MODULE_NODE;
+import static org.onosproject.yang.compiler.datamodel.utils.builtindatatype.YangDataTypes.LEAFREF;
+import static org.onosproject.yang.compiler.linker.impl.YangLinkerUtils.updateFilePriority;
+
+/**
+ * Test cases for testing leafref inter file linking.
+ */
+public class InterFileLeafrefLinkingTest {
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ private final YangUtilManager utilManager = new YangUtilManager();
+ private final YangLinkerManager yangLinkerManager = new YangLinkerManager();
+
+ /**
+ * Checks inter file leafref linking.
+ */
+ @Test
+ public void processInterFileLeafrefLinking()
+ throws IOException, ParserException, MojoExecutionException {
+
+ String searchDir = "src/test/resources/leafreflinker/interfile/interfileleafrefwithimport";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ YangNode refNode = null;
+ YangNode selfNode = null;
+
+ // Create YANG node set
+ yangLinkerManager.createYangNodeSet(utilManager.getYangNodeSet());
+
+ // Add references to import list.
+ yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
+
+ updateFilePriority(utilManager.getYangNodeSet());
+
+ // Carry out inter-file linking.
+ yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet());
+
+ Iterator<YangNode> yangNodeIterator = utilManager.getYangNodeSet().iterator();
+
+ YangNode rootNode = yangNodeIterator.next();
+
+ if (rootNode.getName().equals("module1")) {
+ selfNode = rootNode;
+ refNode = yangNodeIterator.next();
+ } else {
+ refNode = rootNode;
+ selfNode = yangNodeIterator.next();
+ }
+
+ // Check whether the data model tree returned is of type module.
+ assertThat(selfNode instanceof YangModule, is(true));
+
+ // Check whether the node type is set properly to module.
+ assertThat(selfNode.getNodeType(), is(MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) selfNode;
+ assertThat(yangNode.getName(), is("module1"));
+
+ ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("leafref"));
+ assertThat(leafInfo.getDataType().getDataType(), is(LEAFREF));
+
+ // Check whether the data model tree returned is of type module.
+ assertThat(refNode instanceof YangModule, is(true));
+
+ // Check whether the node type is set properly to module.
+ assertThat(refNode.getNodeType(), is(MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode1 = (YangModule) refNode;
+ assertThat(yangNode1.getName(), is("module2"));
+ YangLeaf leafInfo1 = yangNode1.getListOfLeaf().listIterator().next();
+
+ YangLeafRef leafref = (YangLeafRef) leafInfo.getDataType().getDataTypeExtendedInfo();
+
+ assertThat(leafref.getReferredLeafOrLeafList(), is(leafInfo1));
+ assertThat(leafref.getResolvableStatus(), Is.is(ResolvableStatus.RESOLVED));
+
+ assertThat(leafref.getEffectiveDataType().getDataType(),
+ is(YangDataTypes.STRING));
+ }
+
+ /**
+ * Checks inter file resolution when leafref from grouping refers to other file.
+ */
+ @Test
+ public void processInterFileLeafrefFromGroupingRefersToOtherFile()
+ throws IOException, ParserException {
+
+ String searchDir = "src/test/resources/leafreflinker/interfile/interfileleafreffromgroupingreferstootherfile";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ YangNode selfNode = null;
+ YangNode refNode = null;
+
+ // Create YANG node set
+ yangLinkerManager.createYangNodeSet(utilManager.getYangNodeSet());
+
+ // Add references to import list.
+ yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
+
+ updateFilePriority(utilManager.getYangNodeSet());
+
+ // Carry out inter-file linking.
+ yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet());
+
+ Iterator<YangNode> yangNodeIterator = utilManager.getYangNodeSet().iterator();
+
+ YangNode rootNode = yangNodeIterator.next();
+
+ if (rootNode.getName().equals("module1")) {
+ selfNode = rootNode;
+ refNode = yangNodeIterator.next();
+ } else {
+ refNode = rootNode;
+ selfNode = yangNodeIterator.next();
+ }
+
+ // Check whether the data model tree returned is of type module.
+ assertThat(selfNode instanceof YangModule, is(true));
+
+ // Check whether the node type is set properly to module.
+ assertThat(selfNode.getNodeType(), is(MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) selfNode;
+ assertThat(yangNode.getName(), is("module1"));
+
+ YangList list = (YangList) yangNode.getChild().getChild();
+ ListIterator<YangLeaf> leafIterator = list.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getName(), is("link-tp"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("leafref"));
+ assertThat(leafInfo.getDataType().getDataType(), is(LEAFREF));
+
+ YangLeafRef leafref = (YangLeafRef) leafInfo.getDataType().getDataTypeExtendedInfo();
+
+ YangLeaf leafInfo2 = (YangLeaf) leafref.getReferredLeafOrLeafList();
+ assertThat(leafref.getReferredLeafOrLeafList(), is(leafInfo2));
+ assertThat(leafref.getResolvableStatus(), Is.is(ResolvableStatus.RESOLVED));
+
+ assertThat(leafref.getEffectiveDataType().getDataType(),
+ is(YangDataTypes.STRING));
+ }
+
+ /**
+ * Checks inter file resolution when leafref from grouping with prefix is changed properly during cloning.
+ */
+ @Test
+ public void processInterFileLeafrefFromGroupingWithPrefixIsCloned()
+ throws IOException, ParserException {
+
+ String searchDir = "src/test/resources/leafreflinker/interfile/leafrefInGroupingWithPrefix";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ YangNode selfNode = null;
+ YangNode refNode = null;
+
+ // Create YANG node set
+ yangLinkerManager.createYangNodeSet(utilManager.getYangNodeSet());
+
+ // Add references to import list.
+ yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
+
+ updateFilePriority(utilManager.getYangNodeSet());
+
+ // Carry out inter-file linking.
+ yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet());
+
+ Iterator<YangNode> yangNodeIterator = utilManager.getYangNodeSet().iterator();
+
+ YangNode rootNode = yangNodeIterator.next();
+
+ if (rootNode.getName().equals("LeafrefInGroupingOfModule1")) {
+ selfNode = rootNode;
+ refNode = yangNodeIterator.next();
+ } else {
+ refNode = rootNode;
+ selfNode = yangNodeIterator.next();
+ }
+
+ // Check whether the data model tree returned is of type module.
+ assertThat(selfNode instanceof YangModule, is(true));
+
+ // Check whether the node type is set properly to module.
+ assertThat(selfNode.getNodeType(), is(MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) selfNode;
+ assertThat(yangNode.getName(), is("LeafrefInGroupingOfModule1"));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode1 = (YangModule) refNode;
+ assertThat(yangNode1.getName(), is("GroupingCopiedInModule2"));
+
+ YangContainer yangContainer = (YangContainer) yangNode1.getChild();
+
+ ListIterator<YangLeaf> leafIterator = yangContainer.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getName(), is("network-ref"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("leafref"));
+ assertThat(leafInfo.getDataType().getDataType(), is(LEAFREF));
+
+ YangLeafRef leafref = (YangLeafRef) leafInfo.getDataType().getDataTypeExtendedInfo();
+
+ YangLeaf leafInfo2 = (YangLeaf) leafref.getReferredLeafOrLeafList();
+ assertThat(leafref.getReferredLeafOrLeafList(), is(leafInfo2));
+ assertThat(leafref.getResolvableStatus(), Is.is(ResolvableStatus.RESOLVED));
+
+ assertThat(leafref.getEffectiveDataType().getDataType(),
+ is(YangDataTypes.STRING));
+ }
+
+ /**
+ * Checks inter file resolution when leafref from grouping with prefix is changed properly during cloning with
+ * multi reference.
+ */
+ @Test
+ public void processInterFileLeafrefFromGroupingWithPrefixIsClonedMultiReference()
+ throws IOException, ParserException {
+
+ String searchDir = "src/test/resources/leafreflinker/interfile/leafrefInGroupingWithPrefixAndManyReference";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ YangNode selfNode = null;
+ YangNode refNode = null;
+
+ // Create YANG node set
+ yangLinkerManager.createYangNodeSet(utilManager.getYangNodeSet());
+
+ // Add references to import list.
+ yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
+
+ updateFilePriority(utilManager.getYangNodeSet());
+
+ // Carry out inter-file linking.
+ yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet());
+
+ Iterator<YangNode> yangNodeIterator = utilManager.getYangNodeSet().iterator();
+
+ YangNode rootNode = yangNodeIterator.next();
+
+ if (rootNode.getName().equals("ietf-network")) {
+ selfNode = rootNode;
+ refNode = yangNodeIterator.next();
+ } else {
+ refNode = rootNode;
+ selfNode = yangNodeIterator.next();
+ }
+
+ // Check whether the data model tree returned is of type module.
+ assertThat(selfNode instanceof YangModule, is(true));
+
+ // Check whether the node type is set properly to module.
+ assertThat(selfNode.getNodeType(), is(MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) selfNode;
+ assertThat(yangNode.getName(), is("ietf-network"));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode1 = (YangModule) refNode;
+ assertThat(yangNode1.getName(), is("ietf-te-topology"));
+
+ YangContainer yangContainer = (YangContainer) yangNode1.getChild().getNextSibling();
+ ListIterator<YangLeaf> leafIterator;
+ YangLeaf leafInfo;
+
+ leafIterator = yangContainer.getListOfLeaf().listIterator();
+ leafInfo = leafIterator.next();
+ leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getName(), is("node-ref"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("leafref"));
+ assertThat(leafInfo.getDataType().getDataType(), is(LEAFREF));
+
+ YangLeafRef leafref = (YangLeafRef) leafInfo.getDataType().getDataTypeExtendedInfo();
+
+ YangLeaf leafInfo2 = (YangLeaf) leafref.getReferredLeafOrLeafList();
+ assertThat(leafref.getReferredLeafOrLeafList(), is(leafInfo2));
+ assertThat(leafref.getResolvableStatus(), Is.is(ResolvableStatus.RESOLVED));
+
+ assertThat(leafref.getEffectiveDataType().getDataType(),
+ is(YangDataTypes.DERIVED));
+
+ leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getName(), is("network-ref"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("leafref"));
+ assertThat(leafInfo.getDataType().getDataType(), is(LEAFREF));
+
+ YangLeafRef leafref1 = (YangLeafRef) leafInfo.getDataType().getDataTypeExtendedInfo();
+
+ YangLeaf leafInfo4 = (YangLeaf) leafref1.getReferredLeafOrLeafList();
+ assertThat(leafref1.getReferredLeafOrLeafList(), is(leafInfo4));
+ assertThat(leafref1.getResolvableStatus(), Is.is(ResolvableStatus.RESOLVED));
+
+ assertThat(leafref1.getEffectiveDataType().getDataType(),
+ is(YangDataTypes.DERIVED));
+ }
+
+ /**
+ * Checks self resolution when leafref under typedef been referred multiple times.
+ */
+ @Test
+ public void processLeafrefWhenUsedMultipleTimes()
+ throws IOException, ParserException {
+ String searchDir = "src/test/resources/leafreflinker/interfile/typedefreferredmultipletimes";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ YangNode selfNode = null;
+
+ // Create YANG node set
+ yangLinkerManager.createYangNodeSet(utilManager.getYangNodeSet());
+
+ // Add references to import list.
+ yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
+
+ updateFilePriority(utilManager.getYangNodeSet());
+
+ // Carry out inter-file linking.
+ yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet());
+
+ Iterator<YangNode> yangNodeIterator = utilManager.getYangNodeSet().iterator();
+
+ YangNode rootNode = yangNodeIterator.next();
+
+ if (rootNode.getName().equals("ietf-interfaces")) {
+ selfNode = rootNode;
+ }
+
+ // Check whether the data model tree returned is of type module.
+ assertThat((selfNode instanceof YangModule), is(true));
+
+ // Check whether the node type is set properly to module.
+ assertThat(selfNode.getNodeType(), is(YangNodeType.MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) selfNode;
+ assertThat(yangNode.getName(), is("ietf-interfaces"));
+
+ YangContainer container = (YangContainer) yangNode.getChild().getNextSibling();
+
+ YangList list = (YangList) container.getChild();
+
+ ListIterator<YangLeafList> leafIterator;
+ YangLeafList leafInfo;
+
+ leafIterator = list.getListOfLeafList().listIterator();
+ leafInfo = leafIterator.next();
+
+ // Check whether the information in the leaf is correct.
+ assertThat(leafInfo.getName(), is("higher-layer-if"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("leafref"));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.LEAFREF));
+ YangLeafRef leafref = (YangLeafRef) (leafInfo.getDataType().getDataTypeExtendedInfo());
+
+ // Check whether leafref type got resolved.
+ assertThat(leafref.getResolvableStatus(),
+ is(ResolvableStatus.RESOLVED));
+
+ // Check the effective type for the leaf.
+ assertThat(leafref.getEffectiveDataType().getDataType(),
+ is(YangDataTypes.STRING));
+
+ leafInfo = leafIterator.next();
+
+ // Check whether the information in the leaf is correct.
+ assertThat(leafInfo.getName(), is("lower-layer-if"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("leafref"));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.LEAFREF));
+ YangLeafRef leafref1 = (YangLeafRef) (leafInfo.getDataType().getDataTypeExtendedInfo());
+
+ // Check whether leafref type got resolved.
+ assertThat(leafref1.getResolvableStatus(),
+ is(ResolvableStatus.RESOLVED));
+
+ // Check the effective type for the leaf.
+ assertThat(leafref1.getEffectiveDataType().getDataType(),
+ is(YangDataTypes.STRING));
+ }
+}
diff --git a/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/InterFileLinkingTest.java b/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/InterFileLinkingTest.java
new file mode 100644
index 0000000..ed431be
--- /dev/null
+++ b/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/InterFileLinkingTest.java
@@ -0,0 +1,935 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yang.compiler.plugin.maven;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.hamcrest.core.Is;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.onosproject.yang.compiler.datamodel.YangAugment;
+import org.onosproject.yang.compiler.datamodel.YangChoice;
+import org.onosproject.yang.compiler.datamodel.YangContainer;
+import org.onosproject.yang.compiler.datamodel.YangDerivedInfo;
+import org.onosproject.yang.compiler.datamodel.YangGrouping;
+import org.onosproject.yang.compiler.datamodel.YangLeaf;
+import org.onosproject.yang.compiler.datamodel.YangList;
+import org.onosproject.yang.compiler.datamodel.YangModule;
+import org.onosproject.yang.compiler.datamodel.YangNode;
+import org.onosproject.yang.compiler.datamodel.YangNodeType;
+import org.onosproject.yang.compiler.datamodel.YangTypeDef;
+import org.onosproject.yang.compiler.datamodel.YangUses;
+import org.onosproject.yang.compiler.datamodel.utils.ResolvableStatus;
+import org.onosproject.yang.compiler.datamodel.utils.builtindatatype.YangDataTypes;
+import org.onosproject.yang.compiler.linker.impl.YangLinkerManager;
+import org.onosproject.yang.compiler.linker.impl.YangLinkerUtils;
+import org.onosproject.yang.compiler.utils.io.YangPluginConfig;
+import org.onosproject.yang.compiler.utils.io.impl.YangFileScanner;
+import org.onosproject.yang.compiler.utils.io.impl.YangIoUtils;
+import org.onosproject.yang.compiler.parser.exceptions.ParserException;
+import org.onosproject.yang.compiler.parser.impl.YangUtilsParserManager;
+
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.ListIterator;
+
+import static org.hamcrest.CoreMatchers.nullValue;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+import static org.onosproject.yang.compiler.datamodel.YangNodeType.MODULE_NODE;
+import static org.onosproject.yang.compiler.datamodel.utils.builtindatatype.YangDataTypes.DERIVED;
+import static org.onosproject.yang.compiler.datamodel.utils.builtindatatype.YangDataTypes.STRING;
+
+/**
+ * Test cases for testing inter file linking.
+ */
+public class InterFileLinkingTest {
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ private final YangUtilsParserManager manager = new YangUtilsParserManager();
+ private final YangUtilManager utilManager = new YangUtilManager();
+ private final YangLinkerManager yangLinkerManager = new YangLinkerManager();
+
+ /**
+ * Checks inter file type linking.
+ */
+ @Test
+ public void processInterFileTypeLinking()
+ throws IOException, ParserException, MojoExecutionException {
+
+ String searchDir = "src/test/resources/interfiletype";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+
+ YangNode refNode = null;
+ YangNode selfNode = null;
+
+ // Create YANG node set
+ yangLinkerManager.createYangNodeSet(utilManager.getYangNodeSet());
+
+ // Add references to import list.
+ yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
+
+ YangLinkerUtils.updateFilePriority(utilManager.getYangNodeSet());
+
+ // Carry out inter-file linking.
+ yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet());
+
+ Iterator<YangNode> yangNodeIterator = utilManager.getYangNodeSet().iterator();
+
+ YangNode rootNode = yangNodeIterator.next();
+
+ if (rootNode.getName().equals("module1")) {
+ selfNode = rootNode;
+ refNode = yangNodeIterator.next();
+ } else {
+ refNode = rootNode;
+ selfNode = yangNodeIterator.next();
+ }
+
+ // Check whether the data model tree returned is of type module.
+ assertThat(selfNode instanceof YangModule, is(true));
+
+ // Check whether the node type is set properly to module.
+ assertThat(selfNode.getNodeType(), is(MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) selfNode;
+ assertThat(yangNode.getName(), is("module1"));
+
+ ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("hello"));
+ assertThat(leafInfo.getDataType().getDataType(), is(DERIVED));
+
+ assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
+ Is.is((YangTypeDef) refNode.getChild()));
+
+ assertThat(leafInfo.getDataType().getResolvableStatus(), Is.is(ResolvableStatus.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()));
+ }
+
+ /**
+ * Checks inter file uses linking.
+ */
+ @Test
+ public void processInterFileUsesLinking()
+ throws IOException, ParserException, MojoExecutionException {
+
+ String searchDir = "src/test/resources/interfileuses";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+
+ YangNode refNode = null;
+ YangNode selfNode = null;
+
+ // Create YANG node set
+ yangLinkerManager.createYangNodeSet(utilManager.getYangNodeSet());
+
+ // Add references to import list.
+ yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
+
+ YangLinkerUtils.updateFilePriority(utilManager.getYangNodeSet());
+
+ // Carry out inter-file linking.
+ yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet());
+
+ Iterator<YangNode> yangNodeIterator = utilManager.getYangNodeSet().iterator();
+
+ YangNode rootNode = yangNodeIterator.next();
+
+ if (rootNode.getName().equals("module1")) {
+ selfNode = rootNode;
+ refNode = yangNodeIterator.next();
+ } else {
+ refNode = rootNode;
+ selfNode = yangNodeIterator.next();
+ }
+
+ // Check whether the data model tree returned is of type module.
+ assertThat(selfNode instanceof YangModule, is(true));
+
+ // Check whether the node type is set properly to module.
+ assertThat(selfNode.getNodeType(), is(YangNodeType.MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) selfNode;
+ assertThat(yangNode.getName(), is("module1"));
+
+ ListIterator<YangLeaf> leafIterator;
+ YangLeaf leafInfo;
+
+ // Check whether grouping is the sibling of module's child.
+ assertThat(refNode.getChild() instanceof YangGrouping, is(true));
+
+ YangGrouping grouping = (YangGrouping) refNode.getChild();
+ leafIterator = grouping.getListOfLeaf().listIterator();
+ leafInfo = leafIterator.next();
+
+ // 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().getDataType(), is(YangDataTypes.STRING));
+
+ // Check whether uses is module's child.
+ assertThat(yangNode.getChild() instanceof YangUses, is(true));
+ YangUses uses = (YangUses) yangNode.getChild();
+
+ // Check whether uses get resolved.
+ assertThat(uses.getResolvableStatus(),
+ is(ResolvableStatus.RESOLVED));
+ }
+
+ /**
+ * Checks inter file type linking with include list.
+ */
+ @Test
+ public void processInterFileTypeLinkingWithIncludeList()
+ throws IOException, ParserException, MojoExecutionException {
+
+ String searchDir = "src/test/resources/interfiletypewithinclude";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+
+ YangNode refNode = null;
+ YangNode selfNode = null;
+
+ // Create YANG node set
+ yangLinkerManager.createYangNodeSet(utilManager.getYangNodeSet());
+
+ // Carry out linking of sub module with module.
+ yangLinkerManager.linkSubModulesToParentModule(utilManager.getYangNodeSet());
+
+ // Add reference to include list.
+ yangLinkerManager.addRefToYangFilesIncludeList(utilManager.getYangNodeSet());
+
+ YangLinkerUtils.updateFilePriority(utilManager.getYangNodeSet());
+
+ // Carry out inter-file linking.
+ yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet());
+
+ Iterator<YangNode> yangNodeIterator = utilManager.getYangNodeSet().iterator();
+
+ YangNode rootNode = yangNodeIterator.next();
+
+ if (rootNode.getName().equals("module1")) {
+ selfNode = rootNode;
+ refNode = yangNodeIterator.next();
+ } else {
+ refNode = rootNode;
+ selfNode = yangNodeIterator.next();
+ }
+
+ // Check whether the data model tree returned is of type module.
+ assertThat(selfNode instanceof YangModule, is(true));
+
+ // Check whether the node type is set properly to module.
+ assertThat(selfNode.getNodeType(), is(MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) selfNode;
+ assertThat(yangNode.getName(), is("module1"));
+
+ ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("hello"));
+ assertThat(leafInfo.getDataType().getDataType(), is(DERIVED));
+
+ assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
+ is((YangTypeDef) refNode.getChild()));
+
+ assertThat(leafInfo.getDataType().getResolvableStatus(), Is.is(ResolvableStatus.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()));
+ }
+
+ /**
+ * Checks inter file uses linking with include list.
+ */
+ @Test
+ public void processInterFileUsesLinkingWithInclude()
+ throws IOException, ParserException, MojoExecutionException {
+
+ String searchDir = "src/test/resources/interfileuseswithinclude";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+
+ YangNode refNode = null;
+ YangNode selfNode = null;
+
+ // Create YANG node set
+ yangLinkerManager.createYangNodeSet(utilManager.getYangNodeSet());
+
+ // Carry out linking of sub module with module.
+ yangLinkerManager.linkSubModulesToParentModule(utilManager.getYangNodeSet());
+
+ // Add reference to include list.
+ yangLinkerManager.addRefToYangFilesIncludeList(utilManager.getYangNodeSet());
+
+ YangLinkerUtils.updateFilePriority(utilManager.getYangNodeSet());
+
+ // Carry out inter-file linking.
+ yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet());
+
+ Iterator<YangNode> yangNodeIterator = utilManager.getYangNodeSet().iterator();
+
+ YangNode rootNode = yangNodeIterator.next();
+
+ if (rootNode.getName().equals("module1")) {
+ selfNode = rootNode;
+ refNode = yangNodeIterator.next();
+ } else {
+ refNode = rootNode;
+ selfNode = yangNodeIterator.next();
+ }
+
+ // Check whether the data model tree returned is of type module.
+ assertThat(selfNode instanceof YangModule, is(true));
+
+ // Check whether the node type is set properly to module.
+ assertThat(selfNode.getNodeType(), is(YangNodeType.MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) selfNode;
+ assertThat(yangNode.getName(), is("module1"));
+
+ ListIterator<YangLeaf> leafIterator;
+ YangLeaf leafInfo;
+
+ // Check whether grouping is the sibling of module's child.
+ assertThat(refNode.getChild() instanceof YangGrouping, is(true));
+
+ YangGrouping grouping = (YangGrouping) refNode.getChild();
+ leafIterator = grouping.getListOfLeaf().listIterator();
+ leafInfo = leafIterator.next();
+
+ // 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().getDataType(), is(YangDataTypes.STRING));
+
+ // Check whether uses is module's child.
+ assertThat(yangNode.getChild() instanceof YangUses, is(true));
+ YangUses uses = (YangUses) yangNode.getChild();
+
+ // Check whether uses get resolved.
+ assertThat(uses.getResolvableStatus(),
+ is(ResolvableStatus.RESOLVED));
+ }
+
+ /**
+ * Checks inter file type linking with revision.
+ */
+ @Test
+ public void processInterFileTypeLinkingWithRevision()
+ throws IOException, ParserException, MojoExecutionException {
+
+ String searchDir = "src/test/resources/interfiletypewithrevision";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+
+ YangNode refNode = null;
+ YangNode selfNode = null;
+
+ // Create YANG node set
+ yangLinkerManager.createYangNodeSet(utilManager.getYangNodeSet());
+
+ // Add references to import list.
+ yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
+
+ YangLinkerUtils.updateFilePriority(utilManager.getYangNodeSet());
+
+ // Carry out inter-file linking.
+ yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet());
+
+ Iterator<YangNode> yangNodeIterator = utilManager.getYangNodeSet().iterator();
+
+ YangNode rootNode = yangNodeIterator.next();
+
+ if (rootNode.getName().equals("module1")) {
+ selfNode = rootNode;
+ refNode = yangNodeIterator.next();
+ } else {
+ refNode = rootNode;
+ selfNode = yangNodeIterator.next();
+ }
+
+ // Check whether the data model tree returned is of type module.
+ assertThat(selfNode instanceof YangModule, is(true));
+
+ // Check whether the node type is set properly to module.
+ assertThat(selfNode.getNodeType(), is(MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) selfNode;
+ assertThat(yangNode.getName(), is("module1"));
+
+ ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("hello"));
+ assertThat(leafInfo.getDataType().getDataType(), is(DERIVED));
+
+ assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
+ is((YangTypeDef) refNode.getChild()));
+
+ assertThat(leafInfo.getDataType().getResolvableStatus(), Is.is(ResolvableStatus.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()));
+ }
+
+ /**
+ * Checks inter file type linking with revision in name.
+ */
+ @Test
+ public void processInterFileTypeLinkingWithRevisionInName()
+ throws IOException, ParserException, MojoExecutionException {
+
+ String searchDir = "src/test/resources/interfiletypewithrevisioninname";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+
+ YangNode refNode = null;
+ YangNode selfNode = null;
+
+ // Create YANG node set
+ yangLinkerManager.createYangNodeSet(utilManager.getYangNodeSet());
+
+ // Add references to import list.
+ yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
+
+ YangLinkerUtils.updateFilePriority(utilManager.getYangNodeSet());
+
+ // Carry out inter-file linking.
+ yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet());
+
+ Iterator<YangNode> yangNodeIterator = utilManager.getYangNodeSet().iterator();
+
+ YangNode rootNode = yangNodeIterator.next();
+
+ if (rootNode.getName().equals("module1")) {
+ selfNode = rootNode;
+ refNode = yangNodeIterator.next();
+ } else {
+ refNode = rootNode;
+ selfNode = yangNodeIterator.next();
+ }
+
+ // Check whether the data model tree returned is of type module.
+ assertThat(selfNode instanceof YangModule, is(true));
+
+ // Check whether the node type is set properly to module.
+ assertThat(selfNode.getNodeType(), is(MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) selfNode;
+ assertThat(yangNode.getName(), is("module1"));
+
+ ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("hello"));
+ assertThat(leafInfo.getDataType().getDataType(), is(DERIVED));
+
+ assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
+ is((YangTypeDef) refNode.getChild()));
+
+ assertThat(leafInfo.getDataType().getResolvableStatus(), Is.is(ResolvableStatus.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()));
+ }
+
+ /**
+ * Checks hierarchical inter file type linking.
+ */
+ @Test
+ public void processHierarchicalInterFileTypeLinking()
+ throws IOException, ParserException, MojoExecutionException {
+
+ String searchDir = "src/test/resources/hierarchicalinterfiletype";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+
+ YangNode refNode1 = null;
+ YangNode refNode2 = null;
+ YangNode selfNode = null;
+
+ // Create YANG node set
+ yangLinkerManager.createYangNodeSet(utilManager.getYangNodeSet());
+
+ // Add references to import list.
+ yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
+
+ YangLinkerUtils.updateFilePriority(utilManager.getYangNodeSet());
+
+ // Carry out inter-file linking.
+ yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet());
+
+ for (YangNode rootNode : utilManager.getYangNodeSet()) {
+ if (rootNode.getName().equals("ietf-network-topology")) {
+ selfNode = rootNode;
+ } else if (rootNode.getName().equals("ietf-network")) {
+ refNode1 = rootNode;
+ } else {
+ refNode2 = rootNode;
+ }
+ }
+
+ // Check whether the data model tree returned is of type module.
+ assertThat(selfNode instanceof YangModule, is(true));
+
+ // Check whether the node type is set properly to module.
+ assertThat(selfNode.getNodeType(), is(MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) selfNode;
+ assertThat(yangNode.getName(), is("ietf-network-topology"));
+
+ ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getName(), is("source-node"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("node-id"));
+ assertThat(leafInfo.getDataType().getDataType(), is(DERIVED));
+
+ assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
+ is((YangTypeDef) refNode1.getChild()));
+
+ assertThat(leafInfo.getDataType().getResolvableStatus(), Is.is(ResolvableStatus.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()));
+ }
+
+ /**
+ * Checks hierarchical intra with inter file type linking.
+ */
+ @Test
+ public void processHierarchicalIntraWithInterFileTypeLinking()
+ throws IOException, ParserException, MojoExecutionException {
+
+ String searchDir = "src/test/resources/hierarchicalintrawithinterfiletype";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+
+ YangNode refNode1 = null;
+ YangNode selfNode = null;
+
+ // Create YANG node set
+ yangLinkerManager.createYangNodeSet(utilManager.getYangNodeSet());
+
+ // Add references to import list.
+ yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
+
+ YangLinkerUtils.updateFilePriority(utilManager.getYangNodeSet());
+
+ // Carry out inter-file linking.
+ yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet());
+
+ for (YangNode rootNode : utilManager.getYangNodeSet()) {
+ if (rootNode.getName().equals("ietf-network")) {
+ selfNode = rootNode;
+ } else if (rootNode.getName().equals("ietf-inet-types")) {
+ refNode1 = rootNode;
+ }
+ }
+
+ // Check whether the data model tree returned is of type module.
+ assertThat(selfNode instanceof YangModule, is(true));
+
+ // Check whether the node type is set properly to module.
+ assertThat(selfNode.getNodeType(), is(MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) selfNode;
+ assertThat(yangNode.getName(), is("ietf-network"));
+
+ ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getName(), is("node-ref"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("node-id"));
+ assertThat(leafInfo.getDataType().getDataType(), is(DERIVED));
+
+ assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
+ is((YangTypeDef) selfNode.getChild()));
+
+ assertThat(leafInfo.getDataType().getResolvableStatus(), Is.is(ResolvableStatus.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()));
+ }
+
+ /**
+ * Checks hierarchical intra with inter file type linking.
+ */
+ @Test
+ public void interFileWithUsesReferringType()
+ throws IOException, ParserException, MojoExecutionException {
+
+ String searchDir = "src/test/resources/interfilewithusesreferringtype";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.resolveDependenciesUsingLinker();
+
+ YangPluginConfig yangPluginConfig = new YangPluginConfig();
+ yangPluginConfig.setCodeGenDir("target/interfilewithusesreferringtype/");
+
+ utilManager.translateToJava(yangPluginConfig);
+
+ YangIoUtils.deleteDirectory("target/interfilewithusesreferringtype/");
+
+ }
+
+ /**
+ * Checks hierarchical intra with inter file type linking.
+ */
+ @Test
+ public void file1UsesFile2TypeDefFile3Type()
+ throws IOException, ParserException, MojoExecutionException {
+
+ String searchDir = "src/test/resources/file1UsesFile2TypeDefFile3Type";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.resolveDependenciesUsingLinker();
+
+ YangPluginConfig yangPluginConfig = new YangPluginConfig();
+ yangPluginConfig.setCodeGenDir("target/file1UsesFile2TypeDefFile3Type/");
+
+ utilManager.translateToJava(yangPluginConfig);
+ String dir1 = System.getProperty("user.dir") + "/"
+ + "target/file1UsesFile2TypeDefFile3Type/";
+ YangPluginConfig.compileCode(dir1);
+ YangIoUtils.deleteDirectory("target/file1UsesFile2TypeDefFile3Type/");
+
+ }
+
+ /**
+ * Checks hierarchical intra with inter file type linking.
+ */
+ @Test
+ public void interFileIetf()
+ throws IOException, ParserException, MojoExecutionException {
+
+ YangIoUtils.deleteDirectory("target/interfileietf/");
+ String searchDir = "src/test/resources/interfileietf";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.resolveDependenciesUsingLinker();
+
+ YangPluginConfig yangPluginConfig = new YangPluginConfig();
+ yangPluginConfig.setCodeGenDir("target/interfileietf/");
+
+ utilManager.translateToJava(yangPluginConfig);
+
+ YangIoUtils.deleteDirectory("target/interfileietf/");
+
+ }
+
+ /**
+ * Checks hierarchical intra with inter file type linking.
+ */
+ @Test
+ public void usesInContainer()
+ throws IOException, ParserException, MojoExecutionException {
+
+ String searchDir = "src/test/resources/usesInContainer";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.resolveDependenciesUsingLinker();
+
+ YangPluginConfig yangPluginConfig = new YangPluginConfig();
+ yangPluginConfig.setCodeGenDir("target/usesInContainer/");
+
+ utilManager.translateToJava(yangPluginConfig);
+
+ YangIoUtils.deleteDirectory("target/usesInContainer/");
+
+ }
+
+ /**
+ * Checks hierarchical intra with inter file type linking.
+ */
+ @Test
+ public void groupingNodeSameAsModule()
+ throws IOException, ParserException, MojoExecutionException {
+
+ String searchDir = "src/test/resources/groupingNodeSameAsModule";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.resolveDependenciesUsingLinker();
+
+ YangPluginConfig yangPluginConfig = new YangPluginConfig();
+ yangPluginConfig.setCodeGenDir("target/groupingNodeSameAsModule/");
+
+ utilManager.translateToJava(yangPluginConfig);
+ String dir1 = System.getProperty("user.dir") + "/"
+ + "target/groupingNodeSameAsModule/";
+ YangPluginConfig.compileCode(dir1);
+ YangIoUtils.deleteDirectory("target/groupingNodeSameAsModule/");
+
+ }
+
+ /**
+ * Checks priority of the file.
+ */
+ @Test
+ public void interFilePriority()
+ throws IOException, ParserException, MojoExecutionException {
+
+ String searchDir = "src/test/resources/interfilepriority";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.resolveDependenciesUsingLinker();
+
+ YangNode selfNode = null;
+ YangNode refNode1 = null;
+ YangNode refNode2 = null;
+
+ for (YangNode rootNode : utilManager.getYangNodeSet()) {
+ if (rootNode.getName().equals("module1")) {
+ selfNode = rootNode;
+ } else if (rootNode.getName().equals("module2")) {
+ refNode1 = rootNode;
+ } else {
+ refNode2 = rootNode;
+ }
+ }
+
+ // Check whether the data model tree returned is of type module.
+ assertThat(selfNode instanceof YangModule, is(true));
+
+ // Check whether the node type is set properly to module.
+ assertThat(selfNode.getNodeType(), is(MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) selfNode;
+ assertThat(yangNode.getName(), is("module1"));
+ assertThat(yangNode.getPriority(), is(2));
+
+ // Check whether the data model tree returned is of type module.
+ assertThat(refNode1 instanceof YangModule, is(true));
+
+ // Check whether the node type is set properly to module.
+ assertThat(refNode1.getNodeType(), is(MODULE_NODE));
+
+ YangModule referredNode1 = (YangModule) refNode1;
+ assertThat(referredNode1.getName(), is("module2"));
+ assertThat(referredNode1.getPriority(), is(3));
+ }
+
+ /**
+ * Checks contents of uses are copied as child of grouping.
+ */
+ @Test
+ public void usesInsideChildOfGrouping()
+ throws IOException, ParserException, MojoExecutionException {
+
+ String searchDir = "src/test/resources/usesInsideChildOfGrouping";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.resolveDependenciesUsingLinker();
+
+ YangNode selfNode = null;
+ YangNode refNode1 = null;
+
+ for (YangNode rootNode : utilManager.getYangNodeSet()) {
+ if (rootNode.getName().equals("ietf-network")) {
+ selfNode = rootNode;
+ } else if (rootNode.getName().equals("ietf-te-topology")) {
+ refNode1 = rootNode;
+ }
+ }
+
+ // Check whether the data model tree returned is of type module.
+ assertThat(selfNode instanceof YangModule, is(true));
+ assertThat(selfNode.getNodeType(), is(MODULE_NODE));
+ YangModule yangNode = (YangModule) selfNode;
+ assertThat(yangNode.getName(), is("ietf-network"));
+
+ YangModule refNode = (YangModule) refNode1;
+ assertThat(refNode.getName(), is("ietf-te-topology"));
+
+ YangAugment augment = ((YangAugment) refNode.getChild().getNextSibling().
+ getNextSibling().getNextSibling().getNextSibling());
+ assertThat(augment.getName(), is("/nw:networks/nw:network/nw:node"));
+
+ YangUses uses = ((YangUses) augment.getChild());
+ YangContainer container = ((YangContainer) uses.getNextSibling());
+ assertThat(container.getName(), is("te"));
+
+ container = ((YangContainer) container.getChild());
+ assertThat(container.getName(), is("config"));
+
+ uses = ((YangUses) container.getChild().getNextSibling());
+ assertThat(uses.getName(), is("te-node-config-attributes"));
+
+ YangContainer container1 = ((YangContainer) uses.getNextSibling());
+ assertThat(container1.getName(), is("te-node-attributes"));
+
+ uses = ((YangUses) container1.getChild());
+ assertThat(uses.getName(), is("te-node-connectivity-matrix"));
+
+ YangList list = ((YangList) uses.getNextSibling());
+ assertThat(list.getName(), is("connectivity-matrix"));
+ }
+
+ /**
+ * Checks contents of uses are copied as child of grouping.
+ */
+ @Test
+ public void interFileUsesInsideChildOfGrouping()
+ throws IOException, ParserException, MojoExecutionException {
+
+ String searchDir = "src/test/resources/interFileUsesInsideChildOfGrouping";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.resolveDependenciesUsingLinker();
+
+ YangNode selfNode = null;
+ YangNode refNode1 = null;
+
+ for (YangNode rootNode : utilManager.getYangNodeSet()) {
+ if (rootNode.getName().equals("ietf-network")) {
+ selfNode = rootNode;
+ } else if (rootNode.getName().equals("ietf-te-topology")) {
+ refNode1 = rootNode;
+ }
+ }
+
+ // Check whether the data model tree returned is of type module.
+ assertThat(selfNode instanceof YangModule, is(true));
+ assertThat(selfNode.getNodeType(), is(MODULE_NODE));
+ YangModule yangNode = (YangModule) selfNode;
+ assertThat(yangNode.getName(), is("ietf-network"));
+
+ YangModule refNode = (YangModule) refNode1;
+ assertThat(refNode.getName(), is("ietf-te-topology"));
+
+ YangAugment augment = ((YangAugment) refNode.getChild().getNextSibling().
+ getNextSibling().getNextSibling().getNextSibling().getNextSibling());
+ assertThat(augment.getName(), is("/nw:networks/nw:network/nt:link"));
+
+ YangUses uses = ((YangUses) augment.getChild());
+ assertThat(uses.getResolvableStatus(), Is.is(ResolvableStatus.RESOLVED));
+ YangContainer container = ((YangContainer) uses.getNextSibling());
+ assertThat(container.getName(), is("te"));
+
+ container = ((YangContainer) container.getChild());
+ assertThat(container.getName(), is("config"));
+
+ uses = ((YangUses) container.getChild().getNextSibling());
+ assertThat(uses.getName(), is("te-link-config-attributes"));
+ assertThat(uses.getResolvableStatus(), Is.is(ResolvableStatus.RESOLVED));
+
+ YangContainer container1 = ((YangContainer) uses.getNextSibling());
+ assertThat(container1.getName(), is("te-link-attributes"));
+
+ container = ((YangContainer) container1.getChild());
+ assertThat(container.getName(), is("underlay"));
+
+ uses = ((YangUses) container.getChild());
+ assertThat(uses.getName(), is("te-link-underlay-attributes"));
+ assertThat(uses.getResolvableStatus(), Is.is(ResolvableStatus.RESOLVED));
+
+ container = ((YangContainer) uses.getNextSibling());
+ assertThat(container.getName(), is("underlay-primary-path"));
+
+ YangList yangList = ((YangList) container.getChild());
+ assertThat(yangList.getName(), is("path-element"));
+
+ uses = ((YangUses) yangList.getChild());
+ assertThat(uses.getName(), is("te-path-element"));
+ assertThat(uses.getResolvableStatus(), Is.is(ResolvableStatus.RESOLVED));
+
+ uses = ((YangUses) uses.getNextSibling());
+ assertThat(uses.getName(), is("explicit-route-subobject"));
+ assertThat(uses.getResolvableStatus(), Is.is(ResolvableStatus.RESOLVED));
+
+ YangChoice choice = ((YangChoice) uses.getNextSibling());
+ assertThat(choice.getName(), is("type"));
+ }
+}
diff --git a/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/InterJarLinkerTest.java b/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/InterJarLinkerTest.java
new file mode 100644
index 0000000..1ceefff
--- /dev/null
+++ b/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/InterJarLinkerTest.java
@@ -0,0 +1,363 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yang.compiler.plugin.maven;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.project.MavenProject;
+import org.onosproject.yang.compiler.datamodel.YangNode;
+import org.onosproject.yang.compiler.base.tool.YangFileInfo;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+import java.util.jar.JarEntry;
+import java.util.jar.JarOutputStream;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+import static org.onosproject.yang.compiler.datamodel.utils.DataModelUtils.parseJarFile;
+import static org.onosproject.yang.compiler.utils.UtilConstants.SLASH;
+import static org.onosproject.yang.compiler.utils.UtilConstants.TEMP;
+import static org.onosproject.yang.compiler.utils.UtilConstants.YANG_RESOURCES;
+
+/**
+ * Unit test case for inter jar linker.
+ */
+public class InterJarLinkerTest {
+
+ private final YangUtilManager utilManager = new YangUtilManager();
+
+ private static final String TARGET = "target/interJarFileLinking/";
+ private static final String YANG_FILES_DIR = "src/test/resources/interJarFileLinking/yangFiles/";
+
+ private static final String FLOW_CLASSIFIER_FOLDER = "target/interJarFileLinking/org/onosproject"
+ + "/yang/gen/v1/sfc/flowclassifier/rev20160524";
+ private static final String PORT_PAIR_FOLDER = "target/interJarFileLinking/org/onosproject"
+ + "/yang/gen/v1/sfc/portpair/rev20160524";
+ private static final String FLOW_CLASSIFIER_MANAGER = FLOW_CLASSIFIER_FOLDER + SLASH + "FlowClassifierManager.java";
+
+ private MockJarFileProvider mockJarFileProvider = new MockJarFileProvider();
+
+ /**
+ * Unit test case for a single jar dependency.
+ *
+ * @throws IOException when fails to do IO operations
+ * @throws MojoExecutionException when fails to do mojo operations
+ */
+//TODO: FIX the interJAR test case for using toolmanger instead of plugin mgr
+ // @Test
+// public void processSingleJarLinking()
+// throws IOException, MojoExecutionException {
+// utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(YANG_FILES_DIR));
+// Set<YangFileInfo> info = utilManager.getYangFileInfoSet();
+// int size1 = info.size();
+// utilManager.parseYangFileInfoSet();
+//
+// mockJarFileProvider.provideTestJarFile(utilManager);
+// utilManager.setYangFileInfoSet(removeFileInfoFromSet(info));
+// utilManager.resolveDependenciesUsingLinker();
+//
+// int size2 = info.size();
+// assertThat(true, is(size1 != size2));
+// assertThat(true, is(parseFileInfoSet(info.iterator())));
+//
+// deleteDirectory(TARGET);
+// mockJarFileProvider.deleteTestSerFile(YANG_FILES_DIR);
+// }
+//
+// /**
+// * Unit test case for a multiple jar dependency.
+// *
+// * @throws IOException when fails to do IO operations
+// * @throws MojoExecutionException when fails to do mojo operations
+// */
+// @Test
+// public void processMultipleJarLinking()
+// throws IOException, MojoExecutionException {
+// utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(YANG_FILES_DIR));
+//
+// Set<YangFileInfo> info = utilManager.getYangFileInfoSet();
+// int size1 = info.size();
+// utilManager.parseYangFileInfoSet();
+//
+// mockJarFileProvider.provideTestJarFile(utilManager);
+// utilManager.setYangFileInfoSet(removeFileInfoFromSet(info));
+//
+// utilManager.resolveDependenciesUsingLinker();
+// int size2 = info.size();
+// assertThat(true, is(size1 != size2));
+// assertThat(true, is(parseFileInfoSet(info.iterator())));
+// assertThat(true, is(parseFileInfoSet(info.iterator())));
+//
+// /*
+// * grouping flow-classifier {
+// * container flow-classifier {
+// * leaf id {
+// * type flow-classifier-id;
+// * }
+// *
+// * leaf tenant-id {
+// * type port-pair:tenant-id;
+// * }
+// * .
+// * .
+// * .
+// *
+// */
+//
+// Iterator<YangFileInfo> yangFileInfoIterator = info.iterator();
+//
+// YangFileInfo yangFileInfo = yangFileInfoIterator.next();
+//
+// while (yangFileInfoIterator.hasNext()) {
+// if (yangFileInfo.getRootNode().getName().equals("flow-classifier")) {
+// break;
+// }
+// yangFileInfo = yangFileInfoIterator.next();
+// }
+//
+// YangNode node = yangFileInfo.getRootNode();
+// node = node.getChild();
+// while (node != null) {
+// if (node instanceof YangGrouping) {
+// break;
+// }
+// node = node.getNextSibling();
+// }
+//
+// node = node.getChild();
+// ListIterator<YangLeaf> leafIterator = ((YangContainer) node).getListOfLeaf().listIterator();
+// YangLeaf leafInfo = leafIterator.next();
+//
+// assertThat(leafInfo.getName(), is("id"));
+// assertThat(leafInfo.getDataType().getDataTypeName(), is("flow-classifier-id"));
+// assertThat(leafInfo.getDataType().getDataType(), is(DERIVED));
+//
+// leafInfo = leafIterator.next();
+//
+// assertThat(leafInfo.getName(), is("tenant-id"));
+// assertThat(leafInfo.getDataType().getDataType(), is(DERIVED));
+//
+// assertThat(true, is(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef()
+// .getName().equals("tenant-id")));
+//
+// assertThat(leafInfo.getDataType().getResolvableStatus(), is(RESOLVED));
+//
+// YangDerivedInfo<?> derivedInfo = (YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo();
+//
+// // Check for the effective built-in type.
+// assertThat(derivedInfo.getEffectiveBuiltInType(), is(STRING));
+//
+// YangPluginConfig yangPluginConfig = new YangPluginConfig();
+// yangPluginConfig.setCodeGenDir(TARGET);
+//
+// utilManager.translateToJava(yangPluginConfig);
+// testIfFlowClassifierFilesExists();
+// testIfPortPairFileDoesNotExist();
+// deleteDirectory(TARGET);
+// mockJarFileProvider.deleteTestSerFile(YANG_FILES_DIR);
+// }
+
+ /**
+ * Test if flow classifier code is generated.
+ */
+ private void testIfFlowClassifierFilesExists() {
+ File folder = new File(System.getProperty("user.dir") + SLASH + FLOW_CLASSIFIER_FOLDER);
+ File file = new File(System.getProperty("user.dir") + SLASH + FLOW_CLASSIFIER_MANAGER);
+ assertThat(true, is(folder.exists()));
+ assertThat(false, is(file.exists()));
+ }
+
+ /**
+ * Tests if port pair code is not generated.
+ */
+ private void testIfPortPairFileDoesNotExist() {
+ File folder = new File(System.getProperty("user.dir") + SLASH + PORT_PAIR_FOLDER);
+ assertThat(false, is(folder.exists()));
+ }
+
+ /**
+ * Need to remove port-pair YANG file info from the set so , serialized file info can be
+ * tested.
+ *
+ * @param fileInfoSet YANG file info set
+ * @return updated file info set
+ */
+ private Set<YangFileInfo> removeFileInfoFromSet(Set<YangFileInfo> fileInfoSet) {
+ String portPairFile = System.getProperty("user.dir") + SLASH + YANG_FILES_DIR + "portpair.yang";
+ for (YangFileInfo fileInfo : fileInfoSet) {
+ if (fileInfo.getYangFileName().equals(portPairFile)) {
+ fileInfoSet.remove(fileInfo);
+ return fileInfoSet;
+ }
+ }
+ return fileInfoSet;
+ }
+
+ /**
+ * Parses file info list and returns true if file info list contains the serialized file info.
+ *
+ * @param yangFileInfoIterator file info list iterator
+ * @return true if present
+ */
+ private boolean parseFileInfoSet(Iterator<YangFileInfo> yangFileInfoIterator) {
+ YangFileInfo yangFileInfo = yangFileInfoIterator.next();
+ while (yangFileInfoIterator.hasNext()) {
+ if (yangFileInfo.getRootNode().getName().equals("port-pair")) {
+ return true;
+ } else if (yangFileInfo.getRootNode().getName().equals("flow-classifier")) {
+ return true;
+ }
+ yangFileInfo = yangFileInfoIterator.next();
+ }
+ return false;
+
+ }
+
+ /**
+ * Represents jar file provider for testing.
+ */
+ private static class MockJarFileProvider {
+
+ private static final String TARGET = "target/interJarFileLinking/";
+ private static final String TARGET_RESOURCE_PATH = SLASH + TEMP + SLASH + YANG_RESOURCES + SLASH;
+ private static final String JAR_FILE_NAME = "onlab-test-1.7.0-SNAPSHOT.jar";
+ private static final String SER_FILE_NAME = "portPair.ser";
+
+ /**
+ * Creates an instance of jar file provider.
+ */
+ MockJarFileProvider() {
+
+ }
+
+ /**
+ * Provides test jar files for linker.
+ *
+ * @throws IOException when fails to do IO operations
+ */
+ void provideTestJarFile(YangUtilManager utilManager) throws IOException {
+
+ Set<YangFileInfo> info = utilManager.getYangFileInfoSet();
+
+ Set<YangNode> compiledSchemas = new HashSet<>();
+ for (YangFileInfo fileInfo : info) {
+ compiledSchemas.add(fileInfo.getRootNode());
+ }
+
+ MavenProject project = new MavenProject();
+ YangPluginUtils.serializeDataModel(TARGET, project, false);
+ createTestJar();
+
+ for (String file : getListOfTestJar(TARGET)) {
+ addInterJarRootNodes(file, info);
+ }
+ }
+
+ /**
+ * Deletes serialized file.
+ */
+ void deleteTestSerFile(String yangFileDir) {
+ File ser = new File(System.getProperty("user.dir") + SLASH + yangFileDir +
+ SLASH + SER_FILE_NAME);
+ ser.delete();
+ }
+
+ /**
+ * Returns list of test jar files.
+ *
+ * @param searchDir search directory
+ * @return list of test jar files
+ */
+ private List<String> getListOfTestJar(String searchDir) {
+ List<String> jarFiles = new ArrayList<>();
+
+ File directory = new File(searchDir + "/");
+ File[] files = directory.listFiles();
+
+ for (File file : files) {
+ if (!file.isDirectory()) {
+ jarFiles.add(file.toString());
+ }
+ }
+
+ return jarFiles;
+ }
+
+ /**
+ * Adds data model nodes of jar to file info set.
+ *
+ * @param jarFile jar file name
+ * @param info file info
+ * @throws IOException when fails to do IO operations
+ */
+ private void addInterJarRootNodes(String jarFile, Set<YangFileInfo> info) throws IOException {
+ try {
+ List<YangNode> interJarResolvedNodes = parseJarFile(jarFile, TARGET);
+
+ for (YangNode node : interJarResolvedNodes) {
+ YangFileInfo dependentFileInfo = new YangFileInfo();
+ node.setToTranslate(false);
+ dependentFileInfo.setRootNode(node);
+ dependentFileInfo.setForTranslator(false);
+ dependentFileInfo.setYangFileName(node.getName());
+ info.add(dependentFileInfo);
+ }
+ } catch (IOException e) {
+ throw new IOException("failed to resolve in interjar scenario.");
+ }
+ }
+
+ /**
+ * Creates a temporary test jar files.
+ */
+ private void createTestJar() {
+
+ File file = new File(TARGET + TARGET_RESOURCE_PATH);
+ File[] files = file.listFiles();
+ String[] source = new String[files.length];
+
+ for (int i = 0; i < files.length; i++) {
+ source[i] = files[i].toString();
+ }
+ byte[] buf = new byte[1024];
+
+ try {
+ String target = TARGET + JAR_FILE_NAME;
+ JarOutputStream out = new JarOutputStream(new FileOutputStream(target));
+ for (String element : source) {
+ FileInputStream in = new FileInputStream(element);
+ out.putNextEntry(new JarEntry(element));
+ int len;
+ while ((len = in.read(buf)) > 0) {
+ out.write(buf, 0, len);
+ }
+ out.closeEntry();
+ in.close();
+ }
+ out.close();
+ } catch (IOException e) {
+ }
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/IntraFileIfFeatureLinkingTest.java b/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/IntraFileIfFeatureLinkingTest.java
new file mode 100644
index 0000000..8adfa16
--- /dev/null
+++ b/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/IntraFileIfFeatureLinkingTest.java
@@ -0,0 +1,222 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yang.compiler.plugin.maven;
+
+import org.hamcrest.core.Is;
+import org.junit.Test;
+import org.onosproject.yang.compiler.datamodel.YangContainer;
+import org.onosproject.yang.compiler.datamodel.YangFeature;
+import org.onosproject.yang.compiler.datamodel.YangIfFeature;
+import org.onosproject.yang.compiler.datamodel.YangLeaf;
+import org.onosproject.yang.compiler.datamodel.YangModule;
+import org.onosproject.yang.compiler.datamodel.YangNode;
+import org.onosproject.yang.compiler.datamodel.YangNodeType;
+import org.onosproject.yang.compiler.datamodel.YangSubModule;
+import org.onosproject.yang.compiler.datamodel.utils.ResolvableStatus;
+import org.onosproject.yang.compiler.parser.exceptions.ParserException;
+import org.onosproject.yang.compiler.parser.impl.YangUtilsParserManager;
+
+import java.io.IOException;
+import java.util.List;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+
+/**
+ * Test cases for testing if-feature intra file linking.
+ */
+public class IntraFileIfFeatureLinkingTest {
+
+ private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+ /**
+ * Checks self resolution when feature defined in same file.
+ */
+ @Test
+ public void processSelfFileLinkingWithFeature()
+ throws IOException, ParserException {
+
+ YangNode node = manager
+ .getDataModel("src/test/resources/SelfFileLinkingWithFeature.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("syslog"));
+
+ List<YangFeature> featureList = yangNode.getFeatureList();
+ YangFeature feature = featureList.iterator().next();
+ assertThat(feature.getName(), is("local-storage"));
+
+ YangContainer container = (YangContainer) yangNode.getChild();
+ assertThat(container.getName(), is("speed"));
+
+ List<YangLeaf> listOfLeaf = container.getListOfLeaf();
+ YangLeaf leaf = listOfLeaf.iterator().next();
+ assertThat(leaf.getName(), is("local-storage-limit"));
+
+ List<YangIfFeature> ifFeatureList = leaf.getIfFeatureList();
+ YangIfFeature ifFeature = ifFeatureList.iterator().next();
+ assertThat(ifFeature.getName().getName(), is("local-storage"));
+ assertThat(ifFeature.getResolvableStatus(), Is.is(ResolvableStatus.RESOLVED));
+ }
+
+ /**
+ * Checks self resolution when feature is undefined.
+ */
+ @Test
+ public void processSelfFileLinkingWithFeatureUndefined()
+ throws IOException, ParserException {
+
+ YangNode node = manager
+ .getDataModel("src/test/resources/SelfFileLinkingWithFeatureUndefined.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("syslog"));
+
+ YangContainer container = (YangContainer) yangNode.getChild();
+ assertThat(container.getName(), is("speed"));
+
+ List<YangLeaf> listOfLeaf = container.getListOfLeaf();
+ YangLeaf leaf = listOfLeaf.iterator().next();
+ assertThat(leaf.getName(), is("local-storage-limit"));
+
+ List<YangIfFeature> ifFeatureList = leaf.getIfFeatureList();
+ YangIfFeature ifFeature = ifFeatureList.iterator().next();
+ assertThat(ifFeature.getName().getName(), is("local-storage"));
+ assertThat(ifFeature.getResolvableStatus(), is(ResolvableStatus.INTRA_FILE_RESOLVED));
+ }
+
+ /**
+ * Checks self resolution of feature with multiple dependency.
+ */
+ @Test
+ public void processSelfFileLinkingWithMultipleDependency() throws IOException, ParserException {
+ YangNode node = manager
+ .getDataModel("src/test/resources/SelfFileLinkingWithMultipleDependency.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("syslog"));
+
+ List<YangFeature> featureList = yangNode.getFeatureList();
+ YangFeature feature = featureList.iterator().next();
+ assertThat(feature.getName(), is("p2mp-te"));
+
+ YangContainer container = (YangContainer) yangNode.getChild();
+ assertThat(container.getName(), is("speed"));
+
+ List<YangLeaf> listOfLeaf = container.getListOfLeaf();
+ YangLeaf leaf = listOfLeaf.iterator().next();
+ assertThat(leaf.getName(), is("local-storage-limit"));
+
+ List<YangIfFeature> ifFeatureList = leaf.getIfFeatureList();
+ YangIfFeature ifFeature = ifFeatureList.iterator().next();
+ assertThat(ifFeature.getName().getName(), is("frr-te"));
+ assertThat(ifFeature.getResolvableStatus(), is(ResolvableStatus.RESOLVED));
+ }
+
+ /**
+ * Checks self resolution of feature with multiple dependency undefined.
+ */
+ @Test
+ public void processSelfFileLinkingWithMultipleDependencyUnresolved() throws IOException, ParserException {
+ YangNode node = manager
+ .getDataModel("src/test/resources/SelfFileLinkingWithMultipleDependencyUnresolved.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("syslog"));
+
+ List<YangFeature> featureList = yangNode.getFeatureList();
+ YangFeature feature = featureList.iterator().next();
+ assertThat(feature.getName(), is("frr-te"));
+
+ YangContainer container = (YangContainer) yangNode.getChild();
+ assertThat(container.getName(), is("speed"));
+
+ List<YangLeaf> listOfLeaf = container.getListOfLeaf();
+ YangLeaf leaf = listOfLeaf.iterator().next();
+ assertThat(leaf.getName(), is("local-storage-limit"));
+
+ List<YangIfFeature> ifFeatureList = leaf.getIfFeatureList();
+ YangIfFeature ifFeature = ifFeatureList.iterator().next();
+ assertThat(ifFeature.getName().getName(), is("frr-te"));
+ assertThat(ifFeature.getResolvableStatus(), is(ResolvableStatus.INTRA_FILE_RESOLVED));
+ }
+
+ /**
+ * Checks self resolution when feature is defined in same file in submodule.
+ */
+ @Test
+ public void processSelfFileLinkingWithFeatureInSubModule()
+ throws IOException, ParserException {
+
+ YangNode node = manager
+ .getDataModel("src/test/resources/SelfFileLinkingWithFeatureInSubModule.yang");
+
+ // Check whether the data model tree returned is of type module.
+ assertThat((node instanceof YangSubModule), is(true));
+
+ // Check whether the node type is set properly to module.
+ assertThat(node.getNodeType(), is(YangNodeType.SUB_MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangSubModule yangNode = (YangSubModule) node;
+ assertThat(yangNode.getName(), is("syslog"));
+
+ List<YangFeature> featureList = yangNode.getFeatureList();
+ YangFeature feature = featureList.iterator().next();
+ assertThat(feature.getName(), is("local-storage"));
+
+ YangContainer container = (YangContainer) yangNode.getChild();
+ assertThat(container.getName(), is("speed"));
+
+ List<YangLeaf> listOfLeaf = container.getListOfLeaf();
+ YangLeaf leaf = listOfLeaf.iterator().next();
+ assertThat(leaf.getName(), is("local-storage-limit"));
+
+ List<YangIfFeature> ifFeatureList = leaf.getIfFeatureList();
+ YangIfFeature ifFeature = ifFeatureList.iterator().next();
+ assertThat(ifFeature.getName().getName(), is("local-storage"));
+ assertThat(ifFeature.getResolvableStatus(), is(ResolvableStatus.RESOLVED));
+ }
+}
diff --git a/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/IntraFileLeafrefLinkingTest.java b/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/IntraFileLeafrefLinkingTest.java
new file mode 100644
index 0000000..ce9f13d
--- /dev/null
+++ b/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/IntraFileLeafrefLinkingTest.java
@@ -0,0 +1,1987 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yang.compiler.plugin.maven;
+
+import org.hamcrest.core.Is;
+import org.junit.Ignore;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.onosproject.yang.compiler.datamodel.YangAtomicPath;
+import org.onosproject.yang.compiler.datamodel.YangAugment;
+import org.onosproject.yang.compiler.datamodel.YangContainer;
+import org.onosproject.yang.compiler.datamodel.YangFeature;
+import org.onosproject.yang.compiler.datamodel.YangIfFeature;
+import org.onosproject.yang.compiler.datamodel.YangInput;
+import org.onosproject.yang.compiler.datamodel.YangLeaf;
+import org.onosproject.yang.compiler.datamodel.YangLeafList;
+import org.onosproject.yang.compiler.datamodel.YangLeafRef;
+import org.onosproject.yang.compiler.datamodel.YangList;
+import org.onosproject.yang.compiler.datamodel.YangModule;
+import org.onosproject.yang.compiler.datamodel.YangNode;
+import org.onosproject.yang.compiler.datamodel.YangNodeType;
+import org.onosproject.yang.compiler.datamodel.YangPathArgType;
+import org.onosproject.yang.compiler.datamodel.YangPathOperator;
+import org.onosproject.yang.compiler.datamodel.YangPathPredicate;
+import org.onosproject.yang.compiler.datamodel.YangRelativePath;
+import org.onosproject.yang.compiler.datamodel.utils.ResolvableStatus;
+import org.onosproject.yang.compiler.datamodel.utils.builtindatatype.YangDataTypes;
+import org.onosproject.yang.compiler.linker.exceptions.LinkerException;
+import org.onosproject.yang.compiler.linker.impl.YangLinkerManager;
+import org.onosproject.yang.compiler.linker.impl.YangLinkerUtils;
+import org.onosproject.yang.compiler.utils.io.impl.YangFileScanner;
+import org.onosproject.yang.compiler.parser.exceptions.ParserException;
+import org.onosproject.yang.compiler.parser.impl.YangUtilsParserManager;
+
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.IsNull.nullValue;
+import static org.onosproject.yang.compiler.datamodel.YangNodeType.MODULE_NODE;
+import static org.onosproject.yang.compiler.datamodel.utils.builtindatatype.YangDataTypes.LEAFREF;
+
+/**
+ * Test cases for testing leafref intra file linking.
+ */
+public class IntraFileLeafrefLinkingTest {
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ private final YangUtilManager utilManager = new YangUtilManager();
+ private final YangLinkerManager yangLinkerManager = new YangLinkerManager();
+ private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+ /**
+ * Checks self resolution when leafref under module refers to leaf in container.
+ */
+ @Test
+ public void processSelfResolutionWhenLeafrefReferToContainerLeaf()
+ throws IOException, ParserException {
+
+ String searchDir = "src/test/resources/leafreflinker/intrafile/simpleleafref";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ YangNode selfNode = null;
+
+ // Create YANG node set
+ yangLinkerManager.createYangNodeSet(utilManager.getYangNodeSet());
+
+ // Add references to import list.
+ yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
+
+ YangLinkerUtils.updateFilePriority(utilManager.getYangNodeSet());
+
+ // Carry out inter-file linking.
+ yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet());
+
+ Iterator<YangNode> yangNodeIterator = utilManager.getYangNodeSet().iterator();
+
+ YangNode rootNode = yangNodeIterator.next();
+
+ if (rootNode.getName().equals("SelfResolutionWhenLeafrefReferToContainerLeaf")) {
+ selfNode = rootNode;
+ }
+
+ // Check whether the data model tree returned is of type module.
+ assertThat((selfNode instanceof YangModule), is(true));
+
+ // Check whether the node type is set properly to module.
+ assertThat(selfNode.getNodeType(), is(YangNodeType.MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) selfNode;
+ assertThat(yangNode.getName(), is("SelfResolutionWhenLeafrefReferToContainerLeaf"));
+
+ ListIterator<YangLeaf> leafIterator;
+ YangLeaf leafInfo;
+
+ leafIterator = yangNode.getListOfLeaf().listIterator();
+ leafInfo = leafIterator.next();
+
+ // Check whether the information in the leaf is correct.
+ assertThat(leafInfo.getName(), is("network-ref"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("leafref"));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.LEAFREF));
+ YangLeafRef leafref = (YangLeafRef) (leafInfo.getDataType().getDataTypeExtendedInfo());
+
+ // Check whether leafref type got resolved.
+ assertThat(leafref.getResolvableStatus(),
+ Is.is(ResolvableStatus.RESOLVED));
+
+ // Check the effective type for the leaf.
+ assertThat(leafref.getEffectiveDataType().getDataType(),
+ is(YangDataTypes.UINT8));
+ }
+
+ /**
+ * Checks self resolution when leafref under module refers to leaf in input of rpc.
+ */
+ @Test
+ public void processSelfResolutionWhenLeafrefInModuleReferToLeafInInputOfRpc()
+ throws IOException, ParserException {
+
+ String searchDir = "src/test/resources/leafreflinker/intrafile/leafrefwithrpc";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ YangNode selfNode = null;
+
+ // Create YANG node set
+ yangLinkerManager.createYangNodeSet(utilManager.getYangNodeSet());
+
+ // Add references to import list.
+ yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
+
+ YangLinkerUtils.updateFilePriority(utilManager.getYangNodeSet());
+
+ // Carry out inter-file linking.
+ yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet());
+
+ Iterator<YangNode> yangNodeIterator = utilManager.getYangNodeSet().iterator();
+
+ YangNode rootNode = yangNodeIterator.next();
+
+ if (rootNode.getName().equals("SelfResolutionWhenLeafrefInModuleReferToLeafInInputOfRpc")) {
+ selfNode = rootNode;
+ }
+
+ // Check whether the data model tree returned is of type module.
+ assertThat((selfNode instanceof YangModule), is(true));
+
+ // Check whether the node type is set properly to module.
+ assertThat(selfNode.getNodeType(), is(YangNodeType.MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) selfNode;
+ assertThat(yangNode.getName(), is("SelfResolutionWhenLeafrefInModuleReferToLeafInInputOfRpc"));
+
+ ListIterator<YangLeaf> leafIterator;
+ YangLeaf leafInfo;
+
+ leafIterator = yangNode.getListOfLeaf().listIterator();
+ leafInfo = leafIterator.next();
+
+ // Check whether the information in the leaf is correct.
+ assertThat(leafInfo.getName(), is("network-ref"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("leafref"));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.LEAFREF));
+ YangLeafRef leafref = (YangLeafRef) (leafInfo.getDataType().getDataTypeExtendedInfo());
+
+ // Check whether leafref type got resolved.
+ assertThat(leafref.getResolvableStatus(),
+ is(ResolvableStatus.RESOLVED));
+
+ // Check the effective type for the leaf.
+ assertThat(leafref.getEffectiveDataType().getDataType(),
+ is(YangDataTypes.UINT8));
+ }
+
+ /**
+ * Checks self resolution when leafref under module refers to grouping rpc with input as name.
+ * Rpc has input child also. So here the node search must be done by taking input node.
+ * TODO: When path has RPC's input but grouping & typedef with the same name occurs.
+ */
+ @Ignore
+ public void processSelfResolutionWhenLeafrefInModuleReferToGroupingWithInputInRpc()
+ throws IOException, ParserException {
+
+ String searchDir = "src/test/resources/leafreflinker/intrafile/leafrefwithrpcandgrouping";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ YangNode selfNode = null;
+
+ // Create YANG node set
+ yangLinkerManager.createYangNodeSet(utilManager.getYangNodeSet());
+
+ // Add references to import list.
+ yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
+
+ YangLinkerUtils.updateFilePriority(utilManager.getYangNodeSet());
+
+ // Carry out inter-file linking.
+ yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet());
+
+ Iterator<YangNode> yangNodeIterator = utilManager.getYangNodeSet().iterator();
+
+ YangNode rootNode = yangNodeIterator.next();
+
+ if (rootNode.getName().equals("SelfResolutionWhenLeafrefInModuleReferToGroupingWithInputInRpc")) {
+ selfNode = rootNode;
+ }
+
+ // Check whether the data model tree returned is of type module.
+ assertThat((selfNode instanceof YangModule), is(true));
+
+ // Check whether the node type is set properly to module.
+ assertThat(selfNode.getNodeType(), is(YangNodeType.MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) selfNode;
+ assertThat(yangNode.getName(), is("SelfResolutionWhenLeafrefInModuleReferToGroupingWithInputInRpc"));
+
+ ListIterator<YangLeaf> leafIterator;
+ YangLeaf leafInfo;
+
+ leafIterator = yangNode.getListOfLeaf().listIterator();
+ leafInfo = leafIterator.next();
+
+ // Check whether the information in the leaf is correct.
+ assertThat(leafInfo.getName(), is("network-ref"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("leafref"));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.LEAFREF));
+ YangLeafRef leafref = (YangLeafRef) (leafInfo.getDataType().getDataTypeExtendedInfo());
+
+ // Check whether leafref type got resolved.
+ assertThat(leafref.getResolvableStatus(),
+ is(ResolvableStatus.RESOLVED));
+
+ // Check the effective type for the leaf.
+ assertThat(leafref.getEffectiveDataType().getDataType(),
+ is(YangDataTypes.UINT8));
+ }
+
+ /**
+ * Checks self resolution when leafref under module refers to grouping under module.
+ * Grouping/typedef cannot be referred.
+ */
+ @Test
+ public void processSelfResolutionWhenLeafrefInModuleReferToGrouping()
+ throws IOException, ParserException {
+/*
+ thrown.expect(LinkerException.class);
+ thrown.expectMessage(
+ "YANG file error: The target node, in the leafref path /networks/network-id, is invalid.");
+*/
+ String searchDir = "src/test/resources/leafreflinker/intrafile/invalidscenerioforgrouping";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+
+ // Create YANG node set
+ yangLinkerManager.createYangNodeSet(utilManager.getYangNodeSet());
+
+ // Add references to import list.
+ yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
+
+ YangLinkerUtils.updateFilePriority(utilManager.getYangNodeSet());
+
+ // Carry out inter-file linking.
+ yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet());
+ }
+
+ /**
+ * Checks self resolution error scenerio where leafref is without path.
+ */
+ @Test
+ public void processSelfResolutionWhenLeafrefDoesntHavePath()
+ throws IOException, ParserException {
+
+ thrown.expect(ParserException.class);
+ thrown.expectMessage(
+ "YANG file error : a type leafref must have one path statement.");
+ YangNode node = manager
+ .getDataModel("src/test/resources/SelfResolutionWhenLeafrefDoesntHavePath.yang");
+ }
+
+ /**
+ * Checks self resolution when leafref under module refers to invalid node.
+ */
+ @Test
+ public void processSelfResolutionWhenLeafrefInModuleReferToInvalidNode()
+ throws IOException, ParserException {
+
+ thrown.expect(LinkerException.class);
+ thrown.expectMessage(
+ "YANG file error: Unable to find base leaf/leaf-list for given leafref path /define/network-id");
+ String searchDir = "src/test/resources/leafreflinker/intrafile/invalidsceneriowithinvalidnode";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+
+ // Create YANG node set
+ yangLinkerManager.createYangNodeSet(utilManager.getYangNodeSet());
+
+ // Add references to import list.
+ yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
+
+ YangLinkerUtils.updateFilePriority(utilManager.getYangNodeSet());
+
+ // Carry out inter-file linking.
+ yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet());
+ }
+
+ /**
+ * Checks self resolution when leafref under module refers to invalid node.
+ * Inter file linking also has to be done to know the error message.
+ */
+ @Test
+ public void processSelfResolutionWhenLeafrefIsInDeepTreeAndLeafIsInModuleWithReferredTypeUnion()
+ throws IOException, ParserException {
+
+ String searchDir = "src/test/resources/leafreflinker/intrafile/leafreflinking";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ YangNode selfNode = null;
+
+ // Create YANG node set
+ yangLinkerManager.createYangNodeSet(utilManager.getYangNodeSet());
+
+ // Add references to import list.
+ yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
+
+ YangLinkerUtils.updateFilePriority(utilManager.getYangNodeSet());
+
+ // Carry out inter-file linking.
+ yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet());
+
+ Iterator<YangNode> yangNodeIterator = utilManager.getYangNodeSet().iterator();
+
+ YangNode rootNode = yangNodeIterator.next();
+
+ if (rootNode.getName().equals("Test")) {
+ selfNode = rootNode;
+ }
+
+ // Check whether the data model tree returned is of type module.
+ assertThat((selfNode instanceof YangModule), is(true));
+
+ // Check whether the node type is set properly to module.
+ assertThat(selfNode.getNodeType(), is(YangNodeType.MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) selfNode;
+ assertThat(yangNode.getName(), is("Test"));
+
+ YangContainer containerParent = (YangContainer) yangNode.getChild().getChild().getChild();
+ ListIterator<YangLeaf> leafIterator;
+ YangLeaf leafInfo;
+
+ leafIterator = containerParent.getListOfLeaf().listIterator();
+ leafInfo = leafIterator.next();
+
+ // Check whether the information in the leaf is correct.
+ assertThat(leafInfo.getName(), is("name"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("leafref"));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.LEAFREF));
+ YangLeafRef leafref = (YangLeafRef) (leafInfo.getDataType().getDataTypeExtendedInfo());
+
+ // Check whether leafref type got resolved.
+ assertThat(leafref.getResolvableStatus(),
+ is(ResolvableStatus.RESOLVED));
+
+ // Check the effective type for the leaf.
+ assertThat(leafref.getEffectiveDataType().getDataType(),
+ is(YangDataTypes.UNION));
+ }
+
+ /**
+ * Checks self resolution when leafref of leaf-list under module refers to leaf in container.
+ */
+ @Test
+ public void processSelfResolutionWhenLeafrefReferToContainerLeafList()
+ throws IOException, ParserException {
+
+ String searchDir = "src/test/resources/leafreflinker/intrafile/leafrefreferingtoleaflist";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ YangNode selfNode = null;
+
+ // Create YANG node set
+ yangLinkerManager.createYangNodeSet(utilManager.getYangNodeSet());
+
+ // Add references to import list.
+ yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
+
+ YangLinkerUtils.updateFilePriority(utilManager.getYangNodeSet());
+
+ // Carry out inter-file linking.
+ yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet());
+
+ Iterator<YangNode> yangNodeIterator = utilManager.getYangNodeSet().iterator();
+
+ YangNode rootNode = yangNodeIterator.next();
+
+ if (rootNode.getName().equals("ietf-network")) {
+ selfNode = rootNode;
+ }
+
+ // Check whether the data model tree returned is of type module.
+ assertThat((selfNode instanceof YangModule), is(true));
+
+ // Check whether the node type is set properly to module.
+ assertThat(selfNode.getNodeType(), is(YangNodeType.MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) selfNode;
+ assertThat(yangNode.getName(), is("ietf-network"));
+
+ ListIterator<YangLeafList> leafListIterator;
+ YangLeafList leafListInfo;
+
+ leafListIterator = yangNode.getListOfLeafList().listIterator();
+ leafListInfo = leafListIterator.next();
+
+ // Check whether the information in the leaf is correct.
+ assertThat(leafListInfo.getName(), is("network-ref"));
+ assertThat(leafListInfo.getDataType().getDataTypeName(), is("leafref"));
+ assertThat(leafListInfo.getDataType().getDataType(), is(YangDataTypes.LEAFREF));
+ YangLeafRef leafref = (YangLeafRef) (leafListInfo.getDataType().getDataTypeExtendedInfo());
+
+ // Check whether leafref type got resolved.
+ assertThat(leafref.getResolvableStatus(),
+ is(ResolvableStatus.RESOLVED));
+
+ // Check the effective type for the leaf.
+ assertThat(leafref.getEffectiveDataType().getDataType(),
+ is(YangDataTypes.UINT8));
+ }
+
+ /**
+ * Checks self resolution when leafref of leaf-list under module refers to leaf-list in input of rpc.
+ */
+ @Test
+ public void processSelfResolutionWhenLeafrefInModuleReferToLeafListInInputOfRpc()
+ throws IOException, ParserException {
+
+ String searchDir = "src/test/resources/leafreflinker/intrafile/leafreftoinputinrpc";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ YangNode selfNode = null;
+
+ // Create YANG node set
+ yangLinkerManager.createYangNodeSet(utilManager.getYangNodeSet());
+
+ // Add references to import list.
+ yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
+
+ YangLinkerUtils.updateFilePriority(utilManager.getYangNodeSet());
+
+ // Carry out inter-file linking.
+ yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet());
+
+ Iterator<YangNode> yangNodeIterator = utilManager.getYangNodeSet().iterator();
+
+ YangNode rootNode = yangNodeIterator.next();
+
+ if (rootNode.getName().equals("ietf-network")) {
+ selfNode = rootNode;
+ }
+
+ // Check whether the node type is set properly to module.
+ assertThat(selfNode.getNodeType(), is(YangNodeType.MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) selfNode;
+ assertThat(yangNode.getName(), is("ietf-network"));
+
+ ListIterator<YangLeafList> leafListIterator;
+ YangLeafList leafListInfo;
+
+ leafListIterator = yangNode.getListOfLeafList().listIterator();
+ leafListInfo = leafListIterator.next();
+
+ // Check whether the information in the leaf is correct.
+ assertThat(leafListInfo.getName(), is("network-ref"));
+ assertThat(leafListInfo.getDataType().getDataTypeName(), is("leafref"));
+ assertThat(leafListInfo.getDataType().getDataType(), is(YangDataTypes.LEAFREF));
+ YangLeafRef leafref = (YangLeafRef) (leafListInfo.getDataType().getDataTypeExtendedInfo());
+
+ // Check whether leafref type got resolved.
+ assertThat(leafref.getResolvableStatus(),
+ is(ResolvableStatus.RESOLVED));
+
+ // Check the effective type for the leaf.
+ assertThat(leafref.getEffectiveDataType().getDataType(),
+ is(YangDataTypes.UINT8));
+ }
+
+ /**
+ * Checks self resolution when leafref of leaf-list under module refers to invalid node.
+ * Inter file linking also has to be done to know the error message.
+ */
+ @Test
+ public void processSelfResolutionWhenLeafrefIsInDeepTreeAndLeafListIsInModuleWithReferredTypeEnumeration()
+ throws IOException, ParserException {
+
+ String searchDir = "src/test/resources/leafreflinker/intrafile/leafrefwithrefleafderived";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ YangNode selfNode = null;
+
+ // Create YANG node set
+ yangLinkerManager.createYangNodeSet(utilManager.getYangNodeSet());
+
+ // Add references to import list.
+ yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
+
+ YangLinkerUtils.updateFilePriority(utilManager.getYangNodeSet());
+
+ // Carry out inter-file linking.
+ yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet());
+
+ Iterator<YangNode> yangNodeIterator = utilManager.getYangNodeSet().iterator();
+
+ YangNode rootNode = yangNodeIterator.next();
+
+ if (rootNode.getName().equals("Test")) {
+ selfNode = rootNode;
+ }
+
+ // Check whether the node type is set properly to module.
+ assertThat(selfNode.getNodeType(), is(YangNodeType.MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) selfNode;
+
+ assertThat(yangNode.getName(), is("Test"));
+
+ YangContainer containerParent = (YangContainer) yangNode.getChild().getChild().getChild();
+ ListIterator<YangLeafList> leafListListIterator;
+ YangLeafList leafListInfo;
+
+ leafListListIterator = containerParent.getListOfLeafList().listIterator();
+ leafListInfo = leafListListIterator.next();
+
+ // Check whether the information in the leaf is correct.
+ assertThat(leafListInfo.getName(), is("name"));
+ assertThat(leafListInfo.getDataType().getDataTypeName(), is("leafref"));
+ assertThat(leafListInfo.getDataType().getDataType(), is(YangDataTypes.LEAFREF));
+ YangLeafRef leafref = (YangLeafRef) (leafListInfo.getDataType().getDataTypeExtendedInfo());
+
+ // Check whether leafref type got resolved.
+ assertThat(leafref.getResolvableStatus(),
+ is(ResolvableStatus.RESOLVED));
+
+ // Check the effective type for the leaf.
+ assertThat(leafref.getEffectiveDataType().getDataType(),
+ is(YangDataTypes.ENUMERATION));
+ }
+
+ /**
+ * Checks the error scenerio when the referred node is not a leaf or leaf-list.
+ */
+ @Test
+ public void processSelfResolutionWhenLeafrefDoesNotReferToLeafOrLeafList()
+ throws IOException, ParserException {
+
+ thrown.expect(LinkerException.class);
+ thrown.expectMessage(
+ "YANG file error: Unable to find base leaf/leaf-list for given leafref path /networks");
+ String searchDir = "src/test/resources/leafreflinker/intrafile/invalidsceneriowithnorefleaf";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+
+ // Create YANG node set
+ yangLinkerManager.createYangNodeSet(utilManager.getYangNodeSet());
+
+ // Add references to import list.
+ yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
+
+ YangLinkerUtils.updateFilePriority(utilManager.getYangNodeSet());
+
+ // Carry out inter-file linking.
+ yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet());
+ }
+
+ /**
+ * Checks self resolution when leafref of leaf-list under module refers to leaf in container.
+ */
+ @Test
+ public void processSelfResolutionWhenLeafrefInTypedefReferToContainer()
+ throws IOException, ParserException {
+ String searchDir = "src/test/resources/leafreflinker/intrafile/leafrefintypedef";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ YangNode selfNode = null;
+ // Create YANG node set
+ yangLinkerManager.createYangNodeSet(utilManager.getYangNodeSet());
+
+ // Add references to import list.
+ yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
+
+ YangLinkerUtils.updateFilePriority(utilManager.getYangNodeSet());
+
+ // Carry out inter-file linking.
+ yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet());
+
+ Iterator<YangNode> yangNodeIterator = utilManager.getYangNodeSet().iterator();
+
+ YangNode rootNode = yangNodeIterator.next();
+
+ if (rootNode.getName().equals("ietf-network")) {
+ selfNode = rootNode;
+ }
+ // Check whether the data model tree returned is of type module.
+ assertThat((selfNode instanceof YangModule), is(true));
+
+ // Check whether the node type is set properly to module.
+ assertThat(selfNode.getNodeType(), is(YangNodeType.MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) selfNode;
+ assertThat(yangNode.getName(), is("ietf-network"));
+
+ YangContainer yangContainer = (YangContainer) yangNode.getChild();
+ ListIterator<YangLeaf> leafIterator;
+ YangLeaf leafInfo;
+ leafIterator = yangContainer.getListOfLeaf().listIterator();
+ leafInfo = leafIterator.next();
+
+ // Check whether the information in the leaf is correct under grouping.
+ assertThat(leafInfo.getName(), is("network-id"));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.LEAFREF));
+
+ YangLeafRef leafref = (YangLeafRef) (leafInfo.getDataType().getDataTypeExtendedInfo());
+
+ // Check whether leafref type got resolved.
+ assertThat(leafref.getResolvableStatus(),
+ is(ResolvableStatus.RESOLVED));
+
+ // Check the effective type for the leaf.
+ assertThat(leafref.getEffectiveDataType().getDataType(),
+ is(YangDataTypes.UINT8));
+ }
+
+ /**
+ * Checks self resolution when leafref of leaf-list under module refers to leaf-list in input of rpc.
+ */
+ @Test
+ public void processSelfResolutionWhenLeafrefInTypedefModuleReferToLeafListInInputOfRpc()
+ throws IOException, ParserException {
+
+ String searchDir = "src/test/resources/leafreflinker/intrafile/leafreftorpcinputleaflist";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ YangNode selfNode = null;
+ // Create YANG node set
+ yangLinkerManager.createYangNodeSet(utilManager.getYangNodeSet());
+
+ // Add references to import list.
+ yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
+
+ YangLinkerUtils.updateFilePriority(utilManager.getYangNodeSet());
+
+ // Carry out inter-file linking.
+ yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet());
+
+ Iterator<YangNode> yangNodeIterator = utilManager.getYangNodeSet().iterator();
+
+ YangNode rootNode = yangNodeIterator.next();
+
+ if (rootNode.getName().equals("ietf-network")) {
+ selfNode = rootNode;
+ }
+ // Check whether the data model tree returned is of type module.
+ assertThat((selfNode instanceof YangModule), is(true));
+
+ // Check whether the node type is set properly to module.
+ assertThat(selfNode.getNodeType(), is(YangNodeType.MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) selfNode;
+ assertThat(yangNode.getName(), is("ietf-network"));
+
+ YangInput yangInput = (YangInput) yangNode.getChild().getChild();
+
+ ListIterator<YangLeafList> leafListIterator;
+ YangLeafList yangLeafListInfo;
+ leafListIterator = yangInput.getListOfLeafList().listIterator();
+ yangLeafListInfo = leafListIterator.next();
+
+ // Check whether the information in the leaf is correct under grouping.
+ assertThat(yangLeafListInfo.getName(), is("network-id"));
+ assertThat(yangLeafListInfo.getDataType().getDataType(), is(YangDataTypes.LEAFREF));
+
+ YangLeafRef leafref = (YangLeafRef) (yangLeafListInfo.getDataType().getDataTypeExtendedInfo());
+
+ // Check whether leafref type got resolved.
+ assertThat(leafref.getResolvableStatus(),
+ is(ResolvableStatus.RESOLVED));
+
+ // Check the effective type for the leaf.
+ assertThat(leafref.getEffectiveDataType().getDataType(),
+ is(YangDataTypes.UINT8));
+ }
+
+ /**
+ * Checks self resolution when leafref of leaf-list under module refers to invalid node.
+ * Inter file linking also has to be done to know the error message.
+ */
+ @Test
+ public void processSelfResolutionWhenLeafrefInTypedefIsInDeepTreeAndLeafListIsInModuleWithReferredTypeEnumeration()
+ throws IOException, ParserException {
+
+ String searchDir = "src/test/resources/leafreflinker/intrafile/leafreftoleafrefwithtypedef";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ YangNode selfNode = null;
+ // Create YANG node set
+ yangLinkerManager.createYangNodeSet(utilManager.getYangNodeSet());
+
+ // Add references to import list.
+ yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
+
+ YangLinkerUtils.updateFilePriority(utilManager.getYangNodeSet());
+
+ // Carry out inter-file linking.
+ yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet());
+
+ Iterator<YangNode> yangNodeIterator = utilManager.getYangNodeSet().iterator();
+
+ YangNode rootNode = yangNodeIterator.next();
+
+ if (rootNode.getName().equals("Test")) {
+ selfNode = rootNode;
+ }
+ // Check whether the data model tree returned is of type module.
+ assertThat((selfNode instanceof YangModule), is(true));
+
+ // Check whether the node type is set properly to module.
+ assertThat(selfNode.getNodeType(), is(YangNodeType.MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) selfNode;
+ assertThat(yangNode.getName(), is("Test"));
+
+ YangContainer yangContainer = (YangContainer) yangNode.getChild().getChild().getChild().getNextSibling();
+
+ ListIterator<YangLeaf> leafIterator;
+ YangLeaf yangLeafInfo;
+ leafIterator = yangContainer.getListOfLeaf().listIterator();
+ yangLeafInfo = leafIterator.next();
+
+ // Check whether the information in the leaf is correct under grouping.
+ assertThat(yangLeafInfo.getName(), is("interval"));
+ assertThat(yangLeafInfo.getDataType().getDataType(), is(YangDataTypes.LEAFREF));
+
+ YangLeafRef leafref = (YangLeafRef) (yangLeafInfo.getDataType().getDataTypeExtendedInfo());
+
+ // Check whether leafref type got resolved.
+ assertThat(leafref.getResolvableStatus(),
+ is(ResolvableStatus.RESOLVED));
+
+ // Check the effective type for the leaf.
+ assertThat(leafref.getEffectiveDataType().getDataType(),
+ is(YangDataTypes.ENUMERATION));
+ }
+
+ /**
+ * Checks self resolution when grouping and uses are siblings.
+ * Grouping followed by uses.
+ */
+ @Test
+ public void processSelfResolutionWhenLeafrefRefersAnotherLeafref()
+ throws IOException, ParserException {
+
+ String searchDir = "src/test/resources/leafreflinker/intrafile/leafreftoleafref";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ YangNode selfNode = null;
+ // Create YANG node set
+ yangLinkerManager.createYangNodeSet(utilManager.getYangNodeSet());
+
+ // Add references to import list.
+ yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
+
+ YangLinkerUtils.updateFilePriority(utilManager.getYangNodeSet());
+
+ // Carry out inter-file linking.
+ yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet());
+
+ Iterator<YangNode> yangNodeIterator = utilManager.getYangNodeSet().iterator();
+
+ YangNode rootNode = yangNodeIterator.next();
+
+ if (rootNode.getName().equals("ietf-network")) {
+ selfNode = rootNode;
+ }
+ // Check whether the data model tree returned is of type module.
+ assertThat((selfNode instanceof YangModule), is(true));
+
+ // Check whether the node type is set properly to module.
+ assertThat(selfNode.getNodeType(), is(YangNodeType.MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) selfNode;
+ assertThat(yangNode.getName(), is("ietf-network"));
+
+ ListIterator<YangLeaf> leafIterator;
+ YangLeaf leafInfo;
+
+ //YangGrouping grouping = (YangGrouping) yangNode.getChild().getNextSibling();
+ leafIterator = yangNode.getListOfLeaf().listIterator();
+ leafInfo = leafIterator.next();
+
+ // Check whether the information in the leaf is correct under grouping.
+ assertThat(leafInfo.getName(), is("network-ref"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("leafref"));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.LEAFREF));
+ YangLeafRef leafref = (YangLeafRef) (leafInfo.getDataType().getDataTypeExtendedInfo());
+
+ assertThat(leafref.getResolvableStatus(),
+ is(ResolvableStatus.RESOLVED));
+
+ assertThat(leafref.getEffectiveDataType().getDataType(),
+ is(YangDataTypes.UINT8));
+ }
+
+ /**
+ * Checks self resolution when leafref refers to many other leafref.
+ */
+ @Test
+ public void processSelfResolutionWhenLeafrefReferToMultipleLeafref()
+ throws IOException, ParserException {
+
+ String searchDir = "src/test/resources/leafreflinker/intrafile/leafreftomultileafref";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ YangNode selfNode = null;
+ // Create YANG node set
+ yangLinkerManager.createYangNodeSet(utilManager.getYangNodeSet());
+
+ // Add references to import list.
+ yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
+
+ YangLinkerUtils.updateFilePriority(utilManager.getYangNodeSet());
+
+ // Carry out inter-file linking.
+ yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet());
+
+ Iterator<YangNode> yangNodeIterator = utilManager.getYangNodeSet().iterator();
+
+ YangNode rootNode = yangNodeIterator.next();
+
+ if (rootNode.getName().equals("Test")) {
+ selfNode = rootNode;
+ }
+ // Check whether the data model tree returned is of type module.
+ assertThat((selfNode instanceof YangModule), is(true));
+
+ // Check whether the node type is set properly to module.
+ assertThat(selfNode.getNodeType(), is(YangNodeType.MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) selfNode;
+ assertThat(yangNode.getName(), is("Test"));
+
+ YangContainer containerInModule = (YangContainer) yangNode.getChild().getNextSibling();
+ YangContainer containerInList = (YangContainer) containerInModule.getChild().getChild();
+
+ ListIterator<YangLeaf> leafIterator;
+ YangLeaf leafInfo;
+
+ leafIterator = containerInList.getListOfLeaf().listIterator();
+ leafInfo = leafIterator.next();
+
+ // Check whether the information in the leaf is correct under grouping.
+ assertThat(leafInfo.getName(), is("remove"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("leafref"));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.LEAFREF));
+ YangLeafRef leafref = (YangLeafRef) (leafInfo.getDataType().getDataTypeExtendedInfo());
+
+ assertThat(leafref.getResolvableStatus(),
+ is(ResolvableStatus.RESOLVED));
+
+ assertThat(leafref.getEffectiveDataType().getDataType(),
+ is(YangDataTypes.ENUMERATION));
+ }
+
+ /**
+ * Checks self resolution when grouping and uses are siblings.
+ * Grouping followed by uses.
+ */
+ @Test
+ public void processSelfResolutionWhenLeafrefRefersAnotherDerivedType()
+ throws IOException, ParserException {
+
+ String searchDir = "src/test/resources/leafreflinker/intrafile/leafreftoderivedtype";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ YangNode selfNode = null;
+ // Create YANG node set
+ yangLinkerManager.createYangNodeSet(utilManager.getYangNodeSet());
+
+ // Add references to import list.
+ yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
+
+ YangLinkerUtils.updateFilePriority(utilManager.getYangNodeSet());
+
+ // Carry out inter-file linking.
+ yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet());
+
+ Iterator<YangNode> yangNodeIterator = utilManager.getYangNodeSet().iterator();
+
+ YangNode rootNode = yangNodeIterator.next();
+
+ if (rootNode.getName().equals("ietf-network")) {
+ selfNode = rootNode;
+ }
+ // Check whether the data model tree returned is of type module.
+ assertThat((selfNode instanceof YangModule), is(true));
+
+ // Check whether the node type is set properly to module.
+ assertThat(selfNode.getNodeType(), is(YangNodeType.MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) selfNode;
+ assertThat(yangNode.getName(), is("ietf-network"));
+
+ ListIterator<YangLeaf> leafIterator;
+ YangLeaf leafInfo;
+
+ //YangGrouping grouping = (YangGrouping) yangNode.getChild().getNextSibling();
+ leafIterator = yangNode.getListOfLeaf().listIterator();
+ leafInfo = leafIterator.next();
+
+ // Check whether the information in the leaf is correct under grouping.
+ assertThat(leafInfo.getName(), is("network-ref"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("leafref"));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.LEAFREF));
+ YangLeafRef leafref = (YangLeafRef) (leafInfo.getDataType().getDataTypeExtendedInfo());
+
+ assertThat(leafref.getResolvableStatus(),
+ is(ResolvableStatus.RESOLVED));
+
+ assertThat(leafref.getEffectiveDataType().getDataType(),
+ is(YangDataTypes.DERIVED));
+ }
+
+ /**
+ * Checks self resolution when leafref refers to many other leafref.
+ */
+ @Test
+ public void processSelfResolutionWhenLeafrefReferToMultipleTypedef()
+ throws IOException, ParserException {
+
+ String searchDir = "src/test/resources/leafreflinker/intrafile/leafreftomultitypedef";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ YangNode selfNode = null;
+ // Create YANG node set
+ yangLinkerManager.createYangNodeSet(utilManager.getYangNodeSet());
+
+ // Add references to import list.
+ yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
+
+ YangLinkerUtils.updateFilePriority(utilManager.getYangNodeSet());
+
+ // Carry out inter-file linking.
+ yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet());
+
+ Iterator<YangNode> yangNodeIterator = utilManager.getYangNodeSet().iterator();
+
+ YangNode rootNode = yangNodeIterator.next();
+
+ if (rootNode.getName().equals("Test")) {
+ selfNode = rootNode;
+ }
+ // Check whether the data model tree returned is of type module.
+ assertThat((selfNode instanceof YangModule), is(true));
+
+ // Check whether the node type is set properly to module.
+ assertThat(selfNode.getNodeType(), is(YangNodeType.MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) selfNode;
+ assertThat(yangNode.getName(), is("Test"));
+
+ YangContainer containerInModule = (YangContainer) yangNode.getChild().getNextSibling();
+ YangContainer containerInList = (YangContainer) containerInModule.getChild().getChild();
+
+ ListIterator<YangLeaf> leafIterator;
+ YangLeaf leafInfo;
+
+ leafIterator = containerInList.getListOfLeaf().listIterator();
+ leafInfo = leafIterator.next();
+
+ // Check whether the information in the leaf is correct under grouping.
+ assertThat(leafInfo.getName(), is("remove"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("leafref"));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.LEAFREF));
+ YangLeafRef leafref = (YangLeafRef) (leafInfo.getDataType().getDataTypeExtendedInfo());
+
+ assertThat(leafref.getResolvableStatus(),
+ is(ResolvableStatus.RESOLVED));
+
+ assertThat(leafref.getEffectiveDataType().getDataType(),
+ is(YangDataTypes.DERIVED));
+ }
+
+ /**
+ * Checks self resolution when leafref refers to many other leaf with derived type
+ * which in turn referring to another leaf.
+ */
+ @Test
+ public void processSelfResolutionWhenLeafrefReferToDerivedTypeReferringToLeafWithLeafref()
+ throws IOException, ParserException {
+
+ String searchDir = "src/test/resources/leafreflinker/intrafile/leafreftotypedefwithleafref";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ YangNode selfNode = null;
+ // Create YANG node set
+ yangLinkerManager.createYangNodeSet(utilManager.getYangNodeSet());
+
+ // Add references to import list.
+ yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
+
+ YangLinkerUtils.updateFilePriority(utilManager.getYangNodeSet());
+
+ // Carry out inter-file linking.
+ yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet());
+
+ Iterator<YangNode> yangNodeIterator = utilManager.getYangNodeSet().iterator();
+
+ YangNode rootNode = yangNodeIterator.next();
+
+ if (rootNode.getName().equals("Test")) {
+ selfNode = rootNode;
+ }
+ // Check whether the data model tree returned is of type module.
+ assertThat((selfNode instanceof YangModule), is(true));
+
+ // Check whether the node type is set properly to module.
+ assertThat(selfNode.getNodeType(), is(YangNodeType.MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) selfNode;
+ assertThat(yangNode.getName(), is("Test"));
+
+ YangContainer containerInModule = (YangContainer) yangNode.getChild().getNextSibling();
+ YangContainer containerInList = (YangContainer) containerInModule.getChild().getChild();
+
+ ListIterator<YangLeaf> leafIterator;
+ YangLeaf leafInfo;
+
+ leafIterator = containerInList.getListOfLeaf().listIterator();
+ leafInfo = leafIterator.next();
+
+ // Check whether the information in the leaf is correct under grouping.
+ assertThat(leafInfo.getName(), is("remove"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("leafref"));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.LEAFREF));
+ YangLeafRef leafref = (YangLeafRef) leafInfo.getDataType().getDataTypeExtendedInfo();
+
+ assertThat(leafref.getResolvableStatus(),
+ is(ResolvableStatus.RESOLVED));
+
+ assertThat(leafref.getEffectiveDataType().getDataType(),
+ is(YangDataTypes.ENUMERATION));
+ }
+
+ /**
+ * Checks self resolution when leafref under module refers to leaf in container with relative path.
+ */
+ @Test
+ public void processSelfResolutionWhenLeafrefReferToContainerLeafRelPath()
+ throws IOException, ParserException {
+
+ String searchDir = "src/test/resources/leafreflinker/intrafile/relativepath/simpleleafref";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ YangNode selfNode = null;
+ // Create YANG node set
+ yangLinkerManager.createYangNodeSet(utilManager.getYangNodeSet());
+
+ // Add references to import list.
+ yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
+
+ YangLinkerUtils.updateFilePriority(utilManager.getYangNodeSet());
+
+ // Carry out inter-file linking.
+ yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet());
+
+ Iterator<YangNode> yangNodeIterator = utilManager.getYangNodeSet().iterator();
+
+ YangNode rootNode = yangNodeIterator.next();
+
+ if (rootNode.getName().equals("ietf-network")) {
+ selfNode = rootNode;
+ }
+ // Check whether the data model tree returned is of type module.
+ assertThat((selfNode instanceof YangModule), is(true));
+
+ // Check whether the node type is set properly to module.
+ assertThat(selfNode.getNodeType(), is(YangNodeType.MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) selfNode;
+ assertThat(yangNode.getName(), is("ietf-network"));
+
+ ListIterator<YangLeaf> leafIterator;
+ YangLeaf leafInfo;
+
+ leafIterator = yangNode.getListOfLeaf().listIterator();
+ leafInfo = leafIterator.next();
+
+ // Check whether the information in the leaf is correct.
+ assertThat(leafInfo.getName(), is("network-ref"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("leafref"));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.LEAFREF));
+ YangLeafRef leafref = (YangLeafRef) (leafInfo.getDataType().getDataTypeExtendedInfo());
+
+ // Check whether leafref type got resolved.
+ assertThat(leafref.getResolvableStatus(),
+ is(ResolvableStatus.RESOLVED));
+
+ // Check the effective type for the leaf.
+ assertThat(leafref.getEffectiveDataType().getDataType(),
+ is(YangDataTypes.UINT8));
+ }
+
+ /**
+ * Checks self resolution when leafref under module refers to grouping rpc with input as name.
+ * Rpc has input child also. So here the node search must be done by taking input node using relative path.
+ */
+ @Ignore
+ public void processSelfResolutionWhenLeafrefInModuleReferToGroupingWithInputInRpcRelPath()
+ throws IOException, ParserException {
+
+ String searchDir = "src/test/resources/leafreflinker/intrafile/relativepath/leafreftoinputwithgroupinginrpc";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ YangNode selfNode = null;
+ // Create YANG node set
+ yangLinkerManager.createYangNodeSet(utilManager.getYangNodeSet());
+
+ // Add references to import list.
+ yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
+
+ YangLinkerUtils.updateFilePriority(utilManager.getYangNodeSet());
+
+ // Carry out inter-file linking.
+ yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet());
+
+ Iterator<YangNode> yangNodeIterator = utilManager.getYangNodeSet().iterator();
+
+ YangNode rootNode = yangNodeIterator.next();
+
+ if (rootNode.getName().equals("ietf-network")) {
+ selfNode = rootNode;
+ }
+ // Check whether the data model tree returned is of type module.
+ assertThat((selfNode instanceof YangModule), is(true));
+
+ // Check whether the node type is set properly to module.
+ assertThat(selfNode.getNodeType(), is(YangNodeType.MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) selfNode;
+ assertThat(yangNode.getName(), is("ietf-network"));
+
+ ListIterator<YangLeaf> leafIterator;
+ YangLeaf leafInfo;
+
+ leafIterator = yangNode.getListOfLeaf().listIterator();
+ leafInfo = leafIterator.next();
+
+ // Check whether the information in the leaf is correct.
+ assertThat(leafInfo.getName(), is("network-ref"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("leafref"));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.LEAFREF));
+ YangLeafRef leafref = (YangLeafRef) (leafInfo.getDataType().getDataTypeExtendedInfo());
+
+ // Check whether leafref type got resolved.
+ assertThat(leafref.getResolvableStatus(),
+ is(ResolvableStatus.RESOLVED));
+
+ // Check the effective type for the leaf.
+ assertThat(leafref.getEffectiveDataType().getDataType(),
+ is(YangDataTypes.UINT8));
+ }
+
+ /**
+ * Checks self resolution when leafref under module refers to invalid root node with relative path.
+ */
+ @Test
+ public void processSelfResolutionWhenLeafrefInModuleReferToInvalidRootNodeRelPath()
+ throws IOException, ParserException {
+
+ thrown.expect(LinkerException.class);
+ thrown.expectMessage(
+ "YANG file error: The target node, in the leafref path ../../../define/network-id, is invalid.");
+ String searchDir = "src/test/resources/leafreflinker/intrafile/relativepath/invalidrelativeancestoraccess";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+
+ // Create YANG node set
+ yangLinkerManager.createYangNodeSet(utilManager.getYangNodeSet());
+
+ // Add references to import list.
+ yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
+
+ YangLinkerUtils.updateFilePriority(utilManager.getYangNodeSet());
+
+ // Carry out inter-file linking.
+ yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet());
+ }
+
+ /**
+ * Checks self resolution when leafref under module refers to invalid node.
+ * Inter file linking also has to be done to know the error message with relative path.
+ */
+ @Test
+ public void processSelfResolutionWhenLeafrefInModuleReferToInvalidNodeRelPath()
+ throws IOException, ParserException {
+
+
+ thrown.expect(LinkerException.class);
+ thrown.expectMessage(
+ "YANG file error: Unable to find base leaf/leaf-list for given leafref path ../define/network-id");
+ String searchDir = "src/test/resources/leafreflinker/intrafile/relativepath/invalidnode";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+
+ // Create YANG node set
+ yangLinkerManager.createYangNodeSet(utilManager.getYangNodeSet());
+
+ // Add references to import list.
+ yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
+
+ YangLinkerUtils.updateFilePriority(utilManager.getYangNodeSet());
+
+ //Carry out inter-file linking.
+ yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet());
+ }
+
+ /**
+ * Checks self resolution when leafref of leaf-list under module refers to leaf in container with relative path.
+ */
+ @Test
+ public void processSelfResolutionWhenLeafrefInTypedefReferToContainerRelPath()
+ throws IOException, ParserException {
+
+ String searchDir = "src/test/resources/leafreflinker/intrafile/relativepath/leafrefintypedef";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ YangNode selfNode = null;
+ // Create YANG node set
+ yangLinkerManager.createYangNodeSet(utilManager.getYangNodeSet());
+
+ // Add references to import list.
+ yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
+
+ YangLinkerUtils.updateFilePriority(utilManager.getYangNodeSet());
+
+ // Carry out inter-file linking.
+ yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet());
+
+ Iterator<YangNode> yangNodeIterator = utilManager.getYangNodeSet().iterator();
+
+ YangNode rootNode = yangNodeIterator.next();
+
+ if (rootNode.getName().equals("ietf-network")) {
+ selfNode = rootNode;
+ }
+ // Check whether the data model tree returned is of type module.
+ assertThat((selfNode instanceof YangModule), is(true));
+
+ // Check whether the node type is set properly to module.
+ assertThat(selfNode.getNodeType(), is(YangNodeType.MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) selfNode;
+ assertThat(yangNode.getName(), is("ietf-network"));
+ ListIterator<YangLeaf> leafIterator;
+ YangLeaf leafInfo;
+ YangContainer yangContainer = (YangContainer) yangNode.getChild();
+ leafIterator = yangContainer.getListOfLeaf().listIterator();
+ leafInfo = leafIterator.next();
+
+ // Check whether the information in the leaf is correct under grouping.
+ assertThat(leafInfo.getName(), is("network-id"));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.LEAFREF));
+
+ YangLeafRef leafref = (YangLeafRef) (leafInfo.getDataType().getDataTypeExtendedInfo());
+
+ // Check whether leafref type got resolved.
+ assertThat(leafref.getResolvableStatus(),
+ is(ResolvableStatus.RESOLVED));
+
+ // Check the effective type for the leaf.
+ assertThat(leafref.getEffectiveDataType().getDataType(),
+ is(YangDataTypes.UINT8));
+ }
+
+ /**
+ * Checks self resolution when leafref refers to many other leafref with relative path.
+ */
+ @Test
+ public void processSelfResolutionWhenLeafrefReferToMultipleLeafrefRelPath()
+ throws IOException, ParserException {
+
+ String searchDir = "src/test/resources/leafreflinker/intrafile/relativepath/leafreftomultileafref";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ YangNode selfNode = null;
+ // Create YANG node set
+ yangLinkerManager.createYangNodeSet(utilManager.getYangNodeSet());
+
+ // Add references to import list.
+ yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
+
+ YangLinkerUtils.updateFilePriority(utilManager.getYangNodeSet());
+
+ // Carry out inter-file linking.
+ yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet());
+
+ Iterator<YangNode> yangNodeIterator = utilManager.getYangNodeSet().iterator();
+
+ YangNode rootNode = yangNodeIterator.next();
+
+ if (rootNode.getName().equals("Test")) {
+ selfNode = rootNode;
+ }
+ // Check whether the data model tree returned is of type module.
+ assertThat((selfNode instanceof YangModule), is(true));
+
+ // Check whether the node type is set properly to module.
+ assertThat(selfNode.getNodeType(), is(YangNodeType.MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) selfNode;
+ assertThat(yangNode.getName(), is("Test"));
+
+ YangContainer containerInModule = (YangContainer) yangNode.getChild().getNextSibling();
+ YangContainer containerInList = (YangContainer) containerInModule.getChild().getChild();
+
+ ListIterator<YangLeaf> leafIterator;
+ YangLeaf leafInfo;
+
+ leafIterator = containerInList.getListOfLeaf().listIterator();
+ leafInfo = leafIterator.next();
+
+ // Check whether the information in the leaf is correct under grouping.
+ assertThat(leafInfo.getName(), is("remove"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("leafref"));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.LEAFREF));
+ YangLeafRef leafref = (YangLeafRef) (leafInfo.getDataType().getDataTypeExtendedInfo());
+
+ assertThat(leafref.getResolvableStatus(),
+ is(ResolvableStatus.RESOLVED));
+
+ assertThat(leafref.getEffectiveDataType().getDataType(),
+ is(YangDataTypes.ENUMERATION));
+ }
+
+ /**
+ * Checks self resolution when leafref refers to many other leaf with derived type
+ * which in turn referring to another leaf with relative type.
+ */
+ @Test
+ public void processSelfResolutionWhenLeafrefReferToDerivedTypeReferringToLeafWithLeafrefRelType()
+ throws IOException, ParserException {
+
+ String searchDir = "src/test/resources/leafreflinker/intrafile/relativepath/leafreftotypedef";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ YangNode selfNode = null;
+ // Create YANG node set
+ yangLinkerManager.createYangNodeSet(utilManager.getYangNodeSet());
+
+ // Add references to import list.
+ yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
+
+ YangLinkerUtils.updateFilePriority(utilManager.getYangNodeSet());
+
+ // Carry out inter-file linking.
+ yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet());
+
+ Iterator<YangNode> yangNodeIterator = utilManager.getYangNodeSet().iterator();
+
+ YangNode rootNode = yangNodeIterator.next();
+
+ if (rootNode.getName().equals("Test")) {
+ selfNode = rootNode;
+ }
+ // Check whether the data model tree returned is of type module.
+ assertThat((selfNode instanceof YangModule), is(true));
+
+ // Check whether the node type is set properly to module.
+ assertThat(selfNode.getNodeType(), is(YangNodeType.MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) selfNode;
+ assertThat(yangNode.getName(), is("Test"));
+
+ YangContainer containerInModule = (YangContainer) yangNode.getChild().getNextSibling();
+ YangContainer containerInList = (YangContainer) containerInModule.getChild().getChild();
+
+ ListIterator<YangLeaf> leafIterator;
+ YangLeaf leafInfo;
+
+ leafIterator = containerInList.getListOfLeaf().listIterator();
+ leafInfo = leafIterator.next();
+
+ // Check whether the information in the leaf is correct under grouping.
+ assertThat(leafInfo.getName(), is("remove"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("leafref"));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.LEAFREF));
+ YangLeafRef leafref = (YangLeafRef) leafInfo.getDataType().getDataTypeExtendedInfo();
+
+ assertThat(leafref.getResolvableStatus(),
+ is(ResolvableStatus.RESOLVED));
+
+ assertThat(leafref.getEffectiveDataType().getDataType(),
+ is(YangDataTypes.ENUMERATION));
+ }
+
+ /**
+ * Checks the valid scenerios of path argument having proper setters.
+ */
+ @Test
+ public void processPathArgumentStatement()
+ throws IOException, ParserException {
+
+ String searchDir = "src/test/resources/leafreflinker/intrafile/relativepath/pathlistener";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ YangNode selfNode = null;
+ // Create YANG node set
+ yangLinkerManager.createYangNodeSet(utilManager.getYangNodeSet());
+
+ // Add references to import list.
+ yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
+
+ YangLinkerUtils.updateFilePriority(utilManager.getYangNodeSet());
+
+ // Carry out inter-file linking.
+ yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet());
+
+ Iterator<YangNode> yangNodeIterator = utilManager.getYangNodeSet().iterator();
+
+ YangNode rootNode = yangNodeIterator.next();
+
+ if (rootNode.getName().equals("PathListener")) {
+ selfNode = rootNode;
+ }
+ // Check whether the data model tree returned is of type module.
+ assertThat((selfNode instanceof YangModule), is(true));
+
+ // Check whether the node type is set properly to module.
+ assertThat(selfNode.getNodeType(), is(YangNodeType.MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) selfNode;
+ assertThat(yangNode.getName(), is("PathListener"));
+ YangList listInModule = (YangList) yangNode.getChild();
+
+ YangContainer containerInModule = (YangContainer) yangNode.getChild().getNextSibling();
+ ListIterator<YangLeaf> leafIterator;
+ YangLeaf leafInfo;
+
+ YangLeaf leafNameInList = listInModule.getListOfLeaf().listIterator().next();
+
+ leafIterator = containerInModule.getListOfLeaf().listIterator();
+ leafInfo = leafIterator.next();
+
+ // Check whether the information in the leaf is correct under grouping.
+ assertThat(leafInfo.getName(), is("ifname"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("leafref"));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.LEAFREF));
+ YangLeafRef leafref = (YangLeafRef) leafInfo.getDataType().getDataTypeExtendedInfo();
+ assertThat(leafref.getPathType(), Is.is(YangPathArgType.ABSOLUTE_PATH));
+
+ YangRelativePath relativePathForName = leafref.getRelativePath();
+ assertThat(relativePathForName.getAncestorNodeCount(), is(2));
+ List<YangAtomicPath> absPathForName = relativePathForName.getAtomicPathList();
+ Iterator<YangAtomicPath> absPathIteratorForName = absPathForName.listIterator();
+ YangAtomicPath abspathForName = absPathIteratorForName.next();
+ assertThat(abspathForName.getNodeIdentifier().getName(), is("interface"));
+ assertThat(abspathForName.getNodeIdentifier().getPrefix(), is("test"));
+ YangAtomicPath abspath1 = absPathIteratorForName.next();
+ assertThat(abspath1.getNodeIdentifier().getName(), is("name"));
+ assertThat(abspath1.getNodeIdentifier().getPrefix(), is("test"));
+
+ YangLeaf leafInfo1 = leafIterator.next();
+ // Check whether the information in the leaf is correct under grouping.
+ assertThat(leafInfo1.getName(), is("status"));
+ assertThat(leafInfo1.getDataType().getDataTypeName(), is("leafref"));
+ assertThat(leafInfo1.getDataType().getDataType(), is(YangDataTypes.LEAFREF));
+
+ YangLeafRef leafref1 = (YangLeafRef) leafInfo1.getDataType().getDataTypeExtendedInfo();
+ assertThat(leafref1.getPathType(), is(YangPathArgType.ABSOLUTE_PATH));
+
+ List<YangAtomicPath> absolutePathList = leafref1.getAtomicPath();
+ Iterator<YangAtomicPath> absPathIterator = absolutePathList.listIterator();
+ YangAtomicPath abspath = absPathIterator.next();
+ assertThat(abspath.getNodeIdentifier().getName(), is("interface"));
+ assertThat(abspath.getNodeIdentifier().getPrefix(), is("test"));
+
+ List<YangPathPredicate> pathPredicateList = abspath.getPathPredicatesList();
+ Iterator<YangPathPredicate> pathPredicate = pathPredicateList.listIterator();
+ YangPathPredicate pathPredicate1 = pathPredicate.next();
+ assertThat(pathPredicate1.getNodeId().getName(), is("name"));
+ assertThat(pathPredicate1.getNodeId().getPrefix(), nullValue());
+ assertThat(pathPredicate1.getRelPath().getAncestorNodeCount(), is(1));
+ assertThat(pathPredicate1.getPathOp(), is(YangPathOperator.EQUALTO));
+ assertThat(pathPredicate1.getRelPath().getAtomicPathList().listIterator().next().getNodeIdentifier()
+ .getName(), is("ifname"));
+ //TODO : Fill the path predicates
+// assertThat(pathPredicate1.getLeftAxisNode(), is(leafNameInList));
+// assertThat(pathPredicate1.getRightAxisNode(), is(leafInfo));
+ }
+
+ /**
+ * Checks inter file resolution when leafref refers to multiple leafrefs through many files.
+ */
+ @Test
+ public void processInterFileLeafrefRefersToMultipleLeafrefInMultipleFiles()
+ throws IOException, ParserException {
+
+ String searchDir = "src/test/resources/leafreflinker/interfile" +
+ "/interfileleafrefreferstomultipleleafrefinmultiplefiles";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ YangNode refNode1 = null;
+ YangNode refNode2 = null;
+ YangNode selfNode = null;
+
+ // Create YANG node set
+ yangLinkerManager.createYangNodeSet(utilManager.getYangNodeSet());
+
+ // Add references to import list.
+ yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
+
+ YangLinkerUtils.updateFilePriority(utilManager.getYangNodeSet());
+
+ // Carry out inter-file linking.
+ yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet());
+
+ for (YangNode rootNode : utilManager.getYangNodeSet()) {
+ if (rootNode.getName().equals("ietf-network-topology")) {
+ selfNode = rootNode;
+ } else if (rootNode.getName().equals("ietf-network")) {
+ refNode1 = rootNode;
+ } else {
+ refNode2 = rootNode;
+ }
+ }
+ // Check whether the data model tree returned is of type module.
+ assertThat(selfNode instanceof YangModule, is(true));
+
+ // Check whether the node type is set properly to module.
+ assertThat(selfNode.getNodeType(), is(MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) selfNode;
+ assertThat(yangNode.getName(), is("ietf-network-topology"));
+
+ YangList list = (YangList) yangNode.getChild().getChild();
+ ListIterator<YangLeaf> leafIterator = list.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getName(), is("link-tp"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("leafref"));
+ assertThat(leafInfo.getDataType().getDataType(), is(LEAFREF));
+
+ YangLeafRef leafref = (YangLeafRef) leafInfo.getDataType().getDataTypeExtendedInfo();
+
+ YangLeaf leafInfo2 = (YangLeaf) leafref.getReferredLeafOrLeafList();
+ assertThat(leafref.getReferredLeafOrLeafList(), is(leafInfo2));
+ assertThat(leafref.getResolvableStatus(), Is.is(ResolvableStatus.RESOLVED));
+
+ assertThat(leafref.getEffectiveDataType().getDataType(),
+ is(YangDataTypes.STRING));
+ }
+
+
+ /**
+ * Checks addition of if-feature list to leafref.
+ */
+ @Test
+ public void processSelfFileLinkingWithFeatureReferredByLeafref()
+ throws IOException, ParserException {
+
+ String searchDir = "src/test/resources/leafreflinker/iffeatuinleafref/simpleleafrefwithiffeature";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ YangNode selfNode = null;
+ // Create YANG node set
+ yangLinkerManager.createYangNodeSet(utilManager.getYangNodeSet());
+
+ // Add references to import list.
+ yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
+
+ YangLinkerUtils.updateFilePriority(utilManager.getYangNodeSet());
+
+ // Carry out inter-file linking.
+ yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet());
+
+ Iterator<YangNode> yangNodeIterator = utilManager.getYangNodeSet().iterator();
+
+ YangNode rootNode = yangNodeIterator.next();
+
+ if (rootNode.getName().equals("syslog")) {
+ selfNode = rootNode;
+ }
+ // Check whether the data model tree returned is of type module.
+ assertThat((selfNode instanceof YangModule), is(true));
+
+ // Check whether the node type is set properly to module.
+ assertThat(selfNode.getNodeType(), is(YangNodeType.MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) selfNode;
+ assertThat(yangNode.getName(), is("syslog"));
+
+ List<YangFeature> featureList = yangNode.getFeatureList();
+ YangFeature feature = featureList.iterator().next();
+ assertThat(feature.getName(), is("local-storage"));
+
+ YangContainer container = (YangContainer) yangNode.getChild();
+ assertThat(container.getName(), is("speed"));
+
+ List<YangLeaf> listOfLeaf = container.getListOfLeaf();
+ YangLeaf leaf = listOfLeaf.iterator().next();
+ assertThat(leaf.getName(), is("local-storage-limit"));
+
+ List<YangIfFeature> ifFeatureList = leaf.getIfFeatureList();
+ YangIfFeature ifFeature = ifFeatureList.iterator().next();
+ assertThat(ifFeature.getName().getName(), is("local-storage"));
+ assertThat(ifFeature.getResolvableStatus(), is(ResolvableStatus.RESOLVED));
+
+ ListIterator<YangLeaf> listOfLeafInModule = yangNode.getListOfLeaf().listIterator();
+ YangLeaf yangLeaf = listOfLeafInModule.next();
+ assertThat(yangLeaf.getName(), is("storage-value"));
+
+ YangLeafRef leafRef = (YangLeafRef) yangLeaf.getDataType().getDataTypeExtendedInfo();
+
+ assertThat(leafRef.getEffectiveDataType().getDataType(), is(YangDataTypes.UINT64));
+
+ List<YangIfFeature> ifFeatureListInLeafref = leafRef.getIfFeatureList();
+ YangIfFeature ifFeatureInLeafref = ifFeatureListInLeafref.iterator().next();
+ assertThat(ifFeatureInLeafref.getName().getName(), is("local-storage"));
+ assertThat(ifFeatureInLeafref.getResolvableStatus(), is(ResolvableStatus.RESOLVED));
+ }
+
+ /**
+ * Checks addition of if-feature list to leafref when referred leaf is again having leafref in it.
+ */
+ @Test
+ public void processSelfFileLinkingWithFeatureReferredByMultiLeafref()
+ throws IOException, ParserException {
+
+ String searchDir = "src/test/resources/leafreflinker/iffeatuinleafref/featurebymultileafref";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ YangNode selfNode = null;
+ // Create YANG node set
+ yangLinkerManager.createYangNodeSet(utilManager.getYangNodeSet());
+
+ // Add references to import list.
+ yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
+
+ YangLinkerUtils.updateFilePriority(utilManager.getYangNodeSet());
+
+ // Carry out inter-file linking.
+ yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet());
+
+ Iterator<YangNode> yangNodeIterator = utilManager.getYangNodeSet().iterator();
+
+ YangNode rootNode = yangNodeIterator.next();
+
+ if (rootNode.getName().equals("syslog")) {
+ selfNode = rootNode;
+ }
+ // Check whether the data model tree returned is of type module.
+ assertThat((selfNode instanceof YangModule), is(true));
+
+ // Check whether the node type is set properly to module.
+ assertThat(selfNode.getNodeType(), is(YangNodeType.MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) selfNode;
+ assertThat(yangNode.getName(), is("syslog"));
+
+ List<YangFeature> featureList = yangNode.getFeatureList();
+ YangFeature feature = featureList.iterator().next();
+ assertThat(feature.getName(), is("local-storage"));
+
+ YangContainer container = (YangContainer) yangNode.getChild();
+ assertThat(container.getName(), is("speed"));
+
+ List<YangLeaf> listOfLeaf = container.getListOfLeaf();
+ YangLeaf leaf = listOfLeaf.iterator().next();
+ assertThat(leaf.getName(), is("local-storage-limit"));
+
+ List<YangIfFeature> ifFeatureList = leaf.getIfFeatureList();
+ YangIfFeature ifFeature = ifFeatureList.iterator().next();
+ assertThat(ifFeature.getName().getName(), is("local-storage"));
+ assertThat(ifFeature.getResolvableStatus(), is(ResolvableStatus.RESOLVED));
+
+ ListIterator<YangLeaf> listOfLeafInModule = yangNode.getListOfLeaf().listIterator();
+ YangLeaf yangLeaf = listOfLeafInModule.next();
+ assertThat(yangLeaf.getName(), is("storage-value"));
+
+ YangLeafRef leafRef = (YangLeafRef) yangLeaf.getDataType().getDataTypeExtendedInfo();
+
+ assertThat(leafRef.getEffectiveDataType().getDataType(), is(YangDataTypes.UINT64));
+
+ List<YangIfFeature> ifFeatureListInLeafref = leafRef.getIfFeatureList();
+ YangIfFeature ifFeatureInLeafref = ifFeatureListInLeafref.iterator().next();
+
+ assertThat(ifFeatureInLeafref.getName().getName(), is("main-storage"));
+ assertThat(ifFeatureInLeafref.getResolvableStatus(), is(ResolvableStatus.RESOLVED));
+
+ YangIfFeature ifFeatureInLeafref1 = ifFeatureListInLeafref.iterator().next();
+
+ assertThat(ifFeatureInLeafref1.getName().getName(), is("main-storage"));
+ assertThat(ifFeatureInLeafref1.getResolvableStatus(), is(ResolvableStatus.RESOLVED));
+ }
+
+ /**
+ * Checks self resolution when leafref in grouping is copied to augment.
+ */
+ @Test
+ public void processSelfResolutionWhenLeafrefInGroupingIsUnderAugment()
+ throws IOException, ParserException {
+
+ String searchDir = "src/test/resources/leafreflinker/intrafile/leafrefInAugment";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ YangNode selfNode = null;
+
+ // Create YANG node set
+ yangLinkerManager.createYangNodeSet(utilManager.getYangNodeSet());
+
+ // Add references to import list.
+ yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
+
+ YangLinkerUtils.updateFilePriority(utilManager.getYangNodeSet());
+
+ // Carry out inter-file linking.
+ yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet());
+
+ Iterator<YangNode> yangNodeIterator = utilManager.getYangNodeSet().iterator();
+
+ YangNode rootNode = yangNodeIterator.next();
+
+ if (rootNode.getName().equals("topology")) {
+ selfNode = rootNode;
+ }
+
+ // Check whether the data model tree returned is of type module.
+ assertThat((selfNode instanceof YangModule), is(true));
+
+ // Check whether the node type is set properly to module.
+ assertThat(selfNode.getNodeType(), is(YangNodeType.MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) selfNode;
+ assertThat(yangNode.getName(), is("topology"));
+
+ ListIterator<YangLeaf> leafIterator;
+ YangLeaf leafInfo;
+
+ YangAugment augment = (YangAugment) yangNode.getChild().getNextSibling();
+
+ YangList list = (YangList) augment.getChild().getChild().getChild().getChild().getChild();
+
+ leafIterator = list.getListOfLeaf().listIterator();
+ leafInfo = leafIterator.next();
+
+ // Check whether the information in the leaf is correct.
+ assertThat(leafInfo.getName(), is("src-tp-ref"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("leafref"));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.LEAFREF));
+ YangLeafRef leafref = (YangLeafRef) (leafInfo.getDataType().getDataTypeExtendedInfo());
+
+ // Check whether leafref type got resolved.
+ assertThat(leafref.getResolvableStatus(),
+ is(ResolvableStatus.RESOLVED));
+
+ // Check the effective type for the leaf.
+ assertThat(leafref.getEffectiveDataType().getDataType(),
+ is(YangDataTypes.UINT8));
+ }
+
+ /**
+ * Checks self resolution when leafref under grouping's uses.
+ */
+ @Test
+ public void processSelfResolutionWhenLeafrefUnderGroupingUses()
+ throws IOException, ParserException {
+
+ String searchDir = "src/test/resources/leafreflinker/intrafile/leafrefinusesundergrouping";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ YangNode selfNode = null;
+ YangNode refNode = null;
+
+ // Create YANG node set
+ yangLinkerManager.createYangNodeSet(utilManager.getYangNodeSet());
+
+ // Add references to import list.
+ yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
+
+ YangLinkerUtils.updateFilePriority(utilManager.getYangNodeSet());
+
+ // Carry out inter-file linking.
+ yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet());
+
+ Iterator<YangNode> yangNodeIterator = utilManager.getYangNodeSet().iterator();
+
+ YangNode rootNode = yangNodeIterator.next();
+
+ if (rootNode.getName().equals("ietf-network")) {
+ selfNode = rootNode;
+ refNode = yangNodeIterator.next();
+ } else {
+ refNode = rootNode;
+ selfNode = yangNodeIterator.next();
+ }
+
+ // Check whether the data model tree returned is of type module.
+ assertThat(selfNode instanceof YangModule, is(true));
+
+ // Check whether the node type is set properly to module.
+ assertThat(selfNode.getNodeType(), is(MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) selfNode;
+ assertThat(yangNode.getName(), is("ietf-network"));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode1 = (YangModule) refNode;
+ assertThat(yangNode1.getName(), is("network"));
+
+ YangContainer yangContainer = (YangContainer) yangNode.getChild().getNextSibling().getNextSibling();
+ assertThat(yangContainer.getName(), is("fine"));
+
+ YangContainer yangContainer1 = (YangContainer) yangContainer.getChild().getNextSibling();
+ assertThat(yangContainer1.getName(), is("hi"));
+
+ ListIterator<YangLeaf> leafIterator;
+ YangLeaf leafInfo;
+
+ leafIterator = yangContainer1.getListOfLeaf().listIterator();
+ leafInfo = leafIterator.next();
+
+ // Check whether the information in the leaf is correct.
+ assertThat(leafInfo.getName(), is("network-id-ref"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("leafref"));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.LEAFREF));
+ YangLeafRef leafref = (YangLeafRef) (leafInfo.getDataType().getDataTypeExtendedInfo());
+
+ // Check whether leafref type got resolved.
+ assertThat(leafref.getResolvableStatus(),
+ is(ResolvableStatus.RESOLVED));
+
+ // Check the effective type for the leaf.
+ assertThat(leafref.getEffectiveDataType().getDataType(),
+ is(YangDataTypes.DERIVED));
+ }
+
+ /**
+ * Checks self resolution when leafref under typedef refers to the node where it is used.
+ */
+ @Test
+ public void processSelfResolutionWhenLeafrefInTypedefIsUsedInSameReferredNode()
+ throws IOException, ParserException {
+
+ String searchDir = "src/test/resources/leafreflinker/intrafile/leafrefintypedefwithsamereferpath";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ YangNode selfNode = null;
+
+ // Create YANG node set
+ yangLinkerManager.createYangNodeSet(utilManager.getYangNodeSet());
+
+ // Add references to import list.
+ yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
+
+ YangLinkerUtils.updateFilePriority(utilManager.getYangNodeSet());
+
+ // Carry out inter-file linking.
+ yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet());
+
+ Iterator<YangNode> yangNodeIterator = utilManager.getYangNodeSet().iterator();
+
+ YangNode rootNode = yangNodeIterator.next();
+
+ if (rootNode.getName().equals("typedef")) {
+ selfNode = rootNode;
+ }
+
+ // Check whether the data model tree returned is of type module.
+ assertThat((selfNode instanceof YangModule), is(true));
+
+ // Check whether the node type is set properly to module.
+ assertThat(selfNode.getNodeType(), is(YangNodeType.MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) selfNode;
+ assertThat(yangNode.getName(), is("typedef"));
+
+ ListIterator<YangLeaf> leafIterator;
+ YangLeaf leafInfo;
+
+ YangContainer yangContainer = (YangContainer) yangNode.getChild().getNextSibling();
+
+ leafIterator = yangContainer.getListOfLeaf().listIterator();
+ leafInfo = leafIterator.next();
+
+ // Check whether the information in the leaf is correct.
+ assertThat(leafInfo.getName(), is("reference"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("leafref"));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.LEAFREF));
+ YangLeafRef leafref = (YangLeafRef) (leafInfo.getDataType().getDataTypeExtendedInfo());
+
+ // Check whether leafref type got resolved.
+ assertThat(leafref.getResolvableStatus(),
+ is(ResolvableStatus.RESOLVED));
+
+ // Check the effective type for the leaf.
+ assertThat(leafref.getEffectiveDataType().getDataType(),
+ is(YangDataTypes.UINT8));
+ }
+}
diff --git a/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/IntraFileTypeLinkingTest.java b/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/IntraFileTypeLinkingTest.java
new file mode 100644
index 0000000..85129fa
--- /dev/null
+++ b/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/IntraFileTypeLinkingTest.java
@@ -0,0 +1,565 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yang.compiler.plugin.maven;
+
+import org.hamcrest.core.Is;
+import org.junit.Test;
+import org.onosproject.yang.compiler.datamodel.YangContainer;
+import org.onosproject.yang.compiler.datamodel.YangDerivedInfo;
+import org.onosproject.yang.compiler.datamodel.YangLeaf;
+import org.onosproject.yang.compiler.datamodel.YangList;
+import org.onosproject.yang.compiler.datamodel.YangModule;
+import org.onosproject.yang.compiler.datamodel.YangNode;
+import org.onosproject.yang.compiler.datamodel.YangNodeType;
+import org.onosproject.yang.compiler.datamodel.YangTypeDef;
+import org.onosproject.yang.compiler.datamodel.utils.ResolvableStatus;
+import org.onosproject.yang.compiler.datamodel.utils.builtindatatype.YangDataTypes;
+import org.onosproject.yang.compiler.linker.exceptions.LinkerException;
+import org.onosproject.yang.compiler.parser.exceptions.ParserException;
+import org.onosproject.yang.compiler.parser.impl.YangUtilsParserManager;
+
+import java.io.IOException;
+import java.util.ListIterator;
+
+import static org.hamcrest.CoreMatchers.nullValue;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+
+/**
+ * Test cases for testing "type" intra file linking.
+ */
+public class IntraFileTypeLinkingTest {
+
+ private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+ /**
+ * Checks self resolution when typedef and leaf using type are siblings.
+ */
+ @Test
+ public void processSelfResolutionWhenTypeAndTypedefAtRootLevel()
+ throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/SelfResolutionWhenTypeAndTypedefAtRootLevel.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.is(YangNodeType.MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) node;
+ assertThat(yangNode.getName(), is("Test"));
+
+ ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("hello"));
+ assertThat(leafInfo.getDataType().getDataType(), Is.is(YangDataTypes.DERIVED));
+
+ assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
+ Is.is((YangTypeDef) node.getChild()));
+
+ assertThat(leafInfo.getDataType().getResolvableStatus(), Is.is(ResolvableStatus.RESOLVED));
+
+ YangDerivedInfo<?> derivedInfo = (YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo();
+
+ // Check for the effective built-in type.
+ assertThat(derivedInfo.getEffectiveBuiltInType(), Is.is(YangDataTypes.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()));
+ }
+
+ /**
+ * Checks self resolution when typedef and leaf using type are at different
+ * level where typedef is at the root.
+ */
+ @Test
+ public void processSelfFileLinkingTypedefAtRootTypeTwoLevelInHierarchy()
+ throws IOException, ParserException {
+
+ YangNode node =
+ manager.getDataModel("src/test/resources/SelfFileLinkingTypedefAtRootTypeTwoLevelInHierarchy.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.is(YangNodeType.MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) node;
+ assertThat(yangNode.getName(), is("Test"));
+
+ YangContainer yangContainer = (YangContainer) node.getChild().getNextSibling();
+
+ YangList yangList = (YangList) yangContainer.getChild();
+
+ ListIterator<YangLeaf> leafIterator = yangList.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("hello"));
+ assertThat(leafInfo.getDataType().getDataType(), Is.is(YangDataTypes.DERIVED));
+
+ assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
+ is((YangTypeDef) node.getChild()));
+
+ assertThat(leafInfo.getDataType().getResolvableStatus(), Is.is(ResolvableStatus.RESOLVED));
+
+ YangDerivedInfo<?> derivedInfo = (YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo();
+
+ // Check for the effective built-in type.
+ assertThat(derivedInfo.getEffectiveBuiltInType(), Is.is(YangDataTypes.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()));
+ }
+
+ /**
+ * Checks self resolution when typedef and leaf using type are at different
+ * level where typedef is at the root and defined after parent holder
+ * of type.
+ */
+ @Test
+ public void processSelfFileLinkingTypedefAtRootIsAfterContainerHavingType()
+ throws IOException, ParserException {
+
+ YangNode node =
+ manager.getDataModel("src/test/resources/SelfFileLinkingTypedefAtRootIsAfterContainerHavingType.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.is(YangNodeType.MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) node;
+ assertThat(yangNode.getName(), is("Test"));
+
+ YangContainer yangContainer = (YangContainer) node.getChild();
+
+ YangList yangList = (YangList) yangContainer.getChild();
+
+ ListIterator<YangLeaf> leafIterator = yangList.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("hello"));
+ assertThat(leafInfo.getDataType().getDataType(), Is.is(YangDataTypes.DERIVED));
+
+ assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
+ is((YangTypeDef) node.getChild().getNextSibling()));
+
+ assertThat(leafInfo.getDataType().getResolvableStatus(), Is.is(ResolvableStatus.RESOLVED));
+
+ YangDerivedInfo<?> derivedInfo = (YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo();
+
+ // Check for the effective built-in type.
+ assertThat(derivedInfo.getEffectiveBuiltInType(), Is.is(YangDataTypes.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()));
+ }
+
+ /**
+ * Checks self resolution when typedef and leaf using type are at different
+ * level where typedef is at the level of root+1 and defined after parent
+ * holder of type.
+ */
+ @Test
+ public void processSelfFileLinkingTypedefAtMiddleLevelAfterParentHolder()
+ throws IOException, ParserException {
+
+ YangNode node =
+ manager.getDataModel("src/test/resources/SelfFileLinkingTypedefAtMiddleLevelAfterParentHolder.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.is(YangNodeType.MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) node;
+ assertThat(yangNode.getName(), is("Test"));
+
+ YangContainer yangContainer = (YangContainer) node.getChild();
+
+ YangList yangList = (YangList) yangContainer.getChild();
+
+ ListIterator<YangLeaf> leafIterator = yangList.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("hello"));
+ assertThat(leafInfo.getDataType().getDataType(), Is.is(YangDataTypes.DERIVED));
+
+ assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
+ is((YangTypeDef) yangContainer.getChild().getNextSibling()));
+
+ assertThat(leafInfo.getDataType().getResolvableStatus(), Is.is(ResolvableStatus.RESOLVED));
+
+ YangDerivedInfo<?> derivedInfo = (YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo();
+
+ // Check for the effective built-in type.
+ assertThat(derivedInfo.getEffectiveBuiltInType(), Is.is(YangDataTypes.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()));
+ }
+
+ /**
+ * Checks self resolution when typedef hierarchical references are present.
+ */
+ @Test
+ public void processSelfFileLinkingWithTypdefHierarchicalReference()
+ throws IOException, ParserException {
+
+ YangNode node =
+ manager.getDataModel("src/test/resources/SelfFileLinkingWithTypdefHierarchicalReference.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.is(YangNodeType.MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) node;
+ assertThat(yangNode.getName(), is("Test"));
+
+ YangContainer yangContainer = (YangContainer) node.getChild().getNextSibling();
+
+ YangList yangList = (YangList) yangContainer.getChild();
+
+ ListIterator<YangLeaf> leafIterator = yangList.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("FirstClass"));
+ assertThat(leafInfo.getDataType().getDataType(), Is.is(YangDataTypes.DERIVED));
+
+ assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
+ is((YangTypeDef) yangList.getChild()));
+ assertThat(leafInfo.getDataType().getResolvableStatus(),
+ Is.is(ResolvableStatus.RESOLVED));
+
+ YangTypeDef typeDef1 = (YangTypeDef) yangList.getChild();
+
+ assertThat(((YangDerivedInfo<?>) typeDef1.getTypeDefBaseType().getDataTypeExtendedInfo()).getReferredTypeDef(),
+ is((YangTypeDef) yangContainer.getChild().getNextSibling()));
+ assertThat(typeDef1.getTypeDefBaseType().getResolvableStatus(),
+ Is.is(ResolvableStatus.RESOLVED));
+
+ YangTypeDef typeDef2 = (YangTypeDef) yangContainer.getChild().getNextSibling();
+
+ assertThat(((YangDerivedInfo<?>) typeDef2.getTypeDefBaseType().getDataTypeExtendedInfo()).getReferredTypeDef(),
+ is((YangTypeDef) node.getChild()));
+ assertThat(typeDef2.getTypeDefBaseType().getResolvableStatus(),
+ Is.is(ResolvableStatus.RESOLVED));
+
+ YangDerivedInfo<?> derivedInfo = (YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo();
+
+ // Check for the effective built-in type.
+ assertThat(derivedInfo.getEffectiveBuiltInType(), Is.is(YangDataTypes.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()));
+ }
+
+ /**
+ * Checks self resolution when typedef hierarchical references are present
+ * with last type is unresolved.
+ */
+ @Test
+ public void processSelfFileLinkingWithTypdefHierarchicalRefUnresolved()
+ throws IOException, ParserException {
+
+ YangNode node =
+ manager.getDataModel("src/test/resources/SelfFileLinkingWithTypdefHierarchicalRefUnresolved.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.is(YangNodeType.MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) node;
+ assertThat(yangNode.getName(), is("Test"));
+
+ YangContainer yangContainer = (YangContainer) node.getChild().getNextSibling();
+
+ YangList yangList = (YangList) yangContainer.getChild();
+
+ ListIterator<YangLeaf> leafIterator = yangList.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("FirstClass"));
+ assertThat(leafInfo.getDataType().getDataType(), Is.is(YangDataTypes.DERIVED));
+
+ assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
+ is((YangTypeDef) yangList.getChild()));
+ assertThat(leafInfo.getDataType().getResolvableStatus(),
+ Is.is(ResolvableStatus.INTRA_FILE_RESOLVED));
+
+ YangTypeDef typeDef1 = (YangTypeDef) yangList.getChild();
+
+ assertThat(((YangDerivedInfo<?>) typeDef1.getTypeDefBaseType().getDataTypeExtendedInfo()).getReferredTypeDef(),
+ is((YangTypeDef) yangContainer.getChild().getNextSibling()));
+ assertThat(typeDef1.getTypeDefBaseType().getResolvableStatus(),
+ Is.is(ResolvableStatus.INTRA_FILE_RESOLVED));
+
+ YangTypeDef typeDef2 = (YangTypeDef) yangContainer.getChild().getNextSibling();
+
+ assertThat(((YangDerivedInfo<?>) typeDef2.getTypeDefBaseType().getDataTypeExtendedInfo()).getReferredTypeDef(),
+ is((YangTypeDef) node.getChild()));
+ assertThat(typeDef2.getTypeDefBaseType().getResolvableStatus(),
+ Is.is(ResolvableStatus.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()));
+ }
+
+ /**
+ * Checks self resolution when type uses prefix of self module.
+ */
+ @Test
+ public void processSelfFileLinkingWithTypeWithSelfModulePrefix()
+ throws IOException, ParserException {
+
+ YangNode node =
+ manager.getDataModel("src/test/resources/SelfFileLinkingWithTypeWithSelfModulePrefix.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.is(YangNodeType.MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) node;
+ assertThat(yangNode.getName(), is("Test"));
+
+ YangContainer yangContainer = (YangContainer) node.getChild().getNextSibling();
+
+ YangList yangList = (YangList) yangContainer.getChild();
+
+ ListIterator<YangLeaf> leafIterator = yangList.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("FirstClass"));
+ assertThat(leafInfo.getDataType().getDataType(), Is.is(YangDataTypes.DERIVED));
+
+ assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
+ is((YangTypeDef) yangList.getChild()));
+ assertThat(leafInfo.getDataType().getResolvableStatus(),
+ Is.is(ResolvableStatus.RESOLVED));
+
+ YangTypeDef typeDef1 = (YangTypeDef) yangList.getChild();
+
+ assertThat(((YangDerivedInfo<?>) typeDef1.getTypeDefBaseType().getDataTypeExtendedInfo()).getReferredTypeDef(),
+ is((YangTypeDef) yangContainer.getChild().getNextSibling()));
+ assertThat(typeDef1.getTypeDefBaseType().getResolvableStatus(),
+ Is.is(ResolvableStatus.RESOLVED));
+
+ YangTypeDef typeDef2 = (YangTypeDef) yangContainer.getChild().getNextSibling();
+
+ assertThat(((YangDerivedInfo<?>) typeDef2.getTypeDefBaseType().getDataTypeExtendedInfo()).getReferredTypeDef(),
+ is((YangTypeDef) node.getChild()));
+ assertThat(typeDef2.getTypeDefBaseType().getResolvableStatus(),
+ Is.is(ResolvableStatus.RESOLVED));
+
+ YangDerivedInfo<?> derivedInfo = (YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo();
+
+ // Check for the effective built-in type.
+ assertThat(derivedInfo.getEffectiveBuiltInType(), Is.is(YangDataTypes.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()));
+ }
+
+ /**
+ * Checks self resolution when some type uses prefix of self module
+ * some uses external prefix.
+ */
+ @Test
+ public void processSelfFileLinkingWithTypeWithSelfAndExternalPrefixMix()
+ throws IOException, ParserException {
+
+ YangNode node =
+ manager.getDataModel("src/test/resources/SelfFileLinkingWithTypeWithSelfAndExternalPrefixMix.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.is(YangNodeType.MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) node;
+ assertThat(yangNode.getName(), is("Test"));
+
+ YangContainer yangContainer = (YangContainer) node.getChild().getNextSibling();
+
+ YangList yangList = (YangList) yangContainer.getChild();
+
+ ListIterator<YangLeaf> leafIterator = yangList.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("FirstClass"));
+ assertThat(leafInfo.getDataType().getDataType(), Is.is(YangDataTypes.DERIVED));
+
+ assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
+ is((YangTypeDef) yangList.getChild()));
+ assertThat(leafInfo.getDataType().getResolvableStatus(),
+ Is.is(ResolvableStatus.INTRA_FILE_RESOLVED));
+
+ YangTypeDef typeDef1 = (YangTypeDef) yangList.getChild();
+
+ YangTypeDef typeDef2 = (YangTypeDef) yangContainer.getChild().getNextSibling();
+
+ assertThat(((YangDerivedInfo<?>) typeDef2.getTypeDefBaseType().getDataTypeExtendedInfo()).getReferredTypeDef(),
+ is((YangTypeDef) node.getChild()));
+ assertThat(typeDef2.getTypeDefBaseType().getResolvableStatus(),
+ Is.is(ResolvableStatus.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()));
+ }
+
+ /**
+ * Check self resolution when type referred typedef is not available in
+ * file, it should not result in exception.
+ */
+ @Test
+ public void processSelfResolutionWhenTypeReferredTypedefNotDefined()
+ throws IOException, LinkerException {
+
+ YangNode node =
+ manager.getDataModel("src/test/resources/SelfResolutionWhenTypeReferredTypedefNotDefined.yang");
+ }
+
+ /**
+ * Checks self resolution when typedef and leaf using type are at different
+ * level where typedef is is not an ancestor of type, it should not result
+ * in exception.
+ */
+ @Test
+ public void processSelfFileLinkingTypedefNotFound()
+ throws IOException, LinkerException {
+
+ YangNode node = manager.getDataModel("src/test/resources/SelfFileLinkingTypedefNotFound.yang");
+ }
+
+ /**
+ * Checks hierarchical self resolution with self resolution failure scenario.
+ * It should not result in exception.
+ */
+ @Test
+ public void processSelfFileLinkingWithHierarchicalTypeFailureScenario()
+ throws IOException, LinkerException {
+
+ YangNode node =
+ manager.getDataModel("src/test/resources/SelfFileLinkingWithHierarchicalTypeFailureScenario.yang");
+ }
+
+ /**
+ * Checks self resolution when typedef and leaf using type are siblings for binary type.
+ */
+ @Test
+ public void processSelfResolutionWhenTypeAndTypedefAtRootLevelForBinary()
+ throws IOException, ParserException {
+
+ YangNode node
+ = manager.getDataModel("src/test/resources/SelfResolutionWhenTypeAndTypedefAtRootLevelForBinary.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.is(YangNodeType.MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) node;
+ assertThat(yangNode.getName(), is("ospf"));
+
+ ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getName(), is("typedef14"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("type14"));
+ assertThat(leafInfo.getDataType().getDataType(), Is.is(YangDataTypes.DERIVED));
+
+ assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
+ is((YangTypeDef) node.getChild()));
+
+ assertThat(leafInfo.getDataType().getResolvableStatus(), Is.is(ResolvableStatus.RESOLVED));
+
+ YangDerivedInfo<?> derivedInfo = (YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo();
+
+ // Check for the effective built-in type.
+ assertThat(derivedInfo.getEffectiveBuiltInType(), Is.is(YangDataTypes.BINARY));
+
+ // 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/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/IntraFileUsesLinkingTest.java b/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/IntraFileUsesLinkingTest.java
new file mode 100644
index 0000000..f5dee73
--- /dev/null
+++ b/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/IntraFileUsesLinkingTest.java
@@ -0,0 +1,653 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yang.compiler.plugin.maven;
+
+import org.hamcrest.core.Is;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.onosproject.yang.compiler.datamodel.YangContainer;
+import org.onosproject.yang.compiler.datamodel.YangGrouping;
+import org.onosproject.yang.compiler.datamodel.YangInput;
+import org.onosproject.yang.compiler.datamodel.YangLeaf;
+import org.onosproject.yang.compiler.datamodel.YangList;
+import org.onosproject.yang.compiler.datamodel.YangModule;
+import org.onosproject.yang.compiler.datamodel.YangNode;
+import org.onosproject.yang.compiler.datamodel.YangNodeType;
+import org.onosproject.yang.compiler.datamodel.YangTypeDef;
+import org.onosproject.yang.compiler.datamodel.YangUses;
+import org.onosproject.yang.compiler.datamodel.utils.ResolvableStatus;
+import org.onosproject.yang.compiler.datamodel.utils.builtindatatype.YangDataTypes;
+import org.onosproject.yang.compiler.linker.exceptions.LinkerException;
+import org.onosproject.yang.compiler.parser.exceptions.ParserException;
+import org.onosproject.yang.compiler.parser.impl.YangUtilsParserManager;
+
+import java.io.IOException;
+import java.util.ListIterator;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+
+/**
+ * Test cases for testing uses intra file linking.
+ */
+public class IntraFileUsesLinkingTest {
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+ /**
+ * Checks self resolution when grouping and uses are siblings.
+ * Grouping followed by uses.
+ */
+ @Test
+ public void processSelfResolutionWhenUsesAndGroupingAtRootLevel()
+ throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/SelfResolutionWhenUsesAndGroupingAtRootLevel.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<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ // 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().getDataType(), is(YangDataTypes.STRING));
+
+ // Check whether grouping is the sibling of module's child.
+ assertThat((yangNode.getChild().getNextSibling() instanceof YangGrouping), is(true));
+
+ YangGrouping grouping = (YangGrouping) yangNode.getChild().getNextSibling();
+ leafIterator = grouping.getListOfLeaf().listIterator();
+ leafInfo = leafIterator.next();
+
+ // 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().getDataType(), is(YangDataTypes.STRING));
+
+ // Check whether uses is module's child.
+ assertThat((yangNode.getChild() instanceof YangUses), is(true));
+ YangUses uses = (YangUses) yangNode.getChild();
+
+ // Check whether uses get resolved
+ assertThat(uses.getResolvableStatus(),
+ Is.is(ResolvableStatus.RESOLVED));
+ }
+
+ /**
+ * Checks self resolution when grouping and uses are siblings.
+ * Grouping has a child node.
+ */
+ @Test
+ public void processSelfResolutionWhenUsesAndGroupingAtRootLevelGroupingWithChild()
+ throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel(
+ "src/test/resources/SelfResolutionWhenUsesAndGroupingAtRootLevelGroupingWithChild.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<YangLeaf> leafIterator;
+ YangLeaf leafInfo;
+
+ ListIterator<YangLeaf> leafIterator1 = yangNode.getListOfLeaf().listIterator();
+ YangLeaf leafInfo1 = leafIterator1.next();
+
+ // Check whether the information in the leaf is correct under module.
+ assertThat(leafInfo1.getName(), is("treat"));
+ assertThat(leafInfo1.getDataType().getDataTypeName(), is("string"));
+ assertThat(leafInfo1.getDataType().getDataType(), is(YangDataTypes.STRING));
+
+ YangContainer container = (YangContainer) yangNode.getChild().getNextSibling().getNextSibling();
+
+ // Check whether the container name is set correctly which is under module.
+ assertThat(container.getName(), is("test"));
+
+ leafIterator = container.getListOfLeaf().listIterator();
+ leafInfo = leafIterator.next();
+
+ // 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().getDataType(), is(YangDataTypes.STRING));
+
+ // Check whether grouping is the sibling of module's child.
+ assertThat((yangNode.getChild().getNextSibling() instanceof YangGrouping), is(true));
+
+ YangGrouping grouping = (YangGrouping) yangNode.getChild().getNextSibling();
+ leafIterator = grouping.getListOfLeaf().listIterator();
+ leafInfo = leafIterator.next();
+
+ // 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().getDataType(), is(YangDataTypes.STRING));
+
+ // Check whether container is the child of grouping.
+ assertThat((grouping.getChild() instanceof YangContainer), is(true));
+ container = (YangContainer) grouping.getChild();
+
+ // Check whether the container name is set correctly which is under grouping.
+ assertThat(container.getName(), is("test"));
+
+ leafIterator = container.getListOfLeaf().listIterator();
+ leafInfo = leafIterator.next();
+
+ // 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().getDataType(), is(YangDataTypes.STRING));
+
+ // Check whether uses is module's child.
+ assertThat((yangNode.getChild() instanceof YangUses), is(true));
+ YangUses uses = (YangUses) yangNode.getChild();
+
+ // Check whether uses get resolved.
+ assertThat(uses.getResolvableStatus(),
+ is(ResolvableStatus.RESOLVED));
+
+ }
+
+ /**
+ * Checks self resolution when grouping in rpc and uses in output of the same rpc.
+ * Uses is followed by grouping.
+ */
+ @Test
+ public void processSelfResolutionGroupingInRpcAndUsesInOutput()
+ throws IOException, ParserException {
+
+ YangNode node = manager
+ .getDataModel("src/test/resources/SelfResolutionGroupingInRpcAndUsesInOutput.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("rock"));
+
+ ListIterator<YangLeaf> leafIterator;
+ YangLeaf leafInfo;
+
+ // Check whether grouping is the child of rpc.
+ assertThat((yangNode.getChild().getChild() instanceof YangGrouping), is(true));
+ YangGrouping grouping = (YangGrouping) yangNode.getChild().getChild();
+
+ // Check whether the grouping name is set correctly.
+ assertThat(grouping.getName(), is("hello"));
+
+ // Check whether list is the child of grouping.
+ assertThat((grouping.getChild() instanceof YangList), is(true));
+ YangList yangListNode = (YangList) grouping.getChild();
+
+ // Check whether the list name is set correctly.
+ assertThat(yangListNode.getName(), is("valid"));
+
+ leafIterator = yangListNode.getListOfLeaf().listIterator();
+ leafInfo = leafIterator.next();
+
+ // Check whether the information in the leaf is correct under list which is under grouping.
+ assertThat(leafInfo.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16"));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
+ assertThat(leafInfo.getUnits(), is("\"seconds\""));
+ assertThat(leafInfo.getReference(), is("\"RFC 6020\""));
+
+ // Check whether uses is input's child.
+ assertThat((yangNode.getChild().getChild().getNextSibling().getChild() instanceof YangUses), is(true));
+ YangUses uses = (YangUses) yangNode.getChild().getChild().getNextSibling().getChild();
+
+ // Check whether uses get resolved.
+ assertThat(uses.getResolvableStatus(), is(ResolvableStatus.RESOLVED));
+
+ YangInput inputNode = ((YangInput) yangNode.getChild().getChild().getNextSibling());
+ assertThat((inputNode.getChild() instanceof YangUses), is(true));
+
+ YangList yangList = ((YangList) inputNode.getChild().getNextSibling());
+ assertThat(yangList.getName(), is("valid"));
+
+ leafIterator = yangList.getListOfLeaf().listIterator();
+ leafInfo = leafIterator.next();
+
+ // Check whether the information in the leaf is correct under list which is deep copied.
+ assertThat(leafInfo.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16"));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
+ assertThat(leafInfo.getUnits(), is("\"seconds\""));
+ assertThat(leafInfo.getReference(), is("\"RFC 6020\""));
+ }
+
+ /**
+ * Checks the failure scenario when uses is referring to its own grouping directly.
+ */
+ @Test
+ public void processSelfResolutionGroupingReferencingItselfFailureScenerio()
+ throws IOException {
+
+ thrown.expect(LinkerException.class);
+ thrown.expectMessage(
+ "YANG file error: Duplicate input identifier detected, same as leaf \"zip-code in 7 at 13 in " +
+ "src/test/resources/SelfResolutionGroupingReferencingItselfFailureScenerio.yang\"");
+ YangNode node = manager
+ .getDataModel("src/test/resources/SelfResolutionGroupingReferencingItselfFailureScenerio.yang");
+
+ }
+
+ /**
+ * Checks the when multiple uses are present and are referred to the grouping at different levels.
+ */
+ @Test
+ public void processSelfResolutionGroupingWithMultipleUses()
+ throws IOException, ParserException {
+
+ YangNode node = manager
+ .getDataModel("src/test/resources/SelfResolutionGroupingWithMultipleUses.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<YangLeaf> leafIterator;
+ YangLeaf leafInfo;
+
+ // Check whether grouping is the child of container.
+ assertThat((yangNode.getChild().getChild() instanceof YangGrouping), is(true));
+ YangGrouping grouping = (YangGrouping) yangNode.getChild().getChild();
+
+ // Check whether the grouping name is set correctly.
+ assertThat(grouping.getName(), is("endpoint"));
+
+ // Check whether uses is endpoint-grouping's child.
+ assertThat((grouping.getChild() instanceof YangUses), is(true));
+ YangUses firstUses = (YangUses) grouping.getChild();
+
+ // Check whether uses get resolved.
+ assertThat(firstUses.getResolvableStatus(), is(ResolvableStatus.RESOLVED));
+
+ // Validate first uses child is cloned properly
+ assertThat((firstUses.getNextSibling().getNextSibling()
+ .getNextSibling().getNextSibling() instanceof YangList), is(true));
+ YangList firstUsesChild = ((YangList) firstUses.getNextSibling().getNextSibling().getNextSibling()
+ .getNextSibling());
+ assertThat(firstUsesChild.getName(), is("valid"));
+
+ leafIterator = firstUsesChild.getListOfLeaf().listIterator();
+ leafInfo = leafIterator.next();
+
+ // Check whether the information in the leaf is correct under list which has been deep copied from grouping.
+ assertThat(leafInfo.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16"));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
+ assertThat(leafInfo.getUnits(), is("\"seconds\""));
+ assertThat(leafInfo.getReference(), is("\"RFC 6020\""));
+
+ //validate uses second
+ assertThat((firstUses.getNextSibling() instanceof YangContainer), is(true));
+ YangContainer container = (YangContainer) firstUses.getNextSibling();
+ assertThat(container.getName(), is("design"));
+
+ assertThat((container.getChild() instanceof YangUses), is(true));
+ assertThat((container.getListOfLeaf().iterator().next().getName()), is("ink"));
+
+ //validate uses third
+ assertThat((container.getChild().getNextSibling() instanceof YangContainer), is(true));
+ YangContainer container2 = ((YangContainer) container.getChild().getNextSibling());
+ assertThat(container2.getName(), is("correct"));
+ assertThat((container2.getChild() instanceof YangUses), is(true));
+ assertThat((container2.getChild().getNextSibling() instanceof YangContainer), is(true));
+ YangContainer thirdUsesChild = ((YangContainer) container2.getChild().getNextSibling());
+ assertThat(thirdUsesChild.getListOfLeaf().iterator().next().getName(), is("zip-code"));
+
+ //validate fourth uses
+ assertThat((firstUses.getNextSibling().getNextSibling() instanceof YangUses), is(true));
+ YangUses fourthUses = ((YangUses) firstUses.getNextSibling().getNextSibling());
+ assertThat((fourthUses.getNextSibling().getNextSibling().getNextSibling() instanceof YangTypeDef),
+ is(true));
+ assertThat(fourthUses.getNextSibling().getNextSibling().getNextSibling().getName(), is("my-type"));
+
+ //validate fifth uses
+ assertThat((firstUses.getNextSibling().getNextSibling().getNextSibling() instanceof YangUses),
+ is(true));
+
+ //validate end point uses
+ assertThat(grouping.getNextSibling() instanceof YangUses, is(true));
+ assertThat(grouping.getNextSibling().getNextSibling().getNextSibling().getNextSibling()
+ .getNextSibling().getNextSibling().getNextSibling().getNextSibling() instanceof YangContainer,
+ is(true));
+ container = (YangContainer) grouping.getNextSibling().getNextSibling().getNextSibling().getNextSibling()
+ .getNextSibling().getNextSibling().getNextSibling().getNextSibling();
+ assertThat(container.getName(), is("design"));
+ container2 = (YangContainer) container.getChild().getNextSibling();
+ assertThat(container2.getName(), is("correct"));
+ assertThat(container2.getChild().getNextSibling().getName(), is("value"));
+ }
+
+ /**
+ * Checks the failure scenario when uses is present under the same node many times.
+ */
+ @Test
+ public void processSelfResolutionGroupingHavingSameUsesManyTimes()
+ throws IOException, ParserException {
+
+ thrown.expect(ParserException.class);
+ thrown.expectMessage(
+ "YANG File Error: Identifier collision detected in uses as " +
+ "\"failure in 10 at 13 in src/test/resources/SelfResolutionGroupingHavingSameUsesManyTimes.yang");
+ YangNode node = manager
+ .getDataModel("src/test/resources/SelfResolutionGroupingHavingSameUsesManyTimes.yang");
+ }
+
+ /**
+ * Checks the rpc having both typedef and grouping.
+ * It also checks that the grouping under different nodes will not give any problem in resolving uses.
+ */
+ @Test
+ public void processSelfResolutionRpcWithOneTypedefAndTwoGroupingUnderDifferentNode()
+ throws IOException, ParserException {
+
+ YangNode node = manager
+ .getDataModel(
+ "src/test/resources/SelfResolutionRpcWithOneTypedefAndTwoGroupingUnderDifferentNode.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("rock"));
+
+ ListIterator<YangLeaf> leafIterator;
+ YangLeaf leafInfo;
+
+ // Check whether grouping is the child of input.
+ assertThat((yangNode.getChild().getChild().getChild() instanceof YangGrouping), is(true));
+ YangGrouping groupingUnderInput = (YangGrouping) yangNode.getChild().getChild().getChild();
+
+ // Check whether the grouping name is set correctly.
+ assertThat(groupingUnderInput.getName(), is("creative"));
+
+ leafIterator = groupingUnderInput.getListOfLeaf().listIterator();
+ leafInfo = leafIterator.next();
+
+ // Check whether the information in the leaf is correct under grouping.
+ assertThat(leafInfo.getName(), is("carry"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("string"));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING));
+
+ // Check whether grouping is the child of output.
+ assertThat((yangNode.getChild().getChild().getNextSibling().getChild() instanceof YangGrouping), is(true));
+ YangGrouping grouping = (YangGrouping) yangNode.getChild().getChild().getNextSibling().getChild();
+ assertThat(grouping.getName(), is("creative"));
+
+ // Check whether typedef is the sibling of grouping.
+ assertThat((grouping.getNextSibling() instanceof YangTypeDef), is(true));
+
+ YangTypeDef typedef = (YangTypeDef) grouping.getNextSibling();
+ assertThat(typedef.getName(), is("my-type"));
+
+ // Check whether uses is the sibling of typedef.
+ assertThat((typedef.getNextSibling() instanceof YangUses), is(true));
+
+ // Check whether uses get resolved.
+ YangUses uses = (YangUses) typedef.getNextSibling();
+ assertThat(uses.getName(), is("creative"));
+ assertThat(uses.getResolvableStatus(),
+ is(ResolvableStatus.RESOLVED));
+ }
+
+ /**
+ * Checks the failure scenario when uses is cannot resolve its grouping.
+ * It shouldnt result in exception
+ */
+ @Test
+ public void processSelfResolutionNestedGroupingWithUnresolvedUses()
+ throws IOException, LinkerException {
+
+ YangNode node = manager
+ .getDataModel("src/test/resources/SelfResolutionNestedGroupingWithUnresolvedUses.yang");
+ }
+
+ /**
+ * Checks self resolution when typedef hierarchical references are present
+ * with last type is unresolved.
+ */
+ @Test
+ public void processSelfFileLinkingWithGroupingHierarchicalRefUnresolved()
+ throws IOException, ParserException {
+
+ YangNode node = manager
+ .getDataModel("src/test/resources/SelfFileLinkingWithGroupingHierarchicalRefUnresolved.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"));
+
+ // Check whether container is the sibling of grouping.
+ assertThat((yangNode.getChild().getNextSibling() instanceof YangContainer), is(true));
+ YangContainer containerWithUses = (YangContainer) yangNode.getChild().getNextSibling();
+ assertThat(containerWithUses.getName(), is("test"));
+
+ // Check whether uses is the child of container.
+ assertThat((containerWithUses.getChild() instanceof YangUses), is(true));
+ YangUses uses = (YangUses) containerWithUses.getChild();
+ assertThat(uses.getName(), is("create"));
+
+ // Check whether uses is getting resolved.
+ assertThat(uses.getResolvableStatus(),
+ is(ResolvableStatus.INTRA_FILE_RESOLVED));
+
+ // Check whether grouping is the child of module.
+ assertThat((yangNode.getChild() instanceof YangGrouping), is(true));
+ YangGrouping groupingWithUses = (YangGrouping) yangNode.getChild();
+ assertThat(groupingWithUses.getName(), is("create"));
+
+ // Check whether uses with prefix from from other file, is the child of grouping.
+ assertThat((groupingWithUses.getChild() instanceof YangUses), is(true));
+ YangUses uses1 = (YangUses) groupingWithUses.getChild();
+ assertThat(uses1.getName(), is("valid"));
+
+ // Check whether this uses is getting intra-file-resolved.
+ assertThat(uses1.getResolvableStatus(),
+ is(ResolvableStatus.INTRA_FILE_RESOLVED));
+ }
+
+ /**
+ * Checks self resolution when uses has prefix of self module.
+ */
+ @Test
+ public void processSelfFileLinkingWithGroupingWithSelfModulePrefix()
+ throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/SelfFileLinkingWithGroupingWithSelfModulePrefix.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"));
+
+ // Check whether container is the sibling of grouping.
+ YangContainer yangContainer = (YangContainer) node.getChild().getNextSibling();
+
+ // Check whether list is the child of container.
+ YangList yangList = (YangList) yangContainer.getChild();
+
+ // Check whether uses is the child of list.
+ assertThat((yangList.getChild() instanceof YangUses), is(true));
+ YangUses yangUses1 = (YangUses) yangList.getChild();
+ assertThat(yangUses1.getName(), is("FirstClass"));
+
+ // Check whether uses is getting resolved.
+ assertThat(yangUses1.getResolvableStatus(),
+ is(ResolvableStatus.RESOLVED));
+
+ // Check whether grouping is the sibling of uses.
+ YangGrouping yangGrouping1 = (YangGrouping) yangUses1.getNextSibling();
+ assertThat(yangGrouping1.getName(), is("FirstClass"));
+
+ // Check whether uses is the child of grouping.
+ YangUses yangUses2 = (YangUses) yangGrouping1.getChild();
+ assertThat(yangUses2.getName(), is("PassingClass"));
+
+ // Check the uses gets resolved.
+ assertThat(yangUses2.getResolvableStatus(),
+ is(ResolvableStatus.RESOLVED));
+
+ // Check whether grouping is the sibling of list.
+ YangGrouping yangGrouping2 = (YangGrouping) yangList.getNextSibling();
+ assertThat(yangGrouping2.getName(), is("PassingClass"));
+
+ // Check uses is the child of that grouping which has prefix of the same module.
+ YangUses yangUses3 = (YangUses) yangGrouping2.getChild();
+ assertThat(yangUses3.getName(), is("Percentage"));
+
+ // Check uses is getting resolved.
+ assertThat(yangUses3.getResolvableStatus(),
+ is(ResolvableStatus.RESOLVED));
+
+ // Check grouping is the child of module.
+ YangGrouping yangGrouping3 = (YangGrouping) node.getChild();
+
+ ListIterator<YangLeaf> leafIterator;
+ YangLeaf leafInfo;
+ leafIterator = yangGrouping3.getListOfLeaf().listIterator();
+ leafInfo = leafIterator.next();
+
+ // 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().getDataType(), is(YangDataTypes.STRING));
+
+ }
+
+ /**
+ * Checks self resolution when some type uses prefix of self module
+ * some uses external prefix.
+ */
+ @Test
+ public void processSelfFileLinkingWithGroupingWithSelfAndExternalPrefixMix()
+ throws IOException, ParserException {
+
+ YangNode node = manager
+ .getDataModel("src/test/resources/SelfFileLinkingWithGroupingWithSelfAndExternalPrefixMix.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"));
+
+ // Check whether container is the sibling of grouping.
+ YangContainer yangContainer = (YangContainer) node.getChild().getNextSibling();
+
+ // Check whether list is the child of container.
+ YangList yangList = (YangList) yangContainer.getChild();
+
+ // Check whether uses is the child of list.
+ assertThat((yangList.getChild() instanceof YangUses), is(true));
+ YangUses yangUses1 = (YangUses) yangList.getChild();
+ assertThat(yangUses1.getName(), is("FirstClass"));
+
+ // Check whether uses is getting resolved.
+ assertThat(yangUses1.getResolvableStatus(),
+ is(ResolvableStatus.INTRA_FILE_RESOLVED));
+
+ // Check whether grouping is the sibling of uses.
+ YangGrouping yangGrouping1 = (YangGrouping) yangUses1.getNextSibling();
+ assertThat(yangGrouping1.getName(), is("FirstClass"));
+
+ // Check whether uses is the child of grouping which has prefix from other module.
+ YangUses yangUses2 = (YangUses) yangGrouping1.getChild();
+ assertThat(yangUses2.getName(), is("PassingClass"));
+
+ // Check whether uses gets intra-file-resolved.
+ assertThat(yangUses2.getResolvableStatus(),
+ is(ResolvableStatus.INTRA_FILE_RESOLVED));
+
+ // Check whether grouping is the sibling of list.
+ YangGrouping yangGrouping2 = (YangGrouping) yangList.getNextSibling();
+ assertThat(yangGrouping2.getName(), is("PassingClass"));
+
+ // Check uses is the child of that grouping which has prefix of the same module.
+ YangUses yangUses3 = (YangUses) yangGrouping2.getChild();
+ assertThat(yangUses3.getName(), is("Percentage"));
+
+ // Check uses is getting resolved.
+ assertThat(yangUses3.getResolvableStatus(),
+ is(ResolvableStatus.RESOLVED));
+
+ // Check grouping is the child of module.
+ YangGrouping yangGrouping3 = (YangGrouping) node.getChild();
+ ListIterator<YangLeaf> leafIterator;
+ YangLeaf leafInfo;
+ leafIterator = yangGrouping3.getListOfLeaf().listIterator();
+ leafInfo = leafIterator.next();
+
+ // 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().getDataType(), is(YangDataTypes.STRING));
+ }
+
+}
diff --git a/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/NotificationTranslatorTest.java b/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/NotificationTranslatorTest.java
new file mode 100644
index 0000000..6043bee
--- /dev/null
+++ b/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/NotificationTranslatorTest.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yang.compiler.plugin.maven;
+
+import org.junit.Test;
+import org.onosproject.yang.compiler.datamodel.YangNode;
+import org.onosproject.yang.compiler.translator.tojava.JavaCodeGeneratorUtil;
+import org.onosproject.yang.compiler.utils.io.YangPluginConfig;
+import org.onosproject.yang.compiler.utils.io.impl.YangIoUtils;
+import org.onosproject.yang.compiler.parser.exceptions.ParserException;
+import org.onosproject.yang.compiler.parser.impl.YangUtilsParserManager;
+
+import java.io.IOException;
+
+/**
+ * Unit tests for union translator.
+ */
+public final class NotificationTranslatorTest {
+
+ private final YangUtilsParserManager manager = new YangUtilsParserManager();
+ private final static String YANG = "src/test/resources/NotificationTest" +
+ ".yang";
+ private final static String DIR = "target/notificationTranslator/";
+
+ /**
+ * Checks union translation should not result in any exception.
+ */
+ @Test
+ public void processNotificationTranslator()
+ throws IOException, ParserException {
+ YangIoUtils.deleteDirectory(DIR);
+ YangNode node = manager.getDataModel(YANG);
+
+ YangPluginConfig yangPluginConfig = new YangPluginConfig();
+ yangPluginConfig.setCodeGenDir(DIR);
+
+ JavaCodeGeneratorUtil.generateJavaCode(node, yangPluginConfig);
+ YangIoUtils.deleteDirectory(DIR);
+ }
+
+ // TODO enhance the test cases, after having a framework of translator test.
+}
diff --git a/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/PathPredicateLinkingTest.java b/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/PathPredicateLinkingTest.java
new file mode 100644
index 0000000..5f6f15b
--- /dev/null
+++ b/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/PathPredicateLinkingTest.java
@@ -0,0 +1,360 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yang.compiler.plugin.maven;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.onosproject.yang.compiler.datamodel.YangAtomicPath;
+import org.onosproject.yang.compiler.datamodel.YangAugment;
+import org.onosproject.yang.compiler.datamodel.YangContainer;
+import org.onosproject.yang.compiler.datamodel.YangLeaf;
+import org.onosproject.yang.compiler.datamodel.YangLeafRef;
+import org.onosproject.yang.compiler.datamodel.YangList;
+import org.onosproject.yang.compiler.datamodel.YangModule;
+import org.onosproject.yang.compiler.datamodel.YangNode;
+import org.onosproject.yang.compiler.datamodel.YangPathPredicate;
+import org.onosproject.yang.compiler.linker.exceptions.LinkerException;
+import org.onosproject.yang.compiler.linker.impl.YangLinkerManager;
+import org.onosproject.yang.compiler.linker.impl.YangLinkerUtils;
+import org.onosproject.yang.compiler.utils.io.impl.YangFileScanner;
+
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.ListIterator;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+
+/**
+ * Test cases for path predicate linking in leaf-ref.
+ */
+public class PathPredicateLinkingTest {
+
+ private final YangUtilManager utilMgr = new YangUtilManager();
+ private final YangLinkerManager linkerMgr = new YangLinkerManager();
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ private ListIterator<YangLeaf> leafItr;
+ private YangLeaf ifName;
+ private YangLeaf address;
+ private YangLeaf name;
+ private Iterator<YangAtomicPath> pathItr;
+ private YangAtomicPath atomicPath;
+ private Iterator<YangPathPredicate> predicateItr;
+ private YangPathPredicate predicate;
+
+ /**
+ * Processes simple path predicate which gets linked within the same file
+ * using relative path.
+ *
+ * @throws IOException IO file error
+ */
+ @Test
+ public void processSimplePathPredicate() throws IOException {
+
+ String searchDir = "src/test/resources/pathpredicate/simple";
+ utilMgr.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilMgr.parseYangFileInfoSet();
+ utilMgr.createYangNodeSet();
+ YangNode selfNode;
+
+ linkerMgr.createYangNodeSet(utilMgr.getYangNodeSet());
+ linkerMgr.addRefToYangFilesImportList(utilMgr.getYangNodeSet());
+
+ YangLinkerUtils.updateFilePriority(utilMgr.getYangNodeSet());
+
+ linkerMgr.processInterFileLinking(utilMgr.getYangNodeSet());
+ Iterator<YangNode> nodeItr = utilMgr.getYangNodeSet().iterator();
+ selfNode = nodeItr.next();
+
+ // Gets the list node.
+ YangList yangList = (YangList) selfNode.getChild();
+ // Gets the container node.
+ YangContainer container = (YangContainer) yangList.getNextSibling();
+
+ ListIterator<YangLeaf> leafIterator;
+ YangLeaf ifName;
+ YangLeaf address;
+ YangLeaf name;
+ Iterator<YangAtomicPath> pathItr;
+ YangAtomicPath atomicPath;
+ Iterator<YangPathPredicate> predicateItr;
+ YangPathPredicate predicate;
+
+ leafIterator = container.getListOfLeaf().listIterator();
+ ifName = leafIterator.next();
+ address = leafIterator.next();
+
+ // Gets the address leaf's leaf-ref type.
+ YangLeafRef<?> leafRef2 = (YangLeafRef) address.getDataType()
+ .getDataTypeExtendedInfo();
+ pathItr = leafRef2.getAtomicPath().listIterator();
+ atomicPath = pathItr.next();
+
+ // Gets the path-predicate.
+ predicateItr = atomicPath.getPathPredicatesList().listIterator();
+ predicate = predicateItr.next();
+
+ // Gets the left and right axis node in path-predicate.
+ YangLeaf yangLeftLeaf = (YangLeaf) predicate.getLeftAxisNode();
+ YangLeaf yangRightLeaf = (YangLeaf) predicate.getRightAxisNode();
+
+ leafIterator = yangList.getListOfLeaf().listIterator();
+ name = leafIterator.next();
+
+ // Checks that right and left path-predicates are correct.
+ assertThat(yangLeftLeaf, is(name));
+ assertThat(yangRightLeaf, is(ifName));
+ }
+
+ /**
+ * Processes simple inter file path predicate which gets linked to another
+ * file using absolute path.
+ *
+ * @throws IOException IO file error
+ */
+ @Test
+ public void processSimpleInterFilePathPredicate() throws IOException {
+
+ String searchDir = "src/test/resources/pathpredicate/simpleinterfile";
+ utilMgr.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilMgr.parseYangFileInfoSet();
+ utilMgr.createYangNodeSet();
+ YangModule selfNode;
+
+ linkerMgr.createYangNodeSet(utilMgr.getYangNodeSet());
+ linkerMgr.addRefToYangFilesImportList(utilMgr.getYangNodeSet());
+
+ YangLinkerUtils.updateFilePriority(utilMgr.getYangNodeSet());
+
+ linkerMgr.processInterFileLinking(utilMgr.getYangNodeSet());
+ Iterator<YangNode> nodeItr = utilMgr.getYangNodeSet().iterator();
+
+ YangNode rootNode = nodeItr.next();
+ YangModule refNode;
+ if (rootNode.getName().equals("ietf-network")) {
+ selfNode = (YangModule) rootNode;
+ refNode = (YangModule) nodeItr.next();
+ } else {
+ refNode = (YangModule) rootNode;
+ selfNode = (YangModule) nodeItr.next();
+ }
+
+ // Gets the container node.
+ YangContainer container = (YangContainer) selfNode.getChild();
+ // Gets the list node.
+ YangList yangList = (YangList) refNode.getChild();
+
+ ListIterator<YangLeaf> leafItr;
+ YangLeaf ifName;
+ YangLeaf address;
+ YangLeaf name;
+ Iterator<YangAtomicPath> pathItr;
+ YangAtomicPath atomicPath;
+ Iterator<YangPathPredicate> predicateItr;
+ YangPathPredicate predicate;
+
+ leafItr = container.getListOfLeaf().listIterator();
+ ifName = leafItr.next();
+ address = leafItr.next();
+
+ // Gets the address leaf's leaf-ref type.
+ YangLeafRef<?> leafRef2 = (YangLeafRef) address.getDataType()
+ .getDataTypeExtendedInfo();
+ pathItr = leafRef2.getAtomicPath().listIterator();
+ atomicPath = pathItr.next();
+
+ // Gets the path-predicate.
+ predicateItr = atomicPath.getPathPredicatesList().listIterator();
+ predicate = predicateItr.next();
+
+ // Gets the left and right axis node in path-predicate.
+ YangLeaf yangLeftLeaf = (YangLeaf) predicate.getLeftAxisNode();
+ YangLeaf yangRightLeaf = (YangLeaf) predicate.getRightAxisNode();
+
+ leafItr = yangList.getListOfLeaf().listIterator();
+ name = leafItr.next();
+
+ // Checks that right and left path-predicates are correct.
+ assertThat(yangLeftLeaf, is(name));
+ assertThat(yangRightLeaf, is(ifName));
+ }
+
+ /**
+ * Processes inter file path predicate, where leaf-ref is present under
+ * YANG augment.
+ *
+ * @throws IOException IO file error
+ */
+ @Test
+ public void processInterFilePathPredicateFromAugment() throws IOException {
+
+ String searchDir = "src/test/resources/pathpredicate/interfileaugment";
+ utilMgr.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilMgr.parseYangFileInfoSet();
+ utilMgr.createYangNodeSet();
+ YangModule selfNode;
+
+ linkerMgr.createYangNodeSet(utilMgr.getYangNodeSet());
+ linkerMgr.addRefToYangFilesImportList(utilMgr.getYangNodeSet());
+
+ YangLinkerUtils.updateFilePriority(utilMgr.getYangNodeSet());
+
+ linkerMgr.processInterFileLinking(utilMgr.getYangNodeSet());
+ Iterator<YangNode> nodeItr = utilMgr.getYangNodeSet().iterator();
+
+ YangNode rootNode = nodeItr.next();
+ YangModule refNode;
+ if (rootNode.getName().equals("ietf-network")) {
+ selfNode = (YangModule) rootNode;
+ refNode = (YangModule) nodeItr.next();
+ } else {
+ refNode = (YangModule) rootNode;
+ selfNode = (YangModule) nodeItr.next();
+ }
+
+ // Gets the augment node.
+ YangList list = (YangList) selfNode.getChild().getChild();
+
+ // Gets the augment node.
+ YangAugment augment = (YangAugment) refNode.getChild();
+
+ ListIterator<YangLeaf> leafItr;
+ YangLeaf test;
+ YangLeaf networkId;
+ YangLeaf networkRef;
+ Iterator<YangAtomicPath> pathItr;
+ YangAtomicPath atomicPath;
+ Iterator<YangPathPredicate> predicateItr;
+ YangPathPredicate predicate;
+
+ leafItr = augment.getListOfLeaf().listIterator();
+ test = leafItr.next();
+
+ YangLeafRef<?> leafRef =
+ (YangLeafRef) test.getDataType().getDataTypeExtendedInfo();
+ pathItr = leafRef.getAtomicPath().listIterator();
+ pathItr.next();
+ atomicPath = pathItr.next();
+
+ // Gets the path-predicate.
+ predicateItr = atomicPath.getPathPredicatesList().listIterator();
+ predicate = predicateItr.next();
+
+ // Gets the left and right axis node in path-predicate.
+ YangLeaf yangLeftLeaf = (YangLeaf) predicate.getLeftAxisNode();
+ YangLeaf yangRightLeaf = (YangLeaf) predicate.getRightAxisNode();
+
+ leafItr = list.getListOfLeaf().listIterator();
+ networkId = leafItr.next();
+ YangContainer reference = (YangContainer) list.getChild();
+ leafItr = reference.getListOfLeaf().listIterator();
+ networkRef = leafItr.next();
+
+ // Checks that right and left path-predicates are correct.
+ assertThat(yangLeftLeaf, is(networkId));
+ assertThat(yangRightLeaf, is(networkRef));
+ }
+
+ /**
+ * Processes an invalid scenario where the target leaf/leaf-list in
+ * path-predicate is not found.
+ *
+ * @throws IOException IO file error
+ */
+ @Test
+ public void processInvalidPathLink() throws IOException {
+ thrown.expect(LinkerException.class);
+ thrown.expectMessage(
+ "YANG file error: There is no leaf/leaf-list in YANG node as " +
+ "mentioned in the path predicate of the leafref path " +
+ "../../interface[ifname = current()/../../ifname]" +
+ "/address/ip");
+
+ String searchDir = "src/test/resources/pathpredicate/invalidlinking";
+ utilMgr.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilMgr.parseYangFileInfoSet();
+ utilMgr.createYangNodeSet();
+
+ linkerMgr.createYangNodeSet(utilMgr.getYangNodeSet());
+ linkerMgr.addRefToYangFilesImportList(utilMgr.getYangNodeSet());
+
+ YangLinkerUtils.updateFilePriority(utilMgr.getYangNodeSet());
+
+ linkerMgr.processInterFileLinking(utilMgr.getYangNodeSet());
+ }
+
+ /**
+ * Processes an invalid scenario where the right axis node doesn't come
+ * under YANG list node.
+ *
+ * @throws IOException IO file error
+ */
+ @Test
+ public void processInvalidPathLinkForList() throws IOException {
+ thrown.expect(LinkerException.class);
+ thrown.expectMessage(
+ "YANG file error: Path predicates are only applicable for " +
+ "YANG list. The leafref path has path predicate for" +
+ " non-list node in the path ../../default-address" +
+ "[ifname = current()/../ifname]/ifname");
+
+ String searchDir = "src/test/resources/pathpredicate/invalidlinking2";
+ utilMgr.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilMgr.parseYangFileInfoSet();
+ utilMgr.createYangNodeSet();
+ YangNode selfNode;
+
+ linkerMgr.createYangNodeSet(utilMgr.getYangNodeSet());
+ linkerMgr.addRefToYangFilesImportList(utilMgr.getYangNodeSet());
+
+ YangLinkerUtils.updateFilePriority(utilMgr.getYangNodeSet());
+
+ linkerMgr.processInterFileLinking(utilMgr.getYangNodeSet());
+ }
+
+ /**
+ * Processes an invalid scenario where the node in path predicate is not
+ * present in the traversal.
+ *
+ * @throws IOException IO file error
+ */
+ @Test
+ public void processInvalidPathLinkForInvalidNode()
+ throws IOException {
+ thrown.expect(LinkerException.class);
+ thrown.expectMessage(
+ "YANG file error: The path predicate of the leafref has an " +
+ "invalid path in ../../interface[name = current()/" +
+ "../../address/ifname]/address/ip");
+
+ String searchDir = "src/test/resources/pathpredicate/invalidlinking3";
+ utilMgr.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilMgr.parseYangFileInfoSet();
+ utilMgr.createYangNodeSet();
+
+ linkerMgr.createYangNodeSet(utilMgr.getYangNodeSet());
+ linkerMgr.addRefToYangFilesImportList(utilMgr.getYangNodeSet());
+
+ YangLinkerUtils.updateFilePriority(utilMgr.getYangNodeSet());
+
+ linkerMgr.processInterFileLinking(utilMgr.getYangNodeSet());
+ }
+}
diff --git a/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/ProcessSubTreeCodeGenTest.java b/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/ProcessSubTreeCodeGenTest.java
new file mode 100644
index 0000000..fcc5545
--- /dev/null
+++ b/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/ProcessSubTreeCodeGenTest.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yang.compiler.plugin.maven;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.junit.Test;
+import org.onosproject.yang.compiler.utils.io.YangPluginConfig;
+import org.onosproject.yang.compiler.utils.io.impl.YangFileScanner;
+import org.onosproject.yang.compiler.utils.io.impl.YangIoUtils;
+import org.onosproject.yang.compiler.parser.exceptions.ParserException;
+
+import java.io.File;
+import java.io.IOException;
+
+/**
+ * Unit test case for process sub tree code generation test.
+ */
+public class ProcessSubTreeCodeGenTest {
+
+ private final YangUtilManager utilManager = new YangUtilManager();
+ private static final String DIR = "target/pstf/";
+ private static final String COMP = System.getProperty("user.dir") + File
+ .separator + DIR;
+
+ /**
+ * Checks pst translation should not result in any exception.
+ *
+ * @throws MojoExecutionException
+ */
+ @Test
+ public void processTranslator() throws IOException, ParserException, MojoExecutionException {
+
+ YangIoUtils.deleteDirectory(DIR);
+ String searchDir = "src/test/resources/pstcodegen";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ utilManager.resolveDependenciesUsingLinker();
+
+ YangPluginConfig yangPluginConfig = new YangPluginConfig();
+ yangPluginConfig.setCodeGenDir(DIR);
+ utilManager.translateToJava(yangPluginConfig);
+ YangPluginConfig.compileCode(COMP);
+ YangIoUtils.deleteDirectory(DIR);
+ }
+
+}
diff --git a/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/RestrictionResolutionTest.java b/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/RestrictionResolutionTest.java
new file mode 100644
index 0000000..9908367
--- /dev/null
+++ b/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/RestrictionResolutionTest.java
@@ -0,0 +1,913 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yang.compiler.plugin.maven;
+
+import org.hamcrest.core.Is;
+import org.junit.Test;
+import org.onosproject.yang.compiler.datamodel.YangDerivedInfo;
+import org.onosproject.yang.compiler.datamodel.YangLeaf;
+import org.onosproject.yang.compiler.datamodel.YangModule;
+import org.onosproject.yang.compiler.datamodel.YangNode;
+import org.onosproject.yang.compiler.datamodel.YangPatternRestriction;
+import org.onosproject.yang.compiler.datamodel.YangRangeInterval;
+import org.onosproject.yang.compiler.datamodel.YangRangeRestriction;
+import org.onosproject.yang.compiler.datamodel.YangStringRestriction;
+import org.onosproject.yang.compiler.datamodel.YangType;
+import org.onosproject.yang.compiler.datamodel.YangTypeDef;
+import org.onosproject.yang.compiler.datamodel.exceptions.DataModelException;
+import org.onosproject.yang.compiler.datamodel.utils.ResolvableStatus;
+import org.onosproject.yang.compiler.datamodel.utils.builtindatatype.YangDataTypes;
+import org.onosproject.yang.compiler.datamodel.utils.builtindatatype.YangInt16;
+import org.onosproject.yang.compiler.datamodel.utils.builtindatatype.YangInt32;
+import org.onosproject.yang.compiler.datamodel.utils.builtindatatype.YangUint64;
+import org.onosproject.yang.compiler.linker.exceptions.LinkerException;
+import org.onosproject.yang.compiler.parser.exceptions.ParserException;
+import org.onosproject.yang.compiler.parser.impl.YangUtilsParserManager;
+
+import java.io.IOException;
+import java.math.BigInteger;
+import java.util.ListIterator;
+
+import static org.hamcrest.CoreMatchers.nullValue;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.IsNull.notNullValue;
+import static org.onosproject.yang.compiler.datamodel.YangNodeType.MODULE_NODE;
+import static org.onosproject.yang.compiler.datamodel.utils.builtindatatype.YangDataTypes.DERIVED;
+import static org.onosproject.yang.compiler.datamodel.utils.builtindatatype.YangDataTypes.INT32;
+import static org.onosproject.yang.compiler.datamodel.utils.builtindatatype.YangDataTypes.STRING;
+
+/**
+ * Test cases for testing restriction resolution.
+ */
+public final class RestrictionResolutionTest {
+
+ private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+ /**
+ * Checks length restriction in typedef.
+ */
+ @Test
+ public void processLengthRestrictionInTypedef()
+ throws IOException, ParserException, DataModelException {
+
+ YangNode node = manager.getDataModel("src/test/resources/LengthRestrictionInTypedef.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(MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) node;
+ assertThat(yangNode.getName(), is("Test"));
+
+ ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("hello"));
+ assertThat(leafInfo.getDataType().getDataType(), is(DERIVED));
+
+ assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
+ Is.is((YangTypeDef) node.getChild()));
+
+ assertThat(leafInfo.getDataType().getResolvableStatus(), Is.is(ResolvableStatus.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(notNullValue()));
+
+ // Check for the restriction value.
+ YangStringRestriction stringRestriction = (YangStringRestriction) derivedInfo.getResolvedExtendedInfo();
+ YangRangeRestriction lengthRestriction = stringRestriction.getLengthRestriction();
+
+ ListIterator<YangRangeInterval> lengthListIterator = lengthRestriction.getAscendingRangeIntervals()
+ .listIterator();
+
+ YangRangeInterval rangeInterval = lengthListIterator.next();
+
+ assertThat(((YangUint64) rangeInterval.getStartValue()).getValue(), is(BigInteger.valueOf(0)));
+ assertThat(((YangUint64) rangeInterval.getEndValue()).getValue(), is(BigInteger.valueOf(100)));
+ }
+
+ /**
+ * Checks length restriction in referred type.
+ */
+ @Test
+ public void processLengthRestrictionInRefType()
+ throws IOException, ParserException, DataModelException {
+
+ YangNode node = manager.getDataModel("src/test/resources/LengthRestrictionInRefType.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(MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) node;
+ assertThat(yangNode.getName(), is("Test"));
+
+ ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("hello"));
+ assertThat(leafInfo.getDataType().getDataType(), is(DERIVED));
+
+ assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
+ is((YangTypeDef) node.getChild()));
+
+ assertThat(leafInfo.getDataType().getResolvableStatus(), Is.is(ResolvableStatus.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(notNullValue()));
+ assertThat(derivedInfo.getRangeRestrictionString(), is(nullValue()));
+ assertThat(derivedInfo.getPatternRestriction(), is(nullValue()));
+ assertThat(derivedInfo.getResolvedExtendedInfo(), is(notNullValue()));
+
+ // Check for the restriction value.
+ YangStringRestriction stringRestriction = (YangStringRestriction) derivedInfo.getResolvedExtendedInfo();
+ YangRangeRestriction lengthRestriction = stringRestriction.getLengthRestriction();
+
+ ListIterator<YangRangeInterval> lengthListIterator = lengthRestriction.getAscendingRangeIntervals()
+ .listIterator();
+
+ YangRangeInterval rangeInterval = lengthListIterator.next();
+
+ assertThat(((YangUint64) rangeInterval.getStartValue()).getValue(), is(BigInteger.valueOf(0)));
+ assertThat(((YangUint64) rangeInterval.getEndValue()).getValue(), is(BigInteger.valueOf(100)));
+ }
+
+ /**
+ * Checks length restriction in typedef and in type with stricter value.
+ */
+ @Test
+ public void processLengthRestrictionInTypedefAndTypeValid()
+ throws IOException, ParserException, DataModelException {
+
+ YangNode node = manager.getDataModel("src/test/resources/LengthRestrictionInTypedefAndTypeValid.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(MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) node;
+ assertThat(yangNode.getName(), is("Test"));
+
+ ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("hello"));
+ assertThat(leafInfo.getDataType().getDataType(), is(DERIVED));
+
+ assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
+ is((YangTypeDef) node.getChild()));
+
+ assertThat(leafInfo.getDataType().getResolvableStatus(), Is.is(ResolvableStatus.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(notNullValue()));
+ assertThat(derivedInfo.getRangeRestrictionString(), is(nullValue()));
+ assertThat(derivedInfo.getPatternRestriction(), is(nullValue()));
+ assertThat(derivedInfo.getResolvedExtendedInfo(), is(notNullValue()));
+
+ // Check for the restriction value.
+ YangStringRestriction stringRestriction = (YangStringRestriction) derivedInfo.getResolvedExtendedInfo();
+ YangRangeRestriction lengthRestriction = stringRestriction.getLengthRestriction();
+
+ ListIterator<YangRangeInterval> lengthListIterator = lengthRestriction.getAscendingRangeIntervals()
+ .listIterator();
+
+ YangRangeInterval rangeInterval1 = lengthListIterator.next();
+
+ assertThat(((YangUint64) rangeInterval1.getStartValue()).getValue(), is(BigInteger.valueOf(0)));
+ assertThat(((YangUint64) rangeInterval1.getEndValue()).getValue(), is(BigInteger.valueOf(20)));
+
+ YangRangeInterval rangeInterval2 = lengthListIterator.next();
+
+ assertThat(((YangUint64) rangeInterval2.getStartValue()).getValue(), is(BigInteger.valueOf(201)));
+ assertThat(((YangUint64) rangeInterval2.getEndValue()).getValue(), is(BigInteger.valueOf(300)));
+ }
+
+ /**
+ * Checks length restriction in typedef and in type with not stricter value.
+ */
+ @Test(expected = LinkerException.class)
+ public void processLengthRestrictionInTypedefAndTypeInValid()
+ throws IOException, DataModelException {
+ YangNode node = manager.getDataModel("src/test/resources/LengthRestrictionInTypedefAndTypeInValid.yang");
+ }
+
+ /**
+ * Checks range restriction in typedef.
+ */
+ @Test
+ public void processRangeRestrictionInTypedef()
+ throws IOException, ParserException, DataModelException {
+
+ YangNode node = manager.getDataModel("src/test/resources/RangeRestrictionInTypedef.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(MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) node;
+ assertThat(yangNode.getName(), is("Test"));
+
+ ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("hello"));
+ assertThat(leafInfo.getDataType().getDataType(), is(DERIVED));
+
+ assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
+ is((YangTypeDef) node.getChild()));
+
+ assertThat(leafInfo.getDataType().getResolvableStatus(), Is.is(ResolvableStatus.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(notNullValue()));
+
+ // Check for the restriction value.
+ YangRangeRestriction rangeRestriction = (YangRangeRestriction) derivedInfo.getResolvedExtendedInfo();
+
+ ListIterator<YangRangeInterval> rangeListIterator = rangeRestriction.getAscendingRangeIntervals()
+ .listIterator();
+
+ YangRangeInterval rangeInterval1 = rangeListIterator.next();
+
+ assertThat(((YangInt32) rangeInterval1.getStartValue()).getValue(), is(1));
+ assertThat(((YangInt32) rangeInterval1.getEndValue()).getValue(), is(4));
+
+ YangRangeInterval rangeInterval2 = rangeListIterator.next();
+
+ assertThat(((YangInt32) rangeInterval2.getStartValue()).getValue(), is(10));
+ assertThat(((YangInt32) rangeInterval2.getEndValue()).getValue(), is(20));
+ }
+
+ /**
+ * Checks range restriction in referred typedef.
+ */
+ @Test
+ public void processRangeRestrictionInRefTypedef()
+ throws IOException, ParserException, DataModelException {
+
+ YangNode node = manager.getDataModel("src/test/resources/RangeRestrictionInRefTypedef.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(MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) node;
+ assertThat(yangNode.getName(), is("Test"));
+
+ // check top typedef
+ YangTypeDef topTypedef = (YangTypeDef) yangNode.getChild();
+ assertThat(topTypedef.getName(), is("Num3"));
+ YangType type = topTypedef.getTypeList().iterator().next();
+ assertThat(type.getDataType(), is(YangDataTypes.INT16));
+ assertThat(type.getDataTypeName(), is("int16"));
+
+ // Check for the restriction value.
+ YangRangeRestriction rangeRestriction = (YangRangeRestriction) type.getDataTypeExtendedInfo();
+ ListIterator<YangRangeInterval> rangeListIterator = rangeRestriction.getAscendingRangeIntervals()
+ .listIterator();
+ YangRangeInterval rangeInterval1 = rangeListIterator.next();
+ assertThat((int) ((YangInt16) rangeInterval1.getStartValue()).getValue(), is(-32000));
+ assertThat((int) ((YangInt16) rangeInterval1.getEndValue()).getValue(), is(4));
+
+ YangRangeInterval rangeInterval2 = rangeListIterator.next();
+ assertThat((int) ((YangInt16) rangeInterval2.getStartValue()).getValue(), is(32767));
+ assertThat((int) ((YangInt16) rangeInterval2.getEndValue()).getValue(), is(32767));
+
+ // check referred typedef
+ YangTypeDef refTypedef = (YangTypeDef) topTypedef.getNextSibling();
+ assertThat(refTypedef.getName(), is("Num6"));
+ YangType refType = refTypedef.getTypeList().iterator().next();
+ assertThat(refType.getDataType(), is(YangDataTypes.DERIVED));
+ assertThat(refType.getDataTypeName(), is("Num3"));
+ YangDerivedInfo<YangRangeRestriction> derivedInfo =
+ (YangDerivedInfo<YangRangeRestriction>) refType.getDataTypeExtendedInfo();
+
+ // Check for the restriction value.
+ rangeRestriction = (YangRangeRestriction) derivedInfo.getResolvedExtendedInfo();
+ rangeListIterator = rangeRestriction.getAscendingRangeIntervals().listIterator();
+ rangeInterval1 = rangeListIterator.next();
+ assertThat((int) ((YangInt16) rangeInterval1.getStartValue()).getValue(), is(-3));
+ assertThat((int) ((YangInt16) rangeInterval1.getEndValue()).getValue(), is(-3));
+
+ rangeInterval2 = rangeListIterator.next();
+ assertThat((int) ((YangInt16) rangeInterval2.getStartValue()).getValue(), is(-2));
+ assertThat((int) ((YangInt16) rangeInterval2.getEndValue()).getValue(), is(2));
+
+ YangRangeInterval rangeInterval3 = rangeListIterator.next();
+ assertThat((int) ((YangInt16) rangeInterval3.getStartValue()).getValue(), is(3));
+ assertThat((int) ((YangInt16) rangeInterval3.getEndValue()).getValue(), is(3));
+ }
+
+ /**
+ * Checks invalid range restriction in referred typedef.
+ */
+ @Test(expected = LinkerException.class)
+ public void processInvalidRangeRestrictionInRefTypedef()
+ throws IOException, ParserException, DataModelException {
+
+ manager.getDataModel("src/test/resources/RangeRestrictionInvalidInRefTypedef.yang");
+ }
+
+ /**
+ * Checks range restriction in referred type.
+ */
+ @Test
+ public void processRangeRestrictionInRefType()
+ throws IOException, ParserException, DataModelException {
+
+ YangNode node = manager.getDataModel("src/test/resources/RangeRestrictionInRefType.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(MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) node;
+ assertThat(yangNode.getName(), is("Test"));
+
+ ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("hello"));
+ assertThat(leafInfo.getDataType().getDataType(), is(DERIVED));
+
+ assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
+ is((YangTypeDef) node.getChild()));
+
+ assertThat(leafInfo.getDataType().getResolvableStatus(), Is.is(ResolvableStatus.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(notNullValue()));
+ assertThat(derivedInfo.getPatternRestriction(), is(nullValue()));
+ assertThat(derivedInfo.getResolvedExtendedInfo(), is(notNullValue()));
+
+ // Check for the restriction value.
+ YangRangeRestriction rangeRestriction = (YangRangeRestriction) derivedInfo.getResolvedExtendedInfo();
+
+ ListIterator<YangRangeInterval> rangeListIterator = rangeRestriction.getAscendingRangeIntervals()
+ .listIterator();
+
+ YangRangeInterval rangeInterval1 = rangeListIterator.next();
+
+ assertThat(((YangInt32) rangeInterval1.getStartValue()).getValue(), is(1));
+ assertThat(((YangInt32) rangeInterval1.getEndValue()).getValue(), is(4));
+
+ YangRangeInterval rangeInterval2 = rangeListIterator.next();
+
+ assertThat(((YangInt32) rangeInterval2.getStartValue()).getValue(), is(10));
+ assertThat(((YangInt32) rangeInterval2.getEndValue()).getValue(), is(20));
+ }
+
+ /**
+ * Checks range restriction in typedef and stricter in referred type.
+ */
+ @Test
+ public void processRangeRestrictionInRefTypeAndTypedefValid()
+ throws IOException, ParserException, DataModelException {
+
+ YangNode node = manager.getDataModel("src/test/resources/RangeRestrictionInRefTypeAndTypedefValid.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(MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) node;
+ assertThat(yangNode.getName(), is("Test"));
+
+ ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("hello"));
+ assertThat(leafInfo.getDataType().getDataType(), is(DERIVED));
+
+ assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
+ is((YangTypeDef) node.getChild()));
+
+ assertThat(leafInfo.getDataType().getResolvableStatus(), Is.is(ResolvableStatus.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(notNullValue()));
+ assertThat(derivedInfo.getPatternRestriction(), is(nullValue()));
+ assertThat(derivedInfo.getResolvedExtendedInfo(), is(notNullValue()));
+
+ // Check for the restriction value.
+ YangRangeRestriction rangeRestriction = (YangRangeRestriction) derivedInfo.getResolvedExtendedInfo();
+
+ ListIterator<YangRangeInterval> rangeListIterator = rangeRestriction.getAscendingRangeIntervals()
+ .listIterator();
+
+ YangRangeInterval rangeInterval1 = rangeListIterator.next();
+
+ assertThat(((YangInt32) rangeInterval1.getStartValue()).getValue(), is(1));
+ assertThat(((YangInt32) rangeInterval1.getEndValue()).getValue(), is(4));
+
+ YangRangeInterval rangeInterval2 = rangeListIterator.next();
+
+ assertThat(((YangInt32) rangeInterval2.getStartValue()).getValue(), is(10));
+ assertThat(((YangInt32) rangeInterval2.getEndValue()).getValue(), is(20));
+ }
+
+ /**
+ * Checks range restriction in typedef and not stricter in referred type.
+ */
+ @Test(expected = LinkerException.class)
+ public void processRangeRestrictionInRefTypeAndTypedefInValid()
+ throws IOException, ParserException, DataModelException {
+ YangNode node = manager.getDataModel("src/test/resources/RangeRestrictionInRefTypeAndTypedefInValid.yang");
+ }
+
+ /**
+ * Checks range restriction for string.
+ */
+ @Test(expected = ParserException.class)
+ public void processRangeRestrictionInString()
+ throws IOException, ParserException, DataModelException {
+ YangNode node = manager.getDataModel("src/test/resources/RangeRestrictionInString.yang");
+ }
+
+ /**
+ * Checks range restriction for string in referred type.
+ */
+ @Test(expected = LinkerException.class)
+ public void processRangeRestrictionInStringInRefType()
+ throws IOException, DataModelException {
+ YangNode node = manager.getDataModel("src/test/resources/RangeRestrictionInStringInRefType.yang");
+ }
+
+ /**
+ * Checks pattern restriction in typedef.
+ */
+ @Test
+ public void processPatternRestrictionInTypedef()
+ throws IOException, ParserException, DataModelException {
+
+ YangNode node = manager.getDataModel("src/test/resources/PatternRestrictionInTypedef.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(MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) node;
+ assertThat(yangNode.getName(), is("Test"));
+
+ ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("hello"));
+ assertThat(leafInfo.getDataType().getDataType(), is(DERIVED));
+
+ assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
+ is((YangTypeDef) node.getChild()));
+
+ assertThat(leafInfo.getDataType().getResolvableStatus(), Is.is(ResolvableStatus.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(notNullValue()));
+
+ // Check for the restriction value.
+ YangStringRestriction stringRestriction = (YangStringRestriction) derivedInfo.getResolvedExtendedInfo();
+ YangPatternRestriction patternRestriction = stringRestriction.getPatternRestriction();
+
+ ListIterator<String> patternListIterator = patternRestriction.getPatternList().listIterator();
+ String pattern1 = patternListIterator.next();
+
+ assertThat(pattern1, is("[a-zA-Z]"));
+ }
+
+ /**
+ * Checks pattern restriction in referred type.
+ */
+ @Test
+ public void processPatternRestrictionInRefType()
+ throws IOException, ParserException, DataModelException {
+
+ YangNode node = manager.getDataModel("src/test/resources/PatternRestrictionInRefType.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(MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) node;
+ assertThat(yangNode.getName(), is("Test"));
+
+ ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("hello"));
+ assertThat(leafInfo.getDataType().getDataType(), is(DERIVED));
+
+ assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
+ is((YangTypeDef) node.getChild()));
+
+ assertThat(leafInfo.getDataType().getResolvableStatus(), Is.is(ResolvableStatus.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(notNullValue()));
+ assertThat(derivedInfo.getResolvedExtendedInfo(), is(notNullValue()));
+
+ // Check for the restriction value.
+ YangStringRestriction stringRestriction = (YangStringRestriction) derivedInfo.getResolvedExtendedInfo();
+ YangPatternRestriction patternRestriction = stringRestriction.getPatternRestriction();
+
+ ListIterator<String> patternListIterator = patternRestriction.getPatternList().listIterator();
+ String pattern1 = patternListIterator.next();
+
+ assertThat(pattern1, is("[a-zA-Z]"));
+ }
+
+ /**
+ * Checks pattern restriction in referred type and typedef.
+ */
+ @Test
+ public void processPatternRestrictionInRefTypeAndTypedef()
+ throws IOException, ParserException, DataModelException {
+
+ YangNode node = manager.getDataModel("src/test/resources/PatternRestrictionInRefTypeAndTypedef.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(MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) node;
+ assertThat(yangNode.getName(), is("Test"));
+
+ ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("hello"));
+ assertThat(leafInfo.getDataType().getDataType(), is(DERIVED));
+
+ assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
+ is((YangTypeDef) node.getChild()));
+
+ assertThat(leafInfo.getDataType().getResolvableStatus(), Is.is(ResolvableStatus.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(notNullValue()));
+ assertThat(derivedInfo.getResolvedExtendedInfo(), is(notNullValue()));
+
+ // Check for the restriction value.
+ YangStringRestriction stringRestriction = (YangStringRestriction) derivedInfo.getResolvedExtendedInfo();
+ YangPatternRestriction patternRestriction = stringRestriction.getPatternRestriction();
+
+ ListIterator<String> patternListIterator = patternRestriction.getPatternList().listIterator();
+ String pattern1 = patternListIterator.next();
+
+ assertThat(pattern1, is("[a-zA-Z]"));
+
+ String pattern2 = patternListIterator.next();
+
+ assertThat(pattern2, is("[0-9]"));
+ }
+
+ /**
+ * Checks multiple pattern restriction in referred type and typedef.
+ */
+ @Test
+ public void processMultiplePatternRestriction()
+ throws IOException, ParserException, DataModelException {
+
+ YangNode node = manager.getDataModel("src/test/resources/MultiplePatternRestrictionInRefTypeAndTypedef.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(MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) node;
+ assertThat(yangNode.getName(), is("Test"));
+
+ ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("hello"));
+ assertThat(leafInfo.getDataType().getDataType(), is(DERIVED));
+
+ assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
+ is((YangTypeDef) node.getChild()));
+
+ assertThat(leafInfo.getDataType().getResolvableStatus(), Is.is(ResolvableStatus.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(notNullValue()));
+ assertThat(derivedInfo.getResolvedExtendedInfo(), is(notNullValue()));
+
+ // Check for the restriction value.
+ YangStringRestriction stringRestriction = (YangStringRestriction) derivedInfo.getResolvedExtendedInfo();
+ YangPatternRestriction patternRestriction = stringRestriction.getPatternRestriction();
+
+ ListIterator<String> patternListIterator = patternRestriction.getPatternList().listIterator();
+ String pattern1 = patternListIterator.next();
+
+ assertThat(pattern1, is("[a-z]"));
+
+ String pattern2 = patternListIterator.next();
+
+ assertThat(pattern2, is("[A-Z]"));
+
+ String pattern3 = patternListIterator.next();
+
+ assertThat(pattern3, is("[0-9]"));
+
+ String pattern4 = patternListIterator.next();
+
+ assertThat(pattern4, is("[\\n]"));
+ }
+
+ /**
+ * Checks multiple pattern and length restriction in referred type and
+ * typedef.
+ */
+ @Test
+ public void processMultiplePatternAndLengthRestriction()
+ throws IOException, ParserException, DataModelException {
+
+ YangNode node = manager.getDataModel("src/test/resources/MultiplePatternAndLengthRestriction.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(MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) node;
+ assertThat(yangNode.getName(), is("Test"));
+
+ ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("hello"));
+ assertThat(leafInfo.getDataType().getDataType(), is(DERIVED));
+
+ assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
+ is((YangTypeDef) node.getChild()));
+
+ assertThat(leafInfo.getDataType().getResolvableStatus(), Is.is(ResolvableStatus.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(notNullValue()));
+ assertThat(derivedInfo.getRangeRestrictionString(), is(nullValue()));
+ assertThat(derivedInfo.getPatternRestriction(), is(notNullValue()));
+ assertThat(derivedInfo.getResolvedExtendedInfo(), is(notNullValue()));
+
+ // Check for the restriction value.
+ YangStringRestriction stringRestriction = (YangStringRestriction) derivedInfo.getResolvedExtendedInfo();
+
+ // Check for pattern restriction.
+ YangPatternRestriction patternRestriction = stringRestriction.getPatternRestriction();
+ ListIterator<String> patternListIterator = patternRestriction.getPatternList().listIterator();
+ String pattern1 = patternListIterator.next();
+
+ assertThat(pattern1, is("[a-z]"));
+
+ String pattern2 = patternListIterator.next();
+
+ assertThat(pattern2, is("[A-Z]"));
+
+ String pattern3 = patternListIterator.next();
+
+ assertThat(pattern3, is("[0-9]"));
+
+ String pattern4 = patternListIterator.next();
+
+ assertThat(pattern4, is("[\\n]"));
+
+ // Check for length restriction.
+ YangRangeRestriction lengthRestriction = stringRestriction.getLengthRestriction();
+ ListIterator<YangRangeInterval> lengthListIterator = lengthRestriction.getAscendingRangeIntervals()
+ .listIterator();
+
+ YangRangeInterval rangeInterval1 = lengthListIterator.next();
+
+ assertThat(((YangUint64) rangeInterval1.getStartValue()).getValue(), is(BigInteger.valueOf(0)));
+ assertThat(((YangUint64) rangeInterval1.getEndValue()).getValue(), is(BigInteger.valueOf(20)));
+
+ YangRangeInterval rangeInterval2 = lengthListIterator.next();
+
+ assertThat(((YangUint64) rangeInterval2.getStartValue()).getValue(), is(BigInteger.valueOf(201)));
+ assertThat(((YangUint64) rangeInterval2.getEndValue()).getValue(), is(BigInteger.valueOf(300)));
+ }
+
+ /**
+ * Checks multiple pattern and length restriction in referred type and
+ * typedef.
+ */
+ @Test
+ public void processMultiplePatternAndLengthRestrictionValid()
+ throws IOException, ParserException, DataModelException {
+
+ YangNode node = manager.getDataModel("src/test/resources/MultiplePatternAndLengthRestrictionValid.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(MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) node;
+ assertThat(yangNode.getName(), is("Test"));
+
+ ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("hello"));
+ assertThat(leafInfo.getDataType().getDataType(), is(DERIVED));
+
+ assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
+ is((YangTypeDef) node.getChild()));
+
+ assertThat(leafInfo.getDataType().getResolvableStatus(), Is.is(ResolvableStatus.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(notNullValue()));
+ assertThat(derivedInfo.getRangeRestrictionString(), is(nullValue()));
+ assertThat(derivedInfo.getPatternRestriction(), is(notNullValue()));
+ assertThat(derivedInfo.getResolvedExtendedInfo(), is(notNullValue()));
+
+ // Check for the restriction value.
+ YangStringRestriction stringRestriction = (YangStringRestriction) derivedInfo.getResolvedExtendedInfo();
+
+ // Check for pattern restriction.
+ YangPatternRestriction patternRestriction = stringRestriction.getPatternRestriction();
+ ListIterator<String> patternListIterator = patternRestriction.getPatternList().listIterator();
+ String pattern1 = patternListIterator.next();
+
+ assertThat(pattern1, is("[a-z]"));
+
+ String pattern2 = patternListIterator.next();
+
+ assertThat(pattern2, is("[A-Z]"));
+
+ String pattern3 = patternListIterator.next();
+
+ assertThat(pattern3, is("[0-9]"));
+
+ String pattern4 = patternListIterator.next();
+
+ assertThat(pattern4, is("[\\n]"));
+
+ // Check for length restriction.
+ YangRangeRestriction lengthRestriction = stringRestriction.getLengthRestriction();
+ ListIterator<YangRangeInterval> lengthListIterator = lengthRestriction.getAscendingRangeIntervals()
+ .listIterator();
+
+ YangRangeInterval rangeInterval1 = lengthListIterator.next();
+
+ assertThat(((YangUint64) rangeInterval1.getStartValue()).getValue(), is(BigInteger.valueOf(0)));
+ assertThat(((YangUint64) rangeInterval1.getEndValue()).getValue(), is(BigInteger.valueOf(20)));
+
+ YangRangeInterval rangeInterval2 = lengthListIterator.next();
+
+ assertThat(((YangUint64) rangeInterval2.getStartValue()).getValue(), is(BigInteger.valueOf(100)));
+ assertThat(((YangUint64) rangeInterval2.getEndValue()).getValue(),
+ is(new BigInteger("18446744073709551615")));
+ }
+
+ /**
+ * Checks multiple pattern and length restriction in referred type and
+ * typedef invalid scenario.
+ */
+ @Test(expected = LinkerException.class)
+ public void processMultiplePatternAndLengthRestrictionInValid()
+ throws IOException, DataModelException {
+ YangNode node = manager.getDataModel("src/test/resources/MultiplePatternAndLengthRestrictionInValid.yang");
+ }
+}
diff --git a/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/RootClassGeneratorTest.java b/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/RootClassGeneratorTest.java
new file mode 100644
index 0000000..2b01abe
--- /dev/null
+++ b/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/RootClassGeneratorTest.java
@@ -0,0 +1,117 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yang.compiler.plugin.maven;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.junit.Test;
+import org.onosproject.yang.compiler.utils.io.YangPluginConfig;
+import org.onosproject.yang.compiler.utils.io.impl.YangFileScanner;
+import org.onosproject.yang.compiler.utils.io.impl.YangIoUtils;
+import org.onosproject.yang.compiler.parser.exceptions.ParserException;
+
+import java.io.File;
+import java.io.IOException;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+
+/**
+ * Unit test case for root node's code generation.
+ */
+public class RootClassGeneratorTest {
+
+ private final YangUtilManager utilManager = new YangUtilManager();
+
+ @Test
+ public void rootClassGenTest() throws IOException, ParserException, MojoExecutionException {
+ YangIoUtils.deleteDirectory("target/manager/");
+ String searchDir = "src/test/resources/manager/singleChild";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ utilManager.resolveDependenciesUsingLinker();
+
+ YangPluginConfig yangPluginConfig = new YangPluginConfig();
+ yangPluginConfig.setCodeGenDir("target/manager/");
+ utilManager.translateToJava(yangPluginConfig);
+ String dir1 = System.getProperty("user.dir") + File.separator + "target/manager/";
+ YangPluginConfig.compileCode(dir1);
+ String path = System.getProperty("user.dir") + "/target/manager/" +
+ "org/onosproject/yang/gen/v1/single/test5/test/rev20160704" +
+ "/Test5.java";
+ assertThat(true, is((new File(path)).exists()));
+
+ path = System.getProperty("user.dir") + "/target/manager/" +
+ "org/onosproject/yang/gen/v1/single/test5/test/rev20160704" +
+ "/Test7.java";
+ assertThat(true, is((new File(path)).exists()));
+ YangIoUtils.deleteDirectory("target/manager/");
+ }
+
+ @Test
+ public void rootClassGenwithoutRevTest() throws IOException, ParserException, MojoExecutionException {
+ YangIoUtils.deleteDirectory("target/manager/");
+ String searchDir = "src/test/resources/manager/genwithoutrev";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ utilManager.resolveDependenciesUsingLinker();
+
+ YangPluginConfig yangPluginConfig = new YangPluginConfig();
+ yangPluginConfig.setCodeGenDir("target/manager/");
+ utilManager.translateToJava(yangPluginConfig);
+ String dir1 = System.getProperty("user.dir") + File.separator + "target/manager/";
+ YangPluginConfig.compileCode(dir1);
+ String path = System.getProperty("user.dir") + "/target/manager/" +
+ "org/onosproject/yang/gen/v1/test5/test/Test5.java";
+
+ assertThat(true, is((new File(path)).exists()));
+ YangIoUtils.deleteDirectory("target/manager/");
+ }
+
+ @Test
+ public void rootClassMethodGenTest() throws IOException, ParserException, MojoExecutionException {
+ YangIoUtils.deleteDirectory("target/manager/");
+ String searchDir = "src/test/resources/manager/MultiChild";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ utilManager.resolveDependenciesUsingLinker();
+
+ YangPluginConfig yangPluginConfig = new YangPluginConfig();
+ yangPluginConfig.setCodeGenDir("target/manager/");
+ utilManager.translateToJava(yangPluginConfig);
+ String dir1 = System.getProperty("user.dir") + File.separator + "target/manager/";
+ YangPluginConfig.compileCode(dir1);
+ String path = System.getProperty("user.dir") + "/target/manager/" +
+ "org/onosproject/yang/gen/v1/multi/test5/test/rev20160704" +
+ "/Test5.java";
+ assertThat(true, is((new File(path)).exists()));
+
+ path = System.getProperty("user.dir") + "/target/manager/" +
+ "org/onosproject/yang/gen/v1/multi/test5/test/rev20160704" +
+ "/Test7.java";
+ assertThat(true, is((new File(path)).exists()));
+
+ path = System.getProperty("user.dir") + "/target/manager/" +
+ "org/onosproject/yang/gen/v1/multi/test8/test/rev20160704" +
+ "/Test8.java";
+ assertThat(true, is((new File(path)).exists()));
+
+ YangIoUtils.deleteDirectory("target/manager/");
+ }
+}
diff --git a/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/RpcTranslatorTest.java b/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/RpcTranslatorTest.java
new file mode 100644
index 0000000..f4b35bb
--- /dev/null
+++ b/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/RpcTranslatorTest.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yang.compiler.plugin.maven;
+
+import org.junit.Test;
+import org.onosproject.yang.compiler.datamodel.YangNode;
+import org.onosproject.yang.compiler.translator.tojava.JavaCodeGeneratorUtil;
+import org.onosproject.yang.compiler.utils.io.YangPluginConfig;
+import org.onosproject.yang.compiler.utils.io.impl.YangIoUtils;
+import org.onosproject.yang.compiler.parser.exceptions.ParserException;
+import org.onosproject.yang.compiler.parser.impl.YangUtilsParserManager;
+
+import java.io.File;
+import java.io.IOException;
+
+/**
+ * Unit tests for rpc translator.
+ */
+public final class RpcTranslatorTest {
+
+ private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+ /**
+ * Checks rpc translation should not result in any exception.
+ */
+ @Test
+ public void processRpcTranslator()
+ throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/RpcTranslator.yang");
+
+ String dir = "target/rpcTranslator/";
+ YangIoUtils.deleteDirectory(dir);
+ YangPluginConfig yangPluginConfig = new YangPluginConfig();
+ yangPluginConfig.setCodeGenDir(dir);
+
+ JavaCodeGeneratorUtil.generateJavaCode(node, yangPluginConfig);
+ String dir1 = System.getProperty("user.dir") + File.separator + dir;
+ YangPluginConfig.compileCode(dir1);
+ YangIoUtils.deleteDirectory(dir);
+ }
+ // TODO enhance the test cases, after having a framework of translator test.
+}
diff --git a/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/SchemaNodeTest.java b/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/SchemaNodeTest.java
new file mode 100644
index 0000000..3593398
--- /dev/null
+++ b/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/SchemaNodeTest.java
@@ -0,0 +1,218 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yang.compiler.plugin.maven;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.junit.Test;
+import org.onosproject.yang.compiler.datamodel.YangLeaf;
+import org.onosproject.yang.compiler.datamodel.YangLeavesHolder;
+import org.onosproject.yang.compiler.datamodel.YangNode;
+import org.onosproject.yang.compiler.datamodel.YangSchemaNode;
+import org.onosproject.yang.compiler.datamodel.YangSchemaNodeContextInfo;
+import org.onosproject.yang.compiler.datamodel.YangSchemaNodeIdentifier;
+import org.onosproject.yang.compiler.datamodel.exceptions.DataModelException;
+import org.onosproject.yang.compiler.utils.io.YangPluginConfig;
+import org.onosproject.yang.compiler.utils.io.impl.YangFileScanner;
+import org.onosproject.yang.compiler.utils.io.impl.YangIoUtils;
+import org.onosproject.yang.compiler.parser.exceptions.ParserException;
+
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.hamcrest.CoreMatchers.nullValue;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+
+/**
+ * Test cases for testing YANG schema node.
+ */
+public class SchemaNodeTest {
+
+ private final YangUtilManager utilManager = new YangUtilManager();
+
+ /**
+ * Checks method to get schema node from map.
+ *
+ * @throws IOException a violation in IO rule
+ * @throws ParserException a violation in parser rule
+ * @throws MojoExecutionException a violation in mojo rule
+ * @throws DataModelException a violation in data model rule
+ */
+ @Test
+ public void processSchemaNodeMap()
+ throws IOException, ParserException,
+ MojoExecutionException, DataModelException {
+
+ YangIoUtils.deleteDirectory("target/schemaMap/");
+ String searchDir = "src/test/resources/schemaMap";
+ utilManager
+ .createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ utilManager.resolveDependenciesUsingLinker();
+ YangPluginConfig yangPluginConfig = new YangPluginConfig();
+ yangPluginConfig.setCodeGenDir("target/schemaMap/");
+ utilManager.translateToJava(yangPluginConfig);
+
+ Iterator<YangNode> yangNodeIterator =
+ utilManager.getYangNodeSet().iterator();
+ YangNode rootNode = yangNodeIterator.next();
+
+ // Validate the notification enum map
+ assertThat(rootNode.getChild().getNextSibling(),
+ is(rootNode.getNotificationSchemaNode("TESTNOTIFICATION1")));
+
+ // Validate the notification enum map shouldn't have container
+ assertThat(rootNode.getNotificationSchemaNode("TESTCONTAINER"),
+ is(nullValue()));
+
+ // Validation for RPC input/output node.
+ YangNode yangRpcNode = rootNode.getChild().getNextSibling()
+ .getNextSibling();
+ YangSchemaNodeIdentifier yangInputNode = new YangSchemaNodeIdentifier();
+ yangInputNode.setName("input");
+ yangInputNode.setNameSpace(yangRpcNode.getNameSpace());
+ assertThat(yangRpcNode.getChildSchema(yangInputNode).getSchemaNode(),
+ is(yangRpcNode.getChild()));
+
+ YangSchemaNodeIdentifier yangOutputNode = new
+ YangSchemaNodeIdentifier();
+ yangOutputNode.setName("output");
+ yangOutputNode.setNameSpace(yangRpcNode.getNameSpace());
+ assertThat(yangRpcNode.getChildSchema(yangOutputNode).getSchemaNode(),
+ is(yangRpcNode.getChild().getNextSibling()));
+
+ // Validate the input schema map
+ YangSchemaNode yangInput = yangRpcNode.getChild();
+ YangSchemaNodeIdentifier yangInputLeafNode = new
+ YangSchemaNodeIdentifier();
+ yangInputLeafNode.setName("image-name");
+ yangInputLeafNode.setNameSpace(yangRpcNode.getNameSpace());
+ assertThat(yangInput.getChildSchema(yangInputLeafNode),
+ is(notNullValue()));
+
+ YangSchemaNode yangOutput = yangRpcNode.getChild().getNextSibling();
+ YangSchemaNodeIdentifier yangOutputLeafNode = new
+ YangSchemaNodeIdentifier();
+ yangOutputLeafNode.setName("image-name");
+ yangOutputLeafNode.setNameSpace(yangRpcNode.getNameSpace());
+ assertThat(yangOutput.getChildSchema(yangOutputLeafNode),
+ is(notNullValue()));
+
+ // Validate schema node
+ assertThat(rootNode.getYsnContextInfoMap(), is(notNullValue()));
+ Map<YangSchemaNodeIdentifier, YangSchemaNodeContextInfo> schemaMap =
+ rootNode.getYsnContextInfoMap();
+ YangSchemaNodeIdentifier yangSchemaNodeIdentifier =
+ new YangSchemaNodeIdentifier();
+ yangSchemaNodeIdentifier.setName("testcontainer");
+ yangSchemaNodeIdentifier.setNameSpace(yangRpcNode.getNameSpace());
+ assertThat(schemaMap.get(yangSchemaNodeIdentifier), is(notNullValue()));
+ YangSchemaNodeContextInfo yangSchemaNodeContextInfo =
+ schemaMap.get(yangSchemaNodeIdentifier);
+ assertThat(yangSchemaNodeContextInfo.getSchemaNode(),
+ is(rootNode.getChild()));
+
+ assertThat(rootNode.getChild().getYsnContextInfoMap(),
+ is(notNullValue()));
+ Map<YangSchemaNodeIdentifier, YangSchemaNodeContextInfo> schemaMap2 =
+ rootNode.getChild()
+ .getYsnContextInfoMap();
+ yangSchemaNodeIdentifier.setName("testleaf");
+ yangSchemaNodeIdentifier.setNameSpace(yangRpcNode.getNameSpace());
+ assertThat(schemaMap2.get(yangSchemaNodeIdentifier),
+ is(notNullValue()));
+
+ yangSchemaNodeIdentifier.setName("pretzel");
+ yangSchemaNodeIdentifier.setNameSpace(yangRpcNode.getNameSpace());
+ assertThat(schemaMap2.get(yangSchemaNodeIdentifier),
+ is(notNullValue()));
+
+ assertThat(rootNode.getChild().getChild().getYsnContextInfoMap(),
+ is(notNullValue()));
+ Map<YangSchemaNodeIdentifier, YangSchemaNodeContextInfo> schemaMap3 =
+ rootNode.getChild().getChild()
+ .getYsnContextInfoMap();
+ yangSchemaNodeIdentifier.setName("pretzel");
+ yangSchemaNodeIdentifier.setNameSpace(yangRpcNode.getNameSpace());
+ assertThat(schemaMap3.get(yangSchemaNodeIdentifier),
+ is(notNullValue()));
+ YangSchemaNodeContextInfo yangSchemaNodeContextInfo3 =
+ schemaMap3.get(yangSchemaNodeIdentifier);
+
+ assertThat(rootNode.getChild().getChild().getChild()
+ .getYsnContextInfoMap(),
+ is(notNullValue()));
+ Map<YangSchemaNodeIdentifier, YangSchemaNodeContextInfo> schemaMap4 =
+ rootNode.getChild().getChild().getChild()
+ .getYsnContextInfoMap();
+ yangSchemaNodeIdentifier.setName("pretzel");
+ yangSchemaNodeIdentifier.setNameSpace(yangRpcNode.getNameSpace());
+ assertThat(schemaMap4.get(yangSchemaNodeIdentifier),
+ is(notNullValue()));
+
+ YangSchemaNodeContextInfo yangSchemaNodeContextInfo2 =
+ schemaMap4.get(yangSchemaNodeIdentifier);
+ List<YangLeaf> yangListOfLeaf = ((YangLeavesHolder) rootNode.getChild()
+ .getChild().getChild()).getListOfLeaf();
+ YangLeaf yangLeaf = yangListOfLeaf.get(0);
+ assertThat(yangSchemaNodeContextInfo2.getSchemaNode(), is(yangLeaf));
+
+ assertThat(yangSchemaNodeContextInfo3.getSchemaNode(), is(yangLeaf));
+ assertThat(yangSchemaNodeContextInfo3.getContextSwitchedNode(),
+ is(rootNode.getChild().getChild().getChild()));
+
+ YangIoUtils.deleteDirectory("target/schemaMap/");
+ }
+
+ /**
+ * Checks that notification map shouldn't be present in other YANG node.
+ *
+ * @throws IOException a violation in IO rule
+ * @throws ParserException a violation in parser rule
+ * @throws MojoExecutionException a violation in mojo rule
+ * @throws DataModelException a violation in data model rule
+ */
+ @Test(expected = DataModelException.class)
+ public void processNotificationEnumMapInvalidScenario()
+ throws IOException,
+ ParserException, MojoExecutionException,
+ DataModelException {
+
+ YangIoUtils.deleteDirectory("target/schemaMap/");
+ String searchDir = "src/test/resources/schemaMap";
+ utilManager
+ .createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ utilManager.resolveDependenciesUsingLinker();
+ YangPluginConfig yangPluginConfig = new YangPluginConfig();
+ yangPluginConfig.setCodeGenDir("target/schemaMap/");
+ utilManager.translateToJava(yangPluginConfig);
+
+ Iterator<YangNode> yangNodeIterator =
+ utilManager.getYangNodeSet().iterator();
+ YangNode rootNode = yangNodeIterator.next();
+
+ YangIoUtils.deleteDirectory("target/schemaMap/");
+
+ rootNode.getChild().getNotificationSchemaNode("TESTNOTIFICATION1");
+ }
+}
diff --git a/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/TypeDefTranslatorTest.java b/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/TypeDefTranslatorTest.java
new file mode 100644
index 0000000..d45be4a
--- /dev/null
+++ b/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/TypeDefTranslatorTest.java
@@ -0,0 +1,108 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yang.compiler.plugin.maven;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.junit.Test;
+import org.onosproject.yang.compiler.utils.io.YangPluginConfig;
+import org.onosproject.yang.compiler.utils.io.impl.YangFileScanner;
+import org.onosproject.yang.compiler.utils.io.impl.YangIoUtils;
+import org.onosproject.yang.compiler.parser.exceptions.ParserException;
+
+import java.io.File;
+import java.io.IOException;
+
+/**
+ * Unit test case for typedef translator.
+ */
+public class TypeDefTranslatorTest {
+
+ private final YangUtilManager utilManager = new YangUtilManager();
+ private static final String DIR = "target/typedefTranslator/";
+ private static final String DIR1 = System.getProperty("user.dir") + File
+ .separator + DIR;
+
+ /**
+ * Checks typedef translation should not result in any exception.
+ *
+ * @throws MojoExecutionException
+ */
+ @Test
+ public void processTypeDefTranslator() throws IOException,
+ ParserException, MojoExecutionException {
+
+ YangIoUtils.deleteDirectory(DIR);
+ String searchDir = "src/test/resources/typedefTranslator/without";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ utilManager.resolveDependenciesUsingLinker();
+
+ YangPluginConfig yangPluginConfig = new YangPluginConfig();
+ yangPluginConfig.setCodeGenDir(DIR);
+ utilManager.translateToJava(yangPluginConfig);
+ YangPluginConfig.compileCode(DIR1);
+ YangIoUtils.deleteDirectory(DIR);
+ }
+
+ /**
+ * Checks typedef translation should not result in any exception.
+ *
+ * @throws MojoExecutionException
+ */
+ @Test
+ public void processTypeDefWithRestrictionsTranslator() throws IOException,
+ ParserException, MojoExecutionException {
+
+ YangIoUtils.deleteDirectory(DIR);
+ String searchDir = "src/test/resources/typedefTranslator/with";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ utilManager.resolveDependenciesUsingLinker();
+
+ YangPluginConfig yangPluginConfig = new YangPluginConfig();
+ yangPluginConfig.setCodeGenDir(DIR);
+ utilManager.translateToJava(yangPluginConfig);
+ YangPluginConfig.compileCode(DIR1);
+ YangIoUtils.deleteDirectory(DIR);
+
+ }
+
+ /**
+ * Checks typedef translation should not result in any exception.
+ *
+ * @throws MojoExecutionException
+ */
+ @Test
+ public void processTypeDefWithUnionAndBitsTranslator() throws IOException,
+ ParserException, MojoExecutionException {
+
+ YangIoUtils.deleteDirectory(DIR);
+ String searchDir = "src/test/resources/typedefTranslator/union";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ utilManager.resolveDependenciesUsingLinker();
+
+ YangPluginConfig yangPluginConfig = new YangPluginConfig();
+ yangPluginConfig.setCodeGenDir(DIR);
+ utilManager.translateToJava(yangPluginConfig);
+ YangPluginConfig.compileCode(DIR1);
+ YangIoUtils.deleteDirectory(DIR);
+ }
+}
diff --git a/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/TypeLinkingAfterCloningTest.java b/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/TypeLinkingAfterCloningTest.java
new file mode 100644
index 0000000..88937ae
--- /dev/null
+++ b/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/TypeLinkingAfterCloningTest.java
@@ -0,0 +1,817 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yang.compiler.plugin.maven;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.onosproject.yang.compiler.datamodel.YangContainer;
+import org.onosproject.yang.compiler.datamodel.YangDerivedInfo;
+import org.onosproject.yang.compiler.datamodel.YangIdentityRef;
+import org.onosproject.yang.compiler.datamodel.YangLeaf;
+import org.onosproject.yang.compiler.datamodel.YangLeafList;
+import org.onosproject.yang.compiler.datamodel.YangLeafRef;
+import org.onosproject.yang.compiler.datamodel.YangList;
+import org.onosproject.yang.compiler.datamodel.YangModule;
+import org.onosproject.yang.compiler.datamodel.YangNode;
+import org.onosproject.yang.compiler.datamodel.YangType;
+import org.onosproject.yang.compiler.datamodel.YangTypeDef;
+import org.onosproject.yang.compiler.datamodel.YangUnion;
+import org.onosproject.yang.compiler.datamodel.utils.builtindatatype.YangDataTypes;
+import org.onosproject.yang.compiler.linker.impl.YangLinkerManager;
+import org.onosproject.yang.compiler.linker.impl.YangLinkerUtils;
+import org.onosproject.yang.compiler.utils.io.impl.YangFileScanner;
+import org.onosproject.yang.compiler.parser.exceptions.ParserException;
+
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.ListIterator;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+import static org.onosproject.yang.compiler.datamodel.YangNodeType.MODULE_NODE;
+import static org.onosproject.yang.compiler.datamodel.utils.builtindatatype.YangDataTypes.DERIVED;
+import static org.onosproject.yang.compiler.datamodel.utils.builtindatatype.YangDataTypes.IDENTITYREF;
+import static org.onosproject.yang.compiler.datamodel.utils.builtindatatype.YangDataTypes.STRING;
+
+/**
+ * Test cases for type linking after cloning happens grouping.
+ */
+public class TypeLinkingAfterCloningTest {
+
+ private static final String MODULE = "module";
+ private static final String OPEN_ROAD = "org-open-road-m-device";
+ private static final String NODE_ID = "node-id";
+ private static final String LEAF = "leaf";
+ private static final String LEAF_LIST = "leaf-list";
+ private static final String NODE_REF = "node-ref";
+ private static final String FACILITY = "facility";
+ private static final String FACILITY_SYS_LOG = "syslog-facility";
+ private static final String USABILITY_SYS_LOG = "syslog-usability";
+ private static final String AVAILABILITY_SYS_LOG = "syslog-availability";
+ private static final String THIRD = "third";
+ private static final String SECOND = "second";
+ private static final String FIRST = "first";
+ private static final String TYPEDEF = "typedef";
+ private static final String CORRECT = "correct";
+ private static final String UNI = "with-uni";
+ private static final String UNION = "union";
+ private static final String BASE1 = "id2";
+ private static final String BASE2 = "id1";
+ private static final String DIR =
+ "src/test/resources/typelinkingaftercloning/";
+
+ private final YangUtilManager utilMgr = new YangUtilManager();
+ private final YangLinkerManager linkerMgr = new YangLinkerManager();
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ private ListIterator<YangLeaf> leafItr;
+ private YangLeaf leafInfo;
+ private ListIterator<YangLeafList> leafListItr;
+ private YangLeafList leafListInfo;
+ private YangIdentityRef idRef;
+ private YangUnion union;
+ private Iterator<YangType<?>> unionTypeItr;
+ private YangType type;
+ private YangDerivedInfo derInfo;
+ private YangType type2;
+ private YangType type3;
+ private YangType type1;
+ private YangDerivedInfo derInfo1;
+ private YangTypeDef typedef1;
+
+ /**
+ * Returns the error message as the node name incorrect, when assert fails.
+ *
+ * @param node YANG node
+ * @param nodeName node name
+ * @return error message as the name is incorrect
+ */
+ private static String getInCrtName(String node, Object nodeName) {
+ return getCapitalCase(node) + "'s name " + nodeName + " is incorrect.";
+ }
+
+ /**
+ * Returns the capital cased first letter of the given string.
+ *
+ * @param name string to be capital cased
+ * @return capital cased string
+ */
+ private static String getCapitalCase(String name) {
+ return name.substring(0, 1).toUpperCase() + name.substring(1);
+ }
+
+ /**
+ * Returns the error message as the node type incorrect, when assert fails.
+ *
+ * @param node YANG node
+ * @param nodeName node name
+ * @return error message as the type is incorrect
+ */
+ private static String getInCrtLeafType(String node, String nodeName) {
+ return "The " + node + " " + nodeName + " has incorrect data type.";
+ }
+
+ /**
+ * Returns the error message, stating the union and identity-ref level in
+ * the type, has not resolved to the referred identity.
+ *
+ * @param unionLvl union level in node
+ * @param idLvl identity-ref level in node
+ * @param baseName referred base
+ * @param node YANG node having type
+ * @param nodeName node name
+ * @return error message for incorrect identity-ref in union.
+ */
+ public static String getInCrtUnionWithIdRef(
+ String unionLvl, String idLvl, String baseName, String node,
+ String nodeName) {
+ return "The " + idLvl + " direct occurrence identity-ref in " +
+ unionLvl + " level union, of " + node + " " + nodeName +
+ " is not " + baseName;
+ }
+
+ /**
+ * Processes leaf-ref after its cloned to uses from grouping.
+ *
+ * @throws IOException if violates IO operation
+ */
+ @Test
+ public void processLeafRefAfterCloning() throws IOException {
+
+ utilMgr.createYangFileInfoSet(YangFileScanner.getYangFiles(DIR + "leafref/intrafile"));
+ utilMgr.parseYangFileInfoSet();
+ utilMgr.createYangNodeSet();
+ YangNode selfNode;
+
+ // Create YANG node set
+ linkerMgr.createYangNodeSet(utilMgr.getYangNodeSet());
+
+ // Add references to import list.
+ linkerMgr.addRefToYangFilesImportList(utilMgr.getYangNodeSet());
+
+ YangLinkerUtils.updateFilePriority(utilMgr.getYangNodeSet());
+
+ // Carry out inter-file linking.
+ linkerMgr.processInterFileLinking(utilMgr.getYangNodeSet());
+
+ Iterator<YangNode> nodeItr = utilMgr.getYangNodeSet().iterator();
+
+ selfNode = nodeItr.next();
+
+ // Checks whether the data model tree returned is of type module.
+ assertThat((selfNode instanceof YangModule), is(true));
+
+ // Checks whether the node type is set properly to module.
+ assertThat(selfNode.getNodeType(), is(MODULE_NODE));
+
+ assertThat(getInCrtName(MODULE, OPEN_ROAD), selfNode.getName(),
+ is(OPEN_ROAD));
+
+ YangList list = (YangList) selfNode.getChild().getNextSibling()
+ .getNextSibling();
+
+ YangLeafRef leafRef;
+
+ leafItr = list.getListOfLeaf().listIterator();
+ leafInfo = leafItr.next();
+
+ // Checks whether the information in the leaf is correct under list.
+ assertThat(getInCrtName(LEAF, NODE_ID), leafInfo.getName(),
+ is(NODE_ID));
+ leafRef = (YangLeafRef) leafInfo.getDataType()
+ .getDataTypeExtendedInfo();
+
+ // Checks the effective type for the leaf.
+ assertThat(getInCrtLeafType(LEAF, NODE_ID),
+ leafRef.getEffectiveDataType().getDataType(), is(STRING));
+
+ leafListItr = list.getListOfLeafList().listIterator();
+ leafListInfo = leafListItr.next();
+
+ // Checks whether the information in the leaf-list is correct.
+ assertThat(getInCrtName(LEAF_LIST, NODE_REF), leafListInfo.getName(),
+ is(NODE_REF));
+ leafRef = (YangLeafRef) leafListInfo.getDataType()
+ .getDataTypeExtendedInfo();
+
+ assertThat(getInCrtLeafType(LEAF_LIST, NODE_REF),
+ leafRef.getEffectiveDataType().getDataType(), is(DERIVED));
+
+ // Checks whether the information under cloned container is correct.
+ YangContainer container = (YangContainer) list.getChild()
+ .getNextSibling();
+
+ leafItr = container.getListOfLeaf().listIterator();
+ leafInfo = leafItr.next();
+
+ // Checks whether the information in the leaf is correct under cont.
+ assertThat(getInCrtName(LEAF, NODE_ID), leafInfo.getName(),
+ is(NODE_ID));
+ leafRef = (YangLeafRef) leafListInfo.getDataType()
+ .getDataTypeExtendedInfo();
+ assertThat(getInCrtLeafType(LEAF, NODE_ID),
+ leafRef.getEffectiveDataType().getDataType(), is(DERIVED));
+
+ leafListItr = container.getListOfLeafList().listIterator();
+ leafListInfo = leafListItr.next();
+
+ // Checks whether the information in the leaf-list is correct.
+ assertThat(getInCrtName(LEAF_LIST, NODE_REF), leafListInfo.getName(),
+ is(NODE_REF));
+ leafRef = (YangLeafRef) leafListInfo.getDataType()
+ .getDataTypeExtendedInfo();
+ assertThat(getInCrtLeafType(LEAF_LIST, NODE_REF),
+ leafRef.getEffectiveDataType().getDataType(),
+ is(STRING));
+ }
+
+ /**
+ * Processes invalid scenario where a leaf-ref is present in union.
+ *
+ * @throws IOException io error when finding file
+ */
+ @Test
+ public void processInvalidLeafRef() throws IOException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("Union member type must not be one of the " +
+ "built-in types \"empty\" or " +
+ "\"leafref\"node-id_union");
+ utilMgr.createYangFileInfoSet(YangFileScanner.getYangFiles(DIR + "leafref/invalid"));
+ utilMgr.parseYangFileInfoSet();
+ }
+
+ /**
+ * Processes simple identity-ref after it gets cloned from grouping.
+ *
+ * @throws IOException if violates IO operation
+ */
+ @Test
+ public void processIdentityRefBeforeCloning() throws IOException {
+
+ utilMgr.createYangFileInfoSet(YangFileScanner.getYangFiles(DIR + "identityref"));
+ utilMgr.parseYangFileInfoSet();
+ utilMgr.createYangNodeSet();
+ YangNode selfNode;
+
+ // Create YANG node set
+ linkerMgr.createYangNodeSet(utilMgr.getYangNodeSet());
+
+ // Add references to import list.
+ linkerMgr.addRefToYangFilesImportList(utilMgr.getYangNodeSet());
+
+ YangLinkerUtils.updateFilePriority(utilMgr.getYangNodeSet());
+
+ // Carry out inter-file linking.
+ linkerMgr.processInterFileLinking(utilMgr.getYangNodeSet());
+
+ Iterator<YangNode> nodeItr = utilMgr.getYangNodeSet().iterator();
+
+ selfNode = nodeItr.next();
+
+ // Checks whether the data model tree returned is of type module.
+ assertThat((selfNode instanceof YangModule), is(true));
+
+ // Checks whether the node type is set properly to module.
+ assertThat(selfNode.getNodeType(), is(MODULE_NODE));
+
+ assertThat(getInCrtName(MODULE, OPEN_ROAD), selfNode.getName(),
+ is(OPEN_ROAD));
+
+ YangList list = (YangList) selfNode.getChild().getNextSibling()
+ .getNextSibling().getNextSibling();
+
+ leafItr = list.getListOfLeaf().listIterator();
+ leafInfo = leafItr.next();
+
+ // Checks if the leaf has identity-ref in union.
+ assertThat(getInCrtName(LEAF, FACILITY), leafInfo.getName(),
+ is(FACILITY));
+ union = (YangUnion) leafInfo.getDataType().getDataTypeExtendedInfo();
+ unionTypeItr = union.getTypeList().listIterator();
+ type = unionTypeItr.next();
+ idRef = (YangIdentityRef) type.getDataTypeExtendedInfo();
+
+ // Checks the effective type for the leaf.
+ assertThat(getInCrtLeafType(LEAF, FACILITY),
+ idRef.getBaseIdentity().getName(),
+ is(FACILITY_SYS_LOG));
+
+ leafInfo = leafItr.next();
+
+ // Checks whether the information in the leaf is correct under list.
+ assertThat(getInCrtName(LEAF, NODE_ID), leafInfo.getName(),
+ is(NODE_ID));
+ idRef = (YangIdentityRef) leafInfo.getDataType()
+ .getDataTypeExtendedInfo();
+
+ // Checks the effective type for the leaf.
+ assertThat(getInCrtLeafType(LEAF, NODE_ID),
+ idRef.getBaseIdentity().getName(),
+ is(FACILITY_SYS_LOG));
+
+ leafListItr = list.getListOfLeafList().listIterator();
+ leafListInfo = leafListItr.next();
+
+ // Checks if the information in the leaf-list is correct under list.
+ assertThat(getInCrtName(LEAF_LIST, NODE_REF), leafListInfo.getName(),
+ is(NODE_REF));
+
+ derInfo = (YangDerivedInfo) leafListInfo.getDataType()
+ .getDataTypeExtendedInfo();
+
+ type = derInfo.getReferredTypeDef().getTypeList().get(0);
+ idRef = (YangIdentityRef) type.getDataTypeExtendedInfo();
+
+ // Checks the effective type for the leaf-list.
+ assertThat(getInCrtLeafType(LEAF, NODE_REF),
+ idRef.getBaseIdentity().getName(),
+ is(FACILITY_SYS_LOG));
+
+ YangContainer container = (YangContainer) list.getChild()
+ .getNextSibling().getNextSibling();
+
+ leafListItr = container.getListOfLeafList().listIterator();
+ leafListInfo = leafListItr.next();
+
+ // Checks the leaf-list information is correct.
+ assertThat(getInCrtName(LEAF_LIST, FACILITY), leafListInfo.getName(),
+ is(FACILITY));
+ union = (YangUnion) leafListInfo.getDataType()
+ .getDataTypeExtendedInfo();
+ unionTypeItr = union.getTypeList().listIterator();
+ type = unionTypeItr.next();
+ idRef = (YangIdentityRef) type.getDataTypeExtendedInfo();
+
+ // Checks the effective type for the leaf-list.
+ assertThat(getInCrtLeafType(LEAF_LIST, FACILITY),
+ idRef.getBaseIdentity().getName(),
+ is(FACILITY_SYS_LOG));
+
+ leafListInfo = leafListItr.next();
+
+ // Checks the leaf-list information is correct.
+ assertThat(getInCrtName(LEAF_LIST, NODE_REF), leafListInfo.getName(),
+ is(NODE_REF));
+ idRef = (YangIdentityRef) leafListInfo.getDataType()
+ .getDataTypeExtendedInfo();
+
+ // Checks the effective type for the leaf.
+ assertThat(getInCrtLeafType(LEAF_LIST, NODE_REF),
+ idRef.getBaseIdentity().getName(),
+ is(FACILITY_SYS_LOG));
+
+ leafItr = container.getListOfLeaf().listIterator();
+ leafInfo = leafItr.next();
+
+ // Checks the leaf information is correct.
+ assertThat(getInCrtName(LEAF, NODE_ID), leafInfo.getName(),
+ is(NODE_ID));
+ idRef = (YangIdentityRef) leafListInfo.getDataType()
+ .getDataTypeExtendedInfo();
+
+ assertThat(getInCrtLeafType(LEAF, NODE_ID),
+ idRef.getBaseIdentity().getName(),
+ is(FACILITY_SYS_LOG));
+
+ }
+
+ /**
+ * Processes union having different recursive level with identity-ref.
+ *
+ * @throws IOException if violates IO operation
+ */
+ @Test
+ public void processUnionAfterCloning() throws IOException {
+
+ utilMgr.createYangFileInfoSet(YangFileScanner.getYangFiles(DIR + "union"));
+ utilMgr.parseYangFileInfoSet();
+ utilMgr.createYangNodeSet();
+ YangNode selfNode;
+
+ // Create YANG node set
+ linkerMgr.createYangNodeSet(utilMgr.getYangNodeSet());
+
+ // Add references to import list.
+ linkerMgr.addRefToYangFilesImportList(utilMgr.getYangNodeSet());
+ YangLinkerUtils.updateFilePriority(utilMgr.getYangNodeSet());
+
+ // Carry out inter-file linking.
+ linkerMgr.processInterFileLinking(utilMgr.getYangNodeSet());
+ Iterator<YangNode> nodeItr = utilMgr.getYangNodeSet().iterator();
+ selfNode = nodeItr.next();
+
+ YangUnion union2;
+ YangUnion union3;
+ Iterator<YangType<?>> unionTypeItr2;
+ Iterator<YangType<?>> unionTypeItr3;
+ YangDerivedInfo derivedInfo;
+ YangTypeDef typeDef;
+ Iterator<YangType<?>> typeDefItr;
+
+ // Checks whether the data model tree returned is of type module.
+ assertThat((selfNode instanceof YangModule), is(true));
+
+ // Checks whether the node type is set properly to module.
+ assertThat(selfNode.getNodeType(), is(MODULE_NODE));
+
+ assertThat(getInCrtName(MODULE, OPEN_ROAD), selfNode.getName(),
+ is(OPEN_ROAD));
+
+ YangList list = (YangList) selfNode.getChild().getNextSibling()
+ .getNextSibling().getNextSibling().getNextSibling()
+ .getNextSibling().getNextSibling();
+
+ Iterator<YangLeaf> leafItr = list.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafItr.next();
+
+ // Checks if the leaf has identity-ref in union.
+ assertThat(getInCrtName(LEAF, FACILITY), leafInfo.getName(),
+ is(FACILITY));
+
+ // Gets the first level union and the list of type in it.
+ union = (YangUnion) leafInfo.getDataType().getDataTypeExtendedInfo();
+ unionTypeItr = union.getTypeList().listIterator();
+ type = unionTypeItr.next();
+
+ // Gets the second level union and types in it.
+ union2 = (YangUnion) type.getDataTypeExtendedInfo();
+ unionTypeItr2 = union2.getTypeList().listIterator();
+ type2 = unionTypeItr2.next();
+
+ // Gets the third level union and types in it.
+ union3 = (YangUnion) type2.getDataTypeExtendedInfo();
+ unionTypeItr3 = union3.getTypeList().listIterator();
+ type3 = unionTypeItr3.next();
+
+ // Checks the first identity-ref in third level union.
+ idRef = (YangIdentityRef) type3.getDataTypeExtendedInfo();
+ assertThat(getInCrtUnionWithIdRef(
+ THIRD, FIRST, USABILITY_SYS_LOG, LEAF, FACILITY),
+ idRef.getBaseIdentity().getName(),
+ is(USABILITY_SYS_LOG));
+
+ // Checks the first identity-ref in second level union.
+ type2 = unionTypeItr2.next();
+ idRef = (YangIdentityRef) type2.getDataTypeExtendedInfo();
+ assertThat(getInCrtUnionWithIdRef(
+ SECOND, FIRST, FACILITY_SYS_LOG, LEAF, FACILITY),
+ idRef.getBaseIdentity().getName(),
+ is(FACILITY_SYS_LOG));
+
+ // Checks the first identity-ref in first level union.
+ type = unionTypeItr.next();
+ derInfo = (YangDerivedInfo) type.getDataTypeExtendedInfo();
+ type = derInfo.getReferredTypeDef().getTypeList().get(0);
+ idRef = (YangIdentityRef) type.getDataTypeExtendedInfo();
+ assertThat(getInCrtUnionWithIdRef(
+ FIRST, FIRST, AVAILABILITY_SYS_LOG, LEAF, FACILITY),
+ idRef.getBaseIdentity().getName(),
+ is(AVAILABILITY_SYS_LOG));
+
+ // Checks derived type in third level union.
+ type3 = unionTypeItr3.next();
+ derivedInfo = (YangDerivedInfo) type3.getDataTypeExtendedInfo();
+ typeDef = derivedInfo.getReferredTypeDef();
+ typeDefItr = typeDef.getTypeList().listIterator();
+ type = typeDefItr.next();
+
+ // Gets the first level union and the list of type in it.
+ union = (YangUnion) type.getDataTypeExtendedInfo();
+ unionTypeItr = union.getTypeList().listIterator();
+ type = unionTypeItr.next();
+
+ // Gets the first level union and the list of type in it.
+ union2 = (YangUnion) type.getDataTypeExtendedInfo();
+ unionTypeItr2 = union2.getTypeList().listIterator();
+ type2 = unionTypeItr2.next();
+
+ // Checks the first identity-ref in second level union.
+ idRef = (YangIdentityRef) type2.getDataTypeExtendedInfo();
+ assertThat(getInCrtUnionWithIdRef(
+ SECOND, FIRST, AVAILABILITY_SYS_LOG, TYPEDEF, CORRECT),
+ idRef.getBaseIdentity().getName(),
+ is(AVAILABILITY_SYS_LOG));
+
+ // Checks the second identity-ref in second level union.
+ type2 = unionTypeItr2.next();
+ derInfo = (YangDerivedInfo) type2.getDataTypeExtendedInfo();
+ type2 = derInfo.getReferredTypeDef().getTypeList().get(0);
+ idRef = (YangIdentityRef) type2.getDataTypeExtendedInfo();
+ assertThat(getInCrtUnionWithIdRef(
+ SECOND, SECOND, AVAILABILITY_SYS_LOG, TYPEDEF, CORRECT),
+ idRef.getBaseIdentity().getName(),
+ is(AVAILABILITY_SYS_LOG));
+
+ // Checks the first identity-ref in first level union.
+ type = unionTypeItr.next();
+ idRef = (YangIdentityRef) type.getDataTypeExtendedInfo();
+ assertThat(getInCrtUnionWithIdRef(
+ FIRST, FIRST, USABILITY_SYS_LOG, TYPEDEF, CORRECT),
+ idRef.getBaseIdentity().getName(),
+ is(USABILITY_SYS_LOG));
+
+ YangContainer container = (YangContainer) list.getChild()
+ .getNextSibling().getNextSibling();
+
+
+ Iterator<YangLeafList> leafListItr = container.getListOfLeafList()
+ .listIterator();
+ YangLeafList leafListInfo = leafListItr.next();
+
+ // Checks if the leaf-list has identity-ref in union.
+ assertThat(getInCrtName(LEAF_LIST, FACILITY), leafListInfo.getName(),
+ is(FACILITY));
+
+ // Gets the first level union and the list of type in it.
+ union = (YangUnion) leafListInfo.getDataType()
+ .getDataTypeExtendedInfo();
+ unionTypeItr = union.getTypeList().listIterator();
+ type = unionTypeItr.next();
+
+ // Gets the second level union and types in it.
+ union2 = (YangUnion) type.getDataTypeExtendedInfo();
+ unionTypeItr2 = union2.getTypeList().listIterator();
+ type2 = unionTypeItr2.next();
+
+ // Gets the third level union and types in it.
+ union3 = (YangUnion) type2.getDataTypeExtendedInfo();
+ unionTypeItr3 = union3.getTypeList().listIterator();
+ type3 = unionTypeItr3.next();
+
+ // Checks the first identity-ref in third level union.
+ idRef = (YangIdentityRef) type3.getDataTypeExtendedInfo();
+ assertThat(getInCrtUnionWithIdRef(
+ THIRD, FIRST, USABILITY_SYS_LOG, LEAF_LIST, FACILITY),
+ idRef.getBaseIdentity().getName(),
+ is(USABILITY_SYS_LOG));
+
+ // Checks the first identity-ref in second level union.
+ type2 = unionTypeItr2.next();
+ idRef = (YangIdentityRef) type2.getDataTypeExtendedInfo();
+ assertThat(getInCrtUnionWithIdRef(
+ SECOND, FIRST, FACILITY_SYS_LOG, LEAF_LIST, FACILITY),
+ idRef.getBaseIdentity().getName(),
+ is(FACILITY_SYS_LOG));
+
+ // Checks the first identity-ref in first level union.
+ type = unionTypeItr.next();
+ derInfo = (YangDerivedInfo) type.getDataTypeExtendedInfo();
+ type = derInfo.getReferredTypeDef().getTypeList().get(0);
+ idRef = (YangIdentityRef) type.getDataTypeExtendedInfo();
+ assertThat(getInCrtUnionWithIdRef(
+ FIRST, FIRST, AVAILABILITY_SYS_LOG, LEAF_LIST, FACILITY),
+ idRef.getBaseIdentity().getName(),
+ is(AVAILABILITY_SYS_LOG));
+
+ // Checks derived type in third level union.
+ type3 = unionTypeItr3.next();
+ derivedInfo = (YangDerivedInfo) type3.getDataTypeExtendedInfo();
+ typeDef = derivedInfo.getReferredTypeDef();
+ typeDefItr = typeDef.getTypeList().listIterator();
+ type = typeDefItr.next();
+
+ // Gets the first level union and the list of type in it.
+ union = (YangUnion) type.getDataTypeExtendedInfo();
+ unionTypeItr = union.getTypeList().listIterator();
+ type = unionTypeItr.next();
+
+ // Gets the first level union and the list of type in it.
+ union2 = (YangUnion) type.getDataTypeExtendedInfo();
+ unionTypeItr2 = union2.getTypeList().listIterator();
+ type2 = unionTypeItr2.next();
+
+ // Checks the first identity-ref in second level union.
+ idRef = (YangIdentityRef) type2.getDataTypeExtendedInfo();
+ assertThat(getInCrtUnionWithIdRef(
+ SECOND, FIRST, AVAILABILITY_SYS_LOG, TYPEDEF, CORRECT),
+ idRef.getBaseIdentity().getName(),
+ is(AVAILABILITY_SYS_LOG));
+
+ // Checks the second identity-ref in second level union.
+ type2 = unionTypeItr2.next();
+ derInfo = (YangDerivedInfo) type2.getDataTypeExtendedInfo();
+ type2 = derInfo.getReferredTypeDef().getTypeList().get(0);
+ idRef = (YangIdentityRef) type2.getDataTypeExtendedInfo();
+ assertThat(getInCrtUnionWithIdRef(
+ SECOND, SECOND, AVAILABILITY_SYS_LOG, TYPEDEF, CORRECT),
+ idRef.getBaseIdentity().getName(),
+ is(AVAILABILITY_SYS_LOG));
+
+ // Checks the first identity-ref in first level union.
+ type = unionTypeItr.next();
+ idRef = (YangIdentityRef) type.getDataTypeExtendedInfo();
+ assertThat(getInCrtUnionWithIdRef(
+ FIRST, FIRST, USABILITY_SYS_LOG, TYPEDEF, CORRECT),
+ idRef.getBaseIdentity().getName(),
+ is(USABILITY_SYS_LOG));
+ }
+
+ /**
+ * Processes identity-ref when present under typedef, during intra and
+ * inter file linking.
+ *
+ * @throws IOException if violates IO operation
+ */
+ @Test
+ public void processIdentityRefWithTypeDef() throws IOException {
+
+ utilMgr.createYangFileInfoSet(YangFileScanner.getYangFiles(DIR + "idreftypedef"));
+ utilMgr.parseYangFileInfoSet();
+ utilMgr.createYangNodeSet();
+ YangNode selfNode;
+
+ // Create YANG node set
+ linkerMgr.createYangNodeSet(utilMgr.getYangNodeSet());
+
+ // Add references to import list.
+ linkerMgr.addRefToYangFilesImportList(utilMgr.getYangNodeSet());
+ YangLinkerUtils.updateFilePriority(utilMgr.getYangNodeSet());
+
+ // Carry out inter-file linking.
+ linkerMgr.processInterFileLinking(utilMgr.getYangNodeSet());
+ Iterator<YangNode> nodeItr = utilMgr.getYangNodeSet().iterator();
+ YangNode rootNode = nodeItr.next();
+
+ if (rootNode.getName().equals("IdRefInTypeDef1")) {
+ selfNode = rootNode;
+ } else {
+ selfNode = nodeItr.next();
+ }
+
+ YangDerivedInfo derInfo2;
+ YangTypeDef typedef2;
+ YangDerivedInfo derInfo3;
+ YangTypeDef typedef3;
+
+ YangModule module = (YangModule) selfNode;
+ leafItr = module.getListOfLeaf().listIterator();
+
+ // Gets the first leaf, which has three typedef with effective id-ref.
+ leafInfo = leafItr.next();
+ assertThat(getInCrtName(LEAF, LEAF), leafInfo.getName(), is(LEAF));
+ assertThat(getInCrtLeafType(LEAF, LEAF),
+ leafInfo.getDataType().getDataType(), is(DERIVED));
+
+ // Traverses through the three typedef in it.
+ derInfo1 = (YangDerivedInfo) leafInfo.getDataType()
+ .getDataTypeExtendedInfo();
+ typedef1 = derInfo1.getReferredTypeDef();
+ type1 = typedef1.getTypeList().get(0);
+ derInfo2 = (YangDerivedInfo) type1.getDataTypeExtendedInfo();
+ typedef2 = derInfo2.getReferredTypeDef();
+ type2 = typedef2.getTypeList().get(0);
+ derInfo3 = (YangDerivedInfo) type2.getDataTypeExtendedInfo();
+ typedef3 = derInfo3.getReferredTypeDef();
+ type3 = typedef3.getTypeList().get(0);
+ idRef = (YangIdentityRef) type3.getDataTypeExtendedInfo();
+
+ assertThat(getInCrtLeafType(TYPEDEF, typedef1.getName()),
+ derInfo1.getEffectiveBuiltInType(), is(IDENTITYREF));
+ assertThat(getInCrtLeafType(TYPEDEF, typedef3.getName()),
+ idRef.getBaseIdentity().getName(), is(BASE1));
+
+ leafListItr = module.getListOfLeafList().listIterator();
+
+ // Gets the first leaf, which has two typedef with effective id-ref.
+ leafListInfo = leafListItr.next();
+ assertThat(getInCrtName(LEAF_LIST, LEAF_LIST), leafListInfo.getName(),
+ is(LEAF_LIST));
+ assertThat(getInCrtLeafType(LEAF_LIST, LEAF_LIST),
+ leafListInfo.getDataType().getDataType(), is(DERIVED));
+
+ // Traverses through the two typedef in it.
+ derInfo1 = (YangDerivedInfo) leafListInfo.getDataType()
+ .getDataTypeExtendedInfo();
+ typedef1 = derInfo1.getReferredTypeDef();
+ type1 = typedef1.getTypeList().get(0);
+ derInfo2 = (YangDerivedInfo) type1.getDataTypeExtendedInfo();
+ typedef2 = derInfo2.getReferredTypeDef();
+ type2 = typedef2.getTypeList().get(0);
+ idRef = (YangIdentityRef) type2.getDataTypeExtendedInfo();
+
+ assertThat(getInCrtLeafType(TYPEDEF, typedef1.getName()),
+ derInfo1.getEffectiveBuiltInType(), is(IDENTITYREF));
+ assertThat(getInCrtLeafType(TYPEDEF, typedef3.getName()),
+ idRef.getBaseIdentity().getName(), is(BASE1));
+
+ // Gets the leaf with union having typedef referred from other file.
+ leafInfo = leafItr.next();
+ assertThat(getInCrtName(LEAF, UNI), leafInfo.getName(), is(UNI));
+ assertThat(getInCrtLeafType(LEAF, UNI),
+ leafInfo.getDataType().getDataType(),
+ is(YangDataTypes.UNION));
+
+ union = (YangUnion) leafInfo.getDataType().getDataTypeExtendedInfo();
+ type1 = union.getTypeList().get(0);
+ idRef = (YangIdentityRef) type1.getDataTypeExtendedInfo();
+
+ assertThat(getInCrtLeafType(UNION, "first type"),
+ idRef.getBaseIdentity().getName(), is(BASE1));
+
+ type1 = union.getTypeList().get(1);
+ derInfo1 = (YangDerivedInfo) type1.getDataTypeExtendedInfo();
+ typedef1 = derInfo1.getReferredTypeDef();
+ type2 = typedef1.getTypeList().get(0);
+ idRef = (YangIdentityRef) type2.getDataTypeExtendedInfo();
+ assertThat(getInCrtLeafType(UNION, "second type"),
+ idRef.getBaseIdentity().getName(), is("id3"));
+ }
+
+ /**
+ * Processes identity-ref when present in grouping used by inter file uses.
+ *
+ * @throws IOException if violates IO operation
+ */
+ @Test
+ public void processIdentityRefInGrouping() throws IOException {
+
+ utilMgr.createYangFileInfoSet(YangFileScanner.getYangFiles(DIR + "idrefingrouping"));
+ utilMgr.parseYangFileInfoSet();
+ utilMgr.createYangNodeSet();
+ YangNode selfNode;
+
+ // Create YANG node set
+ linkerMgr.createYangNodeSet(utilMgr.getYangNodeSet());
+
+ // Add references to import list.
+ linkerMgr.addRefToYangFilesImportList(utilMgr.getYangNodeSet());
+ YangLinkerUtils.updateFilePriority(utilMgr.getYangNodeSet());
+
+ // Carry out inter-file linking.
+ linkerMgr.processInterFileLinking(utilMgr.getYangNodeSet());
+ Iterator<YangNode> nodeItr = utilMgr.getYangNodeSet().iterator();
+ YangNode rootNode = nodeItr.next();
+
+ if (rootNode.getName().equals("IdRefInGrouping2")) {
+ selfNode = rootNode;
+ } else {
+ selfNode = nodeItr.next();
+ }
+
+ YangModule module = (YangModule) selfNode;
+ YangContainer cont = (YangContainer) module.getChild();
+
+ leafItr = cont.getListOfLeaf().listIterator();
+
+ // Gets the first leaf, which has three typedef with effective id-ref.
+ leafInfo = leafItr.next();
+ assertThat(getInCrtName(LEAF, LEAF), leafInfo.getName(), is(LEAF));
+ assertThat(getInCrtLeafType(LEAF, LEAF),
+ leafInfo.getDataType().getDataType(), is(IDENTITYREF));
+
+ idRef = (YangIdentityRef) leafInfo.getDataType()
+ .getDataTypeExtendedInfo();
+ assertThat(getInCrtLeafType(LEAF, LEAF),
+ idRef.getBaseIdentity().getName(), is(BASE1));
+
+ leafListItr = cont.getListOfLeafList().listIterator();
+
+ // Gets the first leaf, which has two typedef with effective id-ref.
+ leafListInfo = leafListItr.next();
+ assertThat(getInCrtName(LEAF_LIST, LEAF_LIST), leafListInfo.getName(),
+ is(LEAF_LIST));
+ assertThat(getInCrtLeafType(LEAF_LIST, LEAF_LIST),
+ leafListInfo.getDataType().getDataType(), is(DERIVED));
+
+ // Traverses through the two typedef in it.
+ derInfo1 = (YangDerivedInfo) leafListInfo.getDataType()
+ .getDataTypeExtendedInfo();
+ typedef1 = derInfo1.getReferredTypeDef();
+ type1 = typedef1.getTypeList().get(0);
+ idRef = (YangIdentityRef) type1.getDataTypeExtendedInfo();
+
+ assertThat(getInCrtLeafType(TYPEDEF, typedef1.getName()),
+ derInfo1.getEffectiveBuiltInType(), is(IDENTITYREF));
+ assertThat(getInCrtLeafType(TYPEDEF, typedef1.getName()),
+ idRef.getBaseIdentity().getName(), is(BASE2));
+
+ YangContainer cont2 = (YangContainer) cont.getChild().getNextSibling();
+ leafItr = cont2.getListOfLeaf().listIterator();
+ leafInfo = leafItr.next();
+
+ assertThat(getInCrtName(LEAF, LEAF), leafInfo.getName(), is(LEAF));
+ assertThat(getInCrtLeafType(LEAF, LEAF),
+ leafInfo.getDataType().getDataType(), is(IDENTITYREF));
+ idRef = (YangIdentityRef) leafInfo.getDataType()
+ .getDataTypeExtendedInfo();
+ assertThat(getInCrtLeafType(LEAF, LEAF),
+ idRef.getBaseIdentity().getName(), is(BASE2));
+ }
+}
diff --git a/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/UnionTranslatorTest.java b/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/UnionTranslatorTest.java
new file mode 100644
index 0000000..cf4fb1f
--- /dev/null
+++ b/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/UnionTranslatorTest.java
@@ -0,0 +1,259 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yang.compiler.plugin.maven;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.junit.Test;
+import org.onosproject.yang.compiler.datamodel.YangNode;
+import org.onosproject.yang.compiler.translator.tojava.JavaCodeGeneratorUtil;
+import org.onosproject.yang.compiler.utils.io.YangPluginConfig;
+import org.onosproject.yang.compiler.utils.io.impl.YangFileScanner;
+import org.onosproject.yang.compiler.utils.io.impl.YangIoUtils;
+import org.onosproject.yang.compiler.parser.exceptions.ParserException;
+import org.onosproject.yang.compiler.parser.impl.YangUtilsParserManager;
+
+import java.io.File;
+import java.io.IOException;
+
+/**
+ * Unit tests for union translator.
+ */
+public final class UnionTranslatorTest {
+
+ private final YangUtilsParserManager manager = new YangUtilsParserManager();
+ private static final String DIR = "target/unionTranslator/";
+ private static final String DIR1 = System.getProperty("user.dir") + File
+ .separator + DIR;
+
+ /**
+ * Checks union translation should not result in any exception.
+ */
+ @Test
+ public void processUnionTranslator()
+ throws IOException, ParserException {
+ YangIoUtils.deleteDirectory(DIR);
+ YangNode node = manager.getDataModel("src/test/resources/UnionTranslator.yang");
+
+ YangPluginConfig yangPluginConfig = new YangPluginConfig();
+ yangPluginConfig.setCodeGenDir(DIR);
+
+ JavaCodeGeneratorUtil.generateJavaCode(node, yangPluginConfig);
+ YangPluginConfig.compileCode(DIR1);
+ YangIoUtils.deleteDirectory(DIR);
+ }
+
+ /**
+ * Unit test case to test conflicting types.
+ *
+ * @throws IOException when fails to do IO operations
+ * @throws MojoExecutionException when fails to do mojo operations
+ */
+ @Test
+ public void processUnionIntUintConflictingTypes() throws IOException, MojoExecutionException {
+ YangIoUtils.deleteDirectory(DIR);
+ String searchDir = "src/test/resources/unionTranslator/intuint";
+ YangUtilManager utilManager = new YangUtilManager();
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ utilManager.resolveDependenciesUsingLinker();
+
+ YangPluginConfig yangPluginConfig = new YangPluginConfig();
+ yangPluginConfig.setCodeGenDir(DIR);
+
+ utilManager.translateToJava(yangPluginConfig);
+ YangPluginConfig.compileCode(DIR1);
+ YangIoUtils.deleteDirectory(DIR);
+ }
+
+ /**
+ * Unit test case to test conflicting types.
+ *
+ * @throws IOException when fails to do IO operations
+ * @throws MojoExecutionException when fails to do mojo operations
+ */
+ @Test
+ public void processUnionUintIntConflictingTypes() throws IOException,
+ MojoExecutionException {
+ YangIoUtils.deleteDirectory(DIR);
+ String searchDir = "src/test/resources/unionTranslator/uintint";
+ YangUtilManager utilManager = new YangUtilManager();
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ utilManager.resolveDependenciesUsingLinker();
+
+ YangPluginConfig yangPluginConfig = new YangPluginConfig();
+ yangPluginConfig.setCodeGenDir(DIR);
+
+ utilManager.translateToJava(yangPluginConfig);
+ YangPluginConfig.compileCode(DIR1);
+ YangIoUtils.deleteDirectory(DIR);
+ }
+
+ /**
+ * Unit test case to test conflicting types.
+ *
+ * @throws IOException when fails to do IO operations
+ * @throws MojoExecutionException when fails to do mojo operations
+ */
+ @Test
+ public void processUnionLongUlongConflictingTypes() throws IOException,
+ MojoExecutionException {
+ YangIoUtils.deleteDirectory(DIR);
+ String searchDir = "src/test/resources/unionTranslator/longulong";
+ YangUtilManager utilManager = new YangUtilManager();
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ utilManager.resolveDependenciesUsingLinker();
+
+ YangPluginConfig yangPluginConfig = new YangPluginConfig();
+ yangPluginConfig.setCodeGenDir(DIR);
+
+ utilManager.translateToJava(yangPluginConfig);
+ YangPluginConfig.compileCode(DIR1);
+ YangIoUtils.deleteDirectory(DIR);
+ }
+
+ /**
+ * Unit test case to test conflicting types.
+ *
+ * @throws IOException when fails to do IO operations
+ * @throws MojoExecutionException when fails to do mojo operations
+ */
+ @Test
+ public void processUnionUlongLongConflictingTypes() throws IOException,
+ MojoExecutionException {
+ YangIoUtils.deleteDirectory(DIR);
+ String searchDir = "src/test/resources/unionTranslator/ulonglong";
+ YangUtilManager utilManager = new YangUtilManager();
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ utilManager.resolveDependenciesUsingLinker();
+
+ YangPluginConfig yangPluginConfig = new YangPluginConfig();
+ yangPluginConfig.setCodeGenDir(DIR);
+
+ utilManager.translateToJava(yangPluginConfig);
+ YangPluginConfig.compileCode(DIR1);
+ YangIoUtils.deleteDirectory(DIR);
+ }
+
+ /**
+ * Unit test case to test conflicting types.
+ *
+ * @throws IOException when fails to do IO operations
+ * @throws MojoExecutionException when fails to do mojo operations
+ */
+ @Test
+ public void processUnionIntUintUlongLongConflictingTypes() throws IOException,
+ MojoExecutionException {
+ YangIoUtils.deleteDirectory(DIR);
+ String searchDir = "src/test/resources/unionTranslator/intuintulonglong";
+ YangUtilManager utilManager = new YangUtilManager();
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ utilManager.resolveDependenciesUsingLinker();
+
+ YangPluginConfig yangPluginConfig = new YangPluginConfig();
+ yangPluginConfig.setCodeGenDir(DIR);
+
+ utilManager.translateToJava(yangPluginConfig);
+ YangPluginConfig.compileCode(DIR1);
+ YangIoUtils.deleteDirectory(DIR);
+ }
+
+ /**
+ * Unit test case to test conflicting types.
+ *
+ * @throws IOException when fails to do IO operations
+ * @throws MojoExecutionException when fails to do mojo operations
+ */
+ @Test
+ public void processUnionIntUintUlongLongStringConflictingTypes() throws IOException,
+ MojoExecutionException {
+ YangIoUtils.deleteDirectory(DIR);
+ String searchDir = "src/test/resources/unionTranslator/intuintulonglongstring";
+ YangUtilManager utilManager = new YangUtilManager();
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ utilManager.resolveDependenciesUsingLinker();
+
+ YangPluginConfig yangPluginConfig = new YangPluginConfig();
+ yangPluginConfig.setCodeGenDir(DIR);
+
+ utilManager.translateToJava(yangPluginConfig);
+ YangPluginConfig.compileCode(DIR1);
+ YangIoUtils.deleteDirectory(DIR);
+ }
+
+ /**
+ * Unit test case to test conflicting types.
+ *
+ * @throws IOException when fails to do IO operations
+ * @throws MojoExecutionException when fails to do mojo operations
+ */
+ @Test
+ public void processUnionIntUintStringConflictingTypes() throws IOException,
+ MojoExecutionException {
+ YangIoUtils.deleteDirectory(DIR);
+ String searchDir = "src/test/resources/unionTranslator/intuintstring";
+ YangUtilManager utilManager = new YangUtilManager();
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ utilManager.resolveDependenciesUsingLinker();
+
+ YangPluginConfig yangPluginConfig = new YangPluginConfig();
+ yangPluginConfig.setCodeGenDir(DIR);
+
+ utilManager.translateToJava(yangPluginConfig);
+ YangPluginConfig.compileCode(DIR1);
+ YangIoUtils.deleteDirectory(DIR);
+ }
+
+ /**
+ * Unit test case to test Union with binary type.
+ *
+ * @throws IOException when fails to do IO operations
+ * @throws MojoExecutionException when fails to do mojo operations
+ */
+ @Test
+ public void processUnionWithBinaryTypes() throws IOException,
+ MojoExecutionException {
+ YangIoUtils.deleteDirectory(DIR);
+ String searchDir = "src/test/resources/unionTranslator/unionwithbinary";
+ YangUtilManager utilManager = new YangUtilManager();
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ utilManager.resolveDependenciesUsingLinker();
+
+ YangPluginConfig yangPluginConfig = new YangPluginConfig();
+ yangPluginConfig.setCodeGenDir(DIR);
+
+ utilManager.translateToJava(yangPluginConfig);
+ YangPluginConfig.compileCode(DIR1);
+ YangIoUtils.deleteDirectory(DIR);
+ }
+
+ // TODO enhance the test cases, after having a framework of translator test.
+}
diff --git a/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/YangJavaModelUtilsTest.java b/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/YangJavaModelUtilsTest.java
new file mode 100644
index 0000000..e1cad16
--- /dev/null
+++ b/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/YangJavaModelUtilsTest.java
@@ -0,0 +1,194 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yang.compiler.plugin.maven;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.hamcrest.core.Is;
+import org.junit.Test;
+import org.onosproject.yang.compiler.datamodel.YangNode;
+import org.onosproject.yang.compiler.translator.tojava.YangJavaModelUtils;
+import org.onosproject.yang.compiler.utils.io.impl.YangFileScanner;
+import org.onosproject.yang.compiler.parser.exceptions.ParserException;
+
+import java.io.IOException;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+
+/**
+ * Unit test case for java model utils.
+ */
+public class YangJavaModelUtilsTest {
+
+
+ private final YangUtilManager utilManager = new YangUtilManager();
+
+ @Test
+ public void isRootNodeContainsOnlyAugmentTest() throws IOException,
+ ParserException, MojoExecutionException {
+ String searchDir = "src/test/resources/rootNode/onlyaugment";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ utilManager.resolveDependenciesUsingLinker();
+
+ for (YangNode node : utilManager.getYangNodeSet()) {
+ if (node.getName().equals("test5")) {
+ assertThat(false, Is.is(YangJavaModelUtils.isGetSetOfRootNodeRequired(node)));
+ assertThat(true, Is.is(YangJavaModelUtils.isRootNodesCodeGenRequired(node)));
+ }
+ if (node.getName().equals("test6")) {
+ assertThat(true, Is.is(YangJavaModelUtils.isGetSetOfRootNodeRequired(node)));
+ assertThat(true, Is.is(YangJavaModelUtils.isRootNodesCodeGenRequired(node)));
+ }
+ }
+ }
+
+ @Test
+ public void isRootNodeCodeGenRequiredOnlyLeafTest() throws IOException
+ , ParserException, MojoExecutionException {
+ String searchDir = "src/test/resources/rootNode/onlyleaf";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ utilManager.resolveDependenciesUsingLinker();
+
+ for (YangNode node : utilManager.getYangNodeSet()) {
+ if (node.getName().equals("test5")) {
+ assertThat(true, Is.is(YangJavaModelUtils.isGetSetOfRootNodeRequired(node)));
+ assertThat(true, Is.is(YangJavaModelUtils.isRootNodesCodeGenRequired(node)));
+ }
+ }
+ }
+
+ @Test
+ public void isRootNodeCodeGenRequiredOnlyLeafListTest() throws IOException
+ , ParserException, MojoExecutionException {
+ String searchDir = "src/test/resources/rootNode/onlyleaflist";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ utilManager.resolveDependenciesUsingLinker();
+
+ for (YangNode node : utilManager.getYangNodeSet()) {
+ if (node.getName().equals("test5")) {
+ assertThat(true, Is.is(YangJavaModelUtils.isGetSetOfRootNodeRequired(node)));
+ assertThat(true, Is.is(YangJavaModelUtils.isRootNodesCodeGenRequired(node)));
+ }
+ }
+ }
+
+ @Test
+ public void isRootNodeCodeGenRequiredOnlyGroupingTest() throws IOException
+ , ParserException, MojoExecutionException {
+ String searchDir = "src/test/resources/rootNode/onlygrouping";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ utilManager.resolveDependenciesUsingLinker();
+
+ for (YangNode node : utilManager.getYangNodeSet()) {
+ if (node.getName().equals("test5")) {
+ assertThat(true, Is.is(YangJavaModelUtils.isGetSetOfRootNodeRequired(node)));
+ assertThat(false, Is.is(YangJavaModelUtils.isRootNodesCodeGenRequired(node)));
+ }
+ if (node.getName().equals("test6")) {
+ assertThat(true, Is.is(YangJavaModelUtils.isGetSetOfRootNodeRequired(node)));
+ assertThat(false, Is.is(YangJavaModelUtils.isRootNodesCodeGenRequired(node)));
+ }
+ }
+ }
+
+
+ @Test
+ public void isRootNodeCodeGenRequiredOnlyTypeDefTest() throws IOException
+ , ParserException, MojoExecutionException {
+ String searchDir = "src/test/resources/rootNode/onlytypdef";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ utilManager.resolveDependenciesUsingLinker();
+
+ for (YangNode node : utilManager.getYangNodeSet()) {
+ if (node.getName().equals("test5")) {
+ assertThat(false, Is.is(YangJavaModelUtils.isGetSetOfRootNodeRequired(node)));
+ assertThat(false, Is.is(YangJavaModelUtils.isRootNodesCodeGenRequired(node)));
+ }
+ if (node.getName().equals("test6")) {
+ assertThat(true, Is.is(YangJavaModelUtils.isGetSetOfRootNodeRequired(node)));
+ assertThat(false, Is.is(YangJavaModelUtils.isRootNodesCodeGenRequired(node)));
+ }
+ }
+ }
+
+ @Test
+ public void isRootNodeCodeGenRequiredNoGenTest() throws IOException
+ , ParserException, MojoExecutionException {
+ String searchDir = "src/test/resources/rootNode/nogen";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ utilManager.resolveDependenciesUsingLinker();
+
+ for (YangNode node : utilManager.getYangNodeSet()) {
+ if (node.getName().equals("test5")) {
+ assertThat(false, Is.is(YangJavaModelUtils.isGetSetOfRootNodeRequired(node)));
+ assertThat(false, Is.is(YangJavaModelUtils.isRootNodesCodeGenRequired(node)));
+ }
+ }
+
+ }
+
+ @Test
+ public void isRootNodeCodeGenRequiredMixedTest() throws IOException
+ , ParserException, MojoExecutionException {
+ String searchDir = "src/test/resources/rootNode/mixed";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ utilManager.resolveDependenciesUsingLinker();
+
+ for (YangNode node : utilManager.getYangNodeSet()) {
+ if (node.getName().equals("test5")) {
+ assertThat(false, Is.is(YangJavaModelUtils.isGetSetOfRootNodeRequired(node)));
+ assertThat(true, Is.is(YangJavaModelUtils.isRootNodesCodeGenRequired(node)));
+ }
+ if (node.getName().equals("test6")) {
+ assertThat(true, Is.is(YangJavaModelUtils.isGetSetOfRootNodeRequired(node)));
+ assertThat(true, Is.is(YangJavaModelUtils.isRootNodesCodeGenRequired(node)));
+ }
+ }
+
+ }
+
+ @Test
+ public void isRootNodeCodeGenRequiredTypedefGroupingTest() throws IOException
+ , ParserException, MojoExecutionException {
+ String searchDir = "src/test/resources/rootNode/typedefgrouping";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ utilManager.resolveDependenciesUsingLinker();
+
+ for (YangNode node : utilManager.getYangNodeSet()) {
+ if (node.getName().equals("test5")) {
+ assertThat(true, Is.is(YangJavaModelUtils.isGetSetOfRootNodeRequired(node)));
+ assertThat(false, Is.is(YangJavaModelUtils.isRootNodesCodeGenRequired(node)));
+ }
+ }
+
+ }
+}
diff --git a/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/YangPluginUtilsTest.java b/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/YangPluginUtilsTest.java
new file mode 100644
index 0000000..1759d48
--- /dev/null
+++ b/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/YangPluginUtilsTest.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yang.compiler.plugin.maven;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.maven.project.MavenProject;
+import org.junit.Test;
+import org.sonatype.plexus.build.incremental.BuildContext;
+import org.sonatype.plexus.build.incremental.DefaultBuildContext;
+
+import java.io.File;
+import java.io.IOException;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+
+/**
+ * Unit test case for YANG plugin utils.
+ */
+public class YangPluginUtilsTest {
+
+ private static final String BASE_DIR = "target/UnitTestCase";
+
+ /**
+ * This test case checks whether the source is getting added.
+ */
+ @Test
+ public void testForAddSource() throws IOException {
+
+ MavenProject project = new MavenProject();
+ BuildContext context = new DefaultBuildContext();
+ String dir = BASE_DIR + File.separator + "yang";
+ String path = System.getProperty("user.dir") + File.separator + dir;
+ File sourceDir = new File(dir);
+ sourceDir.mkdirs();
+ YangPluginUtils.addToCompilationRoot(sourceDir.toString(), project, context);
+ assertThat(true, is(project.getCompileSourceRoots().contains(path)));
+ FileUtils.deleteDirectory(sourceDir);
+ }
+}
diff --git a/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/YangXpathLinkerTest.java b/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/YangXpathLinkerTest.java
new file mode 100644
index 0000000..28c3db8
--- /dev/null
+++ b/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/YangXpathLinkerTest.java
@@ -0,0 +1,761 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yang.compiler.plugin.maven;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.junit.Test;
+import org.onosproject.yang.compiler.datamodel.ResolvableType;
+import org.onosproject.yang.compiler.datamodel.YangAugment;
+import org.onosproject.yang.compiler.datamodel.YangNode;
+import org.onosproject.yang.compiler.datamodel.YangReferenceResolver;
+import org.onosproject.yang.compiler.datamodel.YangResolutionInfo;
+import org.onosproject.yang.compiler.linker.impl.XpathLinkingTypes;
+import org.onosproject.yang.compiler.linker.impl.YangLinkerManager;
+import org.onosproject.yang.compiler.linker.impl.YangLinkerUtils;
+import org.onosproject.yang.compiler.linker.impl.YangXpathLinker;
+import org.onosproject.yang.compiler.utils.io.YangPluginConfig;
+import org.onosproject.yang.compiler.utils.io.impl.YangFileScanner;
+import org.onosproject.yang.compiler.utils.io.impl.YangIoUtils;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.List;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+
+/**
+ * Unit test cases for x-path linker.
+ */
+public class YangXpathLinkerTest {
+
+ private static final String INTRA_FILE_PATH = "src/test/resources/xPathLinker/IntraFile/";
+ 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 YangLinkerManager linkerManager = new YangLinkerManager();
+
+ /**
+ * Unit test case for intra file linking for single level container.
+ *
+ * @throws IOException when fails to do IO operations
+ * @throws MojoExecutionException
+ */
+ @Test
+ public void processIntraFileLinkingSingleLevel() throws IOException, MojoExecutionException {
+
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(INTRA_FILE_PATH + "IntraSingle/"));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ utilManager.resolveDependenciesUsingLinker();
+
+ YangNode targetNode = null;
+ String targetNodeName = null;
+
+ for (YangNode node : utilManager.getYangNodeSet()) {
+ YangReferenceResolver ref = (YangReferenceResolver) node;
+ List<YangResolutionInfo> infos = ref.getUnresolvedResolutionList(ResolvableType.YANG_AUGMENT);
+ YangResolutionInfo info = infos.get(0);
+
+ YangAugment augment = (YangAugment) info.getEntityToResolveInfo().getEntityToResolve();
+ targetNodeName = augment.getTargetNode().get(augment.getTargetNode().size() - 1).getNodeIdentifier()
+ .getName();
+ targetNode = augment.getAugmentedNode();
+
+ }
+
+ assertThat(true, is(targetNode.getName().equals(targetNodeName)));
+ }
+
+ /**
+ * Unit test case for intra file linking for multiple level container.
+ *
+ * @throws IOException when fails to do IO operations
+ */
+ @Test
+ public void processIntraFileLinkingMultipleLevel() throws IOException {
+
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(INTRA_FILE_PATH + "IntraMulti/"));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+
+ YangNode targetNode = null;
+ String targetNodeName = 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, XpathLinkingTypes.AUGMENT_LINKING);
+ }
+ }
+
+ assertThat(true, is(targetNode.getName().equals(targetNodeName)));
+ }
+
+ /**
+ * Unit test case for intra file linking for single level augment.
+ *
+ * @throws IOException when fails to do IO operations
+ */
+ @Test
+ public void processIntraFileLinkingInAugmentSingleLevel() throws IOException {
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(INTRA_FILE_PATH + "IntraSingleAugment/"));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+
+ YangNode targetNode = null;
+ String targetNodeName = 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, XpathLinkingTypes.AUGMENT_LINKING);
+ }
+ }
+
+ assertThat(true, is(targetNode.getName().equals(targetNodeName)));
+ }
+
+ /**
+ * Unit test case for intra file linking for multiple level augment
+ * without prefix.
+ *
+ * @throws IOException if fails to do IO operations
+ */
+ @Test
+ public void processIntraFileMultiLevelWithoutPrefix() throws IOException {
+
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(
+ INTRA_FILE_PATH + "IntraMultiAugment/withoutprefix"));
+ 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, XpathLinkingTypes.AUGMENT_LINKING);
+ }
+ }
+ assertThat(true, is(target.getName().equals(name)));
+ }
+
+ /**
+ * 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(YangFileScanner.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, XpathLinkingTypes.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(YangFileScanner.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, XpathLinkingTypes.AUGMENT_LINKING);
+ }
+ }
+ assertThat(true, is(target.getName().equals(name)));
+ }
+
+ /**
+ * Unit test case for intra file linking for multiple level submodule.
+ *
+ * @throws IOException when fails to do IO operations
+ */
+ @Test
+ public void processIntraFileLinkingInSubModuleSingleLevel() throws IOException {
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(INTRA_FILE_PATH + "IntraSingleSubModule/"));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ linkerManager.createYangNodeSet(utilManager.getYangNodeSet());
+ linkerManager.linkSubModulesToParentModule(utilManager.getYangNodeSet());
+ linkerManager.addRefToYangFilesIncludeList(utilManager.getYangNodeSet());
+
+ YangNode targetNode = null;
+ String targetNodeName = 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, XpathLinkingTypes.AUGMENT_LINKING);
+ }
+ }
+
+ assertThat(true, is(targetNode.getName().equals(targetNodeName)));
+ }
+
+ /**
+ * Unit test case for intra file linking for multiple level submodule.
+ *
+ * @throws IOException when fails to do IO operations
+ */
+ @Test
+ public void processIntraFileLinkingInSubModuleMultiLevel() throws IOException {
+
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(INTRA_FILE_PATH + "IntraMultiSubModule/"));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ linkerManager.createYangNodeSet(utilManager.getYangNodeSet());
+ linkerManager.linkSubModulesToParentModule(utilManager.getYangNodeSet());
+ linkerManager.addRefToYangFilesIncludeList(utilManager.getYangNodeSet());
+
+ YangNode targetNode = null;
+ String targetNodeName = 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, XpathLinkingTypes.AUGMENT_LINKING);
+ }
+ }
+
+ assertThat(true, is(targetNode.getName().equals(targetNodeName)));
+ }
+
+ /**
+ * Unit test case for intra file linking for single level uses.
+ *
+ * @throws IOException when fails to do IO operations
+ */
+ @Test
+ public void processIntraFileLinkingInUsesSingleLevel() throws IOException {
+
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(INTRA_FILE_PATH + "IntraSingleUses/"));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ linkerManager.createYangNodeSet(utilManager.getYangNodeSet());
+ YangLinkerUtils.updateFilePriority(utilManager.getYangNodeSet());
+ linkerManager.processInterFileLinking(utilManager.getYangNodeSet());
+
+ YangNode targetNode = null;
+ String targetNodeName = 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, XpathLinkingTypes.AUGMENT_LINKING);
+ }
+ }
+
+ assertThat(true, is(targetNode.getName().equals(targetNodeName)));
+ }
+
+ /**
+ * Unit test case for intra file linking for multi level uses.
+ *
+ * @throws IOException when fails to do IO operations
+ */
+ @Test
+ public void processIntraFileLinkingInUsesMultiLevel() throws IOException {
+
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(INTRA_FILE_PATH + "IntraMultiUses/"));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ linkerManager.createYangNodeSet(utilManager.getYangNodeSet());
+ YangLinkerUtils.updateFilePriority(utilManager.getYangNodeSet());
+ linkerManager.processInterFileLinking(utilManager.getYangNodeSet());
+
+ YangNode targetNode = null;
+ String targetNodeName = 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, XpathLinkingTypes.AUGMENT_LINKING);
+ }
+ }
+
+ assertThat(true, is(targetNode.getName().equals(targetNodeName)));
+ }
+
+ /**
+ * Unit test case for inter file linking for single level container.
+ *
+ * @throws IOException when fails to do IO operations
+ */
+ @Test
+ public void processInterFileLinkingSingleLevel() throws IOException {
+
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(INTER_FILE_PATH + "InterSingle/"));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ linkerManager.createYangNodeSet(utilManager.getYangNodeSet());
+ linkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
+
+ YangNode targetNode = null;
+ String targetNodeName = 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, XpathLinkingTypes.AUGMENT_LINKING);
+ }
+ }
+
+ assertThat(true, is(targetNode.getName().equals(targetNodeName)));
+ }
+
+ /**
+ * Unit test case for inter file linking for multi level container.
+ *
+ * @throws IOException when fails to do IO operations
+ */
+ @Test
+ public void processInterFileLinkingMultipleLevel() throws IOException {
+
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(INTER_FILE_PATH + "InterMulti/"));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ linkerManager.createYangNodeSet(utilManager.getYangNodeSet());
+ linkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
+
+ YangNode targetNode = null;
+ String targetNodeName = 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, XpathLinkingTypes.AUGMENT_LINKING);
+ }
+ }
+
+ assertThat(true, is(targetNode.getName().equals(targetNodeName)));
+ }
+
+ /**
+ * Unit test case for inter file linking for single level augment.
+ *
+ * @throws IOException when fails to do IO operations
+ */
+ @Test
+ public void processInterFileLinkingInAugmentSingleLevel() throws IOException {
+
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(INTER_FILE_PATH + "InterSingleAugment/"));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ linkerManager.createYangNodeSet(utilManager.getYangNodeSet());
+ linkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
+
+ YangNode targetNode = null;
+ String targetNodeName = 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, XpathLinkingTypes.AUGMENT_LINKING);
+ }
+ }
+
+ assertThat(true, is(targetNode.getName().equals(targetNodeName)));
+ }
+
+ /**
+ * Unit test case for inter file linking for multi level augment.
+ *
+ * @throws IOException when fails to do IO operations
+ */
+ @Test
+ public void processInterFileLinkingInAugmentMultiLevel() throws IOException {
+
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(INTER_FILE_PATH + "InterMultiAugment/"));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ linkerManager.createYangNodeSet(utilManager.getYangNodeSet());
+ linkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
+
+ YangNode targetNode = null;
+ String targetNodeName = 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, XpathLinkingTypes.AUGMENT_LINKING);
+ }
+ }
+
+ assertThat(true, is(targetNode.getName().equals(targetNodeName)));
+ }
+
+ /**
+ * Unit test case for multipler inter file linking for single level augment.
+ *
+ * @throws IOException when fails to do IO operations
+ */
+ @Test
+ public void processMultiInterFileLinkingInAugmentSingleLevel() throws IOException {
+
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(INTER_FILE_PATH + "InterMultiFileAugment/"));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ linkerManager.createYangNodeSet(utilManager.getYangNodeSet());
+ linkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
+
+ YangNode targetNode = null;
+ String targetNodeName = 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, XpathLinkingTypes.AUGMENT_LINKING);
+ }
+ }
+
+ assertThat(true, is(targetNode.getName().equals(targetNodeName)));
+ }
+
+ /**
+ * Unit test case for multiple inter file linking for multi level augment.
+ *
+ * @throws IOException when fails to do IO operations
+ */
+ @Test
+ public void processMultiInterFileLinkingInAugmentMultiLevel() throws IOException {
+
+ utilManager
+ .createYangFileInfoSet(YangFileScanner.getYangFiles(INTER_FILE_PATH + "InterMultiFileAugmentMulti/"));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ linkerManager.createYangNodeSet(utilManager.getYangNodeSet());
+ linkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
+ linkerManager.linkSubModulesToParentModule(utilManager.getYangNodeSet());
+ linkerManager.addRefToYangFilesIncludeList(utilManager.getYangNodeSet());
+ YangLinkerUtils.updateFilePriority(utilManager.getYangNodeSet());
+ linkerManager.processInterFileLinking(utilManager.getYangNodeSet());
+
+ YangNode targetNode = null;
+ String targetNodeName = 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 = augment.getAugmentedNode();
+ }
+ }
+
+ assertThat(true, is(targetNode.getName().equals(targetNodeName)));
+ }
+
+ /**
+ * Unit test case for inter file linking for single level submodule.
+ *
+ * @throws IOException when fails to do IO operations
+ */
+ @Test
+ public void processInterFileLinkingInSubModuleSingleLevel() throws IOException {
+
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(INTER_FILE_PATH + "InterSingleSubModule/"));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ linkerManager.createYangNodeSet(utilManager.getYangNodeSet());
+ linkerManager.linkSubModulesToParentModule(utilManager.getYangNodeSet());
+ linkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
+ linkerManager.addRefToYangFilesIncludeList(utilManager.getYangNodeSet());
+ YangLinkerUtils.updateFilePriority(utilManager.getYangNodeSet());
+ linkerManager.processInterFileLinking(utilManager.getYangNodeSet());
+ YangNode targetNode = null;
+ String targetNodeName = 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 = augment.getAugmentedNode();
+ }
+ }
+
+ assertThat(true, is(targetNode.getName().equals(targetNodeName)));
+ }
+
+ /**
+ * Unit test case for inter file linking for multi level submodule.
+ *
+ * @throws IOException when fails to do IO operations
+ */
+ @Test
+ public void processInterFileLinkingInSubModuleMultiLevel() throws IOException {
+
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(INTER_FILE_PATH + "InterMultiSubModule/"));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ linkerManager.createYangNodeSet(utilManager.getYangNodeSet());
+ linkerManager.linkSubModulesToParentModule(utilManager.getYangNodeSet());
+ linkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
+ linkerManager.addRefToYangFilesIncludeList(utilManager.getYangNodeSet());
+ YangLinkerUtils.updateFilePriority(utilManager.getYangNodeSet());
+ linkerManager.processInterFileLinking(utilManager.getYangNodeSet());
+ YangNode targetNode = null;
+ String targetNodeName = 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 = augment.getAugmentedNode();
+ }
+ }
+
+ assertThat(true, is(targetNode.getName().equals(targetNodeName)));
+ }
+
+ /**
+ * Unit test case for inter file linking for multi level uses inside augment.
+ *
+ * @throws IOException when fails to do IO operations
+ */
+ @Test
+ public void processInterFileLinkingInUsesInAugment() throws IOException {
+
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(INTER_FILE_PATH + "InterSingleUses/"));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ linkerManager.createYangNodeSet(utilManager.getYangNodeSet());
+ linkerManager.linkSubModulesToParentModule(utilManager.getYangNodeSet());
+ linkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
+ linkerManager.addRefToYangFilesIncludeList(utilManager.getYangNodeSet());
+ YangLinkerUtils.updateFilePriority(utilManager.getYangNodeSet());
+ linkerManager.processInterFileLinking(utilManager.getYangNodeSet());
+
+ YangNode targetNode = null;
+ String targetNodeName = 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 = augment.getAugmentedNode();
+ }
+ }
+
+ assertThat(true, is(targetNode.getName().equals(targetNodeName)));
+
+ }
+
+ /**
+ * Unit test case for inter file linking for multi level uses.
+ *
+ * @throws IOException when fails to do IO operations
+ */
+ @Test
+ public void processInterFileLinkingInUsesMultiLevel() throws IOException {
+
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(INTER_FILE_PATH + "InterMultiUses/"));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ linkerManager.createYangNodeSet(utilManager.getYangNodeSet());
+ linkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
+ linkerManager.addRefToYangFilesIncludeList(utilManager.getYangNodeSet());
+ YangLinkerUtils.updateFilePriority(utilManager.getYangNodeSet());
+ linkerManager.processInterFileLinking(utilManager.getYangNodeSet());
+
+ YangNode targetNode = null;
+ String targetNodeName = 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, XpathLinkingTypes.AUGMENT_LINKING);
+ }
+ }
+
+ assertThat(true, is(targetNode.getName().equals(targetNodeName)));
+ }
+
+ /**
+ * Unit test case for inter file linking for multi level uses inside augment.
+ *
+ * @throws IOException when fails to do IO operations
+ */
+ @Test
+ public void processInterFileLinkingInMultipleSubmodules() throws IOException {
+
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(CASE_FILE_PATH + "submodule/"));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ linkerManager.createYangNodeSet(utilManager.getYangNodeSet());
+ linkerManager.linkSubModulesToParentModule(utilManager.getYangNodeSet());
+ linkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
+ linkerManager.addRefToYangFilesIncludeList(utilManager.getYangNodeSet());
+ YangLinkerUtils.updateFilePriority(utilManager.getYangNodeSet());
+
+ linkerManager.processInterFileLinking(utilManager.getYangNodeSet());
+
+ YangNode targetNode = null;
+ String targetNodeName = 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 = augment.getAugmentedNode();
+ }
+ }
+
+ assertThat(true, is(targetNode.getName().equals(targetNodeName)));
+
+ }
+
+ /**
+ * Unit test case for inter file linking for multi level uses inside augment.
+ *
+ * @throws IOException when fails to do IO operations
+ */
+ @Test
+ public void processInterFileLinkingInMultipleUses() throws IOException {
+
+ YangIoUtils.deleteDirectory("target/xpath/");
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(CASE_FILE_PATH + "uses/"));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ linkerManager.createYangNodeSet(utilManager.getYangNodeSet());
+ linkerManager.linkSubModulesToParentModule(utilManager.getYangNodeSet());
+ linkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
+ linkerManager.addRefToYangFilesIncludeList(utilManager.getYangNodeSet());
+ YangLinkerUtils.updateFilePriority(utilManager.getYangNodeSet());
+ linkerManager.processInterFileLinking(utilManager.getYangNodeSet());
+
+ YangNode targetNode = null;
+ String targetNodeName = 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 = augment.getAugmentedNode();
+ }
+ }
+
+ YangPluginConfig yangPluginConfig = new YangPluginConfig();
+ yangPluginConfig.setCodeGenDir("target/xpath/");
+ utilManager.translateToJava(yangPluginConfig);
+ String dir = System.getProperty("user.dir") + File.separator + "target/xpath/";
+ YangPluginConfig.compileCode(dir);
+ YangIoUtils.deleteDirectory("target/xpath/");
+ assertThat(true, is(targetNode.getName().equals(targetNodeName)));
+ }
+}
diff --git a/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/ietfyang/IetfYangFileTest.java b/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/ietfyang/IetfYangFileTest.java
new file mode 100644
index 0000000..82de4c5
--- /dev/null
+++ b/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/ietfyang/IetfYangFileTest.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yang.compiler.plugin.maven.ietfyang;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.junit.Test;
+import org.onosproject.yang.compiler.utils.io.YangPluginConfig;
+import org.onosproject.yang.compiler.utils.io.impl.YangFileScanner;
+import org.onosproject.yang.compiler.utils.io.impl.YangIoUtils;
+import org.onosproject.yang.compiler.parser.exceptions.ParserException;
+import org.onosproject.yang.compiler.plugin.maven.YangUtilManager;
+
+import java.io.File;
+import java.io.IOException;
+
+/**
+ * Test cases for testing IETF YANG files.
+ */
+public class IetfYangFileTest {
+
+ private final YangUtilManager utilManager = new YangUtilManager();
+
+ /**
+ * Checks hierarchical intra with inter file type linking.
+ * Reference: https://datatracker.ietf.org/doc/draft-zha-l3sm-l3vpn-onos-deployment
+ */
+ @Test
+ public void l3vpnserviceyang()
+ throws IOException, ParserException, MojoExecutionException {
+
+ String dir = "target/ietfyang/l3vpnservice/";
+ YangIoUtils.deleteDirectory(dir);
+ String searchDir = "src/test/resources/ietfyang/l3vpnservice";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.resolveDependenciesUsingLinker();
+
+ YangPluginConfig yangPluginConfig = new YangPluginConfig();
+ yangPluginConfig.setCodeGenDir(dir);
+
+ utilManager.translateToJava(yangPluginConfig);
+ String dir1 = System.getProperty("user.dir") + File.separator + dir;
+ YangPluginConfig.compileCode(dir1);
+ YangIoUtils.deleteDirectory("target/ietfyang/");
+ }
+
+}
diff --git a/compiler/plugin/maven/src/test/resources/ChoiceCaseTranslator.yang b/compiler/plugin/maven/src/test/resources/ChoiceCaseTranslator.yang
new file mode 100644
index 0000000..5834795
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/ChoiceCaseTranslator.yang
@@ -0,0 +1,42 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ container food {
+ choice snack {
+ case sports-arena {
+ leaf pretzel {
+ type string;
+ }
+ leaf beer {
+ type string;
+ }
+ }
+ case late-night {
+ leaf chocolate {
+ type string;
+ }
+ }
+ }
+ container dinner {
+ leaf cheese {
+ type string;
+ }
+ }
+ choice snack2 {
+ case sports-arena {
+ leaf pretzel {
+ type string;
+ }
+ leaf beer {
+ type string;
+ }
+ }
+ case late-night {
+ leaf chocolate {
+ type string;
+ }
+ }
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/EnumTranslator.yang b/compiler/plugin/maven/src/test/resources/EnumTranslator.yang
new file mode 100644
index 0000000..1957c1f
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/EnumTranslator.yang
@@ -0,0 +1,17 @@
+module Sfc {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf test{
+ type string;
+ }
+ leaf myenum {
+ type enumeration {
+ enum zero;
+ enum one;
+ enum seven {
+ value 7;
+ }
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/LengthRestrictionInRefType.yang b/compiler/plugin/maven/src/test/resources/LengthRestrictionInRefType.yang
new file mode 100644
index 0000000..54684f4
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/LengthRestrictionInRefType.yang
@@ -0,0 +1,13 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type hello {
+ length "0..100";
+ }
+ }
+ typedef hello {
+ type string;
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/LengthRestrictionInTypedef.yang b/compiler/plugin/maven/src/test/resources/LengthRestrictionInTypedef.yang
new file mode 100644
index 0000000..17baeec
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/LengthRestrictionInTypedef.yang
@@ -0,0 +1,13 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type hello;
+ }
+ typedef hello {
+ type string {
+ length "0..100";
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/LengthRestrictionInTypedefAndTypeInValid.yang b/compiler/plugin/maven/src/test/resources/LengthRestrictionInTypedefAndTypeInValid.yang
new file mode 100644
index 0000000..65ed7de
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/LengthRestrictionInTypedefAndTypeInValid.yang
@@ -0,0 +1,15 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type hello {
+ length "min..20 | 200..max";
+ }
+ }
+ typedef hello {
+ type string {
+ length "0..100 | 101..200 | 201..300";
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/LengthRestrictionInTypedefAndTypeValid.yang b/compiler/plugin/maven/src/test/resources/LengthRestrictionInTypedefAndTypeValid.yang
new file mode 100644
index 0000000..eca2691
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/LengthRestrictionInTypedefAndTypeValid.yang
@@ -0,0 +1,15 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type hello {
+ length "min..20 | 201..max";
+ }
+ }
+ typedef hello {
+ type string {
+ length "0..100 | 101..200 | 201..300";
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/MultiplePatternAndLengthRestriction.yang b/compiler/plugin/maven/src/test/resources/MultiplePatternAndLengthRestriction.yang
new file mode 100644
index 0000000..d971643
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/MultiplePatternAndLengthRestriction.yang
@@ -0,0 +1,19 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type hello {
+ pattern "[a-z]";
+ pattern "[A-Z]";
+ length "min..20 | 201..max";
+ }
+ }
+ typedef hello {
+ type string {
+ pattern "[0-9]";
+ pattern "[\n]";
+ length "0..100 | 101..200 | 201..300";
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/MultiplePatternAndLengthRestrictionInValid.yang b/compiler/plugin/maven/src/test/resources/MultiplePatternAndLengthRestrictionInValid.yang
new file mode 100644
index 0000000..7ba3ef9
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/MultiplePatternAndLengthRestrictionInValid.yang
@@ -0,0 +1,19 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type hello {
+ pattern "[a-z]";
+ pattern "[A-Z]";
+ length "min..20 | 100..max";
+ }
+ }
+ typedef hello {
+ type string {
+ pattern "[0-9]";
+ pattern "[\n]";
+ length "0..100 | 101..200 | 201..300";
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/MultiplePatternAndLengthRestrictionValid.yang b/compiler/plugin/maven/src/test/resources/MultiplePatternAndLengthRestrictionValid.yang
new file mode 100644
index 0000000..161b558
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/MultiplePatternAndLengthRestrictionValid.yang
@@ -0,0 +1,18 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type hello {
+ pattern "[a-z]";
+ pattern "[A-Z]";
+ length "min..20 | 100..max";
+ }
+ }
+ typedef hello {
+ type string {
+ pattern "[0-9]";
+ pattern "[\n]";
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/MultiplePatternRestrictionInRefTypeAndTypedef.yang b/compiler/plugin/maven/src/test/resources/MultiplePatternRestrictionInRefTypeAndTypedef.yang
new file mode 100644
index 0000000..eaa28c5
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/MultiplePatternRestrictionInRefTypeAndTypedef.yang
@@ -0,0 +1,17 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type hello {
+ pattern "[a-z]";
+ pattern "[A-Z]";
+ }
+ }
+ typedef hello {
+ type string {
+ pattern "[0-9]";
+ pattern "[\n]";
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/NotificationTest.yang b/compiler/plugin/maven/src/test/resources/NotificationTest.yang
new file mode 100644
index 0000000..f199dbd
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/NotificationTest.yang
@@ -0,0 +1,13 @@
+module NotificationTest {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ notification test {
+ leaf type {
+ type string;
+ }
+ leaf severity {
+ type string;
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/PatternRestrictionInRefType.yang b/compiler/plugin/maven/src/test/resources/PatternRestrictionInRefType.yang
new file mode 100644
index 0000000..189177d
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/PatternRestrictionInRefType.yang
@@ -0,0 +1,13 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type hello {
+ pattern "[a-zA-Z]";
+ }
+ }
+ typedef hello {
+ type string;
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/PatternRestrictionInRefTypeAndTypedef.yang b/compiler/plugin/maven/src/test/resources/PatternRestrictionInRefTypeAndTypedef.yang
new file mode 100644
index 0000000..e01b224
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/PatternRestrictionInRefTypeAndTypedef.yang
@@ -0,0 +1,15 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type hello {
+ pattern "[a-zA-Z]";
+ }
+ }
+ typedef hello {
+ type string {
+ pattern "[0-9]";
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/PatternRestrictionInTypedef.yang b/compiler/plugin/maven/src/test/resources/PatternRestrictionInTypedef.yang
new file mode 100644
index 0000000..7875504
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/PatternRestrictionInTypedef.yang
@@ -0,0 +1,13 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type hello;
+ }
+ typedef hello {
+ type string {
+ pattern "[a-zA-Z]";
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/RangeRestrictionInRefType.yang b/compiler/plugin/maven/src/test/resources/RangeRestrictionInRefType.yang
new file mode 100644
index 0000000..da396fa
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/RangeRestrictionInRefType.yang
@@ -0,0 +1,13 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type hello {
+ range "1..4 | 10..20";
+ }
+ }
+ typedef hello {
+ type int32;
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/RangeRestrictionInRefTypeAndTypedefInValid.yang b/compiler/plugin/maven/src/test/resources/RangeRestrictionInRefTypeAndTypedefInValid.yang
new file mode 100644
index 0000000..f45f1ee
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/RangeRestrictionInRefTypeAndTypedefInValid.yang
@@ -0,0 +1,15 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type hello {
+ range "min..4 | min..max";
+ }
+ }
+ typedef hello {
+ type int32 {
+ range "1..4 | 10..20";
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/RangeRestrictionInRefTypeAndTypedefValid.yang b/compiler/plugin/maven/src/test/resources/RangeRestrictionInRefTypeAndTypedefValid.yang
new file mode 100644
index 0000000..b0af767
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/RangeRestrictionInRefTypeAndTypedefValid.yang
@@ -0,0 +1,15 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type hello {
+ range "min..4 | 10..max";
+ }
+ }
+ typedef hello {
+ type int32 {
+ range "1..4 | 10..20";
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/RangeRestrictionInRefTypedef.yang b/compiler/plugin/maven/src/test/resources/RangeRestrictionInRefTypedef.yang
new file mode 100644
index 0000000..14382b5
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/RangeRestrictionInRefTypedef.yang
@@ -0,0 +1,33 @@
+module Test {
+ namespace "urn:ietf:params:xml:ns:yang:yt3";
+ prefix "yt3";
+
+ organization
+ "YANG Language Design Team";
+
+ contact
+ "Andy Bierman";
+
+ description
+ "YANG test module 3.";
+
+ revision 2007-12-04 {
+ description "Initial revision.";
+ }
+
+ typedef Num3 {
+ units seconds;
+ type int16 {
+ range "-32000 .. 4 | max";
+ }
+ description "test 3";
+ }
+
+ typedef Num6 {
+ description "test 6";
+ type Num3 {
+ range "-3 | -2 .. +2 | 3";
+ }
+ default 0;
+ }
+}
\ No newline at end of file
diff --git a/compiler/plugin/maven/src/test/resources/RangeRestrictionInString.yang b/compiler/plugin/maven/src/test/resources/RangeRestrictionInString.yang
new file mode 100644
index 0000000..f167230
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/RangeRestrictionInString.yang
@@ -0,0 +1,13 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type hello;
+ }
+ typedef hello {
+ type string {
+ range "1..4 | 10..20";
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/RangeRestrictionInStringInRefType.yang b/compiler/plugin/maven/src/test/resources/RangeRestrictionInStringInRefType.yang
new file mode 100644
index 0000000..c08635f
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/RangeRestrictionInStringInRefType.yang
@@ -0,0 +1,13 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type hello {
+ range "1..4 | 10..20";
+ }
+ }
+ typedef hello {
+ type string;
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/RangeRestrictionInTypedef.yang b/compiler/plugin/maven/src/test/resources/RangeRestrictionInTypedef.yang
new file mode 100644
index 0000000..0f53d1f
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/RangeRestrictionInTypedef.yang
@@ -0,0 +1,13 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type hello;
+ }
+ typedef hello {
+ type int32 {
+ range "1..4 | 10..20";
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/RangeRestrictionInvalidInRefTypedef.yang b/compiler/plugin/maven/src/test/resources/RangeRestrictionInvalidInRefTypedef.yang
new file mode 100644
index 0000000..9e93f1e
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/RangeRestrictionInvalidInRefTypedef.yang
@@ -0,0 +1,33 @@
+module Test {
+ namespace "urn:ietf:params:xml:ns:yang:yt3";
+ prefix "yt3";
+
+ organization
+ "YANG Language Design Team";
+
+ contact
+ "Andy Bierman";
+
+ description
+ "YANG test module 3.";
+
+ revision 2007-12-04 {
+ description "Initial revision.";
+ }
+
+ typedef Num3 {
+ units seconds;
+ type int16 {
+ range "-3 | -2 .. +2 | 3";
+ }
+ description "test 3";
+ }
+
+ typedef Num6 {
+ description "test 6";
+ type Num3 {
+ range "-32000 .. 4 | max" ;
+ }
+ default 0;
+ }
+}
\ No newline at end of file
diff --git a/compiler/plugin/maven/src/test/resources/RpcTranslator.yang b/compiler/plugin/maven/src/test/resources/RpcTranslator.yang
new file mode 100644
index 0000000..2f0616e
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/RpcTranslator.yang
@@ -0,0 +1,25 @@
+module Sfc {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf test{
+ type string;
+ }
+ container my-container{
+ leaf my-val{
+ type string;
+ }
+ }
+ rpc SFP {
+ input {
+ leaf port {
+ type string;
+ }
+ }
+ output {
+ leaf path {
+ type string;
+ }
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/SelfFileLinkingTypedefAtMiddleLevelAfterParentHolder.yang b/compiler/plugin/maven/src/test/resources/SelfFileLinkingTypedefAtMiddleLevelAfterParentHolder.yang
new file mode 100644
index 0000000..812a528
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/SelfFileLinkingTypedefAtMiddleLevelAfterParentHolder.yang
@@ -0,0 +1,16 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ container ospf {
+ list valid {
+ key "invalid-interval";
+ leaf invalid-interval {
+ type hello;
+ }
+ }
+ typedef hello {
+ type string;
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/SelfFileLinkingTypedefAtRootIsAfterContainerHavingType.yang b/compiler/plugin/maven/src/test/resources/SelfFileLinkingTypedefAtRootIsAfterContainerHavingType.yang
new file mode 100644
index 0000000..10ccab6
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/SelfFileLinkingTypedefAtRootIsAfterContainerHavingType.yang
@@ -0,0 +1,16 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ container ospf {
+ list valid {
+ key "invalid-interval";
+ leaf invalid-interval {
+ type hello;
+ }
+ }
+ }
+ typedef hello {
+ type string;
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/SelfFileLinkingTypedefAtRootTypeTwoLevelInHierarchy.yang b/compiler/plugin/maven/src/test/resources/SelfFileLinkingTypedefAtRootTypeTwoLevelInHierarchy.yang
new file mode 100644
index 0000000..eddb649
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/SelfFileLinkingTypedefAtRootTypeTwoLevelInHierarchy.yang
@@ -0,0 +1,16 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ typedef hello {
+ type string;
+ }
+ container ospf {
+ list valid {
+ key "invalid-interval";
+ leaf invalid-interval {
+ type hello;
+ }
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/SelfFileLinkingTypedefNotFound.yang b/compiler/plugin/maven/src/test/resources/SelfFileLinkingTypedefNotFound.yang
new file mode 100644
index 0000000..523f0b4
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/SelfFileLinkingTypedefNotFound.yang
@@ -0,0 +1,18 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ container ospf {
+ list valid {
+ key "invalid-interval";
+ leaf invalid-interval {
+ type Ant:hello;
+ }
+ }
+ }
+ container isis {
+ typedef hello {
+ type string;
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/SelfFileLinkingWithFeature.yang b/compiler/plugin/maven/src/test/resources/SelfFileLinkingWithFeature.yang
new file mode 100644
index 0000000..53de63a
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/SelfFileLinkingWithFeature.yang
@@ -0,0 +1,23 @@
+module syslog {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix "sys";
+ feature local-storage {
+ description
+ "This feature means the device supports local
+ storage (memory, flash or disk) that can be used to
+ store syslog messages.";
+ }
+
+ container speed {
+ leaf local-storage-limit {
+ if-feature local-storage;
+ type uint64;
+ units "kilobyte";
+ config false;
+ description
+ "The amount of local storage that can be
+ used to hold syslog messages.";
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/SelfFileLinkingWithFeatureInSubModule.yang b/compiler/plugin/maven/src/test/resources/SelfFileLinkingWithFeatureInSubModule.yang
new file mode 100644
index 0000000..09b8b37
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/SelfFileLinkingWithFeatureInSubModule.yang
@@ -0,0 +1,24 @@
+submodule syslog {
+ yang-version 1;
+ belongs-to "syslog1" {
+ prefix "sys";
+ }
+ feature local-storage {
+ description
+ "This feature means the device supports local
+ storage (memory, flash or disk) that can be used to
+ store syslog messages.";
+ }
+
+ container speed {
+ leaf local-storage-limit {
+ if-feature local-storage;
+ type uint64;
+ units "kilobyte";
+ config false;
+ description
+ "The amount of local storage that can be
+ used to hold syslog messages.";
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/SelfFileLinkingWithFeatureUndefined.yang b/compiler/plugin/maven/src/test/resources/SelfFileLinkingWithFeatureUndefined.yang
new file mode 100644
index 0000000..f55c61a
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/SelfFileLinkingWithFeatureUndefined.yang
@@ -0,0 +1,17 @@
+module syslog {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix "sys";
+
+ container speed {
+ leaf local-storage-limit {
+ if-feature local-storage;
+ type uint64;
+ units "kilobyte";
+ config false;
+ description
+ "The amount of local storage that can be
+ used to hold syslog messages.";
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/SelfFileLinkingWithGroupingHierarchicalRefUnresolved.yang b/compiler/plugin/maven/src/test/resources/SelfFileLinkingWithGroupingHierarchicalRefUnresolved.yang
new file mode 100644
index 0000000..cd71621
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/SelfFileLinkingWithGroupingHierarchicalRefUnresolved.yang
@@ -0,0 +1,14 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ import ietf-yang-types {
+ prefix "P";
+ }
+ grouping create {
+ uses P:valid;
+ }
+ container test{
+ uses create;
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/SelfFileLinkingWithGroupingWithSelfAndExternalPrefixMix.yang b/compiler/plugin/maven/src/test/resources/SelfFileLinkingWithGroupingWithSelfAndExternalPrefixMix.yang
new file mode 100644
index 0000000..b6e3b45
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/SelfFileLinkingWithGroupingWithSelfAndExternalPrefixMix.yang
@@ -0,0 +1,28 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ import ietf-yang-types {
+ prefix "P";
+ }
+ grouping Percentage {
+ leaf hello{
+ type string;
+ }
+ }
+ container ospf {
+ list valid {
+ key "invalid";
+ leaf invalid{
+ type string;
+ }
+ uses Ant:FirstClass;
+ grouping FirstClass {
+ uses P:PassingClass;
+ }
+ }
+ grouping PassingClass {
+ uses Ant:Percentage;
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/SelfFileLinkingWithGroupingWithSelfModulePrefix.yang b/compiler/plugin/maven/src/test/resources/SelfFileLinkingWithGroupingWithSelfModulePrefix.yang
new file mode 100644
index 0000000..956ba50
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/SelfFileLinkingWithGroupingWithSelfModulePrefix.yang
@@ -0,0 +1,25 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ grouping Percentage {
+ leaf hello{
+ type string;
+ }
+ }
+ container ospf {
+ list valid {
+ key "invalid";
+ leaf invalid{
+ type string;
+ }
+ uses Ant:FirstClass;
+ grouping FirstClass {
+ uses PassingClass;
+ }
+ }
+ grouping PassingClass {
+ uses Ant:Percentage;
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/SelfFileLinkingWithHierarchicalTypeFailureScenario.yang b/compiler/plugin/maven/src/test/resources/SelfFileLinkingWithHierarchicalTypeFailureScenario.yang
new file mode 100644
index 0000000..d622196
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/SelfFileLinkingWithHierarchicalTypeFailureScenario.yang
@@ -0,0 +1,22 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ typedef Percentage {
+ type Ant:INT;
+ }
+ container ospf {
+ list valid {
+ key "invalid-interval";
+ leaf invalid-interval {
+ type Ant:FirstClass;
+ }
+ typedef FirstClass {
+ type Ant:PassingClass;
+ }
+ }
+ typedef PassingClass {
+ type Percentage;
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/SelfFileLinkingWithMultipleDependency.yang b/compiler/plugin/maven/src/test/resources/SelfFileLinkingWithMultipleDependency.yang
new file mode 100644
index 0000000..d230f99
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/SelfFileLinkingWithMultipleDependency.yang
@@ -0,0 +1,26 @@
+module syslog {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix "sys";
+
+ feature p2mp-te {
+ description "Indicates support for P2MP-TE";
+ }
+
+ feature frr-te {
+ description "Indicates support for TE FastReroute (FRR)";
+ if-feature p2mp-te;
+ }
+
+ container speed {
+ leaf local-storage-limit {
+ if-feature frr-te;
+ type uint64;
+ units "kilobyte";
+ config false;
+ description
+ "The amount of local storage that can be
+ used to hold syslog messages.";
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/SelfFileLinkingWithMultipleDependencyUnresolved.yang b/compiler/plugin/maven/src/test/resources/SelfFileLinkingWithMultipleDependencyUnresolved.yang
new file mode 100644
index 0000000..02bca89
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/SelfFileLinkingWithMultipleDependencyUnresolved.yang
@@ -0,0 +1,22 @@
+module syslog {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix "sys";
+
+ feature frr-te {
+ description "Indicates support for TE FastReroute (FRR)";
+ if-feature p2mp-te;
+ }
+
+ container speed {
+ leaf local-storage-limit {
+ if-feature frr-te;
+ type uint64;
+ units "kilobyte";
+ config false;
+ description
+ "The amount of local storage that can be
+ used to hold syslog messages.";
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/SelfFileLinkingWithMultipleFeature.yang b/compiler/plugin/maven/src/test/resources/SelfFileLinkingWithMultipleFeature.yang
new file mode 100644
index 0000000..407023c
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/SelfFileLinkingWithMultipleFeature.yang
@@ -0,0 +1,26 @@
+module syslog {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix "sys";
+
+ feature p2mp-te {
+ description "Indicates support for P2MP-TE";
+ }
+
+ feature frr-te {
+ description "Indicates support for TE FastReroute (FRR)";
+ if-feature p2mp-te;
+ }
+
+ container speed {
+ leaf local-storage-limit {
+ if-feature local-storage;
+ type uint64;
+ units "kilobyte";
+ config false;
+ description
+ "The amount of local storage that can be
+ used to hold syslog messages.";
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/SelfFileLinkingWithTypdefHierarchicalRefUnresolved.yang b/compiler/plugin/maven/src/test/resources/SelfFileLinkingWithTypdefHierarchicalRefUnresolved.yang
new file mode 100644
index 0000000..a3e4379
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/SelfFileLinkingWithTypdefHierarchicalRefUnresolved.yang
@@ -0,0 +1,25 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ import ietf-yang-types {
+ prefix "P";
+ }
+ typedef Percentage {
+ type P:Per;
+ }
+ container ospf {
+ list valid {
+ key "invalid-interval";
+ leaf invalid-interval {
+ type FirstClass;
+ }
+ typedef FirstClass {
+ type PassingClass;
+ }
+ }
+ typedef PassingClass {
+ type Percentage;
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/SelfFileLinkingWithTypdefHierarchicalReference.yang b/compiler/plugin/maven/src/test/resources/SelfFileLinkingWithTypdefHierarchicalReference.yang
new file mode 100644
index 0000000..958dc23
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/SelfFileLinkingWithTypdefHierarchicalReference.yang
@@ -0,0 +1,22 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ typedef Percentage {
+ type int32;
+ }
+ container ospf {
+ list valid {
+ key "invalid-interval";
+ leaf invalid-interval {
+ type FirstClass;
+ }
+ typedef FirstClass {
+ type PassingClass;
+ }
+ }
+ typedef PassingClass {
+ type Percentage;
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/SelfFileLinkingWithTypeWithSelfAndExternalPrefixMix.yang b/compiler/plugin/maven/src/test/resources/SelfFileLinkingWithTypeWithSelfAndExternalPrefixMix.yang
new file mode 100644
index 0000000..d5f346e
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/SelfFileLinkingWithTypeWithSelfAndExternalPrefixMix.yang
@@ -0,0 +1,25 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ import ietf-yang-types {
+ prefix "P";
+ }
+ typedef Percentage {
+ type int32;
+ }
+ container ospf {
+ list valid {
+ key "invalid-interval";
+ leaf invalid-interval {
+ type Ant:FirstClass;
+ }
+ typedef FirstClass {
+ type P:PassingClass;
+ }
+ }
+ typedef PassingClass {
+ type Ant:Percentage;
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/SelfFileLinkingWithTypeWithSelfModulePrefix.yang b/compiler/plugin/maven/src/test/resources/SelfFileLinkingWithTypeWithSelfModulePrefix.yang
new file mode 100644
index 0000000..4f292b8
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/SelfFileLinkingWithTypeWithSelfModulePrefix.yang
@@ -0,0 +1,22 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ typedef Percentage {
+ type int32;
+ }
+ container ospf {
+ list valid {
+ key "invalid-interval";
+ leaf invalid-interval {
+ type Ant:FirstClass;
+ }
+ typedef FirstClass {
+ type PassingClass;
+ }
+ }
+ typedef PassingClass {
+ type Ant:Percentage;
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/SelfResolutionGroupingHavingSameUsesManyTimes.yang b/compiler/plugin/maven/src/test/resources/SelfResolutionGroupingHavingSameUsesManyTimes.yang
new file mode 100644
index 0000000..d449adf
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/SelfResolutionGroupingHavingSameUsesManyTimes.yang
@@ -0,0 +1,25 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ container valid {
+ grouping endpoint {
+ leaf zip-code {
+ type string;
+ }
+ uses failure;
+ container hold {
+ leaf newone {
+ type string;
+ }
+
+ }
+ uses failure;
+ }
+ grouping failure {
+ leaf test {
+ type string;
+ }
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/SelfResolutionGroupingInRpcAndUsesInOutput.yang b/compiler/plugin/maven/src/test/resources/SelfResolutionGroupingInRpcAndUsesInOutput.yang
new file mode 100644
index 0000000..3589a9f
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/SelfResolutionGroupingInRpcAndUsesInOutput.yang
@@ -0,0 +1,34 @@
+module rock {
+ namespace "http://example.net/rock";
+ prefix "rock";
+
+ rpc rock-the-house {
+ description "description";
+ status current;
+ reference "reference";
+ grouping hello {
+ list valid {
+ key invalid-interval;
+ reference "RFC 6020";
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+ }
+ }
+ input {
+ leaf zip-code {
+ type string;
+ }
+ uses hello;
+ }
+ output {
+ leaf status {
+ type string;
+ }
+ uses hello;
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/SelfResolutionGroupingReferencingItselfFailureScenerio.yang b/compiler/plugin/maven/src/test/resources/SelfResolutionGroupingReferencingItselfFailureScenerio.yang
new file mode 100644
index 0000000..3e0ba3d
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/SelfResolutionGroupingReferencingItselfFailureScenerio.yang
@@ -0,0 +1,13 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ container valid {
+ grouping endpoint {
+ leaf zip-code {
+ type string;
+ }
+ uses endpoint;
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/SelfResolutionGroupingWithMultipleUses.yang b/compiler/plugin/maven/src/test/resources/SelfResolutionGroupingWithMultipleUses.yang
new file mode 100644
index 0000000..906890f
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/SelfResolutionGroupingWithMultipleUses.yang
@@ -0,0 +1,63 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ container valid {
+ grouping endpoint {
+ leaf zip-code {
+ type string;
+ }
+ uses first;
+ container design {
+ uses second;
+ container correct {
+ leaf newone {
+ type string;
+ }
+ uses third;
+ }
+ }
+ uses fourth;
+ uses fifth;
+ }
+ uses endpoint;
+ grouping first {
+ list valid {
+ key invalid-interval;
+ reference "RFC 6020";
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+ }
+ }
+ grouping second {
+ leaf ink {
+ type int32;
+ }
+ }
+ grouping third {
+ container value {
+ leaf zip-code {
+ type string;
+ }
+ }
+ }
+ grouping fourth {
+ typedef my-type {
+ status deprecated;
+ type int32;
+ }
+ leaf correct {
+ type my-type;
+ }
+ }
+ grouping fifth {
+ leaf abc {
+ type string;
+ }
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/SelfResolutionNestedGroupingWithUnresolvedUses.yang b/compiler/plugin/maven/src/test/resources/SelfResolutionNestedGroupingWithUnresolvedUses.yang
new file mode 100644
index 0000000..b2ab735
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/SelfResolutionNestedGroupingWithUnresolvedUses.yang
@@ -0,0 +1,17 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ container test {
+ leaf leaf2 {
+ type string;
+ }
+ grouping treat {
+ grouping create {
+ grouping mass {
+ }
+ }
+ }
+ }
+ uses Ant:treat;
+}
diff --git a/compiler/plugin/maven/src/test/resources/SelfResolutionRpcWithOneTypedefAndTwoGroupingUnderDifferentNode.yang b/compiler/plugin/maven/src/test/resources/SelfResolutionRpcWithOneTypedefAndTwoGroupingUnderDifferentNode.yang
new file mode 100644
index 0000000..91dc763
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/SelfResolutionRpcWithOneTypedefAndTwoGroupingUnderDifferentNode.yang
@@ -0,0 +1,38 @@
+module rock {
+ namespace "http://example.net/rock";
+ prefix "rock";
+
+ rpc rock-the-house {
+ description "description";
+ status current;
+ reference "reference";
+ input {
+ leaf zip-code {
+ type string;
+ }
+ grouping creative {
+ leaf carry {
+ type string;
+ }
+ }
+ }
+ output {
+ leaf status {
+ type string;
+ }
+ grouping creative {
+ list valid {
+ key invalid-interval;
+ leaf invalid-interval {
+ type "uint16";
+ }
+ }
+ }
+ typedef my-type {
+ status deprecated;
+ type int32;
+ }
+ uses creative;
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/SelfResolutionWhenLeafrefDoesntHavePath.yang b/compiler/plugin/maven/src/test/resources/SelfResolutionWhenLeafrefDoesntHavePath.yang
new file mode 100644
index 0000000..90b9efc
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/SelfResolutionWhenLeafrefDoesntHavePath.yang
@@ -0,0 +1,17 @@
+module ietf-network {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-network";
+ prefix nd;
+ container networks {
+ description
+ "Serves as top-level container for a list of networks.";
+ leaf network-id {
+ type uint8;
+ description
+ "Identifies a network.";
+ }
+ }
+ leaf-list network-ref {
+ type leafref;
+ }
+}
\ No newline at end of file
diff --git a/compiler/plugin/maven/src/test/resources/SelfResolutionWhenTypeAndTypedefAtRootLevel.yang b/compiler/plugin/maven/src/test/resources/SelfResolutionWhenTypeAndTypedefAtRootLevel.yang
new file mode 100644
index 0000000..da6795b
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/SelfResolutionWhenTypeAndTypedefAtRootLevel.yang
@@ -0,0 +1,11 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type hello;
+ }
+ typedef hello {
+ type string;
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/SelfResolutionWhenTypeAndTypedefAtRootLevelForBinary.yang b/compiler/plugin/maven/src/test/resources/SelfResolutionWhenTypeAndTypedefAtRootLevelForBinary.yang
new file mode 100644
index 0000000..d6ff30e
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/SelfResolutionWhenTypeAndTypedefAtRootLevelForBinary.yang
@@ -0,0 +1,17 @@
+module ospf {
+ namespace "urn:cisco:params:xml:ns:yang:ospf";
+ // replace with IANA namespace when assigned
+ prefix ospf;
+ revision 2020-10-20 {
+ description
+ "Initial revision.";
+ }
+
+ typedef type14 {
+ type binary;
+ }
+
+ leaf typedef14 {
+ type type14;
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/SelfResolutionWhenTypeReferredTypedefNotDefined.yang b/compiler/plugin/maven/src/test/resources/SelfResolutionWhenTypeReferredTypedefNotDefined.yang
new file mode 100644
index 0000000..33f90c9
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/SelfResolutionWhenTypeReferredTypedefNotDefined.yang
@@ -0,0 +1,11 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type Ant:hello;
+ }
+ typedef hi {
+ type string;
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/SelfResolutionWhenUsesAndGroupingAtRootLevel.yang b/compiler/plugin/maven/src/test/resources/SelfResolutionWhenUsesAndGroupingAtRootLevel.yang
new file mode 100644
index 0000000..f6e9197
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/SelfResolutionWhenUsesAndGroupingAtRootLevel.yang
@@ -0,0 +1,11 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ uses hello;
+ grouping hello {
+ leaf hello{
+ type string;
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/SelfResolutionWhenUsesAndGroupingAtRootLevelGroupingWithChild.yang b/compiler/plugin/maven/src/test/resources/SelfResolutionWhenUsesAndGroupingAtRootLevelGroupingWithChild.yang
new file mode 100644
index 0000000..13cc4a5
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/SelfResolutionWhenUsesAndGroupingAtRootLevelGroupingWithChild.yang
@@ -0,0 +1,16 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ uses treat;
+ grouping treat {
+ leaf treat{
+ type string;
+ }
+ container test{
+ leaf leaf2{
+ type string;
+ }
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/UnionTranslator.yang b/compiler/plugin/maven/src/test/resources/UnionTranslator.yang
new file mode 100644
index 0000000..f1de318
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/UnionTranslator.yang
@@ -0,0 +1,13 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ container valid {
+ leaf invalid-interval {
+ type union {
+ type int32;
+ type int8;
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/compiler/plugin/maven/src/test/resources/augmentTranslator/test.yang b/compiler/plugin/maven/src/test/resources/augmentTranslator/test.yang
new file mode 100644
index 0000000..a5a0daf
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/augmentTranslator/test.yang
@@ -0,0 +1,167 @@
+module test {
+ namespace "test:test";
+ prefix test ;
+
+
+ import test1{
+ prefix test1;
+ }
+
+ import test2{
+ prefix test2;
+ }
+
+ include acme-types;
+
+ organization "";
+ contact "";
+
+ description
+ "Defines basic service types for L3VPN service.";
+
+ revision "2015-12-16" {
+ reference "";
+ }
+
+ container cont1 {
+ container cont2 {
+ leaf leaf {
+ type int32;
+ }
+ }
+ }
+
+ choice choice1 {
+ case case1 {
+ leaf case-leaf {
+ type int32;
+ }
+ container case-container3 {
+ leaf leafs {
+ type int64;
+ }
+ }
+ }
+ }
+
+ leaf leaf-a {
+ type int32;
+ }
+
+ leaf-list leaf-list-a {
+ type int32;
+ }
+
+ list list-a {
+ key "name";
+ leaf name {
+ type string;
+ }
+ }
+
+ augment /cont3 {
+ leaf leaf1 {
+ type int32;
+ }
+ }
+
+ augment /cont1/cont2 {
+ leaf-list leaf2 {
+ type int32;
+ }
+ }
+ augment /choice1 {
+ case case2 {
+ container con1 {
+ leaf in1 {
+ type int32;
+ }
+ }
+ }
+ case case3 {
+ container con2 {
+ leaf in2 {
+ type int32;
+ }
+ }
+ }
+ leaf-list leaf2 {
+ type int32;
+ }
+ leaf leaf1 {
+ type int32;
+ }
+ container case-container {
+ leaf leafs {
+ type int64;
+ }
+ }
+ container case-container2 {
+ leaf leafs {
+ type int64;
+ }
+ }
+ }
+
+ augment /test1:cont1/test1:cont2 {
+ leaf a {
+ type int32;
+ }
+ }
+
+ augment /test1:cont1/test1:cont2/test1:cont1s/test1:cont1s {
+ leaf a {
+ type int32;
+ }
+ }
+
+ augment /test1:cont1/test1:cont2/test1:cont1s/test1:cont1s/test2:aa {
+ leaf name {
+ type string;
+ }
+ leaf surname {
+ type string;
+ }
+ leaf-list aleaflist {
+ type int32;
+ }
+ container cont1 {
+ }
+ list alist {
+ key "name";
+ leaf name {
+ type string;
+ }
+ leaf-list surname {
+ type string;
+ }
+ }
+ }
+
+ augment /test1:rpc-input/test1:input {
+ leaf leaf2 {
+ type int32;
+ }
+ }
+
+ augment /test1:rpc-output/test1:output {
+ leaf leaf2 {
+ type int32;
+ }
+ }
+
+ augment /test1:rpc-input-output/test1:output {
+ leaf leaf2 {
+ type int32;
+ }
+ }
+
+ augment /test1:rpc-input-output/test1:input {
+ leaf leaf2 {
+ type int32;
+ }
+ }
+
+
+}
+
diff --git a/compiler/plugin/maven/src/test/resources/augmentTranslator/test2.yang b/compiler/plugin/maven/src/test/resources/augmentTranslator/test2.yang
new file mode 100644
index 0000000..1eae21b
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/augmentTranslator/test2.yang
@@ -0,0 +1,60 @@
+module test1 {
+ namespace "test1:test1";
+ prefix test1 ;
+
+ organization "";
+ contact "";
+
+ description
+ "Defines basic service types for L3VPN service.";
+
+ revision "2015-12-16" {
+ reference "";
+ }
+
+ container cont1 {
+ container cont2 {
+ }
+ }
+
+ augment /cont1/cont2 {
+ leaf leaf4 {
+ type int32;
+ }
+ container cont1s {
+ container cont1s {
+ }
+ }
+ }
+
+ rpc rpc-input {
+ input {
+ leaf leaf1 {
+ type int32;
+ }
+ }
+ }
+
+ rpc rpc-output {
+ output {
+ leaf leaf1 {
+ type int32;
+ }
+ }
+ }
+
+ rpc rpc-input-output {
+ input {
+ leaf leaf1 {
+ type int32;
+ }
+ }
+ output {
+ leaf leaf1 {
+ type int32;
+ }
+ }
+ }
+
+}
+
diff --git a/compiler/plugin/maven/src/test/resources/augmentTranslator/test3.yang b/compiler/plugin/maven/src/test/resources/augmentTranslator/test3.yang
new file mode 100644
index 0000000..dca558c
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/augmentTranslator/test3.yang
@@ -0,0 +1,26 @@
+module test2 {
+ namespace "test2:test2";
+ prefix test2 ;
+
+ import test1{
+ prefix test1;
+ }
+ organization "";
+ contact "";
+
+ description
+ "Defines basic service types for L3VPN service.";
+
+ revision "2015-12-16" {
+ reference "";
+ }
+
+
+ augment /test1:cont1/test1:cont2/test1:cont1s/test1:cont1s {
+ leaf leaf5 {
+ type int32;
+ }
+ container aa {
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/augmentTranslator/test4.yang b/compiler/plugin/maven/src/test/resources/augmentTranslator/test4.yang
new file mode 100644
index 0000000..bed22db
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/augmentTranslator/test4.yang
@@ -0,0 +1,18 @@
+submodule acme-types {
+
+ belongs-to "test" {
+ prefix "test";
+ }
+ organization "";
+ contact "";
+
+ description
+ "Defines basic service types for L3VPN service.";
+
+ revision "2015-12-16" {
+ reference "";
+ }
+
+ container cont3 {
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/augmentTranslator/test5.yang b/compiler/plugin/maven/src/test/resources/augmentTranslator/test5.yang
new file mode 100644
index 0000000..b7cf234
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/augmentTranslator/test5.yang
@@ -0,0 +1,25 @@
+module test5 {
+ namespace "test:test";
+ prefix test5 ;
+
+ import test{
+ prefix test;
+ }
+ organization "";
+ contact "";
+
+ description
+ "Defines basic service types for L3VPN service.";
+
+ revision "2015-12-16" {
+ reference "";
+ }
+
+ augment /test:cont1 {
+ leaf leaf1 {
+ type int32;
+ }
+ }
+
+}
+
diff --git a/compiler/plugin/maven/src/test/resources/choiceAugment/test.yang b/compiler/plugin/maven/src/test/resources/choiceAugment/test.yang
new file mode 100644
index 0000000..ceee3d7
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/choiceAugment/test.yang
@@ -0,0 +1,78 @@
+module test {
+ namespace "test:test";
+ prefix test ;
+
+ import test1{
+ prefix test1;
+ }
+ organization "";
+ contact "";
+
+ description
+ "Defines basic service types for L3VPN service.";
+
+ revision "2015-12-16" {
+ reference "";
+ }
+
+ augment /test1:rpc-input-output/test1:output/ {
+ choice choice1 {
+ container case1 {
+ leaf int-leaf {
+ type int32;
+ }
+ }
+ }
+ }
+
+ list node {
+ key "node-id";
+ leaf node-id{
+ type string;
+ }
+ leaf-list node-prop{
+ type string;
+ }
+ container termination-points{
+ leaf number-of-tp {
+ type int16;
+ }
+ list termination-point {
+ key "tp-id";
+ leaf tp-id {
+ type string;
+ }
+ }
+ }
+ choice choice1{
+ case case1a{
+ leaf leaf1a1{
+ type string;
+ }
+ leaf leaf1a2{
+ type string;
+ }
+ }
+ case case1b{
+ choice choice1b{
+ case case1bi{
+ leaf leaf1bia{
+ type string;
+ }
+ leaf leaf1bib{
+ type string;
+ }
+ }
+ case case1bii{
+ leaf leaf1biia{
+ type string;
+ }
+ leaf leaf1biib{
+ type string;
+ }
+ }
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/compiler/plugin/maven/src/test/resources/choiceAugment/test2.yang b/compiler/plugin/maven/src/test/resources/choiceAugment/test2.yang
new file mode 100644
index 0000000..4caa38b
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/choiceAugment/test2.yang
@@ -0,0 +1,26 @@
+module test1 {
+ namespace "test1:test1";
+ prefix test1 ;
+
+ organization "";
+ contact "";
+
+ description
+ "Defines basic service types for L3VPN service.";
+ revision "2015-12-16" {
+ reference "";
+ }
+
+ rpc rpc-input-output {
+ input {
+ leaf leaf1 {
+ type int32;
+ }
+ }
+ output {
+ leaf leaf1 {
+ type int32;
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/compiler/plugin/maven/src/test/resources/choiceTranslator/all.yang b/compiler/plugin/maven/src/test/resources/choiceTranslator/all.yang
new file mode 100644
index 0000000..be2fd07
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/choiceTranslator/all.yang
@@ -0,0 +1,157 @@
+module all {
+
+ namespace "yang:all";
+ prefix "all";
+ yang-version 1;
+
+ choice name {
+ case a {
+ leaf udp {
+ type empty;
+ }
+ }
+ case b {
+ leaf tcp {
+ type empty;
+ }
+ }
+ }
+
+
+ container c {
+ choice name {
+ case a {
+ leaf udp {
+ type empty;
+ }
+ }
+ case b {
+ leaf tcp {
+ type empty;
+ }
+ }
+ }
+ }
+
+ list l {
+ config false;
+choice name {
+ case a {
+ leaf udp {
+ type empty;
+ }
+ }
+ case b {
+ leaf tcp {
+ type empty;
+ }
+ }
+ }
+ }
+
+
+ grouping g {
+ choice name {
+ case a {
+ leaf udp {
+ type empty;
+ }
+ }
+ case b {
+ leaf tcp {
+ type empty;
+ }
+ }
+ }
+ }
+ rpc r {
+ input {
+ choice name {
+ case a {
+ leaf udp {
+ type empty;
+ }
+ }
+ case b {
+ leaf tcp {
+ type empty;
+ }
+ }
+ }
+ }
+ output {
+ choice name {
+ case a {
+ leaf udp {
+ type empty;
+ }
+ }
+ case b {
+ leaf tcp {
+ type empty;
+ }
+ }
+ }
+ }
+ }
+
+ augment /name {
+ choice name {
+ case a {
+ leaf udp {
+ type empty;
+ }
+ container cont1 {
+ container cont2 {
+ choice name {
+ case a {
+ leaf udp {
+ type empty;
+ }
+ container cont1 {
+ container cont2 {
+ leaf udp1 {
+ type empty;
+ }
+ }
+ leaf udp2 {
+ type empty;
+ }
+ }
+ }
+ case b {
+ leaf tcp3 {
+ type empty;
+ }
+ }
+ }
+ leaf udp4 {
+ type empty;
+ }
+ }
+ leaf udp5 {
+ type empty;
+ }
+ }
+ }
+ case b {
+ leaf tcp2 {
+ type empty;
+ }
+ }
+ }
+ choice name1 {
+ case a {
+ leaf udp {
+ type empty;
+ }
+ }
+ case b {
+ leaf tcp {
+ type empty;
+ }
+ }
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/compiler/plugin/maven/src/test/resources/compilerAnnotation/test.yang b/compiler/plugin/maven/src/test/resources/compilerAnnotation/test.yang
new file mode 100644
index 0000000..592e23f
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/compilerAnnotation/test.yang
@@ -0,0 +1,33 @@
+module test {
+ namespace "test:test";
+ prefix test;
+ typedef type1 {
+ type string;
+ }
+ list list1 {
+ key "name sur-name";
+ leaf name {
+ type string;
+ }
+ leaf sur-name {
+ type type1;
+ }
+ choice c1 {
+ case ca1 {
+ leaf a {
+ type int32;
+ }
+ }
+ }
+ }
+ list list2 {
+ key "name sur-name";
+ leaf name {
+ type string;
+ }
+ leaf sur-name {
+ type type1;
+ }
+ }
+}
+
diff --git a/compiler/plugin/maven/src/test/resources/compilerAnnotation/test2.yang b/compiler/plugin/maven/src/test/resources/compilerAnnotation/test2.yang
new file mode 100644
index 0000000..704f724
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/compilerAnnotation/test2.yang
@@ -0,0 +1,21 @@
+module test1 {
+ namespace "test1:test1";
+ prefix test1 ;
+
+ import test {
+ prefix test;
+ }
+ organization "";
+ contact "";
+
+ description
+ "Defines basic service types for L3VPN service.";
+
+ revision "2015-12-16" {
+ reference "";
+ }
+
+ ca:compiler-annotation /test:list1 {
+ ds:app-data-structure "Map";
+ }
+}
\ No newline at end of file
diff --git a/compiler/plugin/maven/src/test/resources/file1UsesFile2TypeDefFile3Type/ietf-inet-types.yang b/compiler/plugin/maven/src/test/resources/file1UsesFile2TypeDefFile3Type/ietf-inet-types.yang
new file mode 100644
index 0000000..db6df27
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/file1UsesFile2TypeDefFile3Type/ietf-inet-types.yang
@@ -0,0 +1,12 @@
+ module ietf-inet-types {
+
+ yang-version 1;
+
+ namespace
+ "urn:ietf:params:xml:ns:yang:ietf-inet-types";
+
+ prefix inet;
+ typedef uri {
+ type string;
+ }
+ }
diff --git a/compiler/plugin/maven/src/test/resources/file1UsesFile2TypeDefFile3Type/ietf-network-topology.yang b/compiler/plugin/maven/src/test/resources/file1UsesFile2TypeDefFile3Type/ietf-network-topology.yang
new file mode 100644
index 0000000..4f426e4
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/file1UsesFile2TypeDefFile3Type/ietf-network-topology.yang
@@ -0,0 +1,34 @@
+ module ietf-network-topology {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-network-topology";
+ prefix lnk;
+
+ import ietf-inet-types {
+ prefix inet;
+ }
+
+ typedef tp-id {
+ type inet:uri;
+ description
+ "An identifier for termination points on a node.
+ The identifier SHOULD be chosen such that the same TP in a
+ real network topology will always be identified through the
+ same identifier, even if the model is instantiated in
+ separate datastores. An implementation MAY choose to capture
+ semantics in the identifier, for example to indicate the type
+ of TP and/or the type of node and topology that the TP is a
+ part of.";
+ }
+
+ grouping tp-ref {
+ description
+ "References a termination point in a specific node.";
+ leaf tp-ref {
+ type tp-id;
+ description
+ "A type for an absolute reference to a termination point.
+ (This type should not be used for relative references.
+ In such a case, a relative path should be used instead.)";
+ }
+ }
+ }
diff --git a/compiler/plugin/maven/src/test/resources/file1UsesFile2TypeDefFile3Type/ietf-te-topology.yang b/compiler/plugin/maven/src/test/resources/file1UsesFile2TypeDefFile3Type/ietf-te-topology.yang
new file mode 100644
index 0000000..c1d9324
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/file1UsesFile2TypeDefFile3Type/ietf-te-topology.yang
@@ -0,0 +1,17 @@
+ module ietf-te-topology {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-te-topology";
+ // replace with IANA namespace when assigned
+
+ prefix "tet";
+
+ import ietf-network-topology {
+ prefix "nt";
+ }
+
+ container underlay-trail-src {
+ uses nt:tp-ref;
+ description
+ "Source TE link of the underlay trail.";
+ }
+ }
diff --git a/compiler/plugin/maven/src/test/resources/grouping/grouping.yang b/compiler/plugin/maven/src/test/resources/grouping/grouping.yang
new file mode 100644
index 0000000..518150f
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/grouping/grouping.yang
@@ -0,0 +1,58 @@
+module grouping {
+
+ namespace "yang:grouping";
+ prefix "grouping";
+ yang-version 1;
+ revision 2016-10-08;
+
+ grouping link-details {
+ leaf link-id {
+ type union {
+ type int32;
+ type uint16;
+ type enumeration {
+ enum one;
+ enum two;
+ enum five {
+ value 5;
+ }
+ enum six-square {
+ value 36;
+ }
+ }
+ }
+ }
+ typedef group {
+ type bits {
+ bit disable-nagle {
+ position 0;
+ }
+ bit auto-sense-speed {
+ position 1;
+ }
+ bit Mb-only {
+ position 2;
+ }
+ }
+ }
+ container link {
+ leaf port {
+ type int32;
+ }
+
+ leaf-list port-id {
+ type string;
+ }
+ list areas {
+ key "name1";
+ leaf name1 {
+ type string;
+ }
+ }
+ }
+ }
+
+ container cont2 {
+ uses link-details;
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/groupingNodeSameAsModule/portpair.yang b/compiler/plugin/maven/src/test/resources/groupingNodeSameAsModule/portpair.yang
new file mode 100644
index 0000000..3497f04
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/groupingNodeSameAsModule/portpair.yang
@@ -0,0 +1,29 @@
+module port-pair {
+
+ yang-version 1;
+
+ namespace "sfc.portpair";
+
+ prefix "port-pair";
+
+ grouping port-pair {
+ container port-pair {
+
+ leaf name {
+ type string;
+ }
+
+
+ leaf description {
+ type string;
+ }
+
+ }
+ }
+
+ rpc get-port-pair {
+ output {
+ uses port-pair;
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/hierarchicalinterfiletype/ietf-inet-types.yang b/compiler/plugin/maven/src/test/resources/hierarchicalinterfiletype/ietf-inet-types.yang
new file mode 100644
index 0000000..38f209f
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/hierarchicalinterfiletype/ietf-inet-types.yang
@@ -0,0 +1,15 @@
+ module ietf-inet-types {
+
+ yang-version 1;
+
+ namespace
+ "urn:ietf:params:xml:ns:yang:ietf-inet-types";
+
+ prefix inet;
+
+
+
+ typedef uri {
+ type string;
+ }
+ }
diff --git a/compiler/plugin/maven/src/test/resources/hierarchicalinterfiletype/ietf-network-topology.yang b/compiler/plugin/maven/src/test/resources/hierarchicalinterfiletype/ietf-network-topology.yang
new file mode 100644
index 0000000..6e9dfb7
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/hierarchicalinterfiletype/ietf-network-topology.yang
@@ -0,0 +1,17 @@
+ module ietf-network-topology {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-network-topology";
+ prefix nt;
+
+ import ietf-inet-types {
+ prefix inet;
+ }
+ import ietf-network {
+ prefix nd;
+ }
+ leaf source-node {
+ type nd:node-id;
+ description
+ "Source node identifier, must be in same topology.";
+ }
+ }
diff --git a/compiler/plugin/maven/src/test/resources/hierarchicalinterfiletype/ietf-network.yang b/compiler/plugin/maven/src/test/resources/hierarchicalinterfiletype/ietf-network.yang
new file mode 100644
index 0000000..1f15b40
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/hierarchicalinterfiletype/ietf-network.yang
@@ -0,0 +1,16 @@
+ module ietf-network {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-network";
+ prefix nd;
+
+ import ietf-inet-types {
+ prefix inet;
+ }
+
+ typedef node-id {
+ type inet:uri;
+ description
+ "Identifier for a node.";
+ }
+
+ }
diff --git a/compiler/plugin/maven/src/test/resources/hierarchicalintrawithinterfiletype/ietf-inet-types.yang b/compiler/plugin/maven/src/test/resources/hierarchicalintrawithinterfiletype/ietf-inet-types.yang
new file mode 100644
index 0000000..48d13c6
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/hierarchicalintrawithinterfiletype/ietf-inet-types.yang
@@ -0,0 +1,13 @@
+ module ietf-inet-types {
+
+ yang-version 1;
+
+ namespace
+ "urn:ietf:params:xml:ns:yang:ietf-inet-types";
+
+ prefix inet;
+
+ typedef uri {
+ type string;
+ }
+ }
diff --git a/compiler/plugin/maven/src/test/resources/hierarchicalintrawithinterfiletype/ietf-network.yang b/compiler/plugin/maven/src/test/resources/hierarchicalintrawithinterfiletype/ietf-network.yang
new file mode 100644
index 0000000..e35d0f5
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/hierarchicalintrawithinterfiletype/ietf-network.yang
@@ -0,0 +1,22 @@
+ module ietf-network {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-network";
+ prefix nd;
+
+ import ietf-inet-types {
+ prefix inet;
+ }
+ leaf node-ref {
+ type node-id;
+ description
+ "Used to reference a node.
+ Nodes are identified relative to the network they are
+ contained in.";
+ }
+
+ typedef node-id {
+ type inet:uri;
+ description
+ "Identifier for a node.";
+ }
+ }
diff --git a/compiler/plugin/maven/src/test/resources/identityRef/identityRef.yang b/compiler/plugin/maven/src/test/resources/identityRef/identityRef.yang
new file mode 100644
index 0000000..a7389e7
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/identityRef/identityRef.yang
@@ -0,0 +1,19 @@
+module IdentityTest{
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix IdentityTest;
+
+ identity ref-address-family {
+ description "ref-address-family";
+ }
+
+ identity ipv4-address-family {
+ base ref-address-family;
+ }
+
+ leaf tunnel {
+ type identityref {
+ base ref-address-family;
+ }
+ }
+}
\ No newline at end of file
diff --git a/compiler/plugin/maven/src/test/resources/identityTranslator/test.yang b/compiler/plugin/maven/src/test/resources/identityTranslator/test.yang
new file mode 100644
index 0000000..f4f61bd
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/identityTranslator/test.yang
@@ -0,0 +1,81 @@
+module IdentityTest{
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix IdentityTest;
+
+ identity ref-address-family {
+ description "ref-address-family";
+ }
+
+ identity ipv4-address-family {
+ base ref-address-family;
+ }
+
+ identity ipv6-address-family {
+ base ipv4-address-family;
+ }
+
+ typedef tunnel-type {
+ type identityref {
+ base ref-address-family;
+ }
+ }
+ leaf tunnel1 {
+ type identityref {
+ base ipv4-address-family;
+ }
+ }
+
+ typedef type2 {
+ type identityref {
+ base ipv4-address-family;
+ }
+ }
+
+ container ip {
+ container ipv4-address-family {
+ leaf tunnel1 {
+ type identityref {
+ base ipv4-address-family;
+ }
+ }
+ }
+ }
+
+ typedef type3 {
+ type union {
+ type type2;
+ type identityref {
+ base ipv4-address-family;
+ }
+ }
+ }
+ leaf tunnel {
+ type union {
+ type type2;
+ type identityref {
+ base ipv6-address-family;
+ }
+ }
+ }
+ typedef ipv4-address {
+ type string {
+ pattern
+ '(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(%[\p{N}\p{L}]+)?';
+ }
+ description
+ "The ipv4-address type represents an IPv4 address in
+ dotted-quad notation. The IPv4 address may include a zone
+ index, separated by a % sign.
+
+ The zone index is used to disambiguate identical address
+ values. For link-local addresses, the zone index will
+ typically be the interface index number or the name of an
+ interface. If the zone index is not present, the default
+ zone of the device will be used.
+
+ The canonical format for the zone index is the numerical
+ format";
+ }
+
+}
diff --git a/compiler/plugin/maven/src/test/resources/ietfyang/l3vpnservice/ietf-inet-types.yang b/compiler/plugin/maven/src/test/resources/ietfyang/l3vpnservice/ietf-inet-types.yang
new file mode 100644
index 0000000..851a4d7
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/ietfyang/l3vpnservice/ietf-inet-types.yang
@@ -0,0 +1,454 @@
+ module ietf-inet-types {
+
+ yang-version 1;
+
+ namespace
+ "urn:ietf:params:xml:ns:yang:ietf-inet-types";
+
+ prefix inet;
+
+ organization
+ "IETF NETMOD (NETCONF Data Modeling Language) Working Group";
+
+ contact
+ "WG Web: <http://tools.ietf.org/wg/netmod/>
+ WG List: <mailto:netmod@ietf.org>
+
+ WG Chair: David Kessens
+ <mailto:david.kessens@nsn.com>
+
+ WG Chair: Juergen Schoenwaelder
+ <mailto:j.schoenwaelder@jacobs-university.de>
+
+ Editor: Juergen Schoenwaelder
+ <mailto:j.schoenwaelder@jacobs-university.de>";
+
+ description
+ "This module contains a collection of generally useful derived
+ YANG data types for Internet addresses and related things.
+
+ Copyright (c) 2013 IETF Trust and the persons identified as
+ authors of the code. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or
+ without modification, is permitted pursuant to, and subject
+ to the license terms contained in, the Simplified BSD License
+ set forth in Section 4.c of the IETF Trust's Legal Provisions
+ Relating to IETF Documents
+ (http://trustee.ietf.org/license-info).
+
+ This version of this YANG module is part of RFC 6991; see
+ the RFC itself for full legal notices.";
+
+ revision "2013-07-15" {
+ description
+ "This revision adds the following new data types:
+ - ip-address-no-zone
+ - ipv4-address-no-zone
+ - ipv6-address-no-zone";
+ reference
+ "RFC 6991: Common YANG Data Types";
+
+ }
+
+ revision "2010-09-24" {
+ description "Initial revision.";
+ reference
+ "RFC 6021: Common YANG Data Types";
+
+ }
+
+
+ typedef ip-version {
+ type enumeration {
+ enum "unknown" {
+ value 0;
+ description
+ "An unknown or unspecified version of the Internet
+ protocol.";
+ }
+ enum "ipv4" {
+ value 1;
+ description
+ "The IPv4 protocol as defined in RFC 791.";
+ }
+ enum "ipv6" {
+ value 2;
+ description
+ "The IPv6 protocol as defined in RFC 2460.";
+ }
+ }
+ description
+ "This value represents the version of the IP protocol.
+
+ In the value set and its semantics, this type is equivalent
+ to the InetVersion textual convention of the SMIv2.";
+ reference
+ "RFC 791: Internet Protocol
+ RFC 2460: Internet Protocol, Version 6 (IPv6) Specification
+ RFC 4001: Textual Conventions for Internet Network Addresses";
+
+ }
+
+ typedef dscp {
+ type uint8 {
+ range "0..63";
+ }
+ description
+ "The dscp type represents a Differentiated Services Code Point
+ that may be used for marking packets in a traffic stream.
+ In the value set and its semantics, this type is equivalent
+ to the Dscp textual convention of the SMIv2.";
+ reference
+ "RFC 3289: Management Information Base for the Differentiated
+ Services Architecture
+ RFC 2474: Definition of the Differentiated Services Field
+ (DS Field) in the IPv4 and IPv6 Headers
+ RFC 2780: IANA Allocation Guidelines For Values In
+ the Internet Protocol and Related Headers";
+
+ }
+
+ typedef ipv6-flow-label {
+ type uint32 {
+ range "0..1048575";
+ }
+ description
+ "The ipv6-flow-label type represents the flow identifier or Flow
+ Label in an IPv6 packet header that may be used to
+ discriminate traffic flows.
+
+ In the value set and its semantics, this type is equivalent
+ to the IPv6FlowLabel textual convention of the SMIv2.";
+ reference
+ "RFC 3595: Textual Conventions for IPv6 Flow Label
+ RFC 2460: Internet Protocol, Version 6 (IPv6) Specification";
+
+ }
+
+ typedef port-number {
+ type uint16 {
+ range "0..65535";
+ }
+ description
+ "The port-number type represents a 16-bit port number of an
+ Internet transport-layer protocol such as UDP, TCP, DCCP, or
+ SCTP. Port numbers are assigned by IANA. A current list of
+ all assignments is available from <http://www.iana.org/>.
+
+ Note that the port number value zero is reserved by IANA. In
+ situations where the value zero does not make sense, it can
+ be excluded by subtyping the port-number type.
+ In the value set and its semantics, this type is equivalent
+ to the InetPortNumber textual convention of the SMIv2.";
+ reference
+ "RFC 768: User Datagram Protocol
+ RFC 793: Transmission Control Protocol
+ RFC 4960: Stream Control Transmission Protocol
+ RFC 4340: Datagram Congestion Control Protocol (DCCP)
+ RFC 4001: Textual Conventions for Internet Network Addresses";
+
+ }
+
+ typedef as-number {
+ type uint32;
+ description
+ "The as-number type represents autonomous system numbers
+ which identify an Autonomous System (AS). An AS is a set
+ of routers under a single technical administration, using
+ an interior gateway protocol and common metrics to route
+ packets within the AS, and using an exterior gateway
+ protocol to route packets to other ASes. IANA maintains
+ the AS number space and has delegated large parts to the
+ regional registries.
+
+ Autonomous system numbers were originally limited to 16
+ bits. BGP extensions have enlarged the autonomous system
+ number space to 32 bits. This type therefore uses an uint32
+ base type without a range restriction in order to support
+ a larger autonomous system number space.
+
+ In the value set and its semantics, this type is equivalent
+ to the InetAutonomousSystemNumber textual convention of
+ the SMIv2.";
+ reference
+ "RFC 1930: Guidelines for creation, selection, and registration
+ of an Autonomous System (AS)
+ RFC 4271: A Border Gateway Protocol 4 (BGP-4)
+ RFC 4001: Textual Conventions for Internet Network Addresses
+ RFC 6793: BGP Support for Four-Octet Autonomous System (AS)
+ Number Space";
+
+ }
+
+ typedef ip-address {
+ type union {
+ type ipv4-address;
+ type ipv6-address;
+ }
+ description
+ "The ip-address type represents an IP address and is IP
+ version neutral. The format of the textual representation
+ implies the IP version. This type supports scoped addresses
+ by allowing zone identifiers in the address format.";
+ reference
+ "RFC 4007: IPv6 Scoped Address Architecture";
+
+ }
+
+ typedef ipv4-address {
+ type string {
+ pattern
+ '(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(%[\p{N}\p{L}]+)?';
+ }
+ description
+ "The ipv4-address type represents an IPv4 address in
+ dotted-quad notation. The IPv4 address may include a zone
+ index, separated by a % sign.
+
+ The zone index is used to disambiguate identical address
+ values. For link-local addresses, the zone index will
+ typically be the interface index number or the name of an
+ interface. If the zone index is not present, the default
+ zone of the device will be used.
+
+ The canonical format for the zone index is the numerical
+ format";
+ }
+
+ typedef ipv6-address {
+ type string {
+ pattern
+ '((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))(%[\p{N}\p{L}]+)?';
+ pattern
+ '(([^:]+:){6}(([^:]+:[^:]+)|(.*\..*)))|((([^:]+:)*[^:]+)?::(([^:]+:)*[^:]+)?)(%.+)?';
+ }
+ description
+ "The ipv6-address type represents an IPv6 address in full,
+ mixed, shortened, and shortened-mixed notation. The IPv6
+ address may include a zone index, separated by a % sign.
+
+ The zone index is used to disambiguate identical address
+ values. For link-local addresses, the zone index will
+ typically be the interface index number or the name of an
+ interface. If the zone index is not present, the default
+ zone of the device will be used.
+
+
+
+ The canonical format of IPv6 addresses uses the textual
+ representation defined in Section 4 of RFC 5952. The
+ canonical format for the zone index is the numerical
+ format as described in Section 11.2 of RFC 4007.";
+ reference
+ "RFC 4291: IP Version 6 Addressing Architecture
+ RFC 4007: IPv6 Scoped Address Architecture
+ RFC 5952: A Recommendation for IPv6 Address Text
+ Representation";
+
+ }
+
+ typedef ip-address-no-zone {
+ type union {
+ type ipv4-address-no-zone;
+ type ipv6-address-no-zone;
+ }
+ description
+ "The ip-address-no-zone type represents an IP address and is
+ IP version neutral. The format of the textual representation
+ implies the IP version. This type does not support scoped
+ addresses since it does not allow zone identifiers in the
+ address format.";
+ reference
+ "RFC 4007: IPv6 Scoped Address Architecture";
+
+ }
+
+ typedef ipv4-address-no-zone {
+ type ipv4-address {
+ pattern '[0-9\.]*';
+ }
+ description
+ "An IPv4 address without a zone index. This type, derived from
+ ipv4-address, may be used in situations where the zone is
+ known from the context and hence no zone index is needed.";
+ }
+
+ typedef ipv6-address-no-zone {
+ type ipv6-address {
+ pattern '[0-9a-fA-F:\.]*';
+ }
+ description
+ "An IPv6 address without a zone index. This type, derived from
+ ipv6-address, may be used in situations where the zone is
+ known from the context and hence no zone index is needed.";
+ reference
+ "RFC 4291: IP Version 6 Addressing Architecture
+ RFC 4007: IPv6 Scoped Address Architecture
+ RFC 5952: A Recommendation for IPv6 Address Text
+ Representation";
+
+ }
+
+ typedef ip-prefix {
+ type union {
+ type ipv4-prefix;
+ type ipv6-prefix;
+ }
+ description
+ "The ip-prefix type represents an IP prefix and is IP
+ version neutral. The format of the textual representations
+ implies the IP version.";
+ }
+
+ typedef ipv4-prefix {
+ type string {
+ pattern
+ '(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])/(([0-9])|([1-2][0-9])|(3[0-2]))';
+ }
+ description
+ "The ipv4-prefix type represents an IPv4 address prefix.
+ The prefix length is given by the number following the
+ slash character and must be less than or equal to 32.
+
+ A prefix length value of n corresponds to an IP address
+ mask that has n contiguous 1-bits from the most
+ significant bit (MSB) and all other bits set to 0.
+
+ The canonical format of an IPv4 prefix has all bits of
+ the IPv4 address set to zero that are not part of the
+ IPv4 prefix.";
+ }
+
+ typedef ipv6-prefix {
+ type string {
+ pattern
+ '((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))(/(([0-9])|([0-9]{2})|(1[0-1][0-9])|(12[0-8])))';
+ pattern
+ '(([^:]+:){6}(([^:]+:[^:]+)|(.*\..*)))|((([^:]+:)*[^:]+)?::(([^:]+:)*[^:]+)?)(/.+)';
+ }
+ description
+ "The ipv6-prefix type represents an IPv6 address prefix.
+ The prefix length is given by the number following the
+ slash character and must be less than or equal to 128.
+
+ A prefix length value of n corresponds to an IP address
+ mask that has n contiguous 1-bits from the most
+ significant bit (MSB) and all other bits set to 0.
+
+ The IPv6 address should have all bits that do not belong
+ to the prefix set to zero.
+
+ The canonical format of an IPv6 prefix has all bits of
+ the IPv6 address set to zero that are not part of the
+ IPv6 prefix. Furthermore, the IPv6 address is represented
+ as defined in Section 4 of RFC 5952.";
+ reference
+ "RFC 5952: A Recommendation for IPv6 Address Text
+ Representation";
+
+ }
+
+ typedef domain-name {
+ type string {
+ length "1..253";
+ pattern
+ '((([a-zA-Z0-9_]([a-zA-Z0-9\-_]){0,61})?[a-zA-Z0-9]\.)*([a-zA-Z0-9_]([a-zA-Z0-9\-_]){0,61})?[a-zA-Z0-9]\.?)|\.';
+ }
+ description
+ "The domain-name type represents a DNS domain name. The
+ name SHOULD be fully qualified whenever possible.
+
+ Internet domain names are only loosely specified. Section
+ 3.5 of RFC 1034 recommends a syntax (modified in Section
+ 2.1 of RFC 1123). The pattern above is intended to allow
+ for current practice in domain name use, and some possible
+ future expansion. It is designed to hold various types of
+ domain names, including names used for A or AAAA records
+ (host names) and other records, such as SRV records. Note
+ that Internet host names have a stricter syntax (described
+ in RFC 952) than the DNS recommendations in RFCs 1034 and
+ 1123, and that systems that want to store host names in
+ schema nodes using the domain-name type are recommended to
+ adhere to this stricter standard to ensure interoperability.
+
+ The encoding of DNS names in the DNS protocol is limited
+ to 255 characters. Since the encoding consists of labels
+ prefixed by a length bytes and there is a trailing NULL
+ byte, only 253 characters can appear in the textual dotted
+ notation.
+
+ The description clause of schema nodes using the domain-name
+ type MUST describe when and how these names are resolved to
+ IP addresses. Note that the resolution of a domain-name value
+ may require to query multiple DNS records (e.g., A for IPv4
+ and AAAA for IPv6). The order of the resolution process and
+ which DNS record takes precedence can either be defined
+ explicitly or may depend on the configuration of the
+ resolver.
+
+ Domain-name values use the US-ASCII encoding. Their canonical
+ format uses lowercase US-ASCII characters. Internationalized
+ domain names MUST be A-labels as per RFC 5890.";
+ reference
+ "RFC 952: DoD Internet Host Table Specification
+ RFC 1034: Domain Names - Concepts and Facilities
+ RFC 1123: Requirements for Internet Hosts -- Application
+ and Support
+ RFC 2782: A DNS RR for specifying the location of services
+ (DNS SRV)
+ RFC 5890: Internationalized Domain Names in Applications
+ (IDNA): Definitions and Document Framework";
+
+ }
+
+ typedef host {
+ type union {
+ type ip-address;
+ type domain-name;
+ }
+ description
+ "The host type represents either an IP address or a DNS
+ domain name.";
+ }
+
+ typedef uri {
+ type string;
+ description
+ "The uri type represents a Uniform Resource Identifier
+ (URI) as defined by STD 66.
+
+ Objects using the uri type MUST be in US-ASCII encoding,
+ and MUST be normalized as described by RFC 3986 Sections
+ 6.2.1, 6.2.2.1, and 6.2.2.2. All unnecessary
+ percent-encoding is removed, and all case-insensitive
+ characters are set to lowercase except for hexadecimal
+ digits, which are normalized to uppercase as described in
+ Section 6.2.2.1.
+
+ The purpose of this normalization is to help provide
+ unique URIs. Note that this normalization is not
+ sufficient to provide uniqueness. Two URIs that are
+ textually distinct after this normalization may still be
+ equivalent.
+
+ Objects using the uri type may restrict the schemes that
+ they permit. For example, 'data:' and 'urn:' schemes
+ might not be appropriate.
+
+ A zero-length URI is not a valid URI. This can be used to
+ express 'URI absent' where required.
+
+ In the value set and its semantics, this type is equivalent
+ to the Uri SMIv2 textual convention defined in RFC 5017.";
+ reference
+ "RFC 3986: Uniform Resource Identifier (URI): Generic Syntax
+ RFC 3305: Report from the Joint W3C/IETF URI Planning Interest
+ Group: Uniform Resource Identifiers (URIs), URLs,
+ and Uniform Resource Names (URNs): Clarifications
+ and Recommendations
+ RFC 5017: MIB Textual Conventions for Uniform Resource
+ Identifiers (URIs)";
+
+ }
+ } // module ietf-inet-types
diff --git a/compiler/plugin/maven/src/test/resources/ietfyang/l3vpnservice/ietf-sd-onos-common-types.yang b/compiler/plugin/maven/src/test/resources/ietfyang/l3vpnservice/ietf-sd-onos-common-types.yang
new file mode 100644
index 0000000..7cde2ec
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/ietfyang/l3vpnservice/ietf-sd-onos-common-types.yang
@@ -0,0 +1,141 @@
+ module ietf-sd-onos-common-types {
+ namespace "urn:ietf:params:xml:ns:yang:ietf-sd-onos-common-types";
+ prefix types ;
+ /*
+ import ietf-inet-types{
+ prefix inet;
+ }
+ import ietf-yang-types {
+ prefix yang-types;
+ }
+ */
+ organization "";
+ contact "";
+
+ description
+ "Defines common basic types of L3VPN.";
+
+ revision "2015-12-16" {
+ reference "";
+ }
+
+ typedef admin-status {
+ type enumeration {
+ enum admin-up {
+ value 0 ;
+ description "admin up, the operate-status is depend on the real
+ running status ." ;
+ }
+ enum admin-down {
+ value 1 ;
+ description "admin down,the operate-status is forced to down no
+ matter what the real status is" ;
+ }
+ enum config-up {
+ value 2 ;
+ description "the operate-status is forced to up no matter what
+ the real status is." ;
+ }
+ }
+ default admin-up;
+ description
+ "The administration status of the service.";
+ }
+
+ typedef notification-status {
+ type enumeration {
+ enum up {
+ value 0 ;
+ description "up." ;
+ }
+ enum down {
+ value 1 ;
+ description "down." ;
+ }
+ }
+ default up;
+ description
+ "The notification status of the service.";
+ }
+
+ typedef notification-type {
+ type enumeration {
+ enum ne{
+ value 0 ;
+ description "ncd change." ;
+ }
+ enum link{
+ value 1 ;
+ description "link change." ;
+ }
+ enum ltp{
+ value 2 ;
+ description "ltp change." ;
+ }
+ }
+ default ltp;
+ description
+ "The notification-type of the service.";
+ }
+
+ typedef operate-status {
+ type enumeration {
+ enum operate-up {
+ value 0 ;
+ description "operate up." ;
+ }
+ enum operate-down {
+ value 1 ;
+ description "operate down." ;
+ }
+ }
+ default operate-up;
+ description
+ "The operation status of the service.";
+ }
+
+ grouping command-result {
+ description
+ "Reusable container of the result of the command.";
+ container command-result {
+ description
+ "The result of the command.";
+ leaf result {
+ type int8;
+ description
+ "1 : success, 2 : failed, 3 : partly failed" ;
+ }
+ container success-resources {
+ description
+ "The resources those are available." ;
+ list success-resource-list {
+ description
+ "The resource list shows those are available." ;
+ leaf resource-id {
+ type string;
+ description
+ "The available resource id." ;
+ }
+ }
+ }
+ container failed-resources {
+ description
+ "The resources those are failed." ;
+ list failed-resource-list {
+ description
+ "The resources list shows those are failed." ;
+ leaf resource-id {
+ type string;
+ description
+ "The failed resources ids." ;
+ }
+ leaf error-code {
+ type string;
+ description
+ "The error code." ;
+ }
+ }
+ }
+ }
+ }
+ }
diff --git a/compiler/plugin/maven/src/test/resources/ietfyang/l3vpnservice/ietf-sd-onos-service-l3vpn.yang b/compiler/plugin/maven/src/test/resources/ietfyang/l3vpnservice/ietf-sd-onos-service-l3vpn.yang
new file mode 100644
index 0000000..7b55f71
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/ietfyang/l3vpnservice/ietf-sd-onos-service-l3vpn.yang
@@ -0,0 +1,316 @@
+ module ietf-sd-onos-service-l3vpn {
+ namespace "urn:ietf:params:xml:ns:yang:ietf-sd-onos-service-l3vpn";
+ prefix l3vpn ;
+ /*
+ import ietf-inet-types{
+ prefix inet;
+ }
+ import ietf-yang-types {
+ prefix yang-types;
+ }
+ */
+ import ietf-sd-onos-service-types {
+ prefix service-types;
+ }
+ import ietf-sd-onos-common-types {
+ prefix types;
+ }
+ organization "";
+ contact "";
+
+ description
+ "L3vpn configuration model in ONOS.";
+
+ revision "2015-12-16" {
+ reference "";
+ }
+
+ grouping l3vpn {
+ description
+ "The configuration module of l3 vpn.";
+ leaf name {
+ type string ;
+ mandatory true;
+ description "name of snc eline." ;
+ }
+ leaf id {
+ type uint32 ;
+ mandatory true;
+ description "ID of snc eline." ;
+ }
+ leaf user-label {
+ type string ;
+ description "user label of snc eline." ;
+ }
+ leaf parent-ncd-id {
+ type string ;
+ description "parent ncd id." ;
+ }
+
+ leaf admin-status {
+ type types:admin-status;
+ description "administration status." ;
+ }
+ leaf operate-status {
+ type types:operate-status;
+ description "operation status." ;
+ }
+
+ uses service-type-grouping;
+ container acess-information {
+ description "access information of the l3 vpn." ;
+
+ uses service-types:l3-ac; }
+
+ container protect-policy{
+ description "L3VPN Service protect policy." ;
+ uses service-types:protect-policy;
+ }
+ container tunnel-service {
+ description "tunnel service." ;
+ uses service-types:tunnel-service;
+ }
+
+ }
+
+ grouping service-type-grouping {
+ description "Basic service type" ;
+ leaf service-topology {
+ type enumeration {
+ enum full-mesh {
+ value 1 ;
+ description "full-mesh." ;
+ }
+ enum hub-spoke {
+ value 2 ;
+ description "hub-spoke." ;
+ }
+ }
+ default full-mesh;
+ description "service topology type." ;
+ }
+ }
+
+ container service {
+ description
+ "Root level of L3vpn service module.";
+ container l3vpn-cfg {
+ description
+ "L3vpn configuration model in ONOS.";
+ list vpn-cfg {
+ key name;
+ description
+ "vpn configuration parameter list.";
+ uses l3vpn;
+ }
+ }
+ container service-paths {
+ description
+ "The service path of the l3 vpn.";
+ }
+ }
+
+
+
+ rpc create-l3vpn-instance {
+ description "Create l3vpn instance." ;
+ input {
+ container l3vpn-instance {
+ description "Create l3vpn instance." ;
+ uses l3vpn;
+ }
+ }
+ }
+
+ rpc delete-l3vpn-instance {
+ description "Delete l3vpn instance." ;
+ input {
+ leaf l3vpn-id {
+ type string;
+ description "vpn id." ;
+ }
+ }
+ }
+
+ rpc close-l3vpn {
+ description "Close l3vpn." ;
+ input {
+ leaf l3vpn-id {
+ type string;
+ description "vpn id." ;
+ }
+ container ac-status {
+ description "Access status of the vpn." ;
+ list acs{
+ key "id";
+ description "Access information." ;
+ leaf id {
+ type string;
+ description "Access id." ;
+ }
+ leaf admin-status {
+ type types:admin-status;
+ description "Administration status." ;
+ }
+ }
+ }
+ }
+ }
+
+ rpc modify-l3vpn-instance-basic {
+ description "Modify l3vpn instance basic information." ;
+ input {
+ leaf l3vpn-id {
+ type string;
+ description "vpn id." ;
+ }
+ leaf user-label {
+ type string ;
+ description "user label." ;
+ }
+ }
+ }
+
+ rpc modify-l3vpn-instance-ac-qos {
+ description "Modify l3vpn instance ac qos information." ;
+ input {
+ leaf l3vpn-id {
+ type string;
+ description "L3vpn ID." ;
+ }
+ container ac-qos {
+ description "ac qos information." ;
+ list acs{
+ key "id";
+ description "acs list." ;
+ leaf id {
+ type string;
+ description "acs ID." ;
+ }
+ container qos-policy {
+ description "qos policy." ;
+ container qos-if-cars {
+ description "cars qos policy." ;
+ uses service-types:qos-if-car;
+
+ }
+ }
+ }
+ }
+ }
+ }
+ rpc modify-l3vpn-instance-connection {
+ description "Modify a l3vpn connection." ;
+ input {
+ leaf l3vpn-id {
+ type string;
+ description "L3vpn ID." ;
+ }
+ container ac-connection {
+ description "ac connection." ;
+ list acs{
+ key "id";
+ description "acs ID." ;
+ leaf id {
+ type string ;
+ description "acs ID." ;
+ }
+ container connection {
+ description "CE to PE connection." ;
+ uses service-types:connection;
+ }
+ }
+ }
+ }
+ }
+ rpc inquire-l3vpn-instance-work-path {
+ description "Inquire a L3VPN instance work path." ;
+ input {
+ leaf service-id {
+ type string;
+ description "service ID." ;
+ }
+ leaf ingress-ne-id {
+ type string ;
+ description "ingress network element ID." ;
+ }
+ leaf destination-ne-id {
+ type string ;
+ description "destination network element ID." ;
+ }
+ leaf ingress-ac-id {
+ type string ;
+ description "ingress ac ID." ;
+ }
+ leaf destination-ac-id {
+ type string ;
+ description "destination ac ID." ;
+ }
+ leaf path-layer {
+ type string ;
+ description "path layer." ;
+ }
+ leaf path-role {
+ type string ;
+ description "path role." ;
+ }
+ }
+ output {
+ container service-path {
+ description "service path." ;
+ leaf service-id {
+ type string;
+ description "service ID." ;
+ }
+ leaf ingress-ne-id {
+ type string ;
+ description "ingress network element ID." ;
+ }
+ leaf destination-ne-id {
+ type string ;
+ description "destination network element ID." ;
+ }
+ leaf ingress-ac-id {
+ type string ;
+ description "ingress access circuit ID." ;
+ }
+ leaf destination-ac-id {
+ type string ;
+ description "destination access circuit ID." ;
+ }
+ leaf path-layer {
+ type string ;
+ description "path layer." ;
+ }
+ leaf path-role {
+ type string ;
+ description "path role." ;
+ }
+ list path-list {
+ key "ne-id";
+ description "path list." ;
+ leaf ne-id {
+ type string;
+ description "network element ID." ;
+ }
+ leaf ingress-ltp-id {
+ type string;
+ description "LTP ID." ;
+ }
+ leaf backward-peer-id {
+ type string;
+ description "backward peer ID." ;
+ }
+ leaf egress-ltp-id {
+ type string;
+ description "egress ltp ID." ;
+ }
+ leaf forward-peer-id {
+ type string;
+ description "forward peer ID." ;
+ }
+ }
+ }
+ }
+ }
+ }
diff --git a/compiler/plugin/maven/src/test/resources/ietfyang/l3vpnservice/ietf-sd-onos-service-types.yang b/compiler/plugin/maven/src/test/resources/ietfyang/l3vpnservice/ietf-sd-onos-service-types.yang
new file mode 100644
index 0000000..7fd7700
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/ietfyang/l3vpnservice/ietf-sd-onos-service-types.yang
@@ -0,0 +1,816 @@
+ module ietf-sd-onos-service-types {
+ namespace "urn:ietf:params:xml:ns:yang:ietf-sd-onos-service-types";
+ prefix service-types ;
+
+ import ietf-inet-types {prefix inet; }
+ import ietf-sd-onos-common-types {prefix types;}
+
+ organization "";
+ contact "";
+
+ description
+ "Defines basic service types for L3VPN service.";
+
+ revision "2015-12-16" {
+ reference "";
+ }
+
+ typedef exp {
+ type enumeration {
+ enum BE {
+ value 0 ;
+ description "BE." ;
+ }
+ enum AF1 {
+ value 1 ;
+ description "AF1." ;
+ }
+ enum AF2 {
+ value 2 ;
+ description "AF2." ;
+ }
+ enum AF3 {
+ value 3 ;
+ description "AF3." ;
+ }
+ enum AF4 {
+ value 4 ;
+ description "AF4." ;
+ }
+ enum EF {
+ value 5 ;
+ description "EF." ;
+ }
+ enum CS6 {
+ value 6 ;
+ description "CS6." ;
+ }
+ enum CS7 {
+ value 7 ;
+ description "CS7." ;
+ }
+ }
+ default CS7;
+ description
+ "exp parameter.";
+ }
+
+ typedef pw-role{
+ type enumeration {
+ enum normal{
+ value 0 ;
+ description "normal." ;
+ }
+ enum master {
+ value 1 ;
+ description "master." ;
+ }
+ enum slave {
+ value 2 ;
+ description "slave." ;
+ }
+ enum DNI-PW {
+ value 3 ;
+ description "DNI PW." ;
+ }
+ }
+ default normal;
+ description
+ "The role of the PW.";
+ }
+
+ grouping qos-if-car {
+ description "qos parameter." ;
+ list qos-if-car {
+ key "direction";
+ description "cars qos policy." ;
+ leaf direction {
+ type enumeration {
+ enum inbound{
+ value 0 ;
+ description "inbound." ;
+ }
+ enum outbound {
+ value 1 ;
+ description "outbound." ;
+ }
+ }
+ description "qos for interface car" ;
+ }
+
+ leaf cir {
+ type int32;
+ description "forward CIR. unit:Kbps" ;
+ }
+ leaf pir {
+ type int32;
+ description "forward PIR. unit:Kbps" ;
+ }
+ leaf cbs {
+ type int32;
+ description "forward CBS. unit:Kbps" ;
+ }
+ leaf pbs {
+ type int32;
+ description "forward PBS. unit:Kbps" ;
+ }
+ }
+ }
+
+ grouping protect-policy {
+ description "The protect policy of the VPN" ;
+ leaf protect-type {
+ type enumeration {
+ enum unprotected {
+ value 0 ;
+ description "unprotected." ;
+ }
+ enum protected {
+ value 1 ;
+ description "protection." ;
+ }
+ }
+ default unprotected ;
+ description "protection type" ;
+ }
+
+ leaf revertive-type {
+ type enumeration {
+ enum no-revertive {
+ value 0 ;
+ description "unprotected." ;
+ }
+ enum revertive {
+ value 1 ;
+ description "protection." ;
+ }
+ }
+ description "revertive mode" ;
+ }
+ leaf wtr {
+ type uint32;
+ default 300;
+ description "WTR.unit:s" ;
+ }
+ }
+ grouping oam-policy {
+ description "The oam policy of the vpn service." ;
+ leaf detect-type {
+ type enumeration {
+ enum undetect {
+ value 0 ;
+ description "unprotected." ;
+ }
+ enum APS {
+ value 1 ;
+ description "protection." ;
+ }
+ enum BFD {
+ value 2 ;
+ description "unprotected." ;
+ }
+ }
+ description "detect type" ;
+ }
+ container bfd-detect-para {
+ description "bfd detect parameters." ;
+ leaf ingress-discriminator {
+ type int32;
+ description "ingress-discriminator" ;
+ }
+ leaf egress-discriminator {
+ type int32;
+ description "egress-discriminator" ;
+ }
+ leaf tx-interval {
+ type int32;
+ description "tx-interval" ;
+ }
+ leaf rx-interval {
+ type int32;
+ description "rx-interval" ;
+ }
+ leaf detect-interval {
+ type int32;
+ description "detect-interval" ;
+ }
+ }
+ }
+ grouping ac {
+ description "Access information." ;
+ leaf id{
+ type string;
+ mandatory true;
+ description "ac id." ;
+ }
+ leaf name{
+ type string;
+ config false;
+ description "ac name." ;
+ }
+
+ leaf ne-id {
+ type string ;
+ mandatory true;
+ description "ne id." ;
+ }
+
+ leaf ltp-id {
+ type string ;
+ mandatory true;
+ description "ltp id." ;
+ }
+ leaf admin-status {
+ type types:admin-status;
+ description "Administration status." ;
+ }
+ leaf operate-status {
+ type types:operate-status;
+ description "Operation status." ;
+ }
+ container l2-access {
+ description "link layer access information of ac." ;
+ uses l2-access;
+ }
+
+ leaf role {
+ type enumeration {
+ enum master {
+ value 0 ;
+ description "master." ;
+ }
+ enum slave {
+ value 1 ;
+ description "slave." ;
+ }
+ enum hub {
+ value 2 ;
+ description "slave." ;
+ }
+ enum spoke {
+ value 3 ;
+ description "slave." ;
+ }
+ }
+ default master;
+ description "role of snc lsp." ;
+ }
+ container qos-policy {
+ description "The qos policy of the vpn service." ;
+ container qos-if-cars {
+ description "qos policy if car." ;
+ list qos-if-car {
+ //key "direction";
+ uses qos-if-car;
+ description "List of qos parameters." ;
+ }
+ }
+ }
+ }
+ grouping l3-ac {
+ description "Access information of l3vpn." ;
+ list access-circuit {
+ key "id";
+ description "list of access circuit." ;
+ uses ac;
+ container connection {
+ description "connection information of ac." ;
+ uses connection;
+ }
+ }
+ }
+ grouping l2-access {
+ description "Access information of l2vpn." ;
+ leaf access-type{
+ type enumeration {
+ enum Port {
+ value 0 ;
+ description "master." ;
+ }
+ enum Dot1Q {
+ value 1 ;
+ description "slave." ;
+ }
+ enum QinQ {
+ value 2 ;
+ description "master." ;
+ }
+ }
+ mandatory true;
+ description "The access type of the vpn service." ;
+ }
+ leaf dot1q-vlan-bitmap {
+ type string;
+ mandatory true;
+ description "Dot1Q Vlan Bitmap." ;
+ }
+
+ leaf qinq-svlan-bitmap {
+ type string;
+ mandatory true;
+ description "QinQ svlan Bitmap." ;
+ }
+
+ leaf qinq-cvlan-bitmap {
+ type string;
+ mandatory true;
+ description "QinQ cvlan Bitmap." ;
+ }
+ leaf access-action {
+ type enumeration {
+ enum Keep {
+ value 0 ;
+ description "keep." ;
+ }
+ enum Push {
+ value 1 ;
+ description "push." ;
+ }
+ enum Pop {
+ value 2 ;
+ description "pop." ;
+ }
+ enum Swap {
+ value 3 ;
+ description "swap." ;
+ }
+ }
+ mandatory true;
+ description "access type." ;
+ }
+
+ leaf action-vlan-id {
+ type int32 {
+ range "1..4094";
+ }
+ description "action vlan id." ;
+ }
+ }
+ grouping connection {
+ description "Describe the connection of the vpn service." ;
+ leaf ip-address {
+ type inet:ip-address ;
+ description "ip address of access circuit's connection." ;
+ }
+ leaf mask-length {
+ type int32 {
+ range "1..32";
+ }
+ description "mask length of ip address." ;
+ }
+ leaf protocols {
+ type enumeration {
+ enum static {
+ value 0 ;
+ description "static." ;
+ }
+ enum ospf {
+ value 1 ;
+ description "ospf." ;
+ }
+ enum isis {
+ value 2 ;
+ description "bgp" ;
+ }
+ enum bgp {
+ value 3 ;
+ description "bgp" ;
+ }
+ }
+ description "protocols between PE and CE." ;
+ }
+ container static-routes {
+ description "Defines the static routes." ;
+ list static-route {
+ key "ip-prefix mask-length";
+ description "List of static route." ;
+ leaf ip-prefix {
+ type inet:ipv4-address;
+ description "ip prefix" ;
+ }
+ leaf mask-length {
+ type uint32 {
+ range "1..32";
+ }
+ description "mast length" ;
+ }
+ leaf next-hop {
+ type inet:ipv4-address ;
+ description "next hop" ;
+ }
+ leaf preference {
+ type uint32 {
+ range "1..65535";
+ }
+ description "preference of the route." ;
+ }
+ }
+ }
+ }
+
+ grouping pw{
+ description "PW definition ";
+ leaf id {
+ type string ;
+ description "ID of pw." ;
+ }
+ uses encaplate-type-grouping;
+
+ leaf ingress-ne-id {
+ type string ;
+ description "ingress ne id." ;
+ }
+
+ leaf egress-ne-id {
+ type string ;
+ description "egress ne id." ;
+ }
+
+ leaf ctrl-word-support {
+ type enumeration {
+ enum not-support {
+ value 0 ;
+ description "pw doesn't support control word" ;
+ }
+ enum support {
+ value 1 ;
+ description "pw supports control word" ;
+ }
+ }
+ default support;
+ description "ctrl word support. 0 : not support, 1 : support" ;
+ }
+
+ leaf sn-support {
+ type enumeration {
+ enum not-support {
+ value 0 ;
+ description "pw doesn't support control word" ;
+ }
+ enum support {
+ value 1 ;
+ description "pw supports control word" ;
+ }
+ }
+ default not-support;
+ description "serial number support. 0 : not support, 1 : support" ;
+ }
+
+ leaf vccv-type {
+ type enumeration {
+ enum not-support {
+ value 0 ;
+ description "pw doesn't support vccv" ;
+ }
+ enum CWD {
+ value 1 ;
+ description "pw supports vccv" ;
+ }
+ enum Label-alert {
+ value 2 ;
+ description "pw supports vccv" ;
+ }
+ enum TTL {
+ value 3 ;
+ description "pw supports vccv" ;
+ }
+ enum CWD&Label-alert {
+ value 4 ;
+ description "pw supports vccv" ;
+ }
+ enum CWD&TTL {
+ value 5 ;
+ description "pw supports vccv" ;
+ }
+ enum Label-alert&TTL {
+ value 6 ;
+ description "pw supports vccv" ;
+ }
+ enum CWD&Label-alert&TTL {
+ value 7 ;
+ description "pw supports vccv" ;
+ }
+ }
+ default not-support;
+ description "vccv type" ;
+ }
+
+ leaf conn-ack-type {
+ type enumeration {
+ enum not-support {
+ value 0 ;
+ description "pw doesn't support connection ack" ;
+ }
+ enum support {
+ value 1 ;
+ description "pw supports connection ack" ;
+ }
+ }
+ default not-support;
+ description "Connectivity test type" ;
+ }
+ container tunnels {
+ description "Define tunnels." ;
+ list tunnel{
+ key "tunnel-id";
+ description "The list of tunnel id." ;
+ uses tunnel;
+ }
+ }
+ }
+ grouping tunnel {
+ description "Reusable entity of tunnel." ;
+ leaf tunnel-id {
+ type string ;
+ description "ID of tunnel." ;
+ }
+ }
+ grouping encaplate-type-grouping {
+ description "encaplate type" ;
+ leaf encaplate-type {
+ type enumeration {
+ enum NONE {
+ value 0 ;
+ description "none." ;
+ }
+ enum fr-dlci-martini {
+ value 1 ;
+ description "fr-dlci-martini." ;
+ }
+ enum atm-aal5-sdu {
+ value 2 ;
+ description "atm-aal5-sdu." ;
+ }
+ enum atm-transparent {
+ value 3 ;
+ description "atm-transparent." ;
+ }
+ enum ethernet-vlan {
+ value 4 ;
+ description "ethernet-vlan." ;
+ }
+ enum ethernet {
+ value 5 ;
+ description "ethernet ." ;
+ }
+ enum hdlc {
+ value 6 ;
+ description " hdlc." ;
+ }
+ enum ppp {
+ value 7 ;
+ description "ppp." ;
+ }
+ enum cep-mpls {
+ value 8 ;
+ description " cep-mpls." ;
+ }
+ enum atm-ntol {
+ value 9 ;
+ description "atm-ntol." ;
+ }
+ enum atm-nto1-vpc {
+ value 10 ;
+ description "atm-nto1-vpc." ;
+ }
+ enum ip-layer2 {
+ value 11 ;
+ description " ip-layer2." ;
+ }
+ enum atm-1to1-vcc {
+ value 12 ;
+ description "atm-1to1-vcc." ;
+ }
+ enum atm-1to1-vpc {
+ value 13 ;
+ description "atm-1to1-vpc." ;
+ }
+ enum atm-aal5-pdu {
+ value 14 ;
+ description "atm-aal5-pdu." ;
+ }
+ enum fr-port {
+ value 15 ;
+ description "fr-port." ;
+ }
+ enum cep-packet {
+ value 16 ;
+ description "cep-packet." ;
+ }
+ enum e1 {
+ value 17 ;
+ description "e1." ;
+ }
+ enum t1 {
+ value 18 ;
+ description "t1." ;
+ }
+ enum e3 {
+ value 19 ;
+ description "e3." ;
+ }
+ enum t3 {
+ value 20 ;
+ description " t3." ;
+ }
+ enum cesopsn-basic {
+ value 21 ;
+ description "cesopsn-basic." ;
+ }
+ enum tdmoip-aal1 {
+ value 22 ;
+ description "tdmoip-aal1." ;
+ }
+ enum cesopsn-tdm {
+ value 23 ;
+ description "cesopsn-tdm." ;
+ }
+ enum tdmoip-aal2 {
+ value 24 ;
+ description "tdmoip-aal2." ;
+ }
+ enum fr-dlci {
+ value 25 ;
+ description "fr-dlci." ;
+ }
+ }
+ description "encaplate type." ;
+ }
+ }
+
+ grouping pw-trail{
+ description "pw trail information." ;
+ leaf id {
+ type string ;
+ description "ID of pw-trail." ;
+ }
+
+ leaf role {
+ type pw-role;
+ description "role of pw-trail." ;
+ }
+ container pw-lists {
+ description "List of pw information." ;
+ list pw-list {
+ key id;
+ description "List of pw information." ;
+ uses pw ;
+ }
+ }
+ }
+ grouping tunnel-service {
+ description "Reusable entity of tunnel service." ;
+ leaf signaling-type {
+ type enumeration {
+ enum RSVP-TE {
+ value 0 ;
+ description "RSVP-TE" ;
+ }
+ enum LDP {
+ value 1 ;
+ description "LDP" ;
+ }
+ enum GRE {
+ value 2 ;
+ description "GRE" ;
+ }
+ enum SR-BE {
+ value 3 ;
+ description "SR-BE" ;
+ }
+ enum SR-TE {
+ value 4 ;
+ description "SR-TE" ;
+ }
+ }
+ default RSVP-TE;
+ description "signaling type." ;
+ }
+ leaf tunnel-mode {
+ type enumeration {
+ enum Nto1 {
+ value 0 ;
+ description "multi service one tunnel" ;
+ }
+ enum 1to1 {
+ value 1 ;
+ description "oner service one tunnel" ;
+ }
+ }
+ default Nto1;
+ description "service to tunnel mode." ;
+ }
+ container protect-policy {
+ description "Protect policy." ;
+ uses protect-policy;
+ }
+ container oam-policy {
+ description "oam policy." ;
+ uses oam-policy;
+ }
+ leaf latency {
+ type int32;
+ description "tunnel latency requirement." ;
+ }
+ }
+ grouping service-path {
+ description "Service path of l3vpn." ;
+ list service-path{
+ key "service-id source-ne-id source-ac-id destination-ne-id destination-ac-id";
+ description
+ "The list of service path.";
+ leaf service-id {
+ type string ;
+ description "l2vpn or l3vpn service id." ;
+ }
+ leaf source-ne-id {
+ type string ;
+ description "source ne id." ;
+ }
+
+ leaf source-ac-id {
+ type string ;
+ description "source ltp id." ;
+ }
+ leaf destination-ne-id {
+ type string ;
+ description "destination ne id." ;
+ }
+
+ leaf destination-ac-id {
+ type string ;
+ description "destination ltp id." ;
+ }
+ container path-lists{
+ description "The path list of service path." ;
+ list path-list {
+ key "path-layer path-role";
+ description "The path list of service path." ;
+ leaf path-layer {
+ type enumeration {
+ enum PW {
+ value 0 ;
+ description "pw path." ;
+ }
+ enum BGP-LSP {
+ value 1 ;
+ description "BGP-LSP Path." ;
+ }
+ enum LSP {
+ value 2 ;
+ description "LSP Path." ;
+ }
+ }
+ description "path type. 0 : PW, 1 : BGP-LSP, 2 : PW" ;
+ }
+ leaf path-role {
+ type enumeration {
+ enum Primary {
+ value 0 ;
+ description "master path." ;
+ }
+ enum Backup {
+ value 1 ;
+ description "backup path." ;
+ }
+ enum Active {
+ value 2 ;
+ description "active path." ;
+ }
+ }
+ description "path role.. 0 : master, 1 : backup, 2 :
+ Bypass." ;
+ }
+ container paths {
+ description "path definition." ;
+ list path {
+ key "ne-id";
+ description "Network element id list." ;
+ leaf ne-id {
+ type string;
+ description "Network element id." ;
+ }
+ leaf ingress-ltp-id {
+ type string;
+ description "ingress ltd id." ;
+ }
+ leaf backward-peer-id {
+ type string;
+ description "backward peer id." ;
+ }
+ leaf egress-ltp-id {
+ type string;
+ description "egress ltd id." ;
+ }
+ leaf forward-peer-id {
+ type string;
+ description "forward peer id." ;
+ }
+ }
+ }
+ }
+ }
+
+ }
+ }
+ }
diff --git a/compiler/plugin/maven/src/test/resources/interFileUsesInsideChildOfGrouping/ietf-network-topology.yang b/compiler/plugin/maven/src/test/resources/interFileUsesInsideChildOfGrouping/ietf-network-topology.yang
new file mode 100644
index 0000000..499c0f1
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/interFileUsesInsideChildOfGrouping/ietf-network-topology.yang
@@ -0,0 +1,37 @@
+module ietf-network-topology {
+ yang-version 1;
+ namespace "ietf-vidya-topology";
+ prefix lnk;
+
+ import ietf-network {
+ prefix nd;
+ }
+
+ revision 2015-12-08 {
+ description
+ "Initial revision.
+ NOTE TO RFC EDITOR: Please replace the following reference
+ to draft-ietf-i2rs-yang-network-topo-02 with
+ RFC number when published (i.e. RFC xxxx).";
+ reference
+ "draft-ietf-i2rs-yang-network-topo-02.";
+ }
+
+ augment "/nd:networks/nd:network" {
+ list link {
+ key "link-id";
+ container source {
+ leaf source-node {
+ type string;
+ mandatory true;
+ }
+ leaf source-tp {
+ type string;
+ }
+ }
+ leaf link-id {
+ type string;
+ }
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/interFileUsesInsideChildOfGrouping/ietf-network.yang b/compiler/plugin/maven/src/test/resources/interFileUsesInsideChildOfGrouping/ietf-network.yang
new file mode 100644
index 0000000..a78b231
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/interFileUsesInsideChildOfGrouping/ietf-network.yang
@@ -0,0 +1,30 @@
+module ietf-network {
+ yang-version 1;
+ namespace "ietf-network";
+ prefix nd;
+
+ revision 2015-12-08 {
+ description
+ "Initial revision.
+ NOTE TO RFC EDITOR: Please replace the following reference
+ to draft-ietf-i2rs-yang-network-topo-02 with
+ RFC number when published (i.e. RFC xxxx).";
+ reference
+ "draft-ietf-i2rs-yang-network-topo-02";
+ }
+
+ container networks {
+ list network {
+ key "network-id";
+ leaf network-id {
+ type string;
+ }
+ list node {
+ key "node-id";
+ leaf node-id {
+ type string;
+ }
+ }
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/interFileUsesInsideChildOfGrouping/ietf-te-topology.yang b/compiler/plugin/maven/src/test/resources/interFileUsesInsideChildOfGrouping/ietf-te-topology.yang
new file mode 100644
index 0000000..f92fccc
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/interFileUsesInsideChildOfGrouping/ietf-te-topology.yang
@@ -0,0 +1,65 @@
+module ietf-te-topology {
+ yang-version 1;
+ namespace "ietf-te-topology";
+ prefix "tet";
+
+ import ietf-te-types {
+ prefix "te-types";
+ }
+
+ import ietf-network {
+ prefix "nw";
+ }
+
+ import ietf-network-topology {
+ prefix "nt";
+ }
+
+ revision "2016-03-17" {
+ description "Initial revision";
+ reference "TBD";
+ }
+
+ grouping te-link-augment {
+ container te {
+ container config {
+ uses te-link-config;
+ } // config
+ } // te
+ } // te-link-augment
+
+ grouping te-link-config {
+ uses te-link-config-attributes;
+ } // te-link-config
+
+ grouping te-link-config-attributes {
+ container te-link-attributes {
+ container underlay {
+ uses te-link-underlay-attributes;
+ } // underlay
+ } // te-link-attributes
+ } // te-link-config-attributes
+
+ grouping te-link-underlay-attributes {
+ container underlay-primary-path {
+ list path-element {
+ key "path-element-id";
+ description
+ "A list of path elements describing the service path.";
+ leaf path-element-id {
+ type uint32;
+ description "To identify the element in a path.";
+ }
+ uses te-path-element;
+ }
+ } // underlay-primary-path
+ } // te-link-underlay-attributes
+
+ grouping te-path-element {
+ uses te-types:explicit-route-subobject;
+ } // te-path-element
+
+ augment "/nw:networks/nw:network/nt:link" {
+ uses te-link-augment;
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/interFileUsesInsideChildOfGrouping/ietf-te-types.yang b/compiler/plugin/maven/src/test/resources/interFileUsesInsideChildOfGrouping/ietf-te-types.yang
new file mode 100644
index 0000000..96ce986
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/interFileUsesInsideChildOfGrouping/ietf-te-types.yang
@@ -0,0 +1,19 @@
+module ietf-te-types {
+
+ namespace "ietf-te-types";
+ prefix "te-types";
+
+ revision 2016-03-20 {
+ description "Latest revision of TE generic types";
+ reference "RFC3209";
+ }
+ grouping explicit-route-subobject {
+ choice type {
+ case ipv4-address {
+ leaf v4-address {
+ type string;
+ }
+ }
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/interJarFileLinking/yangFiles/flowclassifier.yang b/compiler/plugin/maven/src/test/resources/interJarFileLinking/yangFiles/flowclassifier.yang
new file mode 100644
index 0000000..0fa3ba1
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/interJarFileLinking/yangFiles/flowclassifier.yang
@@ -0,0 +1,175 @@
+module flow-classifier {
+
+ yang-version 1;
+
+ namespace "sfc.flowclassifier";
+
+ prefix "flow-classifier";
+
+ import "port-pair" {
+ prefix "port-pair";
+ }
+
+ organization "ON-LAB";
+
+ description "This submodule defines for flow classifier.";
+
+ revision "2016-05-24" {
+ description "Initial revision.";
+ }
+
+ typedef flow-classifier-id {
+ type port-pair:uuid;
+ }
+
+ typedef IpPrefix {
+ type string;
+ }
+
+ typedef VirtualPortId {
+ type string;
+ }
+
+ grouping flow-classifier {
+ container flow-classifier {
+ leaf id {
+ type flow-classifier-id;
+ }
+
+ leaf tenant-id {
+ type port-pair:tenant-id;
+ }
+
+ leaf name {
+ type string;
+ }
+
+ leaf description {
+ type string;
+ }
+
+ leaf etherType {
+ type string;
+ }
+
+ leaf protocol {
+ type string;
+ }
+
+ leaf priority {
+ type int32;
+ }
+
+ leaf minSrcPortRange {
+ type int32;
+ }
+
+ leaf maxSrcPortRange {
+ type int32;
+ }
+
+ leaf minDstPortRange {
+ type int32;
+ }
+
+ leaf maxDstPortRange {
+ type int32;
+ }
+
+ leaf srcIpPrefix {
+ type IpPrefix;
+ }
+
+ leaf dstIpPrefix {
+ type IpPrefix;
+ }
+
+ leaf srcPort {
+ type VirtualPortId;
+ }
+
+ leaf dstPort {
+ type VirtualPortId;
+ }
+ }
+ }
+ rpc exists {
+ input {
+ leaf id {
+ type flow-classifier-id;
+ }
+ }
+ output {
+ leaf is-present {
+ type boolean;
+ }
+ }
+ }
+
+ rpc get-flow-classifier-count {
+
+ output {
+ leaf count {
+ type int32;
+ }
+ }
+ }
+
+ rpc get-flow-classifier {
+ input {
+ leaf id {
+ type flow-classifier-id;
+ }
+ }
+ output {
+ uses flow-classifier;
+ }
+ }
+
+ rpc create-flow-classifier {
+ input {
+ uses flow-classifier;
+ }
+ output {
+ leaf is-created {
+ type boolean;
+ }
+ }
+ }
+
+ rpc update-flow-classifier {
+ input {
+ uses flow-classifier;
+ }
+ output {
+ leaf is-updated {
+ type boolean;
+ }
+ }
+ }
+
+ rpc remove-flow-classifier {
+ input {
+ leaf id {
+ type flow-classifier-id;
+ }
+ }
+ output {
+ leaf is-removed {
+ type boolean;
+ }
+ }
+ }
+
+ notification Flow-Classifier-Put {
+ uses flow-classifier;
+ }
+
+ notification Flow-Classifier-Delete {
+ uses flow-classifier;
+ }
+
+ notification Flow-Classifier-Update {
+ uses flow-classifier;
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/interJarFileLinking/yangFiles/portpair.yang b/compiler/plugin/maven/src/test/resources/interJarFileLinking/yangFiles/portpair.yang
new file mode 100644
index 0000000..ee67c62
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/interJarFileLinking/yangFiles/portpair.yang
@@ -0,0 +1,137 @@
+module port-pair {
+
+ yang-version 1;
+
+ namespace "sfc.portpair";
+
+ prefix "port-pair";
+
+ organization "Huawei india pvt. ltd..";
+
+ description "This submodule defines for port pair.";
+
+ revision "2016-05-24" {
+ description "Initial revision.";
+ }
+
+ typedef uuid {
+ type string;
+ }
+
+ typedef port-pair-id {
+ type uuid;
+ }
+
+ typedef tenant-id {
+ type uuid;
+ }
+
+ grouping port-pair {
+ container port-pair {
+
+ leaf name {
+ type string;
+ }
+
+ leaf id {
+ type port-pair-id;
+ }
+
+ leaf tenantIdentifier {
+ type tenant-id;
+ }
+
+ leaf description {
+ type string;
+ }
+
+ leaf ingress {
+ type uuid;
+ }
+
+ leaf egress {
+ type uuid;
+ }
+ }
+ }
+ rpc exists {
+ input {
+ leaf id {
+ type port-pair-id;
+ }
+ }
+ output {
+ leaf is-present {
+ type boolean;
+ }
+ }
+ }
+
+ rpc get-port-pair-count {
+
+ output {
+ leaf count {
+ type int32;
+ }
+ }
+ }
+
+ rpc get-port-pair {
+ input {
+ leaf id {
+ type port-pair-id;
+ }
+ }
+ output {
+ uses port-pair;
+ }
+ }
+
+ rpc create-port-pair {
+ input {
+ uses port-pair;
+ }
+ output {
+ leaf is-created {
+ type boolean;
+ }
+ }
+ }
+
+ rpc update-port-pair {
+ input {
+ uses port-pair;
+ }
+ output {
+ leaf is-updated {
+ type boolean;
+ }
+ }
+ }
+
+ rpc remove-port-pair {
+ input {
+ leaf id {
+ type port-pair-id;
+ }
+ }
+ output {
+ leaf is-removed {
+ type boolean;
+ }
+ }
+ }
+
+
+ notification port-pair-put {
+ uses port-pair;
+ }
+
+ notification port-pair-Delete {
+ uses port-pair;
+ }
+
+ notification port-pair-Update {
+ uses port-pair;
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/interJarFileLinking/yangFiles/test.yang b/compiler/plugin/maven/src/test/resources/interJarFileLinking/yangFiles/test.yang
new file mode 100644
index 0000000..4e7275c
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/interJarFileLinking/yangFiles/test.yang
@@ -0,0 +1,29 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ container valid {
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+ }
+ container invalid {
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+ }
+ container valid2 {
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/interfilefeatureimport/featureFile1.yang b/compiler/plugin/maven/src/test/resources/interfilefeatureimport/featureFile1.yang
new file mode 100644
index 0000000..e78e583
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/interfilefeatureimport/featureFile1.yang
@@ -0,0 +1,26 @@
+module syslog1 {
+ yang-version 1;
+ namespace "http://huawei1.com";
+ prefix "sys1";
+
+ import "syslog2" {
+ prefix "sys2";
+ }
+
+ feature frr-te {
+ description "Indicates support for TE FastReroute (FRR)";
+ if-feature "sys2:p2mp-te";
+ }
+
+ container speed {
+ leaf local-storage-limit {
+ if-feature frr-te;
+ type uint64;
+ units "kilobyte";
+ config false;
+ description
+ "The amount of local storage that can be
+ used to hold syslog messages.";
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/interfilefeatureimport/featureFile2.yang b/compiler/plugin/maven/src/test/resources/interfilefeatureimport/featureFile2.yang
new file mode 100644
index 0000000..782571c
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/interfilefeatureimport/featureFile2.yang
@@ -0,0 +1,9 @@
+module syslog2 {
+ yang-version 1;
+ namespace "http://huawei2.com";
+ prefix "sys2";
+
+ feature p2mp-te {
+ description "Indicates support for P2MP-TE";
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/interfilefeatureimportdependency/featurefile1.yang b/compiler/plugin/maven/src/test/resources/interfilefeatureimportdependency/featurefile1.yang
new file mode 100644
index 0000000..e78e583
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/interfilefeatureimportdependency/featurefile1.yang
@@ -0,0 +1,26 @@
+module syslog1 {
+ yang-version 1;
+ namespace "http://huawei1.com";
+ prefix "sys1";
+
+ import "syslog2" {
+ prefix "sys2";
+ }
+
+ feature frr-te {
+ description "Indicates support for TE FastReroute (FRR)";
+ if-feature "sys2:p2mp-te";
+ }
+
+ container speed {
+ leaf local-storage-limit {
+ if-feature frr-te;
+ type uint64;
+ units "kilobyte";
+ config false;
+ description
+ "The amount of local storage that can be
+ used to hold syslog messages.";
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/interfilefeatureimportdependency/featurefile2.yang b/compiler/plugin/maven/src/test/resources/interfilefeatureimportdependency/featurefile2.yang
new file mode 100644
index 0000000..fcaf8e0
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/interfilefeatureimportdependency/featurefile2.yang
@@ -0,0 +1,14 @@
+module syslog2 {
+ yang-version 1;
+ namespace "http://huawei2.com";
+ prefix "sys2";
+
+ import "syslog3" {
+ prefix "sys3";
+ }
+
+ feature p2mp-te {
+ description "Indicates support for P2MP-TE";
+ if-feature "sys3:extended-admin-groups";
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/interfilefeatureimportdependency/featurefile3.yang b/compiler/plugin/maven/src/test/resources/interfilefeatureimportdependency/featurefile3.yang
new file mode 100644
index 0000000..13d6787
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/interfilefeatureimportdependency/featurefile3.yang
@@ -0,0 +1,11 @@
+module syslog3 {
+ yang-version 1;
+ namespace "http://huawei3.com";
+ prefix "sys3";
+
+ feature extended-admin-groups {
+ description
+ "Indicates support for TE link extended admin
+ groups.";
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/interfilefeatureimportdependencyUndefined/featurefile1.yang b/compiler/plugin/maven/src/test/resources/interfilefeatureimportdependencyUndefined/featurefile1.yang
new file mode 100644
index 0000000..e78e583
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/interfilefeatureimportdependencyUndefined/featurefile1.yang
@@ -0,0 +1,26 @@
+module syslog1 {
+ yang-version 1;
+ namespace "http://huawei1.com";
+ prefix "sys1";
+
+ import "syslog2" {
+ prefix "sys2";
+ }
+
+ feature frr-te {
+ description "Indicates support for TE FastReroute (FRR)";
+ if-feature "sys2:p2mp-te";
+ }
+
+ container speed {
+ leaf local-storage-limit {
+ if-feature frr-te;
+ type uint64;
+ units "kilobyte";
+ config false;
+ description
+ "The amount of local storage that can be
+ used to hold syslog messages.";
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/interfilefeatureimportdependencyUndefined/featurefile2.yang b/compiler/plugin/maven/src/test/resources/interfilefeatureimportdependencyUndefined/featurefile2.yang
new file mode 100644
index 0000000..199a6a6
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/interfilefeatureimportdependencyUndefined/featurefile2.yang
@@ -0,0 +1,15 @@
+module syslog2 {
+ yang-version 1;
+ namespace "http://huawei2.com";
+ prefix "sys2";
+
+ import "syslog3" {
+ prefix "sys3";
+ }
+
+ feature p2mp-te {
+ description "Indicates support for P2MP-TE";
+ if-feature "sys3:extended-admin-groups";
+ }
+}
+
diff --git a/compiler/plugin/maven/src/test/resources/interfilefeatureimportdependencyUndefined/featurefile3.yang b/compiler/plugin/maven/src/test/resources/interfilefeatureimportdependencyUndefined/featurefile3.yang
new file mode 100644
index 0000000..f638139
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/interfilefeatureimportdependencyUndefined/featurefile3.yang
@@ -0,0 +1,5 @@
+module syslog3 {
+ yang-version 1;
+ namespace "http://huawei3.com";
+ prefix "sys3";
+}
diff --git a/compiler/plugin/maven/src/test/resources/interfilefeatureinclude/featureFile3.yang b/compiler/plugin/maven/src/test/resources/interfilefeatureinclude/featureFile3.yang
new file mode 100644
index 0000000..b387853
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/interfilefeatureinclude/featureFile3.yang
@@ -0,0 +1,24 @@
+module syslog3 {
+ yang-version 1;
+ namespace "http://huawei3.com";
+ prefix "sys3";
+
+ include "syslog4";
+
+ feature frr-te {
+ description "Indicates support for TE FastReroute (FRR)";
+ if-feature "p2mp-te";
+ }
+
+ container speed {
+ leaf local-storage-limit {
+ if-feature frr-te;
+ type uint64;
+ units "kilobyte";
+ config false;
+ description
+ "The amount of local storage that can be
+ used to hold syslog messages.";
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/interfilefeatureinclude/featureFile4.yang b/compiler/plugin/maven/src/test/resources/interfilefeatureinclude/featureFile4.yang
new file mode 100644
index 0000000..30e1ce5
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/interfilefeatureinclude/featureFile4.yang
@@ -0,0 +1,10 @@
+submodule syslog4 {
+ yang-version 1;
+ belongs-to "syslog3" {
+ prefix "sys3";
+ }
+
+ feature p2mp-te {
+ description "Indicates support for P2MP-TE";
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/interfilefeatureincludedependency/featurefile1.yang b/compiler/plugin/maven/src/test/resources/interfilefeatureincludedependency/featurefile1.yang
new file mode 100644
index 0000000..a30c85a
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/interfilefeatureincludedependency/featurefile1.yang
@@ -0,0 +1,24 @@
+module syslog1 {
+ yang-version 1;
+ namespace "http://huawei3.com";
+ prefix "sys1";
+
+ include "syslog2";
+
+ feature frr-te {
+ description "Indicates support for TE FastReroute (FRR)";
+ if-feature "p2mp-te";
+ }
+
+ container speed {
+ leaf local-storage-limit {
+ if-feature frr-te;
+ type uint64;
+ units "kilobyte";
+ config false;
+ description
+ "The amount of local storage that can be
+ used to hold syslog messages.";
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/interfilefeatureincludedependency/featurefile2.yang b/compiler/plugin/maven/src/test/resources/interfilefeatureincludedependency/featurefile2.yang
new file mode 100644
index 0000000..370490a
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/interfilefeatureincludedependency/featurefile2.yang
@@ -0,0 +1,16 @@
+submodule syslog2 {
+ yang-version 1;
+ belongs-to "syslog1" {
+ prefix "sys1";
+ }
+
+ import "syslog3" {
+ prefix "sys3";
+ }
+
+ feature p2mp-te {
+ description "Indicates support for P2MP-TE";
+ if-feature "sys3:extended-admin-groups";
+ }
+}
+
diff --git a/compiler/plugin/maven/src/test/resources/interfilefeatureincludedependency/featurefile3.yang b/compiler/plugin/maven/src/test/resources/interfilefeatureincludedependency/featurefile3.yang
new file mode 100644
index 0000000..13d6787
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/interfilefeatureincludedependency/featurefile3.yang
@@ -0,0 +1,11 @@
+module syslog3 {
+ yang-version 1;
+ namespace "http://huawei3.com";
+ prefix "sys3";
+
+ feature extended-admin-groups {
+ description
+ "Indicates support for TE link extended admin
+ groups.";
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/interfilefeatureincludedependencyUndefined/featurefile1.yang b/compiler/plugin/maven/src/test/resources/interfilefeatureincludedependencyUndefined/featurefile1.yang
new file mode 100644
index 0000000..a30c85a
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/interfilefeatureincludedependencyUndefined/featurefile1.yang
@@ -0,0 +1,24 @@
+module syslog1 {
+ yang-version 1;
+ namespace "http://huawei3.com";
+ prefix "sys1";
+
+ include "syslog2";
+
+ feature frr-te {
+ description "Indicates support for TE FastReroute (FRR)";
+ if-feature "p2mp-te";
+ }
+
+ container speed {
+ leaf local-storage-limit {
+ if-feature frr-te;
+ type uint64;
+ units "kilobyte";
+ config false;
+ description
+ "The amount of local storage that can be
+ used to hold syslog messages.";
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/interfilefeatureincludedependencyUndefined/featurefile2.yang b/compiler/plugin/maven/src/test/resources/interfilefeatureincludedependencyUndefined/featurefile2.yang
new file mode 100644
index 0000000..370490a
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/interfilefeatureincludedependencyUndefined/featurefile2.yang
@@ -0,0 +1,16 @@
+submodule syslog2 {
+ yang-version 1;
+ belongs-to "syslog1" {
+ prefix "sys1";
+ }
+
+ import "syslog3" {
+ prefix "sys3";
+ }
+
+ feature p2mp-te {
+ description "Indicates support for P2MP-TE";
+ if-feature "sys3:extended-admin-groups";
+ }
+}
+
diff --git a/compiler/plugin/maven/src/test/resources/interfilefeatureincludedependencyUndefined/featurefile3.yang b/compiler/plugin/maven/src/test/resources/interfilefeatureincludedependencyUndefined/featurefile3.yang
new file mode 100644
index 0000000..f638139
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/interfilefeatureincludedependencyUndefined/featurefile3.yang
@@ -0,0 +1,5 @@
+module syslog3 {
+ yang-version 1;
+ namespace "http://huawei3.com";
+ prefix "sys3";
+}
diff --git a/compiler/plugin/maven/src/test/resources/interfileidentityimport/IdentityInModule.yang b/compiler/plugin/maven/src/test/resources/interfileidentityimport/IdentityInModule.yang
new file mode 100644
index 0000000..efaadd6
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/interfileidentityimport/IdentityInModule.yang
@@ -0,0 +1,15 @@
+
+module IdentityInModule{
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix IdentityInModule;
+
+ identity tunnel-type {
+ description
+ "Base identity from which specific tunnel types are derived.";
+ }
+
+ identity ref-address-family {
+ reference "http://www.iana.org/assignments/address-family-numbers/address-family-numbers.xhtml#address-family-numbers-2";
+ }
+}
\ No newline at end of file
diff --git a/compiler/plugin/maven/src/test/resources/interfileidentityimport/IdentityIntraFile.yang b/compiler/plugin/maven/src/test/resources/interfileidentityimport/IdentityIntraFile.yang
new file mode 100644
index 0000000..4036e97
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/interfileidentityimport/IdentityIntraFile.yang
@@ -0,0 +1,29 @@
+module IdentityIntraFile {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix IdentityIntraFile;
+
+ import "IdentityInModule" {
+ prefix "IdentityInModule";
+ }
+
+ identity ipv4-address-family {
+ base IdentityInModule:ref-address-family;
+ }
+
+ identity ipv6-address-family {
+ base IdentityInModule:ref-address-family;
+ }
+
+ leaf tunnel {
+ type identityref {
+ base IdentityInModule:ref-address-family;
+ }
+ }
+
+ leaf-list network-ref {
+ type identityref {
+ base IdentityInModule:ref-address-family;
+ }
+ }
+}
\ No newline at end of file
diff --git a/compiler/plugin/maven/src/test/resources/interfileidentityimportdependency/featurefile1.yang b/compiler/plugin/maven/src/test/resources/interfileidentityimportdependency/featurefile1.yang
new file mode 100644
index 0000000..b808b11
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/interfileidentityimportdependency/featurefile1.yang
@@ -0,0 +1,30 @@
+module syslog1 {
+ yang-version 1;
+ namespace "http://huawei1.com";
+ prefix "sys1";
+
+ import "syslog2" {
+ prefix "sys2";
+ }
+
+ identity ipv4-address-family {
+ base sys2:ref-address-family;
+ }
+
+ identity ipv6-address-family {
+ base sys2:ref-address-family;
+ }
+
+ leaf tunnel {
+ type identityref {
+ base sys2:ref-address-family;
+ }
+ }
+
+ leaf-list network-ref {
+ type identityref {
+ base sys2:ref-address-family;
+ }
+ }
+
+}
diff --git a/compiler/plugin/maven/src/test/resources/interfileidentityimportdependency/featurefile2.yang b/compiler/plugin/maven/src/test/resources/interfileidentityimportdependency/featurefile2.yang
new file mode 100644
index 0000000..2469e24
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/interfileidentityimportdependency/featurefile2.yang
@@ -0,0 +1,17 @@
+module syslog2 {
+ yang-version 1;
+ namespace "http://huawei2.com";
+ prefix "sys2";
+
+ import "syslog3" {
+ prefix "sys3";
+ }
+
+ identity tunnel-type {
+ base sys3:final-address-family;
+ }
+
+ identity ref-address-family {
+ base sys3:final-address-family;
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/interfileidentityimportdependency/featurefile3.yang b/compiler/plugin/maven/src/test/resources/interfileidentityimportdependency/featurefile3.yang
new file mode 100644
index 0000000..f460bd1
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/interfileidentityimportdependency/featurefile3.yang
@@ -0,0 +1,10 @@
+module syslog3 {
+ yang-version 1;
+ namespace "http://huawei3.com";
+ prefix "sys3";
+
+ identity final-address-family {
+ description
+ "Base identity from which specific tunnel types are derived.";
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/interfileidentityimportdependencyUndefined/featurefile1.yang b/compiler/plugin/maven/src/test/resources/interfileidentityimportdependencyUndefined/featurefile1.yang
new file mode 100644
index 0000000..ec2e48c
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/interfileidentityimportdependencyUndefined/featurefile1.yang
@@ -0,0 +1,29 @@
+module syslog1 {
+ yang-version 1;
+ namespace "http://huawei1.com";
+ prefix "sys1";
+
+ import "syslog2" {
+ prefix "sys2";
+ }
+
+ identity ipv4-address-family {
+ base sys2:ref-address-family;
+ }
+
+ identity ipv6-address-family {
+ base sys2:ref-address-family;
+ }
+
+ leaf tunnel {
+ type identityref {
+ base sys2:ref-address-family;
+ }
+ }
+
+ leaf-list network-ref {
+ type identityref {
+ base sys2:ref-address-family;
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/interfileidentityimportdependencyUndefined/featurefile2.yang b/compiler/plugin/maven/src/test/resources/interfileidentityimportdependencyUndefined/featurefile2.yang
new file mode 100644
index 0000000..25e66af
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/interfileidentityimportdependencyUndefined/featurefile2.yang
@@ -0,0 +1,18 @@
+module syslog2 {
+ yang-version 1;
+ namespace "http://huawei2.com";
+ prefix "sys2";
+
+ import "syslog3" {
+ prefix "sys3";
+ }
+
+ identity tunnel-type {
+ base sys3:final-address-family;
+ }
+
+ identity ref-address-family {
+ base sys3:final-address-family;
+ }
+}
+
diff --git a/compiler/plugin/maven/src/test/resources/interfileidentityimportdependencyUndefined/featurefile3.yang b/compiler/plugin/maven/src/test/resources/interfileidentityimportdependencyUndefined/featurefile3.yang
new file mode 100644
index 0000000..f638139
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/interfileidentityimportdependencyUndefined/featurefile3.yang
@@ -0,0 +1,5 @@
+module syslog3 {
+ yang-version 1;
+ namespace "http://huawei3.com";
+ prefix "sys3";
+}
diff --git a/compiler/plugin/maven/src/test/resources/interfileidentityincludedependency/featurefile1.yang b/compiler/plugin/maven/src/test/resources/interfileidentityincludedependency/featurefile1.yang
new file mode 100644
index 0000000..fe987ea
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/interfileidentityincludedependency/featurefile1.yang
@@ -0,0 +1,27 @@
+module syslog1 {
+ yang-version 1;
+ namespace "http://huawei3.com";
+ prefix "sys1";
+
+ include "syslog2";
+
+ identity ipv4-address-family {
+ base ref-address-family;
+ }
+
+ identity ipv6-address-family {
+ base ref-address-family;
+ }
+
+ leaf tunnel {
+ type identityref {
+ base ref-address-family;
+ }
+ }
+
+ leaf-list network-ref {
+ type identityref {
+ base ref-address-family;
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/interfileidentityincludedependency/featurefile2.yang b/compiler/plugin/maven/src/test/resources/interfileidentityincludedependency/featurefile2.yang
new file mode 100644
index 0000000..14fd83c
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/interfileidentityincludedependency/featurefile2.yang
@@ -0,0 +1,19 @@
+submodule syslog2 {
+ yang-version 1;
+ belongs-to "syslog1" {
+ prefix "sys1";
+ }
+
+ import "syslog3" {
+ prefix "sys3";
+ }
+
+ identity tunnel-type {
+ base sys3:final-address-family;
+ }
+
+ identity ref-address-family {
+ base sys3:final-address-family;
+ }
+}
+
diff --git a/compiler/plugin/maven/src/test/resources/interfileidentityincludedependency/featurefile3.yang b/compiler/plugin/maven/src/test/resources/interfileidentityincludedependency/featurefile3.yang
new file mode 100644
index 0000000..aa056f0
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/interfileidentityincludedependency/featurefile3.yang
@@ -0,0 +1,10 @@
+module syslog3 {
+ yang-version 1;
+ namespace "http://huawei3.com";
+ prefix "sys3";
+
+ identity final-address-family {
+ description
+ "Base identity from which specific tunnel types are derived.";
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/interfileidentityincludedependencyUndefined/featurefile1.yang b/compiler/plugin/maven/src/test/resources/interfileidentityincludedependencyUndefined/featurefile1.yang
new file mode 100644
index 0000000..bc4878f
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/interfileidentityincludedependencyUndefined/featurefile1.yang
@@ -0,0 +1,27 @@
+module syslog1 {
+ yang-version 1;
+ namespace "http://huawei3.com";
+ prefix "sys1";
+
+ include "syslog2";
+
+ identity ipv4-address-family {
+ base sys2:ref-address-family;
+ }
+
+ identity ipv6-address-family {
+ base sys2:ref-address-family;
+ }
+
+ leaf tunnel {
+ type identityref {
+ base sys2:ref-address-family;
+ }
+ }
+
+ leaf-list network-ref {
+ type identityref {
+ base sys2:ref-address-family;
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/interfileidentityincludedependencyUndefined/featurefile2.yang b/compiler/plugin/maven/src/test/resources/interfileidentityincludedependencyUndefined/featurefile2.yang
new file mode 100644
index 0000000..14fd83c
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/interfileidentityincludedependencyUndefined/featurefile2.yang
@@ -0,0 +1,19 @@
+submodule syslog2 {
+ yang-version 1;
+ belongs-to "syslog1" {
+ prefix "sys1";
+ }
+
+ import "syslog3" {
+ prefix "sys3";
+ }
+
+ identity tunnel-type {
+ base sys3:final-address-family;
+ }
+
+ identity ref-address-family {
+ base sys3:final-address-family;
+ }
+}
+
diff --git a/compiler/plugin/maven/src/test/resources/interfileidentityincludedependencyUndefined/featurefile3.yang b/compiler/plugin/maven/src/test/resources/interfileidentityincludedependencyUndefined/featurefile3.yang
new file mode 100644
index 0000000..f638139
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/interfileidentityincludedependencyUndefined/featurefile3.yang
@@ -0,0 +1,5 @@
+module syslog3 {
+ yang-version 1;
+ namespace "http://huawei3.com";
+ prefix "sys3";
+}
diff --git a/compiler/plugin/maven/src/test/resources/interfileidentityinlude/IdentityInModule.yang b/compiler/plugin/maven/src/test/resources/interfileidentityinlude/IdentityInModule.yang
new file mode 100644
index 0000000..e42ad86
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/interfileidentityinlude/IdentityInModule.yang
@@ -0,0 +1,27 @@
+module syslog3 {
+ yang-version 1;
+ namespace "http://huawei3.com";
+ prefix "sys3";
+
+ include "syslog4";
+
+ identity ipv4-address-family {
+ base ref-address-family;
+ }
+
+ identity ipv6-address-family {
+ base ref-address-family;
+ }
+
+ leaf tunnel {
+ type identityref {
+ base ref-address-family;
+ }
+ }
+
+ leaf-list network-ref {
+ type identityref {
+ base ref-address-family;
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/interfileidentityinlude/IdentityIntraFile.yang b/compiler/plugin/maven/src/test/resources/interfileidentityinlude/IdentityIntraFile.yang
new file mode 100644
index 0000000..ffa1a7d
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/interfileidentityinlude/IdentityIntraFile.yang
@@ -0,0 +1,15 @@
+submodule syslog4 {
+ yang-version 1;
+ belongs-to "syslog3" {
+ prefix "sys3";
+ }
+
+ identity tunnel-type {
+ description
+ "Base identity from which specific tunnel types are derived.";
+ }
+
+ identity ref-address-family {
+ reference "http://www.iana.org/assignments/address-family-numbers/address-family-numbers.xhtml#address-family-numbers-2";
+ }
+}
\ No newline at end of file
diff --git a/compiler/plugin/maven/src/test/resources/interfileidentitytypedef/IdentityInModule.yang b/compiler/plugin/maven/src/test/resources/interfileidentitytypedef/IdentityInModule.yang
new file mode 100644
index 0000000..5688615
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/interfileidentitytypedef/IdentityInModule.yang
@@ -0,0 +1,14 @@
+module IdentityInModule{
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix IdentityInModule;
+
+ identity tunnel-type {
+ description
+ "Base identity from which specific tunnel types are derived.";
+ }
+
+ identity ref-address-family {
+ reference "http://www.iana.org/assignments/address-family-numbers/address-family-numbers.xhtml#address-family-numbers-2";
+ }
+}
\ No newline at end of file
diff --git a/compiler/plugin/maven/src/test/resources/interfileidentitytypedef/IdentityIntraFile.yang b/compiler/plugin/maven/src/test/resources/interfileidentitytypedef/IdentityIntraFile.yang
new file mode 100644
index 0000000..fcb2984
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/interfileidentitytypedef/IdentityIntraFile.yang
@@ -0,0 +1,35 @@
+module IdentityIntraFile {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix IdentityIntraFile;
+
+ import "IdentityInModule" {
+ prefix "IdentityInModule";
+ }
+
+ identity ipv4-address-family {
+ base IdentityInModule:ref-address-family;
+ }
+
+ identity ipv6-address-family {
+ base IdentityInModule:ref-address-family;
+ }
+
+ leaf tunnel {
+ type identityref {
+ base IdentityInModule:ref-address-family;
+ }
+ }
+
+ leaf-list network-ref {
+ type identityref {
+ base IdentityInModule:ref-address-family;
+ }
+ }
+
+ typedef type15 {
+ type identityref {
+ base IdentityInModule:ref-address-family;
+ }
+ }
+}
\ No newline at end of file
diff --git a/compiler/plugin/maven/src/test/resources/interfileidentitytypedef/IdentityTypedef.yang b/compiler/plugin/maven/src/test/resources/interfileidentitytypedef/IdentityTypedef.yang
new file mode 100644
index 0000000..6a58976
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/interfileidentitytypedef/IdentityTypedef.yang
@@ -0,0 +1,31 @@
+module IdentityTypedef {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix IdentityTypedef;
+
+ import "IdentityInModule" {
+ prefix "IdentityInModule";
+ }
+
+ identity ipv4-address-family {
+ base IdentityInModule:ref-address-family;
+ }
+
+ identity ipv6-address-family {
+ base IdentityInModule:ref-address-family;
+ }
+
+ leaf tunnel {
+ type type15;
+ }
+
+ leaf-list network-ref {
+ type type15;
+ }
+
+ typedef type15 {
+ type identityref {
+ base IdentityInModule:ref-address-family;
+ }
+ }
+}
\ No newline at end of file
diff --git a/compiler/plugin/maven/src/test/resources/interfileietf/ietf-inet-types.yang b/compiler/plugin/maven/src/test/resources/interfileietf/ietf-inet-types.yang
new file mode 100644
index 0000000..2b7ed38
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/interfileietf/ietf-inet-types.yang
@@ -0,0 +1,454 @@
+ module ietf-inet-types {
+
+ yang-version 1;
+
+ namespace
+ "urn:ietf:params:xml:ns:yang:ietf-inet-types";
+
+ prefix inet;
+
+ organization
+ "IETF NETMOD (NETCONF Data Modeling Language) Working Group";
+
+ contact
+ "WG Web: <http://tools.ietf.org/wg/netmod/>
+ WG List: <mailto:netmod@ietf.org>
+
+ WG Chair: David Kessens
+ <mailto:david.kessens@nsn.com>
+
+ WG Chair: Juergen Schoenwaelder
+ <mailto:j.schoenwaelder@jacobs-university.de>
+
+ Editor: Juergen Schoenwaelder
+ <mailto:j.schoenwaelder@jacobs-university.de>";
+
+ description
+ "This module contains a collection of generally useful derived
+ YANG data types for Internet addresses and related things.
+
+ Copyright (c) 2013 IETF Trust and the persons identified as
+ authors of the code. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or
+ without modification, is permitted pursuant to, and subject
+ to the license terms contained in, the Simplified BSD License
+ set forth in Section 4.c of the IETF Trust's Legal Provisions
+ Relating to IETF Documents
+ (http://trustee.ietf.org/license-info).
+
+ This version of this YANG module is part of RFC 6991; see
+ the RFC itself for full legal notices.";
+
+ revision "2013-07-15" {
+ description
+ "This revision adds the following new data types:
+ - ip-address-no-zone
+ - ipv4-address-no-zone
+ - ipv6-address-no-zone";
+ reference
+ "RFC 6991: Common YANG Data Types";
+
+ }
+
+ revision "2010-09-24" {
+ description "Initial revision.";
+ reference
+ "RFC 6021: Common YANG Data Types";
+
+ }
+
+
+ typedef ip-version {
+ type enumeration {
+ enum "unknown" {
+ value 0;
+ description
+ "An unknown or unspecified version of the Internet
+ protocol.";
+ }
+ enum "ipv4" {
+ value 1;
+ description
+ "The IPv4 protocol as defined in RFC 791.";
+ }
+ enum "ipv6" {
+ value 2;
+ description
+ "The IPv6 protocol as defined in RFC 2460.";
+ }
+ }
+ description
+ "This value represents the version of the IP protocol.
+
+ In the value set and its semantics, this type is equivalent
+ to the InetVersion textual convention of the SMIv2.";
+ reference
+ "RFC 791: Internet Protocol
+ RFC 2460: Internet Protocol, Version 6 (IPv6) Specification
+ RFC 4001: Textual Conventions for Internet Network Addresses";
+
+ }
+
+ typedef dscp {
+ type uint8 {
+ range "0..63";
+ }
+ description
+ "The dscp type represents a Differentiated Services Code Point
+ that may be used for marking packets in a traffic stream.
+ In the value set and its semantics, this type is equivalent
+ to the Dscp textual convention of the SMIv2.";
+ reference
+ "RFC 3289: Management Information Base for the Differentiated
+ Services Architecture
+ RFC 2474: Definition of the Differentiated Services Field
+ (DS Field) in the IPv4 and IPv6 Headers
+ RFC 2780: IANA Allocation Guidelines For Values In
+ the Internet Protocol and Related Headers";
+
+ }
+
+ typedef ipv6-flow-label {
+ type uint32 {
+ range "0..1048575";
+ }
+ description
+ "The ipv6-flow-label type represents the flow identifier or Flow
+ Label in an IPv6 packet header that may be used to
+ discriminate traffic flows.
+
+ In the value set and its semantics, this type is equivalent
+ to the IPv6FlowLabel textual convention of the SMIv2.";
+ reference
+ "RFC 3595: Textual Conventions for IPv6 Flow Label
+ RFC 2460: Internet Protocol, Version 6 (IPv6) Specification";
+
+ }
+
+ typedef port-number {
+ type uint16 {
+ range "0..65535";
+ }
+ description
+ "The port-number type represents a 16-bit port number of an
+ Internet transport-layer protocol such as UDP, TCP, DCCP, or
+ SCTP. Port numbers are assigned by IANA. A current list of
+ all assignments is available from <http://www.iana.org/>.
+
+ Note that the port number value zero is reserved by IANA. In
+ situations where the value zero does not make sense, it can
+ be excluded by subtyping the port-number type.
+ In the value set and its semantics, this type is equivalent
+ to the InetPortNumber textual convention of the SMIv2.";
+ reference
+ "RFC 768: User Datagram Protocol
+ RFC 793: Transmission Control Protocol
+ RFC 4960: Stream Control Transmission Protocol
+ RFC 4340: Datagram Congestion Control Protocol (DCCP)
+ RFC 4001: Textual Conventions for Internet Network Addresses";
+
+ }
+
+ typedef as-number {
+ type uint32;
+ description
+ "The as-number type represents autonomous system numbers
+ which identify an Autonomous System (AS). An AS is a set
+ of routers under a single technical administration, using
+ an interior gateway protocol and common metrics to route
+ packets within the AS, and using an exterior gateway
+ protocol to route packets to other ASes. IANA maintains
+ the AS number space and has delegated large parts to the
+ regional registries.
+
+ Autonomous system numbers were originally limited to 16
+ bits. BGP extensions have enlarged the autonomous system
+ number space to 32 bits. This type therefore uses an uint32
+ base type without a range restriction in order to support
+ a larger autonomous system number space.
+
+ In the value set and its semantics, this type is equivalent
+ to the InetAutonomousSystemNumber textual convention of
+ the SMIv2.";
+ reference
+ "RFC 1930: Guidelines for creation, selection, and registration
+ of an Autonomous System (AS)
+ RFC 4271: A Border Gateway Protocol 4 (BGP-4)
+ RFC 4001: Textual Conventions for Internet Network Addresses
+ RFC 6793: BGP Support for Four-Octet Autonomous System (AS)
+ Number Space";
+
+ }
+
+ typedef ip-address {
+ type union {
+ type ipv4-address;
+ type ipv6-address;
+ }
+ description
+ "The ip-address type represents an IP address and is IP
+ version neutral. The format of the textual representation
+ implies the IP version. This type supports scoped addresses
+ by allowing zone identifiers in the address format.";
+ reference
+ "RFC 4007: IPv6 Scoped Address Architecture";
+
+ }
+
+ typedef ipv4-address {
+ type string {
+ pattern
+ '(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(%[\p{N}\p{L}]+)?';
+ }
+ description
+ "The ipv4-address type represents an IPv4 address in
+ dotted-quad notation. The IPv4 address may include a zone
+ index, separated by a % sign.
+
+ The zone index is used to disambiguate identical address
+ values. For link-local addresses, the zone index will
+ typically be the interface index number or the name of an
+ interface. If the zone index is not present, the default
+ zone of the device will be used.
+
+ The canonical format for the zone index is the numerical
+ format";
+ }
+
+ typedef ipv6-address {
+ type string {
+ pattern
+ '((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))(%[\p{N}\p{L}]+)?';
+ pattern
+ '(([^:]+:){6}(([^:]+:[^:]+)|(.*\..*)))|((([^:]+:)*[^:]+)?::(([^:]+:)*[^:]+)?)(%.+)?';
+ }
+ description
+ "The ipv6-address type represents an IPv6 address in full,
+ mixed, shortened, and shortened-mixed notation. The IPv6
+ address may include a zone index, separated by a % sign.
+
+ The zone index is used to disambiguate identical address
+ values. For link-local addresses, the zone index will
+ typically be the interface index number or the name of an
+ interface. If the zone index is not present, the default
+ zone of the device will be used.
+
+
+
+ The canonical format of IPv6 addresses uses the textual
+ representation defined in Section 4 of RFC 5952. The
+ canonical format for the zone index is the numerical
+ format as described in Section 11.2 of RFC 4007.";
+ reference
+ "RFC 4291: IP Version 6 Addressing Architecture
+ RFC 4007: IPv6 Scoped Address Architecture
+ RFC 5952: A Recommendation for IPv6 Address Text
+ Representation";
+
+ }
+
+ typedef ip-address-no-zone {
+ type union {
+ type ipv4-address-no-zone;
+ type ipv6-address-no-zone;
+ }
+ description
+ "The ip-address-no-zone type represents an IP address and is
+ IP version neutral. The format of the textual representation
+ implies the IP version. This type does not support scoped
+ addresses since it does not allow zone identifiers in the
+ address format.";
+ reference
+ "RFC 4007: IPv6 Scoped Address Architecture";
+
+ }
+
+ typedef ipv4-address-no-zone {
+ type ipv4-address {
+ pattern '[0-9\.]*';
+ }
+ description
+ "An IPv4 address without a zone index. This type, derived from
+ ipv4-address, may be used in situations where the zone is
+ known from the context and hence no zone index is needed.";
+ }
+
+ typedef ipv6-address-no-zone {
+ type ipv6-address {
+ pattern '[0-9a-fA-F:\.]*';
+ }
+ description
+ "An IPv6 address without a zone index. This type, derived from
+ ipv6-address, may be used in situations where the zone is
+ known from the context and hence no zone index is needed.";
+ reference
+ "RFC 4291: IP Version 6 Addressing Architecture
+ RFC 4007: IPv6 Scoped Address Architecture
+ RFC 5952: A Recommendation for IPv6 Address Text
+ Representation";
+
+ }
+
+ typedef ip-prefix {
+ type union {
+ type ipv4-prefix;
+ type ipv6-prefix;
+ }
+ description
+ "The ip-prefix type represents an IP prefix and is IP
+ version neutral. The format of the textual representations
+ implies the IP version.";
+ }
+
+ typedef ipv4-prefix {
+ type string {
+ pattern
+ '(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])/(([0-9])|([1-2][0-9])|(3[0-2]))';
+ }
+ description
+ "The ipv4-prefix type represents an IPv4 address prefix.
+ The prefix length is given by the number following the
+ slash character and must be less than or equal to 32.
+
+ A prefix length value of n corresponds to an IP address
+ mask that has n contiguous 1-bits from the most
+ significant bit (MSB) and all other bits set to 0.
+
+ The canonical format of an IPv4 prefix has all bits of
+ the IPv4 address set to zero that are not part of the
+ IPv4 prefix.";
+ }
+
+ typedef ipv6-prefix {
+ type string {
+ pattern
+ '((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))(/(([0-9])|([0-9]{2})|(1[0-1][0-9])|(12[0-8])))';
+ pattern
+ '(([^:]+:){6}(([^:]+:[^:]+)|(.*\..*)))|((([^:]+:)*[^:]+)?::(([^:]+:)*[^:]+)?)(/.+)';
+ }
+ description
+ "The ipv6-prefix type represents an IPv6 address prefix.
+ The prefix length is given by the number following the
+ slash character and must be less than or equal to 128.
+
+ A prefix length value of n corresponds to an IP address
+ mask that has n contiguous 1-bits from the most
+ significant bit (MSB) and all other bits set to 0.
+
+ The IPv6 address should have all bits that do not belong
+ to the prefix set to zero.
+
+ The canonical format of an IPv6 prefix has all bits of
+ the IPv6 address set to zero that are not part of the
+ IPv6 prefix. Furthermore, the IPv6 address is represented
+ as defined in Section 4 of RFC 5952.";
+ reference
+ "RFC 5952: A Recommendation for IPv6 Address Text
+ Representation";
+
+ }
+
+ typedef domain-name {
+ type string {
+ length "1..253";
+ pattern
+ '((([a-zA-Z0-9_]([a-zA-Z0-9\-_]){0,61})?[a-zA-Z0-9]\.)*([a-zA-Z0-9_]([a-zA-Z0-9\-_]){0,61})?[a-zA-Z0-9]\.?)|\.';
+ }
+ description
+ "The domain-name type represents a DNS domain name. The
+ name SHOULD be fully qualified whenever possible.
+
+ Internet domain names are only loosely specified. Section
+ 3.5 of RFC 1034 recommends a syntax (modified in Section
+ 2.1 of RFC 1123). The pattern above is intended to allow
+ for current practice in domain name use, and some possible
+ future expansion. It is designed to hold various types of
+ domain names, including names used for A or AAAA records
+ (host names) and other records, such as SRV records. Note
+ that Internet host names have a stricter syntax (described
+ in RFC 952) than the DNS recommendations in RFCs 1034 and
+ 1123, and that systems that want to store host names in
+ schema nodes using the domain-name type are recommended to
+ adhere to this stricter standard to ensure interoperability.
+
+ The encoding of DNS names in the DNS protocol is limited
+ to 255 characters. Since the encoding consists of labels
+ prefixed by a length bytes and there is a trailing NULL
+ byte, only 253 characters can appear in the textual dotted
+ notation.
+
+ The description clause of schema nodes using the domain-name
+ type MUST describe when and how these names are resolved to
+ IP addresses. Note that the resolution of a domain-name value
+ may require to query multiple DNS records (e.g., A for IPv4
+ and AAAA for IPv6). The order of the resolution process and
+ which DNS record takes precedence can either be defined
+ explicitly or may depend on the configuration of the
+ resolver.
+
+ Domain-name values use the US-ASCII encoding. Their canonical
+ format uses lowercase US-ASCII characters. Internationalized
+ domain names MUST be A-labels as per RFC 5890.";
+ reference
+ "RFC 952: DoD Internet Host Table Specification
+ RFC 1034: Domain Names - Concepts and Facilities
+ RFC 1123: Requirements for Internet Hosts -- Application
+ and Support
+ RFC 2782: A DNS RR for specifying the location of services
+ (DNS SRV)
+ RFC 5890: Internationalized Domain Names in Applications
+ (IDNA): Definitions and Document Framework";
+
+ }
+
+ typedef host {
+ type union {
+ type ip-address;
+ type domain-name;
+ }
+ description
+ "The host type represents either an IP address or a DNS
+ domain name.";
+ }
+
+ typedef uri {
+ type string;
+ description
+ "The uri type represents a Uniform Resource Identifier
+ (URI) as defined by STD 66.
+
+ Objects using the uri type MUST be in US-ASCII encoding,
+ and MUST be normalized as described by RFC 3986 Sections
+ 6.2.1, 6.2.2.1, and 6.2.2.2. All unnecessary
+ percent-encoding is removed, and all case-insensitive
+ characters are set to lowercase except for hexadecimal
+ digits, which are normalized to uppercase as described in
+ Section 6.2.2.1.
+
+ The purpose of this normalization is to help provide
+ unique URIs. Note that this normalization is not
+ sufficient to provide uniqueness. Two URIs that are
+ textually distinct after this normalization may still be
+ equivalent.
+
+ Objects using the uri type may restrict the schemes that
+ they permit. For example, 'data:' and 'urn:' schemes
+ might not be appropriate.
+
+ A zero-length URI is not a valid URI. This can be used to
+ express 'URI absent' where required.
+
+ In the value set and its semantics, this type is equivalent
+ to the Uri SMIv2 textual convention defined in RFC 5017.";
+ reference
+ "RFC 3986: Uniform Resource Identifier (URI): Generic Syntax
+ RFC 3305: Report from the Joint W3C/IETF URI Planning Interest
+ Group: Uniform Resource Identifiers (URIs), URLs,
+ and Uniform Resource Names (URNs): Clarifications
+ and Recommendations
+ RFC 5017: MIB Textual Conventions for Uniform Resource
+ Identifiers (URIs)";
+
+ }
+ } // module ietf-inet-types
diff --git a/compiler/plugin/maven/src/test/resources/interfileietf/ietf-network-topology.yang b/compiler/plugin/maven/src/test/resources/interfileietf/ietf-network-topology.yang
new file mode 100644
index 0000000..4c57482
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/interfileietf/ietf-network-topology.yang
@@ -0,0 +1,297 @@
+ module ietf-network-topology {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-network-topology";
+ prefix lnk;
+
+ import ietf-inet-types {
+ prefix inet;
+ }
+ import ietf-network {
+ prefix nd;
+ }
+
+ organization
+ "IETF I2RS (Interface to the Routing System) Working Group";
+
+ contact
+ "WG Web: <http://tools.ietf.org/wg/i2rs/>
+ WG List: <mailto:i2rs@ietf.org>
+
+ WG Chair: Susan Hares
+ <mailto:shares@ndzh.com>
+
+ WG Chair: Jeffrey Haas
+ <mailto:jhaas@pfrc.org>
+
+ Editor: Alexander Clemm
+ <mailto:alex@cisco.com>
+
+ Editor: Jan Medved
+ <mailto:jmedved@cisco.com>
+
+ Editor: Robert Varga
+ <mailto:rovarga@cisco.com>
+
+ Editor: Tony Tkacik
+ <mailto:ttkacik@cisco.com>
+
+ Editor: Nitin Bahadur
+ <mailto:nitin_bahadur@yahoo.com>
+
+ Editor: Hariharan Ananthakrishnan
+ <mailto:hari@packetdesign.com>";
+
+ description
+ "This module defines a common base model for network topology,
+ augmenting the base network model with links to connect nodes,
+ as well as termination points to terminate links on nodes.
+
+ Copyright (c) 2015 IETF Trust and the persons identified as
+ authors of the code. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or
+ without modification, is permitted pursuant to, and subject
+ to the license terms contained in, the Simplified BSD License
+ set forth in Section 4.c of the IETF Trust's Legal Provisions
+ Relating to IETF Documents
+ (http://trustee.ietf.org/license-info).
+
+ This version of this YANG module is part of
+ draft-ietf-i2rs-yang-network-topo-02;
+ see the RFC itself for full legal notices.
+
+ NOTE TO RFC EDITOR: Please replace above reference to
+ draft-ietf-i2rs-yang-network-topo-02 with RFC
+ number when published (i.e. RFC xxxx).";
+
+ revision 2015-12-08 {
+ description
+ "Initial revision.
+ NOTE TO RFC EDITOR: Please replace the following reference
+ to draft-ietf-i2rs-yang-network-topo-02 with
+ RFC number when published (i.e. RFC xxxx).";
+ reference
+ "draft-ietf-i2rs-yang-network-topo-02.";
+ }
+
+ typedef link-id {
+ type inet:uri;
+ description
+ "An identifier for a link in a topology.
+ The identifier SHOULD be chosen such that the same link in a
+ real network topology will always be identified through the
+ same identifier, even if the model is instantiated in
+ separate datastores. An implementation MAY choose to capture
+ semantics in the identifier, for example to indicate the type
+ of link and/or the type of topology that the link is a part
+ of.";
+ }
+
+ typedef tp-id {
+ type inet:uri;
+ description
+ "An identifier for termination points on a node.
+ The identifier SHOULD be chosen such that the same TP in a
+ real network topology will always be identified through the
+ same identifier, even if the model is instantiated in
+ separate datastores. An implementation MAY choose to capture
+ semantics in the identifier, for example to indicate the type
+ of TP and/or the type of node and topology that the TP is a
+ part of.";
+ }
+ grouping link-ref {
+ description
+ "References a link in a specific network.";
+ leaf link-ref {
+ type leafref {
+ path "/nd:networks/nd:network[nd:network-id=current()/../"+
+ "network-ref]/lnk:link/lnk:link-id";
+ require-instance false;
+ }
+ description
+ "A type for an absolute reference a link instance.
+ (This type should not be used for relative references.
+ In such a case, a relative path should be used instead.)";
+ }
+ uses nd:network-ref;
+ }
+
+ grouping tp-ref {
+ description
+ "References a termination point in a specific node.";
+ leaf tp-ref {
+ type leafref {
+ path "/nd:networks/nd:network[nd:network-id=current()/../"+
+ "network-ref]/nd:node[nd:node-id=current()/../"+
+ "node-ref]/lnk:termination-point/lnk:tp-id";
+ require-instance false;
+ }
+ description
+ "A type for an absolute reference to a termination point.
+ (This type should not be used for relative references.
+ In such a case, a relative path should be used instead.)";
+ }
+ uses nd:node-ref;
+ }
+
+ augment "/nd:networks/nd:network" {
+ description
+ "Add links to the network model.";
+ list link {
+ key "link-id";
+ description
+ "A Network Link connects a by Local (Source) node and
+ a Remote (Destination) Network Nodes via a set of the
+ nodes' termination points.
+ As it is possible to have several links between the same
+ source and destination nodes, and as a link could
+ potentially be re-homed between termination points, to
+ ensure that we would always know to distinguish between
+ links, every link is identified by a dedicated link
+ identifier.
+ Note that a link models a point-to-point link, not a
+ multipoint link.
+ Layering dependencies on links in underlay topologies are
+ not represented as the layering information of nodes and of
+ termination points is sufficient.";
+ container source {
+ description
+ "This container holds the logical source of a particular
+ link.";
+ leaf source-node {
+ type leafref {
+ path "../../../nd:node/nd:node-id";
+ }
+ mandatory true;
+ description
+ "Source node identifier, must be in same topology.";
+ }
+ leaf source-tp {
+ type leafref {
+ path "../../../nd:node[nd:node-id=current()/../"+
+ "source-node]/termination-point/tp-id";
+ }
+ description
+ "Termination point within source node that terminates
+ the link.";
+ }
+ }
+ container destination {
+ description
+ "This container holds the logical destination of a
+ particular link.";
+ leaf dest-node {
+ type leafref {
+ path "../../../nd:node/nd:node-id";
+ }
+ mandatory true;
+ description
+ "Destination node identifier, must be in the same
+ network.";
+ }
+ leaf dest-tp {
+ type leafref {
+ path "../../../nd:node[nd:node-id=current()/../"+
+ "dest-node]/termination-point/tp-id";
+ }
+ description
+ "Termination point within destination node that
+ terminates the link.";
+ }
+ }
+ leaf link-id {
+ type link-id;
+ description
+ "The identifier of a link in the topology.
+ A link is specific to a topology to which it belongs.";
+ }
+ list supporting-link {
+ key "network-ref link-ref";
+ description
+ "Identifies the link, or links, that this link
+ is dependent on.";
+ leaf network-ref {
+ type leafref {
+ path "../../../nd:supporting-network/nd:network-ref";
+ require-instance false;
+ }
+ description
+ "This leaf identifies in which underlay topology
+ supporting link is present.";
+ }
+ leaf link-ref {
+ type leafref {
+ path "/nd:networks/nd:network[nd:network-id=current()/"+
+ "../network-ref]/link/link-id";
+ require-instance false;
+ }
+ description
+ "This leaf identifies a link which is a part
+ of this link's underlay. Reference loops, in which
+ a link identifies itself as its underlay, either
+ directly or transitively, are not allowed.";
+ }
+ }
+ }
+ }
+ augment "/nd:networks/nd:network/nd:node" {
+ description
+ "Augment termination points which terminate links.
+ Termination points can ultimately be mapped to interfaces.";
+ list termination-point {
+ key "tp-id";
+ description
+ "A termination point can terminate a link.
+ Depending on the type of topology, a termination point
+ could, for example, refer to a port or an interface.";
+ leaf tp-id {
+ type tp-id;
+ description
+ "Termination point identifier.";
+ }
+ list supporting-termination-point {
+ key "network-ref node-ref tp-ref";
+ description
+ "The leaf list identifies any termination points that
+ the termination point is dependent on, or maps onto.
+ Those termination points will themselves be contained
+ in a supporting node.
+ This dependency information can be inferred from
+ the dependencies between links. For this reason,
+ this item is not separately configurable. Hence no
+ corresponding constraint needs to be articulated.
+ The corresponding information is simply provided by the
+ implementing system.";
+ leaf network-ref {
+ type leafref {
+ path "../../../nd:supporting-node/nd:network-ref";
+ require-instance false;
+ }
+ description
+ "This leaf identifies in which topology the
+ supporting termination point is present.";
+ }
+ leaf node-ref {
+ type leafref {
+ path "../../../nd:supporting-node/nd:node-ref";
+ require-instance false;
+ }
+ description
+ "This leaf identifies in which node the supporting
+ termination point is present.";
+ }
+ leaf tp-ref {
+ type leafref {
+ path "/nd:networks/nd:network[nd:network-id=current()/"+
+ "../network-ref]/nd:node[nd:node-id=current()/../"+
+ "node-ref]/termination-point/tp-id";
+ require-instance false;
+ }
+ description
+ "Reference to the underlay node, must be in a
+ different topology";
+ }
+ }
+ }
+ }
+ }
diff --git a/compiler/plugin/maven/src/test/resources/interfileietf/ietf-network.yang b/compiler/plugin/maven/src/test/resources/interfileietf/ietf-network.yang
new file mode 100644
index 0000000..60c47ce
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/interfileietf/ietf-network.yang
@@ -0,0 +1,216 @@
+ module ietf-network {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-network";
+ prefix nd;
+
+ import ietf-inet-types {
+ prefix inet;
+ }
+
+ organization
+ "IETF I2RS (Interface to the Routing System) Working Group";
+
+ contact
+ "WG Web: <http://tools.ietf.org/wg/i2rs/>
+ WG List: <mailto:i2rs@ietf.org>
+
+ WG Chair: Susan Hares
+ <mailto:shares@ndzh.com>
+
+ WG Chair: Jeffrey Haas
+ <mailto:jhaas@pfrc.org>
+
+ Editor: Alexander Clemm
+ <mailto:alex@cisco.com>
+
+ Editor: Jan Medved
+ <mailto:jmedved@cisco.com>
+
+ Editor: Robert Varga
+ <mailto:rovarga@cisco.com>
+
+ Editor: Tony Tkacik
+ <mailto:ttkacik@cisco.com>
+
+ Editor: Nitin Bahadur
+ <mailto:nitin_bahadur@yahoo.com>
+
+ Editor: Hariharan Ananthakrishnan
+ <mailto:hari@packetdesign.com>";
+
+ description
+ "This module defines a common base model for a collection
+ of nodes in a network. Node definitions are further used
+ in network topologies and inventories.
+
+ Copyright (c) 2015 IETF Trust and the persons identified as
+ authors of the code. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or
+ without modification, is permitted pursuant to, and subject
+ to the license terms contained in, the Simplified BSD License
+ set forth in Section 4.c of the IETF Trust's Legal Provisions
+ Relating to IETF Documents
+ (http://trustee.ietf.org/license-info).
+
+ This version of this YANG module is part of
+ draft-ietf-i2rs-yang-network-topo-02;
+ see the RFC itself for full legal notices.
+
+ NOTE TO RFC EDITOR: Please replace above reference to
+ draft-ietf-i2rs-yang-network-topo-02 with RFC
+ number when published (i.e. RFC xxxx).";
+
+ revision 2015-12-08 {
+ description
+ "Initial revision.
+ NOTE TO RFC EDITOR: Please replace the following reference
+ to draft-ietf-i2rs-yang-network-topo-02 with
+ RFC number when published (i.e. RFC xxxx).";
+ reference
+ "draft-ietf-i2rs-yang-network-topo-02";
+ }
+
+ typedef node-id {
+ type inet:uri;
+ description
+ "Identifier for a node.";
+ }
+
+ typedef network-id {
+ type inet:uri;
+ description
+ "Identifier for a network.";
+ }
+ grouping network-ref {
+ description
+ "Contains the information necessary to reference a network,
+ for example an underlay network.";
+ leaf network-ref {
+ type leafref {
+ path "/nd:networks/nd:network/nd:network-id";
+ require-instance false;
+ }
+ description
+ "Used to reference a network, for example an underlay
+ network.";
+ }
+ }
+
+ grouping node-ref {
+ description
+ "Contains the information necessary to reference a node.";
+ leaf node-ref {
+ type leafref {
+ path "/nd:networks/nd:network[nd:network-id=current()/../"+
+ "network-ref]/nd:node/nd:node-id";
+ require-instance false;
+ }
+ description
+ "Used to reference a node.
+ Nodes are identified relative to the network they are
+ contained in.";
+ }
+ uses network-ref;
+ }
+
+ container networks {
+ description
+ "Serves as top-level container for a list of networks.";
+ list network {
+ key "network-id";
+ description
+ "Describes a network.
+ A network typically contains an inventory of nodes,
+ topological information (augmented through
+ network-topology model), as well as layering
+ information.";
+ container network-types {
+ description
+ "Serves as an augmentation target.
+ The network type is indicated through corresponding
+ presence containers augmented into this container.";
+ }
+ leaf network-id {
+ type network-id;
+ description
+ "Identifies a network.";
+ }
+ list supporting-network {
+ key "network-ref";
+ description
+ "An underlay network, used to represent layered network
+ topologies.";
+ leaf network-ref {
+ type leafref {
+ path "/networks/network/network-id";
+ require-instance false;
+ }
+ description
+ "References the underlay network.";
+ }
+ }
+ list node {
+ key "node-id";
+ description
+ "The inventory of nodes of this network.";
+ leaf node-id {
+ type node-id;
+ description
+ "Identifies a node uniquely within the containing
+ network.";
+ }
+ list supporting-node {
+ key "network-ref node-ref";
+ description
+ "Represents another node, in an underlay network, that
+ this node is supported by. Used to represent layering
+ structure.";
+ leaf network-ref {
+ type leafref {
+ path "../../../supporting-network/network-ref";
+ require-instance false;
+ }
+ description
+ "References the underlay network that the
+ underlay node is part of.";
+ }
+ leaf node-ref {
+ type leafref {
+ path "/networks/network/node/node-id";
+ require-instance false;
+ }
+ description
+ "References the underlay node itself.";
+ }
+ }
+ }
+ }
+ }
+ container networks-state {
+ config false;
+ description
+ "Serves as top-level container for a list of state information
+ for networks";
+ list network {
+ key "network-ref";
+ description
+ "Data nodes representing operational data and state of
+ networks.
+ An instance is automatically created for every network
+ in the corresponding list under the networks container.";
+ uses network-ref;
+ leaf server-provided {
+ type boolean;
+ description
+ "Indicates whether the information concerning this
+ particular network is populated by the server
+ (server-provided true, the general case for network
+ information discovered from the server),
+ or whether it is configured by a client
+ (server-provided true, possible e.g. for
+ service overlays managed through a controller).";
+ }
+ }
+ }
+ }
diff --git a/compiler/plugin/maven/src/test/resources/interfileietf/ietf-schedule.yang b/compiler/plugin/maven/src/test/resources/interfileietf/ietf-schedule.yang
new file mode 100644
index 0000000..b9f7297
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/interfileietf/ietf-schedule.yang
@@ -0,0 +1,64 @@
+ module ietf-schedule {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-schedule";
+ // replace with IANA namespace when assigned
+
+ prefix "sch";
+
+ import ietf-yang-types {
+ prefix "yang";
+ }
+
+ organization "TBD";
+ contact "TBD";
+ description
+ "The model allows time scheduling parameters to be specified.";
+
+ revision "2016-03-01" {
+ description "Initial revision";
+ reference "TBD";
+ }
+
+ /*
+ * Groupings
+ */
+
+ grouping schedules {
+ description
+ "A list of schedules defining when a particular
+ configuration takes effect.";
+ container schedules {
+ description
+ "Container of a schedule list defining when a particular
+ configuration takes effect.";
+ list schedule {
+ key "schedule-id";
+ description "A list of schedule elements.";
+
+ leaf schedule-id {
+ type uint32;
+ description "Identifies the schedule element.";
+ }
+ leaf start {
+ type yang:date-and-time;
+ description "Start time.";
+ }
+ leaf schedule-duration {
+ type string {
+ pattern
+ 'P(\d+Y)?(\d+M)?(\d+W)?(\d+D)?T(\d+H)?(\d+M)?(\d+S)?';
+ }
+ description "Schedule duration in ISO 8601 format.";
+ }
+ leaf repeat-interval {
+ type string {
+ pattern
+ 'R\d*/P(\d+Y)?(\d+M)?(\d+W)?(\d+D)?T(\d+H)?(\d+M)?'
+ + '(\d+S)?';
+ }
+ description "Repeat interval in ISO 8601 format.";
+ }
+ }
+ }
+ } // schedules
+ }
diff --git a/compiler/plugin/maven/src/test/resources/interfileietf/ietf-te-topology.yang b/compiler/plugin/maven/src/test/resources/interfileietf/ietf-te-topology.yang
new file mode 100644
index 0000000..582ba9e
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/interfileietf/ietf-te-topology.yang
@@ -0,0 +1,1779 @@
+ module ietf-te-topology {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-te-topology";
+ // replace with IANA namespace when assigned
+
+ prefix "tet";
+
+ import ietf-inet-types {
+ prefix "inet";
+ }
+
+ import ietf-schedule {
+ prefix "sch";
+ }
+
+ import ietf-te-types {
+ prefix "te-types";
+ }
+
+ import ietf-network {
+ prefix "nw";
+ }
+
+ import ietf-network-topology {
+ prefix "nt";
+ }
+
+ organization
+ "Traffic Engineering Architecture and Signaling (TEAS)
+ Working Group";
+
+ contact
+ "WG Web: <http://tools.ietf.org/wg/teas/>
+ WG List: <mailto:teas@ietf.org>
+
+ WG Chair: Lou Berger
+ <mailto:lberger@labn.net>
+
+ WG Chair: Vishnu Pavan Beeram
+ <mailto:vbeeram@juniper.net>
+
+ Editor: Xufeng Liu
+ <mailto:xliu@kuatrotech.com>
+
+ Editor: Igor Bryskin
+ <mailto:Igor.Bryskin@huawei.com>
+
+ Editor: Vishnu Pavan Beeram
+ <mailto:vbeeram@juniper.net>
+
+ Editor: Tarek Saad
+ <mailto:tsaad@cisco.com>
+
+ Editor: Himanshu Shah
+ <mailto:hshah@ciena.com>
+
+ Editor: Oscar Gonzalez De Dios
+ <mailto:oscar.gonzalezdedios@telefonica.com>";
+
+ description "TE topology model";
+
+ revision "2016-03-17" {
+ description "Initial revision";
+ reference "TBD";
+ }
+
+ /*
+ * Features
+ */
+
+ feature configuration-schedule {
+ description
+ "This feature indicates that the system supports
+ configuration scheduling.";
+ }
+
+ feature te-topology-hierarchy {
+ description
+ "This feature indicates that the system allows underlay
+ and/or overlay TE topology hierarchy.";
+ }
+
+ feature te-performance-metric {
+ description
+ "This feature indicates that the system supports
+ TE performance metric defined in
+ RFC7471: OSPF Traffic Engineering (TE) Metric Extensions.";
+ }
+
+ feature template {
+ description
+ "This feature indicates that the system supports
+ template configuration.";
+ }
+
+ /*
+ * Typedefs
+ */
+ typedef performance-metric-normality {
+ type enumeration {
+ enum "unknown" {
+ value 0;
+ description
+ "Unknown.";
+ }
+ enum "normal" {
+ value 1;
+ description
+ "Normal.";
+ }
+ enum "abnormal" {
+ value 2;
+ description
+ "Abnormal. The anomalous bit is set.";
+ }
+ }
+ description
+ "Indicates whether a performance metric is normal, abnormal, or
+ unknown.";
+ reference
+ "RFC7471: OSPF Traffic Engineering (TE) Metric Extensions.";
+ }
+
+ typedef te-admin-status {
+ type enumeration {
+ enum up {
+ description
+ "Enabled.";
+ }
+ enum down {
+ description
+ "Disabled.";
+ }
+ enum testing {
+ description
+ "In some test mode.";
+ }
+ enum preparing-maintenance {
+ description
+ "Resource is disabled in the control plane to prepare for
+ graceful shutdown for maintenance purposes.";
+ reference
+ "RFC5817: Graceful Shutdown in MPLS and Generalized MPLS
+ Traffic Engineering Networks";
+ }
+ enum maintenance {
+ description
+ "Resource is disabled in the data plane for maintenance
+ purposes.";
+ }
+ }
+ description
+ "Defines a type representing the administrative status of
+ a TE resource.";
+ }
+ typedef te-global-id {
+ type uint32;
+ description
+ "An identifier to uniquely identify an operator, which can be
+ either a provider or a client.
+ The definition of this type is taken from RFC6370 and RFC5003.
+ This attribute type is used solely to provide a globally
+ unique context for TE topologies.";
+ }
+
+ typedef te-link-access-type {
+ type enumeration {
+ enum point-to-point {
+ description
+ "The link is point-to-point.";
+ }
+ enum multi-access {
+ description
+ "The link is multi-access, including broacast and NBMA.";
+ }
+ }
+ description
+ "Defines a type representing the access type of a TE link.";
+ reference
+ "RFC3630: Traffic Engineering (TE) Extensions to OSPF
+ Version 2.";
+ }
+
+ typedef te-node-id {
+ type inet:ip-address;
+ description
+ "An identifier for a node in a topology.
+ The identifier is represented as an IPv4 or IPv6 address.
+ This attribute is mapped to Router ID in
+ RFC3630, RFC5329, RFC5305, and RFC 6119.";
+ }
+
+ typedef te-oper-status {
+ type enumeration {
+ enum up {
+ description
+ "Operational up.";
+ }
+ enum down {
+ description
+ "Operational down.";
+ }
+ enum testing {
+ description
+ "In some test mode.";
+ }
+ enum unknown {
+ description
+ "Status cannot be determined for some reason.";
+ }
+ enum preparing-maintenance {
+ description
+ "Resource is disabled in the control plane to prepare for
+ graceful shutdown for maintenance purposes.";
+ reference
+ "RFC5817: Graceful Shutdown in MPLS and Generalized MPLS
+ Traffic Engineering Networks";
+ }
+ enum maintenance {
+ description
+ "Resource is disabled in the data plane for maintenance
+ purposes.";
+ }
+ }
+ description
+ "Defines a type representing the operational status of
+ a TE resource.";
+ }
+
+ typedef te-recovery-status {
+ type enumeration {
+ enum normal {
+ description
+ "Both the recovery and working spans are fully
+ allocated and active, data traffic is being
+ transported over (or selected from) the working
+ span, and no trigger events are reported.";
+ }
+ enum recovery-started {
+ description
+ "The recovery action has been started, but not completed.";
+ }
+ enum recovery-succeeded {
+ description
+ "The recovery action has succeeded. The working span has
+ reported a failure/degrade condition and the user traffic
+ is being transported (or selected) on the recovery span.";
+ }
+ enum recovery-failed {
+ description
+ "The recovery action has failed.";
+ }
+ enum reversion-started {
+ description
+ "The reversion has started.";
+ }
+ enum reversion-failed {
+ description
+ "The reversion has failed.";
+ }
+ enum recovery-unavailable {
+ description
+ "The recovery is unavailable -- either as a result of an
+ operator Lockout command or a failure condition detected
+ on the recovery span.";
+ }
+ enum recovery-admin {
+ description
+ "The operator has issued a command switching the user
+ traffic to the recovery span.";
+ }
+ enum wait-to-restore {
+ description
+ "The recovery domain is recovering from a failuer/degrade
+ condition on the working span that is being controlled by
+ the Wait-to-Restore (WTR) timer.";
+ }
+ }
+ description
+ "Defines the status of a recovery action.";
+ reference
+ "RFC4427: Recovery (Protection and Restoration) Terminology
+ for Generalized Multi-Protocol Label Switching (GMPLS).
+ RFC6378: MPLS Transport Profile (MPLS-TP) Linear Protection";
+ }
+
+ typedef te-template-name {
+ type string {
+ pattern '/?([a-zA-Z0-9\-_.]+)(/[a-zA-Z0-9\-_.]+)*';
+ }
+ description
+ "A type for the name of a TE node template or TE link
+ template.";
+ }
+
+ typedef te-topology-event-type {
+ type enumeration {
+ enum "add" {
+ value 0;
+ description
+ "A TE node or te-link has been added.";
+ }
+ enum "remove" {
+ value 1;
+ description
+ "A TE node or te-link has been removed.";
+ }
+ enum "update" {
+ value 2;
+ description
+ "A TE node or te-link has been updated.";
+ }
+ }
+ description "TE Event type for notifications";
+ } // te-topology-event-type
+ typedef te-topology-id {
+ type string {
+ pattern '/?([a-zA-Z0-9\-_.]+)(/[a-zA-Z0-9\-_.]+)*';
+ }
+ description
+ "An identifier for a topology.";
+ }
+
+ typedef te-tp-id {
+ type union {
+ type uint32; // Unnumbered
+ type inet:ip-address; // IPv4 or IPv6 address
+ }
+ description
+ "An identifier for a TE link endpoint on a node.
+ This attribute is mapped to local or remote link identifier in
+ RFC3630 and RFC5305.";
+ }
+
+ /*
+ * Identities
+ */
+
+ /*
+ * Groupings
+ */
+ grouping information-source-attributes {
+ description
+ "The attributes identifying source that has provided the
+ related information, and the source credibility.";
+ leaf information-source {
+ type enumeration {
+ enum "unknown" {
+ description "The source is unknown.";
+ }
+ enum "locally-configured" {
+ description "Configured entity.";
+ }
+ enum "ospfv2" {
+ description "OSPFv2.";
+ }
+ enum "ospfv3" {
+ description "OSPFv3.";
+ }
+ enum "isis" {
+ description "ISIS.";
+ }
+ enum "system-processed" {
+ description "System processed entity.";
+ }
+ enum "other" {
+ description "Other source.";
+ }
+ }
+ description
+ "Indicates the source of the information.";
+ }
+ container information-source-state {
+ description
+ "The container contains state attributes related to
+ the information source.";
+ leaf credibility-preference {
+ type uint16;
+ description
+ "The preference value to calculate the traffic
+ engineering database credibility value used for
+ tie-break selection between different
+ information-source values.
+ Higher value is more preferable.";
+ }
+ container topology {
+ description
+ "When the information is processed by the system,
+ the attributes in this container indicate which topology
+ is used to process to generate the result information.";
+ uses te-topology-ref;
+ } // topology
+ leaf routing-instance {
+ type string;
+ description
+ "When applicable, this is the name of a routing instance
+ from which the information is learned.";
+ } // routing-information
+ }
+ } // information-source-attributes
+
+ grouping performance-metric-attributes {
+ description
+ "Link performance information in real time.";
+ reference
+ "RFC7471: OSPF Traffic Engineering (TE) Metric Extensions.";
+ leaf unidirectional-delay {
+ type uint32 {
+ range 0..16777215;
+ }
+ description "Delay or latency in micro seconds.";
+ }
+ leaf unidirectional-min-delay {
+ type uint32 {
+ range 0..16777215;
+ }
+ description "Minimum delay or latency in micro seconds.";
+ }
+ leaf unidirectional-max-delay {
+ type uint32 {
+ range 0..16777215;
+ }
+ description "Maximum delay or latency in micro seconds.";
+ }
+ leaf unidirectional-delay-variation {
+ type uint32 {
+ range 0..16777215;
+ }
+ description "Delay variation in micro seconds.";
+ }
+ leaf unidirectional-packet-loss {
+ type decimal64 {
+ fraction-digits 6;
+ range "0 .. 50.331642";
+ }
+ description
+ "Packet loss as a percentage of the total traffic sent
+ over a configurable interval. The finest precision is
+ 0.000003%.";
+ }
+ leaf unidirectional-residual-bandwidth {
+ type decimal64 {
+ fraction-digits 2;
+ }
+ description
+ "Residual bandwidth that subtracts tunnel
+ reservations from Maximum Bandwidth (or link capacity)
+ [RFC3630] and provides an aggregated remainder across QoS
+ classes.";
+ }
+ leaf unidirectional-available-bandwidth {
+ type decimal64 {
+ fraction-digits 2;
+ }
+ description
+ "Available bandwidth that is defined to be residual
+ bandwidth minus the measured bandwidth used for the
+ actual forwarding of non-RSVP-TE LSP packets. For a
+ bundled link, available bandwidth is defined to be the
+ sum of the component link available bandwidths.";
+ }
+ leaf unidirectional-utilized-bandwidth {
+ type decimal64 {
+ fraction-digits 2;
+ }
+ description
+ "Bandwidth utilization that represents the actual
+ utilization of the link (i.e. as measured in the router).
+ For a bundled link, bandwidth utilization is defined to
+ be the sum of the component link bandwidth
+ utilizations.";
+ }
+ } // performance-metric-attributes
+ grouping performance-metric-normality-attributes {
+ description
+ "Link performance metric normality attributes.";
+ reference
+ "RFC7471: OSPF Traffic Engineering (TE) Metric Extensions.";
+ leaf unidirectional-delay {
+ type performance-metric-normality;
+ description "Delay normality.";
+ }
+ leaf unidirectional-min-delay {
+ type performance-metric-normality;
+ description "Minimum delay or latency normality.";
+ }
+ leaf unidirectional-max-delay {
+ type performance-metric-normality;
+ description "Maximum delay or latency normality.";
+ }
+ leaf unidirectional-delay-variation {
+ type performance-metric-normality;
+ description "Delay variation normality.";
+ }
+ leaf unidirectional-packet-loss {
+ type performance-metric-normality;
+ description "Packet loss normality.";
+ }
+ leaf unidirectional-residual-bandwidth {
+ type performance-metric-normality;
+ description "Residual bandwidth normality.";
+ }
+ leaf unidirectional-available-bandwidth {
+ type performance-metric-normality;
+ description "Available bandwidth normality.";
+ }
+ leaf unidirectional-utilized-bandwidth {
+ type performance-metric-normality;
+ description "Bandwidth utilization normality.";
+ }
+ } // performance-metric-normality-attributes
+
+ grouping performance-metric-throttle-container {
+ description
+ "A container controlling performance metric throttle.";
+ container performance-metric-throttle {
+ if-feature te-performance-metric;
+ must "suppression-interval >= measure-interval" {
+ error-message
+ "suppression-interval cannot be less then
+ measure-interval.";
+ description
+ "Constraint on suppression-interval and
+ measure-interval.";
+ }
+ description
+ "Link performance information in real time.";
+ reference
+ "RFC7471: OSPF Traffic Engineering (TE) Metric Extensions.";
+ leaf unidirectional-delay-offset {
+ type uint32 {
+ range 0..16777215;
+ }
+ description
+ "Offset value to be added to the measured delay value.";
+ }
+ leaf measure-interval {
+ type uint32;
+ default 30;
+ description
+ "Interval in seconds to measure the extended metric
+ values.";
+ }
+ leaf advertisement-interval {
+ type uint32;
+ description
+ "Interval in seconds to advertise the extended metric
+ values.";
+ }
+ leaf suppression-interval {
+ type uint32 {
+ range "1 .. max";
+ }
+ default 120;
+ description
+ "Interval in seconds to suppress advertising the extended
+ metric values.";
+ }
+ container threshold-out {
+ uses performance-metric-attributes;
+ description
+ "If the measured parameter falls outside an upper bound
+ for all but the min delay metric (or lower bound for
+ min-delay metric only) and the advertised value is not
+ already outside that bound, anomalous announcement will be
+ triggered.";
+ }
+ container threshold-in {
+ uses performance-metric-attributes;
+ description
+ "If the measured parameter falls inside an upper bound
+ for all but the min delay metric (or lower bound for
+ min-delay metric only) and the advertised value is not
+ already inside that bound, normal (anomalous-flag cleared)
+ announcement will be triggered.";
+ }
+ container threshold-accelerated-advertisement {
+ description
+ "When the difference between the last advertised value and
+ current measured value exceed this threshold, anomalous
+ announcement will be triggered.";
+ uses performance-metric-attributes;
+ }
+ }
+ } // performance-metric-throttle-container
+
+ grouping te-link-augment {
+ description
+ "Augmentation for TE link.";
+
+ container te {
+ presence "TE support.";
+ description
+ "Indicates TE support.";
+
+ container config {
+ description
+ "Configuration data.";
+ uses te-link-config;
+ } // config
+ container state {
+ config false;
+ description
+ "Operational state data.";
+ uses te-link-config;
+ uses te-link-state-derived;
+ } // state
+ } // te
+ } // te-link-augment
+
+ grouping te-link-config {
+ description
+ "TE link configuration grouping.";
+ choice bundle-stack-level {
+ description
+ "The TE link can be partitioned into bundled
+ links, or component links.";
+ case bundle {
+ container bundled-links {
+ description
+ "A set of bundled links.";
+ reference
+ "RFC4201: Link Bundling in MPLS Traffic Engineering
+ (TE).";
+ list bundled-link {
+ key "sequence";
+ description
+ "Specify a bundled interface that is
+ further partitioned.";
+ leaf sequence {
+ type uint32;
+ description
+ "Identify the sequence in the bundle.";
+ }
+ leaf src-tp-ref {
+ type leafref {
+ path "../../../../../../nw:node[nw:node-id = "
+ + "current()/../../../../../nt:source/"
+ + "nt:source-node]/"
+ + "nt:termination-point/nt:tp-id";
+ require-instance true;
+ }
+ description
+ "Reference to another TE termination point on the
+ same souruce node.";
+ }
+ leaf des-tp-ref {
+ type leafref {
+ path "../../../../../../nw:node[nw:node-id = "
+ + "current()/../../../../../nt:destination/"
+ + "nt:dest-node]/"
+ + "nt:termination-point/nt:tp-id";
+ require-instance true;
+ }
+ description
+ "Reference to another TE termination point on the
+ same destination node.";
+ }
+ } // list bundled-link
+ }
+ }
+ case component {
+ container component-links {
+ description
+ "A set of component links";
+ list component-link {
+ key "sequence";
+ description
+ "Specify a component interface that is
+ sufficient to unambiguously identify the
+ appropriate resources";
+
+ leaf sequence {
+ type uint32;
+ description
+ "Identify the sequence in the bundle.";
+ }
+ leaf src-interface-ref {
+ type string;
+ description
+ "Reference to component link interface on the
+ source node.";
+ }
+ leaf des-interface-ref {
+ type string;
+ description
+ "Reference to component link interface on the
+ destinatioin node.";
+ }
+ }
+ }
+ }
+ } // bundle-stack-level
+
+ leaf-list te-link-template {
+ if-feature template;
+ type leafref {
+ path "../../../../../te/templates/link-template/name";
+ }
+ description
+ "The reference to a TE link template.";
+ }
+ uses te-link-config-attributes;
+ } // te-link-config
+
+ grouping te-link-config-attributes {
+ description
+ "Link configuration attributes in a TE topology.";
+ container te-link-attributes {
+ description "Link attributes in a TE topology.";
+ uses sch:schedules;
+ leaf access-type {
+ type te-link-access-type;
+ description
+ "Link access type, which can be point-to-point or
+ multi-access.";
+ }
+ leaf is-abstract {
+ type empty;
+ description "Present if the link is abstract.";
+ }
+ leaf name {
+ type string;
+ description "Link Name.";
+ }
+ container underlay {
+ if-feature te-topology-hierarchy;
+ presence
+ "Indicates the underlay exists for this link.";
+ description "Attributes of the te-link underlay.";
+ reference
+ "RFC4206: Label Switched Paths (LSP) Hierarchy with
+ Generalized Multi-Protocol Label Switching (GMPLS)
+ Traffic Engineering (TE)";
+
+ uses te-link-underlay-attributes;
+ } // underlay
+ leaf admin-status {
+ type te-admin-status;
+ description
+ "The administrative state of the link.";
+ }
+
+ uses performance-metric-throttle-container;
+ uses te-link-info-attributes;
+ } // te-link-attributes
+ } // te-link-config-attributes
+
+ grouping te-link-info-attributes {
+ description
+ "Advertised TE information attributes.";
+ leaf link-index {
+ type uint64;
+ description
+ "The link identifier. If OSPF is used, this represents an
+ ospfLsdbID. If IS-IS is used, this represents an isisLSPID.
+ If a locally configured link is used, this object represents
+ a unique value, which is locally defined in a router.";
+ }
+ leaf administrative-group {
+ type te-types:admin-groups;
+ description
+ "Administrative group or color of the link.
+ This attribute covers both administrative group (defined in
+ RFC3630, RFC5329, and RFC5305), and extended administrative
+ group (defined in RFC7308).";
+ }
+ leaf max-link-bandwidth {
+ type decimal64 {
+ fraction-digits 2;
+ }
+ description
+ "Maximum bandwidth that can be seen on this link in this
+ direction. Units in bytes per second.";
+ reference
+ "RFC3630: Traffic Engineering (TE) Extensions to OSPF
+ Version 2.
+ RFC5305: IS-IS Extensions for Traffic Engineering.";
+ }
+ leaf max-resv-link-bandwidth {
+ type decimal64 {
+ fraction-digits 2;
+ }
+ description
+ "Maximum amount of bandwidth that can be reserved in this
+ direction in this link. Units in bytes per second.";
+ reference
+ "RFC3630: Traffic Engineering (TE) Extensions to OSPF
+ Version 2.
+ RFC5305: IS-IS Extensions for Traffic Engineering.";
+ }
+ list unreserved-bandwidth {
+ key "priority";
+ max-elements "8";
+ description
+ "Unreserved bandwidth for 0-7 priority levels. Units in
+ bytes per second.";
+ reference
+ "RFC3630: Traffic Engineering (TE) Extensions to OSPF
+ Version 2.
+ RFC5305: IS-IS Extensions for Traffic Engineering.";
+ leaf priority {
+ type uint8 {
+ range "0..7";
+ }
+ description "Priority.";
+ }
+ leaf bandwidth {
+ type decimal64 {
+ fraction-digits 2;
+ }
+ description
+ "Unreserved bandwidth for this level.";
+ }
+ }
+ leaf te-default-metric {
+ type uint32;
+ description
+ "Traffic Engineering Metric.";
+ }
+ container performance-metric {
+ if-feature te-performance-metric;
+ description
+ "Link performance information in real time.";
+ reference
+ "RFC7471: OSPF Traffic Engineering (TE) Metric Extensions.";
+ container measurement {
+ description
+ "Measured performance metric values. Static configuration
+ and manual overrides of these measurements are also
+ allowed.";
+ uses performance-metric-attributes;
+ }
+ container normality
+ {
+ description
+ "Performance metric normality values.";
+ uses performance-metric-normality-attributes;
+ }
+ }
+ leaf link-protection-type {
+ type enumeration {
+ enum "unprotected" {
+ description "Unprotected.";
+ }
+ enum "extra-traffic" {
+ description "Extra traffic.";
+ }
+ enum "shared" {
+ description "Shared.";
+ }
+ enum "1-for-1" {
+ description "One for one protection.";
+ }
+ enum "1-plus-1" {
+ description "One plus one protection.";
+ }
+ enum "enhanced" {
+ description "Enhanced protection.";
+ }
+ }
+ description
+ "Link Protection Type desired for this link.";
+ reference
+ "RFC4202: Routing Extensions in Support of
+ Generalized Multi-Protocol Label Switching (GMPLS).";
+ }
+ list interface-switching-capability {
+ key "switching-capability";
+ description
+ "List of Interface Switching Capabilities Descriptors (ISCD)
+ for this link.";
+ reference
+ "RFC3471: Generalized Multi-Protocol Label Switching (GMPLS)
+ Signaling Functional Description.
+ RFC4203: OSPF Extensions in Support of Generalized
+ Multi-Protocol Label Switching (GMPLS).";
+ leaf switching-capability {
+ type identityref {
+ base te-types:switching-capabilities;
+ }
+ description
+ "Switching Capability for this interface.";
+ }
+ leaf encoding {
+ type identityref {
+ base te-types:lsp-encoding-types;
+ }
+ description
+ "Encoding supported by this interface.";
+ }
+ list max-lsp-bandwidth {
+ key "priority";
+ max-elements "8";
+ description
+ "Maximum LSP Bandwidth at priorities 0-7.";
+ leaf priority {
+ type uint8 {
+ range "0..7";
+ }
+ description "Priority.";
+ }
+ leaf bandwidth {
+ type decimal64 {
+ fraction-digits 2;
+ }
+ description
+ "Max LSP Bandwidth for this level";
+ }
+ }
+ container time-division-multiplex-capable {
+ when "../switching-capability = 'TDM'" {
+ description "Valid only for TDM";
+ }
+ description
+ "Interface has time-division multiplex capabilities.";
+
+ leaf minimum-lsp-bandwidth {
+ type decimal64 {
+ fraction-digits 2;
+ }
+ description
+ "Minimum LSP Bandwidth. Units in bytes per second.";
+ }
+ leaf indication {
+ type enumeration {
+ enum "standard" {
+ description
+ "Indicates support of standard SONET/SDH.";
+ }
+ enum "arbitrary" {
+ description
+ "Indicates support of arbitrary SONET/SDH.";
+ }
+ }
+ description
+ "Indication whether the interface supports Standard or
+ Arbitrary SONET/SDH";
+ }
+ }
+ list interface-adjustment-capability {
+ key "upper-sc";
+ description
+ "List of Interface Adjustment Capability Descriptors (IACD)
+ for this link.";
+ reference
+ "RFC6001: Generalized MPLS (GMPLS) Protocol Extensions
+ for Multi-Layer and Multi-Region Networks (MLN/MRN).";
+ leaf upper-sc {
+ type identityref {
+ base te-types:switching-capabilities;
+ }
+ description
+ "Switching Capability for this interface.";
+ }
+ leaf upper-encoding {
+ type identityref {
+ base te-types:lsp-encoding-types;
+ }
+ description
+ "Encoding supported by this interface.";
+ }
+ list max-lsp-bandwidth {
+ key "priority";
+ max-elements "8";
+ description
+ "Maximum LSP Bandwidth at priorities 0-7.";
+ leaf priority {
+ type uint8 {
+ range "0..7";
+ }
+ description "Priority.";
+ }
+ leaf bandwidth {
+ type decimal64 {
+ fraction-digits 2;
+ }
+ description
+ "Max LSP Bandwidth for this level.";
+ }
+ }
+ } // interface-adjustment-capability
+ } // interface-switching-capability
+ container te-srlgs {
+ description
+ "A list of SLRGs.";
+ leaf-list values {
+ type te-types:srlg;
+ description "SRLG value.";
+ reference
+ "RFC4202: Routing Extensions in Support of
+ Generalized Multi-Protocol Label Switching (GMPLS).";
+ }
+ }
+ } // te-link-info-attributes
+
+ grouping te-link-state-derived {
+ description
+ "Link state attributes in a TE topology.";
+ leaf oper-status {
+ type te-oper-status;
+ description
+ "The current operational state of the link.";
+ }
+ uses information-source-attributes;
+ list alt-information-sources {
+ key "information-source";
+ description
+ "A list of information sources learned but not used.";
+ uses information-source-attributes;
+ uses te-link-info-attributes;
+ }
+ container recovery {
+ description
+ "Status of the recovery process.";
+ leaf restoration-status {
+ type te-recovery-status;
+ description
+ "Restoration status.";
+ }
+ leaf protection-status {
+ type te-recovery-status;
+ description
+ "Protection status.";
+ }
+ }
+ container underlay {
+ if-feature te-topology-hierarchy;
+ description "State attributes for te-link underlay.";
+ uses te-link-state-underlay-attributes;
+ }
+ } // te-link-state-derived
+ grouping te-link-state-underlay-attributes {
+ description "State attributes for te-link underlay.";
+ leaf dynamic {
+ type boolean;
+ description
+ "true if the underlay is dynamically created.";
+ }
+ leaf committed {
+ type boolean;
+ description
+ "true if the underlay is committed.";
+ }
+ } // te-link-state-underlay-attributes
+
+ grouping te-link-underlay-attributes {
+ description "Attributes for te-link underlay.";
+ reference
+ "RFC4206: Label Switched Paths (LSP) Hierarchy with
+ Generalized Multi-Protocol Label Switching (GMPLS)
+ Traffic Engineering (TE)";
+ container underlay-primary-path {
+ description
+ "The service path on the underlay topology that
+ supports this link.";
+ uses te-topology-ref;
+ list path-element {
+ key "path-element-id";
+ description
+ "A list of path elements describing the service path.";
+ leaf path-element-id {
+ type uint32;
+ description "To identify the element in a path.";
+ }
+ uses te-path-element;
+ }
+ } // underlay-primary-path
+ list underlay-backup-path {
+ key "index";
+ description
+ "A list of backup service paths on the underlay topology that
+ protect the underlay primary path. If the primary path is
+ not protected, the list contains zero elements. If the
+ primary path is protected, the list contains one or more
+ elements.";
+ leaf index {
+ type uint32;
+ description
+ "A sequence number to identify a backup path.";
+ }
+ uses te-topology-ref;
+ list path-element {
+ key "path-element-id";
+ description
+ "A list of path elements describing the backup service
+ path";
+ leaf path-element-id {
+ type uint32;
+ description "To identify the element in a path.";
+ }
+ uses te-path-element;
+ }
+ } // underlay-backup-path
+ leaf underlay-protection-type {
+ type uint16;
+ description
+ "Underlay protection type desired for this link";
+ }
+ container underlay-trail-src {
+ uses nt:tp-ref;
+ description
+ "Source TE link of the underlay trail.";
+ }
+ container underlay-trail-des {
+ uses nt:tp-ref;
+ description
+ "Destination TE link of the underlay trail.";
+ }
+ } // te-link-underlay-attributes
+
+ grouping te-node-augment {
+ description
+ "Augmentation for TE node.";
+
+ container te {
+ presence "TE support.";
+ description
+ "Indicates TE support.";
+
+ leaf te-node-id {
+ type te-node-id;
+ mandatory true;
+ description
+ "The identifier of a node in the TE topology.
+ A node is specific to a topology to which it belongs.";
+ }
+
+ container config {
+ description
+ "Configuration data.";
+ uses te-node-config;
+ } // config
+ container state {
+ config false;
+ description
+ "Operational state data.";
+
+ uses te-node-config;
+ uses te-node-state-derived;
+ } // state
+
+ list tunnel-termination-point {
+ key "tunnel-tp-id";
+ description
+ "A termination point can terminate a tunnel.";
+ leaf tunnel-tp-id {
+ type binary;
+ description
+ "Tunnel termination point identifier.";
+ }
+ container config {
+ description
+ "Configuration data.";
+ uses te-node-tunnel-termination-capability;
+ }
+
+ container state {
+ config false;
+ description
+ "Operational state data.";
+
+ uses te-node-tunnel-termination-capability;
+ leaf switching-capability {
+ type identityref {
+ base te-types:switching-capabilities;
+ }
+ mandatory true;
+ description
+ "Switching Capability.";
+ }
+ leaf encoding {
+ type identityref {
+ base te-types:lsp-encoding-types;
+ }
+ mandatory true;
+ description
+ "Encoding type.";
+ }
+ } // state
+
+ } // tunnel-termination-point
+ } // te
+ } // te-node-augment
+
+ grouping te-node-config {
+ description "TE node configuration grouping.";
+
+ leaf-list te-node-template {
+ if-feature template;
+ type leafref {
+ path "../../../../../te/templates/node-template/name";
+ }
+ description
+ "The reference to a TE node template.";
+ }
+ uses te-node-config-attributes;
+ } // te-node-config
+
+ grouping te-node-config-attributes {
+ description "Configuration node attributes in a TE topology.";
+ container te-node-attributes {
+ description "Containing node attributes in a TE topology.";
+ uses sch:schedules;
+ leaf admin-status {
+ type te-admin-status;
+ description
+ "The administrative state of the link.";
+ }
+ uses te-node-connectivity-matrix;
+ uses te-node-info-attributes;
+ } // te-node-attributes
+ } // te-node-config-attributes
+
+ grouping te-node-config-attributes-notification {
+ description
+ "Configuration node attributes for template in a TE topology.";
+ container te-node-attributes {
+ description "Containing node attributes in a TE topology.";
+ uses sch:schedules;
+ leaf admin-status {
+ type te-admin-status;
+ description
+ "The administrative state of the link.";
+ }
+ uses te-node-connectivity-matrix-abs;
+ uses te-node-info-attributes;
+ } // te-node-attributes
+ } // te-node-config-attributes-notification
+
+ grouping te-node-config-attributes-template {
+ description
+ "Configuration node attributes for template in a TE topology.";
+ container te-node-attributes {
+ description "Containing node attributes in a TE topology.";
+ uses sch:schedules;
+ leaf admin-status {
+ type te-admin-status;
+ description
+ "The administrative state of the link.";
+ }
+ uses te-node-info-attributes;
+ } // te-node-attributes
+ } // te-node-config-attributes-template
+
+ grouping te-node-connectivity-matrix {
+ description "Connectivity matrix on a TE node.";
+ list connectivity-matrix {
+ key "id";
+ description
+ "Represents node's switching limitations, i.e. limitations
+ in interconnecting network TE links across the node.";
+ reference
+ "RFC7579: General Network Element Constraint Encoding
+ for GMPLS-Controlled Networks.";
+ leaf id {
+ type uint32;
+ description "Identifies the connectivity-matrix entry.";
+ }
+ container from {
+ leaf tp-ref {
+ type leafref {
+ path "../../../../../../nt:termination-point/nt:tp-id";
+ }
+ description
+ "Relative reference to source termination point.";
+ }
+ description
+ "Reference to source NTP.";
+ }
+ container to {
+ leaf tp-ref {
+ type leafref {
+ path "../../../../../../nt:termination-point/nt:tp-id";
+ }
+ description
+ "Relative reference to destination termination point.";
+ }
+ description
+ "Reference to destination NTP.";
+ }
+ leaf is-allowed {
+ type boolean;
+ description
+ "true - switching is allowed,
+ false - switching is disallowed.";
+ }
+ }
+ } // te-node-connectivity-matrix
+
+ grouping te-node-connectivity-matrix-abs {
+ description
+ "Connectivity matrix on a TE node, using absolute
+ paths to reference termination points.";
+ list connectivity-matrix {
+ key "id";
+ description
+ "Represents node's switching limitations, i.e. limitations
+ in interconnecting network TE links across the node.";
+ reference
+ "RFC7579: General Network Element Constraint Encoding
+ for GMPLS-Controlled Networks.";
+ leaf id {
+ type uint32;
+ description "Identifies the connectivity-matrix entry.";
+ }
+ container from {
+ uses nt:tp-ref;
+ description
+ "Reference to source NTP.";
+ }
+ container to {
+ uses nt:tp-ref;
+ description
+ "Reference to destination NTP.";
+ }
+ leaf is-allowed {
+ type boolean;
+ description
+ "true - switching is allowed,
+ false - switching is disallowed.";
+ }
+ }
+ } // te-node-connectivity-matrix-abs
+
+ grouping te-node-info-attributes {
+ description
+ "Advertised TE information attributes.";
+ leaf domain-id {
+ type uint32;
+ description
+ "Identifies the domain that this node belongs.
+ This attribute is used to support inter-domain links.";
+ reference
+ "RFC5152: A Per-Domain Path Computation Method for
+ Establishing Inter-Domain Traffic Engineering (TE)
+ Label Switched Paths (LSPs).
+ RFC5392: OSPF Extensions in Support of Inter-Autonomous
+ System (AS) MPLS and GMPLS Traffic Engineering.
+ RFC5316: ISIS Extensions in Support of Inter-Autonomous
+ System (AS) MPLS and GMPLS Traffic Engineering.";
+ }
+ leaf is-abstract {
+ type empty;
+ description
+ "Present if the node is abstract, not present if the node
+ is actual.";
+ }
+ leaf name {
+ type inet:domain-name;
+ description "Node name.";
+ }
+ leaf-list signaling-address {
+ type inet:ip-address;
+ description "Node signaling address.";
+ }
+ container underlay-topology {
+ if-feature te-topology-hierarchy;
+ description
+ "When an abstract node encapsulates a topology,
+ the attributes in this container point to said topology.";
+ uses te-topology-ref;
+ }
+ } // te-node-info-attributes
+
+ grouping te-node-state-derived {
+ description "Node state attributes in a TE topology.";
+ leaf oper-status {
+ type te-oper-status;
+ description
+ "The current operational state of the node.";
+ }
+ leaf is-multi-access-dr {
+ type empty;
+ description
+ "The presence of this attribute indicates that this TE node
+ is a pseudonode elected as a designated router.";
+ reference
+ "RFC3630: Traffic Engineering (TE) Extensions to OSPF
+ Version 2.
+ RFC1195: Use of OSI IS-IS for Routing in TCP/IP and Dual
+ Environments.";
+ }
+ uses information-source-attributes;
+ list alt-information-sources {
+ key "information-source";
+ description
+ "A list of information sources learned but not used.";
+ uses information-source-attributes;
+ uses te-node-connectivity-matrix;
+ uses te-node-info-attributes;
+ }
+ } // te-node-state-derived
+
+ grouping te-node-state-derived-notification {
+ description "Node state attributes in a TE topology.";
+ leaf oper-status {
+ type te-oper-status;
+ description
+ "The current operational state of the node.";
+ }
+ leaf is-multi-access-dr {
+ type empty;
+ description
+ "The presence of this attribute indicates that this TE node
+ is a pseudonode elected as a designated router.";
+ reference
+ "RFC3630: Traffic Engineering (TE) Extensions to OSPF
+ Version 2.
+ RFC1195: Use of OSI IS-IS for Routing in TCP/IP and Dual
+ Environments.";
+ }
+ uses information-source-attributes;
+ list alt-information-sources {
+ key "information-source";
+ description
+ "A list of information sources learned but not used.";
+ uses information-source-attributes;
+ uses te-node-connectivity-matrix-abs;
+ uses te-node-info-attributes;
+ }
+ } // te-node-state-derived-notification
+
+ grouping te-node-tunnel-termination-capability {
+ description
+ "Termination capability of a tunnel termination point on a
+ TE node.";
+
+ list termination-capability {
+ key "link-tp";
+ description
+ "The termination capabilities between
+ tunnel-termination-point and link termination-point.
+ The capability information can be used to compute
+ the tunnel path.";
+ leaf link-tp {
+ type leafref {
+ path "../../../../../nt:termination-point/nt:tp-id";
+ }
+ description
+ "Link termination point.";
+ }
+ } // termination-capability
+ } // te-node-tunnel-termination-capability
+
+ grouping te-path-element {
+ description
+ "A group of attributes defining an element in a TE path
+ such as TE node, TE link, TE atomic resource or label.";
+ uses te-types:explicit-route-subobject;
+ } // te-path-element
+
+ grouping te-termination-point-augment {
+ description
+ "Augmentation for TE termination point.";
+
+ container te {
+ presence "TE support.";
+ description
+ "Indicates TE support.";
+
+ leaf te-tp-id {
+ type te-tp-id;
+ mandatory true;
+ description
+ "An identifier to uniquely identify a TE termination
+ point.";
+ }
+
+ container config {
+ description
+ "Configuration data.";
+ uses te-termination-point-config;
+ } // config
+ container state {
+ config false;
+ description
+ "Operational state data.";
+ uses te-termination-point-config;
+ } // state
+ } // te
+ } // te-termination-point-augment
+
+ grouping te-termination-point-config {
+ description
+ "TE termination point configuration grouping.";
+ uses sch:schedules;
+ } // te-termination-point-config
+
+ grouping te-topologies-augment {
+ description
+ "Augmentation for TE topologies.";
+
+ container te {
+ presence "TE support.";
+ description
+ "Indicates TE support.";
+
+ container templates {
+ description
+ "Configuration parameters for templates used for TE
+ topology.";
+
+ list node-template {
+ if-feature template;
+ key "name";
+ leaf name {
+ type te-template-name;
+ description
+ "The name to identify a TE node template.";
+ }
+ description
+ "The list of TE node templates used to define sharable
+ and reusable TE node attributes.";
+ uses template-attributes;
+ uses te-node-config-attributes-template;
+ } // node-template
+
+ list link-template {
+ if-feature template;
+ key "name";
+ leaf name {
+ type te-template-name;
+ description
+ "The name to identify a TE link template.";
+ }
+ description
+ "The list of TE link templates used to define sharable
+ and reusable TE link attributes.";
+ uses template-attributes;
+ uses te-link-config-attributes;
+ } // link-template
+ } // templates
+ } // te
+ } // te-topologies-augment
+
+ grouping te-topology-augment {
+ description
+ "Augmentation for TE topology.";
+
+ container te {
+ presence "TE support.";
+ description
+ "Indicates TE support.";
+
+ leaf provider-id {
+ type te-global-id;
+ mandatory true;
+ description
+ "An identifier to uniquely identify a provider.";
+ }
+ leaf client-id {
+ type te-global-id;
+ mandatory true;
+ description
+ "An identifier to uniquely identify a client.";
+ }
+ leaf te-topology-id {
+ type te-topology-id;
+ mandatory true;
+ description
+ "It is presumed that a datastore will contain many
+ topologies. To distinguish between topologies it is
+ vital to have UNIQUE topology identifiers.";
+ }
+
+ container config {
+ description
+ "Configuration data.";
+ uses te-topology-config;
+ } // config
+ container state {
+ config false;
+ description
+ "Operational state data.";
+ uses te-topology-config;
+ } // state
+ } // te
+ } // te-topology-augment
+
+ grouping te-topology-config {
+ description
+ "TE topology configuration grouping.";
+ uses sch:schedules;
+ leaf preference {
+ type uint8 {
+ range "1..255";
+ }
+ description
+ "Specifies a preference for this topology. A lower number
+ indicates a higher preference.";
+ }
+ } // te-topology-config
+
+ grouping te-topology-ref {
+ description
+ "References a TE topology.";
+ leaf provider-id-ref {
+ type leafref {
+ path "/nw:networks/nw:network[nw:network-id = "
+ + "current()/../network-id-ref]/tet:te/tet:provider-id";
+ require-instance false;
+ }
+ description
+ "A reference to a provider-id.";
+ }
+ leaf client-id-ref {
+ type leafref {
+ path "/nw:networks/nw:network[nw:network-id = "
+ + "current()/../network-id-ref]/tet:te/tet:client-id";
+ require-instance false;
+ }
+ description
+ "A reference to a client-id.";
+ }
+ leaf te-topology-id-ref {
+ type leafref {
+ path "/nw:networks/nw:network[nw:network-id = "
+ + "current()/../network-id-ref]/tet:te/tet:te-topology-id";
+ require-instance false;
+ }
+ description
+ "A reference to a te-topology-id.";
+ }
+ leaf network-id-ref {
+ type leafref {
+ path "/nw:networks/nw:network/nw:network-id";
+ require-instance false;
+ }
+ description
+ "A reference to a network-id in base ietf-network module.";
+ }
+ } // te-topology-ref
+
+ grouping te-topology-type {
+ description
+ "Identifies the TE topology type.";
+ container te-topology {
+ presence "Indicates TE topology.";
+ description
+ "Its presence identifies the TE topology type.";
+ }
+ } // te-topology-type
+
+ grouping template-attributes {
+ description
+ "Common attributes for all templates.";
+
+ leaf priority {
+ type uint16;
+ description
+ "The preference value to resolve conflicts between different
+ templates. When two or more templates specify values for
+ one configuration attribute, the value from the template
+ with the highest priority is used.";
+ }
+ leaf reference-change-policy {
+ type enumeration {
+ enum no-action {
+ description
+ "When an attribute changes in this template, the
+ configuration node referring to this template does
+ not take any action.";
+ }
+ enum not-allowed {
+ description
+ "When any configuration object has a reference to this
+ template, changing this template is not allowed.";
+ }
+ enum cascade {
+ description
+ "When an attribute changes in this template, the
+ configuration object referring to this template applies
+ the new attribute value to the corresponding
+ configuration.";
+ }
+ }
+ description
+ "This attribute specifies the action taken to a configuration
+ node that has a reference to this template.";
+ }
+ } // template-attributes
+
+ /*
+ * Configuration data nodes
+ */
+ augment "/nw:networks/nw:network/nw:network-types" {
+ description
+ "Introduce new network type for TE topology.";
+ uses te-topology-type;
+ }
+
+ augment "/nw:networks" {
+ description
+ "Augmentation parameters for TE topologies.";
+ uses te-topologies-augment;
+ }
+
+ augment "/nw:networks/nw:network" {
+ when "nw:network-types/te-topology" {
+ description
+ "Augmentation parameters apply only for networks with
+ TE topology type.";
+ }
+ description
+ "Configuration parameters for TE topology.";
+ uses te-topology-augment;
+ }
+
+ augment "/nw:networks/nw:network/nw:node" {
+ when "../nw:network-types/te-topology" {
+ description
+ "Augmentation parameters apply only for networks with
+ TE topology type.";
+ }
+ description
+ "Configuration parameters for TE at node level.";
+ uses te-node-augment;
+ }
+
+ augment "/nw:networks/nw:network/nt:link" {
+ when "../nw:network-types/te-topology" {
+ description
+ "Augmentation parameters apply only for networks with
+ TE topology type.";
+ }
+ description
+ "Configuration parameters for TE at link level";
+ uses te-link-augment;
+ }
+
+ augment "/nw:networks/nw:network/nw:node/"
+ + "nt:termination-point" {
+ when "../../nw:network-types/te-topology" {
+ description
+ "Augmentation parameters apply only for networks with
+ TE topology type.";
+ }
+ description
+ "Configuration parameters for TE at termination point level";
+ uses te-termination-point-augment;
+ }
+
+ /*
+ * Operational state data nodes
+ */
+
+ /*
+ * Notifications
+ */
+ notification te-node-event {
+ description "Notification event for TE node.";
+ leaf event-type {
+ type te-topology-event-type;
+ description "Event type.";
+ }
+ uses nw:node-ref;
+ uses te-topology-type;
+ uses tet:te-node-config-attributes-notification;
+ uses tet:te-node-state-derived-notification;
+ }
+
+ notification te-link-event {
+ description "Notification event for TE link.";
+ leaf event-type {
+ type te-topology-event-type;
+ description "Event type";
+ }
+ uses nt:link-ref;
+ uses te-topology-type;
+ uses tet:te-link-config-attributes;
+ uses tet:te-link-state-derived;
+ }
+
+ augment "/te-link-event/te-link-attributes/underlay" {
+ description "Add state attributes to te-link underlay.";
+ uses te-link-state-underlay-attributes;
+ }
+ }
diff --git a/compiler/plugin/maven/src/test/resources/interfileietf/ietf-te-types.yang b/compiler/plugin/maven/src/test/resources/interfileietf/ietf-te-types.yang
new file mode 100644
index 0000000..9347f26
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/interfileietf/ietf-te-types.yang
@@ -0,0 +1,870 @@
+ module ietf-te-types {
+
+ namespace "urn:ietf:params:xml:ns:yang:ietf-te-types";
+
+ /* Replace with IANA when assigned */
+ prefix "te-types";
+
+ import ietf-inet-types {
+ prefix inet;
+ }
+
+ organization
+ "IETF Traffic Engineering Architecture and Signaling (TEAS)
+ Working Group";
+
+ contact
+ "WG Web: <http://tools.ietf.org/wg/teas/>
+ WG List: <mailto:teas@ietf.org>
+
+ WG Chair: Lou Berger
+ <mailto:lberger@labn.net>
+
+ WG Chair: Vishnu Pavan Beeram
+ <mailto:vbeeram@juniper.net>
+
+ Editor: Tarek Saad
+ <mailto:tsaad@cisco.com>
+
+ Editor: Rakesh Gandhi
+ <mailto:rgandhi@cisco.com>
+
+ Editor: Vishnu Pavan Beeram
+ <mailto:vbeeram@juniper.net>
+
+ Editor: Himanshu Shah
+ <mailto:hshah@ciena.com>
+
+ Editor: Xufeng Liu
+ <mailto:xufeng.liu@ericsson.com>
+
+ Editor: Xia Chen
+ <mailto:jescia.chenxia@huawei.com>
+
+ Editor: Raqib Jones
+ <mailto:raqib@Brocade.com>
+
+ Editor: Bin Wen
+ <mailto:Bin_Wen@cable.comcast.com>";
+
+ description
+ "This module contains a collection of generally
+ useful TE specific YANG data type defintions.";
+
+ revision 2016-03-20 {
+ description "Latest revision of TE generic types";
+ reference "RFC3209";
+ }
+
+ identity tunnel-type {
+ description
+ "Base identity from which specific tunnel types are
+ derived.";
+ }
+
+ identity tunnel-p2p {
+ base tunnel-type;
+ description
+ "TE point-to-point tunnel type.";
+ }
+
+ identity tunnel-p2mp {
+ base tunnel-type;
+ description
+ "TE point-to-multipoint tunnel type.";
+ }
+
+ identity state-type {
+ description
+ "Base identity for TE states";
+ }
+
+ identity state-up {
+ base state-type;
+ description
+ "State up";
+ }
+
+ identity state-down {
+ base state-type;
+ description
+ "State down";
+ }
+
+ identity lsp-prot-type {
+ description
+ "Base identity from which LSP protection types are
+ derived.";
+ }
+
+ identity lsp-prot-unprotected {
+ description
+ "LSP protection 'Unprotected'";
+ reference "RFC4872";
+ }
+
+ identity lsp-prot-reroute-extra {
+ description
+ "LSP protection '(Full) Rerouting'";
+ reference "RFC4872";
+ }
+
+ identity lsp-prot-reroute {
+ description
+ "LSP protection 'Rerouting without Extra-Traffic'";
+ reference "RFC4872";
+ }
+
+ identity lsp-prot-1-for-n {
+ description
+ "LSP protection '1:N Protection with Extra-Traffic'";
+ reference "RFC4872";
+ }
+
+ identity lsp-prot-unidir-1-to-1 {
+ description
+ "LSP protection '1+1 Unidirectional Protection'";
+ reference "RFC4872";
+ }
+
+ identity lsp-prot-bidir-1-to-1 {
+ description
+ "LSP protection '1+1 Bidirectional Protection'";
+ reference "RFC4872";
+ }
+
+ identity switching-capabilities {
+ description
+ "Base identity for interface switching capabilities";
+ }
+
+ identity switching-psc1 {
+ base switching-capabilities;
+ description
+ "Packet-Switch Capable-1 (PSC-1)";
+ }
+
+ identity switching-evpl {
+ base switching-capabilities;
+ description
+ "Ethernet Virtual Private Line (EVPL)";
+ }
+
+ identity switching-l2sc {
+ base switching-capabilities;
+ description
+ "Layer-2 Switch Capable (L2SC)";
+ }
+
+ identity switching-tdm {
+ base switching-capabilities;
+ description
+ "Time-Division-Multiplex Capable (TDM)";
+ }
+
+ identity switching-otn {
+ base switching-capabilities;
+ description
+ "OTN-TDM capable";
+ }
+
+ identity switching-dcsc {
+ base switching-capabilities;
+ description
+ "Data Channel Switching Capable (DCSC)";
+ }
+ identity switching-lsc {
+ base switching-capabilities;
+ description
+ "Lambda-Switch Capable (LSC)";
+ }
+
+ identity switching-fsc {
+ base switching-capabilities;
+ description
+ "Fiber-Switch Capable (FSC)";
+ }
+
+ identity lsp-encoding-types {
+ description
+ "Base identity for encoding types";
+ }
+
+ identity lsp-encoding-packet {
+ base lsp-encoding-types;
+ description
+ "Packet LSP encoding";
+ }
+
+ identity lsp-encoding-ethernet {
+ base lsp-encoding-types;
+ description
+ "Ethernet LSP encoding";
+ }
+
+ identity lsp-encoding-pdh {
+ base lsp-encoding-types;
+ description
+ "ANSI/ETSI LSP encoding";
+ }
+
+ identity lsp-encoding-sdh {
+ base lsp-encoding-types;
+ description
+ "SDH ITU-T G.707 / SONET ANSI T1.105 LSP encoding";
+ }
+
+ identity lsp-encoding-digital-wrapper {
+ base lsp-encoding-types;
+ description
+ "Digital Wrapper LSP encoding";
+ }
+
+ identity lsp-encoding-lambda {
+ base lsp-encoding-types;
+ description
+ "Lambda (photonic) LSP encoding";
+ }
+
+ identity lsp-encoding-fiber {
+ base lsp-encoding-types;
+ description
+ "Fiber LSP encoding";
+ }
+
+ identity lsp-encoding-fiber-channel {
+ base lsp-encoding-types;
+ description
+ "FiberChannel LSP encoding";
+ }
+
+ identity lsp-encoding-oduk {
+ base lsp-encoding-types;
+ description
+ "G.709 ODUk (Digital Path)LSP encoding";
+ }
+
+ identity lsp-encoding-optical-channel {
+ base lsp-encoding-types;
+ description
+ "Line (e.g., 8B/10B) LSP encoding";
+ }
+
+ identity lsp-encoding-line {
+ base lsp-encoding-types;
+ description
+ "Line (e.g., 8B/10B) LSP encoding";
+ }
+
+ /* TE basic features */
+ feature p2mp-te {
+ description
+ "Indicates support for P2MP-TE";
+ }
+
+ feature frr-te {
+ description
+ "Indicates support for TE FastReroute (FRR)";
+ }
+
+ feature extended-admin-groups {
+ description
+ "Indicates support for TE link extended admin
+ groups.";
+ }
+
+ feature named-path-affinities {
+ description
+ "Indicates support for named path affinities";
+ }
+
+ feature named-extended-admin-groups {
+ description
+ "Indicates support for named extended admin groups";
+ }
+
+ feature named-srlg-groups {
+ description
+ "Indicates support for named SRLG groups";
+ }
+
+ feature named-path-constraints {
+ description
+ "Indicates support for named path constraints";
+ }
+
+ grouping explicit-route-subobject {
+ description
+ "The explicit route subobject grouping";
+ choice type {
+ description
+ "The explicit route subobject type";
+ case ipv4-address {
+ description
+ "IPv4 address explicit route subobject";
+ leaf v4-address {
+ type inet:ipv4-address;
+ description
+ "An IPv4 address. This address is
+ treated as a prefix based on the
+ prefix length value below. Bits beyond
+ the prefix are ignored on receipt and
+ SHOULD be set to zero on transmission.";
+ }
+ leaf v4-prefix-length {
+ type uint8;
+ description
+ "Length in bits of the IPv4 prefix";
+ }
+ leaf v4-loose {
+ type boolean;
+ description
+ "Describes whether the object is loose
+ if set, or otherwise strict";
+ }
+ }
+ case ipv6-address {
+ description
+ "IPv6 address Explicit Route Object";
+ leaf v6-address {
+ type inet:ipv6-address;
+ description
+ "An IPv6 address. This address is
+ treated as a prefix based on the
+ prefix length value below. Bits
+ beyond the prefix are ignored on
+ receipt and SHOULD be set to zero
+ on transmission.";
+ }
+ leaf v6-prefix-length {
+ type uint8;
+ description
+ "Length in bits of the IPv4 prefix";
+ }
+ leaf v6-loose {
+ type boolean;
+ description
+ "Describes whether the object is loose
+ if set, or otherwise strict";
+ }
+ }
+ case as-number {
+ leaf as-number {
+ type uint16;
+ description "AS number";
+ }
+ description
+ "Autonomous System explicit route subobject";
+ }
+ case unnumbered-link {
+ leaf router-id {
+ type inet:ip-address;
+ description
+ "A router-id address";
+ }
+ leaf interface-id {
+ type uint32;
+ description "The interface identifier";
+ }
+ description
+ "Unnumbered link explicit route subobject";
+ reference
+ "RFC3477: Signalling Unnumbered Links in
+ RSVP-TE";
+ }
+ case label {
+ leaf value {
+ type uint32;
+ description "the label value";
+ }
+ description
+ "The Label ERO subobject";
+ }
+ /* AS domain sequence..? */
+ }
+ }
+
+ grouping record-route-subobject {
+ description
+ "The record route subobject grouping";
+ choice type {
+ description
+ "The record route subobject type";
+ case ipv4-address {
+ leaf v4-address {
+ type inet:ipv4-address;
+ description
+ "An IPv4 address. This address is
+ treated as a prefix based on the prefix
+ length value below. Bits beyond the
+ prefix are ignored on receipt and
+ SHOULD be set to zero on transmission.";
+ }
+ leaf v4-prefix-length {
+ type uint8;
+ description
+ "Length in bits of the IPv4 prefix";
+ }
+ leaf v4-flags {
+ type uint8;
+ description
+ "IPv4 address sub-object flags";
+ reference "RFC3209";
+ }
+ }
+ case ipv6-address {
+ leaf v6-address {
+ type inet:ipv6-address;
+ description
+ "An IPv6 address. This address is
+ treated as a prefix based on the
+ prefix length value below. Bits
+ beyond the prefix are ignored on
+ receipt and SHOULD be set to zero
+ on transmission.";
+ }
+ leaf v6-prefix-length {
+ type uint8;
+ description
+ "Length in bits of the IPv4 prefix";
+ }
+ leaf v6-flags {
+ type uint8;
+ description
+ "IPv6 address sub-object flags";
+ reference "RFC3209";
+ }
+ }
+ case label {
+ leaf value {
+ type uint32;
+ description "the label value";
+ }
+ leaf flags {
+ type uint8;
+ description
+ "Label sub-object flags";
+ reference "RFC3209";
+ }
+ description
+ "The Label ERO subobject";
+ }
+ }
+ }
+
+ identity route-usage-type {
+ description
+ "Base identity for route usage";
+ }
+
+ identity route-include-ero {
+ base route-usage-type;
+ description
+ "Include ERO from route";
+ }
+
+ identity route-exclude-ero {
+ base route-usage-type;
+ description
+ "Exclude ERO from route";
+ }
+
+ identity route-exclude-srlg {
+ base route-usage-type;
+ description
+ "Exclude SRLG from route";
+ }
+
+ identity path-metric-type {
+ description
+ "Base identity for path metric type";
+ }
+
+ identity path-metric-te {
+ base path-metric-type;
+ description
+ "TE path metric";
+ }
+
+ identity path-metric-igp {
+ base path-metric-type;
+ description
+ "IGP path metric";
+ }
+
+ identity path-tiebreaker-type {
+ description
+ "Base identity for path tie-breaker type";
+ }
+
+ identity path-tiebreaker-minfill {
+ base path-tiebreaker-type;
+ description
+ "Min-Fill LSP path placement";
+ }
+
+ identity path-tiebreaker-maxfill {
+ base path-tiebreaker-type;
+ description
+ "Max-Fill LSP path placement";
+ }
+
+ identity path-tiebreaker-randoom {
+ base path-tiebreaker-type;
+ description
+ "Random LSP path placement";
+ }
+
+ identity bidir-provisioning-mode {
+ description
+ "Base identity for bidirectional provisioning
+ mode.";
+ }
+
+ identity bidir-provisioning-single-sided {
+ base bidir-provisioning-mode;
+ description
+ "Single-sided bidirectional provioning mode";
+ }
+
+ identity bidir-provisioning-double-sided {
+ base bidir-provisioning-mode;
+ description
+ "Double-sided bidirectional provioning mode";
+ }
+
+ identity bidir-association-type {
+ description
+ "Base identity for bidirectional association type";
+ }
+
+ identity bidir-assoc-corouted {
+ base bidir-association-type;
+ description
+ "Co-routed bidirectional association type";
+ }
+
+ identity bidir-assoc-non-corouted {
+ base bidir-association-type;
+ description
+ "Non co-routed bidirectional association type";
+ }
+
+ identity resource-affinities-type {
+ description
+ "Base identity for resource affinities";
+ }
+
+ identity resource-aff-include-all {
+ base resource-affinities-type;
+ description
+ "The set of attribute filters associated with a
+ tunnel all of which must be present for a link
+ to be acceptable";
+ }
+
+ identity resource-aff-include-any {
+ base resource-affinities-type;
+ description
+ "The set of attribute filters associated with a
+ tunnel any of which must be present for a link
+ to be acceptable";
+ }
+
+ identity resource-aff-exclude-any {
+ base resource-affinities-type;
+ description
+ "The set of attribute filters associated with a
+ tunnel any of which renders a link unacceptable";
+ }
+
+ typedef admin-group {
+ type binary {
+ length 32;
+ }
+ description
+ "Administrative group/Resource class/Color.";
+ }
+
+ typedef extended-admin-group {
+ type binary;
+ description
+ "Extended administrative group/Resource class/Color.";
+ }
+
+ typedef admin-groups {
+ type union {
+ type admin-group;
+ type extended-admin-group;
+ }
+ description "TE administrative group derived type";
+ }
+
+ typedef srlg {
+ type uint32;
+ description "SRLG type";
+ }
+
+ identity path-computation-srlg-type {
+ description
+ "Base identity for SRLG path computation";
+ }
+
+ identity srlg-ignore {
+ base path-computation-srlg-type;
+ description
+ "Ignores SRLGs in path computation";
+ }
+
+ identity srlg-strict {
+ base path-computation-srlg-type;
+ description
+ "Include strict SRLG check in path computation";
+ }
+
+ identity srlg-preferred {
+ base path-computation-srlg-type;
+ description
+ "Include preferred SRLG check in path computation";
+ }
+
+ identity srlg-weighted {
+ base path-computation-srlg-type;
+ description
+ "Include weighted SRLG check in path computation";
+ }
+
+ typedef te-metric {
+ type uint32;
+ description
+ "TE link metric";
+ }
+
+ typedef topology-id {
+ type string {
+ pattern '/?([a-zA-Z0-9\-_.]+)(/[a-zA-Z0-9\-_.]+)*';
+ }
+ description
+ "An identifier for a topology.";
+ }
+
+ /**
+ * TE tunnel generic groupings
+ **/
+
+ /* Tunnel path selection parameters */
+ grouping tunnel-path-selection {
+ description
+ "Tunnel path selection properties grouping";
+ container path-selection {
+ description
+ "Tunnel path selection properties container";
+ leaf topology {
+ type te-types:topology-id;
+ description
+ "The tunnel path is computed using the specific
+ topology identified by this identifier";
+ }
+ leaf cost-limit {
+ type uint32 {
+ range "1..4294967295";
+ }
+ description
+ "The tunnel path cost limit.";
+ }
+ leaf hop-limit {
+ type uint8 {
+ range "1..255";
+ }
+ description
+ "The tunnel path hop limit.";
+ }
+ leaf metric-type {
+ type identityref {
+ base path-metric-type;
+ }
+ default path-metric-te;
+ description
+ "The tunnel path metric type.";
+ }
+ leaf tiebreaker-type {
+ type identityref {
+ base path-tiebreaker-type;
+ }
+ default path-tiebreaker-maxfill;
+ description
+ "The tunnel path computation tie breakers.";
+ }
+ leaf ignore-overload {
+ type boolean;
+ description
+ "The tunnel path can traverse overloaded node.";
+ }
+ uses tunnel-path-affinities;
+ uses tunnel-path-srlgs;
+ }
+ }
+
+ grouping tunnel-path-affinities {
+ description
+ "Path affinities grouping";
+ container tunnel-path-affinities {
+ if-feature named-path-affinities;
+ description
+ "Path affinities container";
+ choice style {
+ description
+ "Path affinities representation style";
+ case values {
+ leaf value {
+ type uint32 {
+ range "0..4294967295";
+ }
+ description
+ "Affinity value";
+ }
+ leaf mask {
+ type uint32 {
+ range "0..4294967295";
+ }
+ description
+ "Affinity mask";
+ }
+ }
+ case named {
+ list constraints {
+ key "usage";
+ leaf usage {
+ type identityref {
+ base resource-affinities-type;
+ }
+ description "Affinities usage";
+ }
+ container constraint {
+ description
+ "Container for named affinities";
+ list affinity-names {
+ key "name";
+ leaf name {
+ type string;
+ description
+ "Affinity name";
+ }
+ description
+ "List of named affinities";
+ }
+ }
+ description
+ "List of named affinity constraints";
+ }
+ }
+ }
+ }
+ }
+
+ grouping tunnel-path-srlgs {
+ description
+ "Path SRLG properties grouping";
+ container tunnel-path-srlgs {
+ description
+ "Path SRLG properties container";
+ choice style {
+ description
+ "Type of SRLG representation";
+ case values {
+ leaf usage {
+ type identityref {
+ base route-exclude-srlg;
+ }
+ description "SRLG usage";
+ }
+ leaf-list values {
+ type te-types:srlg;
+ description "SRLG value";
+ }
+ }
+ case named {
+ list constraints {
+ key "usage";
+ leaf usage {
+ type identityref {
+ base route-exclude-srlg;
+ }
+ description "SRLG usage";
+ }
+ container constraint {
+ description
+ "Container for named SRLG list";
+ list srlg-names {
+ key "name";
+ leaf name {
+ type string;
+ description
+ "The SRLG name";
+ }
+ description
+ "List named SRLGs";
+ }
+ }
+ description
+ "List of named SRLG constraints";
+ }
+ }
+ }
+ }
+ }
+
+ grouping tunnel-bidir-assoc-properties {
+ description
+ "TE tunnel associated bidirectional properties
+ grouping";
+ container bidirectional {
+ description
+ "TE tunnel associated bidirectional attributes.";
+ container association {
+ description
+ "Tunnel bidirectional association properties";
+ leaf id {
+ type uint16;
+ description
+ "The TE tunnel association identifier.";
+ }
+ leaf source {
+ type inet:ip-address;
+ description
+ "The TE tunnel association source.";
+ }
+ leaf global-source {
+ type inet:ip-address;
+ description
+ "The TE tunnel association global
+ source.";
+ }
+ leaf type {
+ type identityref {
+ base bidir-association-type;
+ }
+ default bidir-assoc-non-corouted;
+ description
+ "The TE tunnel association type.";
+ }
+ leaf provisioing {
+ type identityref {
+ base bidir-provisioning-mode;
+ }
+ description
+ "Describes the provisioning model of the
+ associated bidirectional LSP";
+ reference
+ "draft-ietf-teas-mpls-tp-rsvpte-ext-
+ associated-lsp, section-3.2";
+ }
+ }
+ }
+ }
+ /*** End of TE tunnel groupings ***/
+
+ /**
+ * TE interface generic groupings
+ **/
+ }
diff --git a/compiler/plugin/maven/src/test/resources/interfileietf/ietf-yang-types.yang b/compiler/plugin/maven/src/test/resources/interfileietf/ietf-yang-types.yang
new file mode 100644
index 0000000..9a543fa
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/interfileietf/ietf-yang-types.yang
@@ -0,0 +1,490 @@
+ module ietf-yang-types {
+
+ yang-version 1;
+
+ namespace
+ "urn:ietf:params:xml:ns:yang:ietf-yang-types";
+
+ prefix yang;
+
+ organization
+ "IETF NETMOD (NETCONF Data Modeling Language) Working Group";
+
+ contact
+ "WG Web: <http://tools.ietf.org/wg/netmod/>
+ WG List: <mailto:netmod@ietf.org>
+
+ WG Chair: David Kessens
+ <mailto:david.kessens@nsn.com>
+
+ WG Chair: Juergen Schoenwaelder
+ <mailto:j.schoenwaelder@jacobs-university.de>
+
+ Editor: Juergen Schoenwaelder
+ <mailto:j.schoenwaelder@jacobs-university.de>";
+
+ description
+ "This module contains a collection of generally useful derived
+ YANG data types.
+
+ Copyright (c) 2013 IETF Trust and the persons identified as
+ authors of the code. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or
+ without modification, is permitted pursuant to, and subject
+ to the license terms contained in, the Simplified BSD License
+ set forth in Section 4.c of the IETF Trust's Legal Provisions
+ Relating to IETF Documents
+ (http://trustee.ietf.org/license-info).
+
+ This version of this YANG module is part of RFC 6991; see
+ the RFC itself for full legal notices.";
+
+ revision "2013-07-15" {
+ description
+ "This revision adds the following new data types:
+ - yang-identifier
+ - hex-string
+ - uuid
+ - dotted-quad";
+ reference
+ "RFC 6991: Common YANG Data Types";
+
+ }
+
+ revision "2010-09-24" {
+ description "Initial revision.";
+ reference
+ "RFC 6021: Common YANG Data Types";
+
+ }
+
+
+ typedef counter32 {
+ type uint32;
+ description
+ "The counter32 type represents a non-negative integer
+ that monotonically increases until it reaches a
+ maximum value of 2^32-1 (4294967295 decimal), when it
+ wraps around and starts increasing again from zero.
+
+ Counters have no defined 'initial' value, and thus, a
+ single value of a counter has (in general) no information
+ content. Discontinuities in the monotonically increasing
+ value normally occur at re-initialization of the
+ management system, and at other times as specified in the
+ description of a schema node using this type. If such
+ other times can occur, for example, the creation of
+ a schema node of type counter32 at times other than
+ re-initialization, then a corresponding schema node
+ should be defined, with an appropriate type, to indicate
+ the last discontinuity.
+
+ The counter32 type should not be used for configuration
+ schema nodes. A default statement SHOULD NOT be used in
+ combination with the type counter32.
+
+ In the value set and its semantics, this type is equivalent
+ to the Counter32 type of the SMIv2.";
+ reference
+ "RFC 2578: Structure of Management Information Version 2
+ (SMIv2)";
+
+ }
+
+ typedef zero-based-counter32 {
+ type counter32;
+ default "0";
+ description
+ "The zero-based-counter32 type represents a counter32
+ that has the defined 'initial' value zero.
+
+ A schema node of this type will be set to zero (0) on creation
+ and will thereafter increase monotonically until it reaches
+ a maximum value of 2^32-1 (4294967295 decimal), when it
+ wraps around and starts increasing again from zero.
+
+ Provided that an application discovers a new schema node
+ of this type within the minimum time to wrap, it can use the
+ 'initial' value as a delta. It is important for a management
+ station to be aware of this minimum time and the actual time
+ between polls, and to discard data if the actual time is too
+ long or there is no defined minimum time.
+
+ In the value set and its semantics, this type is equivalent
+ to the ZeroBasedCounter32 textual convention of the SMIv2.";
+ reference
+ "RFC 4502: Remote Network Monitoring Management Information
+ Base Version 2";
+
+ }
+
+ typedef counter64 {
+ type uint64;
+ description
+ "The counter64 type represents a non-negative integer
+ that monotonically increases until it reaches a
+ maximum value of 2^64-1 (18446744073709551615 decimal),
+ when it wraps around and starts increasing again from zero.
+
+ Counters have no defined 'initial' value, and thus, a
+ single value of a counter has (in general) no information
+ content. Discontinuities in the monotonically increasing
+ value normally occur at re-initialization of the
+ management system, and at other times as specified in the
+ description of a schema node using this type. If such
+ other times can occur, for example, the creation of
+ a schema node of type counter64 at times other than
+ re-initialization, then a corresponding schema node
+ should be defined, with an appropriate type, to indicate
+ the last discontinuity.
+
+ The counter64 type should not be used for configuration
+ schema nodes. A default statement SHOULD NOT be used in
+ combination with the type counter64.
+
+ In the value set and its semantics, this type is equivalent
+ to the Counter64 type of the SMIv2.";
+ reference
+ "RFC 2578: Structure of Management Information Version 2
+ (SMIv2)";
+
+ }
+
+ typedef zero-based-counter64 {
+ type counter64;
+ default "0";
+ description
+ "The zero-based-counter64 type represents a counter64 that
+ has the defined 'initial' value zero.
+
+
+
+
+ A schema node of this type will be set to zero (0) on creation
+ and will thereafter increase monotonically until it reaches
+ a maximum value of 2^64-1 (18446744073709551615 decimal),
+ when it wraps around and starts increasing again from zero.
+
+ Provided that an application discovers a new schema node
+ of this type within the minimum time to wrap, it can use the
+ 'initial' value as a delta. It is important for a management
+ station to be aware of this minimum time and the actual time
+ between polls, and to discard data if the actual time is too
+ long or there is no defined minimum time.
+
+ In the value set and its semantics, this type is equivalent
+ to the ZeroBasedCounter64 textual convention of the SMIv2.";
+ reference
+ "RFC 2856: Textual Conventions for Additional High Capacity
+ Data Types";
+
+ }
+
+ typedef gauge32 {
+ type uint32;
+ description
+ "The gauge32 type represents a non-negative integer, which
+ may increase or decrease, but shall never exceed a maximum
+ value, nor fall below a minimum value. The maximum value
+ cannot be greater than 2^32-1 (4294967295 decimal), and
+ the minimum value cannot be smaller than 0. The value of
+ a gauge32 has its maximum value whenever the information
+ being modeled is greater than or equal to its maximum
+ value, and has its minimum value whenever the information
+ being modeled is smaller than or equal to its minimum value.
+ If the information being modeled subsequently decreases
+ below (increases above) the maximum (minimum) value, the
+ gauge32 also decreases (increases).
+
+ In the value set and its semantics, this type is equivalent
+ to the Gauge32 type of the SMIv2.";
+ reference
+ "RFC 2578: Structure of Management Information Version 2
+ (SMIv2)";
+
+ }
+
+ typedef gauge64 {
+ type uint64;
+ description
+ "The gauge64 type represents a non-negative integer, which
+ may increase or decrease, but shall never exceed a maximum
+ value, nor fall below a minimum value. The maximum value
+ cannot be greater than 2^64-1 (18446744073709551615), and
+ the minimum value cannot be smaller than 0. The value of
+ a gauge64 has its maximum value whenever the information
+ being modeled is greater than or equal to its maximum
+ value, and has its minimum value whenever the information
+ being modeled is smaller than or equal to its minimum value.
+ If the information being modeled subsequently decreases
+ below (increases above) the maximum (minimum) value, the
+ gauge64 also decreases (increases).
+
+ In the value set and its semantics, this type is equivalent
+ to the CounterBasedGauge64 SMIv2 textual convention defined
+ in RFC 2856";
+ reference
+ "RFC 2856: Textual Conventions for Additional High Capacity
+ Data Types";
+
+ }
+
+ typedef object-identifier {
+ type string {
+ pattern
+ '(([0-1](\.[1-3]?[0-9]))|(2\.(0|([1-9]\d*))))(\.(0|([1-9]\d*)))*';
+ }
+ description
+ "The object-identifier type represents administratively
+ assigned names in a registration-hierarchical-name tree.
+
+ Values of this type are denoted as a sequence of numerical
+ non-negative sub-identifier values. Each sub-identifier
+ value MUST NOT exceed 2^32-1 (4294967295). Sub-identifiers
+ are separated by single dots and without any intermediate
+ whitespace.
+
+ The ASN.1 standard restricts the value space of the first
+ sub-identifier to 0, 1, or 2. Furthermore, the value space
+ of the second sub-identifier is restricted to the range
+ 0 to 39 if the first sub-identifier is 0 or 1. Finally,
+ the ASN.1 standard requires that an object identifier
+ has always at least two sub-identifiers. The pattern
+ captures these restrictions.
+
+ Although the number of sub-identifiers is not limited,
+ module designers should realize that there may be
+ implementations that stick with the SMIv2 limit of 128
+ sub-identifiers.
+
+ This type is a superset of the SMIv2 OBJECT IDENTIFIER type
+ since it is not restricted to 128 sub-identifiers. Hence,
+ this type SHOULD NOT be used to represent the SMIv2 OBJECT
+ IDENTIFIER type; the object-identifier-128 type SHOULD be
+ used instead.";
+ reference
+ "ISO9834-1: Information technology -- Open Systems
+ Interconnection -- Procedures for the operation of OSI
+ Registration Authorities: General procedures and top
+ arcs of the ASN.1 Object Identifier tree";
+
+ }
+
+ typedef object-identifier-128 {
+ type object-identifier {
+ pattern '\d*(\.\d*){1,127}';
+ }
+ description
+ "This type represents object-identifiers restricted to 128
+ sub-identifiers.
+
+ In the value set and its semantics, this type is equivalent
+ to the OBJECT IDENTIFIER type of the SMIv2.";
+ reference
+ "RFC 2578: Structure of Management Information Version 2
+ (SMIv2)";
+
+ }
+
+ typedef yang-identifier {
+ type string {
+ length "1..max";
+ pattern '[a-zA-Z_][a-zA-Z0-9\-_.]*';
+ pattern
+ '.|..|[^xX].*|.[^mM].*|..[^lL].*';
+ }
+ description
+ "A YANG identifier string as defined by the 'identifier'
+ rule in Section 12 of RFC 6020. An identifier must
+ start with an alphabetic character or an underscore
+ followed by an arbitrary sequence of alphabetic or
+ numeric characters, underscores, hyphens, or dots.
+
+ A YANG identifier MUST NOT start with any possible
+ combination of the lowercase or uppercase character
+ sequence 'xml'.";
+ reference
+ "RFC 6020: YANG - A Data Modeling Language for the Network
+ Configuration Protocol (NETCONF)";
+
+ }
+
+ typedef date-and-time {
+ type string {
+ pattern
+ '\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[\+\-]\d{2}:\d{2})';
+ }
+ description
+ "The date-and-time type is a profile of the ISO 8601
+ standard for representation of dates and times using the
+ Gregorian calendar. The profile is defined by the
+ date-time production in Section 5.6 of RFC 3339.
+
+ The date-and-time type is compatible with the dateTime XML
+ schema type with the following notable exceptions:
+
+ (a) The date-and-time type does not allow negative years.
+
+ (b) The date-and-time time-offset -00:00 indicates an unknown
+ time zone (see RFC 3339) while -00:00 and +00:00 and Z
+ all represent the same time zone in dateTime.
+
+ (c) The canonical format (see below) of data-and-time values
+ differs from the canonical format used by the dateTime XML
+ schema type, which requires all times to be in UTC using
+ the time-offset 'Z'.
+
+ This type is not equivalent to the DateAndTime textual
+ convention of the SMIv2 since RFC 3339 uses a different
+ separator between full-date and full-time and provides
+ higher resolution of time-secfrac.
+
+ The canonical format for date-and-time values with a known time
+ zone uses a numeric time zone offset that is calculated using
+ the device's configured known offset to UTC time. A change of
+ the device's offset to UTC time will cause date-and-time values
+ to change accordingly. Such changes might happen periodically
+ in case a server follows automatically daylight saving time
+ (DST) time zone offset changes. The canonical format for
+ date-and-time values with an unknown time zone (usually
+ referring to the notion of local time) uses the time-offset
+ -00:00.";
+ reference
+ "RFC 3339: Date and Time on the Internet: Timestamps
+ RFC 2579: Textual Conventions for SMIv2
+ XSD-TYPES: XML Schema Part 2: Datatypes Second Edition";
+
+ }
+
+ typedef timeticks {
+ type uint32;
+ description
+ "The timeticks type represents a non-negative integer that
+ represents the time, modulo 2^32 (4294967296 decimal), in
+ hundredths of a second between two epochs. When a schema
+ node is defined that uses this type, the description of
+ the schema node identifies both of the reference epochs.
+
+ In the value set and its semantics, this type is equivalent
+ to the TimeTicks type of the SMIv2.";
+ reference
+ "RFC 2578: Structure of Management Information Version 2
+ (SMIv2)";
+
+ }
+
+ typedef timestamp {
+ type timeticks;
+ description
+ "The timestamp type represents the value of an associated
+ timeticks schema node at which a specific occurrence
+ happened. The specific occurrence must be defined in the
+ description of any schema node defined using this type. When
+ the specific occurrence occurred prior to the last time the
+ associated timeticks attribute was zero, then the timestamp
+ value is zero. Note that this requires all timestamp values
+ to be reset to zero when the value of the associated timeticks
+ attribute reaches 497+ days and wraps around to zero.
+
+ The associated timeticks schema node must be specified
+ in the description of any schema node using this type.
+
+ In the value set and its semantics, this type is equivalent
+ to the TimeStamp textual convention of the SMIv2.";
+ reference
+ "RFC 2579: Textual Conventions for SMIv2";
+
+ }
+
+ typedef phys-address {
+ type string {
+ pattern
+ '([0-9a-fA-F]{2}(:[0-9a-fA-F]{2})*)?';
+ }
+ description
+ "Represents media- or physical-level addresses represented
+ as a sequence octets, each octet represented by two hexadecimal
+ numbers. Octets are separated by colons. The canonical
+ representation uses lowercase characters.
+
+ In the value set and its semantics, this type is equivalent
+ to the PhysAddress textual convention of the SMIv2.";
+ reference
+ "RFC 2579: Textual Conventions for SMIv2";
+
+ }
+
+ typedef mac-address {
+ type string {
+ pattern
+ '[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}';
+ }
+ description
+ "The mac-address type represents an IEEE 802 MAC address.
+ The canonical representation uses lowercase characters.
+
+ In the value set and its semantics, this type is equivalent
+ to the MacAddress textual convention of the SMIv2.";
+ reference
+ "IEEE 802: IEEE Standard for Local and Metropolitan Area
+ Networks: Overview and Architecture
+ RFC 2579: Textual Conventions for SMIv2";
+
+ }
+
+ typedef xpath1.0 {
+ type string;
+ description
+ "This type represents an XPATH 1.0 expression.
+
+ When a schema node is defined that uses this type, the
+ description of the schema node MUST specify the XPath
+ context in which the XPath expression is evaluated.";
+ reference
+ "XPATH: XML Path Language (XPath) Version 1.0";
+
+ }
+
+ typedef hex-string {
+ type string {
+ pattern
+ '([0-9a-fA-F]{2}(:[0-9a-fA-F]{2})*)?';
+ }
+ description
+ "A hexadecimal string with octets represented as hex digits
+ separated by colons. The canonical representation uses
+ lowercase characters.";
+ }
+
+ typedef uuid {
+ type string {
+ pattern
+ '[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}';
+ }
+ description
+ "A Universally Unique IDentifier in the string representation
+ defined in RFC 4122. The canonical representation uses
+ lowercase characters.
+
+ The following is an example of a UUID in string representation:
+ f81d4fae-7dec-11d0-a765-00a0c91e6bf6
+ ";
+ reference
+ "RFC 4122: A Universally Unique IDentifier (UUID) URN
+ Namespace";
+
+ }
+
+ typedef dotted-quad {
+ type string {
+ pattern
+ '(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])';
+ }
+ description
+ "An unsigned 32-bit number expressed in the dotted-quad
+ notation, i.e., four octets written as decimal numbers
+ and separated with the '.' (full stop) character.";
+ }
+ } // module ietf-yang-types
+
diff --git a/compiler/plugin/maven/src/test/resources/interfilepriority/module1.yang b/compiler/plugin/maven/src/test/resources/interfilepriority/module1.yang
new file mode 100644
index 0000000..9a21b03
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/interfilepriority/module1.yang
@@ -0,0 +1,14 @@
+module module1 {
+ yang-version 1;
+ namespace "http://huawei.com";
+ prefix Ant;
+ import module2 {
+ prefix p;
+ }
+ leaf invalid-interval {
+ type p:hello;
+ }
+ typedef hello {
+ type string;
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/interfilepriority/module2.yang b/compiler/plugin/maven/src/test/resources/interfilepriority/module2.yang
new file mode 100644
index 0000000..0a3bdad
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/interfilepriority/module2.yang
@@ -0,0 +1,8 @@
+module module2 {
+ yang-version 1;
+ namespace "http://huawei.com";
+ prefix Ant2;
+ typedef hello {
+ type string;
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/interfilepriority/module3.yang b/compiler/plugin/maven/src/test/resources/interfilepriority/module3.yang
new file mode 100644
index 0000000..948c797
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/interfilepriority/module3.yang
@@ -0,0 +1,8 @@
+module module3 {
+ yang-version 1;
+ namespace "http://huawei.com";
+ prefix Ant;
+ import module1 {
+ prefix p;
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/interfilepriority/module4.yang b/compiler/plugin/maven/src/test/resources/interfilepriority/module4.yang
new file mode 100644
index 0000000..df6f8b2
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/interfilepriority/module4.yang
@@ -0,0 +1,8 @@
+module module4 {
+ yang-version 1;
+ namespace "http://huawei.com";
+ prefix Ant;
+ import module3 {
+ prefix p;
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/interfiletype/module1.yang b/compiler/plugin/maven/src/test/resources/interfiletype/module1.yang
new file mode 100644
index 0000000..3c60bd6
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/interfiletype/module1.yang
@@ -0,0 +1,14 @@
+module module1 {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ import module2 {
+ prefix p;
+ }
+ leaf invalid-interval {
+ type p:hello;
+ }
+ typedef hello {
+ type string;
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/interfiletype/module2.yang b/compiler/plugin/maven/src/test/resources/interfiletype/module2.yang
new file mode 100644
index 0000000..6784c45
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/interfiletype/module2.yang
@@ -0,0 +1,8 @@
+module module2 {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant2;
+ typedef hello {
+ type string;
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/interfiletypewithinclude/module1.yang b/compiler/plugin/maven/src/test/resources/interfiletypewithinclude/module1.yang
new file mode 100644
index 0000000..d1d4db3
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/interfiletypewithinclude/module1.yang
@@ -0,0 +1,9 @@
+module module1 {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ include module2;
+ leaf invalid-interval {
+ type hello;
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/interfiletypewithinclude/module2.yang b/compiler/plugin/maven/src/test/resources/interfiletypewithinclude/module2.yang
new file mode 100644
index 0000000..8e47100
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/interfiletypewithinclude/module2.yang
@@ -0,0 +1,9 @@
+submodule module2 {
+ yang-version 1;
+ belongs-to module1 {
+ prefix "module1";
+ }
+ typedef hello {
+ type string;
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/interfiletypewithrevision/module1.yang b/compiler/plugin/maven/src/test/resources/interfiletypewithrevision/module1.yang
new file mode 100644
index 0000000..180511d
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/interfiletypewithrevision/module1.yang
@@ -0,0 +1,15 @@
+module module1 {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ import module2 {
+ prefix p;
+ revision-date 2007-06-09;
+ }
+ leaf invalid-interval {
+ type p:hello;
+ }
+ typedef hello {
+ type string;
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/interfiletypewithrevision/module2.yang b/compiler/plugin/maven/src/test/resources/interfiletypewithrevision/module2.yang
new file mode 100644
index 0000000..fd99872
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/interfiletypewithrevision/module2.yang
@@ -0,0 +1,11 @@
+module module2 {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant2;
+ revision 2007-06-09 {
+ description "Initial revision.";
+ }
+ typedef hello {
+ type string;
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/interfiletypewithrevisioninname/module1.yang b/compiler/plugin/maven/src/test/resources/interfiletypewithrevisioninname/module1.yang
new file mode 100644
index 0000000..180511d
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/interfiletypewithrevisioninname/module1.yang
@@ -0,0 +1,15 @@
+module module1 {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ import module2 {
+ prefix p;
+ revision-date 2007-06-09;
+ }
+ leaf invalid-interval {
+ type p:hello;
+ }
+ typedef hello {
+ type string;
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/interfiletypewithrevisioninname/module2@2007-06-09.yang b/compiler/plugin/maven/src/test/resources/interfiletypewithrevisioninname/module2@2007-06-09.yang
new file mode 100644
index 0000000..fd99872
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/interfiletypewithrevisioninname/module2@2007-06-09.yang
@@ -0,0 +1,11 @@
+module module2 {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant2;
+ revision 2007-06-09 {
+ description "Initial revision.";
+ }
+ typedef hello {
+ type string;
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/interfileuses/module1.yang b/compiler/plugin/maven/src/test/resources/interfileuses/module1.yang
new file mode 100644
index 0000000..69df326
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/interfileuses/module1.yang
@@ -0,0 +1,9 @@
+module module1 {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ import module2 {
+ prefix p;
+ }
+ uses p:hello;
+}
diff --git a/compiler/plugin/maven/src/test/resources/interfileuses/module2.yang b/compiler/plugin/maven/src/test/resources/interfileuses/module2.yang
new file mode 100644
index 0000000..5bb3616
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/interfileuses/module2.yang
@@ -0,0 +1,10 @@
+module module2 {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ grouping hello {
+ leaf hello {
+ type string;
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/interfileuseswithinclude/module1.yang b/compiler/plugin/maven/src/test/resources/interfileuseswithinclude/module1.yang
new file mode 100644
index 0000000..41899d9
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/interfileuseswithinclude/module1.yang
@@ -0,0 +1,7 @@
+module module1 {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ include module2;
+ uses hello;
+}
diff --git a/compiler/plugin/maven/src/test/resources/interfileuseswithinclude/module2.yang b/compiler/plugin/maven/src/test/resources/interfileuseswithinclude/module2.yang
new file mode 100644
index 0000000..1b423d9
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/interfileuseswithinclude/module2.yang
@@ -0,0 +1,11 @@
+submodule module2 {
+ yang-version 1;
+ belongs-to module1 {
+ prefix "module1";
+ }
+ grouping hello {
+ leaf hello {
+ type string;
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/interfilewithusesreferringtype/ietf-network.yang b/compiler/plugin/maven/src/test/resources/interfilewithusesreferringtype/ietf-network.yang
new file mode 100644
index 0000000..3d96560
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/interfilewithusesreferringtype/ietf-network.yang
@@ -0,0 +1,14 @@
+ module ietf-network {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-network";
+ prefix nd;
+
+ container networks {
+ container network-types {
+ description
+ "Serves as an augmentation target.
+ The network type is indicated through corresponding
+ presence containers augmented into this container.";
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/interfilewithusesreferringtype/ietf-te-topology.yang b/compiler/plugin/maven/src/test/resources/interfilewithusesreferringtype/ietf-te-topology.yang
new file mode 100644
index 0000000..2434403
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/interfilewithusesreferringtype/ietf-te-topology.yang
@@ -0,0 +1,51 @@
+ module ietf-te-topology {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-te-topology";
+ // replace with IANA namespace when assigned
+
+ prefix "tet";
+
+ import ietf-network {
+ prefix "nw";
+ }
+
+ grouping te-topologies-augment {
+ description
+ "Augmentation for TE topologies.";
+ leaf reference-change-policy {
+ type enumeration {
+ enum no-action {
+ description
+ "When an attribute changes in this template, the
+ configuration node referring to this template does
+ not take any action.";
+ }
+ enum not-allowed {
+ description
+ "When any configuration object has a reference to this
+ template, changing this template is not allowed.";
+ }
+ enum cascade {
+ description
+ "When an attribute changes in this template, the
+ configuration object referring to this template applies
+ the new attribute value to the corresponding
+ configuration.";
+ }
+ }
+ description
+ "This attribute specifies the action taken to a configuration
+ node that has a reference to this template.";
+ }
+ } // te-topologies-augment
+
+
+
+ augment "/nw:networks" {
+ description
+ "Augmentation parameters for TE topologies.";
+ uses te-topologies-augment;
+ }
+
+
+}
diff --git a/compiler/plugin/maven/src/test/resources/leafreflinker/iffeatuinleafref/featurebymultileafref/SelfFileLinkingWithFeatureReferredByMultiLeafref.yang b/compiler/plugin/maven/src/test/resources/leafreflinker/iffeatuinleafref/featurebymultileafref/SelfFileLinkingWithFeatureReferredByMultiLeafref.yang
new file mode 100644
index 0000000..f57fa6b
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/leafreflinker/iffeatuinleafref/featurebymultileafref/SelfFileLinkingWithFeatureReferredByMultiLeafref.yang
@@ -0,0 +1,40 @@
+module syslog {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix "sys";
+ feature local-storage {
+ description
+ "This feature means the device supports local
+ storage (memory, flash or disk) that can be used to
+ store syslog messages.";
+ }
+ feature main-storage {
+ description
+ "This feature means the device supports main
+ storage that can be used to
+ store syslog messages.";
+ }
+
+ container speed {
+ leaf local-storage-limit {
+ if-feature local-storage;
+ type leafref {
+ path "/value";
+ }
+ units "kilobyte";
+ config false;
+ description
+ "The amount of local storage that can be
+ used to hold syslog messages.";
+ }
+ }
+ leaf storage-value {
+ type leafref {
+ path "/speed/local-storage-limit";
+ }
+ }
+ leaf value {
+ if-feature main-storage;
+ type uint64;
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/leafreflinker/iffeatuinleafref/simpleleafrefwithiffeature/SelfFileLinkingWithFeatureReferredByLeafref.yang b/compiler/plugin/maven/src/test/resources/leafreflinker/iffeatuinleafref/simpleleafrefwithiffeature/SelfFileLinkingWithFeatureReferredByLeafref.yang
new file mode 100644
index 0000000..941b56b
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/leafreflinker/iffeatuinleafref/simpleleafrefwithiffeature/SelfFileLinkingWithFeatureReferredByLeafref.yang
@@ -0,0 +1,28 @@
+module syslog {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix "sys";
+ feature local-storage {
+ description
+ "This feature means the device supports local
+ storage (memory, flash or disk) that can be used to
+ store syslog messages.";
+ }
+
+ container speed {
+ leaf local-storage-limit {
+ if-feature local-storage;
+ type uint64;
+ units "kilobyte";
+ config false;
+ description
+ "The amount of local storage that can be
+ used to hold syslog messages.";
+ }
+ }
+ leaf storage-value {
+ type leafref {
+ path "/speed/local-storage-limit";
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/leafreflinker/interfile/interfileleafreffromgroupingreferstootherfile/module1.yang b/compiler/plugin/maven/src/test/resources/leafreflinker/interfile/interfileleafreffromgroupingreferstootherfile/module1.yang
new file mode 100644
index 0000000..b8a5d98
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/leafreflinker/interfile/interfileleafreffromgroupingreferstootherfile/module1.yang
@@ -0,0 +1,28 @@
+module module1 {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-te-topology";
+ prefix "tet";
+ import module2 {
+ prefix "nt";
+ }
+ container te-node-tunnel-termination-capability {
+ description
+ "Termination capability of a tunnel termination point on a
+ TE node.";
+ list termination-capability {
+ key "link-tp";
+ description
+ "The termination capabilities between
+ tunnel-termination-point and link termination-point.
+ The capability information can be used to compute
+ the tunnel path.";
+ leaf link-tp {
+ type leafref {
+ path "/nt:termination-point/nt:tp-id";
+ }
+ description
+ "Link termination point.";
+ }
+ } // termination-capability
+ } // te-node-tunnel-termination-capability
+}
diff --git a/compiler/plugin/maven/src/test/resources/leafreflinker/interfile/interfileleafreffromgroupingreferstootherfile/module2.yang b/compiler/plugin/maven/src/test/resources/leafreflinker/interfile/interfileleafreffromgroupingreferstootherfile/module2.yang
new file mode 100644
index 0000000..822d90b
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/leafreflinker/interfile/interfileleafreffromgroupingreferstootherfile/module2.yang
@@ -0,0 +1,11 @@
+module module2 {
+ yang-version 1;
+ namespace
+ "urn:ietf:params:xml:ns:yang:ietf-inet-types";
+ prefix inet;
+ container termination-point {
+ leaf tp-id {
+ type string;
+ }
+ }
+}
\ No newline at end of file
diff --git a/compiler/plugin/maven/src/test/resources/leafreflinker/interfile/interfileleafrefreferstomultipleleafrefinmultiplefiles/ieft-inet-types.yang b/compiler/plugin/maven/src/test/resources/leafreflinker/interfile/interfileleafrefreferstomultipleleafrefinmultiplefiles/ieft-inet-types.yang
new file mode 100644
index 0000000..c393dbf
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/leafreflinker/interfile/interfileleafrefreferstomultipleleafrefinmultiplefiles/ieft-inet-types.yang
@@ -0,0 +1,11 @@
+module ietf-inet-types {
+ yang-version 1;
+ namespace
+ "urn:ietf:params:xml:ns:yang:ietf-inet-types";
+ prefix inet;
+ typedef tp-ref {
+ type leafref {
+ path "/nwtp:value";
+ }
+ }
+}
\ No newline at end of file
diff --git a/compiler/plugin/maven/src/test/resources/leafreflinker/interfile/interfileleafrefreferstomultipleleafrefinmultiplefiles/ietf-network-topology.yang b/compiler/plugin/maven/src/test/resources/leafreflinker/interfile/interfileleafrefreferstomultipleleafrefinmultiplefiles/ietf-network-topology.yang
new file mode 100644
index 0000000..b488f46
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/leafreflinker/interfile/interfileleafrefreferstomultipleleafrefinmultiplefiles/ietf-network-topology.yang
@@ -0,0 +1,28 @@
+module ietf-network-topology {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-te-topology";
+ prefix "tet";
+ import ietf-network {
+ prefix "nt";
+ }
+ container te-node-tunnel-termination-capability {
+ description
+ "Termination capability of a tunnel termination point on a
+ TE node.";
+ list termination-capability {
+ key "link-tp";
+ description
+ "The termination capabilities between
+ tunnel-termination-point and link termination-point.
+ The capability information can be used to compute
+ the tunnel path.";
+ leaf link-tp {
+ type leafref {
+ path "/nt:termination-point/nt:tp-id";
+ }
+ description
+ "Link termination point.";
+ }
+ } // termination-capability
+ } // te-node-tunnel-termination-capability
+}
diff --git a/compiler/plugin/maven/src/test/resources/leafreflinker/interfile/interfileleafrefreferstomultipleleafrefinmultiplefiles/ietf-network.yang b/compiler/plugin/maven/src/test/resources/leafreflinker/interfile/interfileleafrefreferstomultipleleafrefinmultiplefiles/ietf-network.yang
new file mode 100644
index 0000000..49a6a04
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/leafreflinker/interfile/interfileleafrefreferstomultipleleafrefinmultiplefiles/ietf-network.yang
@@ -0,0 +1,14 @@
+module ietf-network {
+ yang-version 1;
+ namespace
+ "urn:ietf:params:xml:ns:yang:ietf-inet-types";
+ prefix nw;
+ import ietf-inet-types {
+ prefix inet;
+ }
+ container termination-point {
+ leaf tp-id {
+ type string;
+ }
+ }
+}
\ No newline at end of file
diff --git a/compiler/plugin/maven/src/test/resources/leafreflinker/interfile/interfileleafrefwithimport/module1.yang b/compiler/plugin/maven/src/test/resources/leafreflinker/interfile/interfileleafrefwithimport/module1.yang
new file mode 100644
index 0000000..d33cf1e
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/leafreflinker/interfile/interfileleafrefwithimport/module1.yang
@@ -0,0 +1,16 @@
+module module1 {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ import module2 {
+ prefix p;
+ }
+ leaf invalid-interval {
+ type leafref {
+ path "/p:hello";
+ }
+ }
+ leaf hello {
+ type string;
+ }
+}
\ No newline at end of file
diff --git a/compiler/plugin/maven/src/test/resources/leafreflinker/interfile/interfileleafrefwithimport/module2.yang b/compiler/plugin/maven/src/test/resources/leafreflinker/interfile/interfileleafrefwithimport/module2.yang
new file mode 100644
index 0000000..28a869b
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/leafreflinker/interfile/interfileleafrefwithimport/module2.yang
@@ -0,0 +1,8 @@
+module module2 {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant2;
+ leaf hello {
+ type string;
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/leafreflinker/interfile/leafrefInGroupingWithPrefix/GroupingCopiedInModule2.yang b/compiler/plugin/maven/src/test/resources/leafreflinker/interfile/leafrefInGroupingWithPrefix/GroupingCopiedInModule2.yang
new file mode 100644
index 0000000..dae2db2
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/leafreflinker/interfile/leafrefInGroupingWithPrefix/GroupingCopiedInModule2.yang
@@ -0,0 +1,12 @@
+module GroupingCopiedInModule2 {
+ yang-version 1;
+ namespace "onos-yang-19:level1:newlevel";
+ prefix test;
+ import LeafrefInGroupingOfModule1 {
+ prefix module1;
+ }
+ description "leaf scenario";
+ container value {
+ uses "module1:network-ref";
+ }
+}
\ No newline at end of file
diff --git a/compiler/plugin/maven/src/test/resources/leafreflinker/interfile/leafrefInGroupingWithPrefix/LeafrefInGroupingOfModule1.yang b/compiler/plugin/maven/src/test/resources/leafreflinker/interfile/leafrefInGroupingWithPrefix/LeafrefInGroupingOfModule1.yang
new file mode 100644
index 0000000..0753619
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/leafreflinker/interfile/leafrefInGroupingWithPrefix/LeafrefInGroupingOfModule1.yang
@@ -0,0 +1,40 @@
+module LeafrefInGroupingOfModule1 {
+ yang-version 1;
+ namespace "onos-yang-19:level1:newlevel";
+ prefix test2;
+ description "leaf scenario";
+ container networks {
+ list network {
+ key "network-id";
+ description
+ "Describes a network.
+ A network typically contains an inventory of nodes,
+ topological information (augmented through
+ network-topology model), as well as layering
+ information.";
+ container network-types {
+ description
+ "Serves as an augmentation target.
+ The network type is indicated through corresponding
+ presence containers augmented into this container.";
+ }
+ leaf network-id {
+ type string;
+ description
+ "Identifies a network.";
+ }
+ }
+ leaf network-ip {
+ type uint8;
+ description
+ "Identifies a network.";
+ }
+ }
+ grouping network-ref {
+ leaf network-ref {
+ type leafref {
+ path "/test2:networks/test2:network/test2:network-id";
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/compiler/plugin/maven/src/test/resources/leafreflinker/interfile/leafrefInGroupingWithPrefixAndManyReference/GroupingCopiedInModule2.yang b/compiler/plugin/maven/src/test/resources/leafreflinker/interfile/leafrefInGroupingWithPrefixAndManyReference/GroupingCopiedInModule2.yang
new file mode 100644
index 0000000..d988a3a
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/leafreflinker/interfile/leafrefInGroupingWithPrefixAndManyReference/GroupingCopiedInModule2.yang
@@ -0,0 +1,37 @@
+module ietf-te-topology {
+ yang-version 1;
+ namespace "onos-yang-19:level1:newlevel";
+ prefix test;
+ import ietf-network {
+ prefix "nw";
+ }
+ description "leaf scenario";
+ typedef te-topology-event-type {
+ type enumeration {
+ enum "add" {
+ value 0;
+ description
+ "A TE node or te-link has been added.";
+ }
+ enum "remove" {
+ value 1;
+ description
+ "A TE node or te-link has been removed.";
+ }
+ enum "update" {
+ value 2;
+ description
+ "A TE node or te-link has been updated.";
+ }
+ }
+ description "TE Event type for notifications";
+ } // te-topology-event-type
+ container te-node-event {
+ leaf event-type {
+ type te-topology-event-type;
+ description "Event type.";
+ }
+ description "Notification event for TE node.";
+ uses nw:node-ref;
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/leafreflinker/interfile/leafrefInGroupingWithPrefixAndManyReference/LeafrefInGroupingOfModule1.yang b/compiler/plugin/maven/src/test/resources/leafreflinker/interfile/leafrefInGroupingWithPrefixAndManyReference/LeafrefInGroupingOfModule1.yang
new file mode 100644
index 0000000..f2b7591
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/leafreflinker/interfile/leafrefInGroupingWithPrefixAndManyReference/LeafrefInGroupingOfModule1.yang
@@ -0,0 +1,212 @@
+ module ietf-network {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-network";
+ prefix nd;
+
+ organization
+ "IETF I2RS (Interface to the Routing System) Working Group";
+
+ contact
+ "WG Web: <http://tools.ietf.org/wg/i2rs/>
+ WG List: <mailto:i2rs@ietf.org>
+
+ WG Chair: Susan Hares
+ <mailto:shares@ndzh.com>
+
+ WG Chair: Jeffrey Haas
+ <mailto:jhaas@pfrc.org>
+
+ Editor: Alexander Clemm
+ <mailto:alex@cisco.com>
+
+ Editor: Jan Medved
+ <mailto:jmedved@cisco.com>
+
+ Editor: Robert Varga
+ <mailto:rovarga@cisco.com>
+
+ Editor: Tony Tkacik
+ <mailto:ttkacik@cisco.com>
+
+ Editor: Nitin Bahadur
+ <mailto:nitin_bahadur@yahoo.com>
+
+ Editor: Hariharan Ananthakrishnan
+ <mailto:hari@packetdesign.com>";
+
+ description
+ "This module defines a common base model for a collection
+ of nodes in a network. Node definitions are further used
+ in network topologies and inventories.
+
+ Copyright (c) 2015 IETF Trust and the persons identified as
+ authors of the code. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or
+ without modification, is permitted pursuant to, and subject
+ to the license terms contained in, the Simplified BSD License
+ set forth in Section 4.c of the IETF Trust's Legal Provisions
+ Relating to IETF Documents
+ (http://trustee.ietf.org/license-info).
+
+ This version of this YANG module is part of
+ draft-ietf-i2rs-yang-network-topo-02;
+ see the RFC itself for full legal notices.
+
+ NOTE TO RFC EDITOR: Please replace above reference to
+ draft-ietf-i2rs-yang-network-topo-02 with RFC
+ number when published (i.e. RFC xxxx).";
+
+ revision 2015-12-08 {
+ description
+ "Initial revision.
+ NOTE TO RFC EDITOR: Please replace the following reference
+ to draft-ietf-i2rs-yang-network-topo-02 with
+ RFC number when published (i.e. RFC xxxx).";
+ reference
+ "draft-ietf-i2rs-yang-network-topo-02";
+ }
+
+ typedef node-id {
+ type string;
+ description
+ "Identifier for a node.";
+ }
+
+ typedef network-id {
+ type string;
+ description
+ "Identifier for a network.";
+ }
+ grouping network-ref {
+ description
+ "Contains the information necessary to reference a network,
+ for example an underlay network.";
+ leaf network-ref {
+ type leafref {
+ path "/nd:networks/nd:network/nd:network-id";
+ require-instance false;
+ }
+ description
+ "Used to reference a network, for example an underlay
+ network.";
+ }
+ }
+
+ grouping node-ref {
+ description
+ "Contains the information necessary to reference a node.";
+ leaf node-ref {
+ type leafref {
+ path "/nd:networks/nd:network[nd:network-id=current()/../"+
+ "network-ref]/nd:node/nd:node-id";
+ require-instance false;
+ }
+ description
+ "Used to reference a node.
+ Nodes are identified relative to the network they are
+ contained in.";
+ }
+ uses network-ref;
+ }
+
+ container networks {
+ description
+ "Serves as top-level container for a list of networks.";
+ list network {
+ key "network-id";
+ description
+ "Describes a network.
+ A network typically contains an inventory of nodes,
+ topological information (augmented through
+ network-topology model), as well as layering
+ information.";
+ container network-types {
+ description
+ "Serves as an augmentation target.
+ The network type is indicated through corresponding
+ presence containers augmented into this container.";
+ }
+ leaf network-id {
+ type network-id;
+ description
+ "Identifies a network.";
+ }
+ list supporting-network {
+ key "network-ref";
+ description
+ "An underlay network, used to represent layered network
+ topologies.";
+ leaf network-ref {
+ type leafref {
+ path "/networks/network/network-id";
+ require-instance false;
+ }
+ description
+ "References the underlay network.";
+ }
+ }
+ list node {
+ key "node-id";
+ description
+ "The inventory of nodes of this network.";
+ leaf node-id {
+ type node-id;
+ description
+ "Identifies a node uniquely within the containing
+ network.";
+ }
+ list supporting-node {
+ key "network-ref node-ref";
+ description
+ "Represents another node, in an underlay network, that
+ this node is supported by. Used to represent layering
+ structure.";
+ leaf network-ref {
+ type leafref {
+ path "../../../supporting-network/network-ref";
+ require-instance false;
+ }
+ description
+ "References the underlay network that the
+ underlay node is part of.";
+ }
+ leaf node-ref {
+ type leafref {
+ path "/networks/network/node/node-id";
+ require-instance false;
+ }
+ description
+ "References the underlay node itself.";
+ }
+ }
+ }
+ }
+ }
+ container networks-state {
+ config false;
+ description
+ "Serves as top-level container for a list of state information
+ for networks";
+ list network {
+ key "network-ref";
+ description
+ "Data nodes representing operational data and state of
+ networks.
+ An instance is automatically created for every network
+ in the corresponding list under the networks container.";
+ uses network-ref;
+ leaf server-provided {
+ type boolean;
+ description
+ "Indicates whether the information concerning this
+ particular network is populated by the server
+ (server-provided true, the general case for network
+ information discovered from the server),
+ or whether it is configured by a client
+ (server-provided true, possible e.g. for
+ service overlays managed through a controller).";
+ }
+ }
+ }
+ }
diff --git a/compiler/plugin/maven/src/test/resources/leafreflinker/interfile/typedefreferredmultipletimes/ietf-interfaces.yang b/compiler/plugin/maven/src/test/resources/leafreflinker/interfile/typedefreferredmultipletimes/ietf-interfaces.yang
new file mode 100644
index 0000000..31bcb98
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/leafreflinker/interfile/typedefreferredmultipletimes/ietf-interfaces.yang
@@ -0,0 +1,55 @@
+module ietf-interfaces {
+ namespace "urn:ietf:params:xml:ns:yang:ietf-interfaces";
+ prefix if;
+ typedef interface-state-ref {
+ type leafref {
+ path "/if:interfaces-state/if:interface/if:name";
+ }
+ description
+ "This type is used by data models that need to reference
+ the operationally present interfaces";
+ }
+ /*
+ * Operational state data nodes
+ */
+ container interfaces-state {
+ config false;
+ description
+ "Data nodes for the operational state of interfaces.";
+ list interface {
+ key "name";
+ description
+ "The list of interfaces on the device.
+ System-controlled interfaces created by the system are
+ always present in this list, whether they are configured or
+ not.";
+ leaf name {
+ type string;
+ description
+ "The name of the interface.
+ A server implementation MAY map this leaf to the ifName
+ MIB object. Such an implementation needs to use some
+ mechanism to handle the differences in size and characters
+ allowed between this leaf and ifName. The definition of
+ such a mechanism is outside the scope of this document.";
+ reference "RFC 2863: The Interfaces Group MIB - ifName";
+ }
+ leaf-list higher-layer-if {
+ type interface-state-ref;
+ description
+ "A list of references to interfaces layered on top of this
+ interface.";
+ reference
+ "RFC 2863: The Interfaces Group MIB - ifStackTable";
+ }
+ leaf-list lower-layer-if {
+ type interface-state-ref;
+ description
+ "A list of references to interfaces layered underneath this
+ interface.";
+ reference
+ "RFC 2863: The Interfaces Group MIB - ifStackTable";
+ }
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/invalidscenerioforgrouping/SelfResolutionWhenLeafrefInModuleReferToGroupingInModule.yang b/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/invalidscenerioforgrouping/SelfResolutionWhenLeafrefInModuleReferToGroupingInModule.yang
new file mode 100644
index 0000000..a0bd03b
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/invalidscenerioforgrouping/SelfResolutionWhenLeafrefInModuleReferToGroupingInModule.yang
@@ -0,0 +1,19 @@
+module SelfResolutionWhenLeafrefInModuleReferToGroupingInModule {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-network";
+ prefix nd;
+ grouping networks {
+ leaf network-id {
+ type uint8;
+ description
+ "Identifies a network.";
+ }
+ }
+ container current {
+ leaf network-ref {
+ type leafref {
+ path "/networks/network-id";
+ }
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/invalidsceneriowithinvalidnode/SelfResolutionWhenLeafrefInModuleReferToInvalidNode.yang b/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/invalidsceneriowithinvalidnode/SelfResolutionWhenLeafrefInModuleReferToInvalidNode.yang
new file mode 100644
index 0000000..c10ba2b
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/invalidsceneriowithinvalidnode/SelfResolutionWhenLeafrefInModuleReferToInvalidNode.yang
@@ -0,0 +1,19 @@
+module SelfResolutionWhenLeafrefInModuleReferToInvalidNode {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-network";
+ prefix nd;
+ container networks {
+ description
+ "Serves as top-level container for a list of networks.";
+ leaf network-id {
+ type uint8;
+ description
+ "Identifies a network.";
+ }
+ }
+ leaf network-ref {
+ type leafref {
+ path "/define/network-id";
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/invalidsceneriowithnorefleaf/SelfResolutionWhenLeafrefDoesNotReferToLeafOrLeafList.yang b/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/invalidsceneriowithnorefleaf/SelfResolutionWhenLeafrefDoesNotReferToLeafOrLeafList.yang
new file mode 100644
index 0000000..e5de10b
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/invalidsceneriowithnorefleaf/SelfResolutionWhenLeafrefDoesNotReferToLeafOrLeafList.yang
@@ -0,0 +1,22 @@
+module ietf-network {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-network";
+ prefix nd;
+ container networks {
+ description
+ "Serves as top-level container for a list of networks.";
+ leaf network-id {
+ type status;
+ description
+ "Identifies a network.";
+ }
+ }
+ typedef status {
+ type uint8;
+ }
+ leaf network-ref {
+ type leafref {
+ path "/networks";
+ }
+ }
+}
\ No newline at end of file
diff --git a/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/leafrefInAugment/SelfResolutionIfLeafrefInGroupingIsCopiedToAugment.yang b/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/leafrefInAugment/SelfResolutionIfLeafrefInGroupingIsCopiedToAugment.yang
new file mode 100644
index 0000000..a208903
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/leafrefInAugment/SelfResolutionIfLeafrefInGroupingIsCopiedToAugment.yang
@@ -0,0 +1,64 @@
+module topology {
+ yang-version 1;
+ namespace "onos-yang-19:level1:newlevel";
+ prefix test;
+ organization "huawei";
+ contact "adarsh.m@huawei.com";
+ description "leaf scenario";
+ container networks {
+ list network {
+ key "network-id";
+ description
+ "Describes a network.
+ A network typically contains an inventory of nodes,
+ topological information (augmented through
+ network-topology model), as well as layering
+ information.";
+ container network-types {
+ description
+ "Serves as an augmentation target.
+ The network type is indicated through corresponding
+ presence containers augmented into this container.";
+ }
+ leaf network-id {
+ type string;
+ description
+ "Identifies a network.";
+ }
+ }
+ leaf network-ip {
+ type uint8;
+ description
+ "Identifies a network.";
+ }
+ }
+ augment "/networks/network" {
+ container config {
+ description
+ "Configuration data.";
+ choice bundle-stack-level {
+ description
+ "The TE link can be partitioned into bundled
+ links, or component links.";
+ case bundle {
+ container bundled-links {
+ description
+ "A set of bundled links.";
+ reference
+ "RFC4201: Link Bundling in MPLS Traffic Engineering
+ (TE).";
+ list bundled-link {
+ key "src-tp-ref";
+ leaf src-tp-ref {
+ type leafref {
+ path "../../../../../network-ip";
+ require-instance true;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/leafrefingroupingonly/SelfResolutionWithLeafrefInGrouping.yang b/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/leafrefingroupingonly/SelfResolutionWithLeafrefInGrouping.yang
new file mode 100644
index 0000000..80b6ab0
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/leafrefingroupingonly/SelfResolutionWithLeafrefInGrouping.yang
@@ -0,0 +1,37 @@
+module ietf-network {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-network";
+ prefix nd;
+
+ import ietf-inet-types {
+ prefix inet;
+ }
+ typedef node-id {
+ type inet:uri;
+ description
+ "Identifier for a node.";
+ }
+
+ leaf xyz {
+ type string;
+ }
+ typedef network-id {
+ type inet:uri;
+ description
+ "Identifier for a network.";
+ }
+ grouping network-ref {
+ description
+ "Contains the information necessary to reference a network,
+ for example an underlay network.";
+ leaf network-ref {
+ type leafref {
+ path "/nd:xyz";
+ require-instance false;
+ }
+ description
+ "Used to reference a network, for example an underlay
+ network.";
+ }
+ }
+ }
diff --git a/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/leafrefintypedef/SelfResolutionWhenLeafrefInTypedefReferToContainer.yang b/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/leafrefintypedef/SelfResolutionWhenLeafrefInTypedefReferToContainer.yang
new file mode 100644
index 0000000..ae42100
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/leafrefintypedef/SelfResolutionWhenLeafrefInTypedefReferToContainer.yang
@@ -0,0 +1,22 @@
+module ietf-network {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-network";
+ prefix nd;
+ container networks {
+ description
+ "Serves as top-level container for a list of networks.";
+ leaf network-id {
+ type network-ref;
+ description
+ "Identifies a network.";
+ }
+ leaf id {
+ type uint8;
+ }
+ }
+ typedef network-ref {
+ type leafref {
+ path "/networks/id";
+ }
+ }
+}
\ No newline at end of file
diff --git a/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/leafrefintypedefwithsamereferpath/SelfResolutionWhenLeafrefInTypedefIsUsedInSameReferredNode.yang b/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/leafrefintypedefwithsamereferpath/SelfResolutionWhenLeafrefInTypedefIsUsedInSameReferredNode.yang
new file mode 100644
index 0000000..7506be9
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/leafrefintypedefwithsamereferpath/SelfResolutionWhenLeafrefInTypedefIsUsedInSameReferredNode.yang
@@ -0,0 +1,34 @@
+module typedef {
+ yang-version "1";
+ namespace "http://rob.sh/yang/test/list";
+ prefix "foo";
+ organization "BugReports Inc";
+ contact "Bug reporter";
+
+ description
+ "A test module";
+ revision 2014-01-01 {
+ description "april-fools";
+ reference "fooled-you";
+ }
+
+ typedef referenced-leaf {
+ type leafref {
+ path "/container/target";
+ require-instance false;
+ }
+ }
+
+ container container {
+ description
+ "A container";
+ leaf-list target {
+ type uint8;
+ description
+ "A target leaf for leafref checks";
+ }
+ leaf reference {
+ type referenced-leaf;
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/leafrefinusesundergrouping/ietf-network.yang b/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/leafrefinusesundergrouping/ietf-network.yang
new file mode 100644
index 0000000..4eaa2bf
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/leafrefinusesundergrouping/ietf-network.yang
@@ -0,0 +1,33 @@
+module ietf-network {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-network";
+ prefix nd;
+ import network {
+ prefix "nw";
+ }
+ grouping xyz {
+ leaf network-id-ref {
+ type leafref {
+ path "/nw:networks/nw:network/nw:network-id";
+ require-instance false;
+ }
+ description
+ "A reference to a network-id in base ietf-network module.";
+ }
+ }
+ grouping yzx {
+ container hi {
+ uses xyz;
+ }
+ }
+ container fine {
+ uses yzx;
+ }
+ container networks {
+ leaf network {
+ type string;
+ }
+ }
+}
+
+
diff --git a/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/leafrefinusesundergrouping/network.yang b/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/leafrefinusesundergrouping/network.yang
new file mode 100644
index 0000000..30e8b80
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/leafrefinusesundergrouping/network.yang
@@ -0,0 +1,212 @@
+ module network {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-network";
+ prefix nd;
+
+ organization
+ "IETF I2RS (Interface to the Routing System) Working Group";
+
+ contact
+ "WG Web: <http://tools.ietf.org/wg/i2rs/>
+ WG List: <mailto:i2rs@ietf.org>
+
+ WG Chair: Susan Hares
+ <mailto:shares@ndzh.com>
+
+ WG Chair: Jeffrey Haas
+ <mailto:jhaas@pfrc.org>
+
+ Editor: Alexander Clemm
+ <mailto:alex@cisco.com>
+
+ Editor: Jan Medved
+ <mailto:jmedved@cisco.com>
+
+ Editor: Robert Varga
+ <mailto:rovarga@cisco.com>
+
+ Editor: Tony Tkacik
+ <mailto:ttkacik@cisco.com>
+
+ Editor: Nitin Bahadur
+ <mailto:nitin_bahadur@yahoo.com>
+
+ Editor: Hariharan Ananthakrishnan
+ <mailto:hari@packetdesign.com>";
+
+ description
+ "This module defines a common base model for a collection
+ of nodes in a network. Node definitions are further used
+ in network topologies and inventories.
+
+ Copyright (c) 2015 IETF Trust and the persons identified as
+ authors of the code. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or
+ without modification, is permitted pursuant to, and subject
+ to the license terms contained in, the Simplified BSD License
+ set forth in Section 4.c of the IETF Trust's Legal Provisions
+ Relating to IETF Documents
+ (http://trustee.ietf.org/license-info).
+
+ This version of this YANG module is part of
+ draft-ietf-i2rs-yang-network-topo-02;
+ see the RFC itself for full legal notices.
+
+ NOTE TO RFC EDITOR: Please replace above reference to
+ draft-ietf-i2rs-yang-network-topo-02 with RFC
+ number when published (i.e. RFC xxxx).";
+
+ revision 2015-12-08 {
+ description
+ "Initial revision.
+ NOTE TO RFC EDITOR: Please replace the following reference
+ to draft-ietf-i2rs-yang-network-topo-02 with
+ RFC number when published (i.e. RFC xxxx).";
+ reference
+ "draft-ietf-i2rs-yang-network-topo-02";
+ }
+
+ typedef node-id {
+ type string;
+ description
+ "Identifier for a node.";
+ }
+
+ typedef network-id {
+ type string;
+ description
+ "Identifier for a network.";
+ }
+ grouping network-ref {
+ description
+ "Contains the information necessary to reference a network,
+ for example an underlay network.";
+ leaf network-ref {
+ type leafref {
+ path "/nd:networks/nd:network/nd:network-id";
+ require-instance false;
+ }
+ description
+ "Used to reference a network, for example an underlay
+ network.";
+ }
+ }
+
+ grouping node-ref {
+ description
+ "Contains the information necessary to reference a node.";
+ leaf node-ref {
+ type leafref {
+ path "/nd:networks/nd:network[nd:network-id=current()/../"+
+ "network-ref]/nd:node/nd:node-id";
+ require-instance false;
+ }
+ description
+ "Used to reference a node.
+ Nodes are identified relative to the network they are
+ contained in.";
+ }
+ uses network-ref;
+ }
+
+ container networks {
+ description
+ "Serves as top-level container for a list of networks.";
+ list network {
+ key "network-id";
+ description
+ "Describes a network.
+ A network typically contains an inventory of nodes,
+ topological information (augmented through
+ network-topology model), as well as layering
+ information.";
+ container network-types {
+ description
+ "Serves as an augmentation target.
+ The network type is indicated through corresponding
+ presence containers augmented into this container.";
+ }
+ leaf network-id {
+ type network-id;
+ description
+ "Identifies a network.";
+ }
+ list supporting-network {
+ key "network-ref";
+ description
+ "An underlay network, used to represent layered network
+ topologies.";
+ leaf network-ref {
+ type leafref {
+ path "/networks/network/network-id";
+ require-instance false;
+ }
+ description
+ "References the underlay network.";
+ }
+ }
+ list node {
+ key "node-id";
+ description
+ "The inventory of nodes of this network.";
+ leaf node-id {
+ type node-id;
+ description
+ "Identifies a node uniquely within the containing
+ network.";
+ }
+ list supporting-node {
+ key "network-ref node-ref";
+ description
+ "Represents another node, in an underlay network, that
+ this node is supported by. Used to represent layering
+ structure.";
+ leaf network-ref {
+ type leafref {
+ path "../../../supporting-network/network-ref";
+ require-instance false;
+ }
+ description
+ "References the underlay network that the
+ underlay node is part of.";
+ }
+ leaf node-ref {
+ type leafref {
+ path "/networks/network/node/node-id";
+ require-instance false;
+ }
+ description
+ "References the underlay node itself.";
+ }
+ }
+ }
+ }
+ }
+ container networks-state {
+ config false;
+ description
+ "Serves as top-level container for a list of state information
+ for networks";
+ list network {
+ key "network-ref";
+ description
+ "Data nodes representing operational data and state of
+ networks.
+ An instance is automatically created for every network
+ in the corresponding list under the networks container.";
+ uses network-ref;
+ leaf server-provided {
+ type boolean;
+ description
+ "Indicates whether the information concerning this
+ particular network is populated by the server
+ (server-provided true, the general case for network
+ information discovered from the server),
+ or whether it is configured by a client
+ (server-provided true, possible e.g. for
+ service overlays managed through a controller).";
+ }
+ }
+ }
+ }
\ No newline at end of file
diff --git a/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/leafreflinking/SelfResolutionWhenLeafrefIsInDeepTreeAndLeafIsInModuleWithReferredTypeUnion.yang b/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/leafreflinking/SelfResolutionWhenLeafrefIsInDeepTreeAndLeafIsInModuleWithReferredTypeUnion.yang
new file mode 100644
index 0000000..edf6bfa
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/leafreflinking/SelfResolutionWhenLeafrefIsInDeepTreeAndLeafIsInModuleWithReferredTypeUnion.yang
@@ -0,0 +1,28 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ list valid {
+ key "define";
+ leaf define {
+ type string;
+ }
+ container standard {
+ container present {
+ leaf name {
+ type leafref {
+ path "/invalid-interval";
+ }
+ }
+ }
+ }
+ }
+ leaf invalid-interval {
+ type union {
+ type int32;
+ type enumeration {
+ enum "unbounded";
+ }
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/leafrefreferingtoleaflist/SelfResolutionWhenLeafrefReferToContainerLeafList.yang b/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/leafrefreferingtoleaflist/SelfResolutionWhenLeafrefReferToContainerLeafList.yang
new file mode 100644
index 0000000..ec9a6d3
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/leafrefreferingtoleaflist/SelfResolutionWhenLeafrefReferToContainerLeafList.yang
@@ -0,0 +1,19 @@
+module ietf-network {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-network";
+ prefix nd;
+ container networks {
+ description
+ "Serves as top-level container for a list of networks.";
+ leaf network-id {
+ type uint8;
+ description
+ "Identifies a network.";
+ }
+ }
+ leaf-list network-ref {
+ type leafref {
+ path "/networks/network-id";
+ }
+ }
+}
\ No newline at end of file
diff --git a/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/leafreftoderivedtype/SelfResolutionWhenLeafrefReferToAnotherDerivedType.yang b/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/leafreftoderivedtype/SelfResolutionWhenLeafrefReferToAnotherDerivedType.yang
new file mode 100644
index 0000000..eb2668e
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/leafreftoderivedtype/SelfResolutionWhenLeafrefReferToAnotherDerivedType.yang
@@ -0,0 +1,22 @@
+module ietf-network {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-network";
+ prefix nd;
+ container networks {
+ description
+ "Serves as top-level container for a list of networks.";
+ leaf network-id {
+ type status;
+ description
+ "Identifies a network.";
+ }
+ }
+ typedef status {
+ type uint8;
+ }
+ leaf network-ref {
+ type leafref {
+ path "/networks/network-id";
+ }
+ }
+}
\ No newline at end of file
diff --git a/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/leafreftoinputinrpc/SelfResolutionWhenLeafrefInModuleReferToLeafListInInputOfRpc.yang b/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/leafreftoinputinrpc/SelfResolutionWhenLeafrefInModuleReferToLeafListInInputOfRpc.yang
new file mode 100644
index 0000000..917c434
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/leafreftoinputinrpc/SelfResolutionWhenLeafrefInModuleReferToLeafListInInputOfRpc.yang
@@ -0,0 +1,23 @@
+module ietf-network {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-network";
+ prefix nd;
+ rpc networks {
+ description
+ "Serves as top-level container for a list of networks.";
+ input {
+ leaf-list network-id {
+ type uint8;
+ description
+ "Identifies a network.";
+ }
+ }
+ output {
+ }
+ }
+ leaf-list network-ref {
+ type leafref {
+ path "/networks/input/network-id";
+ }
+ }
+}
\ No newline at end of file
diff --git a/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/leafreftoleafref/SelfResolutionWhenLeafrefReferToAnotherLeafref.yang b/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/leafreftoleafref/SelfResolutionWhenLeafrefReferToAnotherLeafref.yang
new file mode 100644
index 0000000..26ccd1f
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/leafreftoleafref/SelfResolutionWhenLeafrefReferToAnotherLeafref.yang
@@ -0,0 +1,26 @@
+module ietf-network {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-network";
+ prefix nd;
+ container networks {
+ description
+ "Serves as top-level container for a list of networks.";
+ leaf network-id {
+ type leafref {
+ path "/status/current";
+ }
+ description
+ "Identifies a network.";
+ }
+ }
+ container status {
+ leaf current {
+ type uint8;
+ }
+ }
+ leaf network-ref {
+ type leafref {
+ path "/networks/network-id";
+ }
+ }
+}
\ No newline at end of file
diff --git a/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/leafreftoleafrefwithtypedef/SelfResolutionWhenLeafrefInTypedefIsInDeepTreeAndLeafListIsInModuleWithReferredTypeEnumeration.yang b/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/leafreftoleafrefwithtypedef/SelfResolutionWhenLeafrefInTypedefIsInDeepTreeAndLeafListIsInModuleWithReferredTypeEnumeration.yang
new file mode 100644
index 0000000..b61be6a
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/leafreftoleafrefwithtypedef/SelfResolutionWhenLeafrefInTypedefIsInDeepTreeAndLeafListIsInModuleWithReferredTypeEnumeration.yang
@@ -0,0 +1,33 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ list valid {
+ key "define";
+ leaf define {
+ type string;
+ }
+ container standard {
+ typedef node {
+ type leafref {
+ path "/invalid-interval";
+ }
+ }
+ container present {
+ typedef name {
+ type node;
+ }
+ leaf interval {
+ type name;
+ }
+ }
+ }
+ }
+ leaf-list invalid-interval {
+ type enumeration {
+ enum 10m;
+ enum 100m;
+ enum auto;
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/leafreftomultileafref/SelfResolutionWhenLeafrefReferToMultipleLeafref.yang b/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/leafreftomultileafref/SelfResolutionWhenLeafrefReferToMultipleLeafref.yang
new file mode 100644
index 0000000..fd75d32
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/leafreftomultileafref/SelfResolutionWhenLeafrefReferToMultipleLeafref.yang
@@ -0,0 +1,50 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ list valid {
+ key "define";
+ leaf define {
+ type string;
+ }
+ container standard {
+ container present {
+ leaf-list name {
+ type leafref {
+ path "/transmitter/send";
+ }
+ }
+ }
+ }
+ }
+ container reference {
+ list found {
+ key "define";
+ leaf define {
+ type string;
+ }
+ container reciever {
+ leaf remove {
+ type leafref {
+ path "/valid/standard/present/name";
+ }
+ }
+ }
+ }
+ }
+ list transmitter {
+ key "send";
+ leaf send {
+ type leafref {
+ path "/invalid-interval";
+ }
+ }
+ }
+ leaf-list invalid-interval {
+ type enumeration {
+ enum 10m;
+ enum 100m;
+ enum auto;
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/leafreftomultitypedef/SelfResolutionWhenLeafrefReferToMultipleTypedef.yang b/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/leafreftomultitypedef/SelfResolutionWhenLeafrefReferToMultipleTypedef.yang
new file mode 100644
index 0000000..4b286d2
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/leafreftomultitypedef/SelfResolutionWhenLeafrefReferToMultipleTypedef.yang
@@ -0,0 +1,43 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ list valid {
+ key "define";
+ leaf define {
+ type string;
+ }
+ container standard {
+ container present {
+ leaf-list name {
+ type transmitter;
+ }
+ }
+ }
+ }
+ container reference {
+ list found {
+ key "define";
+ leaf define {
+ type string;
+ }
+ container reciever {
+ leaf remove {
+ type leafref {
+ path "/valid/standard/present/name";
+ }
+ }
+ }
+ }
+ }
+ typedef transmitter {
+ type invalid-interval;
+ }
+ typedef invalid-interval {
+ type enumeration {
+ enum 10m;
+ enum 100m;
+ enum auto;
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/leafreftorpcinputleaflist/SelfResolutionWhenLeafrefInTypedefModuleReferToLeafListInInputOfRpc.yang b/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/leafreftorpcinputleaflist/SelfResolutionWhenLeafrefInTypedefModuleReferToLeafListInInputOfRpc.yang
new file mode 100644
index 0000000..59e7a98
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/leafreftorpcinputleaflist/SelfResolutionWhenLeafrefInTypedefModuleReferToLeafListInInputOfRpc.yang
@@ -0,0 +1,26 @@
+module ietf-network {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-network";
+ prefix nd;
+ rpc networks {
+ description
+ "Serves as top-level container for a list of networks.";
+ input {
+ leaf-list network-id {
+ type network-ref;
+ description
+ "Identifies a network.";
+ }
+ leaf id {
+ type uint8;
+ }
+ }
+ output {
+ }
+ }
+ typedef network-ref {
+ type leafref {
+ path "/networks/input/id";
+ }
+ }
+}
\ No newline at end of file
diff --git a/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/leafreftotypedefwithleafref/SelfResolutionWhenLeafrefReferToDerivedTypeReferringToLeafWithLeafref.yang b/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/leafreftotypedefwithleafref/SelfResolutionWhenLeafrefReferToDerivedTypeReferringToLeafWithLeafref.yang
new file mode 100644
index 0000000..1bf423d
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/leafreftotypedefwithleafref/SelfResolutionWhenLeafrefReferToDerivedTypeReferringToLeafWithLeafref.yang
@@ -0,0 +1,45 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ list valid {
+ key "define";
+ leaf define {
+ type string;
+ }
+ container standard {
+ container present {
+ leaf-list name {
+ type transmitter;
+ }
+ }
+ }
+ }
+ container reference {
+ list found {
+ key "define";
+ leaf define {
+ type string;
+ }
+ container reciever {
+ leaf remove {
+ type leafref {
+ path "/valid/standard/present/name";
+ }
+ }
+ }
+ }
+ }
+ typedef transmitter {
+ type leafref {
+ path "/invalid-interval";
+ }
+ }
+ leaf invalid-interval {
+ type enumeration {
+ enum 10m;
+ enum 100m;
+ enum auto;
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/leafrefundernodeingrouping/ietf-network.yang b/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/leafrefundernodeingrouping/ietf-network.yang
new file mode 100644
index 0000000..3db511e
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/leafrefundernodeingrouping/ietf-network.yang
@@ -0,0 +1,95 @@
+module ietf-network {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-network";
+ prefix nd;
+
+ organization
+ "IETF I2RS (Interface to the Routing System) Working Group";
+ grouping node-ref {
+ description
+ "Contains the information necessary to reference a node.";
+ container node-from-grouping {
+ leaf node-ref {
+ type leafref {
+ path "/networks/network/node/node-id";
+ require-instance false;
+ }
+ }
+ }
+ }
+ container networks {
+ description
+ "Serves as top-level container for a list of networks.";
+ list network {
+ key "network-id";
+ description
+ "Describes a network.
+ A network typically contains an inventory of nodes,
+ topological information (augmented through
+ network-topology model), as well as layering
+ information.";
+ container network-types {
+ description
+ "Serves as an augmentation target.
+ The network type is indicated through corresponding
+ presence containers augmented into this container.";
+ }
+ leaf network-id {
+ type string;
+ description
+ "Identifies a network.";
+ }
+ list supporting-network {
+ key "network-ref";
+ description
+ "An underlay network, used to represent layered network
+ topologies.";
+ leaf network-ref {
+ type leafref {
+ path "/networks/network/network-id";
+ require-instance false;
+ }
+ description
+ "References the underlay network.";
+ }
+ }
+ list node {
+ key "node-id";
+ description
+ "The inventory of nodes of this network.";
+ leaf node-id {
+ type uint8;
+ description
+ "Identifies a node uniquely within the containing
+ network.";
+ }
+ list supporting-node {
+ key "network-ref node-ref";
+ description
+ "Represents another node, in an underlay network, that
+ this node is supported by. Used to represent layering
+ structure.";
+ leaf network-ref {
+ type leafref {
+ path "../../../supporting-network/network-ref";
+ require-instance false;
+ }
+ description
+ "References the underlay network that the
+ underlay node is part of.";
+ }
+ leaf node-ref {
+ type leafref {
+ path "/networks/network/node/node-id";
+ require-instance false;
+ }
+ description
+ "References the underlay node itself.";
+ }
+ }
+ }
+ }
+ uses node-ref;
+ }
+
+}
diff --git a/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/leafrefwithrefleafderived/SelfResolutionWhenLeafrefIsInDeepTreeAndLeafListIsInModuleWithReferredTypeEnumeration.yang b/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/leafrefwithrefleafderived/SelfResolutionWhenLeafrefIsInDeepTreeAndLeafListIsInModuleWithReferredTypeEnumeration.yang
new file mode 100644
index 0000000..a3e0f29
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/leafrefwithrefleafderived/SelfResolutionWhenLeafrefIsInDeepTreeAndLeafListIsInModuleWithReferredTypeEnumeration.yang
@@ -0,0 +1,27 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ list valid {
+ key "define";
+ leaf define {
+ type string;
+ }
+ container standard {
+ container present {
+ leaf-list name {
+ type leafref {
+ path "/invalid-interval";
+ }
+ }
+ }
+ }
+ }
+ leaf-list invalid-interval {
+ type enumeration {
+ enum 10m;
+ enum 100m;
+ enum auto;
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/leafrefwithrpc/SelfResolutionWhenLeafrefInModuleReferToLeafInInputOfRpc.yang b/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/leafrefwithrpc/SelfResolutionWhenLeafrefInModuleReferToLeafInInputOfRpc.yang
new file mode 100644
index 0000000..3dce93e
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/leafrefwithrpc/SelfResolutionWhenLeafrefInModuleReferToLeafInInputOfRpc.yang
@@ -0,0 +1,23 @@
+module SelfResolutionWhenLeafrefInModuleReferToLeafInInputOfRpc {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-network";
+ prefix nd;
+ rpc networks {
+ description
+ "Serves as top-level container for a list of networks.";
+ input {
+ leaf network-id {
+ type uint8;
+ description
+ "Identifies a network.";
+ }
+ }
+ output {
+ }
+ }
+ leaf network-ref {
+ type leafref {
+ path "/networks/input/network-id";
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/leafrefwithrpcandgrouping/SelfResolutionWhenLeafrefInModuleReferToGroupingWithInputInRpc.yang b/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/leafrefwithrpcandgrouping/SelfResolutionWhenLeafrefInModuleReferToGroupingWithInputInRpc.yang
new file mode 100644
index 0000000..e8debbd
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/leafrefwithrpcandgrouping/SelfResolutionWhenLeafrefInModuleReferToGroupingWithInputInRpc.yang
@@ -0,0 +1,28 @@
+module SelfResolutionWhenLeafrefInModuleReferToGroupingWithInputInRpc {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-network";
+ prefix nd;
+ rpc networks {
+ description
+ "Serves as top-level container for a list of networks.";
+ grouping input {
+ leaf network-id {
+ type string;
+ description
+ "Identifies a network.";
+ }
+ }
+ input {
+ leaf network-id {
+ type uint8;
+ description
+ "Identifies a network.";
+ }
+ }
+ }
+ leaf network-ref {
+ type leafref {
+ path "/networks/input/network-id";
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/relativepath/invalidnode/SelfResolutionWhenLeafrefInModuleReferToInvalidNodeRelPath.yang b/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/relativepath/invalidnode/SelfResolutionWhenLeafrefInModuleReferToInvalidNodeRelPath.yang
new file mode 100644
index 0000000..9681d76
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/relativepath/invalidnode/SelfResolutionWhenLeafrefInModuleReferToInvalidNodeRelPath.yang
@@ -0,0 +1,19 @@
+module ietf-network {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-network";
+ prefix nd;
+ container networks {
+ description
+ "Serves as top-level container for a list of networks.";
+ leaf network-id {
+ type uint8;
+ description
+ "Identifies a network.";
+ }
+ }
+ leaf network-ref {
+ type leafref {
+ path "../define/network-id";
+ }
+ }
+}
\ No newline at end of file
diff --git a/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/relativepath/invalidrelativeancestoraccess/SelfResolutionWhenLeafrefInModuleReferToInvalidRootNodeRelPath.yang b/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/relativepath/invalidrelativeancestoraccess/SelfResolutionWhenLeafrefInModuleReferToInvalidRootNodeRelPath.yang
new file mode 100644
index 0000000..7e3d216
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/relativepath/invalidrelativeancestoraccess/SelfResolutionWhenLeafrefInModuleReferToInvalidRootNodeRelPath.yang
@@ -0,0 +1,19 @@
+module ietf-network {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-network";
+ prefix nd;
+ container networks {
+ description
+ "Serves as top-level container for a list of networks.";
+ leaf network-id {
+ type uint8;
+ description
+ "Identifies a network.";
+ }
+ }
+ leaf network-ref {
+ type leafref {
+ path "../../../define/network-id";
+ }
+ }
+}
\ No newline at end of file
diff --git a/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/relativepath/leafrefintypedef/SelfResolutionWhenLeafrefInTypedefReferToContainerRelPath.yang b/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/relativepath/leafrefintypedef/SelfResolutionWhenLeafrefInTypedefReferToContainerRelPath.yang
new file mode 100644
index 0000000..93d8e94
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/relativepath/leafrefintypedef/SelfResolutionWhenLeafrefInTypedefReferToContainerRelPath.yang
@@ -0,0 +1,22 @@
+module ietf-network {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-network";
+ prefix nd;
+ container networks {
+ description
+ "Serves as top-level container for a list of networks.";
+ leaf network-id {
+ type network-ref;
+ description
+ "Identifies a network.";
+ }
+ leaf id {
+ type uint8;
+ }
+ }
+ typedef network-ref {
+ type leafref {
+ path "../id";
+ }
+ }
+}
\ No newline at end of file
diff --git a/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/relativepath/leafreftoinputwithgroupinginrpc/SelfResolutionWhenLeafrefInModuleReferToGroupingWithInputInRpcRelPath.yang b/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/relativepath/leafreftoinputwithgroupinginrpc/SelfResolutionWhenLeafrefInModuleReferToGroupingWithInputInRpcRelPath.yang
new file mode 100644
index 0000000..477832d
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/relativepath/leafreftoinputwithgroupinginrpc/SelfResolutionWhenLeafrefInModuleReferToGroupingWithInputInRpcRelPath.yang
@@ -0,0 +1,28 @@
+module ietf-network {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-network";
+ prefix nd;
+ rpc networks {
+ description
+ "Serves as top-level container for a list of networks.";
+ grouping input {
+ leaf network-id {
+ type string;
+ description
+ "Identifies a network.";
+ }
+ }
+ input {
+ leaf network-id {
+ type uint8;
+ description
+ "Identifies a network.";
+ }
+ }
+ }
+ leaf network-ref {
+ type leafref {
+ path "../networks/input/network-id";
+ }
+ }
+}
\ No newline at end of file
diff --git a/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/relativepath/leafreftomultileafref/SelfResolutionWhenLeafrefReferToMultipleLeafrefRelPath.yang b/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/relativepath/leafreftomultileafref/SelfResolutionWhenLeafrefReferToMultipleLeafrefRelPath.yang
new file mode 100644
index 0000000..890bbaa
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/relativepath/leafreftomultileafref/SelfResolutionWhenLeafrefReferToMultipleLeafrefRelPath.yang
@@ -0,0 +1,50 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ list valid {
+ key "define";
+ leaf define {
+ type string;
+ }
+ container standard {
+ container present {
+ leaf-list name {
+ type leafref {
+ path "../../../../transmitter/send";
+ }
+ }
+ }
+ }
+ }
+ container reference {
+ list found {
+ key "define";
+ leaf define {
+ type string;
+ }
+ container reciever {
+ leaf remove {
+ type leafref {
+ path "../../../../valid/standard/present/name";
+ }
+ }
+ }
+ }
+ }
+ list transmitter {
+ key "send";
+ leaf send {
+ type leafref {
+ path "../../invalid-interval";
+ }
+ }
+ }
+ leaf-list invalid-interval {
+ type enumeration {
+ enum 10m;
+ enum 100m;
+ enum auto;
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/relativepath/leafreftotypedef/SelfResolutionWhenLeafrefReferToDerivedTypeReferringToLeafWithLeafrefRelType.yang b/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/relativepath/leafreftotypedef/SelfResolutionWhenLeafrefReferToDerivedTypeReferringToLeafWithLeafrefRelType.yang
new file mode 100644
index 0000000..5570f38
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/relativepath/leafreftotypedef/SelfResolutionWhenLeafrefReferToDerivedTypeReferringToLeafWithLeafrefRelType.yang
@@ -0,0 +1,45 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ list valid {
+ key "define";
+ leaf define {
+ type string;
+ }
+ container standard {
+ container present {
+ leaf-list name {
+ type transmitter;
+ }
+ }
+ }
+ }
+ container reference {
+ list found {
+ key "define";
+ leaf define {
+ type string;
+ }
+ container reciever {
+ leaf remove {
+ type leafref {
+ path "../../../../valid/standard/present/name";
+ }
+ }
+ }
+ }
+ }
+ typedef transmitter {
+ type leafref {
+ path "../../../../invalid-interval";
+ }
+ }
+ leaf invalid-interval {
+ type enumeration {
+ enum 10m;
+ enum 100m;
+ enum auto;
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/relativepath/pathlistener/PathListener.yang b/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/relativepath/pathlistener/PathListener.yang
new file mode 100644
index 0000000..c4dae28
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/relativepath/pathlistener/PathListener.yang
@@ -0,0 +1,31 @@
+module PathListener {
+ namespace "test";
+ prefix test;
+ list interface {
+ key "name";
+ leaf name {
+ type string;
+ }
+ leaf admin-status {
+ type string;
+ }
+ list address {
+ key "ip";
+ leaf ip {
+ type string;
+ }
+ }
+ }
+ container default-address {
+ leaf ifname {
+ type leafref {
+ path "../../test:interface/test:name";
+ }
+ }
+ leaf status {
+ type leafref {
+ path "/test:interface[name = current()/../ifname]/test:admin-status";
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/relativepath/simpleleafref/SelfResolutionWhenLeafrefReferToContainerLeafRelPath.yang b/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/relativepath/simpleleafref/SelfResolutionWhenLeafrefReferToContainerLeafRelPath.yang
new file mode 100644
index 0000000..05ef0d2
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/relativepath/simpleleafref/SelfResolutionWhenLeafrefReferToContainerLeafRelPath.yang
@@ -0,0 +1,19 @@
+module ietf-network {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-network";
+ prefix nd;
+ container networks {
+ description
+ "Serves as top-level container for a list of networks.";
+ leaf network-id {
+ type uint8;
+ description
+ "Identifies a network.";
+ }
+ }
+ leaf network-ref {
+ type leafref {
+ path "../networks/network-id";
+ }
+ }
+}
\ No newline at end of file
diff --git a/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/simpleleafref/SelfResolutionWhenLeafrefReferToContainerLeaf.yang b/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/simpleleafref/SelfResolutionWhenLeafrefReferToContainerLeaf.yang
new file mode 100644
index 0000000..375cace
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/leafreflinker/intrafile/simpleleafref/SelfResolutionWhenLeafrefReferToContainerLeaf.yang
@@ -0,0 +1,19 @@
+module SelfResolutionWhenLeafrefReferToContainerLeaf {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-network";
+ prefix nd;
+ container networks {
+ description
+ "Serves as top-level container for a list of networks.";
+ leaf network-id {
+ type uint8;
+ description
+ "Identifies a network.";
+ }
+ }
+ leaf network-ref {
+ type leafref {
+ path "/networks/network-id";
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/manager/MultiChild/module.yang b/compiler/plugin/maven/src/test/resources/manager/MultiChild/module.yang
new file mode 100644
index 0000000..845380b
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/manager/MultiChild/module.yang
@@ -0,0 +1,18 @@
+module test5 {
+ namespace "multi:test5:test";
+ prefix test ;
+
+ revision "2016-07-04" {
+ description "Initial revision.";
+ }
+ typedef typedef1 {
+ type int32;
+ }
+ typedef typedef2 {
+ type int32;
+ }
+ typedef typedef3 {
+ type int32;
+ }
+
+}
diff --git a/compiler/plugin/maven/src/test/resources/manager/MultiChild/submodule.yang b/compiler/plugin/maven/src/test/resources/manager/MultiChild/submodule.yang
new file mode 100644
index 0000000..92d7c21
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/manager/MultiChild/submodule.yang
@@ -0,0 +1,26 @@
+submodule test6 {
+
+ belongs-to "test5" {
+ prefix "test";
+ }
+
+ revision "2016-07-04" {
+ description "Initial revision.";
+ }
+ grouping grouping1 {
+ leaf leaf1 {
+ type int32;
+ }
+ }
+ grouping grouping2 {
+ leaf leaf1 {
+ type int32;
+ }
+ }
+
+ grouping grouping3 {
+ leaf leaf1 {
+ type int32;
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/manager/MultiChild/test.yang b/compiler/plugin/maven/src/test/resources/manager/MultiChild/test.yang
new file mode 100644
index 0000000..2665267
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/manager/MultiChild/test.yang
@@ -0,0 +1,19 @@
+module test7 {
+ namespace "multi:test5:test";
+ prefix test ;
+
+ revision "2016-07-04" {
+ description "Initial revision.";
+ }
+
+ grouping grouping1 {
+ leaf leaf1 {
+ type int32;
+ }
+ }
+
+ typedef typedef3 {
+ type int32;
+ }
+
+}
diff --git a/compiler/plugin/maven/src/test/resources/manager/MultiChild/test2.yang b/compiler/plugin/maven/src/test/resources/manager/MultiChild/test2.yang
new file mode 100644
index 0000000..c87022d
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/manager/MultiChild/test2.yang
@@ -0,0 +1,22 @@
+module test8 {
+ namespace "multi:test8:test";
+ prefix test ;
+
+ revision "2016-07-04" {
+ description "Initial revision.";
+ }
+
+ grouping grouping1 {
+ leaf leaf1 {
+ type int32;
+ }
+ }
+
+ typedef typedef3 {
+ type int32;
+ }
+
+ container container2 {
+ }
+
+}
diff --git a/compiler/plugin/maven/src/test/resources/manager/genwithoutrev/module.yang b/compiler/plugin/maven/src/test/resources/manager/genwithoutrev/module.yang
new file mode 100644
index 0000000..bcc1cc7
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/manager/genwithoutrev/module.yang
@@ -0,0 +1,9 @@
+module test5 {
+ namespace "test5:test";
+ prefix test ;
+
+ leaf a-leaf {
+ type int32;
+ }
+
+}
diff --git a/compiler/plugin/maven/src/test/resources/manager/nogen/module.yang b/compiler/plugin/maven/src/test/resources/manager/nogen/module.yang
new file mode 100644
index 0000000..97d79b6
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/manager/nogen/module.yang
@@ -0,0 +1,9 @@
+module test5 {
+ namespace "test5:test";
+ prefix test ;
+
+ revision "2016-07-04" {
+ description "Initial revision.";
+ }
+
+}
diff --git a/compiler/plugin/maven/src/test/resources/manager/singleChild/module.yang b/compiler/plugin/maven/src/test/resources/manager/singleChild/module.yang
new file mode 100644
index 0000000..67f4bc9
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/manager/singleChild/module.yang
@@ -0,0 +1,12 @@
+module test5 {
+ namespace "single:test5:test";
+ prefix test ;
+
+ revision "2016-07-04" {
+ description "Initial revision.";
+ }
+ typedef typedef1 {
+ type int32;
+ }
+
+}
diff --git a/compiler/plugin/maven/src/test/resources/manager/singleChild/submodule.yang b/compiler/plugin/maven/src/test/resources/manager/singleChild/submodule.yang
new file mode 100644
index 0000000..541b7dd
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/manager/singleChild/submodule.yang
@@ -0,0 +1,15 @@
+submodule test6 {
+
+ belongs-to "test5" {
+ prefix "test";
+ }
+
+ revision "2016-07-04" {
+ description "Initial revision.";
+ }
+ grouping grouping1 {
+ leaf leaf1 {
+ type int32;
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/manager/singleChild/test.yang b/compiler/plugin/maven/src/test/resources/manager/singleChild/test.yang
new file mode 100644
index 0000000..2d13b4c
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/manager/singleChild/test.yang
@@ -0,0 +1,12 @@
+module test7 {
+ namespace "single:test5:test";
+ prefix test ;
+
+ revision "2016-07-04" {
+ description "Initial revision.";
+ }
+
+ container cont1 {
+ }
+
+}
diff --git a/compiler/plugin/maven/src/test/resources/org/onosproject/yang/compiler/parser/impl/decimal64/Decimal64MultiTypedefMultiInvalidRangeStatement.yang b/compiler/plugin/maven/src/test/resources/org/onosproject/yang/compiler/parser/impl/decimal64/Decimal64MultiTypedefMultiInvalidRangeStatement.yang
new file mode 100644
index 0000000..966b387
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/org/onosproject/yang/compiler/parser/impl/decimal64/Decimal64MultiTypedefMultiInvalidRangeStatement.yang
@@ -0,0 +1,22 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+
+ typedef topDecimal {
+ type decimal64 {
+ fraction-digits 4;
+ range 4..11;
+ }
+ }
+
+ typedef midDecimal {
+ type topDecimal;
+ }
+
+ leaf lowerDecimal {
+ type midDecimal {
+ range 1..12;
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/org/onosproject/yang/compiler/parser/impl/decimal64/Decimal64MultiTypedefMultiRangeStatement.yang b/compiler/plugin/maven/src/test/resources/org/onosproject/yang/compiler/parser/impl/decimal64/Decimal64MultiTypedefMultiRangeStatement.yang
new file mode 100644
index 0000000..76f215a
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/org/onosproject/yang/compiler/parser/impl/decimal64/Decimal64MultiTypedefMultiRangeStatement.yang
@@ -0,0 +1,22 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+
+ typedef topDecimal {
+ type decimal64 {
+ fraction-digits 4;
+ range 1..12;
+ }
+ }
+
+ typedef midDecimal {
+ type topDecimal;
+ }
+
+ leaf lowerDecimal {
+ type midDecimal {
+ range 4..11;
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/org/onosproject/yang/compiler/parser/impl/decimal64/Decimal64MultiTypedefRangeInLeafStatement.yang b/compiler/plugin/maven/src/test/resources/org/onosproject/yang/compiler/parser/impl/decimal64/Decimal64MultiTypedefRangeInLeafStatement.yang
new file mode 100644
index 0000000..eea48f4
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/org/onosproject/yang/compiler/parser/impl/decimal64/Decimal64MultiTypedefRangeInLeafStatement.yang
@@ -0,0 +1,21 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+
+ typedef topDecimal {
+ type decimal64 {
+ fraction-digits 4;
+ }
+ }
+
+ typedef midDecimal {
+ type topDecimal;
+ }
+
+ leaf lowerDecimal {
+ type midDecimal {
+ range 1..12;
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/org/onosproject/yang/compiler/parser/impl/decimal64/Decimal64MultiTypedefRangeStatement.yang b/compiler/plugin/maven/src/test/resources/org/onosproject/yang/compiler/parser/impl/decimal64/Decimal64MultiTypedefRangeStatement.yang
new file mode 100644
index 0000000..b4c0a36
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/org/onosproject/yang/compiler/parser/impl/decimal64/Decimal64MultiTypedefRangeStatement.yang
@@ -0,0 +1,20 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+
+ typedef topDecimal {
+ type decimal64 {
+ fraction-digits 4;
+ range 1..12;
+ }
+ }
+
+ typedef midDecimal {
+ type topDecimal;
+ }
+
+ leaf lowerDecimal {
+ type midDecimal;
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/org/onosproject/yang/compiler/parser/impl/decimal64/Decimal64MultiTypedefStatement.yang b/compiler/plugin/maven/src/test/resources/org/onosproject/yang/compiler/parser/impl/decimal64/Decimal64MultiTypedefStatement.yang
new file mode 100644
index 0000000..8682aac
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/org/onosproject/yang/compiler/parser/impl/decimal64/Decimal64MultiTypedefStatement.yang
@@ -0,0 +1,19 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+
+ typedef topDecimal {
+ type decimal64 {
+ fraction-digits 4;
+ }
+ }
+
+ typedef midDecimal {
+ type topDecimal;
+ }
+
+ leaf lowerDecimal {
+ type midDecimal;
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/org/onosproject/yang/compiler/parser/impl/decimal64/Decimal64MultiTypedefWithMaxRange.yang b/compiler/plugin/maven/src/test/resources/org/onosproject/yang/compiler/parser/impl/decimal64/Decimal64MultiTypedefWithMaxRange.yang
new file mode 100644
index 0000000..405d08c
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/org/onosproject/yang/compiler/parser/impl/decimal64/Decimal64MultiTypedefWithMaxRange.yang
@@ -0,0 +1,22 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+
+ typedef topDecimal {
+ type decimal64 {
+ fraction-digits 4;
+ range 1..12;
+ }
+ }
+
+ typedef midDecimal {
+ type topDecimal;
+ }
+
+ leaf lowerDecimal {
+ type midDecimal {
+ range 4..max;
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/org/onosproject/yang/compiler/parser/impl/decimal64/Decimal64TypeInvalidMaxValueFraction.yang b/compiler/plugin/maven/src/test/resources/org/onosproject/yang/compiler/parser/impl/decimal64/Decimal64TypeInvalidMaxValueFraction.yang
new file mode 100644
index 0000000..68bd8df
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/org/onosproject/yang/compiler/parser/impl/decimal64/Decimal64TypeInvalidMaxValueFraction.yang
@@ -0,0 +1,11 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+
+ leaf invalidDecimal1 {
+ type decimal64 {
+ fraction-digits 19;
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/org/onosproject/yang/compiler/parser/impl/decimal64/Decimal64TypeInvalidMinValueFraction1.yang b/compiler/plugin/maven/src/test/resources/org/onosproject/yang/compiler/parser/impl/decimal64/Decimal64TypeInvalidMinValueFraction1.yang
new file mode 100644
index 0000000..3d7445a
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/org/onosproject/yang/compiler/parser/impl/decimal64/Decimal64TypeInvalidMinValueFraction1.yang
@@ -0,0 +1,11 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+
+ leaf invalidDecimal2 {
+ type decimal64 {
+ fraction-digits 0;
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/org/onosproject/yang/compiler/parser/impl/decimal64/Decimal64TypeInvalidMinValueFraction2.yang b/compiler/plugin/maven/src/test/resources/org/onosproject/yang/compiler/parser/impl/decimal64/Decimal64TypeInvalidMinValueFraction2.yang
new file mode 100644
index 0000000..4e17bbe
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/org/onosproject/yang/compiler/parser/impl/decimal64/Decimal64TypeInvalidMinValueFraction2.yang
@@ -0,0 +1,11 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+
+ leaf invalidDecimal3 {
+ type decimal64 {
+ fraction-digits -1;
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/org/onosproject/yang/compiler/parser/impl/decimal64/Decimal64TypeInvalidRangeStmnt.yang b/compiler/plugin/maven/src/test/resources/org/onosproject/yang/compiler/parser/impl/decimal64/Decimal64TypeInvalidRangeStmnt.yang
new file mode 100644
index 0000000..2ac3d94
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/org/onosproject/yang/compiler/parser/impl/decimal64/Decimal64TypeInvalidRangeStmnt.yang
@@ -0,0 +1,11 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf validDecimal {
+ type decimal64 {
+ fraction-digits 18;
+ range "1 .. 20.14";
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/org/onosproject/yang/compiler/parser/impl/decimal64/Decimal64TypeStatement.yang b/compiler/plugin/maven/src/test/resources/org/onosproject/yang/compiler/parser/impl/decimal64/Decimal64TypeStatement.yang
new file mode 100644
index 0000000..9824c12
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/org/onosproject/yang/compiler/parser/impl/decimal64/Decimal64TypeStatement.yang
@@ -0,0 +1,10 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf validDecimal {
+ type decimal64 {
+ fraction-digits 2;
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/org/onosproject/yang/compiler/parser/impl/decimal64/Decimal64TypeValidation.yang b/compiler/plugin/maven/src/test/resources/org/onosproject/yang/compiler/parser/impl/decimal64/Decimal64TypeValidation.yang
new file mode 100644
index 0000000..06bf5b7
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/org/onosproject/yang/compiler/parser/impl/decimal64/Decimal64TypeValidation.yang
@@ -0,0 +1,10 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf validDecimal {
+ type decimal64 {
+ fraction-digits 18;
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/org/onosproject/yang/compiler/parser/impl/decimal64/Decimal64TypeWithMultiValueRangeStmnt.yang b/compiler/plugin/maven/src/test/resources/org/onosproject/yang/compiler/parser/impl/decimal64/Decimal64TypeWithMultiValueRangeStmnt.yang
new file mode 100644
index 0000000..f657134
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/org/onosproject/yang/compiler/parser/impl/decimal64/Decimal64TypeWithMultiValueRangeStmnt.yang
@@ -0,0 +1,11 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf validDecimal {
+ type decimal64 {
+ fraction-digits 18;
+ range "-9.22..7.22 | 8 | 9..max";
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/org/onosproject/yang/compiler/parser/impl/decimal64/Decimal64TypeWithRangeStatement.yang b/compiler/plugin/maven/src/test/resources/org/onosproject/yang/compiler/parser/impl/decimal64/Decimal64TypeWithRangeStatement.yang
new file mode 100644
index 0000000..f184927
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/org/onosproject/yang/compiler/parser/impl/decimal64/Decimal64TypeWithRangeStatement.yang
@@ -0,0 +1,11 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf validDecimal {
+ type decimal64 {
+ fraction-digits 8;
+ range "-92233720368.54775808 .. 92233720368.54775807";
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/org/onosproject/yang/compiler/parser/impl/decimal64/Decimal64TypeWithoutFraction.yang b/compiler/plugin/maven/src/test/resources/org/onosproject/yang/compiler/parser/impl/decimal64/Decimal64TypeWithoutFraction.yang
new file mode 100644
index 0000000..e7b8beb
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/org/onosproject/yang/compiler/parser/impl/decimal64/Decimal64TypeWithoutFraction.yang
@@ -0,0 +1,8 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf validDecimal {
+ type decimal64;
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/org/onosproject/yang/compiler/parser/impl/decimal64/Decimal64TypedefStatement.yang b/compiler/plugin/maven/src/test/resources/org/onosproject/yang/compiler/parser/impl/decimal64/Decimal64TypedefStatement.yang
new file mode 100644
index 0000000..66addd2
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/org/onosproject/yang/compiler/parser/impl/decimal64/Decimal64TypedefStatement.yang
@@ -0,0 +1,15 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+
+ typedef validDecimal {
+ type decimal64 {
+ fraction-digits 4;
+ }
+ }
+
+ leaf setFourDecimal {
+ type validDecimal;
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/pathpredicate/interfileaugment/ietf-network.yang b/compiler/plugin/maven/src/test/resources/pathpredicate/interfileaugment/ietf-network.yang
new file mode 100644
index 0000000..8e650da
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/pathpredicate/interfileaugment/ietf-network.yang
@@ -0,0 +1,21 @@
+module ietf-network {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-network";
+ prefix nd;
+ container networks {
+ list network {
+ key "network-id";
+ leaf network-id {
+ type uint8;
+ }
+ container reference {
+ leaf network-ref {
+ type string;
+ }
+ }
+ leaf node-id {
+ type int8;
+ }
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/pathpredicate/interfileaugment/ietf-topology.yang b/compiler/plugin/maven/src/test/resources/pathpredicate/interfileaugment/ietf-topology.yang
new file mode 100644
index 0000000..93bfa80
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/pathpredicate/interfileaugment/ietf-topology.yang
@@ -0,0 +1,18 @@
+module ietf-topology {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-te-topology";
+ // replace with IANA namespace when assigned
+ prefix "tet";
+
+ import ietf-network {
+ prefix "nw";
+ }
+ augment "/nw:networks/nw:network" {
+ leaf test {
+ type leafref {
+ path "../../nw:network[nw:network-id = current()/../" +
+ "nw:reference/nw:network-ref]/nw:node-id";
+ }
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/pathpredicate/invalidlinking/ietf-network.yang b/compiler/plugin/maven/src/test/resources/pathpredicate/invalidlinking/ietf-network.yang
new file mode 100644
index 0000000..13bcb3e
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/pathpredicate/invalidlinking/ietf-network.yang
@@ -0,0 +1,33 @@
+module ietf-network {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-network";
+ prefix nd;
+ list interface {
+ key "name";
+ leaf name {
+ type string;
+ }
+ leaf admin-status {
+ type uint8;
+ }
+ list address {
+ key "ip";
+ leaf ip {
+ type int8;
+ }
+ }
+ }
+ container default-address {
+ leaf ifname {
+ type leafref {
+ path "../../interface/name";
+ }
+ }
+ leaf address {
+ type leafref {
+ path "../../interface[ifname = current()/../../ifname]"
+ + "/address/ip";
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/compiler/plugin/maven/src/test/resources/pathpredicate/invalidlinking2/ietf-network.yang b/compiler/plugin/maven/src/test/resources/pathpredicate/invalidlinking2/ietf-network.yang
new file mode 100644
index 0000000..7c1881b
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/pathpredicate/invalidlinking2/ietf-network.yang
@@ -0,0 +1,33 @@
+module ietf-network {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-network";
+ prefix nd;
+ list interface {
+ key "name";
+ leaf name {
+ type string;
+ }
+ leaf admin-status {
+ type uint8;
+ }
+ list address {
+ key "ip";
+ leaf ip {
+ type int8;
+ }
+ }
+ }
+ container default-address {
+ leaf ifname {
+ type leafref {
+ path "../../interface/name";
+ }
+ }
+ leaf address {
+ type leafref {
+ path "../../default-address[ifname = current()/../ifname]/" +
+ "ifname";
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/compiler/plugin/maven/src/test/resources/pathpredicate/invalidlinking3/ietf-network.yang b/compiler/plugin/maven/src/test/resources/pathpredicate/invalidlinking3/ietf-network.yang
new file mode 100644
index 0000000..9ebb2ce
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/pathpredicate/invalidlinking3/ietf-network.yang
@@ -0,0 +1,33 @@
+module ietf-network {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-network";
+ prefix nd;
+ list interface {
+ key "name";
+ leaf name {
+ type string;
+ }
+ leaf admin-status {
+ type uint8;
+ }
+ list address {
+ key "ip";
+ leaf ip {
+ type int8;
+ }
+ }
+ }
+ container default-address {
+ leaf ifname {
+ type leafref {
+ path "../../interface/name";
+ }
+ }
+ leaf address {
+ type leafref {
+ path "../../interface[name = current()/../../address/ifname]"
+ + "/address/ip";
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/compiler/plugin/maven/src/test/resources/pathpredicate/simple/ietf-network.yang b/compiler/plugin/maven/src/test/resources/pathpredicate/simple/ietf-network.yang
new file mode 100644
index 0000000..5c1ecdd
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/pathpredicate/simple/ietf-network.yang
@@ -0,0 +1,33 @@
+module ietf-network {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-network";
+ prefix nd;
+ list interface {
+ key "name";
+ leaf name {
+ type string;
+ }
+ leaf admin-status {
+ type uint8;
+ }
+ list address {
+ key "ip";
+ leaf ip {
+ type int8;
+ }
+ }
+ }
+ container default-address {
+ leaf ifname {
+ type leafref {
+ path "../../interface/name";
+ }
+ }
+ leaf address {
+ type leafref {
+ path "../../interface[name = current()/../ifname]"
+ + "/address/ip";
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/compiler/plugin/maven/src/test/resources/pathpredicate/simpleinterfile/ietf-network.yang b/compiler/plugin/maven/src/test/resources/pathpredicate/simpleinterfile/ietf-network.yang
new file mode 100644
index 0000000..33d77dd
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/pathpredicate/simpleinterfile/ietf-network.yang
@@ -0,0 +1,22 @@
+module ietf-network {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-network";
+ prefix nd;
+ import ietf-topology {
+ prefix tp;
+ }
+ container default-address {
+ leaf ifname {
+ type leafref {
+ path "/tp:interface/tp:name";
+ }
+ }
+ leaf address {
+ type leafref {
+ path "/tp:interface[tp:name = current()/../nd:ifname]"
+ + "/tp:address/ip";
+ }
+ }
+ }
+}
+
diff --git a/compiler/plugin/maven/src/test/resources/pathpredicate/simpleinterfile/ietf-topology.yang b/compiler/plugin/maven/src/test/resources/pathpredicate/simpleinterfile/ietf-topology.yang
new file mode 100644
index 0000000..63db761
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/pathpredicate/simpleinterfile/ietf-topology.yang
@@ -0,0 +1,21 @@
+ module ietf-topology {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-topology";
+ prefix tp;
+ list interface {
+ key "name";
+ leaf name {
+ type string;
+ }
+ leaf admin-status {
+ type uint8;
+ }
+ list address {
+ key "ip";
+ leaf ip {
+ type int8;
+ }
+ }
+ }
+ }
+
diff --git a/compiler/plugin/maven/src/test/resources/pstcodegen/test.yang b/compiler/plugin/maven/src/test/resources/pstcodegen/test.yang
new file mode 100644
index 0000000..93e1476
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/pstcodegen/test.yang
@@ -0,0 +1,83 @@
+module test {
+ namespace "test:test";
+ prefix test;
+
+ container cont1 {
+ leaf leaf1 {
+ type int32;
+ }
+ leaf-list leaf-list1 {
+ type int32;
+ }
+ list list1 {
+ key "name";
+ leaf name {
+ type string;
+ }
+ }
+ container cont2 {
+ leaf leaf2 {
+ type int32;
+ }
+ }
+ }
+ leaf leaf2 {
+ type int32;
+ }
+ leaf-list leaf-list2 {
+ type int32;
+ }
+ list list2 {
+ key "name";
+ leaf name {
+ type string;
+ }
+ }
+ choice choice1 {
+ case case1 {
+ leaf leaf3 {
+ type int32;
+ }
+ leaf-list leaf-list3 {
+ type int32;
+ }
+ list list3 {
+ key "name";
+ leaf name {
+ type string;
+ }
+ }
+ }
+ }
+ grouping group1 {
+ container cont1 {
+ leaf leaf1 {
+ type int32;
+ }
+ leaf-list leaf-list1 {
+ type int32;
+ }
+ list list1 {
+ key "name";
+ leaf name {
+ type string;
+ }
+ }
+ container cont2 {
+ leaf leaf2 {
+ type int32;
+ }
+ }
+ }
+ }
+ rpc rpc1 {
+ input {
+ uses group1;
+ }
+ }
+ augment /cont1/list1 {
+ leaf leaf2 {
+ type int64;
+ }
+ }
+}
\ No newline at end of file
diff --git a/compiler/plugin/maven/src/test/resources/refincludecontentwithprefix/ietf-snmp-common.yang b/compiler/plugin/maven/src/test/resources/refincludecontentwithprefix/ietf-snmp-common.yang
new file mode 100644
index 0000000..ed382c8
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/refincludecontentwithprefix/ietf-snmp-common.yang
@@ -0,0 +1,60 @@
+submodule ietf-snmp-common {
+ belongs-to ietf-snmp {
+ prefix snmp;
+ }
+ organization
+ "IETF NETMOD (NETCONF Data Modeling Language) Working Group";
+ contact
+ "WG Web: <http://tools.ietf.org/wg/netmod/>
+ WG List: <mailto:netmod@ietf.org>
+ WG Chair: Thomas Nadeau
+ <mailto:tnadeau@lucidvision.com>
+ WG Chair: Juergen Schoenwaelder
+ <mailto:j.schoenwaelder@jacobs-university.de>
+ Editor: Martin Bjorklund
+ <mailto:mbj@tail-f.com>
+ Editor: Juergen Schoenwaelder
+ <mailto:j.schoenwaelder@jacobs-university.de>";
+ description
+ "This submodule contains a collection of common YANG definitions
+ for configuring SNMP engines.
+ Copyright (c) 2014 IETF Trust and the persons identified as
+ authors of the code. All rights reserved.
+ Redistribution and use in source and binary forms, with or
+ without modification, is permitted pursuant to, and subject
+ to the license terms contained in, the Simplified BSD License
+ set forth in Section 4.c of the IETF Trust's Legal Provisions
+ Relating to IETF Documents
+ (http://trustee.ietf.org/license-info).
+ This version of this YANG module is part of RFC 7407; see
+ the RFC itself for full legal notices.";
+ revision 2014-12-10 {
+ description
+ "Initial revision.";
+ reference
+ "RFC 7407: A YANG Data Model for SNMP Configuration";
+ }
+ /* Collection of SNMP-specific data types */
+ typedef admin-string {
+ type string {
+ length "0..255";
+ }
+ description
+ "Represents SnmpAdminString as defined in RFC 3411.
+ Note that the size of an SnmpAdminString is measured in
+ octets, not characters.";
+ reference
+ "RFC 3411: An Architecture for Describing Simple Network
+ Management Protocol (SNMP) Management Frameworks.
+ SNMP-FRAMEWORK-MIB.SnmpAdminString";
+ }
+ typedef identifier {
+ type admin-string {
+ length "1..32";
+ }
+ description
+ "Identifiers are used to name items in the SNMP configuration
+ datastore.";
+ }
+ feature testfeature;
+}
diff --git a/compiler/plugin/maven/src/test/resources/refincludecontentwithprefix/ietf-snmp-vacm.yang b/compiler/plugin/maven/src/test/resources/refincludecontentwithprefix/ietf-snmp-vacm.yang
new file mode 100644
index 0000000..5b6595d
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/refincludecontentwithprefix/ietf-snmp-vacm.yang
@@ -0,0 +1,51 @@
+submodule ietf-snmp-vacm {
+ belongs-to ietf-snmp {
+ prefix snmp;
+ }
+ include ietf-snmp-common;
+ organization
+ "IETF NETMOD (NETCONF Data Modeling Language) Working Group";
+ contact
+ "WG Web: <http://tools.ietf.org/wg/netmod/>
+ WG List: <mailto:netmod@ietf.org>
+ WG Chair: Thomas Nadeau
+ <mailto:tnadeau@lucidvision.com>
+ WG Chair: Juergen Schoenwaelder
+ <mailto:j.schoenwaelder@jacobs-university.de>
+ Editor: Martin Bjorklund
+ <mailto:mbj@tail-f.com>
+ Editor: Juergen Schoenwaelder
+ <mailto:j.schoenwaelder@jacobs-university.de>";
+ description
+ "This submodule contains a collection of YANG definitions
+ for configuring the View-based Access Control Model (VACM)
+ of SNMP.
+ Copyright (c) 2014 IETF Trust and the persons identified as
+ authors of the code. All rights reserved.
+ Redistribution and use in source and binary forms, with or
+ without modification, is permitted pursuant to, and subject
+ to the license terms contained in, the Simplified BSD License
+ set forth in Section 4.c of the IETF Trust's Legal Provisions
+ Relating to IETF Documents
+ (http://trustee.ietf.org/license-info).
+ This version of this YANG module is part of RFC 7407; see
+ the RFC itself for full legal notices.";
+ reference
+ "RFC 3415: View-based Access Control Model (VACM) for the
+ Simple Network Management Protocol (SNMP)";
+ revision 2014-12-10 {
+ description
+ "Initial revision.";
+ reference
+ "RFC 7407: A YANG Data Model for SNMP Configuration";
+ }
+ typedef view-name {
+ type snmp:identifier;
+ description
+ "The view-name type represents an SNMP VACM view name.";
+ }
+ leaf testleaf {
+ if-feature snmp:testfeature;
+ type string;
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/refincludecontentwithprefix/ietf-snmp.yang b/compiler/plugin/maven/src/test/resources/refincludecontentwithprefix/ietf-snmp.yang
new file mode 100644
index 0000000..224849c
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/refincludecontentwithprefix/ietf-snmp.yang
@@ -0,0 +1,42 @@
+module ietf-snmp {
+ namespace "urn:ietf:params:xml:ns:yang:ietf-snmp";
+ prefix snmp;
+ include ietf-snmp-common {
+ revision-date 2014-12-10;
+ }
+ include ietf-snmp-vacm {
+ revision-date 2014-12-10;
+ }
+ organization
+ "IETF NETMOD (NETCONF Data Modeling Language) Working Group";
+ contact
+ "WG Web: <http://tools.ietf.org/wg/netmod/>
+ WG List: <mailto:netmod@ietf.org>
+ WG Chair: Thomas Nadeau
+ <mailto:tnadeau@lucidvision.com>
+ WG Chair: Juergen Schoenwaelder
+ <mailto:j.schoenwaelder@jacobs-university.de>
+ Editor: Martin Bjorklund
+ <mailto:mbj@tail-f.com>
+ Editor: Juergen Schoenwaelder
+ <mailto:j.schoenwaelder@jacobs-university.de>";
+ description
+ "This module contains a collection of YANG definitions for
+ configuring SNMP engines.
+ Copyright (c) 2014 IETF Trust and the persons identified as
+ authors of the code. All rights reserved.
+ Redistribution and use in source and binary forms, with or
+ without modification, is permitted pursuant to, and subject
+ to the license terms contained in, the Simplified BSD License
+ set forth in Section 4.c of the IETF Trust's Legal Provisions
+ Relating to IETF Documents
+ (http://trustee.ietf.org/license-info).
+ This version of this YANG module is part of RFC 7407; see
+ the RFC itself for full legal notices.";
+ revision 2014-12-10 {
+ description
+ "Initial revision.";
+ reference
+ "RFC 7407: A YANG Data Model for SNMP Configuration";
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/rootNode/mixed/module.yang b/compiler/plugin/maven/src/test/resources/rootNode/mixed/module.yang
new file mode 100644
index 0000000..e3e5571
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/rootNode/mixed/module.yang
@@ -0,0 +1,21 @@
+module test5 {
+ namespace "test5:test";
+ prefix test ;
+
+ include test6;
+ revision "2016-07-04" {
+ description "Initial revision.";
+ }
+
+ augment /cont1 {
+ leaf cont1 {
+ type string;
+ }
+ }
+ augment /cont2 {
+ leaf cont2 {
+ type string;
+ }
+ }
+
+}
diff --git a/compiler/plugin/maven/src/test/resources/rootNode/mixed/submodule.yang b/compiler/plugin/maven/src/test/resources/rootNode/mixed/submodule.yang
new file mode 100644
index 0000000..e7c497e
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/rootNode/mixed/submodule.yang
@@ -0,0 +1,25 @@
+submodule test6 {
+
+ belongs-to "test5" {
+ prefix "test";
+ }
+
+ revision "2016-07-04" {
+ description "Initial revision.";
+ }
+
+ typedef typedef {
+ type int32;
+ }
+ container cont1 {
+ leaf leaf1 {
+ type int32;
+ }
+ }
+ container cont2 {
+ leaf leaf1 {
+ type int32;
+ }
+ }
+
+}
diff --git a/compiler/plugin/maven/src/test/resources/rootNode/nogen/module.yang b/compiler/plugin/maven/src/test/resources/rootNode/nogen/module.yang
new file mode 100644
index 0000000..97d79b6
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/rootNode/nogen/module.yang
@@ -0,0 +1,9 @@
+module test5 {
+ namespace "test5:test";
+ prefix test ;
+
+ revision "2016-07-04" {
+ description "Initial revision.";
+ }
+
+}
diff --git a/compiler/plugin/maven/src/test/resources/rootNode/onlyaugment/module.yang b/compiler/plugin/maven/src/test/resources/rootNode/onlyaugment/module.yang
new file mode 100644
index 0000000..e3e5571
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/rootNode/onlyaugment/module.yang
@@ -0,0 +1,21 @@
+module test5 {
+ namespace "test5:test";
+ prefix test ;
+
+ include test6;
+ revision "2016-07-04" {
+ description "Initial revision.";
+ }
+
+ augment /cont1 {
+ leaf cont1 {
+ type string;
+ }
+ }
+ augment /cont2 {
+ leaf cont2 {
+ type string;
+ }
+ }
+
+}
diff --git a/compiler/plugin/maven/src/test/resources/rootNode/onlyaugment/submodule.yang b/compiler/plugin/maven/src/test/resources/rootNode/onlyaugment/submodule.yang
new file mode 100644
index 0000000..9acc939
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/rootNode/onlyaugment/submodule.yang
@@ -0,0 +1,21 @@
+submodule test6 {
+
+ belongs-to "test5" {
+ prefix "test";
+ }
+
+ revision "2016-07-04" {
+ description "Initial revision.";
+ }
+ container cont1 {
+ leaf leaf1 {
+ type int32;
+ }
+ }
+ container cont2 {
+ leaf leaf1 {
+ type int32;
+ }
+ }
+
+}
diff --git a/compiler/plugin/maven/src/test/resources/rootNode/onlygrouping/module.yang b/compiler/plugin/maven/src/test/resources/rootNode/onlygrouping/module.yang
new file mode 100644
index 0000000..1c4637c
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/rootNode/onlygrouping/module.yang
@@ -0,0 +1,18 @@
+module test5 {
+ namespace "test5:test";
+ prefix test ;
+
+ revision "2016-07-04" {
+ description "Initial revision.";
+ }
+ typedef typedef1 {
+ type int32;
+ }
+ typedef typedef2 {
+ type int32;
+ }
+ typedef typedef3 {
+ type int32;
+ }
+
+}
diff --git a/compiler/plugin/maven/src/test/resources/rootNode/onlygrouping/submodule.yang b/compiler/plugin/maven/src/test/resources/rootNode/onlygrouping/submodule.yang
new file mode 100644
index 0000000..92d7c21
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/rootNode/onlygrouping/submodule.yang
@@ -0,0 +1,26 @@
+submodule test6 {
+
+ belongs-to "test5" {
+ prefix "test";
+ }
+
+ revision "2016-07-04" {
+ description "Initial revision.";
+ }
+ grouping grouping1 {
+ leaf leaf1 {
+ type int32;
+ }
+ }
+ grouping grouping2 {
+ leaf leaf1 {
+ type int32;
+ }
+ }
+
+ grouping grouping3 {
+ leaf leaf1 {
+ type int32;
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/rootNode/onlyleaf/module.yang b/compiler/plugin/maven/src/test/resources/rootNode/onlyleaf/module.yang
new file mode 100644
index 0000000..61864ad
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/rootNode/onlyleaf/module.yang
@@ -0,0 +1,15 @@
+module test5 {
+ namespace "test5:test";
+ prefix test ;
+
+ revision "2016-07-04" {
+ description "Initial revision.";
+ }
+ leaf a-leaf {
+ type int32;
+ }
+ leaf b-leaf {
+ type int32;
+ }
+
+}
diff --git a/compiler/plugin/maven/src/test/resources/rootNode/onlyleaflist/module.yang b/compiler/plugin/maven/src/test/resources/rootNode/onlyleaflist/module.yang
new file mode 100644
index 0000000..d8cf6b3
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/rootNode/onlyleaflist/module.yang
@@ -0,0 +1,15 @@
+module test5 {
+ namespace "test5:test";
+ prefix test ;
+
+ revision "2016-07-04" {
+ description "Initial revision.";
+ }
+ leaf-list a-leaf {
+ type int32;
+ }
+ leaf-list b-leaf {
+ type int32;
+ }
+
+}
diff --git a/compiler/plugin/maven/src/test/resources/rootNode/onlytypedef/module.yang b/compiler/plugin/maven/src/test/resources/rootNode/onlytypedef/module.yang
new file mode 100644
index 0000000..1c4637c
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/rootNode/onlytypedef/module.yang
@@ -0,0 +1,18 @@
+module test5 {
+ namespace "test5:test";
+ prefix test ;
+
+ revision "2016-07-04" {
+ description "Initial revision.";
+ }
+ typedef typedef1 {
+ type int32;
+ }
+ typedef typedef2 {
+ type int32;
+ }
+ typedef typedef3 {
+ type int32;
+ }
+
+}
diff --git a/compiler/plugin/maven/src/test/resources/rootNode/typedefgrouping/module.yang b/compiler/plugin/maven/src/test/resources/rootNode/typedefgrouping/module.yang
new file mode 100644
index 0000000..b54ad47
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/rootNode/typedefgrouping/module.yang
@@ -0,0 +1,17 @@
+module test5 {
+ namespace "test5:test";
+ prefix test ;
+
+ revision "2016-07-04" {
+ description "Initial revision.";
+ }
+ typedef typedef1 {
+ type int32;
+ }
+ grouping group1 {
+ leaf typedef-leaf {
+ type typedef1;
+ }
+ }
+
+}
diff --git a/compiler/plugin/maven/src/test/resources/rpcAugment/inter/1.yang b/compiler/plugin/maven/src/test/resources/rpcAugment/inter/1.yang
new file mode 100644
index 0000000..dcfe919
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/rpcAugment/inter/1.yang
@@ -0,0 +1,17 @@
+module ietf-inet1 {
+
+ namespace "yang:all1";
+ prefix "inet1";
+ yang-version 1;
+
+ import ietf-inet2 {
+ prefix inet2;
+ }
+
+ augment /inet2:get-port/inet2:input {
+ leaf port {
+ type int32;
+ }
+ }
+
+}
diff --git a/compiler/plugin/maven/src/test/resources/rpcAugment/inter/2.yang b/compiler/plugin/maven/src/test/resources/rpcAugment/inter/2.yang
new file mode 100644
index 0000000..7c6ccbf
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/rpcAugment/inter/2.yang
@@ -0,0 +1,33 @@
+module ietf-inet2 {
+
+ namespace "yang:all2";
+ prefix "inet2";
+ yang-version 1;
+
+
+ rpc get-port {
+ input {
+ leaf port {
+ type int32;
+ }
+
+ leaf-list port-id {
+ type string;
+ }
+ }
+ output {
+ container port {
+ leaf port-number {
+ type enumeration {
+ enum zero-0;
+ }
+ }
+ leaf ip {
+ type int32;
+ }
+ }
+ }
+ }
+
+
+}
diff --git a/compiler/plugin/maven/src/test/resources/rpcAugment/intra/all.yang b/compiler/plugin/maven/src/test/resources/rpcAugment/intra/all.yang
new file mode 100644
index 0000000..6fc76ea
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/rpcAugment/intra/all.yang
@@ -0,0 +1,103 @@
+module ietf-inet {
+
+ namespace "yang:all";
+ prefix "inet";
+ yang-version 1;
+
+ typedef ip-address {
+ type int32;
+ }
+
+ leaf-list id {
+ type string;
+ }
+
+ leaf mybits {
+ type bits {
+ bit disable-nagle {
+ position 0;
+ }
+ bit auto-sense-speed {
+ position 1;
+ }
+ bit Mb-only {
+ position 2;
+ }
+ }
+ }
+
+ container network {
+ leaf network-ip {
+ type ip-address;
+ }
+ }
+
+ typedef leaf1 {
+ type leafref {
+ path "/network/network-ip";
+ }
+ }
+
+ grouping link-details {
+ leaf link-id {
+ type int32;
+ }
+ container link {
+ leaf port {
+ type int32;
+ }
+
+ leaf-list port-id {
+ type string;
+ }
+ list areas {
+ key "name1";
+ leaf name1 {
+ type string;
+ }
+ }
+ }
+ }
+
+ notification link-up {
+ leaf link-id {
+ type int32;
+ }
+
+ leaf-list link-name {
+ type string;
+ }
+ }
+
+ rpc get-port {
+ input {
+ leaf port {
+ type int32;
+ }
+
+ leaf-list port-id {
+ type string;
+ }
+ uses link-details;
+ }
+ output {
+ container port {
+ leaf port-number {
+ type enumeration {
+ enum zero-0;
+ }
+ }
+ leaf ip {
+ type ip-address;
+ }
+ }
+ }
+ }
+
+ augment /get-port/input {
+ leaf port {
+ type int32;
+ }
+ }
+
+}
diff --git a/compiler/plugin/maven/src/test/resources/schemaMap/SchemaMap.yang b/compiler/plugin/maven/src/test/resources/schemaMap/SchemaMap.yang
new file mode 100644
index 0000000..d4c00c7
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/schemaMap/SchemaMap.yang
@@ -0,0 +1,57 @@
+module Testmodule {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ container testcontainer {
+ leaf testleaf {
+ type "uint16";
+ }
+ choice snack {
+ case sports-arena {
+ leaf pretzel {
+ type empty;
+ }
+ }
+ }
+ }
+ notification testnotification1 {
+ leaf type {
+ type string;
+ }
+ leaf severity {
+ type string;
+ }
+ }
+
+ rpc activate-software-image {
+ description "description";
+ input {
+ leaf image-name {
+ type string;
+ }
+ list ospf {
+ key "invalid-interval";
+ config true;
+ max-elements 10;
+ min-elements 3;
+ leaf invalid-interval {
+ type uint16;
+ }
+ }
+ container isis {
+ config true;
+ leaf invalid-interval {
+ type uint16;
+ }
+ }
+ }
+ output {
+ leaf image-name {
+ type string;
+ }
+ leaf image-value {
+ type string;
+ }
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/typedefTranslator/union/typedefs.yang b/compiler/plugin/maven/src/test/resources/typedefTranslator/union/typedefs.yang
new file mode 100644
index 0000000..276efa2
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/typedefTranslator/union/typedefs.yang
@@ -0,0 +1,51 @@
+module types {
+
+ namespace "yang:types";
+ prefix "types";
+ yang-version 1;
+
+ revision 2016-10-08;
+ typedef ip-address {
+ type union {
+ type ipv4-address;
+ type ipv6-address;
+ }
+ }
+
+ typedef ipv4-address {
+ type int32;
+ }
+
+ typedef ipv6-address {
+ type int32;
+ }
+
+ typedef port-number {
+ type bits {
+ bit disable-nagle {
+ position 0;
+ }
+ bit auto-sense-speed {
+ position 1;
+ }
+ bit Mb-only {
+ position 2;
+ }
+ }
+
+}
+
+
+ container con1 {
+ leaf abc {
+ type int32;
+ }
+ }
+
+ typedef leaf {
+ type leafref {
+ path "/con1/abc";
+ }
+ }
+
+}
diff --git a/compiler/plugin/maven/src/test/resources/typedefTranslator/with/Onos_Yang_1.yang b/compiler/plugin/maven/src/test/resources/typedefTranslator/with/Onos_Yang_1.yang
new file mode 100644
index 0000000..c09e372
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/typedefTranslator/with/Onos_Yang_1.yang
@@ -0,0 +1,201 @@
+module typedef {
+
+ yang-version "1";
+ namespace "http://rob.sh/yang/test/list";
+ prefix "foo";
+
+ import remote { prefix defn; }
+
+ organization "BugReports Inc";
+ contact "A bug reporter";
+
+ description
+ "A test module";
+ revision 2014-01-01 {
+ description "april-fools";
+ reference "fooled-you";
+ }
+
+ typedef derived-string-type {
+ type string;
+ }
+
+ typedef restricted-integer-type {
+ type uint16 {
+ range 0..64;
+ }
+ }
+
+ typedef bgp-session-direction {
+ type enumeration {
+ enum INBOUND;
+ enum OUTBOUND;
+ }
+ }
+
+ typedef new-string-type {
+ type string;
+ default "defaultValue";
+ }
+
+ typedef restricted-inherit {
+ type string {
+ pattern "^a.*";
+ }
+ }
+
+ typedef restricted-int-inherit {
+ type int8 {
+ range 0..100;
+ }
+ }
+
+ typedef parent-union {
+ type union {
+ type string {
+ pattern "a.*";
+ }
+ type string {
+ pattern "b.*";
+ }
+ }
+ }
+
+ typedef child-union {
+ type union {
+ type parent-union;
+ type string {
+ pattern "z.*";
+ }
+ }
+ }
+
+ typedef union-included {
+ type union {
+ type string {
+ pattern "a.*";
+ }
+ type string {
+ pattern "b.*";
+ }
+ }
+ }
+
+ identity identity_base;
+ identity IDONE {
+ base "identity_base";
+ }
+
+ identity IDTWO {
+ base "identity_base";
+ }
+
+ typedef identity_one {
+ type identityref {
+ base identity_base;
+ }
+ }
+
+ typedef referenced-leaf {
+ type leafref {
+ path "/container/target";
+ require-instance false;
+ }
+ }
+
+ grouping scoped-typedef {
+ typedef scoped-type {
+ type string {
+ pattern "a.*";
+ }
+ }
+
+ leaf scoped-leaf {
+ type scoped-type;
+ }
+ }
+
+ container container {
+ description
+ "A container";
+
+ leaf-list target {
+ type string;
+ description
+ "A target leaf for leafref checks";
+ }
+
+ leaf string {
+ type derived-string-type;
+ }
+
+ leaf integer {
+ type restricted-integer-type;
+ }
+
+ leaf stringdefault {
+ type derived-string-type;
+ default "aDefaultValue";
+ }
+
+ leaf integerdefault {
+ type restricted-integer-type;
+ default 10;
+ }
+
+ leaf new-string {
+ type new-string-type;
+ }
+
+ leaf remote-new-type {
+ type defn:remote-definition;
+ }
+
+ leaf session-dir {
+ type bgp-session-direction;
+ }
+
+ leaf remote-local-type {
+ type defn:remote-local-definition;
+ }
+
+ leaf inheritance {
+ type restricted-inherit {
+ pattern ".*k";
+ }
+ }
+
+ leaf int-inheritance {
+ type restricted-int-inherit {
+ range 2..5;
+ }
+ }
+
+ leaf-list stacked-union {
+ type child-union;
+ }
+
+ leaf include-of-include-definition {
+ type defn:hybrid-definition;
+ }
+
+ leaf identity-one-typedef {
+ type identity_one;
+ }
+
+ leaf union-with-union {
+ type union {
+ type union-included;
+ type string {
+ pattern "q.*";
+ }
+ }
+ }
+
+ leaf reference {
+ type referenced-leaf;
+ }
+
+ uses scoped-typedef;
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/typedefTranslator/with/remote.yang b/compiler/plugin/maven/src/test/resources/typedefTranslator/with/remote.yang
new file mode 100644
index 0000000..409f04f
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/typedefTranslator/with/remote.yang
@@ -0,0 +1,33 @@
+module remote {
+ yang-version "1";
+ namespace "http://rob.sh/yang/test/typedef/remote";
+ prefix "remote";
+
+ import second-remote { prefix sr; }
+
+ organization "BugReports Inc";
+ contact "A bug reporter";
+
+ description
+ "A test module";
+ revision 2014-01-01 {
+ description "april-fools";
+ reference "fooled-you";
+ }
+
+ typedef remote-definition {
+ type string;
+ }
+
+ typedef remote-local-definition {
+ type local-definition;
+ }
+
+ typedef local-definition {
+ type string;
+ }
+
+ typedef hybrid-definition {
+ type sr:second-remote-definition;
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/typedefTranslator/with/second-remote.yang b/compiler/plugin/maven/src/test/resources/typedefTranslator/with/second-remote.yang
new file mode 100644
index 0000000..c106d89
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/typedefTranslator/with/second-remote.yang
@@ -0,0 +1,21 @@
+module second-remote {
+ yang-version "1";
+ namespace "http://rob.sh/yang/test/typedef/second-remote";
+ prefix "second-remote";
+
+ organization "BugReports Inc";
+ contact "A bug reporter";
+
+ description
+ "A test module";
+ revision 2014-01-01 {
+ description "april-fools";
+ reference "fooled-you";
+ }
+
+ typedef second-remote-definition {
+ type string {
+ pattern "z.*";
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/typedefTranslator/without/Onos_Yang_1.yang b/compiler/plugin/maven/src/test/resources/typedefTranslator/without/Onos_Yang_1.yang
new file mode 100644
index 0000000..56fbacf
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/typedefTranslator/without/Onos_Yang_1.yang
@@ -0,0 +1,489 @@
+module ietf-yang-types {
+
+ yang-version 1;
+
+ namespace
+ "urn:ietf:params:xml:ns:yang:ietf-yang-types";
+
+ prefix yang;
+
+ organization
+ "IETF NETMOD (NETCONF Data Modeling Language) Working Group";
+
+ contact
+ "WG Web: <http://tools.ietf.org/wg/netmod/>
+ WG List: <mailto:netmod@ietf.org>
+
+ WG Chair: David Kessens
+ <mailto:david.kessens@nsn.com>
+
+ WG Chair: Juergen Schoenwaelder
+ <mailto:j.schoenwaelder@jacobs-university.de>
+
+ Editor: Juergen Schoenwaelder
+ <mailto:j.schoenwaelder@jacobs-university.de>";
+
+ description
+ "This module contains a collection of generally useful derived
+ YANG data types.
+
+ Copyright (c) 2013 IETF Trust and the persons identified as
+ authors of the code. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or
+ without modification, is permitted pursuant to, and subject
+ to the license terms contained in, the Simplified BSD License
+ set forth in Section 4.c of the IETF Trust's Legal Provisions
+ Relating to IETF Documents
+ (http://trustee.ietf.org/license-info).
+
+ This version of this YANG module is part of RFC 6991; see
+ the RFC itself for full legal notices.";
+
+ revision "2013-07-15" {
+ description
+ "This revision adds the following new data types:
+ - yang-identifier
+ - hex-string
+ - uuid
+ - dotted-quad";
+ reference
+ "RFC 6991: Common YANG Data Types";
+
+ }
+
+ revision "2010-09-24" {
+ description "Initial revision.";
+ reference
+ "RFC 6021: Common YANG Data Types";
+
+ }
+
+
+ typedef counter32 {
+ type uint32;
+ description
+ "The counter32 type represents a non-negative integer
+ that monotonically increases until it reaches a
+ maximum value of 2^32-1 (4294967295 decimal), when it
+ wraps around and starts increasing again from zero.
+
+ Counters have no defined 'initial' value, and thus, a
+ single value of a counter has (in general) no information
+ content. Discontinuities in the monotonically increasing
+ value normally occur at re-initialization of the
+ management system, and at other times as specified in the
+ description of a schema node using this type. If such
+ other times can occur, for example, the creation of
+ a schema node of type counter32 at times other than
+ re-initialization, then a corresponding schema node
+ should be defined, with an appropriate type, to indicate
+ the last discontinuity.
+
+ The counter32 type should not be used for configuration
+ schema nodes. A default statement SHOULD NOT be used in
+ combination with the type counter32.
+
+ In the value set and its semantics, this type is equivalent
+ to the Counter32 type of the SMIv2.";
+ reference
+ "RFC 2578: Structure of Management Information Version 2
+ (SMIv2)";
+
+ }
+
+ typedef zero-based-counter32 {
+ type counter32;
+ default "0";
+ description
+ "The zero-based-counter32 type represents a counter32
+ that has the defined 'initial' value zero.
+
+ A schema node of this type will be set to zero (0) on creation
+ and will thereafter increase monotonically until it reaches
+ a maximum value of 2^32-1 (4294967295 decimal), when it
+ wraps around and starts increasing again from zero.
+
+ Provided that an application discovers a new schema node
+ of this type within the minimum time to wrap, it can use the
+ 'initial' value as a delta. It is important for a management
+ station to be aware of this minimum time and the actual time
+ between polls, and to discard data if the actual time is too
+ long or there is no defined minimum time.
+
+ In the value set and its semantics, this type is equivalent
+ to the ZeroBasedCounter32 textual convention of the SMIv2.";
+ reference
+ "RFC 4502: Remote Network Monitoring Management Information
+ Base Version 2";
+
+ }
+
+ typedef counter64 {
+ type uint64;
+ description
+ "The counter64 type represents a non-negative integer
+ that monotonically increases until it reaches a
+ maximum value of 2^64-1 (18446744073709551615 decimal),
+ when it wraps around and starts increasing again from zero.
+
+ Counters have no defined 'initial' value, and thus, a
+ single value of a counter has (in general) no information
+ content. Discontinuities in the monotonically increasing
+ value normally occur at re-initialization of the
+ management system, and at other times as specified in the
+ description of a schema node using this type. If such
+ other times can occur, for example, the creation of
+ a schema node of type counter64 at times other than
+ re-initialization, then a corresponding schema node
+ should be defined, with an appropriate type, to indicate
+ the last discontinuity.
+
+ The counter64 type should not be used for configuration
+ schema nodes. A default statement SHOULD NOT be used in
+ combination with the type counter64.
+
+ In the value set and its semantics, this type is equivalent
+ to the Counter64 type of the SMIv2.";
+ reference
+ "RFC 2578: Structure of Management Information Version 2
+ (SMIv2)";
+
+ }
+
+ typedef zero-based-counter64 {
+ type counter64;
+ default "0";
+ description
+ "The zero-based-counter64 type represents a counter64 that
+ has the defined 'initial' value zero.
+
+
+
+
+ A schema node of this type will be set to zero (0) on creation
+ and will thereafter increase monotonically until it reaches
+ a maximum value of 2^64-1 (18446744073709551615 decimal),
+ when it wraps around and starts increasing again from zero.
+
+ Provided that an application discovers a new schema node
+ of this type within the minimum time to wrap, it can use the
+ 'initial' value as a delta. It is important for a management
+ station to be aware of this minimum time and the actual time
+ between polls, and to discard data if the actual time is too
+ long or there is no defined minimum time.
+
+ In the value set and its semantics, this type is equivalent
+ to the ZeroBasedCounter64 textual convention of the SMIv2.";
+ reference
+ "RFC 2856: Textual Conventions for Additional High Capacity
+ Data Types";
+
+ }
+
+ typedef gauge32 {
+ type uint32;
+ description
+ "The gauge32 type represents a non-negative integer, which
+ may increase or decrease, but shall never exceed a maximum
+ value, nor fall below a minimum value. The maximum value
+ cannot be greater than 2^32-1 (4294967295 decimal), and
+ the minimum value cannot be smaller than 0. The value of
+ a gauge32 has its maximum value whenever the information
+ being modeled is greater than or equal to its maximum
+ value, and has its minimum value whenever the information
+ being modeled is smaller than or equal to its minimum value.
+ If the information being modeled subsequently decreases
+ below (increases above) the maximum (minimum) value, the
+ gauge32 also decreases (increases).
+
+ In the value set and its semantics, this type is equivalent
+ to the Gauge32 type of the SMIv2.";
+ reference
+ "RFC 2578: Structure of Management Information Version 2
+ (SMIv2)";
+
+ }
+
+ typedef gauge64 {
+ type uint64;
+ description
+ "The gauge64 type represents a non-negative integer, which
+ may increase or decrease, but shall never exceed a maximum
+ value, nor fall below a minimum value. The maximum value
+ cannot be greater than 2^64-1 (18446744073709551615), and
+ the minimum value cannot be smaller than 0. The value of
+ a gauge64 has its maximum value whenever the information
+ being modeled is greater than or equal to its maximum
+ value, and has its minimum value whenever the information
+ being modeled is smaller than or equal to its minimum value.
+ If the information being modeled subsequently decreases
+ below (increases above) the maximum (minimum) value, the
+ gauge64 also decreases (increases).
+
+ In the value set and its semantics, this type is equivalent
+ to the CounterBasedGauge64 SMIv2 textual convention defined
+ in RFC 2856";
+ reference
+ "RFC 2856: Textual Conventions for Additional High Capacity
+ Data Types";
+
+ }
+
+ typedef object-identifier {
+ type string {
+ pattern
+ '(([0-1](\.[1-3]?[0-9]))|(2\.(0|([1-9]\d*))))(\.(0|([1-9]\d*)))*';
+ }
+ description
+ "The object-identifier type represents administratively
+ assigned names in a registration-hierarchical-name tree.
+
+ Values of this type are denoted as a sequence of numerical
+ non-negative sub-identifier values. Each sub-identifier
+ value MUST NOT exceed 2^32-1 (4294967295). Sub-identifiers
+ are separated by single dots and without any intermediate
+ whitespace.
+
+ The ASN.1 standard restricts the value space of the first
+ sub-identifier to 0, 1, or 2. Furthermore, the value space
+ of the second sub-identifier is restricted to the range
+ 0 to 39 if the first sub-identifier is 0 or 1. Finally,
+ the ASN.1 standard requires that an object identifier
+ has always at least two sub-identifiers. The pattern
+ captures these restrictions.
+
+ Although the number of sub-identifiers is not limited,
+ module designers should realize that there may be
+ implementations that stick with the SMIv2 limit of 128
+ sub-identifiers.
+
+ This type is a superset of the SMIv2 OBJECT IDENTIFIER type
+ since it is not restricted to 128 sub-identifiers. Hence,
+ this type SHOULD NOT be used to represent the SMIv2 OBJECT
+ IDENTIFIER type; the object-identifier-128 type SHOULD be
+ used instead.";
+ reference
+ "ISO9834-1: Information technology -- Open Systems
+ Interconnection -- Procedures for the operation of OSI
+ Registration Authorities: General procedures and top
+ arcs of the ASN.1 Object Identifier tree";
+
+ }
+
+ typedef object-identifier-128 {
+ type object-identifier {
+ pattern '\d*(\.\d*){1,127}';
+ }
+ description
+ "This type represents object-identifiers restricted to 128
+ sub-identifiers.
+
+ In the value set and its semantics, this type is equivalent
+ to the OBJECT IDENTIFIER type of the SMIv2.";
+ reference
+ "RFC 2578: Structure of Management Information Version 2
+ (SMIv2)";
+
+ }
+
+ typedef yang-identifier {
+ type string {
+ length "1..max";
+ pattern '[a-zA-Z_][a-zA-Z0-9\-_.]*';
+ pattern
+ '.|..|[^xX].*|.[^mM].*|..[^lL].*';
+ }
+ description
+ "A YANG identifier string as defined by the 'identifier'
+ rule in Section 12 of RFC 6020. An identifier must
+ start with an alphabetic character or an underscore
+ followed by an arbitrary sequence of alphabetic or
+ numeric characters, underscores, hyphens, or dots.
+
+ A YANG identifier MUST NOT start with any possible
+ combination of the lowercase or uppercase character
+ sequence 'xml'.";
+ reference
+ "RFC 6020: YANG - A Data Modeling Language for the Network
+ Configuration Protocol (NETCONF)";
+
+ }
+
+ typedef date-and-time {
+ type string {
+ pattern
+ '\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[\+\-]\d{2}:\d{2})';
+ }
+ description
+ "The date-and-time type is a profile of the ISO 8601
+ standard for representation of dates and times using the
+ Gregorian calendar. The profile is defined by the
+ date-time production in Section 5.6 of RFC 3339.
+
+ The date-and-time type is compatible with the dateTime XML
+ schema type with the following notable exceptions:
+
+ (a) The date-and-time type does not allow negative years.
+
+ (b) The date-and-time time-offset -00:00 indicates an unknown
+ time zone (see RFC 3339) while -00:00 and +00:00 and Z
+ all represent the same time zone in dateTime.
+
+ (c) The canonical format (see below) of data-and-time values
+ differs from the canonical format used by the dateTime XML
+ schema type, which requires all times to be in UTC using
+ the time-offset 'Z'.
+
+ This type is not equivalent to the DateAndTime textual
+ convention of the SMIv2 since RFC 3339 uses a different
+ separator between full-date and full-time and provides
+ higher resolution of time-secfrac.
+
+ The canonical format for date-and-time values with a known time
+ zone uses a numeric time zone offset that is calculated using
+ the device's configured known offset to UTC time. A change of
+ the device's offset to UTC time will cause date-and-time values
+ to change accordingly. Such changes might happen periodically
+ in case a server follows automatically daylight saving time
+ (DST) time zone offset changes. The canonical format for
+ date-and-time values with an unknown time zone (usually
+ referring to the notion of local time) uses the time-offset
+ -00:00.";
+ reference
+ "RFC 3339: Date and Time on the Internet: Timestamps
+ RFC 2579: Textual Conventions for SMIv2
+ XSD-TYPES: XML Schema Part 2: Datatypes Second Edition";
+
+ }
+
+ typedef timeticks {
+ type uint32;
+ description
+ "The timeticks type represents a non-negative integer that
+ represents the time, modulo 2^32 (4294967296 decimal), in
+ hundredths of a second between two epochs. When a schema
+ node is defined that uses this type, the description of
+ the schema node identifies both of the reference epochs.
+
+ In the value set and its semantics, this type is equivalent
+ to the TimeTicks type of the SMIv2.";
+ reference
+ "RFC 2578: Structure of Management Information Version 2
+ (SMIv2)";
+
+ }
+
+ typedef timestamp {
+ type timeticks;
+ description
+ "The timestamp type represents the value of an associated
+ timeticks schema node at which a specific occurrence
+ happened. The specific occurrence must be defined in the
+ description of any schema node defined using this type. When
+ the specific occurrence occurred prior to the last time the
+ associated timeticks attribute was zero, then the timestamp
+ value is zero. Note that this requires all timestamp values
+ to be reset to zero when the value of the associated timeticks
+ attribute reaches 497+ days and wraps around to zero.
+
+ The associated timeticks schema node must be specified
+ in the description of any schema node using this type.
+
+ In the value set and its semantics, this type is equivalent
+ to the TimeStamp textual convention of the SMIv2.";
+ reference
+ "RFC 2579: Textual Conventions for SMIv2";
+
+ }
+
+ typedef phys-address {
+ type string {
+ pattern
+ '([0-9a-fA-F]{2}(:[0-9a-fA-F]{2})*)?';
+ }
+ description
+ "Represents media- or physical-level addresses represented
+ as a sequence octets, each octet represented by two hexadecimal
+ numbers. Octets are separated by colons. The canonical
+ representation uses lowercase characters.
+
+ In the value set and its semantics, this type is equivalent
+ to the PhysAddress textual convention of the SMIv2.";
+ reference
+ "RFC 2579: Textual Conventions for SMIv2";
+
+ }
+
+ typedef mac-address {
+ type string {
+ pattern
+ '[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}';
+ }
+ description
+ "The mac-address type represents an IEEE 802 MAC address.
+ The canonical representation uses lowercase characters.
+
+ In the value set and its semantics, this type is equivalent
+ to the MacAddress textual convention of the SMIv2.";
+ reference
+ "IEEE 802: IEEE Standard for Local and Metropolitan Area
+ Networks: Overview and Architecture
+ RFC 2579: Textual Conventions for SMIv2";
+
+ }
+
+ typedef xpath1.0 {
+ type string;
+ description
+ "This type represents an XPATH 1.0 expression.
+
+ When a schema node is defined that uses this type, the
+ description of the schema node MUST specify the XPath
+ context in which the XPath expression is evaluated.";
+ reference
+ "XPATH: XML Path Language (XPath) Version 1.0";
+
+ }
+
+ typedef hex-string {
+ type string {
+ pattern
+ '([0-9a-fA-F]{2}(:[0-9a-fA-F]{2})*)?';
+ }
+ description
+ "A hexadecimal string with octets represented as hex digits
+ separated by colons. The canonical representation uses
+ lowercase characters.";
+ }
+
+ typedef uuid {
+ type string {
+ pattern
+ '[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}';
+ }
+ description
+ "A Universally Unique IDentifier in the string representation
+ defined in RFC 4122. The canonical representation uses
+ lowercase characters.
+
+ The following is an example of a UUID in string representation:
+ f81d4fae-7dec-11d0-a765-00a0c91e6bf6
+ ";
+ reference
+ "RFC 4122: A Universally Unique IDentifier (UUID) URN
+ Namespace";
+
+ }
+
+ typedef dotted-quad {
+ type string {
+ pattern
+ '(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])';
+ }
+ description
+ "An unsigned 32-bit number expressed in the dotted-quad
+ notation, i.e., four octets written as decimal numbers
+ and separated with the '.' (full stop) character.";
+ }
+ }
diff --git a/compiler/plugin/maven/src/test/resources/typelinkingaftercloning/identityref/IntraFileIdentityRefAfterCloning.yang b/compiler/plugin/maven/src/test/resources/typelinkingaftercloning/identityref/IntraFileIdentityRefAfterCloning.yang
new file mode 100644
index 0000000..9fbc024
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/typelinkingaftercloning/identityref/IntraFileIdentityRefAfterCloning.yang
@@ -0,0 +1,74 @@
+module org-open-road-m-device {
+ namespace "http://org/openroadm/device";
+ prefix org-open-road-m-device;
+
+ identity syslog-facility {
+ description
+ "The base identity to represent syslog facilities";
+ }
+ typedef value {
+ type identityref {
+ base syslog-facility;
+ }
+ }
+
+ grouping device-common {
+ leaf facility {
+ type union {
+ type identityref {
+ base syslog-facility;
+ }
+ type enumeration {
+ enum "all" {
+ description
+ "This enum describes the case where all
+ facilities are requested.";
+ }
+ }
+ }
+ }
+ leaf node-id {
+ type identityref {
+ base syslog-facility;
+ }
+ description
+ "Globally unique identifier for a device.";
+ config true;
+ }
+ leaf-list node-ref {
+ type value;
+ }
+ container network-ref {
+ leaf-list facility {
+ type union {
+ type identityref {
+ base syslog-facility;
+ }
+ type enumeration {
+ enum "all" {
+ description
+ "This enum describes the case where all
+ facilities are requested.";
+ }
+ }
+ }
+ }
+ leaf-list node-ref {
+ type identityref {
+ base syslog-facility;
+ }
+ description
+ "Globally unique identifier for a device.";
+ config true;
+ }
+ leaf node-id {
+ type value;
+ }
+ }
+ }
+
+ list node {
+ config false;
+ uses device-common;
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/typelinkingaftercloning/idrefingrouping/idrefingrouping1.yang b/compiler/plugin/maven/src/test/resources/typelinkingaftercloning/idrefingrouping/idrefingrouping1.yang
new file mode 100644
index 0000000..8837d49
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/typelinkingaftercloning/idrefingrouping/idrefingrouping1.yang
@@ -0,0 +1,37 @@
+module IdRefInGrouping1 {
+ namespace "http://org/IdRefInGrouping1";
+ prefix id-ref-in-grouping-1;
+
+ identity id1 {
+ description "base identity";
+ }
+
+ identity id2 {
+ base id1;
+ }
+
+ typedef id {
+ type identityref {
+ base id1;
+ }
+ }
+
+ grouping value {
+ leaf leaf {
+ type identityref {
+ base id2;
+ }
+ }
+ leaf-list leaf-list {
+ type id;
+ }
+ container a {
+ leaf leaf {
+ type identityref {
+ base id1;
+ }
+ }
+ }
+ }
+
+}
diff --git a/compiler/plugin/maven/src/test/resources/typelinkingaftercloning/idrefingrouping/idrefingrouping2.yang b/compiler/plugin/maven/src/test/resources/typelinkingaftercloning/idrefingrouping/idrefingrouping2.yang
new file mode 100644
index 0000000..2a347f1
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/typelinkingaftercloning/idrefingrouping/idrefingrouping2.yang
@@ -0,0 +1,12 @@
+module IdRefInGrouping2 {
+ namespace "http://org/IdRefInGrouping2";
+ prefix id-ref-in-grouping-2;
+
+ import IdRefInGrouping1 {
+ prefix idref1;
+ }
+
+ container content {
+ uses idref1:value;
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/typelinkingaftercloning/idreftypedef/IdRefInTypeDef1.yang b/compiler/plugin/maven/src/test/resources/typelinkingaftercloning/idreftypedef/IdRefInTypeDef1.yang
new file mode 100644
index 0000000..4d2642c
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/typelinkingaftercloning/idreftypedef/IdRefInTypeDef1.yang
@@ -0,0 +1,57 @@
+module IdRefInTypeDef1 {
+ namespace "http://org/IdRefInTypeDef1";
+ prefix id-ref-in-type-1;
+
+ import IdRefInTypeDef2 {
+ prefix id;
+ }
+
+ identity id1 {
+ description "base identity";
+ }
+
+ identity id2 {
+ base id1;
+ }
+
+ typedef forleaf3 {
+ type identityref {
+ base id2;
+ }
+ }
+
+ typedef forleaf2 {
+ type forleaf3;
+ }
+
+ typedef forleaf1 {
+ type forleaf2;
+ }
+
+ leaf leaf {
+ type forleaf1;
+ }
+
+ leaf-list leaf-list {
+ type forleaf2;
+ }
+
+ container cont {
+ leaf leaf {
+ type forleaf1;
+ }
+
+ leaf leaf-list {
+ type forleaf2;
+ }
+ }
+
+ leaf with-uni {
+ type union {
+ type identityref {
+ base id2;
+ }
+ type id:value;
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/typelinkingaftercloning/idreftypedef/IdRefInTypeDef2.yang b/compiler/plugin/maven/src/test/resources/typelinkingaftercloning/idreftypedef/IdRefInTypeDef2.yang
new file mode 100644
index 0000000..646a3f6
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/typelinkingaftercloning/idreftypedef/IdRefInTypeDef2.yang
@@ -0,0 +1,18 @@
+module IdRefInTypeDef2 {
+ namespace "http://org/IdRefInTypeDef2";
+ prefix id-ref-in-type-2;
+
+ identity id4 {
+ description "base identity";
+ }
+
+ identity id3 {
+ base id4;
+ }
+
+ typedef value {
+ type identityref {
+ base id3;
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/typelinkingaftercloning/leafref/intrafile/IntraFileLeafrefAfterCloning.yang b/compiler/plugin/maven/src/test/resources/typelinkingaftercloning/leafref/intrafile/IntraFileLeafrefAfterCloning.yang
new file mode 100644
index 0000000..a73280d
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/typelinkingaftercloning/leafref/intrafile/IntraFileLeafrefAfterCloning.yang
@@ -0,0 +1,52 @@
+module org-open-road-m-device {
+ namespace "http://org/openroadm/device";
+ prefix org-open-road-m-device;
+
+ leaf uri {
+ type string;
+ }
+ leaf-list id {
+ type value;
+ }
+ typedef value {
+ type uint8;
+ }
+
+ grouping device-common {
+ leaf node-id {
+ type leafref {
+ path "/uri";
+ }
+ description
+ "Globally unique identifier for a device.";
+ config true;
+ default "open-road-m";
+ }
+ leaf-list node-ref {
+ type leafref {
+ path "/id";
+ }
+ }
+ container network-ref {
+ leaf node-id {
+ type leafref {
+ path "/id";
+ }
+ description
+ "Globally unique identifier for a device.";
+ config true;
+ default "open-road-m";
+ }
+ leaf-list node-ref {
+ type leafref {
+ path "/uri";
+ }
+ }
+ }
+ }
+
+ list node {
+ config false;
+ uses device-common;
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/typelinkingaftercloning/leafref/invalid/invalidleafref.yang b/compiler/plugin/maven/src/test/resources/typelinkingaftercloning/leafref/invalid/invalidleafref.yang
new file mode 100644
index 0000000..79491e1
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/typelinkingaftercloning/leafref/invalid/invalidleafref.yang
@@ -0,0 +1,28 @@
+module org-open-road-m-device {
+ namespace "http://org/openroadm/device";
+ prefix org-open-road-m-device;
+
+ leaf uri {
+ type string;
+ }
+
+ grouping device-common {
+ leaf node-id {
+ type union {
+ type leafref {
+ path "/uri";
+ }
+ type string;
+ }
+ description
+ "Globally unique identifier for a device.";
+ config true;
+ default "open-road-m";
+ }
+ }
+
+ list node {
+ config false;
+ uses device-common;
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/typelinkingaftercloning/union/IntraFileUnionAfterCloning.yang b/compiler/plugin/maven/src/test/resources/typelinkingaftercloning/union/IntraFileUnionAfterCloning.yang
new file mode 100644
index 0000000..a69a5a1
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/typelinkingaftercloning/union/IntraFileUnionAfterCloning.yang
@@ -0,0 +1,81 @@
+module org-open-road-m-device {
+ namespace "http://org/openroadm/device";
+ prefix org-open-road-m-device;
+
+ identity syslog-facility {
+ description
+ "The base identity to represent syslog facilities";
+ }
+
+ identity syslog-usability {
+ description
+ "The base identity to represent syslog usabilities";
+ }
+
+ identity syslog-availability {
+ description
+ "The base identity to represent syslog availabilities";
+ }
+
+ typedef value {
+ type identityref {
+ base syslog-availability;
+ }
+ }
+
+ typedef correct {
+ type union {
+ type union {
+ type identityref {
+ base syslog-availability;
+ }
+ type value;
+ }
+ type identityref {
+ base syslog-usability;
+ }
+ }
+ }
+
+ grouping device-common {
+ leaf facility {
+ type union {
+ type union {
+ type union {
+ type identityref {
+ base syslog-usability;
+ }
+ type correct;
+ }
+ type identityref {
+ base syslog-facility;
+ }
+ }
+ type value;
+ }
+ }
+ container network-ref {
+ leaf-list facility {
+ type union {
+ type union {
+ type union {
+ type identityref {
+ base syslog-usability;
+ }
+ type correct;
+ }
+ type identityref {
+ base syslog-facility;
+ }
+ }
+ type value;
+ }
+ }
+ }
+ }
+
+ list node {
+ config false;
+ uses device-common;
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/unionTranslator/intuint/test.yang b/compiler/plugin/maven/src/test/resources/unionTranslator/intuint/test.yang
new file mode 100644
index 0000000..6cba197
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/unionTranslator/intuint/test.yang
@@ -0,0 +1,23 @@
+module test {
+ namespace "test:test";
+ prefix test ;
+
+ organization "";
+ contact "";
+
+ description
+ "Defines basic service types for L3VPN service.";
+
+ revision "2015-12-16" {
+ reference "";
+ }
+
+ leaf leaf1 {
+ type union {
+ type int32;
+ type uint16;
+ }
+ }
+
+}
+
diff --git a/compiler/plugin/maven/src/test/resources/unionTranslator/intuintstring/test.yang b/compiler/plugin/maven/src/test/resources/unionTranslator/intuintstring/test.yang
new file mode 100644
index 0000000..c806017
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/unionTranslator/intuintstring/test.yang
@@ -0,0 +1,24 @@
+module test {
+ namespace "test:test";
+ prefix test ;
+
+ organization "";
+ contact "";
+
+ description
+ "Defines basic service types for L3VPN service.";
+
+ revision "2015-12-16" {
+ reference "";
+ }
+
+ leaf leaf1 {
+ type union {
+ type int32;
+ type string;
+ type uint16;
+ }
+ }
+
+}
+
diff --git a/compiler/plugin/maven/src/test/resources/unionTranslator/intuintstring/test2.yang b/compiler/plugin/maven/src/test/resources/unionTranslator/intuintstring/test2.yang
new file mode 100644
index 0000000..63b791c
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/unionTranslator/intuintstring/test2.yang
@@ -0,0 +1,24 @@
+module test2 {
+ namespace "test:test";
+ prefix test ;
+
+ organization "";
+ contact "";
+
+ description
+ "Defines basic service types for L3VPN service.";
+
+ revision "2015-12-16" {
+ reference "";
+ }
+
+ leaf leaf1 {
+ type union {
+ type int64;
+ type string;
+ type uint16;
+ }
+ }
+
+}
+
diff --git a/compiler/plugin/maven/src/test/resources/unionTranslator/intuintulonglong/test.yang b/compiler/plugin/maven/src/test/resources/unionTranslator/intuintulonglong/test.yang
new file mode 100644
index 0000000..b4737e7
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/unionTranslator/intuintulonglong/test.yang
@@ -0,0 +1,25 @@
+module test {
+ namespace "test:test";
+ prefix test ;
+
+ organization "";
+ contact "";
+
+ description
+ "Defines basic service types for L3VPN service.";
+
+ revision "2015-12-16" {
+ reference "";
+ }
+
+ leaf leaf1 {
+ type union {
+ type int32;
+ type uint16;
+ type uint32;
+ type int64;
+ }
+ }
+
+}
+
diff --git a/compiler/plugin/maven/src/test/resources/unionTranslator/intuintulonglongstring/test.yang b/compiler/plugin/maven/src/test/resources/unionTranslator/intuintulonglongstring/test.yang
new file mode 100644
index 0000000..a50b5ef
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/unionTranslator/intuintulonglongstring/test.yang
@@ -0,0 +1,26 @@
+module test {
+ namespace "test:test";
+ prefix test ;
+
+ organization "";
+ contact "";
+
+ description
+ "Defines basic service types for L3VPN service.";
+
+ revision "2015-12-16" {
+ reference "";
+ }
+
+ leaf leaf1 {
+ type union {
+ type string;
+ type int32;
+ type uint16;
+ type uint32;
+ type int64;
+ }
+ }
+
+}
+
diff --git a/compiler/plugin/maven/src/test/resources/unionTranslator/longulong/test.yang b/compiler/plugin/maven/src/test/resources/unionTranslator/longulong/test.yang
new file mode 100644
index 0000000..a555043
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/unionTranslator/longulong/test.yang
@@ -0,0 +1,23 @@
+module test {
+ namespace "test:test";
+ prefix test ;
+
+ organization "";
+ contact "";
+
+ description
+ "Defines basic service types for L3VPN service.";
+
+ revision "2015-12-16" {
+ reference "";
+ }
+
+ leaf leaf1 {
+ type union {
+ type int64;
+ type uint32;
+ }
+ }
+
+}
+
diff --git a/compiler/plugin/maven/src/test/resources/unionTranslator/uintint/test.yang b/compiler/plugin/maven/src/test/resources/unionTranslator/uintint/test.yang
new file mode 100644
index 0000000..d7a590a
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/unionTranslator/uintint/test.yang
@@ -0,0 +1,23 @@
+module test {
+ namespace "test:test";
+ prefix test ;
+
+ organization "";
+ contact "";
+
+ description
+ "Defines basic service types for L3VPN service.";
+
+ revision "2015-12-16" {
+ reference "";
+ }
+
+ leaf leaf1 {
+ type union {
+ type uint16;
+ type int32;
+ }
+ }
+
+}
+
diff --git a/compiler/plugin/maven/src/test/resources/unionTranslator/ulonglong/test.yang b/compiler/plugin/maven/src/test/resources/unionTranslator/ulonglong/test.yang
new file mode 100644
index 0000000..22f6e97
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/unionTranslator/ulonglong/test.yang
@@ -0,0 +1,23 @@
+module test {
+ namespace "test:test";
+ prefix test ;
+
+ organization "";
+ contact "";
+
+ description
+ "Defines basic service types for L3VPN service.";
+
+ revision "2015-12-16" {
+ reference "";
+ }
+
+ leaf leaf1 {
+ type union {
+ type uint32;
+ type int64;
+ }
+ }
+
+}
+
diff --git a/compiler/plugin/maven/src/test/resources/unionTranslator/unionwithbinary/test.yang b/compiler/plugin/maven/src/test/resources/unionTranslator/unionwithbinary/test.yang
new file mode 100644
index 0000000..d2c9966
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/unionTranslator/unionwithbinary/test.yang
@@ -0,0 +1,15 @@
+module moduletest {
+ yang-version 1;
+ namespace "onos-yang-20:level1:newlevel";
+ prefix test;
+ organization "huawei";
+ contact "adarsh.m@huawei.com";
+ description "leaf scenario";
+ revision 2015-02-05;
+ leaf eleven {
+ type union {
+ type binary;
+ type int8;
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/usesInContainer/GroupingError.yang b/compiler/plugin/maven/src/test/resources/usesInContainer/GroupingError.yang
new file mode 100644
index 0000000..8c7c01d
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/usesInContainer/GroupingError.yang
@@ -0,0 +1,64 @@
+
+module ietf-sd-onos-service-types {
+
+ namespace "urn:ietf:params:xml:ns:yang:ietf-sd-onos-service-types";
+ prefix service-types ;
+
+ grouping qos-if-car {
+ description "qos parameter." ;
+ list qos-if-car {
+ key "direction";
+ description "cars qos policy." ;
+ leaf direction {
+ type enumeration {
+ enum inbound{
+ value 0 ;
+ description "inbound." ;
+ }
+ enum outbound {
+ value 1 ;
+ description "outbound." ;
+ }
+ }
+ description "qos for interface car" ;
+ }
+}
+}
+
+ container qos-policy {
+ description "The qos policy of the vpn service." ;
+ container qos-if-cars {
+ description "qos policy if car." ;
+ list qos-if-car {
+ key "direction";
+ uses qos-if-car;
+ description "List of qos parameters." ;
+ }
+ }
+ }
+
+ rpc close-l3vpn {
+ description "Close l3vpn." ;
+ input {
+ leaf l3vpn-id {
+ type string;
+ description "vpn id." ;
+ }
+ container ac-status {
+ description "Access status of the vpn." ;
+ list acs{
+ key "id";
+ description "Access information." ;
+ leaf id {
+ type string;
+ description "Access id." ;
+ }
+ leaf admin-status {
+ type string;
+ description "Administration status." ;
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/usesInsideChildOfGrouping/ietf-network.yang b/compiler/plugin/maven/src/test/resources/usesInsideChildOfGrouping/ietf-network.yang
new file mode 100644
index 0000000..8fb2bc0
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/usesInsideChildOfGrouping/ietf-network.yang
@@ -0,0 +1,28 @@
+module ietf-network {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-network";
+ prefix nd;
+
+ revision 2015-12-08 {
+ description
+ "Initial revision.
+ NOTE TO RFC EDITOR: Please replace the following reference
+ to draft-ietf-i2rs-yang-network-topo-02 with
+ RFC number when published (i.e. RFC xxxx).";
+ }
+
+ container networks {
+ list network {
+ key "network-id";
+ leaf network-id {
+ type string;
+ }
+ list node {
+ key "node-id";
+ leaf node-id {
+ type string;
+ }
+ }
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/usesInsideChildOfGrouping/ietf-te-topology.yang b/compiler/plugin/maven/src/test/resources/usesInsideChildOfGrouping/ietf-te-topology.yang
new file mode 100644
index 0000000..f1776fb
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/usesInsideChildOfGrouping/ietf-te-topology.yang
@@ -0,0 +1,60 @@
+module ietf-te-topology {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-te-topology";
+
+ prefix "tet";
+
+ import ietf-network {
+ prefix "nw";
+ }
+
+ revision "2016-03-17" {
+ description "Initial revision";
+ }
+
+ grouping te-node-augment {
+ container te {
+ presence "TE support.";
+
+ leaf te-node-id {
+ type string;
+ mandatory true;
+ }
+
+ container config {
+ uses te-node-config;
+ } // config
+ } // te
+ } // te-node-augment
+
+ grouping te-node-config {
+ leaf-list te-node-template {
+ if-feature template;
+ type string;
+ }
+ uses te-node-config-attributes;
+ } // te-node-config
+
+ grouping te-node-config-attributes {
+ container te-node-attributes {
+ leaf admin-status {
+ type string;
+ }
+ uses te-node-connectivity-matrix;
+ } // te-node-attributes
+ } // te-node-config-attributes
+
+ grouping te-node-connectivity-matrix {
+ list connectivity-matrix {
+ key "id";
+ leaf id {
+ type uint32;
+ description "Identifies the connectivity-matrix entry.";
+ }
+ }
+ } // te-node-connectivity-matrix
+
+ augment "/nw:networks/nw:network/nw:node" {
+ uses te-node-augment;
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/xPathLinker/Case/submodule/test.yang b/compiler/plugin/maven/src/test/resources/xPathLinker/Case/submodule/test.yang
new file mode 100644
index 0000000..dbff7e8
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/xPathLinker/Case/submodule/test.yang
@@ -0,0 +1,31 @@
+module test {
+ namespace "xpath:intra:single";
+ prefix test ;
+
+ include test1;
+ include test2;
+ include test4;
+
+ organization "";
+ contact "";
+
+ description
+ "Defines basic service types for L3VPN service.";
+
+ revision "2015-12-16" {
+ reference "";
+ }
+
+ augment /cont5/cont6 {
+ leaf a {
+ type int32;
+ }
+ }
+
+ augment /cont3/cont4/cont8 {
+ leaf a {
+ type int32;
+ }
+ }
+}
+
diff --git a/compiler/plugin/maven/src/test/resources/xPathLinker/Case/submodule/test1.yang b/compiler/plugin/maven/src/test/resources/xPathLinker/Case/submodule/test1.yang
new file mode 100644
index 0000000..23161d4
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/xPathLinker/Case/submodule/test1.yang
@@ -0,0 +1,47 @@
+submodule test1 {
+
+ belongs-to test {
+ prefix test;
+ }
+
+ include test4;
+
+ organization "";
+ contact "";
+
+ description
+ "Defines basic service types for L3VPN service.";
+
+ revision "2015-12-16" {
+ reference "";
+ }
+
+ container cont1 {
+ leaf leaf1 {
+ type int32;
+ }
+ container cont2 {
+ leaf leaf2 {
+ type int32;
+ }
+ }
+ }
+
+ augment /cont1/cont2 {
+ container cont4 {
+ leaf leaf1 {
+ type int32;
+ }
+ }
+ }
+
+ augment /cont3/cont4 {
+ container cont8 {
+ leaf leaf8 {
+ type int32;
+ }
+ }
+ }
+
+}
+
diff --git a/compiler/plugin/maven/src/test/resources/xPathLinker/Case/submodule/test2.yang b/compiler/plugin/maven/src/test/resources/xPathLinker/Case/submodule/test2.yang
new file mode 100644
index 0000000..26640ee
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/xPathLinker/Case/submodule/test2.yang
@@ -0,0 +1,36 @@
+submodule test2{
+ belongs-to test {
+ prefix test;
+ }
+
+ include test1;
+ organization "";
+ contact "";
+
+ description
+ "Defines basic service types for L3VPN service.";
+
+ revision "2015-12-16" {
+ reference "";
+ }
+
+ container cont5 {
+ leaf leaf5 {
+ type int32;
+ }
+ container cont6 {
+ leaf leaf6 {
+ type int32;
+ }
+ }
+ }
+
+ augment /cont1/cont2/cont4 {
+ container cont10 {
+ leaf leaf10 {
+ type int32;
+ }
+ }
+ }
+}
+
diff --git a/compiler/plugin/maven/src/test/resources/xPathLinker/Case/submodule/test4.yang b/compiler/plugin/maven/src/test/resources/xPathLinker/Case/submodule/test4.yang
new file mode 100644
index 0000000..fcbf522
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/xPathLinker/Case/submodule/test4.yang
@@ -0,0 +1,28 @@
+submodule test4 {
+
+ belongs-to test {
+ prefix test;
+ }
+
+ organization "";
+ contact "";
+
+ description
+ "Defines basic service types for L3VPN service.";
+
+ revision "2015-12-16" {
+ reference "";
+ }
+
+ container cont3 {
+ leaf leaf3 {
+ type int32;
+ }
+ container cont4 {
+ leaf leaf4 {
+ type int32;
+ }
+ }
+ }
+}
+
diff --git a/compiler/plugin/maven/src/test/resources/xPathLinker/Case/uses/test.yang b/compiler/plugin/maven/src/test/resources/xPathLinker/Case/uses/test.yang
new file mode 100644
index 0000000..b326024
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/xPathLinker/Case/uses/test.yang
@@ -0,0 +1,23 @@
+module test {
+ namespace "xpath:intra:single";
+ prefix test ;
+
+ include test2;
+
+ organization "";
+ contact "";
+
+ description
+ "Defines basic service types for L3VPN service.";
+
+ revision "2015-12-16" {
+ reference "";
+ }
+
+ augment /cont5/cont6/cont3/cont4 {
+ leaf a {
+ type int32;
+ }
+ }
+}
+
diff --git a/compiler/plugin/maven/src/test/resources/xPathLinker/Case/uses/test1.yang b/compiler/plugin/maven/src/test/resources/xPathLinker/Case/uses/test1.yang
new file mode 100644
index 0000000..bd75dba
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/xPathLinker/Case/uses/test1.yang
@@ -0,0 +1,37 @@
+submodule test1 {
+
+ belongs-to test {
+ prefix test;
+ }
+
+ organization "";
+ contact "";
+
+ description
+ "Defines basic service types for L3VPN service.";
+
+ revision "2015-12-16" {
+ reference "";
+ }
+
+ container cont1 {
+ leaf leaf1 {
+ type int32;
+ }
+ container cont2 {
+ leaf leaf2 {
+ type int32;
+ }
+ }
+ }
+
+ augment /cont1/cont2 {
+ container cont4 {
+ leaf leaf1 {
+ type int32;
+ }
+ }
+ }
+
+}
+
diff --git a/compiler/plugin/maven/src/test/resources/xPathLinker/Case/uses/test2.yang b/compiler/plugin/maven/src/test/resources/xPathLinker/Case/uses/test2.yang
new file mode 100644
index 0000000..8e4dccf
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/xPathLinker/Case/uses/test2.yang
@@ -0,0 +1,64 @@
+submodule test2{
+ belongs-to test {
+ prefix test;
+ }
+
+ include test3;
+ include test1;
+
+ organization "";
+ contact "";
+
+ description
+ "Defines basic service types for L3VPN service.";
+
+ revision "2015-12-16" {
+ reference "";
+ }
+
+ grouping group2 {
+ container cont11 {
+ }
+ }
+
+ container cont5 {
+ leaf leaf5 {
+ type int32;
+ }
+ container cont6 {
+ leaf leaf6 {
+ type int32;
+ }
+ uses group1;
+ }
+ }
+
+ container ethernet {
+ leaf leaf10 {
+ type string;
+ }
+ }
+
+
+ augment /ethernet {
+ uses group2;
+ }
+
+ augment /cont1/cont2/cont4 {
+ container cont10 {
+ leaf leaf10 {
+ type int32;
+ }
+
+ }
+ }
+
+ augment /cont5/cont6/cont3/cont4 {
+ container cont8 {
+ leaf leaf8 {
+ type int32;
+ }
+ }
+ }
+}
+
diff --git a/compiler/plugin/maven/src/test/resources/xPathLinker/Case/uses/test4.yang b/compiler/plugin/maven/src/test/resources/xPathLinker/Case/uses/test4.yang
new file mode 100644
index 0000000..b45bb7d
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/xPathLinker/Case/uses/test4.yang
@@ -0,0 +1,30 @@
+submodule test3 {
+
+ belongs-to test {
+ prefix test;
+ }
+
+ organization "";
+ contact "";
+
+ description
+ "Defines basic service types for L3VPN service.";
+
+ revision "2015-12-16" {
+ reference "";
+ }
+
+ grouping group1 {
+ container cont3 {
+ leaf leaf3 {
+ type int32;
+ }
+ container cont4 {
+ leaf leaf4 {
+ type int32;
+ }
+ }
+ }
+ }
+
+}
diff --git a/compiler/plugin/maven/src/test/resources/xPathLinker/InterFile/InterMulti/test.yang b/compiler/plugin/maven/src/test/resources/xPathLinker/InterFile/InterMulti/test.yang
new file mode 100644
index 0000000..772f792
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/xPathLinker/InterFile/InterMulti/test.yang
@@ -0,0 +1,25 @@
+module test {
+ namespace "xpath:inter:single";
+ prefix test ;
+
+ import test1{
+ prefix test1;
+ }
+
+ organization "";
+ contact "";
+
+ description
+ "Defines basic service types for L3VPN service.";
+
+ revision "2015-12-16" {
+ reference "";
+ }
+
+ augment /test1:cont1/test1:cont2 {
+ leaf a {
+ type int32;
+ }
+ }
+}
+
diff --git a/compiler/plugin/maven/src/test/resources/xPathLinker/InterFile/InterMulti/test1.yang b/compiler/plugin/maven/src/test/resources/xPathLinker/InterFile/InterMulti/test1.yang
new file mode 100644
index 0000000..9c1cdb0
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/xPathLinker/InterFile/InterMulti/test1.yang
@@ -0,0 +1,26 @@
+module test1 {
+ namespace "xpath:inter:single";
+ prefix test1 ;
+
+ organization "";
+ contact "";
+
+ description
+ "Defines basic service types for L3VPN service.";
+
+ revision "2015-12-16" {
+ reference "";
+ }
+
+ container cont1 {
+ leaf leaf1 {
+ type int32;
+ }
+ container cont2 {
+ leaf leaf1 {
+ type int32;
+ }
+ }
+ }
+}
+
diff --git a/compiler/plugin/maven/src/test/resources/xPathLinker/InterFile/InterMultiAugment/test.yang b/compiler/plugin/maven/src/test/resources/xPathLinker/InterFile/InterMultiAugment/test.yang
new file mode 100644
index 0000000..640a15a
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/xPathLinker/InterFile/InterMultiAugment/test.yang
@@ -0,0 +1,25 @@
+module test {
+ namespace "xpath:inter:single";
+ prefix test ;
+
+ import test1{
+ prefix test1;
+ }
+
+ organization "";
+ contact "";
+
+ description
+ "Defines basic service types for L3VPN service.";
+
+ revision "2015-12-16" {
+ reference "";
+ }
+
+ augment /test1:cont1/test1:cont2/test1:cont2 {
+ leaf a {
+ type int32;
+ }
+ }
+}
+
diff --git a/compiler/plugin/maven/src/test/resources/xPathLinker/InterFile/InterMultiAugment/test1.yang b/compiler/plugin/maven/src/test/resources/xPathLinker/InterFile/InterMultiAugment/test1.yang
new file mode 100644
index 0000000..c9fbeab
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/xPathLinker/InterFile/InterMultiAugment/test1.yang
@@ -0,0 +1,34 @@
+module test1 {
+ namespace "xpath:inter:single";
+ prefix test1 ;
+
+ organization "";
+ contact "";
+
+ description
+ "Defines basic service types for L3VPN service.";
+
+ revision "2015-12-16" {
+ reference "";
+ }
+
+ container cont1 {
+ leaf leaf1 {
+ type int32;
+ }
+ }
+
+ augment /cont1 {
+ container cont2 {
+ leaf leaf1 {
+ type int32;
+ }
+ container cont2 {
+ leaf leaf1 {
+ type int32;
+ }
+ }
+ }
+ }
+}
+
diff --git a/compiler/plugin/maven/src/test/resources/xPathLinker/InterFile/InterMultiFileAugment/test.yang b/compiler/plugin/maven/src/test/resources/xPathLinker/InterFile/InterMultiFileAugment/test.yang
new file mode 100644
index 0000000..53ed780
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/xPathLinker/InterFile/InterMultiFileAugment/test.yang
@@ -0,0 +1,29 @@
+module test {
+ namespace "xpath:inter:single";
+ prefix test ;
+
+ import test1{
+ prefix test1;
+ }
+
+ import test2{
+ prefix test2;
+ }
+
+ organization "";
+ contact "";
+
+ description
+ "Defines basic service types for L3VPN service.";
+
+ revision "2015-12-16" {
+ reference "";
+ }
+
+ augment /test2:cont1/test2:cont2/test1:cont2 {
+ leaf a {
+ type int32;
+ }
+ }
+}
+
diff --git a/compiler/plugin/maven/src/test/resources/xPathLinker/InterFile/InterMultiFileAugment/test1.yang b/compiler/plugin/maven/src/test/resources/xPathLinker/InterFile/InterMultiFileAugment/test1.yang
new file mode 100644
index 0000000..9ae5e24
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/xPathLinker/InterFile/InterMultiFileAugment/test1.yang
@@ -0,0 +1,51 @@
+module test1 {
+ namespace "xpath:inter:single";
+ prefix test1 ;
+
+ import test2{
+ prefix test2;
+ }
+
+ organization "";
+ contact "";
+
+ description
+ "Defines basic service types for L3VPN service.";
+
+ revision "2015-12-16" {
+ reference "";
+ }
+
+
+ container cont1 {
+ leaf leaf1 {
+ type int32;
+ }
+ }
+
+ augment /cont1 {
+ container cont2 {
+ leaf leaf1 {
+ type int32;
+ }
+ container cont2 {
+ leaf leaf1 {
+ type int32;
+ }
+ }
+ }
+ }
+
+ augment /test2:cont1/test2:cont2 {
+ leaf a {
+ type int32;
+ }
+
+ container cont2 {
+ leaf leaf1 {
+ type int32;
+ }
+ }
+ }
+}
+
diff --git a/compiler/plugin/maven/src/test/resources/xPathLinker/InterFile/InterMultiFileAugment/test2.yang b/compiler/plugin/maven/src/test/resources/xPathLinker/InterFile/InterMultiFileAugment/test2.yang
new file mode 100644
index 0000000..f20ac7d
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/xPathLinker/InterFile/InterMultiFileAugment/test2.yang
@@ -0,0 +1,26 @@
+module test2 {
+ namespace "xpath:inter:multi";
+ prefix test2 ;
+
+ organization "";
+ contact "";
+
+ description
+ "Defines basic service types for L3VPN service.";
+
+ revision "2015-12-16" {
+ reference "";
+ }
+
+ container cont1 {
+ leaf leaf1 {
+ type int32;
+ }
+ container cont2 {
+ leaf leaf1 {
+ type int32;
+ }
+ }
+ }
+}
+
diff --git a/compiler/plugin/maven/src/test/resources/xPathLinker/InterFile/InterMultiFileAugmentMulti/test.yang b/compiler/plugin/maven/src/test/resources/xPathLinker/InterFile/InterMultiFileAugmentMulti/test.yang
new file mode 100644
index 0000000..adb4800
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/xPathLinker/InterFile/InterMultiFileAugmentMulti/test.yang
@@ -0,0 +1,29 @@
+module test {
+ namespace "xpath:inter:single";
+ prefix test ;
+
+ import test1{
+ prefix test1;
+ }
+
+ import test2{
+ prefix test2;
+ }
+
+ organization "";
+ contact "";
+
+ description
+ "Defines basic service types for L3VPN service.";
+
+ revision "2015-12-16" {
+ reference "";
+ }
+
+ augment /test2:cont1/test2:cont2/test2:cont3/test1:cont2 {
+ leaf leaf8 {
+ type int32;
+ }
+ }
+}
+
diff --git a/compiler/plugin/maven/src/test/resources/xPathLinker/InterFile/InterMultiFileAugmentMulti/test1.yang b/compiler/plugin/maven/src/test/resources/xPathLinker/InterFile/InterMultiFileAugmentMulti/test1.yang
new file mode 100644
index 0000000..0957e15
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/xPathLinker/InterFile/InterMultiFileAugmentMulti/test1.yang
@@ -0,0 +1,51 @@
+module test1 {
+ namespace "xpath:inter:single";
+ prefix test1 ;
+
+ import test2{
+ prefix test2;
+ }
+
+ organization "";
+ contact "";
+
+ description
+ "Defines basic service types for L3VPN service.";
+
+ revision "2015-12-16" {
+ reference "";
+ }
+
+
+ container cont1 {
+ leaf leaf1 {
+ type int32;
+ }
+ }
+
+ augment /cont1 {
+ container cont2 {
+ leaf leaf1 {
+ type int32;
+ }
+ container cont2 {
+ leaf leaf3 {
+ type int32;
+ }
+ }
+ }
+ }
+
+ augment /test2:cont1/test2:cont2/test2:cont3 {
+ leaf leaf2 {
+ type int32;
+ }
+
+ container cont2 {
+ leaf leaf4 {
+ type int32;
+ }
+ }
+ }
+}
+
diff --git a/compiler/plugin/maven/src/test/resources/xPathLinker/InterFile/InterMultiFileAugmentMulti/test2.yang b/compiler/plugin/maven/src/test/resources/xPathLinker/InterFile/InterMultiFileAugmentMulti/test2.yang
new file mode 100644
index 0000000..0eeb46d
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/xPathLinker/InterFile/InterMultiFileAugmentMulti/test2.yang
@@ -0,0 +1,34 @@
+module test2 {
+ namespace "xpath:inter:multi";
+ prefix test2 ;
+
+ organization "";
+ contact "";
+
+ description
+ "Defines basic service types for L3VPN service.";
+
+ revision "2015-12-16" {
+ reference "";
+ }
+
+ container cont1 {
+ leaf leaf5 {
+ type int32;
+ }
+ container cont2 {
+ leaf leaf6 {
+ type int32;
+ }
+ }
+ }
+
+ augment /cont1/cont2 {
+ container cont3 {
+ leaf leaf7 {
+ type string;
+ }
+ }
+ }
+}
+
diff --git a/compiler/plugin/maven/src/test/resources/xPathLinker/InterFile/InterMultiSubModule/test.yang b/compiler/plugin/maven/src/test/resources/xPathLinker/InterFile/InterMultiSubModule/test.yang
new file mode 100644
index 0000000..40b2386
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/xPathLinker/InterFile/InterMultiSubModule/test.yang
@@ -0,0 +1,33 @@
+module test {
+ namespace "xpath:intra:single";
+ prefix test ;
+
+ import test2 {
+ prefix test2;
+ }
+
+ include test1;
+
+ organization "";
+ contact "";
+
+ description
+ "Defines basic service types for L3VPN service.";
+
+ revision "2015-12-16" {
+ reference "";
+ }
+
+ augment /test2:cont1/test2:cont2/cont2 {
+ leaf a {
+ type int32;
+ }
+ }
+
+ augment /cont2/cont3/cont4 {
+ leaf a {
+ type int32;
+ }
+ }
+}
+
diff --git a/compiler/plugin/maven/src/test/resources/xPathLinker/InterFile/InterMultiSubModule/test1.yang b/compiler/plugin/maven/src/test/resources/xPathLinker/InterFile/InterMultiSubModule/test1.yang
new file mode 100644
index 0000000..a19ba35
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/xPathLinker/InterFile/InterMultiSubModule/test1.yang
@@ -0,0 +1,50 @@
+submodule test1 {
+
+ belongs-to test {
+ prefix test;
+ }
+
+ import test2 {
+ prefix test2;
+ }
+ organization "";
+ contact "";
+
+ description
+ "Defines basic service types for L3VPN service.";
+
+ revision "2015-12-16" {
+ reference "";
+ }
+
+ container cont2 {
+ leaf leaf1 {
+ type int32;
+ }
+ container cont3 {
+ leaf leaf1 {
+ type int32;
+ }
+ }
+ }
+
+ augment /cont2/cont3 {
+ container cont4 {
+ leaf leaf1 {
+ type int32;
+ }
+ }
+ }
+
+ augment /test2:cont1/test2:cont2 {
+ leaf a {
+ type int32;
+ }
+ container cont2 {
+ leaf leaf1 {
+ type int32;
+ }
+ }
+ }
+}
+
diff --git a/compiler/plugin/maven/src/test/resources/xPathLinker/InterFile/InterMultiSubModule/test2.yang b/compiler/plugin/maven/src/test/resources/xPathLinker/InterFile/InterMultiSubModule/test2.yang
new file mode 100644
index 0000000..f20ac7d
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/xPathLinker/InterFile/InterMultiSubModule/test2.yang
@@ -0,0 +1,26 @@
+module test2 {
+ namespace "xpath:inter:multi";
+ prefix test2 ;
+
+ organization "";
+ contact "";
+
+ description
+ "Defines basic service types for L3VPN service.";
+
+ revision "2015-12-16" {
+ reference "";
+ }
+
+ container cont1 {
+ leaf leaf1 {
+ type int32;
+ }
+ container cont2 {
+ leaf leaf1 {
+ type int32;
+ }
+ }
+ }
+}
+
diff --git a/compiler/plugin/maven/src/test/resources/xPathLinker/InterFile/InterMultiUses/test.yang b/compiler/plugin/maven/src/test/resources/xPathLinker/InterFile/InterMultiUses/test.yang
new file mode 100644
index 0000000..01aa34e
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/xPathLinker/InterFile/InterMultiUses/test.yang
@@ -0,0 +1,32 @@
+module test {
+ namespace "xpath:intra:single";
+ prefix test ;
+
+ import test2 {
+ prefix test2;
+ }
+
+ organization "";
+ contact "";
+
+ description
+ "Defines basic service types for L3VPN service.";
+
+ revision "2015-12-16" {
+ reference "";
+ }
+
+ container cont2 {
+ leaf a {
+ type int32;
+ }
+ uses test2:group1;
+ }
+
+ augment /cont2/cont1/cont2 {
+ leaf a {
+ type int32;
+ }
+ }
+}
+
diff --git a/compiler/plugin/maven/src/test/resources/xPathLinker/InterFile/InterMultiUses/test2.yang b/compiler/plugin/maven/src/test/resources/xPathLinker/InterFile/InterMultiUses/test2.yang
new file mode 100644
index 0000000..298d443
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/xPathLinker/InterFile/InterMultiUses/test2.yang
@@ -0,0 +1,28 @@
+module test2 {
+ namespace "xpath:inter:multi";
+ prefix test2 ;
+
+ organization "";
+ contact "";
+
+ description
+ "Defines basic service types for L3VPN service.";
+
+ revision "2015-12-16" {
+ reference "";
+ }
+
+ grouping group1 {
+ container cont1 {
+ leaf leaf1 {
+ type int32;
+ }
+ container cont2 {
+ leaf leaf1 {
+ type int32;
+ }
+ }
+ }
+ }
+}
+
diff --git a/compiler/plugin/maven/src/test/resources/xPathLinker/InterFile/InterSingle/test.yang b/compiler/plugin/maven/src/test/resources/xPathLinker/InterFile/InterSingle/test.yang
new file mode 100644
index 0000000..102ec39
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/xPathLinker/InterFile/InterSingle/test.yang
@@ -0,0 +1,25 @@
+module test {
+ namespace "xpath:inter:single";
+ prefix test ;
+
+ import test1{
+ prefix test1;
+ }
+
+ organization "";
+ contact "";
+
+ description
+ "Defines basic service types for L3VPN service.";
+
+ revision "2015-12-16" {
+ reference "";
+ }
+
+ augment /test1:cont1 {
+ leaf a {
+ type int32;
+ }
+ }
+}
+
diff --git a/compiler/plugin/maven/src/test/resources/xPathLinker/InterFile/InterSingle/test1.yang b/compiler/plugin/maven/src/test/resources/xPathLinker/InterFile/InterSingle/test1.yang
new file mode 100644
index 0000000..243ddfe
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/xPathLinker/InterFile/InterSingle/test1.yang
@@ -0,0 +1,21 @@
+module test1 {
+ namespace "xpath:inter:single";
+ prefix test1 ;
+
+ organization "";
+ contact "";
+
+ description
+ "Defines basic service types for L3VPN service.";
+
+ revision "2015-12-16" {
+ reference "";
+ }
+
+ container cont1 {
+ leaf leaf1 {
+ type int32;
+ }
+ }
+}
+
diff --git a/compiler/plugin/maven/src/test/resources/xPathLinker/InterFile/InterSingleAugment/test.yang b/compiler/plugin/maven/src/test/resources/xPathLinker/InterFile/InterSingleAugment/test.yang
new file mode 100644
index 0000000..772f792
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/xPathLinker/InterFile/InterSingleAugment/test.yang
@@ -0,0 +1,25 @@
+module test {
+ namespace "xpath:inter:single";
+ prefix test ;
+
+ import test1{
+ prefix test1;
+ }
+
+ organization "";
+ contact "";
+
+ description
+ "Defines basic service types for L3VPN service.";
+
+ revision "2015-12-16" {
+ reference "";
+ }
+
+ augment /test1:cont1/test1:cont2 {
+ leaf a {
+ type int32;
+ }
+ }
+}
+
diff --git a/compiler/plugin/maven/src/test/resources/xPathLinker/InterFile/InterSingleAugment/test1.yang b/compiler/plugin/maven/src/test/resources/xPathLinker/InterFile/InterSingleAugment/test1.yang
new file mode 100644
index 0000000..b9c5e32
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/xPathLinker/InterFile/InterSingleAugment/test1.yang
@@ -0,0 +1,29 @@
+module test1 {
+ namespace "xpath:inter:single";
+ prefix test1 ;
+
+ organization "";
+ contact "";
+
+ description
+ "Defines basic service types for L3VPN service.";
+
+ revision "2015-12-16" {
+ reference "";
+ }
+
+ container cont1 {
+ leaf leaf1 {
+ type int32;
+ }
+ }
+
+ augment /cont1 {
+ container cont2 {
+ leaf leaf1 {
+ type int32;
+ }
+ }
+ }
+}
+
diff --git a/compiler/plugin/maven/src/test/resources/xPathLinker/InterFile/InterSingleSubModule/test.yang b/compiler/plugin/maven/src/test/resources/xPathLinker/InterFile/InterSingleSubModule/test.yang
new file mode 100644
index 0000000..a8340ab
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/xPathLinker/InterFile/InterSingleSubModule/test.yang
@@ -0,0 +1,27 @@
+module test {
+ namespace "xpath:intra:single";
+ prefix test ;
+
+ import test2 {
+ prefix test2;
+ }
+
+ include test1;
+
+ organization "";
+ contact "";
+
+ description
+ "Defines basic service types for L3VPN service.";
+
+ revision "2015-12-16" {
+ reference "";
+ }
+
+ augment /test2:cont1/test2:cont2/cont2 {
+ leaf a {
+ type int32;
+ }
+ }
+}
+
diff --git a/compiler/plugin/maven/src/test/resources/xPathLinker/InterFile/InterSingleSubModule/test1.yang b/compiler/plugin/maven/src/test/resources/xPathLinker/InterFile/InterSingleSubModule/test1.yang
new file mode 100644
index 0000000..ebc8750
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/xPathLinker/InterFile/InterSingleSubModule/test1.yang
@@ -0,0 +1,31 @@
+submodule test1 {
+
+ belongs-to test {
+ prefix test;
+ }
+
+ import test2 {
+ prefix test2;
+ }
+ organization "";
+ contact "";
+
+ description
+ "Defines basic service types for L3VPN service.";
+
+ revision "2015-12-16" {
+ reference "";
+ }
+
+ augment /test2:cont1/test2:cont2 {
+ leaf a {
+ type int32;
+ }
+ container cont2 {
+ leaf leaf1 {
+ type int32;
+ }
+ }
+ }
+}
+
diff --git a/compiler/plugin/maven/src/test/resources/xPathLinker/InterFile/InterSingleSubModule/test2.yang b/compiler/plugin/maven/src/test/resources/xPathLinker/InterFile/InterSingleSubModule/test2.yang
new file mode 100644
index 0000000..f20ac7d
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/xPathLinker/InterFile/InterSingleSubModule/test2.yang
@@ -0,0 +1,26 @@
+module test2 {
+ namespace "xpath:inter:multi";
+ prefix test2 ;
+
+ organization "";
+ contact "";
+
+ description
+ "Defines basic service types for L3VPN service.";
+
+ revision "2015-12-16" {
+ reference "";
+ }
+
+ container cont1 {
+ leaf leaf1 {
+ type int32;
+ }
+ container cont2 {
+ leaf leaf1 {
+ type int32;
+ }
+ }
+ }
+}
+
diff --git a/compiler/plugin/maven/src/test/resources/xPathLinker/InterFile/InterSingleUses/test.yang b/compiler/plugin/maven/src/test/resources/xPathLinker/InterFile/InterSingleUses/test.yang
new file mode 100644
index 0000000..15a6fab
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/xPathLinker/InterFile/InterSingleUses/test.yang
@@ -0,0 +1,34 @@
+module test {
+ namespace "xpath:intra:single";
+ prefix test ;
+
+ import test2 {
+ prefix test2;
+ }
+
+ include test1;
+
+ organization "";
+ contact "";
+
+ description
+ "Defines basic service types for L3VPN service.";
+
+ revision "2015-12-16" {
+ reference "";
+ }
+
+ augment /test2:cont1/test2:cont2/cont2 {
+ leaf leaf {
+ type int32;
+ }
+ uses group1;
+ }
+
+ augment /test2:cont1/test2:cont2/cont2/cont1/cont2 {
+ leaf leaf1 {
+ type int32;
+ }
+ }
+}
+
diff --git a/compiler/plugin/maven/src/test/resources/xPathLinker/InterFile/InterSingleUses/test1.yang b/compiler/plugin/maven/src/test/resources/xPathLinker/InterFile/InterSingleUses/test1.yang
new file mode 100644
index 0000000..e7fbc31
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/xPathLinker/InterFile/InterSingleUses/test1.yang
@@ -0,0 +1,42 @@
+submodule test1 {
+
+ belongs-to test {
+ prefix test;
+ }
+
+ import test2 {
+ prefix test2;
+ }
+ organization "";
+ contact "";
+
+ description
+ "Defines basic service types for L3VPN service.";
+
+ revision "2015-12-16" {
+ reference "";
+ }
+
+
+ grouping group1 {
+ container cont1 {
+ container cont2 {
+ leaf leaf2 {
+ type string;
+ }
+ }
+ }
+ }
+
+ augment /test2:cont1/test2:cont2 {
+ leaf leaf3 {
+ type int32;
+ }
+ container cont2 {
+ leaf leaf1 {
+ type int32;
+ }
+ }
+ }
+}
+
diff --git a/compiler/plugin/maven/src/test/resources/xPathLinker/InterFile/InterSingleUses/test2.yang b/compiler/plugin/maven/src/test/resources/xPathLinker/InterFile/InterSingleUses/test2.yang
new file mode 100644
index 0000000..2905f9a
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/xPathLinker/InterFile/InterSingleUses/test2.yang
@@ -0,0 +1,26 @@
+module test2 {
+ namespace "xpath:inter:multi";
+ prefix test2 ;
+
+ organization "";
+ contact "";
+
+ description
+ "Defines basic service types for L3VPN service.";
+
+ revision "2015-12-16" {
+ reference "";
+ }
+
+ container cont1 {
+ leaf leaf4 {
+ type int32;
+ }
+ container cont2 {
+ leaf leaf5 {
+ type int32;
+ }
+ }
+ }
+}
+
diff --git a/compiler/plugin/maven/src/test/resources/xPathLinker/IntraFile/IntraMulti/test.yang b/compiler/plugin/maven/src/test/resources/xPathLinker/IntraFile/IntraMulti/test.yang
new file mode 100644
index 0000000..77d61b9
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/xPathLinker/IntraFile/IntraMulti/test.yang
@@ -0,0 +1,37 @@
+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 {
+ type int32;
+ }
+ container cont2 {
+ leaf leaf2 {
+ type int32;
+ }
+ container cont3 {
+ leaf leaf3 {
+ type int32;
+ }
+ }
+ }
+ }
+
+ augment /cont1/cont2/cont3 {
+ leaf a {
+ type int32;
+ }
+ }
+}
+
diff --git a/compiler/plugin/maven/src/test/resources/xPathLinker/IntraFile/IntraMultiAugment/withoutprefix/test.yang b/compiler/plugin/maven/src/test/resources/xPathLinker/IntraFile/IntraMultiAugment/withoutprefix/test.yang
new file mode 100644
index 0000000..b634ab6
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/xPathLinker/IntraFile/IntraMultiAugment/withoutprefix/test.yang
@@ -0,0 +1,53 @@
+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 {
+ type int32;
+ }
+ container cont2 {
+ leaf leaf2 {
+ type int32;
+ }
+ container cont3 {
+ leaf leaf3 {
+ type int32;
+ }
+ }
+ }
+ }
+
+ augment /cont1/cont2/cont3 {
+ leaf a {
+ type int32;
+ }
+ container cont4 {
+ leaf leaf2 {
+ type int32;
+ }
+ }
+ }
+
+ augment /cont1/cont2/cont3/cont4 {
+ leaf a {
+ type int32;
+ }
+
+ container cont5 {
+ leaf leaf1 {
+ type int32;
+ }
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/xPathLinker/IntraFile/IntraMultiAugment/withpartialprefix/augmentpartialprefix.yang b/compiler/plugin/maven/src/test/resources/xPathLinker/IntraFile/IntraMultiAugment/withpartialprefix/augmentpartialprefix.yang
new file mode 100644
index 0000000..7a84927
--- /dev/null
+++ b/compiler/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/compiler/plugin/maven/src/test/resources/xPathLinker/IntraFile/IntraMultiAugment/withprefix/augment.yang b/compiler/plugin/maven/src/test/resources/xPathLinker/IntraFile/IntraMultiAugment/withprefix/augment.yang
new file mode 100644
index 0000000..be666b3
--- /dev/null
+++ b/compiler/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
diff --git a/compiler/plugin/maven/src/test/resources/xPathLinker/IntraFile/IntraMultiSubModule/test.yang b/compiler/plugin/maven/src/test/resources/xPathLinker/IntraFile/IntraMultiSubModule/test.yang
new file mode 100644
index 0000000..b5d1c8d
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/xPathLinker/IntraFile/IntraMultiSubModule/test.yang
@@ -0,0 +1,28 @@
+module test {
+ namespace "xpath:intra:multi";
+ prefix test ;
+
+ include test1;
+ organization "";
+ contact "";
+
+ description
+ "Defines basic service types for L3VPN service.";
+
+ revision "2015-12-16" {
+ reference "";
+ }
+
+ container cont1 {
+ leaf leaf1 {
+ type int32;
+ }
+ }
+
+ augment /cont2/cont3 {
+ leaf a {
+ type int32;
+ }
+ }
+}
+
diff --git a/compiler/plugin/maven/src/test/resources/xPathLinker/IntraFile/IntraMultiSubModule/test1.yang b/compiler/plugin/maven/src/test/resources/xPathLinker/IntraFile/IntraMultiSubModule/test1.yang
new file mode 100644
index 0000000..faf672e
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/xPathLinker/IntraFile/IntraMultiSubModule/test1.yang
@@ -0,0 +1,28 @@
+submodule test1 {
+
+ belongs-to "test" {
+ prefix "test";
+ }
+
+ organization "";
+ contact "";
+
+ description
+ "Defines basic service types for L3VPN service.";
+
+ revision "2015-12-16" {
+ reference "";
+ }
+
+ container cont2 {
+ leaf leaf1 {
+ type int32;
+ }
+ container cont3 {
+ leaf leaf3 {
+ type int32;
+ }
+ }
+ }
+}
+
diff --git a/compiler/plugin/maven/src/test/resources/xPathLinker/IntraFile/IntraMultiUses/test.yang b/compiler/plugin/maven/src/test/resources/xPathLinker/IntraFile/IntraMultiUses/test.yang
new file mode 100644
index 0000000..6d7473d
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/xPathLinker/IntraFile/IntraMultiUses/test.yang
@@ -0,0 +1,38 @@
+module test {
+ namespace "xpath:intra:single";
+ prefix test ;
+
+ organization "";
+ contact "";
+
+ description
+ "Defines basic service types for L3VPN service.";
+
+ revision "2015-12-16" {
+ reference "";
+ }
+
+ grouping group1 {
+ container cont1 {
+ leaf leaf1 {
+ type int32;
+ }
+ container cont3 {
+ leaf leaf1 {
+ type int32;
+ }
+ }
+ }
+ }
+
+ container cont2 {
+ uses group1;
+ }
+
+ augment /cont2/cont1/cont3 {
+ leaf a {
+ type int32;
+ }
+ }
+}
+
diff --git a/compiler/plugin/maven/src/test/resources/xPathLinker/IntraFile/IntraSingle/test.yang b/compiler/plugin/maven/src/test/resources/xPathLinker/IntraFile/IntraSingle/test.yang
new file mode 100644
index 0000000..95d9c2b
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/xPathLinker/IntraFile/IntraSingle/test.yang
@@ -0,0 +1,27 @@
+module test {
+ namespace "xpath:intra:single";
+ prefix test ;
+
+ organization "";
+ contact "";
+
+ description
+ "Defines basic service types for L3VPN service.";
+
+ revision "2015-12-16" {
+ reference "";
+ }
+
+ container cont1 {
+ leaf leaf1 {
+ type int32;
+ }
+ }
+
+ augment /cont1 {
+ leaf a {
+ type int32;
+ }
+ }
+}
+
diff --git a/compiler/plugin/maven/src/test/resources/xPathLinker/IntraFile/IntraSingleAugment/test.yang b/compiler/plugin/maven/src/test/resources/xPathLinker/IntraFile/IntraSingleAugment/test.yang
new file mode 100644
index 0000000..2925dcf
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/xPathLinker/IntraFile/IntraSingleAugment/test.yang
@@ -0,0 +1,39 @@
+module test {
+ namespace "xpath:intra:single";
+ prefix test ;
+
+ organization "";
+ contact "";
+
+ description
+ "Defines basic service types for L3VPN service.";
+
+ revision "2015-12-16" {
+ reference "";
+ }
+
+ container cont1 {
+ leaf leaf1 {
+ type int32;
+ }
+ }
+
+ augment /cont1 {
+ leaf a {
+ type int32;
+ }
+
+ container cont2 {
+ leaf leaf1 {
+ type int32;
+ }
+ }
+ }
+
+ augment /cont1/cont2 {
+ leaf a {
+ type int32;
+ }
+ }
+}
+
diff --git a/compiler/plugin/maven/src/test/resources/xPathLinker/IntraFile/IntraSingleSubModule/test.yang b/compiler/plugin/maven/src/test/resources/xPathLinker/IntraFile/IntraSingleSubModule/test.yang
new file mode 100644
index 0000000..77401da
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/xPathLinker/IntraFile/IntraSingleSubModule/test.yang
@@ -0,0 +1,28 @@
+module test {
+ namespace "xpath:intra:single";
+ prefix test ;
+
+ include test1;
+ organization "";
+ contact "";
+
+ description
+ "Defines basic service types for L3VPN service.";
+
+ revision "2015-12-16" {
+ reference "";
+ }
+
+ container cont1 {
+ leaf leaf1 {
+ type int32;
+ }
+ }
+
+ augment /cont2 {
+ leaf a {
+ type int32;
+ }
+ }
+}
+
diff --git a/compiler/plugin/maven/src/test/resources/xPathLinker/IntraFile/IntraSingleSubModule/test1.yang b/compiler/plugin/maven/src/test/resources/xPathLinker/IntraFile/IntraSingleSubModule/test1.yang
new file mode 100644
index 0000000..47d4c5c
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/xPathLinker/IntraFile/IntraSingleSubModule/test1.yang
@@ -0,0 +1,23 @@
+submodule test1 {
+
+ belongs-to test {
+ prefix test;
+ }
+
+ organization "";
+ contact "";
+
+ description
+ "Defines basic service types for L3VPN service.";
+
+ revision "2015-12-16" {
+ reference "";
+ }
+
+ container cont2 {
+ leaf leaf1 {
+ type int32;
+ }
+ }
+}
+
diff --git a/compiler/plugin/maven/src/test/resources/xPathLinker/IntraFile/IntraSingleUses/test.yang b/compiler/plugin/maven/src/test/resources/xPathLinker/IntraFile/IntraSingleUses/test.yang
new file mode 100644
index 0000000..3074db7
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/xPathLinker/IntraFile/IntraSingleUses/test.yang
@@ -0,0 +1,33 @@
+module test {
+ namespace "xpath:intra:single";
+ prefix test ;
+
+ organization "";
+ contact "";
+
+ description
+ "Defines basic service types for L3VPN service.";
+
+ revision "2015-12-16" {
+ reference "";
+ }
+
+ grouping group1 {
+ container cont1 {
+ leaf leaf1 {
+ type int32;
+ }
+ }
+ }
+
+ container cont2 {
+ uses group1;
+ }
+
+ augment /cont2/cont1 {
+ leaf a {
+ type int32;
+ }
+ }
+}
+