[ONOS-4547, ONOS-4566, ONOS-4575, ONOS-4582, ONOS-4581, ONOS-4600,
ONOS-4598, ONOS-4607, ONOS-4610, ONOS-4611] Prefix addition from config
and defect fixes.
Change-Id: Ieaab5d3e0fe9a1bfa24a2527eeec5435cf0a1b85
diff --git a/tools/build/conf/src/main/resources/onos/suppressions.xml b/tools/build/conf/src/main/resources/onos/suppressions.xml
index 28c1938..4af0d62 100644
--- a/tools/build/conf/src/main/resources/onos/suppressions.xml
+++ b/tools/build/conf/src/main/resources/onos/suppressions.xml
@@ -41,4 +41,6 @@
<suppress checks="JavadocPackage"
files=".*/thirdparty/.*.java"/>
+ <!-- Suppressions for yangutils generated code -->
+ <suppress files="org.onosproject.yang.gen.v1.*" checks="JavadocStyle" />
</suppressions>
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangEnumeration.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangEnumeration.java
index f004d5e..65f733c 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangEnumeration.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangEnumeration.java
@@ -31,7 +31,7 @@
/**
* Represents the enumeration data type information.
*/
-public class YangEnumeration extends YangNode implements Parsable {
+public class YangEnumeration extends YangNode implements Parsable, CollisionDetector {
// Enumeration info set.
private Set<YangEnum> enumSet;
@@ -126,4 +126,18 @@
public void validateDataOnExit() throws DataModelException {
// TODO auto-generated method stub, to be implemented by parser
}
+
+ @Override
+ public void detectCollidingChild(String identifierName, YangConstructType dataType) throws DataModelException {
+ /*
+ Do nothing.The implementation for this is not required.
+ */
+ }
+
+ @Override
+ public void detectSelfCollision(String identifierName, YangConstructType dataType) throws DataModelException {
+ /*
+ Do nothing.The implementation for this is not required.
+ */
+ }
}
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangList.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangList.java
index 246ffa2..cd45bdc 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangList.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangList.java
@@ -444,8 +444,8 @@
validateConfig(leaves, leafLists);
/* A list must have atleast one key leaf if config is true */
- if (isConfig
- && (keys == null || leaves == null && leafLists == null && !isUsesPresentInList())) {
+ if (isConfig && (keys == null || leaves == null && leafLists == null) && !isUsesPresentInList()
+ && !isListPresentInGrouping()) {
throw new DataModelException("A list must have atleast one key leaf if config is true;");
} else if (keys != null) {
validateKey(leaves, leafLists, keys);
@@ -565,7 +565,7 @@
}
}
- if (!leafFound && !isUsesPresentInList()) {
+ if (!leafFound && !isUsesPresentInList() && !isListPresentInGrouping()) {
throw new DataModelException("An identifier, in key, must refer to a child leaf of the list");
}
leafFound = false;
@@ -617,6 +617,18 @@
node = node.getNextSibling();
}
return false;
+ // TODO When grouping linking is done this method has to be modified.
}
+ private boolean isListPresentInGrouping() {
+ YangNode node = this.getParent();
+ while (node != null) {
+ if (node instanceof YangGrouping) {
+ return true;
+ }
+ node = node.getParent();
+ }
+ return false;
+ // TODO When grouping linking is done this method has to be modified.
+ }
}
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/plugin/manager/YangUtilManager.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/plugin/manager/YangUtilManager.java
index fbde352..0f6febeb 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/plugin/manager/YangUtilManager.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/plugin/manager/YangUtilManager.java
@@ -122,6 +122,12 @@
private String replacementForHyphen;
/**
+ * Prefix which is required for adding with the identifier.
+ */
+ @Parameter(property = "prefixForIdentifier")
+ private String prefixForIdentifier;
+
+ /**
* Build context.
*/
@Component
@@ -146,6 +152,7 @@
conflictResolver.setReplacementForPeriod(replacementForPeriod);
conflictResolver.setReplacementForHyphen(replacementForHyphen);
conflictResolver.setReplacementForUnderscore(replacementForUnderscore);
+ conflictResolver.setPrefixForIdentifier(prefixForIdentifier);
YangPluginConfig yangPlugin = new YangPluginConfig();
yangPlugin.setCodeGenDir(codeGenDir);
yangPlugin.setConflictResolver(conflictResolver);
@@ -174,7 +181,7 @@
addToSource(getDirectory(baseDir, genFilesDir), project, context);
copyYangFilesToTarget(getYangFileInfoSet(), getDirectory(baseDir, outputDirectory), project);
- } catch (Exception e) {
+ } catch (IOException | ParserException e) {
String fileName = "";
if (getCurYangFileInfo() != null) {
fileName = getCurYangFileInfo().getYangFileName();
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/JavaQualifiedTypeInfo.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/JavaQualifiedTypeInfo.java
index 52df259..e581bb1 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/JavaQualifiedTypeInfo.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/JavaQualifiedTypeInfo.java
@@ -103,9 +103,8 @@
* Current leaves holder is adding a leaf info as a attribute to the
* current class.
*/
- String className =
- AttributesJavaDataType.getJavaImportClass(leaf.getDataType(), leaf.isLeafList(),
- leaf.getConflictResolveConfig());
+ String className = AttributesJavaDataType.getJavaImportClass(leaf.getDataType(), leaf.isLeafList(),
+ leaf.getConflictResolveConfig());
if (className != null) {
/*
* Corresponding to the attribute type a class needs to be imported,
@@ -113,7 +112,7 @@
*/
importInfo.setClassInfo(className);
String classPkg = AttributesJavaDataType.getJavaImportPackage(leaf.getDataType(),
- leaf.isLeafList(), className);
+ leaf.isLeafList(), className, leaf.getConflictResolveConfig());
if (classPkg == null) {
throw new TranslatorException("import package cannot be null when the class is used");
}
@@ -166,11 +165,11 @@
* Returns the java qualified type information for the wrapper classes.
*
* @param referredTypesAttrInfo attribute of referred type
- * @param confilictResolver plugin configurations
+ * @param conflictResolver plugin configurations
* @return return the import info for this attribute
*/
public static JavaQualifiedTypeInfo getQualifiedInfoOfFromString(JavaAttributeInfo referredTypesAttrInfo,
- YangToJavaNamingConflictUtil confilictResolver) {
+ YangToJavaNamingConflictUtil conflictResolver) {
/*
* Get the java qualified type information for the wrapper classes and
@@ -179,9 +178,9 @@
JavaQualifiedTypeInfo qualifiedInfoOfFromString = new JavaQualifiedTypeInfo();
qualifiedInfoOfFromString.setClassInfo(
- getJavaImportClass(referredTypesAttrInfo.getAttributeType(), true, confilictResolver));
+ getJavaImportClass(referredTypesAttrInfo.getAttributeType(), true, conflictResolver));
qualifiedInfoOfFromString.setPkgInfo(
- getJavaImportPackage(referredTypesAttrInfo.getAttributeType(), true, null));
+ getJavaImportPackage(referredTypesAttrInfo.getAttributeType(), true, null, conflictResolver));
return qualifiedInfoOfFromString;
}
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/TempJavaEnumerationFragmentFiles.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/TempJavaEnumerationFragmentFiles.java
index 001807a..2ab6f9d 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/TempJavaEnumerationFragmentFiles.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/TempJavaEnumerationFragmentFiles.java
@@ -34,8 +34,12 @@
import static org.onosproject.yangutils.translator.tojava.JavaAttributeInfo.getAttributeInfoForTheData;
import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.generateEnumAttributeString;
import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateEnumClassFile;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getEnumJavaAttribute;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getPrefixForIdentifier;
import static org.onosproject.yangutils.translator.tojava.utils.TempJavaCodeFragmentFilesUtils.closeFile;
import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING;
+import static org.onosproject.yangutils.utils.UtilConstants.REGEX_FOR_FIRST_DIGIT;
+import static org.onosproject.yangutils.utils.UtilConstants.YANG_AUTO_PREFIX;
import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.createPackage;
/**
@@ -173,7 +177,7 @@
/**
* Adds enum class attributes to temporary file.
*
- * @param curEnumInfo current YANG enum
+ * @param curEnumName current YANG enum
* @throws IOException when fails to do IO operations.
*/
private void addAttributesForEnumClass(String curEnumName, YangPluginConfig pluginConfig) throws IOException {
@@ -194,6 +198,16 @@
if (curNode instanceof YangEnumeration) {
YangEnumeration enumeration = (YangEnumeration) curNode;
for (YangEnum curEnum : enumeration.getEnumSet()) {
+ String enumName = curEnum.getNamedValue();
+ String prefixForIdentifier = null;
+ if (enumName.matches(REGEX_FOR_FIRST_DIGIT)) {
+ prefixForIdentifier = getPrefixForIdentifier(pluginConfig.getConflictResolver());
+ if (prefixForIdentifier != null) {
+ curEnum.setNamedValue(prefixForIdentifier + enumName);
+ } else {
+ curEnum.setNamedValue(YANG_AUTO_PREFIX + enumName);
+ }
+ }
setEnumValue(curEnum.getValue());
addToEnumStringList(curEnum.getNamedValue());
addToEnumSetJavaMap(curEnum.getNamedValue(), curEnum.getValue());
@@ -228,7 +242,7 @@
* @param curEnumName current enum name
*/
private void addToEnumSetJavaMap(String curEnumName, int value) {
- getEnumSetJavaMap().put(curEnumName.toUpperCase(), value);
+ getEnumSetJavaMap().put(getEnumJavaAttribute(curEnumName).toUpperCase(), value);
}
/**
@@ -240,7 +254,7 @@
*/
void addJavaSnippetInfoToApplicableTempFiles(String curEnumName, YangPluginConfig pluginConfig)
throws IOException {
- addAttributesForEnumClass(curEnumName, pluginConfig);
+ addAttributesForEnumClass(getEnumJavaAttribute(curEnumName), pluginConfig);
}
/**
@@ -279,7 +293,7 @@
* @param curEnumValue current enum value
*/
private void addToEnumStringList(String curEnumValue) {
- getEnumStringList().add(curEnumValue.toUpperCase());
+ getEnumStringList().add(getEnumJavaAttribute(curEnumValue).toUpperCase());
}
/**
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/TempJavaTypeFragmentFiles.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/TempJavaTypeFragmentFiles.java
index 326cf55..2cbbb49 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/TempJavaTypeFragmentFiles.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/TempJavaTypeFragmentFiles.java
@@ -28,7 +28,6 @@
import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaType;
import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig;
-import static org.onosproject.yangutils.datamodel.YangDataTypes.DERIVED;
import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_TYPEDEF_CLASS;
import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_UNION_CLASS;
import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.CONSTRUCTOR_FOR_TYPE_MASK;
@@ -212,10 +211,7 @@
YangJavaType<?> javaType = (YangJavaType<?>) yangType;
javaType.updateJavaQualifiedInfo(pluginConfig.getConflictResolver());
String typeName = javaType.getDataTypeName();
-
- if (javaType.getDataType().equals(DERIVED)) {
typeName = getCamelCase(typeName, pluginConfig.getConflictResolver());
- }
JavaAttributeInfo javaAttributeInfo = getAttributeInfoForTheData(
javaType.getJavaQualifiedInfo(),
typeName, javaType,
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaModule.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaModule.java
index 5bbe81b..aed8179 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaModule.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaModule.java
@@ -126,7 +126,8 @@
*/
@Override
public void generateCodeEntry(YangPluginConfig yangPlugin) throws TranslatorException {
- String modulePkg = getRootPackage(getVersion(), getNameSpace().getUri(), getRevision().getRevDate());
+ String modulePkg = getRootPackage(getVersion(), getNameSpace().getUri(), getRevision().getRevDate(),
+ yangPlugin.getConflictResolver());
try {
generateCodeOfRootNode(this, yangPlugin, modulePkg);
} catch (IOException e) {
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaSubModule.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaSubModule.java
index 8696495..7205ad7 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaSubModule.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaSubModule.java
@@ -139,7 +139,7 @@
@Override
public void generateCodeEntry(YangPluginConfig yangPlugin) throws TranslatorException {
String subModulePkg = getRootPackage(getVersion(), getNameSpaceFromModule(getBelongsTo()),
- getRevision().getRevDate());
+ getRevision().getRevDate(), yangPlugin.getConflictResolver());
try {
generateCodeOfRootNode(this, yangPlugin, subModulePkg);
} catch (IOException e) {
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaType.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaType.java
index 4ba4858..660940f 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaType.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaType.java
@@ -41,13 +41,13 @@
}
@Override
- public void updateJavaQualifiedInfo(YangToJavaNamingConflictUtil confilictResolver) {
+ public void updateJavaQualifiedInfo(YangToJavaNamingConflictUtil conflictResolver) {
JavaQualifiedTypeInfo importInfo = getJavaQualifiedInfo();
/*
* Type is added as an attribute in the class.
*/
- String className = AttributesJavaDataType.getJavaImportClass(this, false, confilictResolver);
+ String className = AttributesJavaDataType.getJavaImportClass(this, false, conflictResolver);
if (className != null) {
/*
* Corresponding to the attribute type a class needs to be imported,
@@ -55,7 +55,7 @@
*/
importInfo.setClassInfo(className);
String classPkg = AttributesJavaDataType.getJavaImportPackage(this,
- false, className);
+ false, className, conflictResolver);
if (classPkg == null) {
throw new TranslatorException("import package cannot be null when the class is used");
}
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/utils/AttributesJavaDataType.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/utils/AttributesJavaDataType.java
index ebcdc99..cb23994 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/utils/AttributesJavaDataType.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/utils/AttributesJavaDataType.java
@@ -271,9 +271,11 @@
* @param yangType YANG type
* @param isListAttr if the attribute is of list type
* @param classInfo java import class info
+ * @param conflictResolver object of YANG to java naming conflict util
* @return java import package
*/
- public static String getJavaImportPackage(YangType<?> yangType, boolean isListAttr, String classInfo) {
+ public static String getJavaImportPackage(YangType<?> yangType, boolean isListAttr, String classInfo,
+ YangToJavaNamingConflictUtil conflictResolver) {
YangDataTypes type = yangType.getDataType();
@@ -293,7 +295,7 @@
case UINT64:
return JAVA_MATH;
case ENUMERATION:
- return getEnumsPackage(yangType);
+ return getEnumsPackage(yangType, conflictResolver);
case DECIMAL64:
case BITS:
case BINARY:
@@ -305,12 +307,12 @@
//TODO:IDENTITYREF
break;
case UNION:
- return getUnionPackage(yangType);
+ return getUnionPackage(yangType, conflictResolver);
case INSTANCE_IDENTIFIER:
//TODO:INSTANCE_IDENTIFIER
break;
case DERIVED:
- return getTypDefsPackage(yangType);
+ return getTypDefsPackage(yangType, conflictResolver);
default:
throw new TranslatorException("given data type is not supported.");
}
@@ -321,7 +323,7 @@
case STRING:
return JAVA_LANG;
case ENUMERATION:
- return getEnumsPackage(yangType);
+ return getEnumsPackage(yangType, conflictResolver);
case DECIMAL64:
case BITS:
case BINARY:
@@ -335,12 +337,12 @@
case EMPTY:
return JAVA_LANG;
case UNION:
- return getUnionPackage(yangType);
+ return getUnionPackage(yangType, conflictResolver);
case INSTANCE_IDENTIFIER:
//TODO:INSTANCE_IDENTIFIER
break;
case DERIVED:
- return getTypDefsPackage(yangType);
+ return getTypDefsPackage(yangType, conflictResolver);
default:
return null;
}
@@ -352,9 +354,10 @@
* Returns java package for typedef node.
*
* @param type YANG type
+ * @param conflictResolver object of YANG to java naming conflict util
* @return java package for typedef node
*/
- private static String getTypDefsPackage(YangType<?> type) {
+ private static String getTypDefsPackage(YangType<?> type, YangToJavaNamingConflictUtil conflictResolver) {
Object var = type.getDataTypeExtendedInfo();
if (!(var instanceof YangDerivedInfo)) {
throw new TranslatorException("type should have been derived.");
@@ -366,7 +369,7 @@
YangJavaTypeDef typedef = (YangJavaTypeDef) ((YangDerivedInfo<?>) var).getReferredTypeDef();
if (typedef.getJavaFileInfo().getPackage() == null) {
- return getPackageFromParent(typedef.getParent());
+ return getPackageFromParent(typedef.getParent(), conflictResolver);
}
return typedef.getJavaFileInfo().getPackage();
}
@@ -375,9 +378,10 @@
* Returns java package for union node.
*
* @param type YANG type
+ * @param conflictResolver object of YANG to java naming conflict util
* @return java package for union node
*/
- private static String getUnionPackage(YangType<?> type) {
+ private static String getUnionPackage(YangType<?> type, YangToJavaNamingConflictUtil conflictResolver) {
if (!(type.getDataTypeExtendedInfo() instanceof YangUnion)) {
throw new TranslatorException("type should have been union.");
@@ -385,7 +389,7 @@
YangJavaUnion union = (YangJavaUnion) type.getDataTypeExtendedInfo();
if (union.getJavaFileInfo().getPackage() == null) {
- return getPackageFromParent(union.getParent());
+ return getPackageFromParent(union.getParent(), conflictResolver);
}
return union.getJavaFileInfo().getPackage();
}
@@ -394,16 +398,17 @@
* Returns YANG enumeration's java package.
*
* @param type YANG type
+ * @param conflictResolver object of YANG to java naming conflict util
* @return YANG enumeration's java package
*/
- private static String getEnumsPackage(YangType<?> type) {
+ private static String getEnumsPackage(YangType<?> type, YangToJavaNamingConflictUtil conflictResolver) {
if (!(type.getDataTypeExtendedInfo() instanceof YangEnumeration)) {
throw new TranslatorException("type should have been enumeration.");
}
YangJavaEnumeration enumeration = (YangJavaEnumeration) type.getDataTypeExtendedInfo();
if (enumeration.getJavaFileInfo().getPackage() == null) {
- return getPackageFromParent(enumeration.getParent());
+ return getPackageFromParent(enumeration.getParent(), conflictResolver);
}
return enumeration.getJavaFileInfo().getPackage();
}
@@ -412,9 +417,10 @@
* Returns package from parent node.
*
* @param parent parent YANG node
+ * @param conflictResolver object of YANG to java naming conflict util
* @return java package from parent node
*/
- private static String getPackageFromParent(YangNode parent) {
+ private static String getPackageFromParent(YangNode parent, YangToJavaNamingConflictUtil conflictResolver) {
if (!(parent instanceof JavaFileInfoContainer)) {
throw new TranslatorException("invalid child node is being processed.");
}
@@ -423,13 +429,13 @@
if (parent instanceof YangJavaModule) {
YangJavaModule module = (YangJavaModule) parent;
String modulePkg = getRootPackage(module.getVersion(), module.getNameSpace().getUri(), module
- .getRevision().getRevDate());
+ .getRevision().getRevDate(), conflictResolver);
return modulePkg + PERIOD + getCamelCase(module.getName(), null).toLowerCase();
} else if (parent instanceof YangJavaSubModule) {
YangJavaSubModule submodule = (YangJavaSubModule) parent;
String subModulePkg = getRootPackage(submodule.getVersion(),
submodule.getNameSpaceFromModule(submodule.getBelongsTo()),
- submodule.getRevision().getRevDate());
+ submodule.getRevision().getRevDate(), conflictResolver);
return subModulePkg + PERIOD + getCamelCase(submodule.getName(), null).toLowerCase();
}
}
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/utils/ClassDefinitionGenerator.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/utils/ClassDefinitionGenerator.java
index f0a16f6..dde4b03 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/utils/ClassDefinitionGenerator.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/utils/ClassDefinitionGenerator.java
@@ -53,6 +53,7 @@
import static org.onosproject.yangutils.utils.UtilConstants.OPEN_CURLY_BRACKET;
import static org.onosproject.yangutils.utils.UtilConstants.PERIOD;
import static org.onosproject.yangutils.utils.UtilConstants.PUBLIC;
+import static org.onosproject.yangutils.utils.UtilConstants.REGEX_FOR_ANY_STRING_ENDING_WITH_SERVICE;
import static org.onosproject.yangutils.utils.UtilConstants.SERVICE;
import static org.onosproject.yangutils.utils.UtilConstants.SPACE;
import static org.onosproject.yangutils.utils.UtilConstants.SUBJECT;
@@ -241,24 +242,25 @@
curNode = curNode.getNextSibling();
}
}
- if (yangName.contains(SERVICE)) {
+ if (yangName.matches(REGEX_FOR_ANY_STRING_ENDING_WITH_SERVICE)) {
return PUBLIC + SPACE + INTERFACE + SPACE + yangName + SPACE + OPEN_CURLY_BRACKET + NEW_LINE;
}
- return PUBLIC + SPACE + CLASS + SPACE + yangName + MANAGER + SPACE + IMPLEMENTS + SPACE + yangName
- + SERVICE + SPACE + OPEN_CURLY_BRACKET + NEW_LINE;
+ return PUBLIC + SPACE + CLASS + SPACE + yangName + SPACE + IMPLEMENTS + SPACE
+ + yangName.substring(0, yangName.length() - 7) + SERVICE + SPACE + OPEN_CURLY_BRACKET + NEW_LINE;
}
/* Provides class definition when RPC interface needs to extends any event.*/
private static String getRpcInterfaceDefinitionWhenItExtends(String yangName,
JavaExtendsListHolder holder) {
- if (yangName.contains(SERVICE)) {
+ if (yangName.matches(REGEX_FOR_ANY_STRING_ENDING_WITH_SERVICE)) {
String[] strArray = yangName.split(SERVICE);
return PUBLIC + SPACE + INTERFACE + SPACE + yangName + NEW_LINE + EIGHT_SPACE_INDENTATION
+ EXTEND + SPACE + LISTENER_SERVICE + DIAMOND_OPEN_BRACKET + strArray[0] + EVENT_STRING + COMMA
+ SPACE + strArray[0] + EVENT_LISTENER_STRING + DIAMOND_CLOSE_BRACKET + SPACE
+ OPEN_CURLY_BRACKET + NEW_LINE;
}
+ yangName = yangName.substring(0, yangName.length() - 7);
return PUBLIC + SPACE + CLASS + SPACE + yangName + MANAGER + NEW_LINE + EIGHT_SPACE_INDENTATION
+ EXTEND + SPACE + LISTENER_REG + DIAMOND_OPEN_BRACKET + yangName + EVENT_STRING + COMMA + SPACE
+ yangName + EVENT_LISTENER_STRING + DIAMOND_CLOSE_BRACKET + NEW_LINE
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaFileGenerator.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaFileGenerator.java
index ee7ad23..c082d26 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaFileGenerator.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaFileGenerator.java
@@ -97,6 +97,7 @@
import static org.onosproject.yangutils.utils.UtilConstants.IMPL;
import static org.onosproject.yangutils.utils.UtilConstants.INT;
import static org.onosproject.yangutils.utils.UtilConstants.LOGGER_STATEMENT;
+import static org.onosproject.yangutils.utils.UtilConstants.MANAGER;
import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE;
import static org.onosproject.yangutils.utils.UtilConstants.PRIVATE;
import static org.onosproject.yangutils.utils.UtilConstants.PUBLIC;
@@ -306,7 +307,7 @@
JavaFileInfo javaFileInfo = ((JavaFileInfoContainer) curNode).getJavaFileInfo();
- String className = getCapitalCase(javaFileInfo.getJavaName());
+ String className = getCapitalCase(javaFileInfo.getJavaName()) + MANAGER;
initiateJavaFileGeneration(file, GENERATE_SERVICE_AND_MANAGER, imports, curNode, className);
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaFileGeneratorUtils.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaFileGeneratorUtils.java
index 7e31b62..707d947 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaFileGeneratorUtils.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaFileGeneratorUtils.java
@@ -72,14 +72,13 @@
import static org.onosproject.yangutils.utils.UtilConstants.FOUR_SPACE_INDENTATION;
import static org.onosproject.yangutils.utils.UtilConstants.IMMEDIATE;
import static org.onosproject.yangutils.utils.UtilConstants.INT;
-import static org.onosproject.yangutils.utils.UtilConstants.MANAGER;
import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE;
import static org.onosproject.yangutils.utils.UtilConstants.OPEN_PARENTHESIS;
import static org.onosproject.yangutils.utils.UtilConstants.PACKAGE;
import static org.onosproject.yangutils.utils.UtilConstants.PERIOD;
import static org.onosproject.yangutils.utils.UtilConstants.PRIVATE;
+import static org.onosproject.yangutils.utils.UtilConstants.REGEX_FOR_ANY_STRING_ENDING_WITH_SERVICE;
import static org.onosproject.yangutils.utils.UtilConstants.SEMI_COLAN;
-import static org.onosproject.yangutils.utils.UtilConstants.SERVICE;
import static org.onosproject.yangutils.utils.UtilConstants.SERVICE_ANNOTATION;
import static org.onosproject.yangutils.utils.UtilConstants.SLASH;
import static org.onosproject.yangutils.utils.UtilConstants.SPACE;
@@ -317,7 +316,7 @@
if (type == GENERATE_EVENT_CLASS
|| type == GENERATE_EVENT_LISTENER_INTERFACE
|| type == GENERATE_EVENT_SUBJECT_CLASS) {
- pkgString = parsePackageString(path + PERIOD + name, importsList);
+ pkgString = parsePackageString((path + PERIOD + name).toLowerCase(), importsList);
} else {
pkgString = parsePackageString(path, importsList);
}
@@ -454,8 +453,8 @@
YangPluginConfig pluginConfig = ((JavaFileInfoContainer) curNode).getJavaFileInfo().getPluginConfig();
if ((genType & GENERATE_SERVICE_AND_MANAGER) != 0) {
- if (!fileName.contains(SERVICE)) {
- insertDataIntoJavaFile(file, getJavaDoc(RPC_MANAGER, fileName + MANAGER, false, pluginConfig));
+ if (!fileName.matches(REGEX_FOR_ANY_STRING_ENDING_WITH_SERVICE)) {
+ insertDataIntoJavaFile(file, getJavaDoc(RPC_MANAGER, fileName, false, pluginConfig));
insertDataIntoJavaFile(file, addComponentString());
} else {
insertDataIntoJavaFile(file, getJavaDoc(javaDocType, fileName, false, pluginConfig));
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaIdentifierSyntax.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaIdentifierSyntax.java
index 10ec3c2..a4e9cfa 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaIdentifierSyntax.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaIdentifierSyntax.java
@@ -75,16 +75,18 @@
* @param version YANG version
* @param nameSpace name space of the module
* @param revision revision of the module defined
- * @return returns the root package string
+ * @param conflictResolver object of YANG to java naming conflict util
+ * @return the root package string
*/
- public static String getRootPackage(byte version, String nameSpace, String revision) {
+ public static String getRootPackage(byte version, String nameSpace, String revision,
+ YangToJavaNamingConflictUtil conflictResolver) {
String pkg;
pkg = DEFAULT_BASE_PKG;
pkg = pkg + PERIOD;
pkg = pkg + getYangVersion(version);
pkg = pkg + PERIOD;
- pkg = pkg + getPkgFromNameSpace(nameSpace);
+ pkg = pkg + getPkgFromNameSpace(nameSpace, conflictResolver);
pkg = pkg + PERIOD;
pkg = pkg + getYangRevisionStr(revision);
@@ -144,9 +146,10 @@
* Returns package name from name space.
*
* @param nameSpace name space of YANG module
+ * @param conflictResolver object of YANG to java naming conflict util
* @return java package name as per java rules
*/
- private static String getPkgFromNameSpace(String nameSpace) {
+ private static String getPkgFromNameSpace(String nameSpace, YangToJavaNamingConflictUtil conflictResolver) {
ArrayList<String> pkgArr = new ArrayList<String>();
nameSpace = nameSpace.replace(QUOTES, EMPTY_STRING);
@@ -156,7 +159,7 @@
for (String nameSpaceString : nameSpaceArr) {
pkgArr.add(nameSpaceString);
}
- return getPkgFrmArr(pkgArr);
+ return getPkgFrmArr(pkgArr, conflictResolver);
}
/**
@@ -194,17 +197,19 @@
* Returns the package string.
*
* @param pkgArr package array
+ * @param conflictResolver object of YANG to java naming conflict util
* @return package string
*/
- private static String getPkgFrmArr(ArrayList<String> pkgArr) {
+ private static String getPkgFrmArr(ArrayList<String> pkgArr, YangToJavaNamingConflictUtil conflictResolver) {
String pkg = EMPTY_STRING;
int size = pkgArr.size();
int i = 0;
for (String member : pkgArr) {
- boolean presenceOfKeyword = JAVA_KEY_WORDS.contains(member);
+ boolean presenceOfKeyword = JAVA_KEY_WORDS.contains(member.toLowerCase());
if (presenceOfKeyword || member.matches(REGEX_FOR_FIRST_DIGIT)) {
- member = YANG_AUTO_PREFIX + member;
+ String prefix = getPrefixForIdentifier(conflictResolver);
+ member = prefix + member;
}
pkg = pkg + member;
if (i != size - 1) {
@@ -216,20 +221,40 @@
}
/**
- * Returns package sub name from YANG identifier name.
+ * Prefix for adding with identifier and namespace, when it is a java keyword or starting with digits.
*
- * @param name YANG identifier name
- * @return java package sub name as per java rules
+ * @param conflictResolver object of YANG to java naming conflict util
+ * @return prefix which needs to be added
*/
- public static String getSubPkgFromName(String name) {
+ public static String getPrefixForIdentifier(YangToJavaNamingConflictUtil conflictResolver) {
- ArrayList<String> pkgArr = new ArrayList<String>();
- String[] nameArr = name.split(COLAN);
-
- for (String nameString : nameArr) {
- pkgArr.add(nameString);
+ String prefixForIdentifier = null;
+ if (conflictResolver != null) {
+ prefixForIdentifier = conflictResolver.getPrefixForIdentifier();
}
- return getPkgFrmArr(pkgArr);
+ if (prefixForIdentifier != null) {
+ prefixForIdentifier = prefixForIdentifier.replaceAll(REGEX_WITH_ALL_SPECIAL_CHAR, COLAN);
+ String[] strArray = prefixForIdentifier.split(COLAN);
+ try {
+ if (strArray[0].isEmpty()) {
+ List<String> stringArrangement = new ArrayList<String>();
+ for (int i = 1; i < strArray.length; i++) {
+ stringArrangement.add(strArray[i]);
+ }
+ strArray = stringArrangement.toArray(new String[stringArrangement.size()]);
+ }
+ prefixForIdentifier = strArray[0];
+ for (int j = 1; j < strArray.length; j++) {
+ prefixForIdentifier = prefixForIdentifier + strArray[j].substring(0, 1).toUpperCase() +
+ strArray[j].substring(1);
+ }
+ } catch (ArrayIndexOutOfBoundsException outOfBoundsException) {
+ throw new TranslatorException("The given prefix in pom.xml is invalid.");
+ }
+ } else {
+ prefixForIdentifier = YANG_AUTO_PREFIX;
+ }
+ return prefixForIdentifier;
}
/**
@@ -267,16 +292,18 @@
}
strArray = stringArrangement.toArray(new String[stringArrangement.size()]);
}
- return upperCaseConflictResolver(strArray);
+ return upperCaseConflictResolver(strArray, conflictResolver);
}
/**
- * Resolves the conflict when input has uppercase.
+ * Resolves the conflict when input has upper case.
*
- * @param stringArray containing strings for uppercase conflict resolver
+ * @param stringArray containing strings for upper case conflict resolver
+ * @param conflictResolver object of YANG to java naming conflict util
* @return camel cased string
*/
- private static String upperCaseConflictResolver(String[] stringArray) {
+ private static String upperCaseConflictResolver(String[] stringArray,
+ YangToJavaNamingConflictUtil conflictResolver) {
for (int l = 0; l < stringArray.length; l++) {
String[] upperCaseSplitArray = stringArray[l].split(REGEX_WITH_UPPERCASE);
@@ -317,7 +344,7 @@
}
}
stringArray = result.toArray(new String[result.size()]);
- return applyCamelCaseRule(stringArray);
+ return applyCamelCaseRule(stringArray, conflictResolver);
}
/**
@@ -325,9 +352,10 @@
* the letter next to a number in an array.
*
* @param stringArray containing strings for camel case separation
+ * @param conflictResolver object of YANG to java naming conflict util
* @return camel case rule checked string
*/
- private static String applyCamelCaseRule(String[] stringArray) {
+ private static String applyCamelCaseRule(String[] stringArray, YangToJavaNamingConflictUtil conflictResolver) {
String ruleChecker = stringArray[0].toLowerCase();
int i;
@@ -359,23 +387,25 @@
ruleChecker = ruleChecker + stringArray[i].substring(0, 1).toUpperCase() + stringArray[i].substring(1);
}
}
- String ruleCheckerWithPrefix = addPrefix(ruleChecker);
+ String ruleCheckerWithPrefix = addPrefix(ruleChecker, conflictResolver);
return restrictConsecutiveCapitalCase(ruleCheckerWithPrefix);
}
/**
- * Adds prefix YANG auto prefix if the string begins with digit or is a java key word.
+ * Adds prefix, if the string begins with digit or is a java key word.
*
* @param camelCasePrefix string for adding prefix
+ * @param conflictResolver object of YANG to java naming conflict util
* @return prefixed camel case string
*/
- private static String addPrefix(String camelCasePrefix) {
+ private static String addPrefix(String camelCasePrefix, YangToJavaNamingConflictUtil conflictResolver) {
+ String prefix = getPrefixForIdentifier(conflictResolver);
if (camelCasePrefix.matches(REGEX_FOR_FIRST_DIGIT)) {
- camelCasePrefix = YANG_AUTO_PREFIX + camelCasePrefix;
+ camelCasePrefix = prefix + camelCasePrefix;
}
- if (JAVA_KEY_WORDS.contains(camelCasePrefix.toLowerCase())) {
- camelCasePrefix = YANG_AUTO_PREFIX + camelCasePrefix.substring(0, 1).toUpperCase()
+ if (JAVA_KEY_WORDS.contains(camelCasePrefix)) {
+ camelCasePrefix = prefix + camelCasePrefix.substring(0, 1).toUpperCase()
+ camelCasePrefix.substring(1);
}
return camelCasePrefix;
@@ -444,13 +474,21 @@
*/
public static String getEnumJavaAttribute(String name) {
- String[] strArray = name.split(HYPHEN);
+ name = name.replaceAll(REGEX_WITH_ALL_SPECIAL_CHAR, COLAN);
+ String[] strArray = name.split(COLAN);
String output = EMPTY_STRING;
+ if (strArray[0].isEmpty()) {
+ List<String> stringArrangement = new ArrayList<String>();
+ for (int i = 1; i < strArray.length; i++) {
+ stringArrangement.add(strArray[i]);
+ }
+ strArray = stringArrangement.toArray(new String[stringArrangement.size()]);
+ }
for (int i = 0; i < strArray.length; i++) {
- output = output + strArray[i];
- if (i > 0 && i < strArray.length - 1) {
+ if (i > 0 && i < strArray.length) {
output = output + UNDER_SCORE;
}
+ output = output + strArray[i];
}
return output;
}
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/utils/YangToJavaNamingConflictUtil.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/utils/YangToJavaNamingConflictUtil.java
index bfb0d05..4f701b6 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/utils/YangToJavaNamingConflictUtil.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/utils/YangToJavaNamingConflictUtil.java
@@ -37,6 +37,11 @@
private static String replacementForHyphenInIdentifier;
/**
+ * Contains the prefix value for adding with the identifier.
+ */
+ private static String prefixForIdentifier;
+
+ /**
* Creates an object for YANG to java naming conflict util.
*/
public YangToJavaNamingConflictUtil() {
@@ -95,4 +100,22 @@
public String getReplacementForUnderscore() {
return replacementForUnderscoreInIdentifier;
}
+
+ /**
+ * Sets the prefix value for adding with the identifier.
+ *
+ * @param prefix prefix for identifier
+ */
+ public void setPrefixForIdentifier(String prefix) {
+ prefixForIdentifier = prefix;
+ }
+
+ /**
+ * Returns the prefix for identifier.
+ *
+ * @return prefix for identifier
+ */
+ public String getPrefixForIdentifier() {
+ return prefixForIdentifier;
+ }
}
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/utils/RestrictionResolver.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/utils/RestrictionResolver.java
index 6227126..41a8fef 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/utils/RestrictionResolver.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/utils/RestrictionResolver.java
@@ -99,11 +99,11 @@
}
if (rangeBoundary.length == MIN_RANGE_BOUNDARY) {
- startInterval = rangeBoundary[0];
- endInterval = rangeBoundary[0];
+ startInterval = rangeBoundary[0].trim();
+ endInterval = rangeBoundary[0].trim();
} else {
- startInterval = rangeBoundary[0];
- endInterval = rangeBoundary[1];
+ startInterval = rangeBoundary[0].trim();
+ endInterval = rangeBoundary[1].trim();
}
try {
@@ -186,11 +186,11 @@
}
if (rangeBoundary.length == MIN_RANGE_BOUNDARY) {
- startInterval = rangeBoundary[0];
- endInterval = rangeBoundary[0];
+ startInterval = rangeBoundary[0].trim();
+ endInterval = rangeBoundary[0].trim();
} else {
- startInterval = rangeBoundary[0];
- endInterval = rangeBoundary[1];
+ startInterval = rangeBoundary[0].trim();
+ endInterval = rangeBoundary[1].trim();
}
try {
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/utils/UtilConstants.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/utils/UtilConstants.java
index ca214c7..c96a6ef 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/utils/UtilConstants.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/utils/UtilConstants.java
@@ -767,6 +767,11 @@
public static final String REGEX_WITH_SINGLE_CAPITAL_CASE_AND_DIGITS_SMALL_CASES = "[A-Z][0-9a-z]+";
/**
+ * Static attribute for regex for any string ending with service.
+ */
+ public static final String REGEX_FOR_ANY_STRING_ENDING_WITH_SERVICE = ".+Service";
+
+ /**
* Static attribute for class syntax.
*/
public static final String CLASS = "class";
diff --git a/utils/yangutils/src/main/resources/GeneratedYang.g4 b/utils/yangutils/src/main/resources/GeneratedYang.g4
index c44a555..55a7a35 100644
--- a/utils/yangutils/src/main/resources/GeneratedYang.g4
+++ b/utils/yangutils/src/main/resources/GeneratedYang.g4
@@ -25,8 +25,8 @@
package org.onosproject.yangutils.parser.antlrgencode;
}
- yangfile : moduleStatement
- | subModuleStatement;
+ yangfile : moduleStatement EOF
+ | subModuleStatement EOF;
/**
* module-stmt = optsep module-keyword sep identifier-arg-str
diff --git a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/TreeWalkListenerTest.java b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/TreeWalkListenerTest.java
index cebd680..874f8ed 100644
--- a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/TreeWalkListenerTest.java
+++ b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/TreeWalkListenerTest.java
@@ -52,4 +52,34 @@
thrown.expectMessage("YANG file error : \"anyxml\" is not supported.");
manager.getDataModel("src/test/resources/AnyxmlStatement.yang");
}
+
+ /**
+ * Checks whether exception is thrown when extra brace is added in the EOF.
+ */
+ @Test
+ public void processFileWithExtraBrace() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("mismatched input '}' expecting <EOF>");
+ manager.getDataModel("src/test/resources/ProcessFileWithExtraBrace.yang");
+ }
+
+ /**
+ * Checks whether exception is thrown when leaf is given after module ends.
+ */
+ @Test
+ public void processFileWithExtraLeaf() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("mismatched input 'leaf' expecting <EOF>");
+ manager.getDataModel("src/test/resources/ProcessFileWithExtraLeaf.yang");
+ }
+
+ /**
+ * Checks whether exception is thrown when extra brace is added in between the EOF.
+ */
+ @Test
+ public void processFileWithExtraBraceInBetween() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("mismatched input 'container' expecting <EOF>");
+ manager.getDataModel("src/test/resources/ProcessFileWithExtraBraceInBetween.yang");
+ }
}
diff --git a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/LengthRestrictionListenerTest.java b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/LengthRestrictionListenerTest.java
index ae15d0c..3df9c13 100644
--- a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/LengthRestrictionListenerTest.java
+++ b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/LengthRestrictionListenerTest.java
@@ -267,4 +267,36 @@
assertThat(((YangUint64) rangeInterval.getStartValue()).getValue(), is(BigInteger.valueOf(0)));
assertThat(((YangUint64) rangeInterval.getEndValue()).getValue(), is(BigInteger.valueOf(100)));
}
+
+ /**
+ * Checks whether space can be allowed when length statement is present.
+ */
+ @Test
+ public void processLengthStatementWithSpace() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/LengthStatementWithSpace.yang");
+
+ assertThat((node instanceof YangModule), is(true));
+ assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+ 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("string"));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING));
+ YangStringRestriction stringRestriction = (YangStringRestriction) leafInfo
+ .getDataType().getDataTypeExtendedInfo();
+ 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)));
+ }
}
diff --git a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/RangeRestrictionListenerTest.java b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/RangeRestrictionListenerTest.java
index 88672fd..466bb97 100644
--- a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/RangeRestrictionListenerTest.java
+++ b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/RangeRestrictionListenerTest.java
@@ -207,4 +207,33 @@
assertThat(((YangInt32) rangeInterval.getEndValue()).getValue(), is(4));
assertThat(((YangInt32) rangeInterval.getEndValue()).getValue(), is(4));
}
+
+ /**
+ * Checks whether space can be allowed when range statement is present.
+ */
+ @Test
+ public void processRangeStatementWithSpace() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/RangeStatementWithSpace.yang");
+
+ assertThat((node instanceof YangModule), is(true));
+ assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+ 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("int32"));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.INT32));
+ YangRangeRestriction rangeRestriction = (YangRangeRestriction) leafInfo
+ .getDataType().getDataTypeExtendedInfo();
+
+ ListIterator<YangRangeInterval> rangeListIterator = rangeRestriction.getAscendingRangeIntervals()
+ .listIterator();
+ YangRangeInterval rangeInterval = rangeListIterator.next();
+ assertThat(((YangInt32) rangeInterval.getStartValue()).getValue(), is(1));
+ assertThat(((YangInt32) rangeInterval.getEndValue()).getValue(), is(4));
+ }
}
diff --git a/utils/yangutils/src/test/java/org/onosproject/yangutils/translator/tojava/utils/AttributesJavaDataTypeTest.java b/utils/yangutils/src/test/java/org/onosproject/yangutils/translator/tojava/utils/AttributesJavaDataTypeTest.java
index 11a2fa2..85aac96 100644
--- a/utils/yangutils/src/test/java/org/onosproject/yangutils/translator/tojava/utils/AttributesJavaDataTypeTest.java
+++ b/utils/yangutils/src/test/java/org/onosproject/yangutils/translator/tojava/utils/AttributesJavaDataTypeTest.java
@@ -59,6 +59,7 @@
private static final String CLASS_INFO5 = "Integer";
private static final String TYPE_DEF_PKG = "target.test";
private static String test = "";
+ private static YangToJavaNamingConflictUtil pluginConfig = null;
/**
* Unit test for private constructor.
@@ -88,7 +89,6 @@
*/
@Test
public void testgetJavaClassInfo() {
- YangToJavaNamingConflictUtil pluginConfig = null;
test = getJavaImportClass(getStubYangType(TYPE1), false, pluginConfig);
assertThat(true, is(test.equals(CLASS_INFO1)));
@@ -125,16 +125,16 @@
*/
@Test
public void testgetJavaPkgInfo() {
- test = getJavaImportPackage(getStubYangType(TYPE1), false, CLASS_INFO1);
+ test = getJavaImportPackage(getStubYangType(TYPE1), false, CLASS_INFO1, pluginConfig);
assertThat(true, is(test.equals(JAVA_LANG)));
- test = getJavaImportPackage(getStubYangType(TYPE2), true, CLASS_INFO5);
+ test = getJavaImportPackage(getStubYangType(TYPE2), true, CLASS_INFO5, pluginConfig);
assertThat(true, is(test.equals(JAVA_LANG)));
- test = getJavaImportPackage(getStubYangType(TYPE3), false, CLASS_INFO3);
+ test = getJavaImportPackage(getStubYangType(TYPE3), false, CLASS_INFO3, pluginConfig);
assertThat(null, is(test));
- test = getJavaImportPackage(getStubYangType(TYPE4), false, CLASS_INFO4);
+ test = getJavaImportPackage(getStubYangType(TYPE4), false, CLASS_INFO4, pluginConfig);
assertThat(null, is(test));
}
@@ -145,7 +145,7 @@
*/
@Test
public void testForTypeDef() throws DataModelException {
- test = getJavaImportPackage(getStubExtendedInfo(getStubYangType(TYPE_DEF)), false, TYPE_DEF_PKG);
+ test = getJavaImportPackage(getStubExtendedInfo(getStubYangType(TYPE_DEF)), false, TYPE_DEF_PKG, pluginConfig);
assertThat(true, is(test.equals(TYPE_DEF_PKG)));
}
diff --git a/utils/yangutils/src/test/java/org/onosproject/yangutils/translator/tojava/utils/JavaIdentifierSyntaxTest.java b/utils/yangutils/src/test/java/org/onosproject/yangutils/translator/tojava/utils/JavaIdentifierSyntaxTest.java
index a3b9200..6b86b9c 100644
--- a/utils/yangutils/src/test/java/org/onosproject/yangutils/translator/tojava/utils/JavaIdentifierSyntaxTest.java
+++ b/utils/yangutils/src/test/java/org/onosproject/yangutils/translator/tojava/utils/JavaIdentifierSyntaxTest.java
@@ -19,7 +19,10 @@
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.onosproject.yangutils.translator.exception.TranslatorException;
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsNot.not;
@@ -38,6 +41,9 @@
*/
public final class JavaIdentifierSyntaxTest {
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
private static final String PARENT_PACKAGE = "test5/test6/test7";
private static final String CHILD_PACKAGE = "test1:test2:test3";
private static final String DATE1 = "2000-1-5";
@@ -47,10 +53,17 @@
private static final String DATE_WITH_REV1 = "rev20000105";
private static final String DATE_WITH_REV2 = "rev19920125";
private static final String VERSION_NUMBER = "v1";
+ private static final String VALID_PREFIX = "123add-prefix";
+ private static final String INVALID_PREFIX = "-*()&^&#$%";
+ private static final String INVALID_PREFIX1 = "abc~!@#$%^&*()_+}{:<>?`1234567890-=[]''|,./SS";
+ private static final String INVALID_NAME_SPACE_FOR_INVALID_PREFIX = "try:#test3:9case3";
private static final String INVALID_NAME_SPACE1 = "byte:#test2:9test3";
private static final String INVALID_NAME_SPACE2 = "const:#test2://9test3";
- private static final String VALID_NAME_SPACE1 = "yangautoprefixbyte.test2.yangautoprefix9test3";
+ private static final String INVALID_NAME_SPACE3 = "CONST:TRY://9test3";
+ private static final String VALID_NAME_SPACE1 = "123addprefixbyte.test2.123addprefix9test3";
private static final String VALID_NAME_SPACE2 = "yangautoprefixconst.test2.yangautoprefix9test3";
+ private static final String VALID_NAME_SPACE3 = "abc1234567890ssconst.test2.abc1234567890ss9test3";
+ private static final String VALID_NAME_SPACE4 = "yangautoprefixconst.yangautoprefixtry.yangautoprefix9test3";
private static final String WITHOUT_CAMEL_CASE = "test-camel-case-identifier";
private static final String WITH_CAMEL_CASE = "testCamelCaseIdentifier";
private static final String WITHOUT_CAMEL_CASE1 = ".-_try-._-.123";
@@ -77,9 +90,16 @@
private static final String WITH_CAMEL_CASE11 = "test3Name";
private static final String WITHOUT_CAMEL_CASE12 = "TEST3name";
private static final String WITH_CAMEL_CASE12 = "test3Name";
+ private static final String WITHOUT_CAMEL_CASE13 = "t-RY";
+ private static final String WITH_CAMEL_CASE13 = "tRy";
+ private static final String WITHOUT_CAMEL_CASE14 = "TRY";
+ private static final String WITH_CAMEL_CASE14 = "yangAutoPrefixTry";
private static final String WITHOUT_CAPITAL = "test_this";
private static final String WITH_CAPITAL = "Test_this";
private static final String WITH_SMALL = "test_this";
+ private static final String WITH_CAMEL_CASE_WITH_PREFIX = "123addPrefixTry";
+ private static final String WITH_CAMEL_CASE_WITH_PREFIX1 = "abc1234567890Ss1123G123Gaa";
+ private static YangToJavaNamingConflictUtil conflictResolver = new YangToJavaNamingConflictUtil();
/**
* Unit test for private constructor.
@@ -111,22 +131,44 @@
*/
@Test
public void getRootPackageTest() {
- String rootPackage = getRootPackage((byte) 1, CHILD_PACKAGE, DATE1);
+ conflictResolver.setPrefixForIdentifier(null);
+ String rootPackage = getRootPackage((byte) 1, CHILD_PACKAGE, DATE1, conflictResolver);
assertThat(rootPackage.equals(DEFAULT_BASE_PKG + PERIOD + VERSION_NUMBER
+ PERIOD + CHILD_WITH_PERIOD + PERIOD + DATE_WITH_REV1), is(true));
}
/**
+ * Unit test for root package generation with invalid prefix.
+ */
+ @Test
+ public void getRootPackageWithInvalidPrefix() throws TranslatorException {
+ thrown.expect(TranslatorException.class);
+ thrown.expectMessage("The given prefix in pom.xml is invalid.");
+ conflictResolver.setPrefixForIdentifier(INVALID_PREFIX);
+ String rootPackage1 = getRootPackage((byte) 1, INVALID_NAME_SPACE_FOR_INVALID_PREFIX, DATE1, conflictResolver);
+ }
+
+ /**
* Unit test for root package generation with special characters presence.
*/
@Test
public void getRootPackageWithSpecialCharactersTest() {
- String rootPackage = getRootPackage((byte) 1, INVALID_NAME_SPACE1, DATE1);
+ conflictResolver.setPrefixForIdentifier(VALID_PREFIX);
+ String rootPackage = getRootPackage((byte) 1, INVALID_NAME_SPACE1, DATE1, conflictResolver);
assertThat(rootPackage.equals(DEFAULT_BASE_PKG + PERIOD + VERSION_NUMBER
+ PERIOD + VALID_NAME_SPACE1 + PERIOD + DATE_WITH_REV1), is(true));
- String rootPackage1 = getRootPackage((byte) 1, INVALID_NAME_SPACE2, DATE1);
+ conflictResolver.setPrefixForIdentifier(null);
+ String rootPackage1 = getRootPackage((byte) 1, INVALID_NAME_SPACE2, DATE1, conflictResolver);
assertThat(rootPackage1.equals(DEFAULT_BASE_PKG + PERIOD + VERSION_NUMBER
+ PERIOD + VALID_NAME_SPACE2 + PERIOD + DATE_WITH_REV1), is(true));
+ String rootPackage2 = getRootPackage((byte) 1, INVALID_NAME_SPACE3, DATE1, conflictResolver);
+ assertThat(rootPackage2.equals(DEFAULT_BASE_PKG + PERIOD + VERSION_NUMBER
+ + PERIOD + VALID_NAME_SPACE4 + PERIOD + DATE_WITH_REV1), is(true));
+ conflictResolver.setPrefixForIdentifier(INVALID_PREFIX1);
+ String rootPackage3 = getRootPackage((byte) 1, INVALID_NAME_SPACE2, DATE1, conflictResolver);
+ assertThat(rootPackage3.equals(DEFAULT_BASE_PKG + PERIOD + VERSION_NUMBER
+ + PERIOD + VALID_NAME_SPACE3 + PERIOD + DATE_WITH_REV1), is(true));
+
}
/**
@@ -134,7 +176,7 @@
*/
@Test
public void getRootPackageWithRevTest() {
- String rootPkgWithRev = getRootPackage((byte) 1, CHILD_PACKAGE, DATE2);
+ String rootPkgWithRev = getRootPackage((byte) 1, CHILD_PACKAGE, DATE2, null);
assertThat(rootPkgWithRev.equals(
DEFAULT_BASE_PKG + PERIOD + VERSION_NUMBER + PERIOD + CHILD_WITH_PERIOD + PERIOD + DATE_WITH_REV2),
is(true));
@@ -154,32 +196,63 @@
*/
@Test
public void getCamelCaseTest() {
- String camelCase = getCamelCase(WITHOUT_CAMEL_CASE, null);
+ conflictResolver.setPrefixForIdentifier(null);
+ String camelCase = getCamelCase(WITHOUT_CAMEL_CASE, conflictResolver);
assertThat(camelCase.equals(WITH_CAMEL_CASE), is(true));
- String camelCase1 = getCamelCase(WITHOUT_CAMEL_CASE1, null);
+ String camelCase1 = getCamelCase(WITHOUT_CAMEL_CASE1, conflictResolver);
assertThat(camelCase1.equals(WITH_CAMEL_CASE1), is(true));
- String camelCase2 = getCamelCase(WITHOUT_CAMEL_CASE2, null);
+ String camelCase2 = getCamelCase(WITHOUT_CAMEL_CASE2, conflictResolver);
assertThat(camelCase2.equals(WITH_CAMEL_CASE2), is(true));
- String camelCase3 = getCamelCase(WITHOUT_CAMEL_CASE3, null);
+ String camelCase3 = getCamelCase(WITHOUT_CAMEL_CASE3, conflictResolver);
assertThat(camelCase3.equals(WITH_CAMEL_CASE3), is(true));
- String camelCase4 = getCamelCase(WITHOUT_CAMEL_CASE4, null);
+ String camelCase4 = getCamelCase(WITHOUT_CAMEL_CASE4, conflictResolver);
assertThat(camelCase4.equals(WITH_CAMEL_CASE4), is(true));
- String camelCase5 = getCamelCase(WITHOUT_CAMEL_CASE5, null);
+ String camelCase5 = getCamelCase(WITHOUT_CAMEL_CASE5, conflictResolver);
assertThat(camelCase5.equals(WITH_CAMEL_CASE5), is(true));
- String camelCase6 = getCamelCase(WITHOUT_CAMEL_CASE6, null);
+ String camelCase6 = getCamelCase(WITHOUT_CAMEL_CASE6, conflictResolver);
assertThat(camelCase6.equals(WITH_CAMEL_CASE6), is(true));
- String camelCase7 = getCamelCase(WITHOUT_CAMEL_CASE7, null);
+ String camelCase7 = getCamelCase(WITHOUT_CAMEL_CASE7, conflictResolver);
assertThat(camelCase7.equals(WITH_CAMEL_CASE7), is(true));
- String camelCase8 = getCamelCase(WITHOUT_CAMEL_CASE8, null);
+ String camelCase8 = getCamelCase(WITHOUT_CAMEL_CASE8, conflictResolver);
assertThat(camelCase8.equals(WITH_CAMEL_CASE8), is(true));
- String camelCase9 = getCamelCase(WITHOUT_CAMEL_CASE9, null);
+ String camelCase9 = getCamelCase(WITHOUT_CAMEL_CASE9, conflictResolver);
assertThat(camelCase9.equals(WITH_CAMEL_CASE9), is(true));
- String camelCase10 = getCamelCase(WITHOUT_CAMEL_CASE10, null);
+ String camelCase10 = getCamelCase(WITHOUT_CAMEL_CASE10, conflictResolver);
assertThat(camelCase10.equals(WITH_CAMEL_CASE10), is(true));
- String camelCase11 = getCamelCase(WITHOUT_CAMEL_CASE11, null);
+ String camelCase11 = getCamelCase(WITHOUT_CAMEL_CASE11, conflictResolver);
assertThat(camelCase11.equals(WITH_CAMEL_CASE11), is(true));
- String camelCase12 = getCamelCase(WITHOUT_CAMEL_CASE12, null);
+ String camelCase12 = getCamelCase(WITHOUT_CAMEL_CASE12, conflictResolver);
assertThat(camelCase12.equals(WITH_CAMEL_CASE12), is(true));
+ String camelCase13 = getCamelCase(WITHOUT_CAMEL_CASE13, conflictResolver);
+ assertThat(camelCase13.equals(WITH_CAMEL_CASE13), is(true));
+ String camelCase14 = getCamelCase(WITHOUT_CAMEL_CASE14, conflictResolver);
+ assertThat(camelCase14.equals(WITH_CAMEL_CASE14), is(true));
+ }
+
+ /**
+ * Unit test for getting the camel case along with the prefix provided.
+ */
+ @Test
+ public void getCamelCaseWithPrefixTest() {
+
+ conflictResolver.setPrefixForIdentifier(VALID_PREFIX);
+ String camelCase = getCamelCase(WITHOUT_CAMEL_CASE2, conflictResolver);
+ assertThat(camelCase.equals(WITH_CAMEL_CASE_WITH_PREFIX), is(true));
+ conflictResolver.setPrefixForIdentifier(INVALID_PREFIX1);
+ String camelCase2 = getCamelCase(WITHOUT_CAMEL_CASE3, conflictResolver);
+ assertThat(camelCase2.equals(WITH_CAMEL_CASE_WITH_PREFIX1), is(true));
+ }
+
+ /**
+ * Unit test for getting the camel case along with the invalid prefix provided.
+ */
+ @Test
+ public void getCamelCaseWithInvalidPrefixTest() throws TranslatorException {
+
+ thrown.expect(TranslatorException.class);
+ thrown.expectMessage("The given prefix in pom.xml is invalid.");
+ conflictResolver.setPrefixForIdentifier(INVALID_PREFIX);
+ String camelCase = getCamelCase(WITHOUT_CAMEL_CASE3, conflictResolver);
}
/**
diff --git a/utils/yangutils/src/test/resources/LengthStatementWithSpace.yang b/utils/yangutils/src/test/resources/LengthStatementWithSpace.yang
new file mode 100644
index 0000000..e8612d1
--- /dev/null
+++ b/utils/yangutils/src/test/resources/LengthStatementWithSpace.yang
@@ -0,0 +1,10 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type string {
+ length " 0 .. 100 ";
+ }
+ }
+}
diff --git a/utils/yangutils/src/test/resources/PositionImplicitAndExplicit.yang b/utils/yangutils/src/test/resources/PositionImplicitAndExplicit.yang
index 5be4cbb..bef9712 100644
--- a/utils/yangutils/src/test/resources/PositionImplicitAndExplicit.yang
+++ b/utils/yangutils/src/test/resources/PositionImplicitAndExplicit.yang
@@ -2,14 +2,14 @@
yang-version 1;
namespace http://huawei.com;
prefix Ant;
- leaf mybits {
- type bits {
- bit disable-nagle;
- bit auto-sense-speed {
- position 1;
- }
- bit Ten-Mb-only;
- }
- }
+ leaf mybits {
+ type bits {
+ bit disable-nagle;
+ bit auto-sense-speed {
+ position 1;
+ }
+ bit Ten-Mb-only;
+ }
}
}
+
diff --git a/utils/yangutils/src/test/resources/PositionStatement.yang b/utils/yangutils/src/test/resources/PositionStatement.yang
index 76c204d..afa0a4c 100644
--- a/utils/yangutils/src/test/resources/PositionStatement.yang
+++ b/utils/yangutils/src/test/resources/PositionStatement.yang
@@ -2,17 +2,17 @@
yang-version 1;
namespace http://huawei.com;
prefix Ant;
- leaf mybits {
- type bits {
- bit disable-nagle {
- position 0;
- }
- bit auto-sense-speed {
- position 1;
- }
- bit Ten-Mb-only {
- position 2;
- }
- }
+ leaf mybits {
+ type bits {
+ bit disable-nagle {
+ position 0;
+ }
+ bit auto-sense-speed {
+ position 1;
+ }
+ bit Ten-Mb-only {
+ position 2;
+ }
+ }
}
}
diff --git a/utils/yangutils/src/test/resources/ProcessFileWithExtraBrace.yang b/utils/yangutils/src/test/resources/ProcessFileWithExtraBrace.yang
new file mode 100644
index 0000000..ca3f0d0
--- /dev/null
+++ b/utils/yangutils/src/test/resources/ProcessFileWithExtraBrace.yang
@@ -0,0 +1,15 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ container food {
+ choice snack {
+ list sports-arena {
+ }
+ }
+ }
+ }
+}
+}
+}
+}
diff --git a/utils/yangutils/src/test/resources/ProcessFileWithExtraBraceInBetween.yang b/utils/yangutils/src/test/resources/ProcessFileWithExtraBraceInBetween.yang
new file mode 100644
index 0000000..580d270
--- /dev/null
+++ b/utils/yangutils/src/test/resources/ProcessFileWithExtraBraceInBetween.yang
@@ -0,0 +1,35 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ import ietf-yang-types {
+ prefix "P";
+ }
+ grouping Percentage {
+ leaf hello{
+ type string;
+ }
+ leaf invalid1{
+ type string;
+ }
+ }
+ leaf invalid2{
+ 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/utils/yangutils/src/test/resources/ProcessFileWithExtraLeaf.yang b/utils/yangutils/src/test/resources/ProcessFileWithExtraLeaf.yang
new file mode 100644
index 0000000..5624b7a
--- /dev/null
+++ b/utils/yangutils/src/test/resources/ProcessFileWithExtraLeaf.yang
@@ -0,0 +1,13 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ container food {
+ choice snack {
+ list sports-arena {
+ }
+ }
+ }
+}
+leaf invalid {
+
diff --git a/utils/yangutils/src/test/resources/RangeStatementWithSpace.yang b/utils/yangutils/src/test/resources/RangeStatementWithSpace.yang
new file mode 100644
index 0000000..a41d68a
--- /dev/null
+++ b/utils/yangutils/src/test/resources/RangeStatementWithSpace.yang
@@ -0,0 +1,11 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type int32 {
+ range " 1 .. 4 | 10 .. 20 ";
+ }
+ }
+}
+
diff --git a/utils/yangutils/src/test/resources/ShortCaseListenerWithContainer.yang b/utils/yangutils/src/test/resources/ShortCaseListenerWithContainer.yang
index 166eeb0..3322a66 100644
--- a/utils/yangutils/src/test/resources/ShortCaseListenerWithContainer.yang
+++ b/utils/yangutils/src/test/resources/ShortCaseListenerWithContainer.yang
@@ -2,12 +2,11 @@
yang-version 1;
namespace http://huawei.com;
prefix Ant;
- container food {
- choice snack {
- container sports-arena {
- leaf pretzel {
- type empty;
- }
+ container food {
+ choice snack {
+ container sports-arena {
+ leaf pretzel {
+ type empty;
}
}
}
diff --git a/utils/yangutils/src/test/resources/ShortCaseListenerWithList.yang b/utils/yangutils/src/test/resources/ShortCaseListenerWithList.yang
index eb03fca..6eeec79 100644
--- a/utils/yangutils/src/test/resources/ShortCaseListenerWithList.yang
+++ b/utils/yangutils/src/test/resources/ShortCaseListenerWithList.yang
@@ -2,15 +2,15 @@
yang-version 1;
namespace http://huawei.com;
prefix Ant;
- container food {
- choice snack {
- list sports-arena {
- key "pretzel";
- leaf pretzel {
- type int32;
- }
+ container food {
+ choice snack {
+ list sports-arena {
+ key "pretzel";
+ leaf pretzel {
+ type int32;
}
}
}
}
}
+