Skip to content
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
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@
<artifactId>maven-release-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<useReleaseProfile>false</useReleaseProfile>
<tagNameFormat>v@{project.version}</tagNameFormat>
<releaseProfiles>release</releaseProfiles>
<goals>deploy</goals>
</configuration>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,23 +200,58 @@ public static boolean matches(UUri pattern, UUri candidateUri) {
matchesResource(pattern, candidateUri);
}

static boolean hasWildcardAuthority(UUri uri) {
/**
* Checks if a uProtocol URI contains the wildcard authority.
*
* @param uri The URI to check.
* @return {@code true} if the URI's authority is the wildcard authority.
* @throws NullPointerException if uri is {@code null}.
*/
public static boolean hasWildcardAuthority(UUri uri) {
return UriFactory.WILDCARD_AUTHORITY.equals(uri.getAuthorityName());
}

static boolean hasWildcardEntityTypeId(UUri uri) {
/**
* Checks if a uProtocol URI contains the wildcard uEntity type.
*
* @param uri The URI to check.
* @return {@code true} if the URI's uEntity type identifier is the wildcard identifier.
* @throws NullPointerException if uri is {@code null}.
*/
public static boolean hasWildcardEntityTypeId(UUri uri) {
return (uri.getUeId() & UriFactory.WILDCARD_ENTITY_TYPE_ID) == UriFactory.WILDCARD_ENTITY_TYPE_ID;
}

static boolean hasWildcardEntityInstanceId(UUri uri) {
/**
* Checks if a uProtocol URI contains the wildcard uEntity instance identifier.
*
* @param uri The URI to check.
* @return {@code true} if the URI's uEntity instance identifier is the wildcard identifier.
* @throws NullPointerException if uri is {@code null}.
*/
public static boolean hasWildcardEntityInstanceId(UUri uri) {
return (uri.getUeId() & UriFactory.WILDCARD_ENTITY_INSTANCE_ID) == UriFactory.WILDCARD_ENTITY_INSTANCE_ID;
}

static boolean hasWildcardEntityVersion(UUri uri) {
/**
* Checks if a uProtocol URI contains the wildcard uEntity major version.
*
* @param uri The URI to check.
* @return {@code true} if the URI's uEntity major version is the wildcard version.
* @throws NullPointerException if uri is {@code null}.
*/
public static boolean hasWildcardEntityVersion(UUri uri) {
return uri.getUeVersionMajor() == UriFactory.WILDCARD_ENTITY_VERSION;
}

static boolean hasWildcardResourceId(UUri uri) {
/**
* Checks if a uProtocol URI contains the wildcard uEntity resource identifier.
*
* @param uri The URI to check.
* @return {@code true} if the URI's uEntity resource identifier is the wildcard identifier.
* @throws NullPointerException if uri is {@code null}.
*/
public static boolean hasWildcardResourceId(UUri uri) {
return uri.getResourceId() == UriFactory.WILDCARD_RESOURCE_ID;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,61 +165,4 @@ void testHasWildcard(String uri, boolean shouldSucceed) {
assertFalse(UriValidator.hasWildcard(uuri));
}
}

@ParameterizedTest(name = "Test URI matches pattern: {index} {arguments}")
@CsvSource(useHeadersInDisplayName = true, delimiter = '|', textBlock = """
uri | pattern
/1/1/A1FB | /1/1/A1FB
/1/1/A1FB | //*/1/1/A1FB
/1/1/A1FB | /FFFF/1/A1FB
/1/1/A1FB | //*/FFFF/1/A1FB
/1/1/A1FB | /FFFFFFFF/1/A1FB
/1/1/A1FB | //*/FFFFFFFF/1/A1FB
/1/1/A1FB | /1/FF/A1FB
/1/1/A1FB | //*/1/FF/A1FB
/1/1/A1FB | /1/1/FFFF
/1/1/A1FB | //*/1/1/FFFF
/1/1/A1FB | /FFFFFFFF/FF/FFFF
/1/1/A1FB | //*/FFFFFFFF/FF/FFFF
/10001/1/A1FB | /10001/1/A1FB
/10001/1/A1FB | //*/10001/1/A1FB
/10001/1/A1FB | /FFFFFFFF/1/A1FB
/10001/1/A1FB | //*/FFFFFFFF/1/A1FB
/10001/1/A1FB | /FFFFFFFF/FF/FFFF
/10001/1/A1FB | //*/FFFFFFFF/FF/FFFF
//vcu.my_vin/1/1/A1FB | //vcu.my_vin/1/1/A1FB
//vcu.my_vin/1/1/A1FB | //*/1/1/A1FB
"""
)
// TODO: replace with Cucumber based test in UuriTests.java
// [utest->dsn~uri-pattern-matching~2]
void testMatchesSucceeds(String uri, String pattern) {
UUri patternUri = UriSerializer.deserialize(pattern);
UUri candidateUri = UriSerializer.deserialize(uri);
assertTrue(UriValidator.matches(patternUri, candidateUri));
}

@ParameterizedTest(name = "Test URI does not match pattern: {index} {arguments}")
@CsvSource(useHeadersInDisplayName = true, delimiter = '|', textBlock = """
uri | pattern
/1/1/A1FB | //mcu1/1/1/A1FB
//vcu.my_vin/1/1/A1FB | //mcu1/1/1/A1FB
//vcu/B1A5/1/A1FB | //vc/FFFFFFFF/FF/FFFF
/B1A5/1/A1FB | //*/25B1/FF/FFFF
/B1A5/1/A1FB | //*/FFFFFFFF/2/FFFF
/B1A5/1/A1FB | //*/FFFFFFFF/FF/ABCD
/B1A5/1/A1FB | /25B1/1/A1FB
/B1A5/1/A1FB | /2B1A5/1/A1FB
/10B1A5/1/A1FB | /40B1A5/1/A1FB
/B1A5/1/A1FB | /B1A5/4/A1FB
/B1A5/1/A1FB | /B1A5/1/90FB
"""
)
// TODO: replace with Cucumber based test in UuriTests.java
// [utest->dsn~uri-pattern-matching~2]
void testMatchesFails(String uri, String pattern) {
UUri patternUri = UriSerializer.deserialize(pattern);
UUri candidateUri = UriSerializer.deserialize(uri);
assertFalse(UriValidator.matches(patternUri, candidateUri));
}
}