Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SDC-325, tradeID using hyphen instead of underscore #75

Merged
merged 5 commits into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ jobs:
name: Java 17 build and unit testing
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up Java
uses: actions/setup-java@v1
uses: actions/setup-java@v2
with:
distribution: 'zulu'
java-version: 17
- name: Build with Maven
run: mvn -B package --file pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ private TradeUtils(){}
*/
public static String getUniqueTradeId(){
String uniqueID = UUID.randomUUID().toString().replace("-", "").substring(0, 17);
return "ID_" + uniqueID;
return "ID-" + uniqueID;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,18 @@ class TradeUtilsTest {

@Test
void getUniqueTradeId() {
String idPrefix = "ID-";
List<String> ids = new ArrayList<>();
for (int i = 1; i <= 200 ; i++){
for (int i = 1; i <= 200; i++) {
String id = TradeUtils.getUniqueTradeId();
System.out.println(i + ". " +id);
assertTrue(id.contains("ID_"));
System.out.println(i + ". " + id);
assertTrue(id.contains(idPrefix));

//max length 20
assertEquals(20, id.length());

//id only contains letters and numbers (and the leading underscore)
assertTrue(Pattern.matches("ID_[a-zA-Z0-9]+", id));
assertTrue(Pattern.matches(idPrefix + "[a-zA-Z0-9]+", id));

//check on uniqueness
assertFalse(ids.contains(id));
Expand Down