Search in sources :

Example 71 with CaseInsensitiveString

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

the class PipelineRepositoryTest method shouldUpdateTimelineEntriesAndEntriesForRollback.

@Test
public void shouldUpdateTimelineEntriesAndEntriesForRollback() throws Exception {
    Object[] pipelineRow1 = { "p1", new BigInteger("1"), new BigInteger("1"), new Date(), "fingerprint", 1.0, "r1", null, new BigInteger("1"), new BigInteger("1") };
    Object[] pipelineRow2 = { "p1", new BigInteger("2"), new BigInteger("2"), new Date(), "fingerprint", 2.0, "r2", null, new BigInteger("1"), new BigInteger("1") };
    stubPipelineInstancesInDb(pipelineRow1, pipelineRow2);
    ArrayList<PipelineTimelineEntry> tempEntries = new ArrayList<>();
    PipelineTimeline pipelineTimeline = new PipelineTimeline(pipelineRepository, transactionTemplate, transactionSynchronizationManager);
    pipelineRepository.updatePipelineTimeline(pipelineTimeline, tempEntries);
    PipelineTimelineEntry timelineEntry1 = pipelineTimeline.getEntryFor(new CaseInsensitiveString("p1"), 1);
    PipelineTimelineEntry timelineEntry2 = pipelineTimeline.getEntryFor(new CaseInsensitiveString("p1"), 2);
    assertThat(pipelineTimeline.instanceCount(new CaseInsensitiveString("p1")), is(2));
    assertNotNull(timelineEntry1);
    assertNotNull(timelineEntry2);
    assertThat(tempEntries.size(), is(2));
    assertThat(tempEntries, containsInAnyOrder(timelineEntry1, timelineEntry2));
}
Also used : ArrayList(java.util.ArrayList) BigInteger(java.math.BigInteger) PipelineTimelineEntry(com.thoughtworks.go.domain.PipelineTimelineEntry) PipelineTimeline(com.thoughtworks.go.server.domain.PipelineTimeline) Date(java.util.Date) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 72 with CaseInsensitiveString

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

the class FetchArtifactViewHelperTest method setUp.

/**
 *  PIPELINES                                          +           TEMPLATE
 *                                                     +
 * random_other                                        +
 * [mingle]                                            +
 *                                                     +           template-1
 * random_pipeline                                     +            [1, 2, 3]
 * [mingle]<---------------------------|               +
 *                                     |               +
 * uppest                              |               +
 * [1, 2, 3]                           |               +           template-2
 *     ^                               |               +            [1, 2]
 *     |                               |               +
 * upper                               |               +
 * [1, 2, 3]                           |               +
 *     ^<--------------------------|   |               +
 *     |                           |   |               +
 * downer                          |   |               +
 * [1, 2, 3]                       |   |               +
 *     ^<----------------------|   |   |               +
 *     |                       |   |   |               +
 * downest                    downest_wmp              +
 * [1, 2, 3]                    [1, 2, 3]              +
 *                                                     +
 */
