use of com.thoughtworks.go.domain.activity.ProjectStatus in project gocd by gocd.
the class CcTrayJobStatusChangeHandlerTest method shouldUpdateBreakersAlongWithOtherFields.
@Test
public void shouldUpdateBreakersAlongWithOtherFields() throws Exception {
String jobName = "job1";
Set<String> breakers = new HashSet<>();
breakers.add("abc");
breakers.add("def");
CcTrayJobStatusChangeHandler handler = new CcTrayJobStatusChangeHandler(cache);
ProjectStatus newStatus = handler.statusFor(JobInstanceMother.completed(jobName), breakers);
assertThat(newStatus.getBreakers(), is(breakers));
}
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 call.
public void call(PipelineConfig pipelineConfig, String pipelineGroup) {
ArrayList<ProjectStatus> projectStatuses = new ArrayList<>();
final Map<String, Viewers> groupsAndTheirViewers = ccTrayViewAuthority.groupsAndTheirViewers();
Viewers usersWithViewPermissionsOfThisGroup = groupsAndTheirViewers.get(pipelineGroup);
updateProjectStatusForPipeline(usersWithViewPermissionsOfThisGroup, pipelineConfig, projectStatuses);
cache.putAll(projectStatuses);
}
use of com.thoughtworks.go.domain.activity.ProjectStatus in project gocd by gocd.
the class CcTrayCacheTest method shouldBeAbleToReplaceMultipleItemsInCache.
@Test
public void shouldBeAbleToReplaceMultipleItemsInCache() throws Exception {
ProjectStatus firstStatusOfItem1 = new ProjectStatus("item1", "Sleeping 1", "last-build-status 1", "last-build-label 1", new Date(), "web-url 1");
ProjectStatus nextStatusOfItem1 = new ProjectStatus("item1", "Sleeping 2", "last-build-status 2", "last-build-label 2", new Date(), "web-url 2");
ProjectStatus status2 = new ProjectStatus("item2", "Sleeping", "last-build-status", "last-build-label", new Date(), "web-url");
ProjectStatus firstStatusOfItem3 = new ProjectStatus("item3", "Sleeping A", "last-build-status A", "last-build-label A", new Date(), "web-url A");
ProjectStatus nextStatusOfItem3 = new ProjectStatus("item3", "Sleeping B", "last-build-status B", "last-build-label B", new Date(), "web-url B");
cache.put(firstStatusOfItem1);
cache.put(status2);
cache.put(firstStatusOfItem3);
cache.putAll(asList(nextStatusOfItem1, status2, nextStatusOfItem3));
assertThat(cache.get("item1"), is(nextStatusOfItem1));
assertThat(cache.get("item2"), is(status2));
assertThat(cache.get("item3"), is(nextStatusOfItem3));
}
Aggregations