Skip to content

Commit

Permalink
#340 Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
jemacineiras committed Sep 20, 2023
1 parent 50ae8d3 commit 1e1d5be
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 22 deletions.
40 changes: 19 additions & 21 deletions src/main/java/com/sngular/kloadgen/model/FieldValueMapping.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,10 @@ public final List<String> getFieldValuesList() {
try {
inputFieldValueAux = inputFieldValueList;

if (inputFieldValueAux.charAt(0) != "[".charAt(0)) {
if (inputFieldValueAux.charAt(0) != '[') {
inputFieldValueAux = "[" + inputFieldValueAux;
}
if (inputFieldValueAux.charAt(inputFieldValueAux.length() - 1) != "]".charAt(0)) {
if (inputFieldValueAux.charAt(inputFieldValueAux.length() - 1) != ']') {
inputFieldValueAux += "]";
}
final JsonNode nodes = OBJECT_MAPPER.readTree(inputFieldValueAux);
Expand All @@ -122,26 +122,24 @@ public final List<String> getFieldValuesList() {

}
} catch (final JsonProcessingException ex) {
// Warning: even though IntelliJ say that can be simplified, it can't be simplified!! (test fails)

if(inputFieldValueList.startsWith("[") && inputFieldValueList.endsWith("]")) {
String pattern = "(?<=\\[?)((([À-ÿ\\p{Alnum}\\p{Punct}&&[^,\\[\\]]]+:([À-ÿ\\p{Alnum}\\p{Punct}&&[^,\\[\\]]]+|\\[([À-ÿ\\p{Alnum}\\p{Punct}&&[^,\\[\\]]]+," +
"[À-ÿ\\p{Alnum}\\p{Punct}&&[^,\\[\\]]]+|)*]))|[À-ÿ\\p{Alnum}\\p{Punct}&&[^,\\[\\]]]+)(?=[]|,]))";
Pattern r = Pattern.compile(pattern);
Matcher matcher = r.matcher(inputFieldValueList.trim());
while (matcher.find()) {
result.add(matcher.group(0));
}
} else {
String pattern = "([À-ÿ\\p{Alnum}\\p{Punct}&&[^,\\[\\]]][À-ÿ\\s\\p{Alnum}\\p{Punct}&&[^,\\[\\]]]+)[^,\\s]?+";
Pattern r = Pattern.compile(pattern);
Matcher matcher = r.matcher(inputFieldValueList.trim());
while (matcher.find()) {
result.add(matcher.group(0));
}
// Warning: even though IntelliJ say that can be simplified, it can't be simplified!! (test fails)

if (inputFieldValueList.startsWith("[") && inputFieldValueList.endsWith("]")) {
final String pattern = "(?<=\\[?)((([À-ÿ\\p{Alnum}\\p{Punct}&&[^,\\[\\]]]+:([À-ÿ\\p{Alnum}\\p{Punct}&&[^,\\[\\]]]+|\\[([À-ÿ\\p{Alnum}\\p{Punct}&&[^,\\[\\]]]+,"
+ "[À-ÿ\\p{Alnum}\\p{Punct}&&[^,\\[\\]]]+|)*]))|[À-ÿ\\p{Alnum}\\p{Punct}&&[^,\\[\\]]]+)(?=[]|,]))";
final Pattern r = Pattern.compile(pattern);
final Matcher matcher = r.matcher(inputFieldValueList.trim());
while (matcher.find()) {
result.add(matcher.group(0));
}


} else {
final String pattern = "([À-ÿ\\p{Alnum}\\p{Punct}&&[^,\\[\\]]][À-ÿ\\s\\p{Alnum}\\p{Punct}&&[^,\\[\\]]]+)[^,\\s]?+";
final Pattern r = Pattern.compile(pattern);
final Matcher matcher = r.matcher(inputFieldValueList.trim());
while (matcher.find()) {
result.add(matcher.group(0));
}
}

}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public class ValidTypeConstants {
ARRAY, MAP, ENUM, STRING, INT, LONG, TIMESTAMP, STRING_TIMESTAMP, SHORT, DOUBLE, LONG_TIMESTAMP, UUID, BOOLEAN,
BYTES, INT_DATE, INT_TIME_MILLIS, LONG_TIME_MICROS, LONG_TIMESTAMP_MILLIS, LONG_TIMESTAMP_MICROS,
LONG_LOCAL_TIMESTAMP_MILLIS, LONG_LOCAL_TIMESTAMP_MICROS, STRING_UUID, BYTES_DECIMAL, FIXED_DECIMAL,
INT_YEAR, INT_MONTH, INT_DAY, INT_HOURS, INT_MINUTES, INT_SECONDS, INT_NANOS,STRING_MAP_ARRAY
INT_YEAR, INT_MONTH, INT_DAY, INT_HOURS, INT_MINUTES, INT_SECONDS, INT_NANOS, STRING_MAP_ARRAY
);

private ValidTypeConstants() {
Expand Down

0 comments on commit 1e1d5be

Please sign in to comment.