summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSmokowski, Kevin (ks6305) <kevin.smokowski@att.com>2019-06-25 16:40:05 +0000
committerSmokowski, Kevin (ks6305) <kevin.smokowski@att.com>2019-06-25 16:40:05 +0000
commitbcddb35fdcd176e210c95ef8b22d5b0321f1e658 (patch)
tree358bc8a34fb657c0381805d60b91ff9493f11cd7
parent2f7123a54f1528b20a19d57bae146e01c0499a58 (diff)
support yang enumerations with underscores
underscores should be stripeed before Enum.valueOf is called Change-Id: Ie69e16dbf515b9fc8375bb9be2597198ccbd3c65 Issue-ID: CCSDK-1434 Signed-off-by: Smokowski, Kevin (ks6305) <kevin.smokowski@att.com>
-rwxr-xr-xsli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java3
-rwxr-xr-xsli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelperTest.java1
2 files changed, 4 insertions, 0 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 0300236f7..730f272ba 100755
--- 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
@@ -1255,6 +1255,9 @@ public class MdsalHelper {
return (inStr);
}
+ // This is needed for enums containing under scores
+ inStr = inStr.replaceAll("_", "");
+
// This will strip out all periods, which cannot be in a java enum
inStr = inStr.replaceAll("\\.", "");
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 744d48d70..cebb99663 100755
--- 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
@@ -151,6 +151,7 @@ public class MdsalHelperTest extends TestCase {
}
public void testToJavaEnum() throws Exception {
+ assertEquals("VENDOR6500MODEL", MdsalHelper.toJavaEnum("VENDOR_6500_MODEL"));
assertEquals("_2018HelloWorld", MdsalHelper.toJavaEnum("2018Hello World"));
assertEquals("SomethingElse", MdsalHelper.toJavaEnum("Something.Else"));
assertEquals("MyTestString", MdsalHelper.toJavaEnum("my-test-string"));