Search in sources :

Example 41 with ProjectStatus

use of com.thoughtworks.go.domain.activity.ProjectStatus in project gocd by gocd.

the class CcTrayConfigChangeHandlerTest method shouldPopulateNewCacheWithProjectsFromOldCacheWhenTheyExist.

@Test
public void shouldPopulateNewCacheWithProjectsFromOldCacheWhenTheyExist() throws Exception {
    String stageProjectName = "pipeline1 :: stage";
    String jobProjectName = "pipeline1 :: stage :: job";
    ProjectStatus existingStageStatus = new ProjectStatus(stageProjectName, "OldActivity", "OldStatus", "OldLabel", new Date(), "stage-url");
    when(cache.get(stageProjectName)).thenReturn(existingStageStatus);
    ProjectStatus existingJobStatus = new ProjectStatus(jobProjectName, "OldActivity-Job", "OldStatus-Job", "OldLabel-Job", new Date(), "job-url");
    when(cache.get(jobProjectName)).thenReturn(existingJobStatus);
    handler.call(GoConfigMother.configWithPipelines("pipeline1"));
    verify(cache).replaceAllEntriesInCacheWith(eq(asList(existingStageStatus, existingJobStatus)));
    verifyZeroInteractions(stageStatusLoader);
}
Also used : ProjectStatus(com.thoughtworks.go.domain.activity.ProjectStatus) Date(java.util.Date) Test(org.junit.Test)

Example 42 with ProjectStatus

use of com.thoughtworks.go.domain.activity.ProjectStatus in project gocd by gocd.

the class CcTrayConfigChangeHandlerTest method shouldUpdateCacheWithPipelineDetailsWhenPipelineConfigChanges.

@Test
public void shouldUpdateCacheWithPipelineDetailsWhenPipelineConfigChanges() {
    String pipeline1Stage = "pipeline1 :: stage1";
    String pipeline1job = "pipeline1 :: stage1 :: job1";
    String pipeline2stage = "pipeline2 :: stage1";
    String pipeline2job = "pipeline2 :: stage1 :: job1";
    ProjectStatus statusOfPipeline1StageInCache = new ProjectStatus(pipeline1Stage, "OldActivity", "OldStatus", "OldLabel", new Date(), "p1-stage-url");
    ProjectStatus statusOfPipeline1JobInCache = new ProjectStatus(pipeline1job, "OldActivity-Job", "OldStatus-Job", "OldLabel-Job", new Date(), "p1-job-url");
    ProjectStatus statusOfPipeline2StageInCache = new ProjectStatus(pipeline1Stage, "OldActivity", "OldStatus", "OldLabel", new Date(), "p2-stage-url");
    ProjectStatus statusOfPipeline2JobInCache = new ProjectStatus(pipeline1job, "OldActivity-Job", "OldStatus-Job", "OldLabel-Job", new Date(), "p2-job2-url");
    when(cache.get(pipeline1Stage)).thenReturn(statusOfPipeline1StageInCache);
    when(cache.get(pipeline1job)).thenReturn(statusOfPipeline1JobInCache);
    when(cache.get(pipeline2stage)).thenReturn(statusOfPipeline2StageInCache);
    when(cache.get(pipeline2job)).thenReturn(statusOfPipeline2JobInCache);
    PipelineConfig pipeline1Config = GoConfigMother.pipelineHavingJob("pipeline1", "stage1", "job1", "arts", "dir").pipelineConfigByName(new CaseInsensitiveString("pipeline1"));
    handler.call(pipeline1Config, "group1");
    ArgumentCaptor<ArrayList<ProjectStatus>> argumentCaptor = new ArgumentCaptor<>();
    verify(cache).putAll(argumentCaptor.capture());
    List<ProjectStatus> allValues = argumentCaptor.getValue();
    assertThat(allValues.get(0).name(), is(pipeline1Stage));
    assertThat(allValues.get(1).name(), is(pipeline1job));
    verify(cache, atLeastOnce()).get(pipeline1Stage);
    verify(cache, atLeastOnce()).get(pipeline1job);
    verifyNoMoreInteractions(cache);
}
Also used : ProjectStatus(com.thoughtworks.go.domain.activity.ProjectStatus) ArgumentCaptor(org.mockito.ArgumentCaptor) ArrayList(java.util.ArrayList) Date(java.util.Date) Test(org.junit.Test)

Aggregations

ProjectStatus (com.thoughtworks.go.domain.activity.ProjectStatus)42 Test (org.junit.Test)34 Date (java.util.Date)28 Stage (com.thoughtworks.go.domain.Stage)9 NullStage (com.thoughtworks.go.domain.NullStage)8 ArrayList (java.util.ArrayList)5 Viewers (com.thoughtworks.go.domain.cctray.viewers.Viewers)4 JobInstance (com.thoughtworks.go.domain.JobInstance)3 AllowedViewers (com.thoughtworks.go.domain.cctray.viewers.AllowedViewers)2 StageIdentity (com.thoughtworks.go.server.domain.StageIdentity)2 ArgumentCaptor (org.mockito.ArgumentCaptor)2 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)1 PipelineGroupVisitor (com.thoughtworks.go.domain.PipelineGroupVisitor)1 HashSet (java.util.HashSet)1