use of com.thoughtworks.go.util.TimeProvider 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.util.TimeProvider 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.util.TimeProvider in project gocd by gocd.
the class PipelineSqlMapDaoIntegrationTest method shouldStoreAndRetrieveMultipleSvnMaterials.
@Test
public void shouldStoreAndRetrieveMultipleSvnMaterials() throws SQLException {
SvnMaterial svnMaterial1 = svnMaterial("svnUrl1", "folder1");
SvnMaterial svnMaterial2 = svnMaterial("svnUrl2", "folder2");
PipelineConfig pipelineConfig = PipelineMother.twoBuildPlansWithResourcesAndMaterials("mingle", "dev");
pipelineConfig.setMaterialConfigs(new MaterialConfigs(svnMaterial1.config(), svnMaterial2.config()));
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();
assertThat(materials, hasItem((Material) svnMaterial1));
assertThat(materials, hasItem((Material) svnMaterial2));
}
use of com.thoughtworks.go.util.TimeProvider in project gocd by gocd.
the class PipelineSqlMapDaoIntegrationTest method shouldHaveServerAndPortAndViewAndUseTicketsInP4Materials.
@Test
public void shouldHaveServerAndPortAndViewAndUseTicketsInP4Materials() throws SQLException {
String p4view = "//depot/... //localhost/...";
Materials p4Materials = MaterialsMother.p4Materials(p4view);
P4Material p4Material = (P4Material) p4Materials.first();
p4Material.setUseTickets(true);
PipelineConfig pipelineConfig = PipelineMother.twoBuildPlansWithResourcesAndMaterials("mingle", "dev");
pipelineConfig.setMaterialConfigs(p4Materials.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();
assertThat(materials.get(0), is(p4Material));
}
use of com.thoughtworks.go.util.TimeProvider in project gocd by gocd.
the class PipelineSqlMapDaoIntegrationTest method shouldThrowExceptionWhenBuildCauseIsAskedForAPipelineWithInvalidCounter.
@Test
public void shouldThrowExceptionWhenBuildCauseIsAskedForAPipelineWithInvalidCounter() {
String pipelineName = "P1";
PipelineConfig pipelineConfig = PipelineConfigMother.createPipelineConfigWithStages(pipelineName, "S1");
String username = "username";
BuildCause manualForced = BuildCause.createManualForced(modifyOneFile(pipelineConfig), new Username(new CaseInsensitiveString(username)));
Pipeline pipeline = dbHelper.schedulePipeline(pipelineConfig, manualForced, username, new TimeProvider());
dbHelper.pass(pipeline);
BuildCause buildCause = pipelineDao.findBuildCauseOfPipelineByNameAndCounter(pipelineName, 1);
assertThat(buildCause, is(notNullValue()));
try {
pipelineDao.findBuildCauseOfPipelineByNameAndCounter(pipelineName, 10);
fail("should have thrown PipelineNotFoundException");
} catch (Exception e) {
assertThat(e instanceof PipelineNotFoundException, is(true));
assertThat(e.getMessage(), is("Pipeline P1 with counter 10 was not found"));
}
}
Aggregations