@@ -178,6 +178,36 @@ public void matchWithUnboundInMiddle() {
178
178
assertPositionalMatch (template .match ("bar/foo/foo/foo/bar" ), "foo/foo" , "bar" );
179
179
}
180
180
181
+ @ Test
182
+ public void matchWithNamedBindings () {
183
+ PathTemplate template = PathTemplate .create ("projects/*/{instance_id=instances/*}/**" );
184
+ Map <String , String > actual =
185
+ template .match ("projects/proj_foo/instances/instance_bar/table/table_baz" );
186
+ Truth .assertThat (actual ).containsEntry ("instance_id" , "instances/instance_bar" );
187
+ }
188
+
189
+ @ Test
190
+ public void matchFailWithNamedBindingsWhenPathMismatches () {
191
+ PathTemplate template = PathTemplate .create ("projects/*/{instance_id=instances/*}/**" );
192
+ Map <String , String > actual =
193
+ template .match ("projects/proj_foo/instances_fail/instance_bar/table/table_baz" );
194
+ Truth .assertThat (actual ).isNull ();
195
+ }
196
+
197
+ @ Test
198
+ public void matchWithNamedBindingsThatHasOnlyWildcard () {
199
+ PathTemplate template = PathTemplate .create ("profiles/{routing_id=*}" );
200
+ Map <String , String > actual = template .match ("profiles/prof_qux" );
201
+ Truth .assertThat (actual ).containsEntry ("routing_id" , "prof_qux" );
202
+ }
203
+
204
+ @ Test
205
+ public void matchFailWithNamedBindingsThatHasOnlyWildcardWhenPathMismatches () {
206
+ PathTemplate template = PathTemplate .create ("profiles/{routing_id=*}" );
207
+ Map <String , String > actual = template .match ("profiles/prof_qux/fail" );
208
+ Truth .assertThat (actual ).isNull ();
209
+ }
210
+
181
211
@ Test
182
212
public void matchWithCustomVerbs () {
183
213
PathTemplate template = PathTemplate .create ("**:foo" );
0 commit comments