use of org.springframework.transaction.support.TransactionCallback in project gocd by gocd.
the class MaterialRepositoryIntegrationTest method saveOneDependencyModification.
private MaterialRevision saveOneDependencyModification(final DependencyMaterial dependencyMaterial, final String revision, final String label) {
return (MaterialRevision) transactionTemplate.execute(new TransactionCallback() {
@Override
public Object doInTransaction(TransactionStatus status) {
Modification modification = new Modification(new Date(), revision, label, null);
MaterialRevision originalRevision = new MaterialRevision(dependencyMaterial, modification);
repo.save(new MaterialRevisions(originalRevision));
return originalRevision;
}
});
}
use of org.springframework.transaction.support.TransactionCallback in project gocd by gocd.
the class ScheduleHelper method schedule.
public Pipeline schedule(final PipelineConfig pipelineConfig, final BuildCause buildCause, final String approvedBy, final SchedulingContext schedulingContext) {
return (Pipeline) transactionTemplate.execute(new TransactionCallback() {
@Override
public Object doInTransaction(TransactionStatus status) {
materialRepository.save(buildCause.getMaterialRevisions());
Pipeline pipeline = instanceFactory.createPipelineInstance(pipelineConfig, buildCause, schedulingContext, "md5-test", new TimeProvider());
pipeline = pipelineService.save(pipeline);
return pipeline;
}
});
}
use of org.springframework.transaction.support.TransactionCallback in project gocd by gocd.
the class PackageMaterialUpdaterIntegrationTest method shouldUpdateMaterialInstanceWhenPluginIsUpgraded.
@Test
public void shouldUpdateMaterialInstanceWhenPluginIsUpgraded() throws Exception {
final PackageMaterial material = MaterialsMother.packageMaterial();
final MaterialInstance materialInstance = material.createMaterialInstance();
materialRepository.saveOrUpdate(materialInstance);
addMetadata(material, "fieldX", false);
material.getPackageDefinition().getConfiguration().addNewConfiguration("fieldX", true);
final List<Modification> modifications = ModificationsMother.multipleModificationList();
doNothing().when(scmMaterialUpdater).insertLatestOrNewModifications(material, materialInstance, new File(""), new Modifications(modifications));
transactionTemplate.execute(new TransactionCallback() {
@Override
public Object doInTransaction(TransactionStatus transactionStatus) {
packageMaterialUpdater.insertLatestOrNewModifications(material, materialInstance, new File(""), new Modifications(modifications));
return null;
}
});
MaterialInstance actualInstance = materialRepository.findMaterialInstance(material);
assertThat(actualInstance.getConfiguration(), is(material.createMaterialInstance().getConfiguration()));
}
use of org.springframework.transaction.support.TransactionCallback in project gocd by gocd.
the class BuildRepositoryServiceIntegrationTest method schedulePipeline.
private Pipeline schedulePipeline(final PipelineConfig pipeline) {
return (Pipeline) transactionTemplate.execute(new TransactionCallback() {
@Override
public Object doInTransaction(TransactionStatus status) {
MaterialRevisions materialRevisions = new MaterialRevisions();
for (Material material : new MaterialConfigConverter().toMaterials(pipeline.materialConfigs())) {
materialRevisions.addRevision(material, new Modification("user", "comment", null, new Date(), ModificationsMother.nextRevision()));
}
materialRepository.save(materialRevisions);
Pipeline scheduledPipeline = instanceFactory.createPipelineInstance(pipeline, BuildCause.createManualForced(materialRevisions, Username.ANONYMOUS), new DefaultSchedulingContext(DEFAULT_APPROVED_BY), md5, new TimeProvider());
pipelineService.save(scheduledPipeline);
return scheduledPipeline;
}
});
}
use of org.springframework.transaction.support.TransactionCallback in project gocd by gocd.
the class BuildRepositoryServiceIntegrationTest method createNewPipelineWithFirstStageFailed.
private Stage createNewPipelineWithFirstStageFailed() throws Exception {
return (Stage) transactionTemplate.execute(new TransactionCallback() {
@Override
public Object doInTransaction(TransactionStatus status) {
Pipeline forcedPipeline = instanceFactory.createPipelineInstance(mingle, modifySomeFiles(mingle), new DefaultSchedulingContext(DEFAULT_APPROVED_BY), md5, new TimeProvider());
materialRepository.save(forcedPipeline.getBuildCause().getMaterialRevisions());
pipelineService.save(forcedPipeline);
Stage stage = forcedPipeline.getFirstStage();
dbHelper.failStage(stage);
return stage;
}
});
}
Aggregations