Search in sources :

Example 91 with MaterialRevisions

use of com.thoughtworks.go.domain.MaterialRevisions in project gocd by gocd.

the class AutoTriggerDependencyResolutionTest method shouldChooseTheRevisionFromSecondInAComplexSituation.

@Test
public void shouldChooseTheRevisionFromSecondInAComplexSituation() throws Exception {
    // hg -> First          git
    // |      \             |
    // |      Third  <- Second
    // |        |      /
    // |        |    /
    // +------> Last
    // 
    HgMaterial hg = u.wf(new HgMaterial("hg", null), "folder1");
    String[] hg_revs = { "h1", "h2" };
    u.checkinInOrder(hg, hg_revs);
    GitMaterial git = u.wf(new GitMaterial("git"), "folder2");
    String[] git_revs = { "g1", "g2" };
    u.checkinInOrder(git, git_revs);
    ScheduleTestUtil.AddedPipeline first = u.saveConfigWith("first", u.m(hg));
    ScheduleTestUtil.AddedPipeline second = u.saveConfigWith("second", u.m(git));
    ScheduleTestUtil.AddedPipeline third = u.saveConfigWith("third", u.m(first), u.m(second));
    ScheduleTestUtil.AddedPipeline last = u.saveConfigWith("last", u.m(hg), u.m(second), u.m(third));
    String first_1 = u.runAndPass(first, "h1");
    String second_1 = u.runAndPass(second, "g1");
    String second_2 = u.runAndPass(second, "g1");
    String second_3 = u.runAndPass(second, "g2");
    String second_4 = u.runAndPass(second, "g2");
    String third_1 = u.runAndPass(third, first_1, second_2);
    String third_2 = u.runAndPass(third, first_1, second_2);
    String third_3 = u.runAndPass(third, first_1, second_2);
    MaterialRevisions given = u.mrs(u.mr(hg, true, hg_revs), u.mr(second, true, second_4), u.mr(third, true, third_3));
    MaterialRevisions expected = u.mrs(u.mr(hg, true, "h1"), u.mr(second, true, second_2), u.mr(third, true, third_3));
    MaterialRevisions finalRevisions = getRevisionsBasedOnDependencies(goConfigDao.load(), given, new CaseInsensitiveString("last"));
    assertThat(finalRevisions, is(expected));
}
Also used : GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 92 with MaterialRevisions

use of com.thoughtworks.go.domain.MaterialRevisions in project gocd by gocd.

the class AutoTriggerDependencyResolutionTest method shouldGetTheRevisionsFromTheNearestUpStreamPipeline.

@Test
public void shouldGetTheRevisionsFromTheNearestUpStreamPipeline() throws Exception {
    HgMaterial hg = u.wf(new HgMaterial("hg", null), "folder1");
    String[] hg_revs = { "hg1", "hg2", "hg3" };
    int i = 1;
    u.checkinInOrder(hg, u.d(i++), hg_revs);
    ScheduleTestUtil.AddedPipeline up0 = u.saveConfigWith("up0", u.m(hg));
    ScheduleTestUtil.AddedPipeline up1 = u.saveConfigWith("up1", u.m(up0), u.m(hg));
    ScheduleTestUtil.AddedPipeline current = u.saveConfigWith("current", u.m(up1), u.m(hg));
    String up0_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(up0, u.d(i++), "hg1");
    String up0_2 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(up0, u.d(i++), "hg2");
    String up0_3 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(up0, u.d(i++), "hg3");
    String up1_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(up1, u.d(i), up0_2, "hg2");
    MaterialRevisions given = u.mrs(u.mr(hg, true, "hg3"), u.mr(up1, true, up1_1));
    MaterialRevisions expected = u.mrs(u.mr(hg, true, "hg2"), u.mr(up1, true, up1_1));
    MaterialRevisions revisions = getRevisionsBasedOnDependencies(goConfigDao.load(), given, new CaseInsensitiveString("current"));
    assertThat(revisions, is(expected));
}
Also used : MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 93 with MaterialRevisions

use of com.thoughtworks.go.domain.MaterialRevisions in project gocd by gocd.

the class AutoTriggerDependencyResolutionTest method shouldResolveTriangleDependency.

