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);
}
use of com.thoughtworks.go.config.materials.Materials in project gocd by gocd.
the class PipelineSqlMapDaoIntegrationTest method shouldPersistMaterialsWithRealPassword.
@Test
public void shouldPersistMaterialsWithRealPassword() {
MaterialRevisions materialRevisions = new MaterialRevisions();
addRevision(materialRevisions, MaterialsMother.svnMaterial("http://username:password@localhost"));
addRevision(materialRevisions, MaterialsMother.hgMaterial("http://username:password@localhost"));
addRevision(materialRevisions, new GitMaterial("git://username:password@localhost"));
addRevision(materialRevisions, new P4Material("localhost:1666", "view"));
BuildCause buildCause = BuildCause.createManualForced(materialRevisions, Username.ANONYMOUS);
Pipeline pipeline = new Pipeline("Test", buildCause);
save(pipeline);
Pipeline loaded = pipelineDao.mostRecentPipeline("Test");
Materials materials = loaded.getMaterials();
for (Material material : materials) {
assertThat(((ScmMaterial) material).getUrl(), not(containsString("******")));
}
}
use of com.thoughtworks.go.config.materials.Materials in project gocd by gocd.
the class BuildCauseProducerServiceIntegrationSvnTest method shouldCreateBuildCauseWithModifications.
@Test
public void shouldCreateBuildCauseWithModifications() throws Exception {
repositoryForMaterial(new SvnTestRepo(tempDir));
prepareAPipelineWithHistory();
checkInFiles("foo");
ServerHealthStateOperationResult result = new ServerHealthStateOperationResult();
materialDatabaseUpdater.updateMaterial(svnMaterial);
buildCauseProducerService.autoSchedulePipeline(CaseInsensitiveString.str(mingleConfig.name()), result, 123);
assertThat(result.canContinue(), is(true));
BuildCause mingleBuildCause = pipelineScheduleQueue.toBeScheduled().get(mingleConfig.name());
MaterialRevisions materialRevisions = mingleBuildCause.getMaterialRevisions();
assertThat(materialRevisions.getRevisions().size(), is(1));
Materials materials = materialRevisions.getMaterials();
assertThat(materials.size(), is(1));
assertThat(materials.get(0), is(svnMaterial));
}
use of com.thoughtworks.go.config.materials.Materials in project gocd by gocd.
the class BuildCauseProducerServiceIntegrationSvnTest method shouldCreateBuildCauseWithModificationsForSvnRepoWithExternal.
@Test
public void shouldCreateBuildCauseWithModificationsForSvnRepoWithExternal() throws Exception {
SvnTestRepoWithExternal repo = new SvnTestRepoWithExternal(tempDir);
repositoryForMaterial(repo);
prepareAPipelineWithHistory();
checkInFiles("foo");
ServerHealthStateOperationResult result = new ServerHealthStateOperationResult();
materialDatabaseUpdater.updateMaterial(svnMaterial);
buildCauseProducerService.autoSchedulePipeline(CaseInsensitiveString.str(mingleConfig.name()), result, 123);
assertThat(result.canContinue(), is(true));
BuildCause mingleBuildCause = pipelineScheduleQueue.toBeScheduled().get(mingleConfig.name());
MaterialRevisions materialRevisions = mingleBuildCause.getMaterialRevisions();
assertThat(materialRevisions.getRevisions().size(), is(2));
Materials materials = materialRevisions.getMaterials();
assertThat(materials.size(), is(2));
assertThat(materials.get(0), is(svnMaterial));
SvnMaterial external = (SvnMaterial) materials.get(1);
assertThat(external.getUrl(), is(repo.externalRepositoryUrl()));
}
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.lang3.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);
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));
}
Aggregations