Search in sources :

Example 26 with MaterialRevision

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

the class LegacyMaterialCheckerTest method shouldGetModificationsSinceRevision.

@Test
public void shouldGetModificationsSinceRevision() {
    Material material = mock(Material.class);
    MaterialRevision materialRevision = mock(MaterialRevision.class);
    Revision revision = mock(Revision.class);
    List<Modification> modifications = new ArrayList<>();
    when(materialRevision.getRevision()).thenReturn(revision);
    when(materialService.modificationsSince(material, file, revision, null)).thenReturn(modifications);
    List<Modification> actual = checker.findModificationsSince(file, material, materialRevision);
    assertThat(actual, is(modifications));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) Revision(com.thoughtworks.go.domain.materials.Revision) ArrayList(java.util.ArrayList) Material(com.thoughtworks.go.domain.materials.Material) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) Test(org.junit.Test)

Example 27 with MaterialRevision

use of com.thoughtworks.go.domain.MaterialRevision 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));
}
Also used : Modifications(com.thoughtworks.go.domain.materials.Modifications) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause) Test(org.junit.Test)

Example 28 with MaterialRevision

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

the class MaterialCheckerTest method shouldNOTSkipFindingRevisionsSinceForMaterialsThatAreNewlyAdded.

@Test
public void shouldNOTSkipFindingRevisionsSinceForMaterialsThatAreNewlyAdded() throws Exception {
    SvnMaterial svnMaterial = new SvnMaterial("svnUrl", null, null, false);
    SvnMaterial svnExternalMaterial = new SvnMaterial("svnExternalUrl", null, null, false);
    Modification svnExternalModification = new Modification("user", "external commit", "em@il", new Date(), "3");
    MaterialRevision previousSvnRevision = new MaterialRevision(svnMaterial, mod(1L));
    Modification svnModification = new Modification("user", "commend", "em@il", new Date(), "2");
    MaterialRevisions latestRevisions = new MaterialRevisions(new MaterialRevision(svnMaterial, svnModification), new MaterialRevision(svnExternalMaterial, svnExternalModification));
    Mockito.when(materialRepository.findModificationsSince(svnMaterial, previousSvnRevision)).thenReturn(modifications(svnModification));
    MaterialRevisions revisionsSince = materialChecker.findRevisionsSince(new MaterialRevisions(), new Materials(svnMaterial, svnExternalMaterial), new MaterialRevisions(previousSvnRevision), latestRevisions);
    assertThat(revisionsSince, is(new MaterialRevisions(new MaterialRevision(svnMaterial, svnModification), new MaterialRevision(svnExternalMaterial, svnExternalModification))));
    Mockito.verify(materialRepository).findModificationsSince(svnMaterial, previousSvnRevision);
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) Materials(com.thoughtworks.go.config.materials.Materials) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) Date(java.util.Date) Test(org.junit.Test)

Example 29 with MaterialRevision

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

the class MaterialCheckerTest method shouldUseLatestPipelineInstanceForDependentPipelineGivenThePreviousRevision.

@Test
public void shouldUseLatestPipelineInstanceForDependentPipelineGivenThePreviousRevision() throws Exception {
    DependencyMaterial dependencyMaterial = new DependencyMaterial(new CaseInsensitiveString("pipeline-name"), new CaseInsensitiveString("stage-name"));
    Stage passedStage = StageMother.passedStageInstance("stage-name", "job-name", "pipeline-name");
    MaterialRevisions materialRevisions = new MaterialRevisions();
    Modification previous = new Modification("Unknown", "Unknown", null, passedStage.completedDate(), "pipeline-name/1/stage-name/0");
    MaterialRevision previousRevision = revisions(dependencyMaterial, previous).getMaterialRevision(0);
    when(materialRepository.findModificationsSince(dependencyMaterial, previousRevision)).thenReturn(Arrays.asList(new Modification(new Date(), "pipeline-name/2/stage-name/0", "MOCK_LABEL-12", null)));
    MaterialRevisions revisionsSince = materialChecker.findRevisionsSince(materialRevisions, new Materials(dependencyMaterial), new MaterialRevisions(previousRevision), new MaterialRevisions());
    assertThat(revisionsSince.getMaterialRevision(0).getRevision().getRevision(), is("pipeline-name/2/stage-name/0"));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) Materials(com.thoughtworks.go.config.materials.Materials) Stage(com.thoughtworks.go.domain.Stage) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Date(java.util.Date) Test(org.junit.Test)

Example 30 with MaterialRevision

use of com.thoughtworks.go.domain.MaterialRevision 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));
}
Also used : Modifications(com.thoughtworks.go.domain.materials.Modifications) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause) 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