Search in sources :

Example 6 with Materials

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

the class PipelineSqlMapDaoIntegrationTest method shouldStoreAndRetrieveHgMaterialsFromDatabase.

@Test
public void shouldStoreAndRetrieveHgMaterialsFromDatabase() throws SQLException {
    Materials materials = MaterialsMother.hgMaterials("hgUrl", "hgdir");
    PipelineConfig pipelineConfig = PipelineMother.twoBuildPlansWithResourcesAndMaterials("mingle", "dev");
    pipelineConfig.setMaterialConfigs(materials.convertToConfigs());
    final MaterialRevisions originalMaterialRevision = multipleModificationsInHg(pipelineConfig);
    Pipeline pipeline = instanceFactory.createPipelineInstance(pipelineConfig, BuildCause.createManualForced(originalMaterialRevision, Username.ANONYMOUS), new DefaultSchedulingContext(DEFAULT_APPROVED_BY), md5, new TimeProvider());
    save(pipeline);
    Pipeline pipelineFromDB = pipelineDao.loadPipeline(pipeline.getId());
    final MaterialRevisions materialRevisions = pipelineFromDB.getBuildCause().getMaterialRevisions();
    assertEquals(originalMaterialRevision, materialRevisions);
    assertThat(materialRevisions.getMaterialRevision(0).getRevision().getRevision(), is("9fdcf27f16eadc362733328dd481d8a2c29915e1"));
    assertThat(pipelineFromDB.getMaterials(), is(materials));
}
Also used : TimeProvider(com.thoughtworks.go.util.TimeProvider) Materials(com.thoughtworks.go.config.materials.Materials) Test(org.junit.Test)

Example 7 with Materials

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

the class PipelineSqlMapDaoIntegrationTest method shouldStoreAndRetrieveDependencyMaterials.

@Test
public void shouldStoreAndRetrieveDependencyMaterials() throws SQLException {
    DependencyMaterial dependencyMaterial = new DependencyMaterial(new CaseInsensitiveString("pipeline-name"), new CaseInsensitiveString("stage-name"));
    PipelineConfig pipelineConfig = PipelineMother.twoBuildPlansWithResourcesAndMaterials("mingle", "dev");
    pipelineConfig.setMaterialConfigs(new MaterialConfigs(dependencyMaterial.config()));
    MaterialRevisions materialRevisions = new MaterialRevisions();
    materialRevisions.addRevision(DependencyMaterialRevision.create("pipeline-name", -12, "1234", "stage-name", 1).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) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) Date(java.util.Date) Test(org.junit.Test)

Example 8 with Materials

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

the class PipelineSqlMapDaoIntegrationTest method shouldHaveUrlInGitMaterials.

@Test
public void shouldHaveUrlInGitMaterials() throws SQLException {
    Materials gitMaterials = MaterialsMother.gitMaterials("gitUrl");
    PipelineConfig pipelineConfig = PipelineMother.twoBuildPlansWithResourcesAndMaterials("mingle", "dev");
    pipelineConfig.setMaterialConfigs(gitMaterials.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.getUrl(), is("gitUrl"));
}
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)

Example 9 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) TimeProvider(com.thoughtworks.go.util.TimeProvider) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) Materials(com.thoughtworks.go.config.materials.Materials) Test(org.junit.Test)

Example 10 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 : 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