Search in sources :

Example 71 with MaterialRevision

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

the class FaninDependencyResolutionTest method shouldRestoreMaterialNamesBasedOnMaterialConfig.

@Test
public void shouldRestoreMaterialNamesBasedOnMaterialConfig() throws Exception {
    /*
            g -> up   -> down
                 +-> mid -+
         */
    GitMaterial git = u.wf(new GitMaterial("git"), "folder1");
    u.checkinInOrder(git, "g1");
    ScheduleTestUtil.AddedPipeline up = u.saveConfigWith("up", u.m(git));
    ScheduleTestUtil.MaterialDeclaration upForMid = u.m(up);
    ((DependencyMaterial) upForMid.material).setName(new CaseInsensitiveString("up-for-mid"));
    ScheduleTestUtil.AddedPipeline mid = u.saveConfigWith("mid", upForMid);
    ScheduleTestUtil.MaterialDeclaration upForDown = u.m(up);
    ((DependencyMaterial) upForDown.material).setName(new CaseInsensitiveString("up-for-down"));
    ScheduleTestUtil.AddedPipeline down = u.saveConfigWith("down", u.m(mid), upForDown);
    CruiseConfig cruiseConfig = goConfigDao.load();
    String up_1 = u.runAndPass(up, "g1");
    String mid_1 = u.runAndPass(mid, up_1);
    String down_1 = u.runAndPass(down, mid_1, up_1);
    MaterialRevisions given = u.mrs(u.mr(mid, false, mid_1), u.mr(up, false, up_1));
    MaterialRevisions revisionsBasedOnDependencies = getRevisionsBasedOnDependencies(down, cruiseConfig, given);
    for (MaterialRevision revisionsBasedOnDependency : revisionsBasedOnDependencies) {
        DependencyMaterial dependencyPipeline = (DependencyMaterial) revisionsBasedOnDependency.getMaterial();
        if (dependencyPipeline.getPipelineName().equals(new CaseInsensitiveString("up"))) {
            assertThat(dependencyPipeline.getName(), is(new CaseInsensitiveString("up-for-down")));
        }
    }
    assertThat(revisionsBasedOnDependencies, is(given));
}
Also used : GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) CruiseConfig(com.thoughtworks.go.config.CruiseConfig) Test(org.junit.Test)

Example 72 with MaterialRevision

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

the class DependencyMaterialAgentTest method materialRevision.

private MaterialRevision materialRevision(String pipelineName, Integer pipelineCounter, String pipelineLabel, String stageName, int stageCounter) {
    DependencyMaterial material = new DependencyMaterial(new CaseInsensitiveString(pipelineName), new CaseInsensitiveString(stageName));
    DependencyMaterialRevision revision = DependencyMaterialRevision.create(pipelineName, pipelineCounter, pipelineLabel, stageName, stageCounter);
    MaterialRevision materialRevision = revision.convert(material, new Date());
    return materialRevision;
}
Also used : DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Date(java.util.Date)

Example 73 with MaterialRevision

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

the class GitMultipleMaterialsTest method shouldIgnoreDestinationFolderWhenCloningMaterialWhenServerSide.

@Test
public void shouldIgnoreDestinationFolderWhenCloningMaterialWhenServerSide() throws Exception {
    GitMaterial material1 = repo.createMaterial("dest1");
    MaterialRevision materialRevision = new MaterialRevision(material1, material1.latestModification(pipelineDir, new TestSubprocessExecutionContext()));
    materialRevision.updateTo(pipelineDir, ProcessOutputStreamConsumer.inMemoryConsumer(), new TestSubprocessExecutionContext(true));
    assertThat(new File(pipelineDir, "dest1").exists(), is(false));
    assertThat(new File(pipelineDir, ".git").exists(), is(true));
}
Also used : GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) TestSubprocessExecutionContext(com.thoughtworks.go.domain.materials.TestSubprocessExecutionContext) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) MaterialRevisionsMatchers.containsModifiedFile(com.thoughtworks.go.config.MaterialRevisionsMatchers.containsModifiedFile) File(java.io.File) Test(org.junit.Test)

Example 74 with MaterialRevision

use of com.thoughtworks.go.domain.MaterialRevision 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)

Example 75 with MaterialRevision

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

the class SvnExternalTest method shouldGetLatestRevision.

@Test
public void shouldGetLatestRevision() {
    SvnMaterial svn = svnMaterial(svnRepo.projectRepositoryUrl(), null);
    SvnMaterial svnExt = svnMaterial(svnRepo.externalRepositoryUrl(), "end2end");
    final Materials materials = new Materials(svn, svnExt);
    final MaterialRevisions materialRevisions = materials.latestModification(svnRepo.workingFolder(), new TestSubprocessExecutionContext());
    assertThat(materialRevisions.numberOfRevisions(), is(2));
    MaterialRevision main = materialRevisions.getRevisions().get(0);
    assertThat(main.getMaterial(), is(svn));
    assertThat(main.getModifications().size(), is(1));
    assertThat(main.getRevision().getRevision(), is("5"));
    MaterialRevision external = materialRevisions.getRevisions().get(1);
    assertThat(external.getMaterial(), is(svnExt));
    assertThat(external.getRevision().getRevision(), is("4"));
    assertThat(external.getModifications().size(), is(1));
}
Also used : MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) TestSubprocessExecutionContext(com.thoughtworks.go.domain.materials.TestSubprocessExecutionContext) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) Materials(com.thoughtworks.go.config.materials.Materials) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision)

Aggregations

MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)185 Test (org.junit.Test)141 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)72 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)68 Modification (com.thoughtworks.go.domain.materials.Modification)65 Date (java.util.Date)50 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)31 Pipeline (com.thoughtworks.go.domain.Pipeline)29 Username (com.thoughtworks.go.server.domain.Username)27 PipelineMaterialRevision (com.thoughtworks.go.domain.PipelineMaterialRevision)23 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)21 PipelineConfigDependencyGraph (com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph)21 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)20 PipelineDependencyNode (com.thoughtworks.go.domain.valuestreammap.PipelineDependencyNode)18 SCMDependencyNode (com.thoughtworks.go.domain.valuestreammap.SCMDependencyNode)18 ValueStreamMap (com.thoughtworks.go.domain.valuestreammap.ValueStreamMap)18 File (java.io.File)17 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)16 DependencyMaterialRevision (com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision)16 EnvironmentVariableContext (com.thoughtworks.go.util.command.EnvironmentVariableContext)16