use of com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph in project gocd by gocd.
the class AutoBuildCauseTest method shouldUseTheMaterialRevisionsAfterGettingTheRightVersionsBasedOnDependency.
@Test
public void shouldUseTheMaterialRevisionsAfterGettingTheRightVersionsBasedOnDependency() throws Exception {
PipelineConfigDependencyGraph dependencyGraph = dependencyGraphOfDepthOne(MaterialConfigsMother.hgMaterialConfig());
String targetPipeline = dependencyGraph.getCurrent().name().toLower();
MaterialRevisions revisions = createHgMaterialWithMultipleRevisions(1, oneModifiedFile("2"));
MaterialRevision dependencyRevision = dependencyMaterialRevision("up1", 1, "label", "first", 1, new Date());
dependencyRevision.markAsChanged();
revisions.addRevision(dependencyRevision);
MaterialRevisions expectedRevisions = createHgMaterialWithMultipleRevisions(1, oneModifiedFile("1"));
expectedRevisions.addRevision(dependencyRevision);
when(goConfigService.upstreamDependencyGraphOf(targetPipeline, cruiseConfig)).thenReturn(dependencyGraph);
when(pipelineService.getRevisionsBasedOnDependencies(eq(revisions), eq(cruiseConfig), eq(dependencyGraph.getCurrent().name()))).thenReturn(expectedRevisions);
BuildCause buildCause = new AutoBuild(goConfigService, pipelineService, targetPipeline, new SystemEnvironment(), materialChecker, serverHealthService).onModifications(revisions, false, null);
MaterialRevision expected = expectedRevisions.getMaterialRevision(0);
assertThat(buildCause.getMaterialRevisions().getMaterialRevision(0), is(expected));
}
use of com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph in project gocd by gocd.
the class AutoBuildCauseTest method shouldReturnNullIfUpstreamMaterialHasNotChanged_WithFaninOff.
@Test
public void shouldReturnNullIfUpstreamMaterialHasNotChanged_WithFaninOff() throws Exception {
PipelineConfigDependencyGraph dependencyGraph = dependencyGraphOfDepthOne(MaterialConfigsMother.hgMaterialConfig());
MaterialRevisions revisions = createHgMaterialWithMultipleRevisions(1, oneModifiedFile("2"));
MaterialRevision dependencyRevision = dependencyMaterialRevision("up1", 1, "label", "first", 1, new Date());
dependencyRevision.markAsNotChanged();
revisions.addRevision(dependencyRevision);
when(goConfigService.upstreamDependencyGraphOf("current", cruiseConfig)).thenReturn(dependencyGraph);
when(systemEnvironment.enforceRevisionCompatibilityWithUpstream()).thenReturn(false);
AutoBuild autoBuild = new AutoBuild(goConfigService, pipelineService, "current", systemEnvironment, materialChecker, serverHealthService);
BuildCause current = autoBuild.onModifications(revisions, false, null);
assertThat(current, is(nullValue()));
}
use of com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph in project gocd by gocd.
the class AutoBuildCauseTest method shouldReturnCorrectRevisionsIfUpstreamIgnoresAllTheModificationsAndFirstOrderMaterialNotChanged.
@Test
public void shouldReturnCorrectRevisionsIfUpstreamIgnoresAllTheModificationsAndFirstOrderMaterialNotChanged() throws Exception {
PipelineConfigDependencyGraph dependencyGraph = dependencyGraphOfDepthOne(MaterialConfigsMother.hgMaterialConfig(), MaterialConfigsMother.svnMaterialConfig());
String targetPipeline = dependencyGraph.getCurrent().name().toLower();
firstHgMaterial(dependencyGraph).setFilter(new Filter(new IgnoredFiles("**/*.xml")));
MaterialRevisions revisions = createHgMaterialWithMultipleRevisions(1, oneModifiedFile("2"));
MaterialRevisions firstOrderRevision = createSvnMaterialWithMultipleRevisions(1, oneModifiedFile("2"));
MaterialRevision dependencyRevision = dependencyMaterialRevision("up1", 1, "label", "first", 1, new Date());
revisions.addAll(firstOrderRevision);
revisions.addRevision(dependencyRevision);
dependencyRevision.markAsNotChanged();
firstOrderRevision.getMaterialRevision(0).markAsNotChanged();
revisions.getMaterialRevision(0).markAsChanged();
MaterialRevisions expectedRevisions = createHgMaterialWithMultipleRevisions(1, oneModifiedFile("2"));
expectedRevisions.addRevision(dependencyRevision);
when(goConfigService.upstreamDependencyGraphOf(targetPipeline, cruiseConfig)).thenReturn(dependencyGraph);
when(pipelineService.getRevisionsBasedOnDependencies(eq(revisions), eq(cruiseConfig), eq(dependencyGraph.getCurrent().name()))).thenReturn(expectedRevisions);
assertThat(new AutoBuild(goConfigService, pipelineService, targetPipeline, new SystemEnvironment(), materialChecker, serverHealthService).onModifications(revisions, false, null).getMaterialRevisions(), is(expectedRevisions));
}
use of com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph in project gocd by gocd.
the class AutoBuildCauseTest method shouldSetApproverToCruiseForTheProducedBuildCause.
@Test
public void shouldSetApproverToCruiseForTheProducedBuildCause() throws Exception {
SvnMaterial material = new SvnMaterial("http://foo.bar/baz", "user", "pass", false);
MaterialRevisions materialRevisions = new MaterialRevisions(new MaterialRevision(material, new Modification(new Date(), "1234", "MOCK_LABEL-12", null)));
when(goConfigService.upstreamDependencyGraphOf("foo", cruiseConfig)).thenReturn(new PipelineConfigDependencyGraph(null));
when(pipelineService.getRevisionsBasedOnDependencies(materialRevisions, cruiseConfig, new CaseInsensitiveString("foo"))).thenReturn(materialRevisions);
BuildCause buildCause = new AutoBuild(goConfigService, pipelineService, "foo", new SystemEnvironment(), materialChecker, serverHealthService).onModifications(materialRevisions, false, null);
assertThat(buildCause.getApprover(), is(GoConstants.DEFAULT_APPROVED_BY));
}
use of com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph in project gocd by gocd.
the class AutoBuildCauseTest method shouldReturnNullIfUpstreamMaterialAndFirstOrderMaterialHaveNotChanged_WithFaninOff.
@Test
public void shouldReturnNullIfUpstreamMaterialAndFirstOrderMaterialHaveNotChanged_WithFaninOff() throws Exception {
PipelineConfigDependencyGraph dependencyGraph = dependencyGraphOfDepthOne(MaterialConfigsMother.hgMaterialConfig(), MaterialConfigsMother.svnMaterialConfig());
MaterialRevisions revisions = createHgMaterialWithMultipleRevisions(1, oneModifiedFile("2"));
MaterialRevisions firstOrderRevision = createSvnMaterialWithMultipleRevisions(1, oneModifiedFile("2"));
MaterialRevision dependencyRevision = dependencyMaterialRevision("up1", 1, "label", "first", 1, new Date());
revisions.addAll(firstOrderRevision);
revisions.addRevision(dependencyRevision);
dependencyRevision.markAsNotChanged();
firstOrderRevision.getMaterialRevision(0).markAsNotChanged();
revisions.getMaterialRevision(0).markAsChanged();
when(goConfigService.upstreamDependencyGraphOf("downstream", cruiseConfig)).thenReturn(dependencyGraph);
when(systemEnvironment.enforceRevisionCompatibilityWithUpstream()).thenReturn(false);
AutoBuild build = new AutoBuild(goConfigService, pipelineService, "downstream", systemEnvironment, materialChecker, serverHealthService);
BuildCause cause = build.onModifications(revisions, false, null);
assertThat(cause, is(nullValue()));
}
Aggregations