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