use of com.thoughtworks.go.util.TimeProvider in project gocd by gocd.
the class PipelineHistoryMother method stageHistory.
public static StageInstanceModels stageHistory(PipelineConfig pipelineConfig, Date modificationDate) {
StageInstanceModels history = new StageInstanceModels();
for (StageConfig stageConfig : pipelineConfig) {
StageInstanceModel item = new StageInstanceModel(CaseInsensitiveString.str(stageConfig.name()), "1", buildHistory(stageConfig, modificationDate));
item.setCounter("1");
item.setApprovalType(new InstanceFactory().createStageInstance(stageConfig, new DefaultSchedulingContext("anyone"), md5, new TimeProvider()).getApprovalType());
if (stageConfig.requiresApproval()) {
item.setApprovedBy(APPROVED_BY);
} else {
item.setApprovedBy(GoConstants.DEFAULT_APPROVED_BY);
}
history.add(item);
}
return history;
}
use of com.thoughtworks.go.util.TimeProvider in project gocd by gocd.
the class ConfigMigrator method migrate.
public static GoConfigMigration migrate(final File configFile) {
ConfigElementImplementationRegistry registry = ConfigElementImplementationRegistryMother.withNoPlugins();
GoConfigMigration upgrader = new GoConfigMigration(new GoConfigMigration.UpgradeFailedHandler() {
public void handle(Exception e) {
String content = "";
try {
content = FileUtil.readContentFromFile(configFile);
} catch (IOException e1) {
}
throw bomb(e.getMessage() + ": content=\n" + content + "\n" + (e.getCause() == null ? "" : e.getCause().getMessage()), e);
}
}, mock(ConfigRepository.class), new TimeProvider(), new ConfigCache(), registry);
//TODO: LYH & GL GoConfigMigration should be able to handle stream instead of binding to file
upgrader.upgradeIfNecessary(configFile, "N/A");
return upgrader;
}
use of com.thoughtworks.go.util.TimeProvider in project gocd by gocd.
the class GoConfigRevisionTest method shouldUnderstandEquality.
@Test
public void shouldUnderstandEquality() {
GoConfigRevision rev1 = new GoConfigRevision("blah", "md5", "loser", "2.2.2", new TimeProvider());
GoConfigRevision rev2 = new GoConfigRevision("blah blah", "md5", "loser 2", "2.2.3", new TimeProvider());
assertThat(rev1, is(rev2));
}
use of com.thoughtworks.go.util.TimeProvider in project gocd by gocd.
the class PipelineWithMultipleStages method scheduleAndCompleteFollowingStages.
protected void scheduleAndCompleteFollowingStages(Pipeline pipeline, JobResult result) {
for (int index = 2; index <= stagesSize; index++) {
StageConfig stageConfig = stageConfig(index);
Stage instance = new InstanceFactory().createStageInstance(stageConfig, new DefaultSchedulingContext("anyone"), "md5-test", new TimeProvider());
instance.setOrderId(index);
dbHelper.getStageDao().saveWithJobs(pipeline, instance);
dbHelper.completeStage(instance, result);
}
}
use of com.thoughtworks.go.util.TimeProvider in project gocd by gocd.
the class PipelineWithRunOnAllJob method scheduleAndCompleteFollowingStages.
protected void scheduleAndCompleteFollowingStages(Pipeline pipeline, JobResult result) {
Stage ft = new InstanceFactory().createStageInstance(ftStage(), new DefaultSchedulingContext("anyone"), "md5-test", new TimeProvider());
ft.setOrderId(pipeline.getFirstStage().getOrderId() + 1);
dbHelper.getStageDao().saveWithJobs(pipeline, ft);
dbHelper.completeStage(ft, result);
}
Aggregations