@Before
public void setUp() {
    initMocks(this);
    when(systemEnvironment.isFetchArtifactTemplateAutoSuggestEnabled()).thenReturn(true);
    when(systemEnvironment.get(SystemEnvironment.FETCH_ARTIFACT_AUTO_SUGGEST)).thenReturn(true);
    PipelineConfig random = PipelineConfigMother.pipelineConfig("random_pipeline");
    JobConfigs randomJobs = random.getStage(new CaseInsensitiveString("mingle")).getJobs();
    randomJobs.add(new JobConfig("mingle_job"));
    PipelineConfig uppest = PipelineConfigMother.createPipelineConfig("uppest", "uppest_stage_1", "uppest_job_1", "uppest_job_1a");
    uppest.add(StageConfigMother.custom("uppest_stage_2", "uppest_job_2"));
    uppest.add(StageConfigMother.custom("uppest_stage_3", "uppest_job_3"));
    PipelineConfig upper = PipelineConfigMother.createPipelineConfig("upper", "upper_stage_1", "upper_job_1", "upper_job_1a");
    upper.add(StageConfigMother.custom("upper_stage_2", "upper_job_2"));
    upper.add(StageConfigMother.custom("upper_stage_3", "upper_job_3"));
    upper.addMaterialConfig(new DependencyMaterialConfig(new CaseInsensitiveString("uppest"), new CaseInsensitiveString("uppest_stage_2")));
    PipelineConfig downer = PipelineConfigMother.createPipelineConfig("downer", "downer_stage_1", "downer_job_1", "downer_job_1a");
    downer.add(StageConfigMother.custom("downer_stage_2", "downer_job_2"));
    downer.add(StageConfigMother.custom("downer_stage_3", "downer_job_3"));
    downer.addMaterialConfig(new DependencyMaterialConfig(new CaseInsensitiveString("upper"), new CaseInsensitiveString("upper_stage_2")));
    PipelineConfig downest = PipelineConfigMother.createPipelineConfig("downest", "downest_stage_1", "downest_job_1", "downest_job_1a");
    downest.add(StageConfigMother.custom("downest_stage_2", "downest_job_2"));
    downest.add(StageConfigMother.custom("downest_stage_3", "downest_job_3"));
    downest.addMaterialConfig(new DependencyMaterialConfig(new CaseInsensitiveString("downer"), new CaseInsensitiveString("downer_stage_2")));
    PipelineConfig downestWithMultiplePaths = PipelineConfigMother.createPipelineConfig("downest_wmp", "downest_wmp_stage_1", "downest_wmp_job_1", "downest_wmp_job_1a");
    downestWithMultiplePaths.add(StageConfigMother.custom("downest_wmp_stage_2", "downest_wmp_job_2"));
    downestWithMultiplePaths.add(StageConfigMother.custom("downest_wmp_stage_3", "downest_wmp_job_3"));
    downestWithMultiplePaths.addMaterialConfig(new DependencyMaterialConfig(new CaseInsensitiveString("downer"), new CaseInsensitiveString("downer_stage_2")));
    downestWithMultiplePaths.addMaterialConfig(new DependencyMaterialConfig(new CaseInsensitiveString("upper"), new CaseInsensitiveString("upper_stage_2")));
    downestWithMultiplePaths.addMaterialConfig(new DependencyMaterialConfig(new CaseInsensitiveString("random_pipeline"), new CaseInsensitiveString("mingle")));
    PipelineConfig randomOther = PipelineConfigMother.pipelineConfig("randomOther_pipeline");
    JobConfigs randomOtherJobs = randomOther.getStage(new CaseInsensitiveString("mingle")).getJobs();
    randomOtherJobs.add(new JobConfig("mingle_job_from_other_pipeline"));
    TemplatesConfig templates = new TemplatesConfig(new PipelineTemplateConfig(new CaseInsensitiveString("template-1"), StageConfigMother.custom("t1-stage-1", "t1-job-1", "t1-job-1a"), StageConfigMother.custom("t1-stage-2", "t1-job-2"), StageConfigMother.custom("t1-stage-3", "t1-job-3")), new PipelineTemplateConfig(new CaseInsensitiveString("template-2"), StageConfigMother.custom("t2-stage-1", "t2-job-1", "t2-job-1a"), StageConfigMother.custom("t2-stage-2", "t2-job-2")));
    cruiseConfig = configWith(uppest, upper, downer, downest, downestWithMultiplePaths, random, randomOther);
    cruiseConfig.setTemplates(templates);
}
Also used : TemplatesConfig(com.thoughtworks.go.config.TemplatesConfig) PipelineConfig(com.thoughtworks.go.config.PipelineConfig) PipelineTemplateConfig(com.thoughtworks.go.config.PipelineTemplateConfig) JobConfigs(com.thoughtworks.go.config.JobConfigs) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) JobConfig(com.thoughtworks.go.config.JobConfig) Before(org.junit.Before)

Example 73 with CaseInsensitiveString

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

the class EnvironmentServiceTest method shouldAddEnvironmentsThatHaveNoPipelinesConfigured.

