use of com.thoughtworks.go.server.domain.xml.builder.ElementBuilder in project gocd by gocd.
the class JobPlanXmlRepresenter method populateJob.
public void populateJob(ElementBuilder builder, XmlWriterContext ctx, WaitingJobPlan waitingJobPlan) {
JobPlan jobPlan = waitingJobPlan.jobPlan();
builder.attr("name", jobPlan.getName()).link(ctx.jobXmlLink(jobPlan.getIdentifier()), "self").link(ctx.jobDetailsLink(jobPlan.getIdentifier()), "alternate", jobPlan.getName() + " Job Detail", "text/html").textNode("buildLocator", jobPlan.getIdentifier().buildLocator());
if (isNotBlank(waitingJobPlan.envName())) {
builder.textNode("environment", waitingJobPlan.envName());
}
if (!jobPlan.getResources().isEmpty()) {
builder.node("resources", rb -> jobPlan.getResources().forEach(resource -> {
rb.cdataNode("resource", resource.getName());
}));
}
if (!jobPlan.getVariables().isEmpty()) {
builder.node("environmentVariables", eb -> jobPlan.getVariables().forEach(variable -> {
eb.node("variable", vb -> vb.attr("name", variable.getName()).text(variable.getDisplayValue()));
}));
}
}
use of com.thoughtworks.go.server.domain.xml.builder.ElementBuilder in project gocd by gocd.
the class MaterialXmlRepresenter method toXml.
@Override
public Document toXml(XmlWriterContext ctx) {
DOMElement rootElement = new DOMElement("material");
ElementBuilder builder = new ElementBuilder(rootElement);
populateMaterial(ctx, materialRevision.getMaterial(), builder);
return new DOMDocument(rootElement);
}
use of com.thoughtworks.go.server.domain.xml.builder.ElementBuilder in project gocd by gocd.
the class DependencyMaterialXmlRepresenterTest method shouldRepresentDependencyMaterial.
@ParameterizedTest
@FileSource(files = "/feeds/materials/dependency-material.xml")
void shouldRepresentDependencyMaterial(String expectedXML) {
Date date = DateUtils.parseISO8601("2019-12-31T15:31:49+05:30");
DependencyMaterial material = MaterialsMother.dependencyMaterial();
material.setId(60);
MaterialRevision revision = new MaterialRevision(material, new Modification(date, "acceptance/63/twist-plugins/2", null, null));
DOMElement root = new DOMElement("materials");
ElementBuilder builder = new ElementBuilder(root);
StageFinder stageFinder = getStageFinder(100L);
XmlWriterContext context = new XmlWriterContext("https://test.host/go", null, null, stageFinder, new SystemEnvironment());
new DependencyMaterialXmlRepresenter("up42", 1, revision).populate(builder, context);
assertThat(root.asXML()).and(expectedXML).ignoreWhitespace().areIdentical();
}
use of com.thoughtworks.go.server.domain.xml.builder.ElementBuilder in project gocd by gocd.
the class PackageMaterialXmlRepresenterTest method shouldRepresentDependencyMaterial.
@ParameterizedTest
@FileSource(files = "/feeds/materials/package-material.xml")
void shouldRepresentDependencyMaterial(String expectedXML) {
Date date = DateUtils.parseISO8601("2019-12-31T15:31:49+05:30");
PackageMaterial material = MaterialsMother.packageMaterial();
material.setId(60);
Modification modification = new Modification("Bob", "Release new package", null, date, "1");
MaterialRevision revision = new MaterialRevision(material, modification);
DOMElement root = new DOMElement("materials");
ElementBuilder builder = new ElementBuilder(root);
XmlWriterContext context = new XmlWriterContext("https://test.host/go", null, null, null, new SystemEnvironment());
new PackageMaterialXmlRepresenter("up42", 1, revision).populate(builder, context);
assertThat(root.asXML()).and(expectedXML).ignoreWhitespace().areIdentical();
}
use of com.thoughtworks.go.server.domain.xml.builder.ElementBuilder in project gocd by gocd.
the class ScmMaterialXmlRepresenterTest method shouldGenerateXmlFromMaterialRevision.
@ParameterizedTest
@FileSource(files = "/feeds/materials/git-material.xml")
void shouldGenerateXmlFromMaterialRevision(String expectedXML) {
GitMaterial gitMaterial = gitMaterial("https://material/example.git");
gitMaterial.setId(100);
MaterialRevision materialRevision = new MaterialRevision(gitMaterial, modifications());
DOMElement root = new DOMElement("materials");
ElementBuilder builder = new ElementBuilder(root);
XmlWriterContext context = new XmlWriterContext("https://test.host/go", null, null, null, new SystemEnvironment());
new ScmMaterialXmlRepresenter("up42", 1, materialRevision).populate(builder, context);
assertThat(root.asXML()).and(expectedXML).ignoreWhitespace().areIdentical();
}
Aggregations