/* TRIANGLE TEST BEGIN */
@Test
public void shouldResolveTriangleDependency() throws Exception {
    GitMaterial git = new GitMaterial("git");
    String[] git_revs = { "g1" };
    u.checkinInOrder(git, git_revs);
    ScheduleTestUtil.AddedPipeline p4 = u.saveConfigWith("p4", u.m(git));
    ScheduleTestUtil.AddedPipeline p5 = u.saveConfigWith("p5", u.m(p4));
    ScheduleTestUtil.AddedPipeline p6 = u.saveConfigWith("p6", u.m(p4), u.m(p5));
    String p4_1 = u.runAndPass(p4, "g1");
    String p4_2 = u.runAndPass(p4, "g1");
    String p5_1 = u.runAndPass(p5, p4_2);
    String p4_3 = u.runAndPass(p4, "g1");
    String p4_4 = u.runAndPass(p4, "g1");
    PipelineConfigDependencyGraph graph = new PipelineConfigDependencyGraph(p6.config, new PipelineConfigDependencyGraph(p5.config), new PipelineConfigDependencyGraph(p4.config));
    MaterialRevisions given = u.mrs(u.mr(p4, true, p4_4), u.mr(p5, true, p5_1));
    MaterialRevisions expected = u.mrs(u.mr(p4, true, p4_2), u.mr(p5, true, p5_1));
    assertThat(pipelineService.getRevisionsBasedOnDependencies(graph, given), is(expected));
}
Also used : PipelineConfigDependencyGraph(com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 94 with MaterialRevisions

use of com.thoughtworks.go.domain.MaterialRevisions in project gocd by gocd.

the class GitMultipleMaterialsTest method shouldFindModificationsForBothMaterials.

@Test
public void shouldFindModificationsForBothMaterials() throws Exception {
    Materials materials = new Materials(repo.createMaterial("dest1"), repo.createMaterial("dest2"));
    String fileName = "newFile.txt";
    repo.addFileAndPush(fileName, "add a new file " + fileName);
    MaterialRevisions materialRevisions = materials.latestModification(pipelineDir, new TestSubprocessExecutionContext());
    assertThat(materialRevisions.getRevisions().size(), is(2));
    assertThat(materialRevisions, containsModifiedFile(fileName));
}
Also used : MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) TestSubprocessExecutionContext(com.thoughtworks.go.domain.materials.TestSubprocessExecutionContext) Materials(com.thoughtworks.go.config.materials.Materials) Test(org.junit.Test)

Example 95 with MaterialRevisions

use of com.thoughtworks.go.domain.MaterialRevisions in project gocd by gocd.

the class SvnExternalTest method shouldGetLatestRevisionFromExpandedSvnExternalRepository.

@Test
public void shouldGetLatestRevisionFromExpandedSvnExternalRepository() {
    MaterialRevisions materialRevisions = new MaterialRevisions();
    Material svnExt = svnMaterial(svnRepo.externalRepositoryUrl(), "end2end");
    List<Modification> modifications = ((SvnMaterial) svnExt).latestModification(svnRepo.workingFolder(), new TestSubprocessExecutionContext());
    materialRevisions.addRevision(svnExt, modifications);
    assertThat(materialRevisions.numberOfRevisions(), is(1));
    MaterialRevision materialRevision = materialRevisions.getRevisions().get(0);
    assertThat(materialRevision.getMaterial(), is(svnExt));
    assertThat(materialRevision.getRevision().getRevision(), is("4"));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) TestSubprocessExecutionContext(com.thoughtworks.go.domain.materials.TestSubprocessExecutionContext) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) Material(com.thoughtworks.go.domain.materials.Material) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) MaterialsMother.svnMaterial(com.thoughtworks.go.helper.MaterialsMother.svnMaterial) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision)

Aggregations

MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)212 Test (org.junit.Test)166 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)111 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)68 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)55 Date (java.util.Date)49 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)46 Modification (com.thoughtworks.go.domain.materials.Modification)38 CruiseConfig (com.thoughtworks.go.config.CruiseConfig)33 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)33 HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)31 PipelineConfigDependencyGraph (com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph)31 Materials (com.thoughtworks.go.config.materials.Materials)27 Pipeline (com.thoughtworks.go.domain.Pipeline)20 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)19 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)17 Material (com.thoughtworks.go.domain.materials.Material)16 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)15 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)14 File (java.io.File)12