Search in sources :

Example 6 with PipelineTemplateConfig

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

the class TemplateConfigCommandTest method shouldValidateTemplateName.

@Test
public void shouldValidateTemplateName() {
    PipelineTemplateConfig templateConfig = new PipelineTemplateConfig(new CaseInsensitiveString("@#$#"), StageConfigMother.oneBuildPlanWithResourcesAndMaterials("stage", "job"));
    cruiseConfig.addTemplate(templateConfig);
    TemplateConfigCommand command = new CreateTemplateConfigCommand(templateConfig, currentUser, goConfigService, result);
    assertThat(command.isValid(cruiseConfig), is(false));
    assertThat(templateConfig.errors().getAllOn("name"), is(Arrays.asList("Invalid template name '@#$#'. This must be alphanumeric and can contain underscores and periods (however, it cannot start with a period). The maximum allowed length is 255 characters.")));
}
Also used : PipelineTemplateConfig(com.thoughtworks.go.config.PipelineTemplateConfig) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 7 with PipelineTemplateConfig

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

the class DeleteTemplateConfigCommandTest method setup.

@Before
public void setup() {
    initMocks(this);
    currentUser = new Username(new CaseInsensitiveString("user"));
    cruiseConfig = new GoConfigMother().defaultCruiseConfig();
    pipelineTemplateConfig = new PipelineTemplateConfig(new CaseInsensitiveString("template"), StageConfigMother.oneBuildPlanWithResourcesAndMaterials("stage", "job"));
    result = new HttpLocalizedOperationResult();
}
Also used : HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) Username(com.thoughtworks.go.server.domain.Username) PipelineTemplateConfig(com.thoughtworks.go.config.PipelineTemplateConfig) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) GoConfigMother(com.thoughtworks.go.helper.GoConfigMother) Before(org.junit.Before)

Example 8 with PipelineTemplateConfig

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

the class PipelineTemplateConfigViewModelTest method shouldReturnStringNamesOfPipelines.

@Test
public void shouldReturnStringNamesOfPipelines() {
    PipelineTemplateConfigViewModel viewModel = new PipelineTemplateConfigViewModel(new PipelineTemplateConfig(), "", Arrays.asList(PipelineConfigMother.pipelineConfig("pipeline_1"), PipelineConfigMother.pipelineConfig(".pipeline.2")));
    assertThat(viewModel.pipelineNames(), is(Arrays.asList("pipeline_1", ".pipeline.2")));
    viewModel = new PipelineTemplateConfigViewModel();
    assertThat(viewModel.pipelineNames(), is(new ArrayList<String>()));
}
Also used : PipelineTemplateConfig(com.thoughtworks.go.config.PipelineTemplateConfig) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 9 with PipelineTemplateConfig

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

the class PipelineTemplateConfigViewModelTest method shouldSetConfigAttributesBasedOnExistingPipeline.

@Test
public void shouldSetConfigAttributesBasedOnExistingPipeline() {
    StageConfig stage1 = StageConfigMother.custom("stage_foo", "foo1", "foo2");
    StageConfig stage2 = StageConfigMother.custom("stage_bar", "bar1", "bar2");
    PipelineConfig pipeline = PipelineConfigMother.pipelineConfig("pipeline", stage1, stage2);
    PipelineTemplateConfigViewModel viewModel = new PipelineTemplateConfigViewModel(new PipelineTemplateConfig(), "", Arrays.asList(PipelineConfigMother.pipelineConfig("foo_bar"), pipeline));
    Map m = m("template", m(PipelineTemplateConfig.NAME, "template_name"), PipelineTemplateConfigViewModel.USE_EXISTING_PIPELINE, "1", PipelineTemplateConfigViewModel.SELECTED_PIPELINE_NAME, pipeline.name().toString());
    viewModel.setConfigAttributes(m);
    assertThat(viewModel.useExistingPipeline(), is(true));
    assertThat(viewModel.selectedPipelineName(), is(pipeline.name().toString()));
    PipelineTemplateConfig template = viewModel.templateConfig();
    assertThat(template.name(), is(new CaseInsensitiveString("template_name")));
    assertThat(template.size(), is(2));
    assertThat(template.get(0), is(stage1));
    assertThat(template.get(1), is(stage2));
}
Also used : PipelineConfig(com.thoughtworks.go.config.PipelineConfig) PipelineTemplateConfig(com.thoughtworks.go.config.PipelineTemplateConfig) Map(java.util.Map) StageConfig(com.thoughtworks.go.config.StageConfig) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 10 with PipelineTemplateConfig

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

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