Skip to content
This repository was archived by the owner on Feb 2, 2025. It is now read-only.

Commit 6293b92

Browse files
committed
Corrected by review comments
1 parent 15982cc commit 6293b92

File tree

1 file changed

+12
-22
lines changed
  • src/main/java/com/github/markusbernhardt/seleniumlibrary/keywords

1 file changed

+12
-22
lines changed

src/main/java/com/github/markusbernhardt/seleniumlibrary/keywords/DataUtils.java

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
import java.util.ArrayList;
1010
import java.util.Collections;
1111
import java.util.List;
12-
import java.util.regex.Matcher;
13-
import java.util.regex.Pattern;
12+
import java.util.Locale;
1413

1514
@RobotKeywords
1615
public class DataUtils extends RunOnFailureKeywordsAdapter {
@@ -31,34 +30,25 @@ public class DataUtils extends RunOnFailureKeywordsAdapter {
3130
// Keywords
3231
// ##############################
3332

34-
@RobotKeyword
33+
/**
34+
* Sort list of strings.
35+
*
36+
* @param jsonStringOfList json string of list strings
37+
* @param params sorting order
38+
* @return sorting list of strings
39+
*/
40+
@RobotKeyword("Returns sorting list of strings by ``order``.")
3541
@ArgumentNames({"list", "order=ascending"})
36-
public List<String> sortStringList(String listToString, String... params) {
37-
List<String> listOfStrings = robot.parseRobotList(listToString);
42+
public List<String> sortStrings(String jsonStringOfList, String... params) {
43+
List<String> listOfStrings = robot.parseRobotList(jsonStringOfList);
3844
String order = robot.getParamsValue(params, 0, ASCENDING);
3945
List<String> sortedList = new ArrayList<>(listOfStrings);
4046
if (order.equalsIgnoreCase(DESCENDING)) {
4147
listOfStrings.sort(Collections.reverseOrder());
4248
} else {
4349
Collections.sort(listOfStrings);
4450
}
45-
logging.info(String.format("Sorted list '%s' by %s", sortedList, order.toUpperCase()));
51+
logging.info(String.format("Sorted list '%s' by %s", sortedList, order.toUpperCase(Locale.ENGLISH)));
4652
return sortedList;
4753
}
48-
49-
@RobotKeyword
50-
@ArgumentNames({"text", "regExpPattern", "groupIndex"})
51-
public String getStringByRegexpGroup(String text, String regExpPattern, int groupIndex) {
52-
Matcher matcher = Pattern.compile(regExpPattern).matcher(text);
53-
matcher.find();
54-
String matchedText = matcher.group(groupIndex);
55-
logging.info(String.format("Matched text '%s' by pattern '%s' and group index '%d' from the text '%s'", matchedText, regExpPattern, groupIndex, text));
56-
return matchedText;
57-
}
58-
59-
@RobotKeyword
60-
@ArgumentNames({"text", "regExpPattern"})
61-
public boolean isTextMatchPattern(String text, String regExpPattern) {
62-
return Pattern.compile(regExpPattern).matcher(text).matches();
63-
}
6454
}

0 commit comments

Comments
 (0)