Search in sources :

Example 31 with StageConfig

use of com.thoughtworks.go.config.StageConfig in project gocd by gocd.

the class MaterialRevisionBuilder method depInstance.

public Tuple depInstance(String pipelineName, int counter, Date modifiedTime, Tuple... buildCause) {
    String key = key(pipelineName, counter, modifiedTime);
    if (!instanceToRevision.containsKey(key)) {
        if (buildCause.length == 0) {
            throw new RuntimeException("Cannot create instance without a buildcause. You can retrive it without buildcause once it has been created");
        }
        DependencyMaterial material = new DependencyMaterial(new CaseInsensitiveString(pipelineName), new CaseInsensitiveString(STAGE_NAME));
        DependencyMaterialRevision revision = DependencyMaterialRevision.create(pipelineName, counter, "label", STAGE_NAME, 1);
        instanceToRevision.put(key, revision.convert(material, modifiedTime));
        final long id = getNextId();
        org.mockito.Mockito.when(pipelineDao.findPipelineByNameAndCounter(pipelineName, counter)).thenReturn(pipeline(id));
        org.mockito.Mockito.when(materialRepository.findMaterialRevisionsForPipeline(id)).thenReturn(buildCauseOfThisPipeline(buildCause));
    }
    MaterialRevision materialRevision = instanceToRevision.get(key);
    Materials materials = new Materials();
    for (MaterialRevision revision : buildCauseOfThisPipeline(buildCause)) {
        materials.add(revision.getMaterial());
    }
    PipelineConfig config = new PipelineConfig(new CaseInsensitiveString(pipelineName), materials.convertToConfigs(), new StageConfig(new CaseInsensitiveString(STAGE_NAME), new JobConfigs()));
    return new Tuple(new PipelineConfigDependencyGraph(config, dependencyGraphsFor(buildCause)), materialRevision);
}
Also used : PipelineConfig(com.thoughtworks.go.config.PipelineConfig) Materials(com.thoughtworks.go.config.materials.Materials) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) DependencyMaterialRevision(com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) StageConfig(com.thoughtworks.go.config.StageConfig) PipelineConfigDependencyGraph(com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph) JobConfigs(com.thoughtworks.go.config.JobConfigs) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) DependencyMaterialRevision(com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision)

Aggregations

StageConfig (com.thoughtworks.go.config.StageConfig)31 Test (org.junit.Test)12 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)11 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)8 TimeProvider (com.thoughtworks.go.util.TimeProvider)4 EnvironmentVariableConfig (com.thoughtworks.go.config.EnvironmentVariableConfig)3 EnvironmentVariablesConfig (com.thoughtworks.go.config.EnvironmentVariablesConfig)3 AgentConfig (com.thoughtworks.go.config.AgentConfig)2 Agents (com.thoughtworks.go.config.Agents)2 JobConfigs (com.thoughtworks.go.config.JobConfigs)2 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)2 DefaultSchedulingContext (com.thoughtworks.go.domain.DefaultSchedulingContext)2 NullStage (com.thoughtworks.go.domain.NullStage)2 Stage (com.thoughtworks.go.domain.Stage)2 InstanceFactory (com.thoughtworks.go.server.service.InstanceFactory)2 Map (java.util.Map)2 Gson (com.google.gson.Gson)1 AdminUser (com.thoughtworks.go.config.AdminUser)1 Approval (com.thoughtworks.go.config.Approval)1 AuthConfig (com.thoughtworks.go.config.AuthConfig)1