@@ -487,9 +487,6 @@ public void complexResourceBasicInvalidIds() {
487
487
@ Test
488
488
public void complexResourceMultipleDelimiters () {
489
489
thrown .expect (ValidationException .class );
490
- PathTemplate .create ("projects/*/zones/.-~{zone_a}" );
491
- thrown .expectMessage (
492
- String .format ("parse error: invalid begin or end character in '%s'" , ".-~{zone_a}" ));
493
490
494
491
PathTemplate .create ("projects/*/zones/{zone_a}~.{zone_b}" );
495
492
thrown .expectMessage (
@@ -717,6 +714,80 @@ public void instantiateWithCustomVerbs() {
717
714
Truth .assertThat (template .matches (templateInstance )).isTrue ();
718
715
}
719
716
717
+ @ Test
718
+ public void instantiateWithASegmentStartsWithADelimiter () {
719
+ PathTemplate pathTemplate =
720
+ PathTemplate .create (
721
+ "v1beta1/{parent=projects/*/locations/*/clusters/*}/.well-known/openid-configuration" );
722
+ String pattern =
723
+ "v1beta1/projects/abc/locations/def/clusters/yte/.well-known/openid-configuration" ;
724
+ Truth .assertThat (pathTemplate .matches (pattern )).isTrue ();
725
+ }
726
+
727
+ @ Test
728
+ public void instantiateWithASegmentContainingComplexResourceNamesAndStartsWithADelimiter () {
729
+ thrown .expect (ValidationException .class );
730
+ PathTemplate .create (
731
+ "v1beta1/{parent=projects/*/locations/*/clusters/*}/.{well}-{known}/openid-configuration" );
732
+ thrown .expectMessage (
733
+ String .format ("parse error: invalid begin or end character in '%s'" , ".{well}-{known}" ));
734
+ }
735
+
736
+ @ Test
737
+ public void
738
+ instantiateWithASegmentContainingNoComplexResourceNamesAndStartsWithMultipleDelimiters () {
739
+ PathTemplate pathTemplate =
740
+ PathTemplate .create (
741
+ "v1beta1/{parent=projects/*/locations/*/clusters/*}/.-~well-known/openid-configuration" );
742
+ String pattern =
743
+ "v1beta1/projects/abc/locations/def/clusters/yte/.-~well-known/openid-configuration" ;
744
+ Truth .assertThat (pathTemplate .matches (pattern )).isTrue ();
745
+ }
746
+
747
+ @ Test
748
+ public void instantiateWithASegmentOnlyContainingOneDelimiter () {
749
+ thrown .expect (ValidationException .class );
750
+ PathTemplate .create ("v1/publishers/{publisher}/books/." );
751
+ thrown .expectMessage (String .format ("parse error: invalid begin or end character in '%s'" , "." ));
752
+ }
753
+
754
+ @ Test
755
+ public void instantiateWithASegmentOnlyContainingOneCharacter () {
756
+ PathTemplate pathTemplate = PathTemplate .create ("v1/publishers/{publisher}/books/a" );
757
+ String pattern = "v1/publishers/o'reilly/books/a" ;
758
+ Truth .assertThat (pathTemplate .matches (pattern )).isTrue ();
759
+ }
760
+
761
+ @ Test
762
+ public void instantiateWithASegmentEndsWithADelimiter () {
763
+ PathTemplate pathTemplate =
764
+ PathTemplate .create (
765
+ "v1beta1/{parent=projects/*/locations/*/clusters/*}/well-known./openid-configuration" );
766
+ String pattern =
767
+ "v1beta1/projects/abc/locations/def/clusters/yte/well-known./openid-configuration" ;
768
+ Truth .assertThat (pathTemplate .matches (pattern )).isTrue ();
769
+ }
770
+
771
+ @ Test
772
+ public void instantiateWithASegmentContainingComplexResourceNamesAndEndsWithADelimiter () {
773
+ thrown .expect (ValidationException .class );
774
+ PathTemplate .create (
775
+ "v1beta1/{parent=projects/*/locations/*/clusters/*}/{well}-{known}./openid-configuration" );
776
+ thrown .expectMessage (
777
+ String .format ("parse error: invalid begin or end character in '%s'" , "{well}-{known}." ));
778
+ }
779
+
780
+ @ Test
781
+ public void
782
+ instantiateWithASegmentContainingNoComplexResourceNamesAndEndsWithMultipleDelimiters () {
783
+ PathTemplate pathTemplate =
784
+ PathTemplate .create (
785
+ "v1beta1/{parent=projects/*/locations/*/clusters/*}/well-known.-~/openid-configuration" );
786
+ String pattern =
787
+ "v1beta1/projects/abc/locations/def/clusters/yte/well-known.-~/openid-configuration" ;
788
+ Truth .assertThat (pathTemplate .matches (pattern )).isTrue ();
789
+ }
790
+
720
791
// Other
721
792
// =====
722
793
0 commit comments