WebUrlImpl extends UrlImpl implements WebUrl { public String getLink() { if (link == null) { try { link = URLEncoder.encode(getLink(-1, null, null), "utf-8"); } catch (UnsupportedEncodingException e) { logger.error("Unexpected error while urlencoding link {}", link, e); } link = link.replaceAll("%2F", "/"); } return link; } WebUrlImpl(Site site, String path);  WebUrlImpl(Site site, Path url);  WebUrlImpl(Site site, Path url, String path);  WebUrlImpl(Site site, String path, long version);  WebUrlImpl(Site site, String path, long version, RequestFlavor flavor);  WebUrlImpl(Site site, String path, long version, RequestFlavor flavor,
      Language language);  WebUrlImpl(WebUrlImpl url, String path); Site getSite(); String getLink(); String getLink(long version); String getLink(Language language); String getLink(String flavor); String getLink(long version, Language language, String flavor); String normalize(); String normalize(boolean includeVersion, boolean includeLanguage,
      boolean includeFlavor); RequestFlavor getFlavor(); long getVersion(); Language getLanguage(); boolean hasLanguagePathSegment(); @Override int hashCode(); @Override boolean equals(Object object); @Override String toString();  }
@Test public void testGetLink() { assertEquals(livePath, liveUrl.getLink()); assertEquals(livePath, liveUrlWithPort.getLink()); assertTrue(flavoredLiveUrl.getLink().endsWith(flavoredPath)); assertTrue(localizedLiveUrl.getLink().endsWith(localizedPath)); assertTrue(flavoredLocalizedLiveUrl.getLink().endsWith(flavoredLocalizedPath)); assertTrue(flavoredSegmentedLiveUrl.getLink().endsWith(flavoredPath)); assertTrue(localizedSegmentedLiveUrl.getLink().endsWith(localizedPath)); assertTrue(flavoredLocalizedSegmentedLiveUrl.getLink().endsWith(flavoredLocalizedPath)); assertEquals(versionedPath, versionedUrl.getLink()); assertTrue(flavoredVersionedUrl.getLink().endsWith(flavoredVersionedPath)); assertTrue(localizedVersionedUrl.getLink().endsWith(localizedVersionedPath)); assertTrue(flavoredLocalizedVersionedUrl.getLink().endsWith(flavoredLocalizedVersionedPath)); }
@Test public void testGetLinkLanguage() { String l = "_fr"; assertEquals(localizedPath.replaceAll("_de", l), liveUrl.getLink(french)); assertEquals(flavoredLocalizedPath.replaceAll("_de", l), flavoredLiveUrl.getLink(french)); assertEquals(localizedPath.replaceAll("_de", l), localizedLiveUrl.getLink(french)); assertEquals(flavoredLocalizedPath.replaceAll("_de", l), flavoredSegmentedLiveUrl.getLink(french)); assertEquals(localizedPath.replaceAll("_de", l), localizedSegmentedLiveUrl.getLink(french)); assertEquals(flavoredLocalizedPath.replaceAll("_de", l), flavoredLocalizedLiveUrl.getLink(french)); assertEquals(flavoredLocalizedPath.replaceAll("_de", l), flavoredLocalizedSegmentedLiveUrl.getLink(french)); assertEquals(localizedVersionedPath.replaceAll("_de", l), versionedUrl.getLink(french)); assertEquals(flavoredLocalizedVersionedPath.replaceAll("_de", l), flavoredVersionedUrl.getLink(french)); assertEquals(localizedVersionedPath.replaceAll("_de", l), localizedVersionedUrl.getLink(french)); assertEquals(flavoredLocalizedVersionedPath.replaceAll("_de", l), flavoredLocalizedVersionedUrl.getLink(french)); }
@Test public void testGetLinkString() { String flavor = "pdf"; assertEquals(flavoredPath.replaceAll("json", flavor), liveUrl.getLink(flavor)); assertEquals(flavoredLocalizedPath.replaceAll("json", flavor), localizedLiveUrl.getLink(flavor)); assertEquals(flavoredPath.replaceAll("json", flavor), flavoredLiveUrl.getLink(flavor)); assertEquals(flavoredPath.replaceAll("json", flavor), flavoredSegmentedLiveUrl.getLink(flavor)); assertEquals(flavoredLocalizedPath.replaceAll("json", flavor), localizedSegmentedLiveUrl.getLink(flavor)); assertEquals(flavoredLocalizedPath.replaceAll("json", flavor), flavoredLocalizedLiveUrl.getLink(flavor)); assertEquals(flavoredLocalizedPath.replaceAll("json", flavor), flavoredLocalizedSegmentedLiveUrl.getLink(flavor)); assertEquals(flavoredVersionedPath.replaceAll("json", flavor), versionedUrl.getLink(flavor)); assertEquals(flavoredVersionedPath.replaceAll("json", flavor), flavoredVersionedUrl.getLink(flavor)); assertEquals(flavoredLocalizedVersionedPath.replaceAll("json", flavor), localizedVersionedUrl.getLink(flavor)); assertEquals(flavoredLocalizedVersionedPath.replaceAll("json", flavor), flavoredLocalizedVersionedUrl.getLink(flavor)); }