use of com.thoughtworks.go.domain.DefaultJobPlan in project gocd by gocd.
the class JobPlanXmlViewModelTest method shouldConvertJobPlanToXmlDocument.
@Test
public void shouldConvertJobPlanToXmlDocument() throws IOException, DocumentException {
EnvironmentVariableConfig secureEnvVariable = new EnvironmentVariableConfig(new GoCipher(), "secureVariable", "value2", true);
DefaultJobPlan jobPlan1 = JobInstanceMother.jobPlan("job-1", 1);
jobPlan1.setJobId(10);
EnvironmentVariablesConfig variables = new EnvironmentVariablesConfig();
variables.add("some_var", "blah");
variables.add(secureEnvVariable);
jobPlan1.setVariables(variables);
DefaultJobPlan jobPlan2 = JobInstanceMother.jobPlan("job-2", 1);
jobPlan2.setJobId(11);
JobPlanXmlViewModel jobPlanXmlViewModel = new JobPlanXmlViewModel(ArrayUtil.asList(new WaitingJobPlan(jobPlan1, "envName"), new WaitingJobPlan(jobPlan2, null)));
String expectedXml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<scheduledJobs>" + "<job name=\"job-1\" id=\"10\">" + "<link rel=\"self\" href=\"http://baseurl/go/tab/build/detail/pipeline/1/stage/1/job-1\"/>" + "<buildLocator>pipeline/1/stage/1/job-1</buildLocator>" + "<environment>envName</environment>" + "<resources><resource><![CDATA[foo]]></resource><resource><![CDATA[bar]]></resource></resources>" + "<environmentVariables><variable name=\"some_var\">blah</variable><variable name=\"secureVariable\">****</variable></environmentVariables>" + "</job>" + "<job name=\"job-2\" id=\"11\">" + "<link rel=\"self\" href=\"http://baseurl/go/tab/build/detail/pipeline/1/stage/1/job-2\"/>" + "<buildLocator>pipeline/1/stage/1/job-2</buildLocator>" + "<resources><resource><![CDATA[foo]]></resource><resource><![CDATA[bar]]></resource></resources>" + "</job>" + "</scheduledJobs>";
Document document = jobPlanXmlViewModel.toXml(new XmlWriterContext("http://baseurl/go", null, null, null, null));
assertEquals(expectedXml, document.asXML());
}
use of com.thoughtworks.go.domain.DefaultJobPlan in project gocd by gocd.
the class ElasticAgentPluginServiceTest method plan.
private JobPlan plan(int jobId, String pluginId) {
ElasticProfile elasticProfile = new ElasticProfile("id", pluginId);
JobIdentifier identifier = new JobIdentifier("pipeline-" + jobId, 1, "1", "stage", "1", "job");
return new DefaultJobPlan(null, new ArtifactPlans(), null, jobId, identifier, null, new EnvironmentVariablesConfig(), new EnvironmentVariablesConfig(), elasticProfile);
}
Aggregations