Search in sources :

Example 6 with JobConfigs

use of com.thoughtworks.go.config.JobConfigs in project gocd by gocd.

the class FetchArtifactViewHelperTest method setUp.

/**
     *  PIPELINES                                          +           TEMPLATE
     *                                                     +
     * random_other                                        +
     * [mingle]                                            +
     *                                                     +           template-1
     * random_pipeline                                     +            [1, 2, 3]
     * [mingle]<---------------------------|               +
     *                                     |               +
     * uppest                              |               +
     * [1, 2, 3]                           |               +           template-2
     *     ^                               |               +            [1, 2]
     *     |                               |               +
     * upper                               |               +
     * [1, 2, 3]                           |               +
     *     ^<--------------------------|   |               +
     *     |                           |   |               +
     * downer                          |   |               +
     * [1, 2, 3]                       |   |               +
     *     ^<----------------------|   |   |               +
     *     |                       |   |   |               +
     * downest                    downest_wmp              +
     * [1, 2, 3]                    [1, 2, 3]              +
     *                                                     +
     */
@Before
public void setUp() {
    initMocks(this);
    when(systemEnvironment.isFetchArtifactTemplateAutoSuggestEnabled()).thenReturn(true);
    when(systemEnvironment.get(SystemEnvironment.FETCH_ARTIFACT_AUTO_SUGGEST)).thenReturn(true);
    PipelineConfig random = PipelineConfigMother.pipelineConfig("random_pipeline");
    JobConfigs randomJobs = random.getStage(new CaseInsensitiveString("mingle")).getJobs();
    randomJobs.add(new JobConfig("mingle_job"));
    PipelineConfig uppest = PipelineConfigMother.createPipelineConfig("uppest", "uppest_stage_1", "uppest_job_1", "uppest_job_1a");
    uppest.add(StageConfigMother.custom("uppest_stage_2", "uppest_job_2"));
    uppest.add(StageConfigMother.custom("uppest_stage_3", "uppest_job_3"));
    PipelineConfig upper = PipelineConfigMother.createPipelineConfig("upper", "upper_stage_1", "upper_job_1", "upper_job_1a");
    upper.add(StageConfigMother.custom("upper_stage_2", "upper_job_2"));
    upper.add(StageConfigMother.custom("upper_stage_3", "upper_job_3"));
    upper.addMaterialConfig(new DependencyMaterialConfig(new CaseInsensitiveString("uppest"), new CaseInsensitiveString("uppest_stage_2")));
    PipelineConfig downer = PipelineConfigMother.createPipelineConfig("downer", "downer_stage_1", "downer_job_1", "downer_job_1a");
    downer.add(StageConfigMother.custom("downer_stage_2", "downer_job_2"));
    downer.add(StageConfigMother.custom("downer_stage_3", "downer_job_3"));
    downer.addMaterialConfig(new DependencyMaterialConfig(new CaseInsensitiveString("upper"), new CaseInsensitiveString("upper_stage_2")));
    PipelineConfig downest = PipelineConfigMother.createPipelineConfig("downest", "downest_stage_1", "downest_job_1", "downest_job_1a");
    downest.add(StageConfigMother.custom("downest_stage_2", "downest_job_2"));
    downest.add(StageConfigMother.custom("downest_stage_3", "downest_job_3"));
    downest.addMaterialConfig(new DependencyMaterialConfig(new CaseInsensitiveString("downer"), new CaseInsensitiveString("downer_stage_2")));
    PipelineConfig downestWithMultiplePaths = PipelineConfigMother.createPipelineConfig("downest_wmp", "downest_wmp_stage_1", "downest_wmp_job_1", "downest_wmp_job_1a");
    downestWithMultiplePaths.add(StageConfigMother.custom("downest_wmp_stage_2", "downest_wmp_job_2"));
    downestWithMultiplePaths.add(StageConfigMother.custom("downest_wmp_stage_3", "downest_wmp_job_3"));
    downestWithMultiplePaths.addMaterialConfig(new DependencyMaterialConfig(new CaseInsensitiveString("downer"), new CaseInsensitiveString("downer_stage_2")));
    downestWithMultiplePaths.addMaterialConfig(new DependencyMaterialConfig(new CaseInsensitiveString("upper"), new CaseInsensitiveString("upper_stage_2")));
    downestWithMultiplePaths.addMaterialConfig(new DependencyMaterialConfig(new CaseInsensitiveString("random_pipeline"), new CaseInsensitiveString("mingle")));
    PipelineConfig randomOther = PipelineConfigMother.pipelineConfig("randomOther_pipeline");
    JobConfigs randomOtherJobs = randomOther.getStage(new CaseInsensitiveString("mingle")).getJobs();
    randomOtherJobs.add(new JobConfig("mingle_job_from_other_pipeline"));
    TemplatesConfig templates = new TemplatesConfig(new PipelineTemplateConfig(new CaseInsensitiveString("template-1"), StageConfigMother.custom("t1-stage-1", "t1-job-1", "t1-job-1a"), StageConfigMother.custom("t1-stage-2", "t1-job-2"), StageConfigMother.custom("t1-stage-3", "t1-job-3")), new PipelineTemplateConfig(new CaseInsensitiveString("template-2"), StageConfigMother.custom("t2-stage-1", "t2-job-1", "t2-job-1a"), StageConfigMother.custom("t2-stage-2", "t2-job-2")));
    cruiseConfig = configWith(uppest, upper, downer, downest, downestWithMultiplePaths, random, randomOther);
    cruiseConfig.setTemplates(templates);
}
Also used : TemplatesConfig(com.thoughtworks.go.config.TemplatesConfig) PipelineConfig(com.thoughtworks.go.config.PipelineConfig) PipelineTemplateConfig(com.thoughtworks.go.config.PipelineTemplateConfig) JobConfigs(com.thoughtworks.go.config.JobConfigs) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) JobConfig(com.thoughtworks.go.config.JobConfig) Before(org.junit.Before)

