use of com.thoughtworks.go.server.util.Pagination in project gocd by gocd.
the class JobInstanceServiceTest method shouldPopulateErrorWhenPipelineNotFound_findJobHistoryPage.
@Test
public void shouldPopulateErrorWhenPipelineNotFound_findJobHistoryPage() {
when(cruiseConfig.hasPipelineNamed(new CaseInsensitiveString("pipeline"))).thenReturn(false);
when(goConfigService.currentCruiseConfig()).thenReturn(cruiseConfig);
when(securityService.hasViewPermissionForPipeline(Username.valueOf("looser"), "pipeline")).thenReturn(true);
final JobInstanceService jobService = new JobInstanceService(jobInstanceDao, buildPropertiesService, topic, jobStatusCache, transactionTemplate, transactionSynchronizationManager, null, null, goConfigService, securityService, pluginManager, serverHealthService);
Pagination pagination = Pagination.pageStartingAt(1, 1, 1);
HttpOperationResult result = new HttpOperationResult();
JobInstances jobHistoryPage = jobService.findJobHistoryPage("pipeline", "stage", "job", pagination, "looser", result);
assertThat(jobHistoryPage, is(nullValue()));
assertThat(result.httpCode(), is(404));
}
use of com.thoughtworks.go.server.util.Pagination in project gocd by gocd.
the class JobInstanceServiceTest method shouldPopulateErrorWhenUnauthorized_findJobHistoryPage.
@Test
public void shouldPopulateErrorWhenUnauthorized_findJobHistoryPage() {
when(cruiseConfig.hasPipelineNamed(new CaseInsensitiveString("pipeline"))).thenReturn(true);
when(goConfigService.currentCruiseConfig()).thenReturn(cruiseConfig);
when(securityService.hasViewPermissionForPipeline(Username.valueOf("looser"), "pipeline")).thenReturn(false);
final JobInstanceService jobService = new JobInstanceService(jobInstanceDao, buildPropertiesService, topic, jobStatusCache, transactionTemplate, transactionSynchronizationManager, null, null, goConfigService, securityService, pluginManager, serverHealthService);
Pagination pagination = Pagination.pageStartingAt(1, 1, 1);
HttpOperationResult result = new HttpOperationResult();
JobInstances jobHistoryPage = jobService.findJobHistoryPage("pipeline", "stage", "job", pagination, "looser", result);
assertThat(jobHistoryPage, is(nullValue()));
assertThat(result.canContinue(), is(false));
}
use of com.thoughtworks.go.server.util.Pagination in project gocd by gocd.
the class MaterialServiceTest method shouldDelegateToMaterialRepository_getModificationsFor.
@Test
public void shouldDelegateToMaterialRepository_getModificationsFor() {
GitMaterialConfig materialConfig = new GitMaterialConfig("http://test.com");
GitMaterialInstance gitMaterialInstance = new GitMaterialInstance("http://test.com", null, null, "flyweight");
Pagination pagination = Pagination.pageStartingAt(0, 10, 10);
Modifications modifications = new Modifications();
modifications.add(new Modification("user", "comment", "email", new Date(), "revision"));
when(materialRepository.findMaterialInstance(materialConfig)).thenReturn(gitMaterialInstance);
when(materialRepository.getModificationsFor(gitMaterialInstance, pagination)).thenReturn(modifications);
Modifications gotModifications = materialService.getModificationsFor(materialConfig, pagination);
assertThat(gotModifications, is(modifications));
}
use of com.thoughtworks.go.server.util.Pagination in project gocd by gocd.
the class StageService method findStageHistoryForChart.
public StageSummaryModels findStageHistoryForChart(String pipelineName, String stageName, int pageNumber, int pageSize, Username username) {
int total = stageDao.getTotalStageCountForChart(pipelineName, stageName);
Pagination pagination = Pagination.pageByNumber(pageNumber, total, pageSize);
List<Stage> stages = stageDao.findStageHistoryForChart(pipelineName, stageName, pageSize, pagination.getOffset());
StageSummaryModels stageSummaryModels = new StageSummaryModels();
for (Stage forStage : stages) {
StageSummaryModel stageSummaryByIdentifier = new StageSummaryModel(forStage, null, stageDao, forStage.getIdentifier());
if (!stageSummaryByIdentifier.getStage().getState().completed()) {
continue;
}
stageSummaryModels.add(stageSummaryByIdentifier);
}
stageSummaryModels.setPagination(pagination);
return stageSummaryModels;
}
use of com.thoughtworks.go.server.util.Pagination in project gocd by gocd.
the class JobInstanceService method completedJobsOnAgent.
public JobInstancesModel completedJobsOnAgent(String uuid, JobHistoryColumns columnName, SortOrder order, int pageNumber, int pageSize) {
int total = totalCompletedJobsCountOn(uuid);
Pagination pagination = Pagination.pageByNumber(pageNumber, total, pageSize);
return completedJobsOnAgent(uuid, columnName, order, pagination);
}
Aggregations