TestDataGenerator randomFieldName and randomDomainName usage of ValidateDomainAndFieldNamesAction#2571
TestDataGenerator randomFieldName and randomDomainName usage of ValidateDomainAndFieldNamesAction#2571
Conversation
…a repeated character between 2 and 15 times
…dd all of the charSet to the generated string
…nerator.randomFieldName
…alidate domain names based on the domain kind
…hars() for each generated name iteration
… into a single space
…r (will increase with next PR)
| testDgen.addCustomRow(Map.of("Name", "class1")); | ||
| testDgen.addCustomRow(Map.of("Name", "class2")); |
There was a problem hiding this comment.
Is this just cleaning up data that adds no value to the test?
There was a problem hiding this comment.
Yes, these other columns like "intColumn" are now randomly generated names so when I went to update them in the data rows I noticed that the values aren't checked anywhere so it seemed cleaner to just remove the related data row values.
| // first the header | ||
| List<String> rows = new ArrayList<>(); | ||
| rows.add(String.join("\t", data.get(0).keySet())); | ||
| data.forEach(dataMap -> { | ||
| StringBuilder row = new StringBuilder(); | ||
| data.get(0).keySet().forEach(key -> { | ||
| row.append(dataMap.get(key)); | ||
| row.append("\t"); | ||
| }); | ||
| rows.add(row.substring(0, row.lastIndexOf("\t"))); | ||
| }); | ||
| return String.join("\n", rows); |
There was a problem hiding this comment.
Hopefully there aren't too many more methods like this out there.
There was a problem hiding this comment.
We've likely found most of them at this point!
| public static final char WIDE_PLACEHOLDER = '\u03A0'; // 'Π' - Wide character can't be picked from the string with 'charAt' | ||
| public static final char REPEAT_PLACEHOLDER = '\u22EF'; // '⋯' - Used to indicate that the char will be repeated |
There was a problem hiding this comment.
Thanks. I was tempted on one of the previous PRs that made WIDE_CHAR public to suggest making WIDE_PLACEHOLDER and NON_LATIN_STRING public as well.
I also wonder how we decide where to put public constants like these as well as the next few lines. We have some constant values in TestDataUtils. BaseWebDriverTest has several constants as well. I think there might be value to consider a future PR that consolidates all of these type of constants into one location.
Rationale
We've been slowly handling various cases on the test code side to account for randomly generated domain and field names that end up being invalid (because of invalid character sequences, length, etc.). This PR changes that approach so that we instead call a server API (ValidateDomainAndFieldNamesAction) to do those checks on the generated name and regenerate the name if it is invalid.
Related Pull Requests
Changes