FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

test: Add unit tests for explicit dynamic routing header. by blakeli0 · Pull Request #337 · googleapis/api-common-java · GitHub

This repository was archived by the owner on Sep 27, 2023. It is now read-only.
/ api-common-java Public archive
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .java  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,36 @@ public void matchWithUnboundInMiddle() {
assertPositionalMatch(template.match("bar/foo/foo/foo/bar"), "foo/foo", "bar");
}

@Test
public void matchWithNamedBindings() {
PathTemplate template = PathTemplate.create("projects/*/{instance_id=instances/*}/**");
Map<String, String> actual =
template.match("projects/proj_foo/instances/instance_bar/table/table_baz");
Truth.assertThat(actual).containsEntry("instance_id", "instances/instance_bar");
}

@Test
public void matchFailWithNamedBindingsWhenPathMismatches() {
PathTemplate template = PathTemplate.create("projects/*/{instance_id=instances/*}/**");
Map<String, String> actual =
template.match("projects/proj_foo/instances_fail/instance_bar/table/table_baz");
Truth.assertThat(actual).isNull();
}

@Test
public void matchWithNamedBindingsThatHasOnlyWildcard() {
PathTemplate template = PathTemplate.create("profiles/{routing_id=*}");
Map<String, String> actual = template.match("profiles/prof_qux");
Truth.assertThat(actual).containsEntry("routing_id", "prof_qux");
}

@Test
public void matchFailWithNamedBindingsThatHasOnlyWildcardWhenPathMismatches() {
PathTemplate template = PathTemplate.create("profiles/{routing_id=*}");
Map<String, String> actual = template.match("profiles/prof_qux/fail");
Truth.assertThat(actual).isNull();
}

@Test
public void matchWithCustomVerbs() {
PathTemplate template = PathTemplate.create("**:foo");
Expand Down

Back | FazBrowse Home | New Git URL