use of com.thoughtworks.go.domain.Pipeline 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.domain.Pipeline in project gocd by gocd.
the class PipelineServiceTriangleDependencyTest method stubPipelineSaveForStatusListener.
private Pipeline stubPipelineSaveForStatusListener(StageStatusListener stageStatusListener, JobStatusListener jobStatusListener) {
StageDao stageDao = mock(StageDao.class);
ServerHealthService serverHealthService = mock(ServerHealthService.class);
when(serverHealthService.logs()).thenReturn(new ServerHealthStates());
JobInstanceService jobInstanceService = new JobInstanceService(mock(JobInstanceDao.class), mock(PropertiesService.class), mock(JobResultTopic.class), mock(JobStatusCache.class), actualTransactionTemplate, transactionSynchronizationManager, null, null, goConfigService, null, pluginManager, serverHealthService, jobStatusListener);
StageService stageService = new StageService(stageDao, jobInstanceService, mock(StageStatusTopic.class), mock(StageStatusCache.class), mock(SecurityService.class), mock(PipelineDao.class), mock(ChangesetService.class), mock(GoConfigService.class), actualTransactionTemplate, transactionSynchronizationManager, goCache);
Stage savedStage = StageMother.passedStageInstance("stage", "job", "pipeline-name");
when(stageDao.save(any(Pipeline.class), any(Stage.class))).thenReturn(savedStage);
stageService.addStageStatusListener(stageStatusListener);
service = new PipelineService(pipelineDao, stageService, mock(PipelineLockService.class), pipelineTimeline, materialRepository, actualTransactionTemplate, systemEnvironment, null, materialConfigConverter);
Pipeline pipeline = PipelineMother.pipeline("cruise", savedStage);
when(pipelineDao.save(pipeline)).thenReturn(pipeline);
when(pipelineTimeline.pipelineBefore(anyLong())).thenReturn(9L);
when(pipelineTimeline.pipelineAfter(pipeline.getId())).thenReturn(-1L);
when(materialRepository.findMaterialRevisionsForPipeline(9L)).thenReturn(MaterialRevisions.EMPTY);
return pipeline;
}
use of com.thoughtworks.go.domain.Pipeline 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.domain.Pipeline in project gocd by gocd.
the class PropertiesServiceTest method shouldReturnEmptyListIfLimitCountIsNotPositive.
@Test
public void shouldReturnEmptyListIfLimitCountIsNotPositive() {
Pipeline pipeline1 = createNewPipeline();
Pipeline pipeline2 = createNewPipeline();
List<Properties> propertiesList = propertiesService.loadHistory(fixture.pipelineName, fixture.devStage, PipelineWithTwoStages.JOB_FOR_DEV_STAGE, pipeline2.getId(), -1);
assertThat(propertiesList.size(), is(0));
propertiesList = propertiesService.loadHistory(fixture.pipelineName, fixture.devStage, PipelineWithTwoStages.JOB_FOR_DEV_STAGE, pipeline2.getId(), 0);
assertThat(propertiesList.size(), is(0));
}
use of com.thoughtworks.go.domain.Pipeline in project gocd by gocd.
the class PropertiesServiceTest method shouldLoadHistoryUptoSpecifiedPipeline.
@Test
public void shouldLoadHistoryUptoSpecifiedPipeline() {
Pipeline pipeline1 = createNewPipeline();
Pipeline pipeline2 = createNewPipeline();
List<Properties> propertiesList = propertiesService.loadHistory(fixture.pipelineName, fixture.devStage, PipelineWithTwoStages.JOB_FOR_DEV_STAGE, pipeline2.getId(), 1);
assertThat(propertiesList.size(), is(1));
assertThat(propertiesList.get(0).getValue("cruise_pipeline_counter"), is(String.valueOf(pipeline2.getCounter())));
}
Aggregations