use of com.thoughtworks.go.domain.JobInstances in project gocd by gocd.
the class PipelineWithRunOnAllJob 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());
}
use of com.thoughtworks.go.domain.JobInstances in project gocd by gocd.
the class BackgroundStageLoaderTest method setup.
@Before
public void setup() {
stageFeedsReader = mock(StageAtomFeedsReader.class);
pipelineInstanceLoader = mock(PipelineInstanceLoader.class);
systemEnvironment = mock(SystemEnvironment.class);
backgroundStageLoader = new BackgroundStageLoader(stageFeedsReader, mock(StageResourceImporter.class), mock(StageStorage.class), pipelineInstanceLoader, mock(StageService.class), systemEnvironment);
listener = new BackgroundStageLoaderStageStatusListener(backgroundStageLoader, systemEnvironment);
stage = new Stage();
jobInstances = mock(JobInstances.class);
}
use of com.thoughtworks.go.domain.JobInstances in project gocd by gocd.
the class JobPresentationServiceTest method shouldReturnJobModel.
@Test
public void shouldReturnJobModel() {
JobInstance dev = assignedWithAgentId("dev", "agent1");
JobInstance DEv = assignedWithAgentId("DEv", "agent1");
JobInstance bev = assignedWithAgentId("bev", "agent2");
JobInstance tev = scheduled("tev");
JobInstance lev = assignAgent(passed("lev"), "agent3");
JobInstance kev = assignAgent(failed("kev"), "agent3");
AgentInstance agentInstance = building();
when(agentService.findAgentAndRefreshStatus(any(String.class))).thenReturn(agentInstance);
List<JobInstanceModel> models = new JobPresentationService(jobDurationStrategy, agentService).jobInstanceModelFor(new JobInstances(dev, bev, tev, lev, kev, DEv));
assertThat(models.size(), is(6));
// failed
assertThat(models.get(0), is(new JobInstanceModel(kev, jobDurationStrategy, agentInstance)));
// in progress. sort by name (case insensitive)
assertThat(models.get(1), is(new JobInstanceModel(bev, jobDurationStrategy, agentInstance)));
assertThat(models.get(2), is(new JobInstanceModel(dev, jobDurationStrategy, agentInstance)));
assertThat(models.get(3), is(new JobInstanceModel(DEv, jobDurationStrategy, agentInstance)));
assertThat(models.get(4), is(new JobInstanceModel(tev, jobDurationStrategy)));
// passed
assertThat(models.get(5), is(new JobInstanceModel(lev, jobDurationStrategy, agentInstance)));
// assert agent info
verify(agentService, times(2)).findAgentAndRefreshStatus("agent1");
verify(agentService).findAgentAndRefreshStatus("agent2");
verify(agentService, times(2)).findAgentAndRefreshStatus("agent3");
verifyNoMoreInteractions(agentService);
}
use of com.thoughtworks.go.domain.JobInstances in project gocd by gocd.
the class StageSummaryModelTest method shouldRetriveShowElapsedTime.
@Test
public void shouldRetriveShowElapsedTime() throws Exception {
JobInstance first = JobInstanceMother.completed("first", JobResult.Failed);
Stage stage = StageMother.custom("pipeline", "stage", new JobInstances(first));
StageSummaryModel model = new StageSummaryModel(stage, new Stages(stage), JOB_DURATION_STRATEGY, null);
assertThat(model.nonPassedJobs().get(0).getElapsedTime(), is(first.getElapsedTime()));
}
use of com.thoughtworks.go.domain.JobInstances in project gocd by gocd.
the class StageSummaryModelTest method shouldReturnJobsForAGivenResult.
@Test
public void shouldReturnJobsForAGivenResult() throws Exception {
JobInstance first = JobInstanceMother.completed("first", JobResult.Failed);
JobInstance second = JobInstanceMother.completed("bsecond", JobResult.Passed);
JobInstance third = JobInstanceMother.completed("athird", JobResult.Passed);
JobInstance fourth = JobInstanceMother.building("fourth");
JobInstance fifth = JobInstanceMother.completed("fifth", JobResult.Cancelled);
Stage stage = StageMother.custom("pipeline", "stage", new JobInstances(first, second, third, fourth, fifth));
StageSummaryModel model = new StageSummaryModel(stage, new Stages(stage), JOB_DURATION_STRATEGY, null);
assertThat(model.passedJobs().size(), is(2));
assertThat(model.passedJobs().get(0).getName(), is(third.getName()));
assertThat(model.passedJobs().get(1).getName(), is(second.getName()));
assertThat(model.nonPassedJobs().size(), is(2));
assertThat(model.nonPassedJobs().get(0).getName(), is(fifth.getName()));
assertThat(model.nonPassedJobs().get(1).getName(), is(first.getName()));
assertThat(model.inProgressJobs().size(), is(1));
assertThat(model.inProgressJobs().get(0).getName(), is(fourth.getName()));
}
Aggregations