use of com.thoughtworks.go.domain.JobInstance in project gocd by gocd.
the class JobStatusJsonPresentationModelTest method shouldShowArtifactTabwhenBuildPassed.
@Test
public void shouldShowArtifactTabwhenBuildPassed() throws Exception {
JobInstance instance = JobInstanceMother.passed("plan1");
JobStatusJsonPresentationModel buildStatusJson = new JobStatusJsonPresentationModel(instance);
assertThat(buildStatusJson.getTabToShow(), is("#tab-artifacts"));
}
use of com.thoughtworks.go.domain.JobInstance in project gocd by gocd.
the class CcTrayActivityListenerTest method onIntializationAndStartOfDaemon_ShouldRegisterAListener_WhichInvokesJobChangeHandler_WhenJobStatusChanges.
@Test
public void onIntializationAndStartOfDaemon_ShouldRegisterAListener_WhichInvokesJobChangeHandler_WhenJobStatusChanges() throws Exception {
JobInstance aJob = JobInstanceMother.cancelled("job1");
CcTrayJobStatusChangeHandler handler = mock(CcTrayJobStatusChangeHandler.class);
CcTrayActivityListener listener = new CcTrayActivityListener(goConfigService, handler, null, null);
listener.initialize();
listener.startDaemon();
listener.jobStatusChanged(aJob);
waitForProcessingToHappen();
verify(handler).call(aJob);
}
use of com.thoughtworks.go.domain.JobInstance in project gocd by gocd.
the class CcTrayStageStatusChangeHandlerTest method shouldCreateJobStatusesWithBreakers_OnlyIfTheyHaveFailed.
@Test
public void shouldCreateJobStatusesWithBreakers_OnlyIfTheyHaveFailed() throws Exception {
JobInstance job1_building = JobInstanceMother.building("job1");
JobInstance job2_failed = JobInstanceMother.failed("job2");
Stage stage = StageMother.custom("stage1", job1_building, job2_failed);
when(breakersCalculator.calculateFor(stage)).thenReturn(s("breaker1", "breaker2"));
handler.statusesOfStageAndItsJobsFor(stage);
verify(jobStatusChangeHandler).statusFor(job1_building, new HashSet<>());
verify(jobStatusChangeHandler).statusFor(job2_failed, s("breaker1", "breaker2"));
}
use of com.thoughtworks.go.domain.JobInstance 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.JobInstance in project gocd by gocd.
the class ConsoleActivityMonitorTest method shouldNotTrackConsoleActivityFor_completedJob.
@Test
public void shouldNotTrackConsoleActivityFor_completedJob() {
JobIdentifier jobId = new JobIdentifier("foo-pipeline", 10, "foo-10", "bar-stage", "20", "baz-build");
JobInstance job = buildingInstance(jobId);
listener.jobStatusChanged(job);
Date jobStartAndCompleteTime = new Date();
when(timeProvider.currentTimeMillis()).thenReturn(jobStartAndCompleteTime.getTime());
consoleActivityMonitor.consoleUpdatedFor(jobId);
job.completing(JobResult.Passed);
job.completed(new Date());
listener.jobStatusChanged(job);
when(timeProvider.currentTimeMillis()).thenReturn(new DateTime().plusDays(10).getMillis());
consoleActivityMonitor.cancelUnresponsiveJobs(scheduleService);
verifyNoMoreInteractions(jobInstanceService);
}
Aggregations