use of com.thoughtworks.go.domain.PipelineDependencyGraphOld in project gocd by gocd.
the class PipelineDependencyGraphOldTest method shouldProvideMaterialRevisionForAGivenDownStreamPipeline.
@Test
public void shouldProvideMaterialRevisionForAGivenDownStreamPipeline() throws Exception {
StageInstanceModels stages = new StageInstanceModels();
stages.add(new StageInstanceModel("stage-0", "21", StageResult.Cancelled, new StageIdentifier("blahUpStream", 23, "stage-0", "21")));
stages.add(new StageInstanceModel("stage-1", "2", StageResult.Cancelled, new StageIdentifier("blahUpStream", 23, "stage-1", "2")));
PipelineInstanceModel upStream = PipelineHistoryMother.singlePipeline("blahUpStream", stages);
PipelineInstanceModel down1 = pim("blahDown1");
down1.setMaterialConfigs(new MaterialConfigs(dependencyMaterialConfig("blahUpStream", "stage-0")));
PipelineInstanceModel down2 = pim("blahDown2");
down2.setMaterialConfigs(new MaterialConfigs(dependencyMaterialConfig("blahUpStream", "stage-1")));
PipelineDependencyGraphOld graph = new PipelineDependencyGraphOld(upStream, PipelineInstanceModels.createPipelineInstanceModels(down1, down2));
assertThat(graph.dependencyRevisionFor(down1), is("blahUpStream/23/stage-0/21"));
assertThat(graph.dependencyRevisionFor(down2), is("blahUpStream/23/stage-1/2"));
}
use of com.thoughtworks.go.domain.PipelineDependencyGraphOld in project gocd by gocd.
the class PipelineDependencyGraphOldTest method shouldShouldbeAbleToTellIfUpStreamMaterialIsAvailableForTrigger.
@Test
public void shouldShouldbeAbleToTellIfUpStreamMaterialIsAvailableForTrigger() throws Exception {
StageInstanceModels stages = new StageInstanceModels();
stages.add(new StageInstanceModel("stage-0", "21", StageResult.Cancelled, new StageIdentifier("blahUpStream", 23, "stage-0", "21")));
PipelineInstanceModel upStream = PipelineHistoryMother.singlePipeline("blahUpStream", stages);
PipelineInstanceModel down1 = pim("blahDown1");
down1.setMaterialConfigs(new MaterialConfigs(dependencyMaterialConfig("blahUpStream", "stage-1")));
PipelineDependencyGraphOld graph = new PipelineDependencyGraphOld(upStream, PipelineInstanceModels.createPipelineInstanceModels(down1));
assertThat(graph.hasUpStreamRevisionFor(down1), is(false));
}
use of com.thoughtworks.go.domain.PipelineDependencyGraphOld in project gocd by gocd.
the class PipelineDependencyGraphOldTest method assertThatTriggerIsPossibleOnlyIfUpStreamPassed.
private void assertThatTriggerIsPossibleOnlyIfUpStreamPassed(StageResult upstreamResult) {
StageInstanceModels stages = new StageInstanceModels();
stages.add(new StageInstanceModel("stage-0", "21", upstreamResult, new StageIdentifier("blahUpStream", 23, "stage-0", "21")));
PipelineInstanceModel upStream = PipelineHistoryMother.singlePipeline("blahUpStream", stages);
PipelineInstanceModel down1 = pim("blahDown1");
down1.setMaterialConfigs(new MaterialConfigs(dependencyMaterialConfig("blahUpStream", "stage-0")));
PipelineDependencyGraphOld graph = new PipelineDependencyGraphOld(upStream, PipelineInstanceModels.createPipelineInstanceModels(down1));
assertThat(graph.hasUpStreamRevisionFor(graph.dependencies().find("blahDown1")), is(upstreamResult == StageResult.Passed));
}
use of com.thoughtworks.go.domain.PipelineDependencyGraphOld in project gocd by gocd.
the class PipelineDependencyGraphOldTest method shouldGroupPiplineInstancesByName.
@Test
public void shouldGroupPiplineInstancesByName() throws Exception {
PipelineInstanceModel raghu1 = pim("raghu");
raghu1.setCounter(1);
PipelineInstanceModel raghu2 = pim("raghu");
raghu2.setCounter(2);
PipelineInstanceModel phavan = pim("pavan");
PipelineDependencyGraphOld graph = new PipelineDependencyGraphOld(pim("upstream"), PipelineInstanceModels.createPipelineInstanceModels(raghu2, phavan, raghu1));
Map<String, TreeSet<PipelineInstanceModel>> map = graph.groupedDependencies();
assertThat(map.size(), is(2));
assertOrderIsMainted(map);
assertThat(map.get("pavan").size(), is(1));
assertThat(map.get("pavan"), hasItem(phavan));
assertThat(map.get("raghu").size(), is(2));
assertThat(map.get("raghu").first(), is(raghu2));
assertThat(map.get("raghu").last(), is(raghu1));
}
use of com.thoughtworks.go.domain.PipelineDependencyGraphOld in project gocd by gocd.
the class PipelineDependencyGraphOldTest method shouldFilterPIMS.
@Test
public void shouldFilterPIMS() throws Exception {
PipelineDependencyGraphOld graph = new PipelineDependencyGraphOld(pim("upstream"), PipelineInstanceModels.createPipelineInstanceModels(pim("pavan"), pim("raghu")));
PipelineDependencyGraphOld.Filterer filterer = mock(PipelineDependencyGraphOld.Filterer.class);
when(filterer.filterPipeline("raghu")).thenReturn(false);
when(filterer.filterPipeline("pavan")).thenReturn(true);
graph.filterDependencies(filterer);
PipelineInstanceModels models = graph.dependencies();
assertThat(models.size(), is(1));
assertThat(models.get(0).getName(), is("pavan"));
}
Aggregations