### Question:
NavDeepLink { boolean matches(@NonNull Uri deepLink) { return mPattern.matcher(deepLink.toString()).matches(); } NavDeepLink(@NonNull String uri);   }### Answer:
@Test public void deepLinkExactMatch() { NavDeepLink deepLink = new NavDeepLink(DEEP_LINK_EXACT_HTTP); assertThat(deepLink.matches(Uri.parse(DEEP_LINK_EXACT_HTTP)), is(true)); assertThat(deepLink.matches(Uri.parse(DEEP_LINK_EXACT_HTTPS)), is(false)); }
@Test public void deepLinkExactMatchWithHyphens() { String deepLinkString = "android-app: NavDeepLink deepLink = new NavDeepLink(deepLinkString); assertThat(deepLink.matches(Uri.parse(deepLinkString)), is(true)); }
@Test public void deepLinkExactMatchNoScheme() { NavDeepLink deepLink = new NavDeepLink(DEEP_LINK_EXACT_NO_SCHEME); assertThat(deepLink.matches(Uri.parse(DEEP_LINK_EXACT_HTTP)), is(true)); assertThat(deepLink.matches(Uri.parse(DEEP_LINK_EXACT_HTTPS)), is(true)); }
@Test public void deepLinkEmptyArgumentNoMatch() { String deepLinkArgument = DEEP_LINK_EXACT_HTTPS + "/users/{id}/posts"; NavDeepLink deepLink = new NavDeepLink(deepLinkArgument); assertThat(deepLink.matches( Uri.parse(deepLinkArgument.replace("{id}", ""))), is(false)); }
@Test public void deepLinkPrefixMatch() { String deepLinkPrefix = DEEP_LINK_EXACT_HTTPS + "/posts/.*"; NavDeepLink deepLink = new NavDeepLink(deepLinkPrefix); assertThat(deepLink.matches( Uri.parse(deepLinkPrefix.replace(".*", "test"))), is(true)); }
@Test public void deepLinkWildcardMatch() { String deepLinkWildcard = DEEP_LINK_EXACT_HTTPS + "/posts/.*/new"; NavDeepLink deepLink = new NavDeepLink(deepLinkWildcard); assertThat(deepLink.matches( Uri.parse(deepLinkWildcard.replace(".*", "test"))), is(true)); }