use of com.thoughtworks.go.junit5.FileSource 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.junit5.FileSource in project gocd by gocd.
the class JobPlanXmlRepresenterTest method shouldGenerateDocumentForJobPlan.
@ParameterizedTest
@FileSource(files = "/feeds/job-plan.xml")
void shouldGenerateDocumentForJobPlan(String expectedXML) {
EnvironmentVariable secureEnvVariable = new EnvironmentVariable("secureVariable", "value2", true);
DefaultJobPlan jobPlan1 = JobInstanceMother.jobPlan("job-1", 1);
EnvironmentVariables variables = new EnvironmentVariables();
variables.add("some_var", "blah");
variables.add(secureEnvVariable);
jobPlan1.setVariables(variables);
XmlWriterContext context = new XmlWriterContext("https://go-server/go", null, null, null, new SystemEnvironment());
Document document = new JobPlanXmlRepresenter(List.of(new WaitingJobPlan(jobPlan1, "envName"))).toXml(context);
assertThat(document.asXML()).and(expectedXML).ignoreWhitespace().areIdentical();
}
use of com.thoughtworks.go.junit5.FileSource in project gocd by gocd.
the class PipelinesXmlRepresenterTest method shouldConvertPipelineInstanceModelsToDocument.
@ParameterizedTest
@FileSource(files = "/feeds/pipelines.xml")
void shouldConvertPipelineInstanceModelsToDocument(String expectedXML) {
XmlWriterContext context = new XmlWriterContext("https://go-server/go", null, null, null, new SystemEnvironment());
PipelineInstanceModel up42Model = pipelineInstanceModel("up42");
PipelineInstanceModel up43Model = pipelineInstanceModel("up43");
PipelineInstanceModels models = createPipelineInstanceModels(up42Model, up43Model);
PipelinesXmlRepresenter representer = new PipelinesXmlRepresenter(models);
Document document = representer.toXml(context);
XmlAssert.assertThat(document.asXML()).and(expectedXML).ignoreWhitespace().areIdentical();
}
use of com.thoughtworks.go.junit5.FileSource 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.junit5.FileSource in project gocd by gocd.
the class StageXmlRepresenterTest method shouldGenerateDocumentForStage.
@ParameterizedTest
@FileSource(files = "/feeds/stage.xml")
void shouldGenerateDocumentForStage(String expectedXML) {
String pipelineName = "BulletinBoard";
String stageName = "UnitTest";
String jobName = "run-junit";
XmlWriterContext context = new XmlWriterContext("https://go-server/go", null, null, null, new SystemEnvironment());
Stage stage = StageMother.cancelledStage(stageName, jobName);
stage.getJobInstances().get(0).setIdentifier(new JobIdentifier(pipelineName, 1, null, stageName, "1", jobName));
stage.getJobInstances().get(0).getTransitions().first().setStateChangeTime(parseISO8601("2020-01-03T11:14:19+05:30"));
stage.setIdentifier(new StageIdentifier(pipelineName, 10, stage.getName(), "4"));
Document document = new StageXmlRepresenter(stage).toXml(context);
assertThat(document.asXML()).and(expectedXML).ignoreWhitespace().areIdentical();
}
Aggregations