use of com.thoughtworks.go.domain.PipelineRunIdInfo in project gocd by gocd.
the class MaterialServiceTest method shouldReturnNullIfNoInstanceIsPresent.
@Test
public void shouldReturnNullIfNoInstanceIsPresent() {
GitMaterialConfig materialConfig = git("http://test.com");
when(materialRepository.findMaterialInstance(materialConfig)).thenReturn(null);
PipelineRunIdInfo info = materialService.getLatestAndOldestModification(materialConfig, "");
verify(materialRepository, never()).getOldestAndLatestModificationId(anyLong(), anyString());
assertThat(info, is(nullValue()));
}
use of com.thoughtworks.go.domain.PipelineRunIdInfo in project gocd by gocd.
the class ModificationsRepresenter method toJSON.
public static void toJSON(OutputWriter outputWriter, List<Modification> modifications, PipelineRunIdInfo latestAndOldestModId, String fingerprint, String pattern, Integer pageSize) {
if (modifications == null || modifications.isEmpty()) {
outputWriter.addChildList("modifications", emptyList());
return;
}
if (latestAndOldestModId != null) {
Modification latest = modifications.get(0);
Modification oldest = modifications.get(modifications.size() - 1);
String previousLink = null, nextLink = null;
if (latest.getId() != latestAndOldestModId.getLatestRunId()) {
previousLink = Routes.InternalMaterialConfig.previous(fingerprint, latest.getId(), pattern, pageSize);
}
if (oldest.getId() != latestAndOldestModId.getOldestRunId()) {
nextLink = Routes.InternalMaterialConfig.next(fingerprint, oldest.getId(), pattern, pageSize);
}
if (isNotBlank(previousLink) || isNotBlank(nextLink)) {
String finalPreviousLink = previousLink;
String finalNextLink = nextLink;
outputWriter.addLinks(outputLinkWriter -> {
outputLinkWriter.addLinkIfPresent("previous", finalPreviousLink);
outputLinkWriter.addLinkIfPresent("next", finalNextLink);
});
}
}
outputWriter.addChildList("modifications", childWriter -> {
modifications.forEach((mod) -> childWriter.addChild(writer -> ModificationRepresenter.toJSON(writer, mod)));
});
}
use of com.thoughtworks.go.domain.PipelineRunIdInfo in project gocd by gocd.
the class StageInstanceControllerV3 method history.
public String history(Request request, Response response) throws IOException {
String pipelineName = request.params("pipeline_name");
String stageName = request.params("stage_name");
Long after = getCursor(request, "after");
Long before = getCursor(request, "before");
int pageSize = getPageSize(request);
StageInstanceModels stageInstanceModels = stageService.findStageHistoryViaCursor(currentUsername(), pipelineName, stageName, after, before, pageSize);
PipelineRunIdInfo latestAndOldestPipelineIds = stageService.getOldestAndLatestStageInstanceId(currentUsername(), pipelineName, stageName);
return writerForTopLevelObject(request, response, writer -> StageInstancesRepresenter.toJSON(writer, stageInstanceModels, latestAndOldestPipelineIds));
}
use of com.thoughtworks.go.domain.PipelineRunIdInfo in project gocd by gocd.
the class MaterialServiceTest method shouldCallDaoToFetchLatestAndOlderModification.
@Test
public void shouldCallDaoToFetchLatestAndOlderModification() {
GitMaterialConfig materialConfig = git("http://test.com");
GitMaterialInstance gitMaterialInstance = new GitMaterialInstance("http://test.com", null, null, null, "flyweight");
PipelineRunIdInfo value = new PipelineRunIdInfo(1, 2);
when(materialRepository.findMaterialInstance(materialConfig)).thenReturn(gitMaterialInstance);
when(materialRepository.getOldestAndLatestModificationId(anyLong(), anyString())).thenReturn(value);
PipelineRunIdInfo info = materialService.getLatestAndOldestModification(materialConfig, "");
verify(materialRepository).getOldestAndLatestModificationId(anyLong(), eq(""));
assertThat(info, is(value));
}
use of com.thoughtworks.go.domain.PipelineRunIdInfo in project gocd by gocd.
the class PipelineInstanceControllerV1 method getHistoryInfo.
String getHistoryInfo(Request request, Response response) throws IOException {
String pipelineName = request.params("pipeline_name");
Integer pageSize = getPageSize(request);
Long after = getCursor(request, "after");
Long before = getCursor(request, "before");
PipelineInstanceModels pipelineInstanceModels = pipelineHistoryService.loadPipelineHistoryData(currentUsername(), pipelineName, after, before, pageSize);
PipelineRunIdInfo latestAndOldestPipelineIds = pipelineHistoryService.getOldestAndLatestPipelineId(pipelineName, currentUsername());
return writerForTopLevelObject(request, response, (outputWriter) -> PipelineInstanceModelsRepresenter.toJSON(outputWriter, pipelineInstanceModels, latestAndOldestPipelineIds));
}
Aggregations