summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java27
-rw-r--r--sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelperTest.java7
2 files changed, 19 insertions, 15 deletions
diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java
index e8f73e8c..f87b7d3c 100644
--- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java
+++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java
@@ -50,11 +50,6 @@ public class MdsalHelper {
private static final Logger LOG = LoggerFactory.getLogger(MdsalHelper.class);
private static Properties yangMappingProperties = new Properties();
- protected static boolean useLegacyEnumerationMapping = false;
-
- public static void useLegacyEnumerationMapping(Boolean bool) {
- useLegacyEnumerationMapping = bool;
- }
@Deprecated
public static void setProperties(Properties input) {
@@ -88,25 +83,37 @@ public class MdsalHelper {
}
public static Properties toProperties(Properties props, Object fromObj) {
+ return toProperties(props, fromObj, false);
+ }
+
+ public static Properties toProperties(Properties props, Object fromObj, Boolean useLegacyEnumerationMapping) {
Class fromClass = null;
if (fromObj != null) {
fromClass = fromObj.getClass();
}
- return toProperties(props, "", fromObj, fromClass);
+ return toProperties(props, "", fromObj, fromClass,useLegacyEnumerationMapping );
}
public static Properties toProperties(Properties props, String pfx, Object fromObj) {
+ return toProperties(props, pfx, fromObj, false);
+ }
+
+ public static Properties toProperties(Properties props, String pfx, Object fromObj, Boolean useLegacyEnumerationMapping) {
Class fromClass = null;
if (fromObj != null) {
fromClass = fromObj.getClass();
}
- return toProperties(props, pfx, fromObj, fromClass);
+ return toProperties(props, pfx, fromObj, fromClass, useLegacyEnumerationMapping);
}
public static Properties toProperties(Properties props, String pfx, Object fromObj, Class fromClass) {
+ return toProperties(props, pfx, fromObj, fromClass, false);
+ }
+
+ public static Properties toProperties(Properties props, String pfx, Object fromObj, Class fromClass, Boolean useLegacyEnumerationMapping) {
if (fromObj == null) {
return props;
@@ -121,7 +128,7 @@ public class MdsalHelper {
List fromList = (List) fromObj;
for (int i = 0; i < fromList.size(); i++) {
- toProperties(props, pfx + "[" + i + "]", fromList.get(i), fromClass);
+ toProperties(props, pfx + "[" + i + "]", fromList.get(i), fromClass, useLegacyEnumerationMapping);
}
props.setProperty(pfx + "_length", Integer.toString(fromList.size()));
@@ -365,7 +372,7 @@ public class MdsalHelper {
m.setAccessible(isAccessible);
}
if (retValue != null) {
- toProperties(props, propNamePfx + "." + fieldName, retValue, returnType);
+ toProperties(props, propNamePfx + "." + fieldName, retValue, returnType, useLegacyEnumerationMapping);
}
} catch (Exception e) {
@@ -398,7 +405,7 @@ public class MdsalHelper {
// this array.
Type paramType = m.getGenericReturnType();
Type elementType = ((ParameterizedType) paramType).getActualTypeArguments()[0];
- toProperties(props, propNamePfx + "." + fieldName, retList, (Class) elementType);
+ toProperties(props, propNamePfx + "." + fieldName, retList, (Class) elementType, useLegacyEnumerationMapping);
} catch (Exception e) {
LOG.error("Caught exception trying to convert List returned by " + fromClass.getName() + "."
+ m.getName() + "() to Properties entry", e);
diff --git a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelperTest.java b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelperTest.java
index d5ca04d7..307c69c7 100644
--- a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelperTest.java
+++ b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelperTest.java
@@ -147,7 +147,6 @@ public class MdsalHelperTest extends TestCase {
// During the default enumeration mapping no properties file is needed, the yang value is returned
// by the java object
public void testDefaultEnumerationMapping() throws Exception {
- MdsalHelper.useLegacyEnumerationMapping(false);
Properties props = new Properties();
MdsalHelper.toProperties(props, new WrapperObj());
assertEquals("4COS", props.getProperty("wrapper-obj.cos-model-type"));
@@ -156,9 +155,8 @@ public class MdsalHelperTest extends TestCase {
// When no properties file exists the default java value will be returned if legacy enumeration
// mapping is enabled
public void testLegacyEnumerationMappingNoProperties() throws Exception {
- MdsalHelper.useLegacyEnumerationMapping(true);
Properties props = new Properties();
- MdsalHelper.toProperties(props, new WrapperObj());
+ MdsalHelper.toProperties(props, new WrapperObj(), true);
assertEquals("_4COS", props.getProperty("wrapper-obj.cos-model-type"));
}
@@ -166,9 +164,8 @@ public class MdsalHelperTest extends TestCase {
// properties file should be returned
public void testLegacyEnumerationMappingWithProperties() throws Exception {
MdsalHelper.loadProperties("src/test/resources/EnumerationMapping.properties");
- MdsalHelper.useLegacyEnumerationMapping(true);
Properties props = new Properties();
- MdsalHelper.toProperties(props, new WrapperObj());
+ MdsalHelper.toProperties(props, new WrapperObj(), true);
assertEquals("HelloWorld", props.getProperty("wrapper-obj.cos-model-type"));
}
}