use of com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig in project gocd by gocd.
the class ConfigConverterTest method shouldConvertDependencyMaterial.
@Test
public void shouldConvertDependencyMaterial() {
CRDependencyMaterial crDependencyMaterial = new CRDependencyMaterial("name", "pipe", "stage");
DependencyMaterialConfig dependencyMaterialConfig = (DependencyMaterialConfig) configConverter.toMaterialConfig(crDependencyMaterial, context);
assertThat(dependencyMaterialConfig.getName().toLower(), is("name"));
assertThat(dependencyMaterialConfig.getPipelineName().toLower(), is("pipe"));
assertThat(dependencyMaterialConfig.getStageName().toLower(), is("stage"));
}
use of com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig in project gocd by gocd.
the class PipelineServiceTriangleDependencyTest method shouldNotGetTheRevisionsFromUpStreamPipelineIfTheDependencyMaterialHasNotChanged.
@Test
public void shouldNotGetTheRevisionsFromUpStreamPipelineIfTheDependencyMaterialHasNotChanged() throws Exception {
MaterialRevisions expected = createHgMaterialWithMultipleRevisions(1L, first);
MaterialRevision up1Revision = dependencyMaterialRevision("up1", 1, "label", "stage", 1, new Date());
expected.addRevision(up1Revision);
MaterialRevisions actual = createHgMaterialWithMultipleRevisions(1L, third);
actual.addRevision(up1Revision);
up1Revision.markAsNotChanged();
PipelineConfig current = createPipelineConfigWithMaterialConfig("current", actual.getMaterials().get(0).config(), new DependencyMaterialConfig(new CaseInsensitiveString("up1"), new CaseInsensitiveString("first")));
PipelineConfig up1 = createPipelineConfigWithMaterialConfig("up1", expected.getMaterials().get(0).config());
when(pipelineDao.findBuildCauseOfPipelineByNameAndCounter("up1", 1)).thenReturn(BuildCause.createManualForced(expected, new Username(str("loser"))));
PipelineConfigDependencyGraph dependencyGraph = new PipelineConfigDependencyGraph(current, new PipelineConfigDependencyGraph(up1));
assertThat(service.getRevisionsBasedOnDependencies(dependencyGraph, actual), is(actual));
}
use of com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig in project gocd by gocd.
the class PipelineServiceTriangleDependencyTest method shouldGetTheRevisionsForDependencyMaterialFromUpStreamPipeline.
@Test
public void shouldGetTheRevisionsForDependencyMaterialFromUpStreamPipeline() throws Exception {
Date modifiedTime = new Date();
MaterialRevisions expected = new MaterialRevisions();
expected.addRevision(dependencyMaterialRevision("up1", 1, "label", "stage", 1, modifiedTime));
expected.addRevision(dependencyMaterialRevision("common", 3, "label", "first", 1, modifiedTime));
MaterialRevisions actual = new MaterialRevisions();
actual.addRevision(changedDependencyMaterialRevision("up1", 1, "label", "stage", 1, modifiedTime));
actual.addRevision(dependencyMaterialRevision("common", 4, "label", "first", 1, modifiedTime));
PipelineConfig current = createPipelineConfigWithMaterialConfig("current", new DependencyMaterialConfig(new CaseInsensitiveString("common"), new CaseInsensitiveString("first")), new DependencyMaterialConfig(new CaseInsensitiveString("up1"), new CaseInsensitiveString("first")));
PipelineConfig up1 = createPipelineConfigWithMaterialConfig("up1", new DependencyMaterialConfig(new CaseInsensitiveString("common"), new CaseInsensitiveString("first")));
PipelineConfig common = createPipelineConfigWithMaterialConfig("common", MaterialConfigsMother.hgMaterialConfig());
Pipeline pipeline = PipelineMother.passedPipelineInstance("up1", "stage", "job");
pipeline.setId(10);
when(pipelineDao.findPipelineByNameAndCounter("up1", 1)).thenReturn(pipeline);
MaterialRevisions upStreamPipelinesRevisions = new MaterialRevisions();
upStreamPipelinesRevisions.addRevision(dependencyMaterialRevision("common", 3, "label", "first", 1, modifiedTime));
when(materialRepository.findMaterialRevisionsForPipeline(10)).thenReturn(upStreamPipelinesRevisions);
PipelineConfigDependencyGraph dependencyGraph = new PipelineConfigDependencyGraph(current, new PipelineConfigDependencyGraph(up1, new PipelineConfigDependencyGraph(common)));
MaterialRevisions finalRevisions = service.getRevisionsBasedOnDependencies(dependencyGraph, actual);
assertThat(finalRevisions, is(expected));
for (int i = 0; i < expected.numberOfRevisions(); i++) {
assertTrue(finalRevisions.getMaterialRevision(i) == actual.getMaterialRevision(i));
}
}
use of com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig in project gocd by gocd.
the class PipelineServiceTriangleDependencyTest method shouldGetTheRevisionsFromTheUpStreamPipelineFor2SameMaterial.
@Test
public void shouldGetTheRevisionsFromTheUpStreamPipelineFor2SameMaterial() throws Exception {
MaterialRevision up1Revision = dependencyMaterialRevision("up1", 1, "label", "stage", 1, new Date());
up1Revision.markAsChanged();
MaterialRevisions expected = new MaterialRevisions();
expected.addRevision(up1Revision);
expected.addAll(createHgMaterialWithMultipleRevisions(1L, first));
expected.addAll(createSvnMaterialWithMultipleRevisions(2L, first));
MaterialRevisions actual = new MaterialRevisions();
actual.addRevision(up1Revision);
actual.addAll(createHgMaterialWithMultipleRevisions(1L, third));
actual.addAll(createSvnMaterialWithMultipleRevisions(2L, third));
PipelineConfig current = createPipelineConfigWithMaterialConfig("current", new DependencyMaterialConfig(new CaseInsensitiveString("up1"), new CaseInsensitiveString("first")), MaterialConfigsMother.hgMaterialConfig(), MaterialConfigsMother.svnMaterialConfig());
PipelineConfig up1 = createPipelineConfigWithMaterialConfig("up1", MaterialConfigsMother.hgMaterialConfig(), MaterialConfigsMother.svnMaterialConfig());
Pipeline pipeline = PipelineMother.passedPipelineInstance("up1", "stage", "job");
pipeline.setId(10);
when(pipelineDao.findPipelineByNameAndCounter("up1", 1)).thenReturn(pipeline);
when(materialRepository.findMaterialRevisionsForPipeline(10)).thenReturn(expected);
PipelineConfigDependencyGraph dependencyGraph = new PipelineConfigDependencyGraph(current, new PipelineConfigDependencyGraph(up1));
assertThat(service.getRevisionsBasedOnDependencies(dependencyGraph, actual), is(expected));
}
use of com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig in project gocd by gocd.
the class PipelineConfigServiceIntegrationTest method shouldShowThePipelineConfigErrorMessageWhenPipelineBeingCreatedHasErrorsOnEnvironmentVariables.
@Test
public void shouldShowThePipelineConfigErrorMessageWhenPipelineBeingCreatedHasErrorsOnEnvironmentVariables() throws GitAPIException {
PipelineConfig pipeline = GoConfigMother.createPipelineConfigWithMaterialConfig(UUID.randomUUID().toString(), new DependencyMaterialConfig(pipelineConfig.name(), pipelineConfig.first().name()));
pipeline.addEnvironmentVariable("", "PipelineEnvVar");
EnvironmentVariablesConfig stageVariables = new EnvironmentVariablesConfig();
EnvironmentVariableConfig stageVar = new EnvironmentVariableConfig("", "StageEnvVar");
stageVariables.add(stageVar);
EnvironmentVariablesConfig jobVariables = new EnvironmentVariablesConfig();
EnvironmentVariableConfig jobVar = new EnvironmentVariableConfig("", "JobEnvVar");
jobVariables.add(jobVar);
StageConfig stageConfig = pipeline.get(0);
stageConfig.setVariables(stageVariables);
JobConfig jobConfig = stageConfig.getJobs().get(0);
jobConfig.setVariables(jobVariables);
pipelineConfigService.createPipelineConfig(user, pipeline, result, groupName);
assertThat(result.toString(), result.isSuccessful(), is(false));
assertThat(result.httpCode(), is(422));
assertThat(pipeline.getVariables().get(0).errors().firstError(), is(String.format("Environment Variable cannot have an empty name for pipeline '" + pipeline.name() + "'.", pipeline.name())));
assertThat(stageVar.errors().firstError(), is(String.format("Environment Variable cannot have an empty name for stage 'stage'.", pipeline.name())));
assertThat(jobVar.errors().firstError(), is(String.format("Environment Variable cannot have an empty name for job 'job'.", pipeline.name())));
}
Aggregations