Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save The0x539/d8d3193fc3185ce9a9991e10fab6f1e3 to your computer and use it in GitHub Desktop.
Save The0x539/d8d3193fc3185ce9a9991e10fab6f1e3 to your computer and use it in GitHub Desktop.
public static String testableHtml(PageData pageData, boolean includeSuiteSetup) {
if (!pageData.hasAttribute("Test")) {
return pageData.getHtml();
}
WikiPage wikiPage = pageData.getWikiPage();
StringBuffer buffer = new StringBuffer();
if (includeSuiteSetup) {
includePage(buffer, wikiPage, SuiteResponder.SUITE_SETUP_NAME, "-setup");
}
includePage(buffer, wikiPage, "SetUp", "-setup");
buffer.append(pageData.getContent());
includePage(buffer, wikiPage, "TearDown", "-teardown");
if (includeSuiteSetup) {
includePage(buffer, wikiPage, SuiteResponder.SUITE_TEARDOWN_NAME, "-teardown");
}
pageData.setContent(buffer.toString());
return pageData.getHtml();
}
private static void includePage(StringBuffer buffer, WikiPage wikiPage, String pageName, String argName) {
WikiPage page = PageCrawlerImpl.getInheritedPage(pageName, wikiPage);
if (page == null) {
return;
}
WikiPagePath path = page.getPageCrawler().getFullPath(page);
String pathName = PathParser.render(path);
buffer
.append("!include ").append(argName)
.append(" .").append(pathName)
.append("\n");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment