Search in sources :

Example 1 with JobInstance

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

Example 2 with JobInstance

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

Example 3 with JobInstance

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

Example 4 with JobInstance

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

Example 5 with JobInstance

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()));
}
Also used : StageDao(com.thoughtworks.go.server.dao.StageDao) Expectations(org.jmock.Expectations) JobInstance(com.thoughtworks.go.domain.JobInstance) ArrayList(java.util.ArrayList) JobConfigIdentifier(com.thoughtworks.go.domain.JobConfigIdentifier) Mockery(org.jmock.Mockery) Test(org.junit.Test)

Aggregations

JobInstance (com.thoughtworks.go.domain.JobInstance)90 Test (org.junit.Test)65 Stage (com.thoughtworks.go.domain.Stage)23 Pipeline (com.thoughtworks.go.domain.Pipeline)22 JobIdentifier (com.thoughtworks.go.domain.JobIdentifier)16 JobInstances (com.thoughtworks.go.domain.JobInstances)11 JobConfigIdentifier (com.thoughtworks.go.domain.JobConfigIdentifier)10 Stages (com.thoughtworks.go.domain.Stages)5 JsonTester (com.thoughtworks.go.util.JsonTester)5 Map (java.util.Map)5 ModelAndView (org.springframework.web.servlet.ModelAndView)5 AgentConfig (com.thoughtworks.go.config.AgentConfig)4 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)4 Date (java.util.Date)4 ArtifactPropertiesGenerator (com.thoughtworks.go.config.ArtifactPropertiesGenerator)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 StageDao (com.thoughtworks.go.server.dao.StageDao)3