Search in sources :

Example 51 with Materials

use of com.thoughtworks.go.config.materials.Materials in project gocd by gocd.

the class MaterialRevisionsTest method shouldReturnLatestChangeSetForDependencyMaterial.

@Test
public void shouldReturnLatestChangeSetForDependencyMaterial() {
    Materials materials = new Materials(MaterialsMother.dependencyMaterial());
    MaterialRevisions original = modifyOneFile(materials, "1");
    MaterialRevisions newRevisions = modifyOneFile(materials, "2");
    assertThat(newRevisions.hasChangedSince(original), is(true));
}
Also used : Materials(com.thoughtworks.go.config.materials.Materials) Test(org.junit.Test)

Example 52 with Materials

use of com.thoughtworks.go.config.materials.Materials in project gocd by gocd.

the class GitMaterialTest method shouldUpdateSubmodules.

@Test
public void shouldUpdateSubmodules() throws Exception {
    GitSubmoduleRepos submoduleRepos = new GitSubmoduleRepos(temporaryFolder);
    submoduleRepos.addSubmodule(SUBMODULE, "sub1");
    GitMaterial gitMaterial = new GitMaterial(submoduleRepos.mainRepo().getUrl());
    File serverWorkingDir = temporaryFolder.newFolder();
    Materials materials = new Materials();
    materials.add(gitMaterial);
    MaterialRevisions materialRevisions = materials.latestModification(serverWorkingDir, new TestSubprocessExecutionContext());
    File agentWorkingDir = temporaryFolder.newFolder();
    MaterialRevision materialRevision = materialRevisions.getMaterialRevision(0);
    materialRevision.updateTo(agentWorkingDir, inMemoryConsumer(), new TestSubprocessExecutionContext());
    File localFile = submoduleRepos.files(GitSubmoduleRepos.NAME).get(0);
    assertThat(new File(agentWorkingDir, localFile.getName()), exists());
    File file = submoduleRepos.files(SUBMODULE).get(0);
    File workingSubmoduleFolder = new File(agentWorkingDir, "sub1");
    assertThat(new File(workingSubmoduleFolder, file.getName()), exists());
}
Also used : GitSubmoduleRepos(com.thoughtworks.go.helper.GitSubmoduleRepos) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) Materials(com.thoughtworks.go.config.materials.Materials) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) RandomAccessFile(java.io.RandomAccessFile) File(java.io.File) Test(org.junit.Test)

Example 53 with Materials

use of com.thoughtworks.go.config.materials.Materials in project gocd by gocd.

the class GitMaterialTest method shouldGetLatestModificationsFromRepoWithSubmodules.

@Test
public void shouldGetLatestModificationsFromRepoWithSubmodules() throws Exception {
    GitSubmoduleRepos submoduleRepos = new GitSubmoduleRepos(temporaryFolder);
    submoduleRepos.addSubmodule(SUBMODULE, "sub1");
    GitMaterial gitMaterial = new GitMaterial(submoduleRepos.mainRepo().getUrl());
    File workingDirectory = temporaryFolder.newFolder();
    Materials materials = new Materials();
    materials.add(gitMaterial);
    MaterialRevisions materialRevisions = materials.latestModification(workingDirectory, new TestSubprocessExecutionContext());
    assertThat(materialRevisions.numberOfRevisions(), is(1));
    MaterialRevision materialRevision = materialRevisions.getMaterialRevision(0);
    assertThat(materialRevision.getRevision().getRevision(), is(submoduleRepos.currentRevision(GitSubmoduleRepos.NAME)));
}
Also used : GitSubmoduleRepos(com.thoughtworks.go.helper.GitSubmoduleRepos) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) Materials(com.thoughtworks.go.config.materials.Materials) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) RandomAccessFile(java.io.RandomAccessFile) File(java.io.File) Test(org.junit.Test)

Example 54 with Materials

use of com.thoughtworks.go.config.materials.Materials in project gocd by gocd.

the class PipelineMother method pipelineWithAllTypesOfMaterials.

