use of org.jdom2.Document 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"));
}
use of org.jdom2.Document in project gocd by gocd.
the class XmlUtils method buildXmlDocument.
private static Document buildXmlDocument(InputStream inputStream, SAXBuilder builder) throws JDOMException, IOException {
XsdErrorTranslator errorHandler = new XsdErrorTranslator();
builder.setErrorHandler(errorHandler);
Document cruiseRoot = builder.build(inputStream);
if (errorHandler.hasValidationError()) {
throw new XsdValidationException(errorHandler.translate());
}
return cruiseRoot;
}
use of org.jdom2.Document in project gocd by gocd.
the class FullConfigSaveMergeFlowTest method setup.
@Before
public void setup() throws Exception {
configForEdit = mock(CruiseConfig.class);
updateConfigCommand = new FullConfigUpdateCommand(configForEdit, "md5");
loader = mock(MagicalGoConfigXmlLoader.class);
writer = mock(MagicalGoConfigXmlWriter.class);
document = mock(Document.class);
systemEnvironment = mock(SystemEnvironment.class);
fileWriter = mock(GoConfigFileWriter.class);
serverVersion = mock(ServerVersion.class);
timeProvider = mock(TimeProvider.class);
configRepository = mock(ConfigRepository.class);
cachedGoPartials = mock(CachedGoPartials.class);
configElementImplementationRegistry = mock(ConfigElementImplementationRegistry.class);
partials = new ArrayList<>();
flow = new FullConfigSaveMergeFlow(loader, writer, configElementImplementationRegistry, serverVersion, timeProvider, configRepository, cachedGoPartials, fileWriter);
}
use of org.jdom2.Document in project gocd by gocd.
the class FullConfigSaveNormalFlowTest method setup.
@Before
public void setup() throws Exception {
configForEdit = new BasicCruiseConfig();
updateConfigCommand = new FullConfigUpdateCommand(configForEdit, "md5");
loader = mock(MagicalGoConfigXmlLoader.class);
writer = mock(MagicalGoConfigXmlWriter.class);
document = mock(Document.class);
systemEnvironment = mock(SystemEnvironment.class);
fileWriter = mock(GoConfigFileWriter.class);
serverVersion = mock(ServerVersion.class);
timeProvider = mock(TimeProvider.class);
configRepository = mock(ConfigRepository.class);
cachedGoPartials = mock(CachedGoPartials.class);
configElementImplementationRegistry = mock(ConfigElementImplementationRegistry.class);
partials = new ArrayList<>();
flow = new FullConfigSaveNormalFlow(loader, writer, configElementImplementationRegistry, serverVersion, timeProvider, configRepository, cachedGoPartials, fileWriter);
}
use of org.jdom2.Document 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."));
}
Aggregations