HtmlSerializerContext { public String getAttachmentUri(String name) { if (StringUtils.isNotBlank(pagePath)) { try { String pattern = "/attachment/{projectName}/{branchName}/{pagePath}/{name}"; String uri = ServletUriComponentsBuilder.fromCurrentContextPath() .path(pattern).build() .expand(projectName, branchName, Util.toUrlPagePath(pagePath), name) .encode(Charsets.UTF_8.name()).toUriString() .replaceFirst("^http(?:s)?: return uri; } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); } catch (IllegalStateException e) { } } return "#"; } HtmlSerializerContext(String projectName, String branchName, String pagePath,
			MarkdownProcessor markdownProcessor, Authentication authentication, Locale locale, IPageStore pageStore,
			SystemSettingsStore systemSettingsStore, String contextPath); String getAttachmentUri(String name); String getPageUri(String path); String getUrl(String uri); String markdownToHtml(String markdown); List<Header> getHeaders(); MacroInvocation addMacroInvocation(String macroName, String params);  }
@Test public void getAttachmentUri() { String uri = htmlSerializerContext.getAttachmentUri("test.png"); assertEquals(CONTEXT + "/attachment/" + PROJECT + "/" + BRANCH + "/" + Util.toUrlPagePath(PAGE) + "/test.png", uri); }