use of com.thoughtworks.go.util.TimeProvider in project gocd by gocd.
the class StageMother method createStageWithFakeDuration.
private static Stage createStageWithFakeDuration(String pipelineName, int pipelineCounter, String stageName, int stageCounter, String jobName, final DateTime scheduleTime, DateTime completedTime, JobResult jobResult) {
TimeProvider timeProvider = new TimeProvider() {
@Override
public Date currentTime() {
return scheduleTime.toDate();
}
public DateTime currentDateTime() {
throw new UnsupportedOperationException("Not implemented");
}
public DateTime timeoutTime(Timeout timeout) {
throw new UnsupportedOperationException("Not implemented");
}
};
JobInstance firstJob = new JobInstance(jobName, timeProvider);
JobInstances jobInstances = new JobInstances(firstJob);
Stage stage = StageMother.custom(pipelineName, stageName, jobInstances);
firstJob.assign("AGENT-1", completedTime.toDate());
firstJob.completing(jobResult, completedTime.toDate());
firstJob.completed(completedTime.toDate());
stage.calculateResult();
stage.setCreatedTime(new Timestamp(timeProvider.currentTime().getTime()));
stage.setLastTransitionedTime(new Timestamp(completedTime.toDate().getTime()));
stage.setIdentifier(new StageIdentifier(pipelineName, pipelineCounter, "LABEL-" + pipelineCounter, stageName, String.valueOf(stageCounter)));
return stage;
}
use of com.thoughtworks.go.util.TimeProvider in project gocd by gocd.
the class StageMother method custom.
public static Stage custom(String pipelineName, String stageName, JobInstances instances) {
Stage stage = new Stage(stageName, instances, DEFAULT_APPROVED_BY, GoConstants.APPROVAL_SUCCESS, new TimeProvider());
stage.setIdentifier(new StageIdentifier(pipelineName, 1, "1", stageName, "1"));
stage.building();
return stage;
}
use of com.thoughtworks.go.util.TimeProvider in project gocd by gocd.
the class StageNotificationServiceTest method stubPipelineAndStage.
private void stubPipelineAndStage(Date date) {
final PipelineConfig pipelineConfig = PipelineConfigMother.createPipelineConfig("go", "dev", "compile", "test", "twist");
final Modification svnModification = new Modification("lgao", "Fixing the not checked in files", "jez@cruise.com", date, "123");
svnModification.createModifiedFile("build.xml", "some_dir", ModifiedAction.added);
svnModification.createModifiedFile("some.xml", "other_dir", ModifiedAction.deleted);
Pipeline pipeline = instanceFactory.createPipelineInstance(pipelineConfig, new ManualBuild(new Username(new CaseInsensitiveString("loser"))).onModifications(new MaterialRevisions(new MaterialRevision(new MaterialConfigConverter().toMaterials(pipelineConfig.materialConfigs()).get(0), svnModification)), false, null), new DefaultSchedulingContext("loser"), "md5-test", new TimeProvider());
Stage stage = pipeline.getStages().get(0);
when(stageService.findStageWithIdentifier(stageIdentifier)).thenReturn(stage);
stage.setPipelineId(100L);
when(pipelineService.fullPipelineById(100)).thenReturn(pipeline);
}
use of com.thoughtworks.go.util.TimeProvider in project gocd by gocd.
the class PipelineBuilder method addJob.
public void addJob(String jobName) {
JobInstance instance = new JobInstance(jobName, new TimeProvider());
currentStage().getJobInstances().add(instance);
}
use of com.thoughtworks.go.util.TimeProvider in project gocd by gocd.
the class JobRerunScheduleServiceTest method setup.
@Before
public void setup() {
jobInstanceService = mock(JobInstanceService.class);
goConfigService = mock(GoConfigService.class);
environmentConfigService = mock(EnvironmentConfigService.class);
serverHealthService = mock(ServerHealthService.class);
final TestTransactionSynchronizationManager synchronizationManager = new TestTransactionSynchronizationManager();
schedulingChecker = mock(SchedulingCheckerService.class);
pipelineScheduleQueue = mock(PipelineScheduleQueue.class);
pipelineService = mock(PipelineService.class);
stageService = mock(StageService.class);
securityService = mock(SecurityService.class);
lockService = mock(PipelineLockService.class);
txnTemplate = new TestTransactionTemplate(synchronizationManager);
timeProvider = new TimeProvider();
instanceFactory = mock(InstanceFactory.class);
schedulingPerformanceLogger = mock(SchedulingPerformanceLogger.class);
elasticProfileService = mock(ElasticProfileService.class);
service = new ScheduleService(goConfigService, pipelineService, stageService, schedulingChecker, mock(PipelineDao.class), mock(StageDao.class), mock(StageOrderService.class), securityService, pipelineScheduleQueue, jobInstanceService, mock(JobInstanceDao.class), mock(AgentAssignment.class), environmentConfigService, lockService, serverHealthService, txnTemplate, mock(AgentService.class), synchronizationManager, timeProvider, null, null, instanceFactory, schedulingPerformanceLogger, elasticProfileService);
}
Aggregations