use of com.thoughtworks.go.domain.materials.Modifications in project gocd by gocd.
the class ValueStreamMapServiceTest method shouldPopulateRevisionsForUpstreamPipelines.
@Test
public void shouldPopulateRevisionsForUpstreamPipelines() {
/*
* git---> p1 ---> p3
* | v ^
* +---> p2 -----+
* **/
GitMaterial git = new GitMaterial("git");
MaterialConfig gitConfig = git.config();
BuildCause p3buildCause = createBuildCause(asList("p1", "p2"), new ArrayList<>());
BuildCause p2buildCause = createBuildCauseForRevisions(asList(dependencyMaterial("p1", 2)), asList(git), ModificationsMother.multipleModificationList(0));
BuildCause p1buildCause = createBuildCause(new ArrayList<>(), asList(git));
Modifications modifications = p1buildCause.getMaterialRevisions().getMaterialRevision(0).getModifications();
when(pipelineService.buildCauseFor("p3", 1)).thenReturn(p3buildCause);
when(pipelineService.buildCauseFor("p2", 1)).thenReturn(p2buildCause);
when(pipelineService.buildCauseFor("p1", 1)).thenReturn(p1buildCause);
when(pipelineService.buildCauseFor("p1", 2)).thenReturn(p1buildCause);
PipelineConfig p1Config = PipelineConfigMother.pipelineConfig("p1", new MaterialConfigs(gitConfig));
PipelineConfig p2Config = PipelineConfigMother.pipelineConfig("p2", new MaterialConfigs(gitConfig));
PipelineConfig p3Config = PipelineConfigMother.pipelineConfig("p3", new MaterialConfigs(new DependencyMaterialConfig(p1Config.name(), p1Config.getFirstStageConfig().name()), new DependencyMaterialConfig(p2Config.name(), p2Config.getFirstStageConfig().name())));
CruiseConfig cruiseConfig = new BasicCruiseConfig(new BasicPipelineConfigs(p1Config, p2Config, p3Config));
when(pipelineService.findPipelineByCounterOrLabel("p3", "1")).thenReturn(new Pipeline("p3", "LABEL-P3", p3buildCause));
when(goConfigService.currentCruiseConfig()).thenReturn(cruiseConfig);
ValueStreamMapPresentationModel graph = valueStreamMapService.getValueStreamMap("p3", 1, user, result);
VSMTestHelper.assertNodeHasRevisions(graph, "p1", new PipelineRevision("p1", 1, "LABEL-p1-1"), new PipelineRevision("p1", 2, "LABEL-p1-2"));
VSMTestHelper.assertNodeHasRevisions(graph, "p2", new PipelineRevision("p2", 1, "LABEL-p2-1"));
VSMTestHelper.assertNodeHasRevisions(graph, "p3", new PipelineRevision("p3", 1, "LABEL-P3"));
VSMTestHelper.assertSCMNodeHasMaterialRevisions(graph, git.getFingerprint(), new MaterialRevision(git, false, modifications));
verify(runStagesPopulator).apply(any(ValueStreamMap.class));
}
use of com.thoughtworks.go.domain.materials.Modifications in project gocd by gocd.
the class MaterialCheckerTest method updateChangedRevisionsShouldFilterRevisionsThatHaveBuiltBefore.
@Test
public void updateChangedRevisionsShouldFilterRevisionsThatHaveBuiltBefore() {
CaseInsensitiveString pipelineName = new CaseInsensitiveString("pipelineName");
GitMaterial gitMaterial = new GitMaterial("git://foo");
BuildCause buildCause = BuildCause.createWithModifications(new MaterialRevisions(new MaterialRevision(gitMaterial, mod(10L), mod(9L), mod(8L))), "user");
when(materialRepository.latestModificationRunByPipeline(pipelineName, gitMaterial)).thenReturn(9L);
materialChecker.updateChangedRevisions(pipelineName, buildCause);
MaterialRevisions actualRevisions = buildCause.getMaterialRevisions();
assertThat(actualRevisions.getModifications(gitMaterial), is(new Modifications(mod(10L))));
assertThat(actualRevisions.findRevisionFor(gitMaterial).isChanged(), is(true));
}
use of com.thoughtworks.go.domain.materials.Modifications in project gocd by gocd.
the class MaterialCheckerTest method updateChangedRevisionsShouldRetainLatestRevisionIfAllHaveBuiltBefore.
@Test
public void updateChangedRevisionsShouldRetainLatestRevisionIfAllHaveBuiltBefore() {
CaseInsensitiveString pipelineName = new CaseInsensitiveString("pipelineName");
GitMaterial gitMaterial = new GitMaterial("git://foo");
BuildCause buildCause = BuildCause.createWithModifications(new MaterialRevisions(new MaterialRevision(gitMaterial, mod(10L), mod(9L), mod(8L))), "user");
when(materialRepository.latestModificationRunByPipeline(pipelineName, gitMaterial)).thenReturn(10L);
materialChecker.updateChangedRevisions(pipelineName, buildCause);
MaterialRevisions actualRevisions = buildCause.getMaterialRevisions();
assertThat(actualRevisions.getModifications(gitMaterial), is(new Modifications(mod(10L), mod(9L), mod(8L))));
assertThat(actualRevisions.findRevisionFor(gitMaterial).isChanged(), is(false));
}
use of com.thoughtworks.go.domain.materials.Modifications in project gocd by gocd.
the class PackageMaterialUpdaterTest method shouldUpdateToNewMaterialInstanceWhenConfigHas_Changed.
@Test
public void shouldUpdateToNewMaterialInstanceWhenConfigHas_Changed() throws Exception {
PackageMaterial material = MaterialsMother.packageMaterial();
MaterialInstance materialInstance = material.createMaterialInstance();
materialInstance.setId(1);
material.getPackageDefinition().getConfiguration().add(ConfigurationPropertyMother.create("key2", false, "value2"));
MaterialInstance newMaterialInstance = material.createMaterialInstance();
newMaterialInstance.setId(1);
File file = new File("random");
Modifications modifications = new Modifications();
when(materialRepository.find(anyLong())).thenReturn(materialInstance);
materialUpdater.insertLatestOrNewModifications(material, materialInstance, file, modifications);
verify(materialRepository).saveOrUpdate(newMaterialInstance);
verify(scmMaterialUpdater).insertLatestOrNewModifications(material, materialInstance, file, modifications);
}
use of com.thoughtworks.go.domain.materials.Modifications in project gocd by gocd.
the class PackageMaterialUpdaterTest method shouldNotUpdateMaterialInstanceWhenConfigHas_NOT_Changed.
@Test
public void shouldNotUpdateMaterialInstanceWhenConfigHas_NOT_Changed() throws Exception {
PackageMaterial material = MaterialsMother.packageMaterial();
MaterialInstance materialInstance = material.createMaterialInstance();
File file = new File("random");
Modifications modifications = new Modifications();
materialUpdater.insertLatestOrNewModifications(material, materialInstance, file, modifications);
verify(materialRepository, never()).saveOrUpdate(Matchers.<MaterialInstance>any());
verify(scmMaterialUpdater).insertLatestOrNewModifications(material, materialInstance, file, modifications);
}
Aggregations