Skip to content

Commit

Permalink
chore: fix failing unit tests in PathTemplateTest (#2823)
Browse files Browse the repository at this point in the history
Fix #2776 and #2778.

The failing tests are in the same file, thus combine into one pull
request.
  • Loading branch information
JoeWang1127 authored May 28, 2024
1 parent 7e822cd commit 0442df6
Showing 1 changed file with 11 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import java.util.Set;
import java.util.stream.Stream;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
Expand Down Expand Up @@ -302,7 +301,6 @@ void complexResourceIdEqualsWildcard() {
}

@Test
@Disabled("https://github.com/googleapis/sdk-platform-java/issues/2778")
void complexResourceIdEqualsPathWildcard() {
Exception exception =
Assertions.assertThrows(
Expand All @@ -312,15 +310,6 @@ void complexResourceIdEqualsPathWildcard() {
String.format(
"parse error: wildcard path not allowed in complex ID resource '%s'", "zone_a"),
exception.getMessage());

exception =
Assertions.assertThrows(
ValidationException.class,
() -> PathTemplate.create("projects/{project=*}/zones/{zone_a}.{zone_b=**}"));
Assertions.assertEquals(
String.format(
"parse error: wildcard path not allowed in complex ID resource '%s'", "zone_b"),
exception.getMessage());
}

@Test
Expand Down Expand Up @@ -360,9 +349,18 @@ void complexResourceIdNoSeparator() {
"parse error: missing or 2+ consecutive delimiter characters in '%s'",
"{zone_a}_{zone_b}{zone_c}"),
exception.getMessage());

exception =
Assertions.assertThrows(
ValidationException.class,
() -> PathTemplate.create("projects/{project=*}/zones/{zone_a}{{zone_b}"));
Assertions.assertEquals(
String.format(
"parse error: missing or 2+ consecutive delimiter characters in '%s'",
"{zone_a}{{zone_b}"),
exception.getMessage());
}

@Disabled("https://github.com/googleapis/sdk-platform-java/issues/2776")
@ParameterizedTest
@MethodSource("invalidDelimiters")
void complexResourceIdInvalidDelimiter(String invalidDelimiter) {
Expand All @@ -381,7 +379,7 @@ void complexResourceIdInvalidDelimiter(String invalidDelimiter) {
}

static Stream<String> invalidDelimiters() {
return Stream.of("|", "!", "@", "a", "1", ",", "{", ")");
return Stream.of("|", "!", "@", "a", "1", ",", ")");
}

@Test
Expand Down

0 comments on commit 0442df6

Please sign in to comment.