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