use of com.thoughtworks.go.server.functional.helpers.MaterialRevisionBuilder 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));
}
}
use of com.thoughtworks.go.server.functional.helpers.MaterialRevisionBuilder in project gocd by gocd.
the class PipelineServiceTriangleDependencyTest method shouldChooseTheRevisionFromSecondWhenThirdIsNotModified.
@Test
public void shouldChooseTheRevisionFromSecondWhenThirdIsNotModified() 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).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", 4, 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));
}
}
use of com.thoughtworks.go.server.functional.helpers.MaterialRevisionBuilder in project gocd by gocd.
the class PipelineServiceTriangleDependencyTest method shouldChooseTheRevisionFromSecondWhenThirdIsNotModifiedInspiteOfSecondBeingFirstMaterialInConfig.
@Test
public void shouldChooseTheRevisionFromSecondWhenThirdIsNotModifiedInspiteOfSecondBeingFirstMaterialInConfig() 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("second", 4, date, builder.svnInstance("2", date)), builder.depInstance("third", 3, date, builder.depInstance("second", 2, date, builder.svnInstance("1", date)))).getGraph();
MaterialRevisions actual = new MaterialRevisions();
actual.addRevision(builder.lookingAtDep("second", 4, date).markAsChanged().revision());
actual.addRevision(builder.lookingAtDep("third", 3, date).revision());
MaterialRevisions expected = new MaterialRevisions();
expected.addRevision(builder.depInstance("second", 4, 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));
}
}
use of com.thoughtworks.go.server.functional.helpers.MaterialRevisionBuilder in project gocd by gocd.
the class PipelineServiceTriangleDependencyTest method shouldChooseTheRevisionFromThirdWhenSecondIsNotModified.
@Test
public void shouldChooseTheRevisionFromThirdWhenSecondIsNotModified() 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).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));
}
}
use of com.thoughtworks.go.server.functional.helpers.MaterialRevisionBuilder in project gocd by gocd.
the class PipelineServiceTriangleDependencyTest method shouldChooseTheRevisionFromThirdWhenSecondComesBeforeThirdInConfiguration.
@Test
public void shouldChooseTheRevisionFromThirdWhenSecondComesBeforeThirdInConfiguration() 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("second", 4, date, builder.svnInstance("2", date)), builder.depInstance("third", 3, date, builder.depInstance("second", 2, date, builder.svnInstance("1", date)))).getGraph();
MaterialRevisions actual = new MaterialRevisions();
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.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