use of com.thoughtworks.go.domain.JobInstance in project gocd by gocd.
the class CcTrayJobStatusChangeHandlerTest method shouldUpdateValueInCacheWhenJobHasChanged.
@Test
public void shouldUpdateValueInCacheWhenJobHasChanged() throws Exception {
String jobName = "job1";
ProjectStatus existingStatusInCache = new ProjectStatus(projectNameFor(jobName), "OldActivity", "OldStatus", "OldLabel", new Date(), webUrlFor(jobName));
when(cache.get(projectNameFor(jobName))).thenReturn(existingStatusInCache);
CcTrayJobStatusChangeHandler handler = new CcTrayJobStatusChangeHandler(cache);
JobInstance completedJob = JobInstanceMother.completed(jobName);
handler.call(completedJob);
verify(cache).put(statusCaptor.capture());
ProjectStatus newStatusInCache = statusCaptor.getValue();
assertThat(newStatusInCache.name(), is(projectNameFor(jobName)));
assertThat(newStatusInCache.getLastBuildStatus(), is("Success"));
assertThat(newStatusInCache.getLastBuildLabel(), is("label-1"));
assertThat(newStatusInCache.getLastBuildTime(), is(completedJob.getCompletedDate()));
assertThat(newStatusInCache.getBreakers(), is(Collections.<String>emptySet()));
assertThat(activityOf(newStatusInCache), is("Sleeping"));
assertThat(webUrlOf(newStatusInCache), is(webUrlFor(jobName)));
}
use of com.thoughtworks.go.domain.JobInstance in project gocd by gocd.
the class JobStatusListenerTest method setUp.
@Before
public void setUp() throws Exception {
goCache.clear();
dbHelper.onSetUp();
configHelper.usingCruiseConfigDao(goConfigDao);
configHelper.onSetUp();
PipelineConfig pipelineConfig = withSingleStageWithMaterials(PIPELINE_NAME, STAGE_NAME, withBuildPlans(JOB_NAME));
configHelper.addPipeline(PIPELINE_NAME, STAGE_NAME);
savedPipeline = scheduleHelper.schedule(pipelineConfig, BuildCause.createWithModifications(modifyOneFile(pipelineConfig), ""), GoConstants.DEFAULT_APPROVED_BY);
JobInstance job = savedPipeline.getStages().first().getJobInstances().first();
job.setAgentUuid(UUID);
mockery = new ClassMockery();
stageStatusTopic = mockery.mock(StageStatusTopic.class);
}
use of com.thoughtworks.go.domain.JobInstance in project gocd by gocd.
the class JobStatusCacheTest method shouldExcludeJobFromOtherPipelines.
@Test
public void shouldExcludeJobFromOtherPipelines() {
JobInstance job1 = JobInstanceMother.instanceForRunOnAllAgents("cruise", "dev", "linux-firefox", "1", 1);
JobInstance job2 = JobInstanceMother.instanceForRunOnAllAgents("cruise", "dev", "linux-firefox", "1", 2);
jobStatusCache.jobStatusChanged(job1);
jobStatusCache.jobStatusChanged(job2);
JobInstance otherPipeline = JobInstanceMother.buildingInstance("different-pipeline", "dev", "linux-firefox", "1");
jobStatusCache.jobStatusChanged(otherPipeline);
JobConfigIdentifier config = new JobConfigIdentifier("cruise", "dev", "linux-firefox");
List<JobInstance> list = jobStatusCache.currentJobs(config);
assertThat(list, not(hasItem(otherPipeline)));
}
use of com.thoughtworks.go.domain.JobInstance in project gocd by gocd.
the class JobStatusCacheTest method shouldRefreshCurrentJobWhenNewJobComes.
@Test
public void shouldRefreshCurrentJobWhenNewJobComes() {
JobInstance job = JobInstanceMother.buildingInstance("cruise", "dev", "linux-firefox", "1");
jobStatusCache.jobStatusChanged(job);
assertThat(jobStatusCache.currentJob(job.getIdentifier().jobConfigIdentifier()).getState(), is(JobState.Building));
JobInstance passing = job.clone();
passing.changeState(JobState.Completed);
jobStatusCache.jobStatusChanged(passing);
assertThat(jobStatusCache.currentJob(passing.getIdentifier().jobConfigIdentifier()).getState(), is(JobState.Completed));
}
use of com.thoughtworks.go.domain.JobInstance in project gocd by gocd.
the class PipelineWithTwoStages method createPipelineWithFirstStageAssigned.
public Pipeline createPipelineWithFirstStageAssigned(String agentId) {
Pipeline pipeline = createPipelineWithFirstStageScheduled();
JobInstances instances = pipeline.getStages().byName(devStage).getJobInstances();
for (JobInstance instance : instances) {
dbHelper.assignToAgent(instance, agentId);
}
return dbHelper.getPipelineDao().loadPipeline(pipeline.getId());
}
Aggregations