Search in sources :

Example 1 with HtmlRenderer

use of com.thoughtworks.go.server.presentation.models.HtmlRenderer in project gocd by gocd.

the class DirectoryEntriesTest method shouldReturnAMessageWhenThereAreNoArtifacts.

@Test
public void shouldReturnAMessageWhenThereAreNoArtifacts() throws Exception {
    HtmlRenderer renderer = new HtmlRenderer("context");
    DirectoryEntries directoryEntries = new DirectoryEntries();
    directoryEntries.add(new FolderDirectoryEntry("cruise-output", "", new DirectoryEntries()));
    directoryEntries.setIsArtifactsDeleted(true);
    directoryEntries.render(renderer);
    Element document = getRenderedDocument(renderer);
    assertThat(document.getChildren().size(), is(2));
    assertThat(document.getChild("p").getTextNormalize(), Matchers.containsString("Artifacts for this job instance are unavailable as they may have been or deleted externally. Re-run the stage or job to generate them again."));
    assertThat(document.getChild("ul").getChild("div").getChild("span").getChild("a").getTextNormalize(), is("cruise-output"));
}
Also used : Element(org.jdom2.Element) HtmlRenderer(com.thoughtworks.go.server.presentation.models.HtmlRenderer) Test(org.junit.Test)

Example 2 with HtmlRenderer

use of com.thoughtworks.go.server.presentation.models.HtmlRenderer in project gocd by gocd.

the class DirectoryEntriesTest method shouldReturnAMessageWhenAllArtifactsHaveBeenDeletedButArtifactsDeletedFlagHasNotBeenSet.

@Test
public void shouldReturnAMessageWhenAllArtifactsHaveBeenDeletedButArtifactsDeletedFlagHasNotBeenSet() throws Exception {
    HtmlRenderer renderer = new HtmlRenderer("context");
    DirectoryEntries directoryEntries = new DirectoryEntries();
    directoryEntries.render(renderer);
    Element document = getRenderedDocument(renderer);
    assertThat(document.getChildren().size(), is(1));
    assertThat(document.getChild("p").getTextNormalize(), Matchers.containsString("Artifacts for this job instance are unavailable as they may have been or deleted externally. Re-run the stage or job to generate them again."));
}
Also used : Element(org.jdom2.Element) HtmlRenderer(com.thoughtworks.go.server.presentation.models.HtmlRenderer) Test(org.junit.Test)

Example 3 with HtmlRenderer

use of com.thoughtworks.go.server.presentation.models.HtmlRenderer in project gocd by gocd.

the class DirectoryEntriesTest method shouldListAllArtifactsWhenArtifactsNotPurged.

@Test
public void shouldListAllArtifactsWhenArtifactsNotPurged() throws Exception {
    HtmlRenderer renderer = new HtmlRenderer("context");
    DirectoryEntries directoryEntries = new DirectoryEntries();
    directoryEntries.add(new FolderDirectoryEntry("cruise-output", "", new DirectoryEntries()));
    directoryEntries.add(new FolderDirectoryEntry("some-artifact", "", new DirectoryEntries()));
    directoryEntries.render(renderer);
    Element document = getRenderedDocument(renderer);
    assertThat(document.getChildren().size(), is(2));
    Element cruiseOutputElement = (Element) document.getChildren().get(0);
    assertThat(cruiseOutputElement.getChild("div").getChild("span").getChild("a").getTextNormalize(), is("cruise-output"));
    Element artifactElement = (Element) document.getChildren().get(1);
    assertThat(artifactElement.getChild("div").getChild("span").getChild("a").getTextNormalize(), is("some-artifact"));
}
Also used : Element(org.jdom2.Element) HtmlRenderer(com.thoughtworks.go.server.presentation.models.HtmlRenderer) Test(org.junit.Test)

Example 4 with HtmlRenderer

use of com.thoughtworks.go.server.presentation.models.HtmlRenderer in project gocd by gocd.

the class ArtifactFolder method renderArtifactFiles.

public String renderArtifactFiles(String requestContext) {
    HtmlRenderer renderer = new HtmlRenderer(requestContext);
    allEntries().render(renderer);
    return renderer.asString();
}
Also used : HtmlRenderer(com.thoughtworks.go.server.presentation.models.HtmlRenderer)

Example 5 with HtmlRenderer

use of com.thoughtworks.go.server.presentation.models.HtmlRenderer in project gocd by gocd.

the class DirectoryEntriesTest method shouldReturnAMessageWhenAllArtifactsArePurgedIncludingCruiseOutput.

@Test
public void shouldReturnAMessageWhenAllArtifactsArePurgedIncludingCruiseOutput() throws Exception {
    HtmlRenderer renderer = new HtmlRenderer("context");
    DirectoryEntries directoryEntries = new DirectoryEntries();
    directoryEntries.setIsArtifactsDeleted(true);
    directoryEntries.render(renderer);
    Element document = getRenderedDocument(renderer);
    assertThat(document.getChildren().size(), is(1));
    assertThat(document.getChild("p").getTextNormalize(), Matchers.containsString("Artifacts for this job instance are unavailable as they may have been or deleted externally. Re-run the stage or job to generate them again."));
}
Also used : Element(org.jdom2.Element) HtmlRenderer(com.thoughtworks.go.server.presentation.models.HtmlRenderer) Test(org.junit.Test)

Aggregations

HtmlRenderer (com.thoughtworks.go.server.presentation.models.HtmlRenderer)5 Element (org.jdom2.Element)4 Test (org.junit.Test)4