use of org.jsoup.nodes.Document in project gocd by gocd.
the class BuildDetailPageVelocityTemplateTest method shouldEscapeBuildCauseOnVelocityTemplate.
@Test
public void shouldEscapeBuildCauseOnVelocityTemplate() throws Exception {
Document actualDoc = Jsoup.parse(getBuildDetailVelocityView(createJobDetailModel()).render());
assertThat(actualDoc.select("#build-detail-summary").last().html(), containsString("modified by Ernest Hemingway <oldman@sea.com>"));
}
use of org.jsoup.nodes.Document in project gocd by gocd.
the class HeaderTemplateTest method should_NOT_HaveHeaderWhenLocalizerIs_NULL_InContext.
@Test
public void should_NOT_HaveHeaderWhenLocalizerIs_NULL_InContext() throws Exception {
HashMap<String, Object> data = new HashMap<>();
data.put("l", null);
TestVelocityView view = new TestVelocityView(TEMPLATE_PATH, data);
Document actualOutput = Jsoup.parse(view.render());
assertThat(actualOutput.select("#header .application_nav").isEmpty(), is(true));
}
use of org.jsoup.nodes.Document in project gocd by gocd.
the class HeaderTemplateTest method shouldHaveNavigationElementsWhenLocalizerIsPresentInContext.
@Test
public void shouldHaveNavigationElementsWhenLocalizerIsPresentInContext() throws Exception {
HashMap<String, Object> data = new HashMap<>();
data.put("l", mock(Localizer.class));
TestVelocityView view = new TestVelocityView(TEMPLATE_PATH, data);
Document actualOutput = Jsoup.parse(view.render());
assertThat(actualOutput.select("#header .application_nav").isEmpty(), is(false));
}
use of org.jsoup.nodes.Document in project gocd by gocd.
the class NotificationTemplateTest method shouldHTMLEscapeMatchers.
@Test
public void shouldHTMLEscapeMatchers() throws Exception {
HashMap<String, Object> data = new HashMap<>();
User user = new User("name", "display-name", new String[] { "<script>this && that</script>", "matcher2" }, "email1@host.com", true);
user.populateModel(data);
data.put("pipelines", "[]");
data.put("l", null);
Document actualDoc = Jsoup.parse(new TestVelocityView(TEMPLATE_PATH, data).render());
assertMatchers(actualDoc, "<script>this && that</script>,matcher2", "<script>this && that</script>,", "matcher2");
}
use of org.jsoup.nodes.Document in project jstructure by JonStargaryen.
the class OrientationsOfProteinsInMembranesAnnotator method getDocument.
Document getDocument(String url) throws IOException {
logger.info("fetching OPM annotation from {}", url);
Document document = Jsoup.connect(url).get();
// not the results directly but rather the page forwarding to representative entries
if (document.text().contains("Representative structure(s) of this protein: ")) {
String href = document.getElementById("body").getElementsByTag("a").first().attr("href");
logger.info("moving to representative structure at {}", href);
return getDocument(BASE_URL + href);
}
return document;
}
Aggregations