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));
}
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));
}
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);
}
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"));
}
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));
}
Aggregations