use of com.thoughtworks.go.config.materials.Materials 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.config.materials.Materials 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.config.materials.Materials in project gocd by gocd.
the class MaterialCheckerTest method shouldUseLatestPipelineInstanceForDependentPipeline.
@Test
public void shouldUseLatestPipelineInstanceForDependentPipeline() throws Exception {
DependencyMaterial dependencyMaterial = new DependencyMaterial(new CaseInsensitiveString("pipeline-name"), new CaseInsensitiveString("stage-name"));
Stage passedStage = StageMother.passedStageInstance("stage-name", "job-name", "pipeline-name");
Modification modification = new Modification("Unknown", "Unknown", null, passedStage.completedDate(), "pipeline-name/1[LABEL-1]/stage-name/0");
Mockito.when(materialRepository.findLatestModification(dependencyMaterial)).thenReturn(revisions(dependencyMaterial, modification));
materialChecker.findLatestRevisions(new MaterialRevisions(), new Materials(dependencyMaterial));
Mockito.verify(materialRepository).findLatestModification(dependencyMaterial);
}
use of com.thoughtworks.go.config.materials.Materials in project gocd by gocd.
the class ModificationsMother method modifyOneFile.
public static MaterialRevisions modifyOneFile(Materials materials, String revision, String comment, String committer) {
MaterialRevisions materialRevisions = new MaterialRevisions();
Materials expandedMaterials = new Materials();
for (Material material : materials) {
expandedMaterials.add(material);
}
for (Material material : expandedMaterials) {
Modification modification;
if (material instanceof DependencyMaterial) {
DependencyMaterial dependencyMaterial = (DependencyMaterial) material;
modification = oneModifiedFile(committer, dependencyMaterial.getPipelineName() + "/1/" + dependencyMaterial.getStageName() + "/" + revision, TWO_DAYS_AGO_CHECKIN, dependencyMaterial.getPipelineName() + "-1.2.3");
} else {
modification = oneModifiedFile(committer, revision, comment, TWO_DAYS_AGO_CHECKIN);
}
materialRevisions.addRevision(new MaterialRevision(material, true, modification));
}
return materialRevisions;
}
use of com.thoughtworks.go.config.materials.Materials in project gocd by gocd.
the class MixedMultipleMaterialsTest method shouldGetLatestModificationswithThreeRepositories.
@Test
public void shouldGetLatestModificationswithThreeRepositories() throws Exception {
HgMaterial hgMaterial = hgRepo.material();
SvnMaterial svnMaterial = svnRepo.createMaterial("multiple-materials/trunk/part1", "part1");
GitMaterial gitMaterial = gitRepo.createMaterial();
Materials materials = new Materials(hgMaterial, svnMaterial, gitMaterial);
MaterialRevisions revisions = materials.latestModification(pipelineDir, new TestSubprocessExecutionContext());
assertThat(revisions.getMaterialRevision(0).numberOfModifications(), is(1));
assertThat(revisions.getMaterialRevision(0).getRevision(), is(new Modifications(hgRepo.latestModifications()).latestRevision(hgMaterial)));
assertThat(revisions.getMaterialRevision(1).numberOfModifications(), is(1));
assertThat(revisions.getMaterialRevision(1).getRevision(), is(latestRevision(svnMaterial, pipelineDir, new TestSubprocessExecutionContext())));
assertThat(revisions.getMaterialRevision(2).numberOfModifications(), is(1));
assertThat(revisions.getMaterialRevision(2).getRevision(), is(new Modifications(gitRepo.latestModifications()).latestRevision(gitMaterial)));
assertThat(revisions.toString(), revisions.totalNumberOfModifications(), is(3));
}
Aggregations