use of com.thoughtworks.go.util.TimeProvider in project gocd by gocd.
the class PipelineScheduleQueueIntegrationTest method shouldCreatePipelineIfBuildCauseIsNotTrumped.
@Test
public void shouldCreatePipelineIfBuildCauseIsNotTrumped() throws Exception {
PipelineConfig pipelineConfig = fixture.pipelineConfig();
BuildCause cause = modifySomeFiles(pipelineConfig);
saveRev(cause);
queue.schedule(fixture.pipelineName, cause);
assertThat(queue.createPipeline(cause, pipelineConfig, new DefaultSchedulingContext(cause.getApprover(), new Agents()), "md5-test", new TimeProvider()), is(not(nullValue())));
}
use of com.thoughtworks.go.util.TimeProvider in project gocd by gocd.
the class MaterialRepositoryIntegrationTest method hasPipelineEverRunWith_shouldCacheResultsForPipelineNameMaterialIdAndModificationId.
@Test
public void hasPipelineEverRunWith_shouldCacheResultsForPipelineNameMaterialIdAndModificationId() {
HgMaterial hgMaterial = MaterialsMother.hgMaterial("hgUrl", "dest");
MaterialRevision materialRevision = saveOneScmModification(hgMaterial, "user", "file");
PipelineConfig pipelineConfig = PipelineMother.createPipelineConfig("mingle", new MaterialConfigs(hgMaterial.config()), "dev");
MaterialRevisions materialRevisions = new MaterialRevisions(materialRevision);
Pipeline pipeline = instanceFactory.createPipelineInstance(pipelineConfig, BuildCause.createManualForced(materialRevisions, Username.ANONYMOUS), new DefaultSchedulingContext(DEFAULT_APPROVED_BY), md5, new TimeProvider());
GoCache spyGoCache = spy(goCache);
when(spyGoCache.get(any(String.class))).thenCallRealMethod();
Mockito.doCallRealMethod().when(spyGoCache).put(any(String.class), any(Object.class));
repo = new MaterialRepository(sessionFactory, spyGoCache, 2, transactionSynchronizationManager, materialConfigConverter, materialExpansionService, databaseStrategy);
pipelineSqlMapDao.save(pipeline);
MaterialRevisions revisions = new MaterialRevisions(new MaterialRevision(hgMaterial, materialRevision.getLatestModification()));
assertThat("should hit the db and cache it", repo.hasPipelineEverRunWith("mingle", revisions), is(true));
assertThat("should have cached the result on the previous call", repo.hasPipelineEverRunWith("mingle", revisions), is(true));
verify(spyGoCache, times(1)).put(any(String.class), eq(Boolean.TRUE));
}
use of com.thoughtworks.go.util.TimeProvider in project gocd by gocd.
the class MaterialRepositoryIntegrationTest method hasPipelineEverRunWith.
@Test
public void hasPipelineEverRunWith() {
HgMaterial hgMaterial = MaterialsMother.hgMaterial("hgUrl", "dest");
MaterialRevision materialRevision = saveOneScmModification(hgMaterial, "user", "file");
PipelineConfig pipelineConfig = PipelineMother.createPipelineConfig("mingle", new MaterialConfigs(hgMaterial.config()), "dev");
MaterialRevisions materialRevisions = new MaterialRevisions(materialRevision);
Pipeline pipeline = instanceFactory.createPipelineInstance(pipelineConfig, BuildCause.createManualForced(materialRevisions, Username.ANONYMOUS), new DefaultSchedulingContext(DEFAULT_APPROVED_BY), md5, new TimeProvider());
pipelineSqlMapDao.save(pipeline);
MaterialRevisions revisions = new MaterialRevisions(new MaterialRevision(hgMaterial, materialRevision.getLatestModification()));
assertThat(repo.hasPipelineEverRunWith("mingle", revisions), is(true));
}
use of com.thoughtworks.go.util.TimeProvider in project gocd by gocd.
the class MaterialRepositoryIntegrationTest method hasPipelineEverRunWithMultipleMaterialsAndMultipleRuns.
@Test
public void hasPipelineEverRunWithMultipleMaterialsAndMultipleRuns() {
HgMaterial hgMaterial1 = MaterialsMother.hgMaterial("hgUrl", "dest");
MaterialRevision hgMaterialRevision1 = saveOneScmModification(hgMaterial1, "user", "file");
DependencyMaterial depMaterial1 = new DependencyMaterial(new CaseInsensitiveString("blahPipeline"), new CaseInsensitiveString("blahStage"));
MaterialRevision depMaterialRevision1 = saveOneDependencyModification(depMaterial1, "blahPipeline/1/blahStage/1");
PipelineConfig pipelineConfig = PipelineMother.createPipelineConfig("mingle", new MaterialConfigs(hgMaterial1.config(), depMaterial1.config()), "dev");
MaterialRevisions materialRevisions1 = new MaterialRevisions(hgMaterialRevision1, depMaterialRevision1);
pipelineSqlMapDao.save(instanceFactory.createPipelineInstance(pipelineConfig, BuildCause.createManualForced(materialRevisions1, Username.ANONYMOUS), new DefaultSchedulingContext(DEFAULT_APPROVED_BY), md5, new TimeProvider()));
HgMaterial hgMaterial2 = MaterialsMother.hgMaterial("hgUrl", "dest");
MaterialRevision hgMaterialRevision2 = saveOneScmModification(hgMaterial2, "user", "file");
DependencyMaterial depMaterial2 = new DependencyMaterial(new CaseInsensitiveString("blahPipeline"), new CaseInsensitiveString("blahStage"));
MaterialRevision depMaterialRevision2 = saveOneDependencyModification(depMaterial2, "blahPipeline/2/blahStage/1");
PipelineConfig pipelineConfig2 = PipelineMother.createPipelineConfig("mingle", new MaterialConfigs(hgMaterial2.config(), depMaterial2.config()), "dev");
MaterialRevisions materialRevisions2 = new MaterialRevisions(hgMaterialRevision2, depMaterialRevision2);
savePipeline(instanceFactory.createPipelineInstance(pipelineConfig2, BuildCause.createManualForced(materialRevisions2, Username.ANONYMOUS), new DefaultSchedulingContext(DEFAULT_APPROVED_BY), md5, new TimeProvider()));
MaterialRevisions revisions = new MaterialRevisions(new MaterialRevision(depMaterial1, depMaterialRevision1.getLatestModification()), new MaterialRevision(hgMaterial2, hgMaterialRevision2.getLatestModification()));
assertThat(repo.hasPipelineEverRunWith("mingle", revisions), is(true));
}
use of com.thoughtworks.go.util.TimeProvider in project gocd by gocd.
the class MaterialRepositoryIntegrationTest method savePipelineAndCreate_DMRs.
private DependencyMaterial savePipelineAndCreate_DMRs(Date d, MaterialRevisions hgMaterialRevisions, PipelineConfig config, int... dmrStageCounters) {
Pipeline pipeline = savePipeline(instanceFactory.createPipelineInstance(config, BuildCause.createWithModifications(hgMaterialRevisions, "Loser"), new DefaultSchedulingContext(DEFAULT_APPROVED_BY), md5, new TimeProvider()));
CaseInsensitiveString stageName = config.get(0).name();
DependencyMaterial material = new DependencyMaterial(config.name(), stageName);
String label = pipeline.getLabel();
ArrayList<Modification> mods = new ArrayList<>();
for (int i = 0; i < dmrStageCounters.length; i++) {
int dmrStageCounter = dmrStageCounters[i];
StageIdentifier stageIdentifier = new StageIdentifier(pipeline.getIdentifier(), CaseInsensitiveString.str(stageName), String.valueOf(dmrStageCounter));
mods.add(new Modification(d, stageIdentifier.getStageLocator(), label, pipeline.getId()));
}
final MaterialRevision materialRevision = new MaterialRevision(material, mods);
transactionTemplate.execute(new TransactionCallback() {
public Object doInTransaction(TransactionStatus status) {
repo.saveMaterialRevision(materialRevision);
return null;
}
});
return material;
}
Aggregations