9
9
import java .util .ArrayList ;
10
10
import java .util .Collections ;
11
11
import java .util .List ;
12
- import java .util .regex .Matcher ;
13
- import java .util .regex .Pattern ;
12
+ import java .util .Locale ;
14
13
15
14
@ RobotKeywords
16
15
public class DataUtils extends RunOnFailureKeywordsAdapter {
@@ -31,34 +30,25 @@ public class DataUtils extends RunOnFailureKeywordsAdapter {
31
30
// Keywords
32
31
// ##############################
33
32
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``." )
35
41
@ 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 );
38
44
String order = robot .getParamsValue (params , 0 , ASCENDING );
39
45
List <String > sortedList = new ArrayList <>(listOfStrings );
40
46
if (order .equalsIgnoreCase (DESCENDING )) {
41
47
listOfStrings .sort (Collections .reverseOrder ());
42
48
} else {
43
49
Collections .sort (listOfStrings );
44
50
}
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 )));
46
52
return sortedList ;
47
53
}
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
- }
64
54
}
0 commit comments