Search in sources :

Example 1 with ProjectStatus

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

the class CcTrayCacheTest method shouldBeAbleToPutAnItemIntoCache.

@Test
public void shouldBeAbleToPutAnItemIntoCache() throws Exception {
    ProjectStatus status = new ProjectStatus("item1", "Sleeping", "last-build-status", "last-build-label", new Date(), "web-url");
    cache.put(status);
    assertThat(cache.get("item1"), is(status));
}
Also used : ProjectStatus(com.thoughtworks.go.domain.activity.ProjectStatus) Date(java.util.Date) Test(org.junit.Test)

Example 2 with ProjectStatus

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

the class CcTrayCacheTest method shouldBeAbleToClearExistingCacheAndReplaceAllItemsInIt.

@Test
public void shouldBeAbleToClearExistingCacheAndReplaceAllItemsInIt() throws Exception {
    ProjectStatus status1 = new ProjectStatus("item1", "Sleeping 1", "last-build-status 1", "last-build-label 1", new Date(), "web-url 1");
    ProjectStatus status2 = new ProjectStatus("item2", "Sleeping 2", "last-build-status 2", "last-build-label 2", new Date(), "web-url 2");
    ProjectStatus status3 = new ProjectStatus("item3", "Sleeping 3", "last-build-status 3", "last-build-label 3", new Date(), "web-url 3");
    ProjectStatus status4 = new ProjectStatus("item4", "Sleeping 4", "last-build-status 4", "last-build-label 4", new Date(), "web-url 4");
    ProjectStatus status5 = new ProjectStatus("item5", "Sleeping 5", "last-build-status 5", "last-build-label 5", new Date(), "web-url 5");
    cache.put(status1);
    cache.put(status2);
    cache.put(status3);
    cache.replaceAllEntriesInCacheWith(asList(status3, status4, status5));
    assertThat(cache.get("item1"), is(nullValue()));
    assertThat(cache.get("item2"), is(nullValue()));
    assertThat(cache.get("item3"), is(status3));
    assertThat(cache.get("item4"), is(status4));
    assertThat(cache.get("item5"), is(status5));
}
Also used : ProjectStatus(com.thoughtworks.go.domain.activity.ProjectStatus) Date(java.util.Date) Test(org.junit.Test)

Example 3 with ProjectStatus

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

the class CcTrayCacheTest method shouldContainChangedEntryInOrderedListAfterAPut.

@Test
public void shouldContainChangedEntryInOrderedListAfterAPut() throws Exception {
    ProjectStatus status1 = new ProjectStatus("item1", "Sleeping 1", "last-build-status 1", "last-build-label 1", new Date(), "web-url 1");
    ProjectStatus status2 = new ProjectStatus("item2", "Sleeping 2", "last-build-status 2", "last-build-label 2", new Date(), "web-url 2");
    ProjectStatus status3 = new ProjectStatus("item3", "Sleeping 3", "last-build-status 3", "last-build-label 3", new Date(), "web-url 3");
    ProjectStatus status2_changed = new ProjectStatus("item2", "CHANGED Sleeping 2C", "last-build-status 2C", "last-build-label 2C", new Date(), "web-url 2C");
    cache.replaceAllEntriesInCacheWith(asList(status1, status2, status3));
    List<ProjectStatus> allProjects = cache.allEntriesInOrder();
    assertThat(allProjects.get(1), is(status2));
    cache.put(status2_changed);
    allProjects = cache.allEntriesInOrder();
    assertThat(allProjects.get(0), is(status1));
    assertThat(allProjects.get(1), is(status2_changed));
    assertThat(allProjects.get(2), is(status3));
}
Also used : ProjectStatus(com.thoughtworks.go.domain.activity.ProjectStatus) Date(java.util.Date) Test(org.junit.Test)

Example 4 with ProjectStatus

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

the class CcTrayConfigChangeHandlerTest method shouldHandleNewJobsInConfig_ByReplacingJobsMissingInConfigWithNullJob.

/* Simulate adding a job, in a running system. Cache has the stage info, but not the job info. */
@Test
public void shouldHandleNewJobsInConfig_ByReplacingJobsMissingInConfigWithNullJob() throws Exception {
    String stage1ProjectName = "pipeline1 :: stage1";
    String job1ProjectName = "pipeline1 :: stage1 :: job1";
    String projectNameOfNewJob = "pipeline1 :: stage1 :: NEW_JOB_IN_CONFIG";
    ProjectStatus statusOfStage1InCache = new ProjectStatus(stage1ProjectName, "OldActivity", "OldStatus", "OldLabel", new Date(), "stage-url");
    ProjectStatus statusOfJob1InCache = new ProjectStatus(job1ProjectName, "OldActivity-Job", "OldStatus-Job", "OldLabel-Job", new Date(), "job1-url");
    when(cache.get(stage1ProjectName)).thenReturn(statusOfStage1InCache);
    when(cache.get(job1ProjectName)).thenReturn(statusOfJob1InCache);
    when(cache.get(projectNameOfNewJob)).thenReturn(null);
    CruiseConfig config = new BasicCruiseConfig();
    goConfigMother.addPipeline(config, "pipeline1", "stage1", "job1", "NEW_JOB_IN_CONFIG");
    handler.call(config);
    ProjectStatus expectedNullStatusForNewJob = new ProjectStatus.NullProjectStatus(projectNameOfNewJob);
    verify(cache).replaceAllEntriesInCacheWith(eq(asList(statusOfStage1InCache, statusOfJob1InCache, expectedNullStatusForNewJob)));
    verifyZeroInteractions(stageStatusLoader);
}
Also used : ProjectStatus(com.thoughtworks.go.domain.activity.ProjectStatus) Date(java.util.Date) Test(org.junit.Test)

Example 5 with ProjectStatus

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

the class CcTrayConfigChangeHandlerTest method shouldProvideCCTrayCacheWithAListOfAllProjectsInOrder.

@Test
public void shouldProvideCCTrayCacheWithAListOfAllProjectsInOrder() throws Exception {
    ProjectStatus pipeline1_stage1 = new ProjectStatus("pipeline1 :: stage", "Activity1", "Status1", "Label1", new Date(), "stage1-url");
    ProjectStatus pipeline1_stage1_job = new ProjectStatus("pipeline1 :: stage :: job", "Activity1-Job", "Status1-Job", "Label1-Job", new Date(), "job1-url");
    ProjectStatus pipeline2_stage1 = new ProjectStatus("pipeline2 :: stage", "Activity2", "Status2", "Label2", new Date(), "stage2-url");
    ProjectStatus pipeline2_stage1_job = new ProjectStatus("pipeline2 :: stage :: job", "Activity2-Job", "Status2-Job", "Label2-Job", new Date(), "job2-url");
    when(cache.get("pipeline1 :: stage")).thenReturn(pipeline1_stage1);
    when(cache.get("pipeline1 :: stage :: job")).thenReturn(pipeline1_stage1_job);
    when(cache.get("pipeline2 :: stage")).thenReturn(pipeline2_stage1);
    when(cache.get("pipeline2 :: stage :: job")).thenReturn(pipeline2_stage1_job);
    handler.call(GoConfigMother.configWithPipelines("pipeline2", "pipeline1"));
    /* Adds pipeline1 first in config. Then pipeline2. */
    verify(cache).replaceAllEntriesInCacheWith(eq(asList(pipeline1_stage1, pipeline1_stage1_job, pipeline2_stage1, pipeline2_stage1_job)));
    verifyZeroInteractions(stageStatusLoader);
}
Also used : ProjectStatus(com.thoughtworks.go.domain.activity.ProjectStatus) 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