Search in sources :

Example 6 with ProjectStatus

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

the class CcTrayServiceTest method statusFor.

private ProjectStatus statusFor(String projectName, String... allowedUsers) throws Exception {
    ProjectStatus status = new ProjectStatus(projectName, "activity1", "build-status-1", "build-label-1", DateUtils.parseYYYYMMDD("2010-05-23"), "web-url");
    status.updateViewers(viewers(allowedUsers));
    return status;
}
Also used : ProjectStatus(com.thoughtworks.go.domain.activity.ProjectStatus)

Example 7 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 8 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 9 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 10 with ProjectStatus

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

the class CcTrayConfigChangeHandlerTest method shouldUpdateCacheWithAppropriateViewersForProjectStatusWhenPipelineConfigChanges.

@Test
public void shouldUpdateCacheWithAppropriateViewersForProjectStatusWhenPipelineConfigChanges() {
    String pipeline1Stage = "pipeline1 :: stage1";
    String pipeline1job = "pipeline1 :: 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");
    when(cache.get(pipeline1Stage)).thenReturn(statusOfPipeline1StageInCache);
    when(cache.get(pipeline1job)).thenReturn(statusOfPipeline1JobInCache);
    PipelineConfig pipeline1Config = GoConfigMother.pipelineHavingJob("pipeline1", "stage1", "job1", "arts", "dir").pipelineConfigByName(new CaseInsensitiveString("pipeline1"));
    when(pipelinePermissionsAuthority.permissionsForPipeline(pipeline1Config.name())).thenReturn(new Permissions(viewers("user1", "user2"), null, null, null));
    handler.call(pipeline1Config);
    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(0).viewers().contains("user1"), is(true));
    assertThat(allValues.get(0).viewers().contains("user2"), is(true));
    assertThat(allValues.get(0).viewers().contains("user3"), is(false));
    assertThat(allValues.get(1).name(), is(pipeline1job));
    assertThat(allValues.get(1).viewers().contains("user1"), is(true));
    assertThat(allValues.get(1).viewers().contains("user2"), is(true));
    assertThat(allValues.get(1).viewers().contains("user3"), is(false));
}
Also used : ProjectStatus(com.thoughtworks.go.domain.activity.ProjectStatus) ArgumentCaptor(org.mockito.ArgumentCaptor) Permissions(com.thoughtworks.go.config.security.Permissions) Test(org.junit.Test)

Aggregations

ProjectStatus (com.thoughtworks.go.domain.activity.ProjectStatus)43 Test (org.junit.Test)34 Date (java.util.Date)14 Stage (com.thoughtworks.go.domain.Stage)9 NullStage (com.thoughtworks.go.domain.NullStage)8 Permissions (com.thoughtworks.go.config.security.Permissions)4 Users (com.thoughtworks.go.config.security.users.Users)4 ArrayList (java.util.ArrayList)4 AllowedUsers (com.thoughtworks.go.config.security.users.AllowedUsers)3 JobInstance (com.thoughtworks.go.domain.JobInstance)3 PluginRoleConfig (com.thoughtworks.go.config.PluginRoleConfig)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 Viewers (com.thoughtworks.go.domain.cctray.viewers.Viewers)1 HashSet (java.util.HashSet)1