Search in sources :

Example 6 with PipelineRunIdInfo

use of com.thoughtworks.go.domain.PipelineRunIdInfo in project gocd by gocd.

the class InternalMaterialModificationsControllerV1 method modifications.

public String modifications(Request request, Response response) throws Exception {
    String fingerprint = request.params("fingerprint");
    Long after = afterCursor(request);
    Long before = beforeCursor(request);
    Integer pageSize = getPageSize(request);
    String pattern = request.queryParamOrDefault("pattern", "");
    HttpOperationResult result = new HttpOperationResult();
    MaterialConfig materialConfig = materialConfigService.getMaterialConfig(currentUsernameString(), fingerprint, result);
    if (!result.canContinue()) {
        return renderHTTPOperationResult(result, request, response);
    }
    List<Modification> modifications = materialService.getModificationsFor(materialConfig, pattern, after, before, pageSize);
    PipelineRunIdInfo info = materialService.getLatestAndOldestModification(materialConfig, pattern);
    return writerForTopLevelObject(request, response, writer -> ModificationsRepresenter.toJSON(writer, modifications, info, materialConfig.getFingerprint(), pattern, pageSize));
}
Also used : PipelineRunIdInfo(com.thoughtworks.go.domain.PipelineRunIdInfo) HttpOperationResult(com.thoughtworks.go.server.service.result.HttpOperationResult) Modification(com.thoughtworks.go.domain.materials.Modification) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig)

Example 7 with PipelineRunIdInfo

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));
}
Also used : PipelineRunIdInfo(com.thoughtworks.go.domain.PipelineRunIdInfo) GitMaterialInstance(com.thoughtworks.go.domain.materials.git.GitMaterialInstance) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

PipelineRunIdInfo (com.thoughtworks.go.domain.PipelineRunIdInfo)7 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)2 Modification (com.thoughtworks.go.domain.materials.Modification)2 Test (org.junit.jupiter.api.Test)2 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2 OutputWriter (com.thoughtworks.go.api.base.OutputWriter)1 JobInstances (com.thoughtworks.go.domain.JobInstances)1 MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)1 GitMaterialInstance (com.thoughtworks.go.domain.materials.git.GitMaterialInstance)1 PipelineInstanceModels (com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels)1 StageInstanceModels (com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModels)1 HttpOperationResult (com.thoughtworks.go.server.service.result.HttpOperationResult)1 Routes (com.thoughtworks.go.spark.Routes)1 Collections.emptyList (java.util.Collections.emptyList)1 List (java.util.List)1 StringUtils.isNotBlank (org.apache.commons.lang3.StringUtils.isNotBlank)1