Search in sources :

Example 21 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 22 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 {
    Viewers viewers = viewers("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) AllowedViewers(com.thoughtworks.go.domain.cctray.viewers.AllowedViewers) Viewers(com.thoughtworks.go.domain.cctray.viewers.Viewers) Date(java.util.Date) Test(org.junit.Test)

Example 23 with ProjectStatus

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

the class CcTrayStageStatusChangeHandlerTest method shouldUpdateBuildDetailsOfStageWhenStageIsCompleted.

@Test
public void shouldUpdateBuildDetailsOfStageWhenStageIsCompleted() throws Exception {
    Stage completedStage = StageMother.createPassedStage("pipeline", 1, "stage1", 1, "job1", new Date());
    completedStage.setCompletedByTransitionId(1L);
    List<ProjectStatus> statuses = handler.statusesOfStageAndItsJobsFor(completedStage);
    ProjectStatus statusOfStage = statuses.get(0);
    assertThat(completedStage.isCompleted(), is(true));
    assertThat(statusOfStage.getLastBuildStatus(), is("Success"));
    assertThat(statusOfStage.getLastBuildTime(), is(completedStage.completedDate()));
    assertThat(statusOfStage.getLastBuildLabel(), is("LABEL-1"));
}
Also used : ProjectStatus(com.thoughtworks.go.domain.activity.ProjectStatus) NullStage(com.thoughtworks.go.domain.NullStage) Stage(com.thoughtworks.go.domain.Stage) Date(java.util.Date) Test(org.junit.Test)

Example 24 with ProjectStatus

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

the class CcTrayStageStatusChangeHandlerTest method shouldLeaveBuildDetailsOfStageSameAsTheOneInCache_WhenStageIsNotCompleted_AndThereIsAnExistingStageInCache.

@Test
public void shouldLeaveBuildDetailsOfStageSameAsTheOneInCache_WhenStageIsNotCompleted_AndThereIsAnExistingStageInCache() throws Exception {
    String projectName = "pipeline :: stage1";
    ProjectStatus existingStageStatus = new ProjectStatus(projectName, "OldActivity", "OldStatus", "OldLabel", new Date(), webUrlFor("stage1"));
    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(stage.getState().completed(), is(not(true)));
    assertThat(statusOfStage.getLastBuildStatus(), is(existingStageStatus.getLastBuildStatus()));
    assertThat(statusOfStage.getLastBuildTime(), is(existingStageStatus.getLastBuildTime()));
    assertThat(statusOfStage.getLastBuildLabel(), is(existingStageStatus.getLastBuildLabel()));
}
Also used : ProjectStatus(com.thoughtworks.go.domain.activity.ProjectStatus) NullStage(com.thoughtworks.go.domain.NullStage) Stage(com.thoughtworks.go.domain.Stage) Date(java.util.Date) Test(org.junit.Test)

Example 25 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)

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