Search in sources :

Example 61 with MaterialRevision

use of com.thoughtworks.go.domain.MaterialRevision in project gocd by gocd.

the class ChangesetServiceIntegrationTest method shouldReturnModsOf2MaterialsBetweenTheGivenPipelineCounters.

@Test
public void shouldReturnModsOf2MaterialsBetweenTheGivenPipelineCounters() {
    List<MaterialRevision> revisionsForPipeline1 = new ArrayList<>();
    addRevisionWith2Mods(revisionsForPipeline1, hg);
    addRevisionWith2Mods(revisionsForPipeline1, git);
    Username username = new Username(new CaseInsensitiveString("user1"));
    Pipeline pipelineOne = dbHelper.checkinRevisionsToBuild(new ManualBuild(username), pipelineConfigWithTwoMaterials, revisionsForPipeline1);
    List<MaterialRevision> revisionsForPipeline2 = new ArrayList<>();
    addRevisionWith2Mods(revisionsForPipeline2, hg);
    addRevisionWith2Mods(revisionsForPipeline2, git);
    Pipeline pipelineTwo = dbHelper.checkinRevisionsToBuild(new ManualBuild(username), pipelineConfigWithTwoMaterials, revisionsForPipeline2);
    HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
    List<MaterialRevision> actual = changesetService.revisionsBetween(CaseInsensitiveString.str(pipelineConfigWithTwoMaterials.name()), pipelineOne.getCounter(), pipelineTwo.getCounter(), username, result, true, false);
    List<MaterialRevision> expectedRevisions = groupByMaterial(revisionsForPipeline2);
    assertMaterialRevisions(expectedRevisions, actual);
    assertThat(result.isSuccessful(), is(true));
}
Also used : HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) Username(com.thoughtworks.go.server.domain.Username) PipelineMaterialRevision(com.thoughtworks.go.domain.PipelineMaterialRevision) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) Pipeline(com.thoughtworks.go.domain.Pipeline) Test(org.junit.Test)

Example 62 with MaterialRevision

use of com.thoughtworks.go.domain.MaterialRevision in project gocd by gocd.

the class MaterialDatabaseDependencyUpdaterTest method shouldReturnLatestPipelineIfThereHasBeenANewOne.

@Test
public void shouldReturnLatestPipelineIfThereHasBeenANewOne() throws Exception {
    DependencyMaterial dependencyMaterial = new DependencyMaterial(new CaseInsensitiveString("pipeline-name"), new CaseInsensitiveString("stage-name"));
    stubStageServiceGetHistory(null, stages(9));
    updater.updateMaterial(dependencyMaterial);
    List<Modification> modification = materialRepository.findLatestModification(dependencyMaterial).getMaterialRevision(0).getModifications();
    stubStageServiceGetHistoryAfter(null, 9, stages(10));
    updater.updateMaterial(dependencyMaterial);
    List<Modification> newModifications = materialRepository.findModificationsSince(dependencyMaterial, new MaterialRevision(dependencyMaterial, modification));
    assertThat(newModifications.size(), is(1));
    assertThat(newModifications.get(0).getRevision(), is("pipeline-name/10/stage-name/0"));
    assertThat(newModifications.get(0).getPipelineLabel(), is("LABEL-10"));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 63 with MaterialRevision

use of com.thoughtworks.go.domain.MaterialRevision in project gocd by gocd.

the class MaterialDatabaseSvnWithExternalsUpdaterTest method shouldUpdateModificationsForExternals.

@Test
public void shouldUpdateModificationsForExternals() throws Exception {
    updater.updateMaterial(material);
    testRepoWithExternal.checkInExternalFile("foo_bar", "foo bar quux");
    updater.updateMaterial(material);
    MaterialRevisions materialRevisions = materialRepository.findLatestModification(material);
    assertThat(materialRevisions.numberOfRevisions(), is(2));
    SvnMaterial externalMaterial = testRepoWithExternal.externalMaterial();
    MaterialRevision revisionForExternal = materialRevisions.findRevisionFor(externalMaterial);
    assertThat(revisionForExternal.getModification(0).getComment(), is("foo bar quux"));
}
Also used : MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) Test(org.junit.Test)

Example 64 with MaterialRevision

use of com.thoughtworks.go.domain.MaterialRevision in project gocd by gocd.

the class PipelineServiceTriangleDependencyTest method shouldNotGetTheRevisionsFromUpStreamPipelineIfTheDependencyMaterialHasNotChanged.

