Search in sources :

Example 11 with ProjectStatus

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

the class CcTrayStageStatusChangeHandlerTest method shouldLeaveBuildDetailsOfStageSameAsTheDefault_WhenStageIsNotCompleted_AndThereIsNoExistingStageInCache.

@Test
public void shouldLeaveBuildDetailsOfStageSameAsTheDefault_WhenStageIsNotCompleted_AndThereIsNoExistingStageInCache() throws Exception {
    String projectName = "pipeline :: stage1";
    ProjectStatus.NullProjectStatus defaultStatus = new ProjectStatus.NullProjectStatus(projectName);
    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(defaultStatus.getLastBuildStatus()));
    assertThat(statusOfStage.getLastBuildTime(), is(defaultStatus.getLastBuildTime()));
    assertThat(statusOfStage.getLastBuildLabel(), is(defaultStatus.getLastBuildLabel()));
}
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 12 with ProjectStatus

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

the class CcTrayStageStatusChangeHandlerTest method shouldUpdateCacheWhenStageWhichHasChangedIsNotANullStage.

@Test
public void shouldUpdateCacheWhenStageWhichHasChangedIsNotANullStage() throws Exception {
    Stage completedStage = StageMother.createPassedStage("pipeline", 1, "stage1", 1, "job1", new Date());
    ProjectStatus jobStatus = new ProjectStatus("job1_name", "activity1", "lastBuildStatus1", "lastBuildLabel1", new Date(), "webUrl1");
    when(jobStatusChangeHandler.statusFor(completedStage.getJobInstances().first(), new HashSet<>())).thenReturn(jobStatus);
    handler.call(completedStage);
    verify(breakersCalculator).calculateFor(completedStage);
    verify(cache).putAll(statusesCaptor.capture());
    List<ProjectStatus> statusesWhichWereCached = statusesCaptor.getValue();
    assertThat(statusesWhichWereCached.size(), is(2));
    assertThat(statusesWhichWereCached.get(0).name(), is("pipeline :: stage1"));
    assertThat(statusesWhichWereCached.get(0).getLastBuildStatus(), is("Success"));
    assertThat(activityOf(statusesWhichWereCached.get(0)), is("Sleeping"));
    assertThat(statusesWhichWereCached.get(1), is(jobStatus));
}
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 13 with ProjectStatus

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

the class CcTrayConfigChangeHandler method findAllProjectStatusesForStagesAndJobsIn.

private List<ProjectStatus> findAllProjectStatusesForStagesAndJobsIn(CruiseConfig config) {
    final List<ProjectStatus> projectStatuses = new ArrayList<>();
    final Map<String, Viewers> groupsAndTheirViewers = ccTrayViewAuthority.groupsAndTheirViewers();
    config.accept(new PipelineGroupVisitor() {

        @Override
        public void visit(PipelineConfigs pipelineConfigs) {
            Viewers usersWithViewPermissionsOfThisGroup = groupsAndTheirViewers.get(pipelineConfigs.getGroup());
            for (PipelineConfig pipelineConfig : pipelineConfigs) {
                updateProjectStatusForPipeline(usersWithViewPermissionsOfThisGroup, pipelineConfig, projectStatuses);
            }
        }
    });
    return projectStatuses;
}
Also used : ProjectStatus(com.thoughtworks.go.domain.activity.ProjectStatus) ArrayList(java.util.ArrayList) Viewers(com.thoughtworks.go.domain.cctray.viewers.Viewers) PipelineGroupVisitor(com.thoughtworks.go.domain.PipelineGroupVisitor)

Example 14 with ProjectStatus

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

the class CcTrayJobStatusChangeHandler method statusFor.

public ProjectStatus statusFor(JobInstance job, Set<String> breakers) {
    String projectName = job.getIdentifier().ccProjectName();
    ProjectStatus existingStatusOfThisJobInCache = projectByName(projectName);
    ProjectStatus newStatus = new ProjectStatus(projectName, job.getState().cctrayActivity(), lastBuildStatus(existingStatusOfThisJobInCache, job), lastBuildLabel(existingStatusOfThisJobInCache, job), lastBuildTime(existingStatusOfThisJobInCache, job), job.getIdentifier().webUrl(), breakers);
    newStatus.updateViewers(existingStatusOfThisJobInCache.viewers());
    return newStatus;
}
Also used : ProjectStatus(com.thoughtworks.go.domain.activity.ProjectStatus)

Example 15 with ProjectStatus

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

the class CcTrayStageStatusChangeHandler method getStageStatus.

private ProjectStatus getStageStatus(Stage stage, String projectName, Set<String> breakers) {
    ProjectStatus existingStatus = projectByName(projectName);
    ProjectStatus newStatus = new ProjectStatus(projectName, stage.stageState().cctrayActivity(), lastBuildStatus(stage, existingStatus), lastBuildLabel(stage, existingStatus), lastBuildTime(stage, existingStatus), stage.getIdentifier().webUrl(), breakers);
    newStatus.updateViewers(existingStatus.viewers());
    return newStatus;
}
Also used : ProjectStatus(com.thoughtworks.go.domain.activity.ProjectStatus)

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