use of com.thoughtworks.go.junit5.FileSource in project gocd by gocd.
the class JobXmlRepresenterTest method shouldGenerateDocumentForJob.
@ParameterizedTest
@FileSource(files = "/feeds/job.xml")
void shouldGenerateDocumentForJob(String expectedXML) throws IllegalArtifactLocationException {
ArtifactUrlReader urlReader = mock(ArtifactUrlReader.class);
JobInstance jobInstance = JobInstanceMother.failed("unit-test");
JobIdentifier identifier = new JobIdentifier("up42", 1, "UP42", "unit-tests", "1", "unit");
jobInstance.setIdentifier(identifier);
JobPlanLoader jobPlanLoader = mock(JobPlanLoader.class);
JobPlan jobPlan = mock(JobPlan.class);
when(urlReader.findArtifactUrl(identifier)).thenReturn("artifact-url");
when(urlReader.findArtifactRoot(identifier)).thenReturn("artifact-root-url");
when(jobPlanLoader.loadOriginalJobPlan(jobInstance.getIdentifier())).thenReturn(jobPlan);
when(jobPlan.getArtifactPlansOfType(ArtifactPlanType.unit)).thenReturn(Collections.singletonList(new ArtifactPlan(ArtifactPlanType.unit, "source", "destination")));
XmlWriterContext context = new XmlWriterContext("https://go-server/go", urlReader, jobPlanLoader, null, new SystemEnvironment());
Document document = new JobXmlRepresenter(jobInstance).toXml(context);
assertThat(document.asXML()).and(expectedXML).ignoreWhitespace().areIdentical();
}
use of com.thoughtworks.go.junit5.FileSource 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();
}
use of com.thoughtworks.go.junit5.FileSource in project gocd by gocd.
the class FeedEntriesRepresenterTest method shouldGenerateXmlWithoutEntryWhenEmpty.
@ParameterizedTest
@FileSource(files = "/feeds/stages-with-no-entries.xml")
void shouldGenerateXmlWithoutEntryWhenEmpty(String expectedXML) {
String pipelineName = "up42";
XmlWriterContext context = new XmlWriterContext("https://go-server/go", null, null, null, new SystemEnvironment());
FeedEntries feedEntries = mock(FeedEntries.class);
when(feedEntries.lastUpdatedDate()).thenReturn(DateUtils.parseISO8601("2019-12-31T07:28:30+05:30"));
Document document = new FeedEntriesRepresenter(pipelineName, feedEntries).toXml(context);
XmlAssert.assertThat(document.asXML()).and(expectedXML).ignoreWhitespace().areIdentical();
}
use of com.thoughtworks.go.junit5.FileSource in project gocd by gocd.
the class FeedEntriesRepresenterTest method shouldGenerateFeedXml.
@ParameterizedTest
@FileSource(files = "/feeds/stages-with-entries.xml")
void shouldGenerateFeedXml(String expectedXML) {
String pipelineName = "up42";
StageFeedEntry entryOne = cancelled();
StageFeedEntry entryTwo = passed();
entryOne.getAuthors().add(new Author("bob", "bob@gocd.org"));
entryTwo.getAuthors().add(new Author("joe <joe@gocd.org>", null));
XmlWriterContext context = new XmlWriterContext("https://go-server/go", null, null, null, new SystemEnvironment());
FeedEntriesRepresenter representable = new FeedEntriesRepresenter(pipelineName, new FeedEntries(entryOne, entryTwo));
Document document = representable.toXml(context);
XmlAssert.assertThat(document.asXML()).and(expectedXML).ignoreWhitespace().areIdentical();
}
use of com.thoughtworks.go.junit5.FileSource in project gocd by gocd.
the class PipelineXmlRepresenterTest method shouldGeneratePipelineXml.
@ParameterizedTest
@FileSource(files = "/feeds/pipeline.xml")
void shouldGeneratePipelineXml(String expectedXML) {
Document document = new PipelineXmlRepresenter(model).toXml(context);
assertThat(document.asXML()).and(expectedXML).ignoreWhitespace().areIdentical();
}
Aggregations