use of com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig in project gocd by gocd.
the class DependencyMaterialUpdateNotifierTest method shouldScheduleOnlyNewDepenedencyMaterialsForUpdateOnSubsequentConfigChanges.
@Test
public void shouldScheduleOnlyNewDepenedencyMaterialsForUpdateOnSubsequentConfigChanges() {
DependencyMaterial dependencyMaterialForP1S1 = MaterialsMother.dependencyMaterial("p1", "s1");
Set<DependencyMaterialConfig> schedulableMaterialConfigs = new HashSet<>(Arrays.asList((DependencyMaterialConfig) dependencyMaterialForP1S1.config()));
when(goConfigService.getSchedulableDependencyMaterials()).thenReturn(schedulableMaterialConfigs);
when(materialConfigConverter.toMaterial(dependencyMaterialForP1S1.config())).thenReturn(dependencyMaterialForP1S1);
notifier = new DependencyMaterialUpdateNotifier(goConfigService, materialConfigConverter, materialUpdateService, serverHealthService);
notifier.initialize();
DependencyMaterial dependencyMaterialForP2S2 = MaterialsMother.dependencyMaterial("p2", "s2");
schedulableMaterialConfigs = new HashSet<>(Arrays.asList((DependencyMaterialConfig) dependencyMaterialForP2S2.config()));
when(goConfigService.getSchedulableDependencyMaterials()).thenReturn(schedulableMaterialConfigs);
when(materialConfigConverter.toMaterial(dependencyMaterialForP2S2.config())).thenReturn(dependencyMaterialForP2S2);
notifier.onConfigChange(mock(CruiseConfig.class));
verify(materialUpdateService).updateMaterial(dependencyMaterialForP2S2);
}
use of com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig in project gocd by gocd.
the class DependencyMaterialUpdateNotifierTest method shouldRetryUpdatingMaterialsPreviouslyInProgress_OnMaterialUpdate.
@Test
public void shouldRetryUpdatingMaterialsPreviouslyInProgress_OnMaterialUpdate() {
Stage stage = StageMother.passedStageInstance("Stage1", "plan", "Pipeline1");
DependencyMaterial dependencyMaterial = MaterialsMother.dependencyMaterial(stage.getIdentifier().getPipelineName(), stage.getName());
Set<DependencyMaterialConfig> schedulableMaterialConfigs = new HashSet<>(Arrays.asList((DependencyMaterialConfig) dependencyMaterial.config()));
when(goConfigService.getSchedulableDependencyMaterials()).thenReturn(schedulableMaterialConfigs);
when(materialConfigConverter.toMaterial(dependencyMaterial.config())).thenReturn(dependencyMaterial);
when(materialUpdateService.updateMaterial(dependencyMaterial)).thenReturn(true, false);
notifier = new DependencyMaterialUpdateNotifier(goConfigService, materialConfigConverter, materialUpdateService, serverHealthService);
notifier.initialize();
notifier.stageStatusChanged(stage);
notifier.onMaterialUpdate(dependencyMaterial);
verify(materialUpdateService, atMost(3)).updateMaterial(dependencyMaterial);
}
use of com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig in project gocd by gocd.
the class GoConfigServiceTest method shouldReturnUpstreamDependencyGraphForAGivenPipeline.
@Test
public void shouldReturnUpstreamDependencyGraphForAGivenPipeline() throws Exception {
PipelineConfig current = GoConfigMother.createPipelineConfigWithMaterialConfig("current", new DependencyMaterialConfig(new CaseInsensitiveString("up1"), new CaseInsensitiveString("first")), new DependencyMaterialConfig(new CaseInsensitiveString("up2"), new CaseInsensitiveString("first")));
PipelineConfig up1 = GoConfigMother.createPipelineConfigWithMaterialConfig("up1", new DependencyMaterialConfig(new CaseInsensitiveString("uppest"), new CaseInsensitiveString("first")));
PipelineConfig up2 = GoConfigMother.createPipelineConfigWithMaterialConfig("up2", new DependencyMaterialConfig(new CaseInsensitiveString("uppest"), new CaseInsensitiveString("first")));
PipelineConfig uppest = GoConfigMother.createPipelineConfigWithMaterialConfig("uppest", MaterialConfigsMother.hgMaterialConfig());
when(goConfigDao.load()).thenReturn(configWith(current, up1, up2, uppest));
assertThat(goConfigService.upstreamDependencyGraphOf("current"), is(new PipelineConfigDependencyGraph(current, new PipelineConfigDependencyGraph(up1, new PipelineConfigDependencyGraph(uppest)), new PipelineConfigDependencyGraph(up2, new PipelineConfigDependencyGraph(uppest)))));
/*
uppest
/ \
up1 up2
\ /
current
*/
}
use of com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig in project gocd by gocd.
the class GoConfigServiceTest method shouldReturnNullIfNoMaterialMatches.
@Test
public void shouldReturnNullIfNoMaterialMatches() throws Exception {
DependencyMaterialConfig dependencyMaterialConfig = new DependencyMaterialConfig(new CaseInsensitiveString("upstream-pipeline"), new CaseInsensitiveString("upstream-stage"));
cruiseConfig = configWith(GoConfigMother.createPipelineConfigWithMaterialConfig(dependencyMaterialConfig));
when(goConfigDao.load()).thenReturn(cruiseConfig);
assertThat(goConfigService.findMaterial(new CaseInsensitiveString("pipeline"), "missing"), is(nullValue()));
}
use of com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig in project gocd by gocd.
the class GoConfigServiceTest method shouldReturnDependentPiplinesForAGivenPipeline.
@Test
public void shouldReturnDependentPiplinesForAGivenPipeline() throws Exception {
PipelineConfig up = createPipelineConfig("blahPipeline", "blahStage");
up.addMaterialConfig(MaterialConfigsMother.hgMaterialConfig());
PipelineConfig down1 = GoConfigMother.createPipelineConfigWithMaterialConfig("down1", new DependencyMaterialConfig(new CaseInsensitiveString("blahPipeline"), new CaseInsensitiveString("blahStage")));
PipelineConfig down2 = GoConfigMother.createPipelineConfigWithMaterialConfig("down2", new DependencyMaterialConfig(new CaseInsensitiveString("blahPipeline"), new CaseInsensitiveString("blahStage")));
when(goConfigDao.load()).thenReturn(configWith(up, down1, down2, GoConfigMother.createPipelineConfigWithMaterialConfig("otherPipeline", new DependencyMaterialConfig(new CaseInsensitiveString("someotherpipeline"), new CaseInsensitiveString("blahStage")))));
assertThat(goConfigService.downstreamPipelinesOf("blahPipeline"), is(Arrays.asList(down1, down2)));
}
Aggregations