public static Pipeline pipelineWithAllTypesOfMaterials(String pipelineName, String stageName, String jobName, String fixedMaterialRevisionForAllMaterials) {
    GitMaterial gitMaterial = MaterialsMother.gitMaterial("http://user:password@gitrepo.com", null, "branch");
    HgMaterial hgMaterial = MaterialsMother.hgMaterial("http://user:password@hgrepo.com");
    SvnMaterial svnMaterial = MaterialsMother.svnMaterial("http://user:password@svnrepo.com", null, "username", "password", false, null);
    TfsMaterial tfsMaterial = MaterialsMother.tfsMaterial("http://user:password@tfsrepo.com");
    P4Material p4Material = MaterialsMother.p4Material("127.0.0.1:1666", "username", "password", "view", false);
    DependencyMaterial dependencyMaterial = MaterialsMother.dependencyMaterial();
    PackageMaterial packageMaterial = MaterialsMother.packageMaterial();
    PluggableSCMMaterial pluggableSCMMaterial = MaterialsMother.pluggableSCMMaterial();
    Materials materials = new Materials(gitMaterial, hgMaterial, svnMaterial, tfsMaterial, p4Material, dependencyMaterial, packageMaterial, pluggableSCMMaterial);
    return new Pipeline(pipelineName, BuildCause.createWithModifications(ModificationsMother.modifyOneFile(materials, fixedMaterialRevisionForAllMaterials), ""), StageMother.passedStageInstance(stageName, jobName, pipelineName));
}
Also used : TfsMaterial(com.thoughtworks.go.config.materials.tfs.TfsMaterial) PluggableSCMMaterial(com.thoughtworks.go.config.materials.PluggableSCMMaterial) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) PackageMaterial(com.thoughtworks.go.config.materials.PackageMaterial) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) Materials(com.thoughtworks.go.config.materials.Materials) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) P4Material(com.thoughtworks.go.config.materials.perforce.P4Material)

Example 55 with Materials

use of com.thoughtworks.go.config.materials.Materials in project gocd by gocd.

the class PipelineServiceIntegrationTest method shouldReturnPMRsInCorrectOrder.

@Test
public void shouldReturnPMRsInCorrectOrder() throws Exception {
    File file1 = new File("file1");
    File file2 = new File("file2");
    File file3 = new File("file3");
    File file4 = new File("file4");
    Material hg1 = new HgMaterial("url1", "Dest1");
    Material hg2 = new HgMaterial("url2", "Dest2");
    String[] hgRevs = new String[] { "h1", "h2" };
    Date latestModification = new Date();
    u.checkinFiles(hg2, "h2", a(file1, file2, file3, file4), ModifiedAction.added, org.apache.commons.lang.time.DateUtils.addDays(latestModification, -1));
    u.checkinFiles(hg1, "h1", a(file1, file2, file3, file4), ModifiedAction.added, latestModification);
    ScheduleTestUtil.AddedPipeline pair01 = u.saveConfigWith("pair01", "stageName", u.m(hg1), u.m(hg2));
    u.runAndPass(pair01, hgRevs);
    ReflectionUtil.invoke(pipelineSqlMapDao, "initDao");
    Pipeline pipeline = pipelineService.mostRecentFullPipelineByName("pair01");
    MaterialRevisions materialRevisions = pipeline.getBuildCause().getMaterialRevisions();
    Materials materials = materialRevisions.getMaterials();
    assertThat(materials.size(), is(2));
    assertThat(materials.get(0), is(hg1));
    assertThat(materials.get(1), is(hg2));
}
Also used : MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) Materials(com.thoughtworks.go.config.materials.Materials) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) Material(com.thoughtworks.go.domain.materials.Material) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) File(java.io.File) Date(java.util.Date) Pipeline(com.thoughtworks.go.domain.Pipeline) Test(org.junit.Test)

Aggregations

Materials (com.thoughtworks.go.config.materials.Materials)63 Test (org.junit.Test)47 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)27 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)20 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)19 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)17 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)13 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)12 Material (com.thoughtworks.go.domain.materials.Material)11 Modification (com.thoughtworks.go.domain.materials.Modification)11 HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)10 TimeProvider (com.thoughtworks.go.util.TimeProvider)10 File (java.io.File)10 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)9 Date (java.util.Date)8 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)7 MaterialRevisionsMatchers.containsModifiedFile (com.thoughtworks.go.config.MaterialRevisionsMatchers.containsModifiedFile)5 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)5 P4Material (com.thoughtworks.go.config.materials.perforce.P4Material)5 Stage (com.thoughtworks.go.domain.Stage)5