Search in sources :

Example 1 with MaterialRevisionBuilder

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));
    }
}
Also used : PipelineConfigDependencyGraph(com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph) MaterialRevisionBuilder(com.thoughtworks.go.server.functional.helpers.MaterialRevisionBuilder) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) Date(java.util.Date) Test(org.junit.Test)

Example 2 with MaterialRevisionBuilder

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));
    }
}
Also used : PipelineConfigDependencyGraph(com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph) MaterialRevisionBuilder(com.thoughtworks.go.server.functional.helpers.MaterialRevisionBuilder) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) Date(java.util.Date) Test(org.junit.Test)

Example 3 with MaterialRevisionBuilder

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));
    }
}
Also used : PipelineConfigDependencyGraph(com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph) MaterialRevisionBuilder(com.thoughtworks.go.server.functional.helpers.MaterialRevisionBuilder) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) Date(java.util.Date) Test(org.junit.Test)

Example 4 with MaterialRevisionBuilder

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));
    }
}
Also used : PipelineConfigDependencyGraph(com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph) MaterialRevisionBuilder(com.thoughtworks.go.server.functional.helpers.MaterialRevisionBuilder) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) Date(java.util.Date) Test(org.junit.Test)

Example 5 with MaterialRevisionBuilder

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));
    }
}
Also used : PipelineConfigDependencyGraph(com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph) MaterialRevisionBuilder(com.thoughtworks.go.server.functional.helpers.MaterialRevisionBuilder) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) Date(java.util.Date) Test(org.junit.Test)

Aggregations

MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)6 PipelineConfigDependencyGraph (com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph)6 MaterialRevisionBuilder (com.thoughtworks.go.server.functional.helpers.MaterialRevisionBuilder)6 Date (java.util.Date)6 Test (org.junit.Test)6