Skip to content

Commit

Permalink
Add TestDataGenerator.randomFieldName for including combinations of s…
Browse files Browse the repository at this point in the history
…pecial characters at start and end of field names
  • Loading branch information
cnathe committed Feb 7, 2025
1 parent 79720b9 commit 2a230d0
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/org/labkey/test/util/TestDataGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@
import java.util.function.Supplier;
import java.util.regex.Pattern;

import static org.labkey.test.BaseWebDriverTest.ILLEGAL_QUERY_KEY_CHARACTERS;


/**
* Use this class to generate random test data for a given column schema
Expand Down Expand Up @@ -355,6 +357,15 @@ public static String randomDomainName(int size)
return domainName;
}

public static String randomFieldName(String part)
{
// use the characters that we know are encoded in fieldKeys plus characters that we know clients are using
String chars = StringUtils.join(ILLEGAL_QUERY_KEY_CHARACTERS, "") + " %()=+-[]_|*`'\":;<>?!@#^";
int startChars = randomInt(0, 5);
int endChars = randomInt(0, 5);
return (randomString(startChars, null, chars) + part + randomString(endChars, null, chars)).trim();
}

public static int randomInt(int min, int max)
{
if (min >= max)
Expand Down

0 comments on commit 2a230d0

Please sign in to comment.