@Test
public void shouldAddEnvironmentsThatHaveNoPipelinesConfigured() throws Exception {
    when(environmentConfigService.environmentNames()).thenReturn(Arrays.asList(new CaseInsensitiveString("uat"), new CaseInsensitiveString("preprod")));
    when(environmentConfigService.pipelinesFor(new CaseInsensitiveString("uat"))).thenReturn(new ArrayList<>());
    when(environmentConfigService.pipelinesFor(new CaseInsensitiveString("preprod"))).thenReturn(Arrays.asList(new CaseInsensitiveString("preprod-pipeline")));
    stubPipelineHistoryServiceToReturnPipelines("preprod-pipeline");
    List<Environment> environments = environmentService.getEnvironments(USER_FOO);
    assertThat(environments.size(), is(2));
    assertThat(environments.get(0).getPipelineModels().size(), is(0));
    assertThat(environments.get(1).getPipelineModels().size(), is(1));
}
Also used : Environment(com.thoughtworks.go.presentation.pipelinehistory.Environment) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 74 with CaseInsensitiveString

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

the class EnvironmentServiceTest method shouldReturnAllTheEnvironments.

@Test
public void shouldReturnAllTheEnvironments() throws Exception {
    when(environmentConfigService.environmentNames()).thenReturn(Arrays.asList(new CaseInsensitiveString("uat"), new CaseInsensitiveString("preprod")));
    when(environmentConfigService.pipelinesFor(new CaseInsensitiveString("uat"))).thenReturn(Arrays.asList(new CaseInsensitiveString("uat-pipeline"), new CaseInsensitiveString("staging-pipeline")));
    when(environmentConfigService.pipelinesFor(new CaseInsensitiveString("preprod"))).thenReturn(Arrays.asList(new CaseInsensitiveString("preprod-pipeline")));
    stubPipelineHistoryServiceToReturnPipelines("uat-pipeline", "preprod-pipeline", "staging-pipeline");
    List<Environment> environments = environmentService.getEnvironments(USER_FOO);
    assertThat(environments.size(), is(2));
    assertThat(environments.get(0).getPipelineModels().size(), is(2));
    assertThat(environments.get(1).getPipelineModels().size(), is(1));
}
Also used : Environment(com.thoughtworks.go.presentation.pipelinehistory.Environment) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 75 with CaseInsensitiveString

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

the class EnvironmentServiceTest method stubPipelineHistoryServiceToReturnPipelines.

private PipelineInstanceModel stubPipelineHistoryServiceToReturnPipelines(final String pipelineName) {
    PipelineInstanceModel pipelineInstanceModel = PipelineInstanceModel.createPipeline(pipelineName, -1, "1", BuildCause.createManualForced(), new StageInstanceModels());
    PipelineModel pipelineModel = new PipelineModel(pipelineInstanceModel.getName(), true, true, PipelinePauseInfo.notPaused());
    pipelineModel.addPipelineInstance(pipelineInstanceModel);
    when(pipelineHistoryService.latestPipelineModel(new Username(new CaseInsensitiveString("Foo")), pipelineName)).thenReturn(pipelineModel);
    return pipelineInstanceModel;
}
Also used : Username(com.thoughtworks.go.server.domain.Username) PipelineInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel) StageInstanceModels(com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModels) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) PipelineModel(com.thoughtworks.go.presentation.pipelinehistory.PipelineModel)

Aggregations

CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)392 Test (org.junit.Test)277 Username (com.thoughtworks.go.server.domain.Username)80 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)65 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)65 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)57 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)56 Date (java.util.Date)50 Modification (com.thoughtworks.go.domain.materials.Modification)44 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)30 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)28 Before (org.junit.Before)28 HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)27 HashMap (java.util.HashMap)26 CruiseConfig (com.thoughtworks.go.config.CruiseConfig)24 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)24 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)19 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)19 ArrayList (java.util.ArrayList)19 Pipeline (com.thoughtworks.go.domain.Pipeline)18