use of com.thoughtworks.go.domain.JobInstance in project gocd by gocd.
the class AgentAssignmentTest method shouldReturnNullAfterJobIsRescheduled.
@Test
public void shouldReturnNullAfterJobIsRescheduled() {
JobInstance rescheduled = JobInstanceMother.rescheduled("dev", "uuid");
agentAssignment.jobStatusChanged(rescheduled);
assertThat(agentAssignment.latestActiveJobOnAgent("uuid"), is(nullValue()));
}
use of com.thoughtworks.go.domain.JobInstance in project gocd by gocd.
the class AgentAssignmentTest method shouldGetLatestActiveJobOnAgent.
@Test
public void shouldGetLatestActiveJobOnAgent() {
JobInstance assigned = JobInstanceMother.assignedWithAgentId("dev", "uuid");
agentAssignment.jobStatusChanged(assigned);
assertThat(agentAssignment.latestActiveJobOnAgent("uuid"), Is.is(assigned));
}
use of com.thoughtworks.go.domain.JobInstance in project gocd by gocd.
the class JobStatusCacheTest method shouldReturnNullWhenNoCurrentJob.
@Test
public void shouldReturnNullWhenNoCurrentJob() throws Exception {
pipelineFixture.createdPipelineWithAllStagesPassed();
JobConfigIdentifier jobConfigIdentifier = new JobConfigIdentifier(pipelineFixture.pipelineName, pipelineFixture.devStage, "wrong-job");
JobInstance currentJob = jobStatusCache.currentJob(jobConfigIdentifier);
assertThat(currentJob, is(nullValue()));
}
use of com.thoughtworks.go.domain.JobInstance in project gocd by gocd.
the class JobStatusCacheTest method shouldSkipNeverRunJobsWhenTryingToDealWithOtherJobs.
@Test
public void shouldSkipNeverRunJobsWhenTryingToDealWithOtherJobs() {
StageDao dao = mock(StageDao.class);
JobInstance random = jobInstance("random");
when(dao.mostRecentJobsForStage("cruise", "dev")).thenReturn(Arrays.asList(random));
JobStatusCache cache = new JobStatusCache(dao);
assertThat(cache.currentJobs(new JobConfigIdentifier("cruise", "dev", "linux-firefox")).isEmpty(), is(true));
assertThat(cache.currentJobs(new JobConfigIdentifier("cruise", "dev", "random")).get(0), is(random));
Mockito.verify(dao, times(2)).mostRecentJobsForStage("cruise", "dev");
}
use of com.thoughtworks.go.domain.JobInstance in project gocd by gocd.
the class JobStatusCacheTest method shouldLoadMostRecentInstanceFromDBOnlyOnce.
@Test
public void shouldLoadMostRecentInstanceFromDBOnlyOnce() throws SQLException {
Mockery mockery = new Mockery();
final StageDao mock = mockery.mock(StageDao.class);
final JobInstance instance = JobInstanceMother.passed("linux-firefox");
final List<JobInstance> found = new ArrayList<>();
found.add(instance);
mockery.checking(new Expectations() {
{
one(mock).mostRecentJobsForStage("pipeline", "stage");
will(returnValue(found));
}
});
JobConfigIdentifier identifier = new JobConfigIdentifier(instance.getPipelineName(), instance.getStageName(), instance.getName());
JobStatusCache cache = new JobStatusCache(mock);
assertThat(cache.currentJob(identifier).getState(), is(instance.getState()));
//call currentJob for the second time, should not call jobInstanceDao now
assertThat(cache.currentJob(identifier).getState(), is(instance.getState()));
}
Aggregations