@Test
public void shouldNotGetTheRevisionsFromUpStreamPipelineIfTheDependencyMaterialHasNotChanged() throws Exception {
    MaterialRevisions expected = createHgMaterialWithMultipleRevisions(1L, first);
    MaterialRevision up1Revision = dependencyMaterialRevision("up1", 1, "label", "stage", 1, new Date());
    expected.addRevision(up1Revision);
    MaterialRevisions actual = createHgMaterialWithMultipleRevisions(1L, third);
    actual.addRevision(up1Revision);
    up1Revision.markAsNotChanged();
    PipelineConfig current = createPipelineConfigWithMaterialConfig("current", actual.getMaterials().get(0).config(), new DependencyMaterialConfig(new CaseInsensitiveString("up1"), new CaseInsensitiveString("first")));
    PipelineConfig up1 = createPipelineConfigWithMaterialConfig("up1", expected.getMaterials().get(0).config());
    when(pipelineDao.findBuildCauseOfPipelineByNameAndCounter("up1", 1)).thenReturn(BuildCause.createManualForced(expected, new Username(str("loser"))));
    PipelineConfigDependencyGraph dependencyGraph = new PipelineConfigDependencyGraph(current, new PipelineConfigDependencyGraph(up1));
    assertThat(service.getRevisionsBasedOnDependencies(dependencyGraph, actual), is(actual));
}
Also used : PipelineConfigDependencyGraph(com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph) PipelineConfig(com.thoughtworks.go.config.PipelineConfig) Username(com.thoughtworks.go.server.domain.Username) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) ModificationsMother.dependencyMaterialRevision(com.thoughtworks.go.helper.ModificationsMother.dependencyMaterialRevision) ModificationsMother.changedDependencyMaterialRevision(com.thoughtworks.go.helper.ModificationsMother.changedDependencyMaterialRevision) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) Date(java.util.Date) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 65 with MaterialRevision

use of com.thoughtworks.go.domain.MaterialRevision in project gocd by gocd.

the class PipelineServiceTriangleDependencyTest method shouldGetTheRevisionsFromTheUpStreamPipelineFor2SameMaterial.

@Test
public void shouldGetTheRevisionsFromTheUpStreamPipelineFor2SameMaterial() throws Exception {
    MaterialRevision up1Revision = dependencyMaterialRevision("up1", 1, "label", "stage", 1, new Date());
    up1Revision.markAsChanged();
    MaterialRevisions expected = new MaterialRevisions();
    expected.addRevision(up1Revision);
    expected.addAll(createHgMaterialWithMultipleRevisions(1L, first));
    expected.addAll(createSvnMaterialWithMultipleRevisions(2L, first));
    MaterialRevisions actual = new MaterialRevisions();
    actual.addRevision(up1Revision);
    actual.addAll(createHgMaterialWithMultipleRevisions(1L, third));
    actual.addAll(createSvnMaterialWithMultipleRevisions(2L, third));
    PipelineConfig current = createPipelineConfigWithMaterialConfig("current", new DependencyMaterialConfig(new CaseInsensitiveString("up1"), new CaseInsensitiveString("first")), MaterialConfigsMother.hgMaterialConfig(), MaterialConfigsMother.svnMaterialConfig());
    PipelineConfig up1 = createPipelineConfigWithMaterialConfig("up1", MaterialConfigsMother.hgMaterialConfig(), MaterialConfigsMother.svnMaterialConfig());
    Pipeline pipeline = PipelineMother.passedPipelineInstance("up1", "stage", "job");
    pipeline.setId(10);
    when(pipelineDao.findPipelineByNameAndCounter("up1", 1)).thenReturn(pipeline);
    when(materialRepository.findMaterialRevisionsForPipeline(10)).thenReturn(expected);
    PipelineConfigDependencyGraph dependencyGraph = new PipelineConfigDependencyGraph(current, new PipelineConfigDependencyGraph(up1));
    assertThat(service.getRevisionsBasedOnDependencies(dependencyGraph, actual), is(expected));
}
Also used : PipelineConfigDependencyGraph(com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph) PipelineConfig(com.thoughtworks.go.config.PipelineConfig) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) ModificationsMother.dependencyMaterialRevision(com.thoughtworks.go.helper.ModificationsMother.dependencyMaterialRevision) ModificationsMother.changedDependencyMaterialRevision(com.thoughtworks.go.helper.ModificationsMother.changedDependencyMaterialRevision) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) Date(java.util.Date) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Pipeline(com.thoughtworks.go.domain.Pipeline) Test(org.junit.Test)

Aggregations

MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)185 Test (org.junit.Test)141 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)72 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)68 Modification (com.thoughtworks.go.domain.materials.Modification)65 Date (java.util.Date)50 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)31 Pipeline (com.thoughtworks.go.domain.Pipeline)29 Username (com.thoughtworks.go.server.domain.Username)27 PipelineMaterialRevision (com.thoughtworks.go.domain.PipelineMaterialRevision)23 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)21 PipelineConfigDependencyGraph (com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph)21 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)20 PipelineDependencyNode (com.thoughtworks.go.domain.valuestreammap.PipelineDependencyNode)18 SCMDependencyNode (com.thoughtworks.go.domain.valuestreammap.SCMDependencyNode)18 ValueStreamMap (com.thoughtworks.go.domain.valuestreammap.ValueStreamMap)18 File (java.io.File)17 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)16 DependencyMaterialRevision (com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision)16 EnvironmentVariableContext (com.thoughtworks.go.util.command.EnvironmentVariableContext)16