Skip to content

Commit

Permalink
feat(impl): [#528] policyId allow "urn:uuid:" prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
dsmf committed May 13, 2024
1 parent 94b5977 commit 25ced4c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import jakarta.validation.ConstraintValidator;
import jakarta.validation.ConstraintValidatorContext;
import org.apache.commons.lang3.StringUtils;

/**
* Validator for list of business partner numbers (BPN).
Expand All @@ -44,7 +45,7 @@ public static boolean isValid(final String policyId) {

private static boolean validateUUID(final String uuidStr) {
try {
UUID.fromString(uuidStr);
UUID.fromString(StringUtils.removeStart(uuidStr, "urn:uuid:"));
return true;
} catch (IllegalArgumentException e) {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,15 @@ void withValidPolicyId(final String validPolicyId) {
}

private static Stream<String> generateUUIDs() {
return Stream.generate(() -> faker.internet().uuid()).limit(10);
return Stream.concat(uuidStream().limit(5), generateUUIDsWithUrnPrefix().limit(5));
}

private static Stream<String> generateUUIDsWithUrnPrefix() {
return uuidStream().map(uuid -> "urn:uuid:" + uuid);
}

private static Stream<String> uuidStream() {
return Stream.generate(() -> faker.internet().uuid());
}

@ParameterizedTest
Expand Down

0 comments on commit 25ced4c

Please sign in to comment.