Search in sources :

Example 31 with Materials

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

the class PipelineSqlMapDaoIntegrationTest method shouldStoreAndRetrieveSvnMaterials.

@Test
public void shouldStoreAndRetrieveSvnMaterials() throws SQLException {
    SvnMaterial svnMaterial = svnMaterial("svnUrl", "folder");
    PipelineConfig pipelineConfig = PipelineMother.twoBuildPlansWithResourcesAndMaterials("mingle", "dev");
    pipelineConfig.setMaterialConfigs(new MaterialConfigs(svnMaterial.config()));
    MaterialRevisions materialRevisions = new MaterialRevisions();
    materialRevisions.addRevision(svnMaterial, ModificationsMother.multipleModificationList());
    Pipeline pipeline = instanceFactory.createPipelineInstance(pipelineConfig, BuildCause.createManualForced(materialRevisions, Username.ANONYMOUS), new DefaultSchedulingContext(DEFAULT_APPROVED_BY), md5, new TimeProvider());
    assertNotInserted(pipeline.getId());
    savePipeline(pipeline);
    Pipeline pipelineFromDB = pipelineDao.loadPipeline(pipeline.getId());
    final Materials materials = pipelineFromDB.getMaterials();
    assertThat(materials.get(0), is(svnMaterial));
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) PipelineConfig(com.thoughtworks.go.config.PipelineConfig) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) Materials(com.thoughtworks.go.config.materials.Materials) Test(org.junit.Test)

Example 32 with Materials

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

the class PipelineSqlMapDaoIntegrationTest method shouldSupportSubmoduleFolderInGitMaterials.

@Test
public void shouldSupportSubmoduleFolderInGitMaterials() throws Exception {
    Materials materials = MaterialsMother.gitMaterials("gitUrl", "submoduleFolder", null);
    PipelineConfig pipelineConfig = PipelineMother.twoBuildPlansWithResourcesAndMaterials("mingle", "dev");
    pipelineConfig.setMaterialConfigs(materials.convertToConfigs());
    Pipeline pipeline = instanceFactory.createPipelineInstance(pipelineConfig, BuildCause.createManualForced(modifyOneFile(pipelineConfig), Username.ANONYMOUS), new DefaultSchedulingContext(DEFAULT_APPROVED_BY), md5, new TimeProvider());
    assertNotInserted(pipeline.getId());
    save(pipeline);
    Pipeline pipelineFromDB = pipelineDao.loadPipeline(pipeline.getId());
    Materials materialsFromDB = pipelineFromDB.getMaterials();
    GitMaterial gitMaterial = (GitMaterial) materialsFromDB.get(0);
    assertThat(gitMaterial.getSubmoduleFolder(), is("submoduleFolder"));
}
Also used : PipelineConfig(com.thoughtworks.go.config.PipelineConfig) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) Materials(com.thoughtworks.go.config.materials.Materials) Test(org.junit.Test)

Example 33 with Materials

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

the class SvnMultipleMaterialsTest method shouldNotThrowNPEIfTheWorkingDirectoryIsEmpty.

@Test
public void shouldNotThrowNPEIfTheWorkingDirectoryIsEmpty() throws Exception {
    SvnMaterial svnMaterial1 = repo.createMaterial("multiple-materials/trunk/part1", "part1");
    SvnMaterial svnMaterial2 = repo.createMaterial("multiple-materials/trunk/part2", "part2");
    Materials materials = new Materials(svnMaterial1, svnMaterial2);
    Revision revision = latestRevision(svnMaterial1, pipelineDir, new TestSubprocessExecutionContext());
    updateMaterials(materials, revision);
    FileUtil.deleteFolder(pipelineDir);
    updateMaterials(materials, revision);
}
Also used : MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) Materials(com.thoughtworks.go.config.materials.Materials) Test(org.junit.Test)

Example 34 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 35 with Materials

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

the class MaterialRevisionBuilder method depInstance.

public Tuple depInstance(String pipelineName, int counter, Date modifiedTime, Tuple... buildCause) {
    String key = key(pipelineName, counter, modifiedTime);
    if (!instanceToRevision.containsKey(key)) {
        if (buildCause.length == 0) {
            throw new RuntimeException("Cannot create instance without a buildcause. You can retrive it without buildcause once it has been created");
        }
        DependencyMaterial material = new DependencyMaterial(new CaseInsensitiveString(pipelineName), new CaseInsensitiveString(STAGE_NAME));
        DependencyMaterialRevision revision = DependencyMaterialRevision.create(pipelineName, counter, "label", STAGE_NAME, 1);
        instanceToRevision.put(key, revision.convert(material, modifiedTime));
        final long id = getNextId();
        org.mockito.Mockito.when(pipelineDao.findPipelineByNameAndCounter(pipelineName, counter)).thenReturn(pipeline(id));
        org.mockito.Mockito.when(materialRepository.findMaterialRevisionsForPipeline(id)).thenReturn(buildCauseOfThisPipeline(buildCause));
    }
    MaterialRevision materialRevision = instanceToRevision.get(key);
    Materials materials = new Materials();
    for (MaterialRevision revision : buildCauseOfThisPipeline(buildCause)) {
        materials.add(revision.getMaterial());
    }
    PipelineConfig config = new PipelineConfig(new CaseInsensitiveString(pipelineName), materials.convertToConfigs(), new StageConfig(new CaseInsensitiveString(STAGE_NAME), new JobConfigs()));
    return new Tuple(new PipelineConfigDependencyGraph(config, dependencyGraphsFor(buildCause)), materialRevision);
}
Also used : PipelineConfig(com.thoughtworks.go.config.PipelineConfig) Materials(com.thoughtworks.go.config.materials.Materials) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) DependencyMaterialRevision(com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) StageConfig(com.thoughtworks.go.config.StageConfig) PipelineConfigDependencyGraph(com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph) JobConfigs(com.thoughtworks.go.config.JobConfigs) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) DependencyMaterialRevision(com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision)

Aggregations

Materials (com.thoughtworks.go.config.materials.Materials)58 Test (org.junit.Test)48 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)24 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)19 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)19 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)16 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)14 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)13 Material (com.thoughtworks.go.domain.materials.Material)10 Modification (com.thoughtworks.go.domain.materials.Modification)10 File (java.io.File)10 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)9 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)9 Date (java.util.Date)9 HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)8 MaterialRevisionsMatchers.containsModifiedFile (com.thoughtworks.go.config.MaterialRevisionsMatchers.containsModifiedFile)5 P4Material (com.thoughtworks.go.config.materials.perforce.P4Material)5 Stage (com.thoughtworks.go.domain.Stage)5 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)5 PackageMaterial (com.thoughtworks.go.config.materials.PackageMaterial)4