Search in sources :

Example 1 with DefaultJobPlan

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());
}
Also used : EnvironmentVariableConfig(com.thoughtworks.go.config.EnvironmentVariableConfig) DefaultJobPlan(com.thoughtworks.go.domain.DefaultJobPlan) GoCipher(com.thoughtworks.go.security.GoCipher) EnvironmentVariablesConfig(com.thoughtworks.go.config.EnvironmentVariablesConfig) XmlWriterContext(com.thoughtworks.go.domain.XmlWriterContext) WaitingJobPlan(com.thoughtworks.go.domain.WaitingJobPlan) Document(org.dom4j.Document) Test(org.junit.Test)

Example 2 with DefaultJobPlan

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);
}
Also used : DefaultJobPlan(com.thoughtworks.go.domain.DefaultJobPlan) ArtifactPlans(com.thoughtworks.go.config.ArtifactPlans) EnvironmentVariablesConfig(com.thoughtworks.go.config.EnvironmentVariablesConfig) ElasticProfile(com.thoughtworks.go.config.elastic.ElasticProfile) JobIdentifier(com.thoughtworks.go.domain.JobIdentifier)

Aggregations

EnvironmentVariablesConfig (com.thoughtworks.go.config.EnvironmentVariablesConfig)2 DefaultJobPlan (com.thoughtworks.go.domain.DefaultJobPlan)2 ArtifactPlans (com.thoughtworks.go.config.ArtifactPlans)1 EnvironmentVariableConfig (com.thoughtworks.go.config.EnvironmentVariableConfig)1 ElasticProfile (com.thoughtworks.go.config.elastic.ElasticProfile)1 JobIdentifier (com.thoughtworks.go.domain.JobIdentifier)1 WaitingJobPlan (com.thoughtworks.go.domain.WaitingJobPlan)1 XmlWriterContext (com.thoughtworks.go.domain.XmlWriterContext)1 GoCipher (com.thoughtworks.go.security.GoCipher)1 Document (org.dom4j.Document)1 Test (org.junit.Test)1