use of com.thoughtworks.go.server.ui.JobInstancesModel in project gocd by gocd.
the class AgentJobHistoryControllerV1 method index.
public String index(Request request, Response response) throws IOException {
String uuid = request.params(":uuid");
Integer offset = getOffset(request);
Integer pageSize = getPageSize(request);
JobInstanceService.JobHistoryColumns column = getSortColumn(request);
SortOrder sortOrder = getSortOrder(request);
Integer total = jobInstanceService.totalCompletedJobsCountOn(uuid);
Pagination pagination = Pagination.pageStartingAt(offset, total, pageSize);
AgentInstance agent = agentService.findAgent(uuid);
if (agent.isNullAgent()) {
throw new RecordNotFoundException(EntityType.Agent, uuid);
}
JobInstancesModel jobInstances = jobInstanceService.completedJobsOnAgent(uuid, column, sortOrder, pagination);
return writerForTopLevelObject(request, response, outputWriter -> AgentJobHistoryRepresenter.toJSON(outputWriter, uuid, jobInstances));
}
use of com.thoughtworks.go.server.ui.JobInstancesModel in project gocd by gocd.
the class JobInstanceServiceTest method shouldGetCompletedJobsOnAgentOnTheGivenPage.
@Test
public void shouldGetCompletedJobsOnAgentOnTheGivenPage() {
JobInstanceService jobService = new JobInstanceService(jobInstanceDao, null, jobStatusCache, transactionTemplate, transactionSynchronizationManager, null, null, goConfigService, null, serverHealthService);
ArrayList<JobInstance> expected = new ArrayList<>();
when(jobInstanceDao.totalCompletedJobsOnAgent("uuid")).thenReturn(500);
when(jobInstanceDao.completedJobsOnAgent("uuid", JobInstanceService.JobHistoryColumns.pipeline, SortOrder.ASC, 50, 50)).thenReturn(expected);
JobInstancesModel actualModel = jobService.completedJobsOnAgent("uuid", JobInstanceService.JobHistoryColumns.pipeline, SortOrder.ASC, 2, 50);
assertThat(actualModel, is(new JobInstancesModel(new JobInstances(expected), Pagination.pageByNumber(2, 500, 50))));
verify(jobInstanceDao).totalCompletedJobsOnAgent("uuid");
verify(jobInstanceDao).completedJobsOnAgent("uuid", JobInstanceService.JobHistoryColumns.pipeline, SortOrder.ASC, 50, 50);
}
Aggregations