Search in sources :

Example 61 with Materials

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

the class PipelineSqlMapDaoIntegrationTest method shouldStoreAndRetrieveDependencyMaterialsWithMaxAllowedRevision.

@Test
public void shouldStoreAndRetrieveDependencyMaterialsWithMaxAllowedRevision() throws SQLException {
    char[] name = new char[255];
    for (int i = 0; i < 255; i++) {
        name[i] = 'a';
    }
    final String s = new String(name);
    final String s1 = new String(name);
    DependencyMaterial dependencyMaterial = new DependencyMaterial(new CaseInsensitiveString(s), new CaseInsensitiveString(s1));
    PipelineConfig pipelineConfig = PipelineMother.twoBuildPlansWithResourcesAndMaterials("mingle", "dev");
    pipelineConfig.setMaterialConfigs(new MaterialConfigs(dependencyMaterial.config()));
    MaterialRevisions materialRevisions = new MaterialRevisions();
    DependencyMaterialRevision revision = DependencyMaterialRevision.create(new String(name), -10, new String(name), new String(name), Integer.MAX_VALUE);
    materialRevisions.addRevision(revision.convert(dependencyMaterial, new Date()));
    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(dependencyMaterial));
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) TimeProvider(com.thoughtworks.go.util.TimeProvider) Materials(com.thoughtworks.go.config.materials.Materials) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) DependencyMaterialRevision(com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision) Date(java.util.Date) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) Test(org.junit.Test)

Example 62 with Materials

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

the class PipelineSqlMapDaoIntegrationTest method shouldSupportMultipleP4Materials.

@Test
public void shouldSupportMultipleP4Materials() throws SQLException {
    String p4view1 = "//depot1/... //localhost1/...";
    String p4view2 = "//depot2/... //localhost2/...";
    Material p4Material1 = MaterialsMother.p4Materials(p4view1).get(0);
    Material p4Material2 = MaterialsMother.p4Materials(p4view2).get(0);
    Materials materials = new Materials(p4Material1, p4Material2);
    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());
    savePipeline(pipeline);
    Pipeline pipelineFromDB = pipelineDao.loadPipeline(pipeline.getId());
    final Materials loaded = pipelineFromDB.getMaterials();
    assertThat(loaded.get(0), is(p4Material1));
    assertThat(loaded.get(1), is(p4Material2));
}
Also used : TimeProvider(com.thoughtworks.go.util.TimeProvider) Materials(com.thoughtworks.go.config.materials.Materials) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) MaterialsMother.svnMaterial(com.thoughtworks.go.helper.MaterialsMother.svnMaterial) ScmMaterial(com.thoughtworks.go.config.materials.ScmMaterial) Material(com.thoughtworks.go.domain.materials.Material) P4Material(com.thoughtworks.go.config.materials.perforce.P4Material) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Test(org.junit.Test)

Example 63 with Materials

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

the class PipelineSqlMapDaoIntegrationTest method shouldSupportBranchInGitMaterials.

@Test
public void shouldSupportBranchInGitMaterials() throws Exception {
    Materials branchedMaterials = MaterialsMother.gitMaterials("gitUrl", "foo");
    PipelineConfig pipelineConfig = PipelineMother.twoBuildPlansWithResourcesAndMaterials("mingle", "dev");
    pipelineConfig.setMaterialConfigs(branchedMaterials.convertToConfigs());
    Pipeline pipeline = instanceFactory.createPipelineInstance(pipelineConfig, BuildCause.createManualForced(modifyOneFile(pipelineConfig), Username.ANONYMOUS), new DefaultSchedulingContext(DEFAULT_APPROVED_BY), md5, new TimeProvider());
    assertNotInserted(pipeline.getId());
    savePipeline(pipeline);
    Pipeline pipelineFromDB = pipelineDao.loadPipeline(pipeline.getId());
    Materials materials = pipelineFromDB.getMaterials();
    GitMaterial gitMaterial = (GitMaterial) materials.get(0);
    assertThat(gitMaterial.getBranch(), is("foo"));
}
Also used : TimeProvider(com.thoughtworks.go.util.TimeProvider) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) Materials(com.thoughtworks.go.config.materials.Materials) 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