From 0442df64c11ea2ad34f97c071181fb6fba7f2196 Mon Sep 17 00:00:00 2001 From: Joe Wang <106995533+JoeWang1127@users.noreply.github.com> Date: Tue, 28 May 2024 09:46:13 -0400 Subject: [PATCH] chore: fix failing unit tests in `PathTemplateTest` (#2823) Fix #2776 and #2778. The failing tests are in the same file, thus combine into one pull request. --- .../api/pathtemplate/PathTemplateTest.java | 24 +++++++++---------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/api-common-java/src/test/java/com/google/api/pathtemplate/PathTemplateTest.java b/api-common-java/src/test/java/com/google/api/pathtemplate/PathTemplateTest.java index a51bdff91b..85e3a060bb 100644 --- a/api-common-java/src/test/java/com/google/api/pathtemplate/PathTemplateTest.java +++ b/api-common-java/src/test/java/com/google/api/pathtemplate/PathTemplateTest.java @@ -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; @@ -302,7 +301,6 @@ void complexResourceIdEqualsWildcard() { } @Test - @Disabled("https://github.com/googleapis/sdk-platform-java/issues/2778") void complexResourceIdEqualsPathWildcard() { Exception exception = Assertions.assertThrows( @@ -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 @@ -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) { @@ -381,7 +379,7 @@ void complexResourceIdInvalidDelimiter(String invalidDelimiter) { } static Stream invalidDelimiters() { - return Stream.of("|", "!", "@", "a", "1", ",", "{", ")"); + return Stream.of("|", "!", "@", "a", "1", ",", ")"); } @Test