aboutsummaryrefslogtreecommitdiffstats
path: root/UniversalVesAdapter/src/main/java
diff options
context:
space:
mode:
authorPooja03 <PM00501616@techmahindra.com>2018-03-28 18:28:37 +0530
committerPooja03 <PM00501616@techmahindra.com>2018-03-28 18:28:37 +0530
commit00a00a68862effd791ce3f127d0ddd5903598b89 (patch)
tree7249b6f39b17990a2a9c26d6499a9a65ccce8f76 /UniversalVesAdapter/src/main/java
parent8297bd0760ff3c46ef36d5a6408a757cf36097fe (diff)
Added UniversalVesAdapter TestCases in the Mapper
Adding remaining UniversalVesAdapter TestCases in Mapper Change-Id: Ic49bbbe2b4c4e242b1e91edfe565c7918e4b24e5 Issue-ID: DCAEGEN2-335 Signed-off-by: Pooja03 <PM00501616@techmahindra.com>
Diffstat (limited to 'UniversalVesAdapter/src/main/java')
-rw-r--r--UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/utils/MapperConfigUtils.java36
1 files changed, 30 insertions, 6 deletions
diff --git a/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/utils/MapperConfigUtils.java b/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/utils/MapperConfigUtils.java
index e94cdf5..4e67ed6 100644
--- a/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/utils/MapperConfigUtils.java
+++ b/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/utils/MapperConfigUtils.java
@@ -237,7 +237,7 @@ public class MapperConfigUtils {
}
if (null != evaluation.getOperand()) {
- if (EnumUtils.isValidEnum(JoinOperator.class, evaluation.getOperand())) {
+ if (MapperConfigUtils.isValidEnum(JoinOperator.class, evaluation.getOperand())) {
// if(JOIN_OPERATOR.contains(evaluation.getOperand())){
switch (JoinOperator.valueOf(evaluation.getOperand())) {
case AND:
@@ -251,7 +251,7 @@ public class MapperConfigUtils {
}
}
- if (EnumUtils.isValidEnum(ExpressionOperator.class, evaluation.getOperand())) {
+ if (MapperConfigUtils.isValidEnum(ExpressionOperator.class, evaluation.getOperand())) {
// if(EXPR_OPERATOR.contains(evaluation.getOperand())){
// currently it is assumed field being compared is first level
@@ -261,7 +261,7 @@ public class MapperConfigUtils {
if (null != field && null != evaluation.getDatatype() && actualObj.has(field)) {
switch (ExpressionOperator.valueOf(evaluation.getOperand())) {
case EQUALS:
- if (EnumUtils.isValidEnum(DataType.class, evaluation.getDatatype())) {
+ if (MapperConfigUtils.isValidEnum(DataType.class, evaluation.getDatatype())) {
switch (DataType.valueOf(evaluation.getDatatype())) {
case STRING:
if (null != actualObj.get(field))
@@ -276,7 +276,7 @@ public class MapperConfigUtils {
} else
return false;
case STARTSWITH:
- if (EnumUtils.isValidEnum(DataType.class, evaluation.getDatatype())) {
+ if (MapperConfigUtils.isValidEnum(DataType.class, evaluation.getDatatype())) {
switch (DataType.valueOf(evaluation.getDatatype())) {
case STRING:
if (null != actualObj.get(field))
@@ -287,7 +287,7 @@ public class MapperConfigUtils {
} else
return false;
case ENDSWITH:
- if (EnumUtils.isValidEnum(DataType.class, evaluation.getDatatype())) {
+ if (MapperConfigUtils.isValidEnum(DataType.class, evaluation.getDatatype())) {
switch (DataType.valueOf(evaluation.getDatatype())) {
case STRING:
if (null != actualObj.get(field))
@@ -298,7 +298,7 @@ public class MapperConfigUtils {
} else
return false;
case CONTAINS:
- if (EnumUtils.isValidEnum(DataType.class, evaluation.getDatatype())) {
+ if (MapperConfigUtils.isValidEnum(DataType.class, evaluation.getDatatype())) {
switch (DataType.valueOf(evaluation.getDatatype())) {
case STRING:
if (null != actualObj.get(field))
@@ -318,5 +318,29 @@ public class MapperConfigUtils {
return false;
}
+ /**
+ * <p>Checks if the specified name is a valid enum for the class.</p>
+ *
+ * <p>This method differs from {@link Enum#valueOf} in that checks if the name is
+ * a valid enum without needing to catch the exception.</p>
+ *
+ * @param <E> the type of the enumeration
+ * @param enumClass the class of the enum to query, not null
+ * @param enumName the enum name, null returns false
+ * @return true if the enum name is valid, otherwise false
+ */
+
+ public static <E extends Enum<E>> boolean isValidEnum(final Class<E> enumClass, final String enumName) {
+ if (enumName == null) {
+ return false;
+ }
+ try {
+ Enum.valueOf(enumClass, enumName);
+ return true;
+ } catch (final IllegalArgumentException ex) {
+ return false;
+ }
+ }
+
}