Example 7 with JobConfigs

use of com.thoughtworks.go.config.JobConfigs in project gocd by gocd.

the class StageInfoAdapterTest method shouldReturnCorrectAutoApprovedStatus.

@Test
public void shouldReturnCorrectAutoApprovedStatus() throws Exception {
    StageConfig stage = StageConfigMother.custom("dev", new JobConfigs());
    assertThat(stage.requiresApproval(), is(false));
    assertThat(new StageInfoAdapter(stage).isAutoApproved(), is(true));
}
Also used : JobConfigs(com.thoughtworks.go.config.JobConfigs) StageConfig(com.thoughtworks.go.config.StageConfig) Test(org.junit.Test)

Example 8 with JobConfigs

use of com.thoughtworks.go.config.JobConfigs in project gocd by gocd.

the class PipelineTemplateConfigViewModelTest method shouldSetConfigAttributesWithNoExistingPipeline.

@Test
public void shouldSetConfigAttributesWithNoExistingPipeline() {
    PipelineTemplateConfigViewModel viewModel = new PipelineTemplateConfigViewModel();
    Map m = m("template", m(PipelineTemplateConfig.NAME, "template_name"), PipelineTemplateConfigViewModel.USE_EXISTING_PIPELINE, "0", PipelineTemplateConfigViewModel.PIPELINE_NAMES, "quux");
    viewModel.setConfigAttributes(m);
    PipelineTemplateConfig template = viewModel.templateConfig();
    assertThat(template.name(), is(new CaseInsensitiveString("template_name")));
    assertThat(template.size(), is(1));
    assertThat(template.get(0).name().toString(), is(StageConfig.DEFAULT_NAME));
    JobConfigs jobs = template.get(0).getJobs();
    assertThat(jobs.size(), is(1));
    assertThat(jobs.get(0).name().toString(), is(JobConfig.DEFAULT_NAME));
}
Also used : PipelineTemplateConfig(com.thoughtworks.go.config.PipelineTemplateConfig) JobConfigs(com.thoughtworks.go.config.JobConfigs) Map(java.util.Map) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 9 with JobConfigs

use of com.thoughtworks.go.config.JobConfigs in project gocd by gocd.

the class PipelineSqlMapDaoIntegrationTest method shouldNotIncludePipelinesNotUsingUpstreamAsDependencyMaterial_evenIfADependencyRevisionGeneratedOutOfParentPipelineAppearsInPMRrangeForANonDependentPipeline.

