Search in sources :

Example 11 with PipelineConfigDependencyGraph

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));
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) PipelineConfigDependencyGraph(com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) Date(java.util.Date) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause) Test(org.junit.Test)

Example 12 with PipelineConfigDependencyGraph

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()));
}
Also used : PipelineConfigDependencyGraph(com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) Date(java.util.Date) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause) Test(org.junit.Test)

Example 13 with PipelineConfigDependencyGraph

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));
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) PipelineConfigDependencyGraph(com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph) Filter(com.thoughtworks.go.config.materials.Filter) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) IgnoredFiles(com.thoughtworks.go.config.materials.IgnoredFiles) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) Date(java.util.Date) Test(org.junit.Test)

Example 14 with PipelineConfigDependencyGraph

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));
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) Modification(com.thoughtworks.go.domain.materials.Modification) PipelineConfigDependencyGraph(com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) Date(java.util.Date) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause) Test(org.junit.Test)

Example 15 with PipelineConfigDependencyGraph

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()));
}
Also used : PipelineConfigDependencyGraph(com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) Date(java.util.Date) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause) Test(org.junit.Test)

Aggregations

PipelineConfigDependencyGraph (com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph)37 Test (org.junit.Test)32 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)31 Date (java.util.Date)28 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)21 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)16 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)12 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)11 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)8 Pipeline (com.thoughtworks.go.domain.Pipeline)7 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)7 ModificationsMother.changedDependencyMaterialRevision (com.thoughtworks.go.helper.ModificationsMother.changedDependencyMaterialRevision)7 ModificationsMother.dependencyMaterialRevision (com.thoughtworks.go.helper.ModificationsMother.dependencyMaterialRevision)7 MaterialRevisionBuilder (com.thoughtworks.go.server.functional.helpers.MaterialRevisionBuilder)6 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)3 HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)3 HgMaterialConfig (com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig)3 Modification (com.thoughtworks.go.domain.materials.Modification)3 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)2 Materials (com.thoughtworks.go.config.materials.Materials)2