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));
}
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"));
}
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);
}
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));
}
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);
}
Aggregations