Search in sources :

Example 66 with JobInstance

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"));
}
Also used : JobInstance(com.thoughtworks.go.domain.JobInstance) Test(org.junit.Test)

Example 67 with JobInstance

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);
}
Also used : JobInstance(com.thoughtworks.go.domain.JobInstance) Test(org.junit.Test)

Example 68 with JobInstance

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"));
}
Also used : JobInstance(com.thoughtworks.go.domain.JobInstance) NullStage(com.thoughtworks.go.domain.NullStage) Stage(com.thoughtworks.go.domain.Stage) Test(org.junit.Test)

Example 69 with JobInstance

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"));
}
Also used : ProjectStatus(com.thoughtworks.go.domain.activity.ProjectStatus) JobInstance(com.thoughtworks.go.domain.JobInstance) NullStage(com.thoughtworks.go.domain.NullStage) Stage(com.thoughtworks.go.domain.Stage) Test(org.junit.Test)

Example 70 with JobInstance

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);
}
Also used : JobInstance(com.thoughtworks.go.domain.JobInstance) JobIdentifier(com.thoughtworks.go.domain.JobIdentifier) Date(java.util.Date) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Aggregations

JobInstance (com.thoughtworks.go.domain.JobInstance)82 Test (org.junit.Test)56 Stage (com.thoughtworks.go.domain.Stage)16 JobIdentifier (com.thoughtworks.go.domain.JobIdentifier)15 Pipeline (com.thoughtworks.go.domain.Pipeline)15 JobInstances (com.thoughtworks.go.domain.JobInstances)12 JobConfigIdentifier (com.thoughtworks.go.domain.JobConfigIdentifier)7 Agent (com.thoughtworks.go.server.domain.Agent)6 Gson (com.google.gson.Gson)5 Stages (com.thoughtworks.go.domain.Stages)5 Map (java.util.Map)5 DurationBean (com.thoughtworks.go.dto.DurationBean)4 DateTime (org.joda.time.DateTime)4 ArtifactPropertiesGenerator (com.thoughtworks.go.config.ArtifactPropertiesGenerator)3 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)3 Resource (com.thoughtworks.go.config.Resource)3 DirectoryEntries (com.thoughtworks.go.domain.DirectoryEntries)3 StageIdentifier (com.thoughtworks.go.domain.StageIdentifier)3 ProjectStatus (com.thoughtworks.go.domain.activity.ProjectStatus)3 JobInstanceModel (com.thoughtworks.go.server.ui.JobInstanceModel)3