Skip to content

Commit adefb22

Browse files
author
nareshwart
committed
test fix
1 parent ef979f8 commit adefb22

4 files changed

Lines changed: 78 additions & 50 deletions

File tree

src/main/java/com/devopsdemo/helper/GenericResourceBundle.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,9 @@ public static String getProperties(String source) {
1111
.map(rb::getString)
1212
.orElse("");
1313
}
14+
15+
public static ResourceBundle getBundle(String baseName, java.util.Locale locale) {
16+
return ResourceBundle.getBundle(baseName, locale);
17+
}
1418
}
1519

src/main/java/com/devopsdemo/utilities/HexAsciiConvertor.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@ public static String convertHexToASCII(String hexValue) {
2424
}
2525
return outputAscii.toString();
2626
}
27+
28+
/**
29+
* Alias for convertHexToASCII to match test usage.
30+
*/
31+
public static String hexToAscii(String hexValue) {
32+
return convertHexToASCII(hexValue);
33+
}
2734

2835
/**
2936
* Converts ASCII values into hexadecimal.

src/main/java/com/devopsdemo/utilities/PrepareTargetMethod.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,11 @@ public class PrepareTargetMethod {
1313
public String prepareTargetMethod(String name) {
1414
return METHOD_GET_PREFIX + name.substring(0, 1).toUpperCase() + name.substring(1);
1515
}
16+
17+
/**
18+
* Static version for test compatibility.
19+
*/
20+
public static String prepareTarget(String name) {
21+
return METHOD_GET_PREFIX + name.substring(0, 1).toUpperCase() + name.substring(1);
22+
}
1623
}

src/main/java/com/devopsdemo/utilities/StringUtilities.java

Lines changed: 60 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -18,28 +18,38 @@
1818
*/
1919
public class StringUtilities {
2020

21-
private static final String COMMA_SEPARATOR = ",";
22-
private static final String PARAM_SEPARATOR = "=";
23-
private static final String TYPE_SEPARATOR = ";";
24-
private static final String DATEFORMAT_SEPARATOR = "@";
25-
private static final String CONVERTOR_METHOD_NAME = "valueOf";
26-
private static final String DATE_TYPE = "date";
27-
private static final String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss";
28-
private static final String STRING_TYPE = "string";
29-
30-
private static final Logger LOG = LoggerFactory.getLogger(StringUtilities.class);
31-
32-
private static final HashMap<String, Class<?>> PRIMITIVE_NAME_TYPE_MAP = new HashMap<>();
33-
34-
static {
35-
PRIMITIVE_NAME_TYPE_MAP.put("boolean", Boolean.class);
36-
PRIMITIVE_NAME_TYPE_MAP.put("int", Integer.class);
37-
PRIMITIVE_NAME_TYPE_MAP.put("long", Long.class);
38-
PRIMITIVE_NAME_TYPE_MAP.put("float", Float.class);
39-
PRIMITIVE_NAME_TYPE_MAP.put("double", Double.class);
40-
}
41-
42-
/**
21+
private static final String COMMA_SEPARATOR = ",";
22+
private static final String PARAM_SEPARATOR = "=";
23+
private static final String TYPE_SEPARATOR = ";";
24+
private static final String DATEFORMAT_SEPARATOR = "@";
25+
private static final String CONVERTOR_METHOD_NAME = "valueOf";
26+
private static final String DATE_TYPE = "date";
27+
private static final String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss";
28+
private static final String STRING_TYPE = "string";
29+
30+
private static final Logger LOG = LoggerFactory.getLogger(StringUtilities.class);
31+
32+
private static final HashMap<String, Class<?>> PRIMITIVE_NAME_TYPE_MAP = new HashMap<>();
33+
34+
static {
35+
PRIMITIVE_NAME_TYPE_MAP.put("boolean", Boolean.class);
36+
PRIMITIVE_NAME_TYPE_MAP.put("int", Integer.class);
37+
PRIMITIVE_NAME_TYPE_MAP.put("long", Long.class);
38+
PRIMITIVE_NAME_TYPE_MAP.put("float", Float.class);
39+
PRIMITIVE_NAME_TYPE_MAP.put("double", Double.class);
40+
}
41+
42+
/**
43+
* Reverses the given string.
44+
* @param input the string to reverse
45+
* @return the reversed string
46+
*/
47+
public static String reverseString(String input) {
48+
if (input == null) return null;
49+
return new StringBuilder(input).reverse().toString();
50+
}
51+
52+
/**
4353
* given a comma separated string and type, returns an ArrayList of specific types
4454
* @param strParamValueList The string (assumed to be comma separated). Usually meant for use in creating
4555
* parameter values for passing in IN Clauses
@@ -48,15 +58,15 @@ public class StringUtilities {
4858
*/
4959
public static List<Object> convertStringToList(String strParamValueList,String type){
5060
if (strParamValueList == null || strParamValueList.isBlank()) {
51-
return null;
52-
}
53-
54-
var list = new ArrayList<Object>();
55-
var arr = strParamValueList.trim().split(COMMA_SEPARATOR);
56-
for (var tmpString : arr) {
57-
list.add(convert(tmpString, type));
58-
}
59-
return list;
61+
return null;
62+
}
63+
64+
var list = new ArrayList<Object>();
65+
var arr = strParamValueList.trim().split(COMMA_SEPARATOR);
66+
for (var tmpString : arr) {
67+
list.add(convert(tmpString, type));
68+
}
69+
return list;
6070
}
6171

6272
/**
@@ -69,23 +79,23 @@ public static List<Object> convertStringToList(String strParamValueList,String t
6979
*/
7080
public static HashMap<String, Object> createParameterList(String... strParamValueList){
7181
var hMap = new HashMap<String, Object>();
72-
for (var strArg : strParamValueList) {
73-
String type = null;
74-
if (strArg.contains(TYPE_SEPARATOR)) {
75-
var parts = strArg.split(TYPE_SEPARATOR);
76-
type = parts[1];
77-
strArg = parts[0];
78-
}
79-
if (strArg.contains(PARAM_SEPARATOR)) {
80-
var arr = strArg.split(PARAM_SEPARATOR);
81-
if (arr[1].contains(COMMA_SEPARATOR)) {
82-
hMap.put(arr[0], convertStringToList(arr[1], type));
83-
} else {
84-
hMap.put(arr[0], convert(arr[1], type));
85-
}
86-
}
87-
}
88-
return hMap;
82+
for (var strArg : strParamValueList) {
83+
String type = null;
84+
if (strArg.contains(TYPE_SEPARATOR)) {
85+
var parts = strArg.split(TYPE_SEPARATOR);
86+
type = parts[1];
87+
strArg = parts[0];
88+
}
89+
if (strArg.contains(PARAM_SEPARATOR)) {
90+
var arr = strArg.split(PARAM_SEPARATOR);
91+
if (arr[1].contains(COMMA_SEPARATOR)) {
92+
hMap.put(arr[0], convertStringToList(arr[1], type));
93+
} else {
94+
hMap.put(arr[0], convert(arr[1], type));
95+
}
96+
}
97+
}
98+
return hMap;
8999
}
90100

91101
/**
@@ -97,8 +107,8 @@ public static HashMap<String, Object> createParameterList(String... strParamValu
97107
private static Object convert(String value, String types) {
98108

99109
if (value == null || value.isBlank() || types == null || types.isBlank() || types.equalsIgnoreCase(STRING_TYPE)) {
100-
return value;
101-
}
110+
return value;
111+
}
102112

103113
var type = types.toLowerCase();
104114
if (type.equals(DATE_TYPE)) {

0 commit comments

Comments
 (0)