Search in sources :

Example 1 with FileSource

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();
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) Modification(com.thoughtworks.go.domain.materials.Modification) ElementBuilder(com.thoughtworks.go.server.domain.xml.builder.ElementBuilder) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) DOMElement(org.dom4j.dom.DOMElement) Date(java.util.Date) FileSource(com.thoughtworks.go.junit5.FileSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 2 with FileSource

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();
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) Document(org.dom4j.Document) FileSource(com.thoughtworks.go.junit5.FileSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 3 with FileSource

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();
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) PipelineInstanceModels.createPipelineInstanceModels(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels.createPipelineInstanceModels) PipelineInstanceModels(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels) PipelineInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel) XmlWriterContext(com.thoughtworks.go.domain.XmlWriterContext) Document(org.dom4j.Document) FileSource(com.thoughtworks.go.junit5.FileSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 4 with FileSource

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();
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) Modification(com.thoughtworks.go.domain.materials.Modification) PackageMaterial(com.thoughtworks.go.config.materials.PackageMaterial) ElementBuilder(com.thoughtworks.go.server.domain.xml.builder.ElementBuilder) XmlWriterContext(com.thoughtworks.go.domain.XmlWriterContext) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) DOMElement(org.dom4j.dom.DOMElement) Date(java.util.Date) FileSource(com.thoughtworks.go.junit5.FileSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 5 with FileSource

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();
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) StageIdentifier(com.thoughtworks.go.domain.StageIdentifier) Stage(com.thoughtworks.go.domain.Stage) XmlWriterContext(com.thoughtworks.go.domain.XmlWriterContext) JobIdentifier(com.thoughtworks.go.domain.JobIdentifier) Document(org.dom4j.Document) FileSource(com.thoughtworks.go.junit5.FileSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

FileSource (com.thoughtworks.go.junit5.FileSource)10 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)10 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)9 Document (org.dom4j.Document)7 XmlWriterContext (com.thoughtworks.go.domain.XmlWriterContext)6 ElementBuilder (com.thoughtworks.go.server.domain.xml.builder.ElementBuilder)3 DOMElement (org.dom4j.dom.DOMElement)3 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)2 FeedEntries (com.thoughtworks.go.domain.feed.FeedEntries)2 Modification (com.thoughtworks.go.domain.materials.Modification)2 Date (java.util.Date)2 PackageMaterial (com.thoughtworks.go.config.materials.PackageMaterial)1 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)1 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)1 JobIdentifier (com.thoughtworks.go.domain.JobIdentifier)1 Stage (com.thoughtworks.go.domain.Stage)1 StageIdentifier (com.thoughtworks.go.domain.StageIdentifier)1 Author (com.thoughtworks.go.domain.feed.Author)1 StageFeedEntry (com.thoughtworks.go.domain.feed.stage.StageFeedEntry)1 PipelineInstanceModel (com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel)1