use of com.thoughtworks.go.util.TimeProvider in project gocd by gocd.
the class MaterialRepositoryIntegrationTest method hasPipelineEverRunWithMultipleMaterialsInPeggedRevisionsCase.
@Test
public void hasPipelineEverRunWithMultipleMaterialsInPeggedRevisionsCase() {
HgMaterial firstMaterial = MaterialsMother.hgMaterial("first", "dest");
MaterialRevision first1 = saveOneScmModification("first1", firstMaterial, "user", "file", "comment");
MaterialRevision first2 = saveOneScmModification("first2", firstMaterial, "user", "file", "comment");
HgMaterial secondMaterial = MaterialsMother.hgMaterial("second", "dest");
MaterialRevision second1 = saveOneScmModification("second1", secondMaterial, "user", "file", "comment");
MaterialRevision second2 = saveOneScmModification("second2", secondMaterial, "user", "file", "comment");
MaterialRevisions firstRun = new MaterialRevisions(first1, second2);
MaterialRevisions secondRun = new MaterialRevisions(first2, second1);
PipelineConfig config = PipelineMother.createPipelineConfig("mingle", new MaterialConfigs(firstMaterial.config(), secondMaterial.config()), "dev");
savePipeline(instanceFactory.createPipelineInstance(config, BuildCause.createWithModifications(firstRun, "Pavan"), new DefaultSchedulingContext(DEFAULT_APPROVED_BY), md5, new TimeProvider()));
savePipeline(instanceFactory.createPipelineInstance(config, BuildCause.createWithModifications(secondRun, "Shilpa-who-gets-along-well-with-her"), new DefaultSchedulingContext(DEFAULT_APPROVED_BY), md5, new TimeProvider()));
assertThat(repo.hasPipelineEverRunWith("mingle", new MaterialRevisions(first2, second2)), is(true));
}
use of com.thoughtworks.go.util.TimeProvider in project gocd by gocd.
the class MaterialRepositoryIntegrationTest method hasPipelineEverRunWithIsFalseWhenThereAreNewerModificationsThatHaveNotBeenBuilt.
@Test
public void hasPipelineEverRunWithIsFalseWhenThereAreNewerModificationsThatHaveNotBeenBuilt() {
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);
MaterialRevision notBuiltRevision = saveOneScmModification(hgMaterial, "user", "file2");
MaterialRevisions revisions = new MaterialRevisions(new MaterialRevision(hgMaterial, notBuiltRevision.getLatestModification()));
assertThat(repo.hasPipelineEverRunWith("mingle", revisions), is(false));
}
use of com.thoughtworks.go.util.TimeProvider in project gocd by gocd.
the class PipelineHistoryServiceIntegrationTest method findMatchingPipelineInstances_shouldShowExpectedNumberOfMatchesWhenThePipelineHasMultipleStagesAndJobs.
@Test
public void findMatchingPipelineInstances_shouldShowExpectedNumberOfMatchesWhenThePipelineHasMultipleStagesAndJobs() {
final int limit = 2;
PipelineConfig pipelineConfig = PipelineConfigMother.createPipelineConfigWithStages("pipeline_name");
pipelineConfig.add(StageConfigMother.custom("stage-1", "job-1", "job-2", "job-3", "job-4"));
goConfigService.addPipeline(pipelineConfig, "pipeline-group");
pipelineConfig.setLabelTemplate("${COUNT}");
Pipeline shouldMatch1 = dbHelper.schedulePipeline(pipelineConfig, ModificationsMother.buildCauseForOneModifiedFile(pipelineConfig, "abc-revision-should-match", "comment", "committer"), new TimeProvider());
dbHelper.cancelStage(shouldMatch1.getStages().get(0));
Pipeline shouldMatch2 = dbHelper.schedulePipeline(pipelineConfig, ModificationsMother.buildCauseForOneModifiedFile(pipelineConfig, "this-abc-revision-should-match-too", "another comment", "committer"), new TimeProvider());
dbHelper.cancelStage(shouldMatch2.getStages().get(0));
PipelineInstanceModels actual = pipelineHistoryService.findMatchingPipelineInstances("pipeline_name", "abc", limit, new Username(new CaseInsensitiveString("user")), new HttpLocalizedOperationResult());
assertThat("size", actual.size(), is(2));
assertThat("first counter", actual.get(0).getCounter(), is(shouldMatch2.getCounter()));
assertThat("second counter", actual.get(1).getCounter(), is(shouldMatch1.getCounter()));
}
use of com.thoughtworks.go.util.TimeProvider in project gocd by gocd.
the class PipelineHistoryServiceIntegrationTest method shouldReturnListOfPipelineInstancesByPageNumber.
@Test
public void shouldReturnListOfPipelineInstancesByPageNumber() {
final int limit = 1;
PipelineConfig pipelineConfig = PipelineConfigMother.createPipelineConfig("mingle", "stage", "job");
goConfigService.addPipeline(pipelineConfig, "pipeline-group");
Pipeline instance1 = dbHelper.schedulePipeline(pipelineConfig, new TimeProvider());
dbHelper.cancelStage(instance1.getStages().get(0));
Pipeline instance2 = dbHelper.schedulePipeline(pipelineConfig, new TimeProvider());
dbHelper.passStage(instance2.getStages().get(0));
Pipeline instance3 = dbHelper.schedulePipeline(pipelineConfig, new TimeProvider());
dbHelper.passStage(instance3.getStages().get(0));
PipelineInstanceModels actual = pipelineHistoryService.findPipelineInstancesByPageNumber(instance2.getName(), 2, limit, "admin");
assertThat(actual.size(), is(1));
assertThat(actual.get(0).getCounter(), is(2));
assertThat(actual.getPagination(), is(Pagination.pageStartingAt(1, 3, limit)));
}
use of com.thoughtworks.go.util.TimeProvider in project gocd by gocd.
the class PipelineHistoryServiceIntegrationTest method findMatchingPipelineInstances_shouldMatchLabels.
@Test
public void findMatchingPipelineInstances_shouldMatchLabels() {
final int limit = 10;
PipelineConfig pipelineConfig = PipelineConfigMother.createPipelineConfig("pipeline_name", "stage", "job");
goConfigService.addPipeline(pipelineConfig, "pipeline-group");
pipelineConfig.setLabelTemplate("${COUNT}-blah-1");
Pipeline instance1 = dbHelper.schedulePipeline(pipelineConfig, new TimeProvider());
dbHelper.cancelStage(instance1.getStages().get(0));
pipelineConfig.setLabelTemplate("${COUNT}-blah-2");
Pipeline instance2 = dbHelper.schedulePipeline(pipelineConfig, new TimeProvider());
dbHelper.passStage(instance2.getStages().get(0));
pipelineConfig.setLabelTemplate("${COUNT}-blah-1-1");
Pipeline instance3 = dbHelper.schedulePipeline(pipelineConfig, new TimeProvider());
dbHelper.passStage(instance3.getStages().get(0));
pipelineConfig.setLabelTemplate("${COUNT}-blaH-1-2");
Pipeline instance4 = dbHelper.schedulePipeline(pipelineConfig, new TimeProvider());
dbHelper.passStage(instance4.getStages().get(0));
PipelineInstanceModels actual = pipelineHistoryService.findMatchingPipelineInstances("pipeline_name", "h-1", limit, new Username(new CaseInsensitiveString("user")), new HttpLocalizedOperationResult());
assertThat(actual.size(), is(3));
assertThat(actual.get(0).getCounter(), is(4));
assertThat(actual.get(1).getCounter(), is(3));
assertThat(actual.get(2).getCounter(), is(1));
}
Aggregations