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()));
}
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));
}
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;
}
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;
}
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;
}
Aggregations