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.")));
}
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();
}
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>()));
}
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));
}
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));
}
Aggregations