use of com.thoughtworks.go.server.functional.helpers.MaterialRevisionBuilder in project gocd by gocd.
the class PipelineServiceTriangleDependencyTest method shouldChooseTheRevisionFromThirdWhenBothThirdAndSecondAreModified.
@Test
public void shouldChooseTheRevisionFromThirdWhenBothThirdAndSecondAreModified() throws Exception {
// Third* <- Second*
// | /
// | /
// Last
//
// * indicates changed
Date date = new Date();
MaterialRevisionBuilder builder = new MaterialRevisionBuilder(pipelineDao, materialRepository);
PipelineConfigDependencyGraph graph = builder.depInstance("last", 1, date, builder.depInstance("third", 3, date, builder.depInstance("second", 2, date, builder.svnInstance("1", date))), builder.depInstance("second", 4, date, builder.svnInstance("2", date))).getGraph();
MaterialRevisions actual = new MaterialRevisions();
actual.addRevision(builder.lookingAtDep("third", 3, date).markAsChanged().revision());
actual.addRevision(builder.lookingAtDep("second", 4, date).markAsChanged().revision());
MaterialRevisions expected = new MaterialRevisions();
expected.addRevision(builder.depInstance("third", 3, date).getRevision());
expected.addRevision(builder.depInstance("second", 2, 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