Search in sources :

Example 71 with Document

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"));
}
Also used : Element(org.jdom2.Element) HtmlRenderer(com.thoughtworks.go.server.presentation.models.HtmlRenderer) Test(org.junit.Test)

Example 72 with Document

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;
}
Also used : Document(org.jdom2.Document)

Example 73 with Document

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);
}
Also used : ServerVersion(com.thoughtworks.go.server.util.ServerVersion) TimeProvider(com.thoughtworks.go.util.TimeProvider) ConfigRepository(com.thoughtworks.go.service.ConfigRepository) Document(org.jdom2.Document) SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) FullConfigUpdateCommand(com.thoughtworks.go.config.update.FullConfigUpdateCommand) ConfigElementImplementationRegistry(com.thoughtworks.go.config.registry.ConfigElementImplementationRegistry) Before(org.junit.Before)

Example 74 with Document

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);
}
Also used : ServerVersion(com.thoughtworks.go.server.util.ServerVersion) TimeProvider(com.thoughtworks.go.util.TimeProvider) ConfigRepository(com.thoughtworks.go.service.ConfigRepository) Document(org.jdom2.Document) SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) FullConfigUpdateCommand(com.thoughtworks.go.config.update.FullConfigUpdateCommand) ConfigElementImplementationRegistry(com.thoughtworks.go.config.registry.ConfigElementImplementationRegistry) Before(org.junit.Before)

Example 75 with Document

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."));
}
Also used : Element(org.jdom2.Element) HtmlRenderer(com.thoughtworks.go.server.presentation.models.HtmlRenderer) Test(org.junit.Test)

Aggregations

Document (org.jdom2.Document)86 Element (org.jdom2.Element)76 Test (org.junit.Test)33 File (java.io.File)29 DocType (org.jdom2.DocType)24 SAXBuilder (org.jdom2.input.SAXBuilder)21 IOException (java.io.IOException)16 XMLOutputter (org.jdom2.output.XMLOutputter)15 ProcessingInstruction (org.jdom2.ProcessingInstruction)13 XmlFile (jmri.jmrit.XmlFile)11 Document (com.google.cloud.language.v1beta2.Document)10 ApiException (com.google.api.gax.grpc.ApiException)9 Document (com.google.cloud.language.v1.Document)9 GeneratedMessageV3 (com.google.protobuf.GeneratedMessageV3)9 StatusRuntimeException (io.grpc.StatusRuntimeException)9 ArrayList (java.util.ArrayList)9 EncodingType (com.google.cloud.language.v1beta2.EncodingType)8 FileOutputStream (java.io.FileOutputStream)8 JLabel (javax.swing.JLabel)7 EncodingType (com.google.cloud.language.v1.EncodingType)6