@Test
public void shouldNotIncludePipelinesNotUsingUpstreamAsDependencyMaterial_evenIfADependencyRevisionGeneratedOutOfParentPipelineAppearsInPMRrangeForANonDependentPipeline() throws Exception {
    // shine -> cruise(depends on shine)
    // mingle(not related to shine)
    final HgMaterial mingleHg = MaterialsMother.hgMaterial();
    PipelineConfig mingle = PipelineConfigMother.pipelineConfig("mingle", mingleHg.config(), new JobConfigs(new JobConfig("run-tests")));
    PipelineConfig shine = PipelineMother.twoBuildPlansWithResourcesAndMaterials("shine", "compile");
    Pipeline shineInstance = dbHelper.newPipelineWithAllStagesPassed(shine);
    PipelineConfig cruise = pipelineConfigFor("cruise", "shine", "compile");
    final DependencyMaterial cruiseUpstream = new DependencyMaterial(new CaseInsensitiveString("shine"), new CaseInsensitiveString("compile"));
    final Modification cruiseMod = new Modification(new Date(), String.format("shine/%s/compile/%s", shineInstance.getCounter(), shineInstance.getStages().get(0).getCounter()), "shine-1", null);
    final Modification mingleFrom = ModificationsMother.oneModifiedFile("1234");
    saveRev(mingleHg, mingleFrom);
    saveRev(cruiseUpstream, cruiseMod);
    final Modification mingleTo = ModificationsMother.oneModifiedFile("abcd");
    saveRev(mingleHg, mingleTo);
    dbHelper.saveMaterialsWIthPassedStages(instanceFactory.createPipelineInstance(mingle, BuildCause.createManualForced(new MaterialRevisions(new MaterialRevision(mingleHg, mingleTo, mingleFrom)), Username.ANONYMOUS), new DefaultSchedulingContext(GoConstants.DEFAULT_APPROVED_BY), md5, new TimeProvider()));
    final Pipeline cruiseInstance = instanceFactory.createPipelineInstance(cruise, BuildCause.createManualForced(new MaterialRevisions(new MaterialRevision(cruiseUpstream, cruiseMod)), Username.ANONYMOUS), new DefaultSchedulingContext(GoConstants.DEFAULT_APPROVED_BY), md5, new TimeProvider());
    dbHelper.saveMaterialsWIthPassedStages(cruiseInstance);
    PipelineDependencyGraphOld dependencyGraph = pipelineDao.pipelineGraphByNameAndCounter("shine", shineInstance.getCounter());
    assertPipelineEquals(shineInstance, dependencyGraph.pipeline());
    ensureBuildCauseIsLoadedFor(dependencyGraph.pipeline());
    PipelineInstanceModels dependencies = dependencyGraph.dependencies();
    assertThat(dependencies.size(), is(1));
    assertPipelineEquals(cruiseInstance, dependencies.find("cruise"));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) PipelineConfig(com.thoughtworks.go.config.PipelineConfig) JobConfig(com.thoughtworks.go.config.JobConfig) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Date(java.util.Date) PipelineInstanceModels(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels) JobConfigs(com.thoughtworks.go.config.JobConfigs) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) DependencyMaterialRevision(com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision) Test(org.junit.Test)

Example 10 with JobConfigs

use of com.thoughtworks.go.config.JobConfigs in project gocd by gocd.

the class BuildPlansTest method shouldNotBombIfABuildPlanWithSameNameIsSetAgain.

@Test
public void shouldNotBombIfABuildPlanWithSameNameIsSetAgain() throws Exception {
    JobConfigs jobConfigs = new JobConfigs();
    jobConfigs.add(jobConfig("Test"));
    jobConfigs.set(0, jobConfig("Test"));
}
Also used : JobConfigs(com.thoughtworks.go.config.JobConfigs) Test(org.junit.Test)

Aggregations

JobConfigs (com.thoughtworks.go.config.JobConfigs)11 Test (org.junit.Test)7 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)5 JobConfig (com.thoughtworks.go.config.JobConfig)4 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)3 PipelineTemplateConfig (com.thoughtworks.go.config.PipelineTemplateConfig)2 StageConfig (com.thoughtworks.go.config.StageConfig)2 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)2 DependencyMaterialRevision (com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision)2 TemplatesConfig (com.thoughtworks.go.config.TemplatesConfig)1 Materials (com.thoughtworks.go.config.materials.Materials)1 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)1 HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)1 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)1 Modification (com.thoughtworks.go.domain.materials.Modification)1 PipelineInstanceModels (com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels)1 PipelineConfigDependencyGraph (com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph)1 Date (java.util.Date)1 Map (java.util.Map)1 Before (org.junit.Before)1