Search in sources :

Example 11 with TimeProvider

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);
    }
}
Also used : TimeProvider(com.thoughtworks.go.util.TimeProvider) InstanceFactory(com.thoughtworks.go.server.service.InstanceFactory) Stage(com.thoughtworks.go.domain.Stage) StageConfig(com.thoughtworks.go.config.StageConfig) DefaultSchedulingContext(com.thoughtworks.go.domain.DefaultSchedulingContext)

Example 12 with TimeProvider

use of com.thoughtworks.go.util.TimeProvider in project gocd by gocd.

the class JobInstanceSqlMapDaoTest method createNewPipeline.

private Pipeline createNewPipeline(PipelineConfig pipelineConfig) {
    Pipeline pipeline = instanceFactory.createPipelineInstance(pipelineConfig, modifySomeFiles(pipelineConfig), new DefaultSchedulingContext(DEFAULT_APPROVED_BY), "md5-test", new TimeProvider());
    dbHelper.savePipelineWithStagesAndMaterials(pipeline);
    return pipeline;
}
Also used : TimeProvider(com.thoughtworks.go.util.TimeProvider)

Example 13 with TimeProvider

use of com.thoughtworks.go.util.TimeProvider in project gocd by gocd.

the class JobInstanceSqlMapDaoTest method shouldLoadRerunOfCounterValueForScheduledBuilds.

@Test
public void shouldLoadRerunOfCounterValueForScheduledBuilds() {
    List<JobPlan> jobPlans = jobInstanceDao.orderedScheduledBuilds();
    assertThat(jobPlans.size(), is(2));
    assertThat(jobPlans.get(0).getIdentifier().getRerunOfCounter(), is(nullValue()));
    assertThat(jobPlans.get(1).getIdentifier().getRerunOfCounter(), is(nullValue()));
    dbHelper.passStage(savedStage);
    Stage stage = instanceFactory.createStageForRerunOfJobs(savedStage, a(JOB_NAME), schedulingContext, pipelineConfig.getStage(new CaseInsensitiveString(STAGE_NAME)), new TimeProvider(), "md5");
    dbHelper.saveStage(savedPipeline, stage, stage.getOrderId() + 1);
    jobPlans = jobInstanceDao.orderedScheduledBuilds();
    assertThat(jobPlans.size(), is(1));
    assertThat(jobPlans.get(0).getIdentifier().getRerunOfCounter(), is(savedStage.getCounter()));
}
Also used : TimeProvider(com.thoughtworks.go.util.TimeProvider) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 14 with TimeProvider

use of com.thoughtworks.go.util.TimeProvider in project gocd by gocd.

the class PipelineSqlMapDaoIntegrationTest method schedulePipelineWithoutCounter.

private void schedulePipelineWithoutCounter(PipelineConfig pipelineConfig) {
    Pipeline pipeline = instanceFactory.createPipelineInstance(pipelineConfig, BuildCause.createWithModifications(modifyOneFile(pipelineConfig), ""), new DefaultSchedulingContext("anyone"), "md5-test", new TimeProvider());
    save(pipeline);
    for (Stage stage : pipeline.getStages()) {
        stageDao.saveWithJobs(pipeline, stage);
    }
}
Also used : TimeProvider(com.thoughtworks.go.util.TimeProvider)

Example 15 with TimeProvider

use of com.thoughtworks.go.util.TimeProvider in project gocd by gocd.

the class PipelineSqlMapDaoIntegrationTest method shouldHaveUrlInGitMaterials.

@Test
public void shouldHaveUrlInGitMaterials() throws SQLException {
    Materials gitMaterials = MaterialsMother.gitMaterials("gitUrl");
    PipelineConfig pipelineConfig = PipelineMother.twoBuildPlansWithResourcesAndMaterials("mingle", "dev");
    pipelineConfig.setMaterialConfigs(gitMaterials.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();
    GitMaterial gitMaterial = (GitMaterial) materials.get(0);
    assertThat(gitMaterial.getUrl(), is("gitUrl"));
}
Also used : TimeProvider(com.thoughtworks.go.util.TimeProvider) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) Materials(com.thoughtworks.go.config.materials.Materials) Test(org.junit.Test)

Aggregations

TimeProvider (com.thoughtworks.go.util.TimeProvider)177 Test (org.junit.Test)122 Date (java.util.Date)29 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)28 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)25 DateTime (org.joda.time.DateTime)18 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)16 GoConfigRevision (com.thoughtworks.go.domain.GoConfigRevision)13 Username (com.thoughtworks.go.server.domain.Username)13 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)13 Before (org.junit.Before)13 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)12 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)11 Materials (com.thoughtworks.go.config.materials.Materials)10 HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)10 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)9 TransactionStatus (org.springframework.transaction.TransactionStatus)9 Material (com.thoughtworks.go.domain.materials.Material)7 Modification (com.thoughtworks.go.domain.materials.Modification)7 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)6