Search in sources :

Example 36 with ProjectStatus

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

the class CcTrayStageStatusChangeHandlerTest method shouldReuseViewersListFromExistingStatusWhenCreatingNewStatus.

@Test
public void shouldReuseViewersListFromExistingStatusWhenCreatingNewStatus() throws Exception {
    Users viewers = viewers(Collections.singleton(new PluginRoleConfig("admin", "ldap")), "viewer1", "viewer2");
    String projectName = "pipeline :: stage1";
    ProjectStatus existingStageStatus = new ProjectStatus(projectName, "OldActivity", "OldStatus", "OldLabel", new Date(), webUrlFor("stage1"));
    existingStageStatus.updateViewers(viewers);
    when(cache.get(projectName)).thenReturn(existingStageStatus);
    Stage stage = StageMother.custom("stage1", JobInstanceMother.building("job1"));
    List<ProjectStatus> statuses = handler.statusesOfStageAndItsJobsFor(stage);
    ProjectStatus statusOfStage = statuses.get(0);
    assertThat(statusOfStage.viewers(), is(viewers));
}
Also used : ProjectStatus(com.thoughtworks.go.domain.activity.ProjectStatus) NullStage(com.thoughtworks.go.domain.NullStage) Stage(com.thoughtworks.go.domain.Stage) Users(com.thoughtworks.go.config.security.users.Users) AllowedUsers(com.thoughtworks.go.config.security.users.AllowedUsers) PluginRoleConfig(com.thoughtworks.go.config.PluginRoleConfig) Test(org.junit.Test)

Example 37 with ProjectStatus

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

the class CcTrayStageStatusChangeHandlerTest method shouldGenerateStatusesForStageAndAllJobsWithinIt.

@Test
public void shouldGenerateStatusesForStageAndAllJobsWithinIt() throws Exception {
    JobInstance firstJob = JobInstanceMother.building("job1");
    JobInstance secondJob = JobInstanceMother.completed("job2");
    Stage stage = StageMother.custom("stage1", firstJob, secondJob);
    when(jobStatusChangeHandler.statusFor(firstJob, new HashSet<>())).thenReturn(new ProjectStatus("job1_name", null, null, null, null, null));
    when(jobStatusChangeHandler.statusFor(secondJob, new HashSet<>())).thenReturn(new ProjectStatus("job2_name", null, null, null, null, null));
    List<ProjectStatus> statuses = handler.statusesOfStageAndItsJobsFor(stage);
    assertThat(statuses.size(), is(3));
    assertThat(statuses.get(0).name(), is("pipeline :: stage1"));
    assertThat(statuses.get(1).name(), is("job1_name"));
    assertThat(statuses.get(2).name(), is("job2_name"));
}
Also used : ProjectStatus(com.thoughtworks.go.domain.activity.ProjectStatus) JobInstance(com.thoughtworks.go.domain.JobInstance) NullStage(com.thoughtworks.go.domain.NullStage) Stage(com.thoughtworks.go.domain.Stage) Test(org.junit.Test)

Example 38 with ProjectStatus

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

the class CcTrayStageStatusChangeHandlerTest method shouldCalculateBreakersForStage.

@Test
public void shouldCalculateBreakersForStage() throws Exception {
    Stage stage = StageMother.custom("stage1", JobInstanceMother.building("job1"));
    when(breakersCalculator.calculateFor(stage)).thenReturn(s("breaker1", "breaker2"));
    List<ProjectStatus> statuses = handler.statusesOfStageAndItsJobsFor(stage);
    assertThat(statuses.get(0).getBreakers(), is(s("breaker1", "breaker2")));
}
Also used : ProjectStatus(com.thoughtworks.go.domain.activity.ProjectStatus) NullStage(com.thoughtworks.go.domain.NullStage) Stage(com.thoughtworks.go.domain.Stage) Test(org.junit.Test)

Example 39 with ProjectStatus

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

the class CcTrayStageStatusChangeHandlerTest method shouldCreateStatusesWithStageActivityAndWebUrl.

@Test
public void shouldCreateStatusesWithStageActivityAndWebUrl() throws Exception {
    Stage stage = StageMother.custom("stage1", JobInstanceMother.building("job1"));
    List<ProjectStatus> statuses = handler.statusesOfStageAndItsJobsFor(stage);
    ProjectStatus statusOfStage = statuses.get(0);
    assertThat(activityOf(statusOfStage), is("Building"));
    assertThat(webUrlOf(statusOfStage), is(webUrlFor("stage1")));
}
Also used : ProjectStatus(com.thoughtworks.go.domain.activity.ProjectStatus) NullStage(com.thoughtworks.go.domain.NullStage) Stage(com.thoughtworks.go.domain.Stage) Test(org.junit.Test)

Example 40 with ProjectStatus

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

the class CcTrayStageStatusLoaderTest method shouldNotHaveAnyStatusesIfAStageCannotBeFoundInDB.

@Test
public void shouldNotHaveAnyStatusesIfAStageCannotBeFoundInDB() throws Exception {
    setupStagesInDB(new StageIdentity("pipeline1", "stage1", 12L), new StageIdentity("pipeline2", "stage2", 14L));
    List<ProjectStatus> actualStatuses = loader.getStatusesForStageAndJobsOf(pipelineConfigFor("pipeline1"), stageConfigFor("non-existent-stage"));
    assertThat(actualStatuses, is(Collections.<ProjectStatus>emptyList()));
}
Also used : ProjectStatus(com.thoughtworks.go.domain.activity.ProjectStatus) StageIdentity(com.thoughtworks.go.server.domain.StageIdentity) 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