Search in sources :

Example 1 with PipelineTemplateConfig

use of com.thoughtworks.go.config.PipelineTemplateConfig 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 2 with PipelineTemplateConfig

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

the class TemplateConfigCommandTest method shouldThrowAnExceptionIfTemplateConfigCannotBeFound.

@Test
public void shouldThrowAnExceptionIfTemplateConfigCannotBeFound() {
    PipelineTemplateConfig templateConfig = new PipelineTemplateConfig(new CaseInsensitiveString("non-existent-template"), StageConfigMother.oneBuildPlanWithResourcesAndMaterials("stage", "job"));
    TemplateConfigCommand command = new CreateTemplateConfigCommand(templateConfig, currentUser, goConfigService, result);
    thrown.expectMessage("The template with name 'non-existent-template' is not found.");
    command.isValid(cruiseConfig);
    assertThat(result.toString(), containsString("RESOURCE_NOT_FOUND"));
}
Also used : PipelineTemplateConfig(com.thoughtworks.go.config.PipelineTemplateConfig) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 3 with PipelineTemplateConfig

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

the class TemplateConfigCommandTest method shouldValidateUniquenessOfTemplateName.

@Test
public void shouldValidateUniquenessOfTemplateName() {
    PipelineTemplateConfig templateConfig1 = new PipelineTemplateConfig(new CaseInsensitiveString("template"), StageConfigMother.oneBuildPlanWithResourcesAndMaterials("stage", "job"));
    PipelineTemplateConfig templateConfig2 = new PipelineTemplateConfig(new CaseInsensitiveString("template"), StageConfigMother.oneBuildPlanWithResourcesAndMaterials("stage", "job"));
    cruiseConfig.addTemplate(templateConfig1);
    cruiseConfig.addTemplate(templateConfig2);
    TemplateConfigCommand command = new CreateTemplateConfigCommand(templateConfig2, currentUser, goConfigService, result);
    assertThat(command.isValid(cruiseConfig), is(false));
    assertThat(templateConfig2.errors().getAllOn("name"), is(Arrays.asList("Template name 'template' is not unique")));
}
Also used : PipelineTemplateConfig(com.thoughtworks.go.config.PipelineTemplateConfig) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 4 with PipelineTemplateConfig

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

the class TemplateConfigCommandTest method shouldValidateIfTemplateNameIsNull.

@Test
public void shouldValidateIfTemplateNameIsNull() {
    PipelineTemplateConfig templateConfig = new PipelineTemplateConfig(null, StageConfigMother.oneBuildPlanWithResourcesAndMaterials("stage", "job"));
    cruiseConfig.addTemplate(templateConfig);
    TemplateConfigCommand command = new CreateTemplateConfigCommand(templateConfig, currentUser, goConfigService, result);
    thrown.expectMessage("Template name cannot be null.");
    command.isValid(cruiseConfig);
}
Also used : PipelineTemplateConfig(com.thoughtworks.go.config.PipelineTemplateConfig) Test(org.junit.Test)

Example 5 with PipelineTemplateConfig

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

the class TemplateConfigCommandTest method shouldValidateStageNameUniquenessWithinATemplate.

@Test
public void shouldValidateStageNameUniquenessWithinATemplate() {
    PipelineTemplateConfig templateConfig = new PipelineTemplateConfig(new CaseInsensitiveString("template"), StageConfigMother.oneBuildPlanWithResourcesAndMaterials("stage", "job"), StageConfigMother.oneBuildPlanWithResourcesAndMaterials("stage", "job"));
    cruiseConfig.addTemplate(templateConfig);
    TemplateConfigCommand command = new CreateTemplateConfigCommand(templateConfig, currentUser, goConfigService, result);
    assertThat(command.isValid(cruiseConfig), is(false));
    assertThat(templateConfig.getStage(new CaseInsensitiveString("stage")).errors().getAllOn("name"), is(Arrays.asList("You have defined multiple stages called 'stage'. Stage names are case-insensitive and must be unique.")));
}
Also used : PipelineTemplateConfig(com.thoughtworks.go.config.PipelineTemplateConfig) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Aggregations

PipelineTemplateConfig (com.thoughtworks.go.config.PipelineTemplateConfig)11 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)9 Test (org.junit.Test)8 Before (org.junit.Before)3 JobConfigs (com.thoughtworks.go.config.JobConfigs)2 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)2 GoConfigMother (com.thoughtworks.go.helper.GoConfigMother)2 Username (com.thoughtworks.go.server.domain.Username)2 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)2 Map (java.util.Map)2 JobConfig (com.thoughtworks.go.config.JobConfig)1 StageConfig (com.thoughtworks.go.config.StageConfig)1 TemplatesConfig (com.thoughtworks.go.config.TemplatesConfig)1 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)1 ArrayList (java.util.ArrayList)1