use of com.thoughtworks.go.domain.MaterialRevisions in project gocd by gocd.
the class P4MultipleMaterialsTest method shouldFoundModificationsForEachMaterial.
@Test
public void shouldFoundModificationsForEachMaterial() throws Exception {
P4Material p4Material1 = p4Fixture.material(VIEW_SRC, "src");
P4Material p4Material2 = p4Fixture.material(VIEW_LIB, "lib");
Materials materials = new Materials(p4Material1, p4Material2);
p4TestRepo.checkInOneFile(p4Material1, "filename.txt");
p4TestRepo.checkInOneFile(p4Material2, "filename2.txt");
MaterialRevisions materialRevisions = materials.latestModification(clientFolder, new TestSubprocessExecutionContext());
assertThat(materialRevisions.getRevisions().size(), is(2));
assertThat(materialRevisions, containsModifiedFile("src/filename.txt"));
assertThat(materialRevisions, containsModifiedFile("lib/filename2.txt"));
}
use of com.thoughtworks.go.domain.MaterialRevisions in project gocd by gocd.
the class SvnMultipleMaterialsTest method shouldDetectLatestModifications.
@Test
public void shouldDetectLatestModifications() throws Exception {
SvnMaterial svnMaterial1 = repo.createMaterial("multiple-materials/trunk/part1", "part1");
SvnMaterial svnMaterial2 = repo.createMaterial("multiple-materials/trunk/part2", "part2");
Materials materials = new Materials(svnMaterial1, svnMaterial2);
MaterialRevisions materialRevisions = materials.latestModification(pipelineDir, new TestSubprocessExecutionContext());
MaterialRevision revision1 = materialRevisions.getMaterialRevision(0);
assertThat(revision1.getRevision(), is(latestRevision(svnMaterial1, pipelineDir, new TestSubprocessExecutionContext())));
MaterialRevision revision2 = materialRevisions.getMaterialRevision(1);
assertThat(revision2.getRevision(), is(latestRevision(svnMaterial2, pipelineDir, new TestSubprocessExecutionContext())));
}
use of com.thoughtworks.go.domain.MaterialRevisions in project gocd by gocd.
the class FetchTaskTest method buildCauseWithDependencyMaterial.
private BuildCause buildCauseWithDependencyMaterial(String upstreamPipelineName, int upstreamPipelineCounter, String upstreamPipelineLabel, String upstreamStageName, int upstreamStageCounter) {
BuildCause buildCause = BuildCause.createWithEmptyModifications();
MaterialRevisions materialRevisions = new MaterialRevisions();
DependencyMaterialRevision materialRevision = DependencyMaterialRevision.create(upstreamPipelineName, upstreamPipelineCounter, upstreamPipelineLabel, upstreamStageName, upstreamStageCounter);
MaterialRevision withRevision = materialRevision.convert(new DependencyMaterial(new CaseInsensitiveString(upstreamPipelineName), new CaseInsensitiveString(upstreamStageName)), new Date());
materialRevisions.addRevision(withRevision);
buildCause.setMaterialRevisions(materialRevisions);
return buildCause;
}
use of com.thoughtworks.go.domain.MaterialRevisions 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.MaterialRevisions in project gocd by gocd.
the class PipelineServiceTriangleDependencyTest method shouldChooseTheRevisionFromSecondInAComplexSituation.
@Test
public void shouldChooseTheRevisionFromSecondInAComplexSituation() throws Exception {
// hg -> First git
// | \ |
// | Third <- Second*
// | | /
// | | /
// +------> Last
//
// * indicates changed
Date date = new Date();
MaterialRevisionBuilder builder = new MaterialRevisionBuilder(pipelineDao, materialRepository);
PipelineConfigDependencyGraph graph = builder.depInstance("last", 1, date, builder.hgInstance("rev2", date), builder.depInstance("second", 4, date, builder.svnInstance("2", date)), builder.depInstance("third", 3, date, builder.depInstance("first", 1, date, builder.hgInstance("rev1", date)), builder.depInstance("second", 2, date, builder.svnInstance("1", date)))).getGraph();
MaterialRevisions actual = new MaterialRevisions();
actual.addRevision(builder.lookingAtHg("rev2", date).markAsChanged().revision());
actual.addRevision(builder.lookingAtDep("second", 4, date).markAsChanged().revision());
actual.addRevision(builder.lookingAtDep("third", 3, date).markAsChanged().revision());
MaterialRevisions expected = new MaterialRevisions();
expected.addRevision(builder.hgInstance("rev1", date).getRevision());
expected.addRevision(builder.depInstance("second", 2, date).getRevision());
expected.addRevision(builder.depInstance("third", 3, date).getRevision());
MaterialRevisions finalRevisions = service.getRevisionsBasedOnDependencies(graph, actual);
assertThat(finalRevisions, is(expected));
for (int i = 0; i < expected.numberOfRevisions(); i++) {
assertTrue(finalRevisions.getMaterialRevision(i) == actual.getMaterialRevision(i));
}
}
Aggregations