Search in sources :

Example 26 with PipelineInstanceModel

use of com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel in project gocd by gocd.

the class PipelineHistoryServiceIntegrationTest method shouldPopulateResultAsNotFoundWhenPipelineNotFound.

@Test
public void shouldPopulateResultAsNotFoundWhenPipelineNotFound() {
    HttpOperationResult result = new HttpOperationResult();
    PipelineInstanceModel pipelineInstance = pipelineHistoryService.load(-1, new Username(new CaseInsensitiveString("foo")), result);
    assertThat(pipelineInstance, is(nullValue()));
    assertThat(result.httpCode(), is(404));
}
Also used : HttpOperationResult(com.thoughtworks.go.server.service.result.HttpOperationResult) Username(com.thoughtworks.go.server.domain.Username) PipelineInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel) EmptyPipelineInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.EmptyPipelineInstanceModel) Test(org.junit.Test)

Example 27 with PipelineInstanceModel

use of com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel in project gocd by gocd.

the class PipelineHistoryServiceIntegrationTest method shouldNotThrowUpWhenPipelineCounterIs0AndShouldReturnAnEmptyPIM.

@Test
public void shouldNotThrowUpWhenPipelineCounterIs0AndShouldReturnAnEmptyPIM() {
    PipelineConfig mingleConfig = PipelineConfigMother.createPipelineConfig("mingle", "stage", "job");
    goConfigService.addPipeline(mingleConfig, "pipeline-group");
    PipelineInstanceModel pim = pipelineHistoryService.findPipelineInstance("mingle", 0, new Username(new CaseInsensitiveString("doesnotmatter")), new HttpOperationResult());
    assertThat(pim, instanceOf(EmptyPipelineInstanceModel.class));
}
Also used : HttpOperationResult(com.thoughtworks.go.server.service.result.HttpOperationResult) EmptyPipelineInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.EmptyPipelineInstanceModel) Username(com.thoughtworks.go.server.domain.Username) PipelineInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel) EmptyPipelineInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.EmptyPipelineInstanceModel) Test(org.junit.Test)

Example 28 with PipelineInstanceModel

use of com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel in project gocd by gocd.

the class PipelineHistoryServiceIntegrationTest method shouldPopulateResultAsUnauthorizedWhenUserNotAllowedToViewPipeline.

@Test
public void shouldPopulateResultAsUnauthorizedWhenUserNotAllowedToViewPipeline() {
    Pipeline pipeline = pipelineOne.createdPipelineWithAllStagesPassed();
    String groupName = configHelper.currentConfig().getGroups().findGroupNameByPipeline(new CaseInsensitiveString(pipeline.getName()));
    configHelper.setViewPermissionForGroup(groupName, "admin");
    HttpOperationResult result = new HttpOperationResult();
    PipelineInstanceModel pipelineInstance = pipelineHistoryService.load(pipeline.getId(), new Username(new CaseInsensitiveString("foo")), result);
    assertThat(pipelineInstance, is(nullValue()));
    assertThat(result.httpCode(), is(401));
    result = new HttpOperationResult();
    pipelineInstance = pipelineHistoryService.load(pipeline.getId(), new Username(new CaseInsensitiveString("admin")), result);
    assertThat(pipelineInstance, is(not(nullValue())));
}
Also used : HttpOperationResult(com.thoughtworks.go.server.service.result.HttpOperationResult) Username(com.thoughtworks.go.server.domain.Username) PipelineInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel) EmptyPipelineInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.EmptyPipelineInstanceModel) Test(org.junit.Test)

Example 29 with PipelineInstanceModel

use of com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel in project gocd by gocd.

the class PipelineHistoryServiceIntegrationTest method findMatchingPipelineInstances_shouldPopulatePipelineFieldsIncludingPlaceholderStages.

@Test
public void findMatchingPipelineInstances_shouldPopulatePipelineFieldsIncludingPlaceholderStages() {
    configHelper.setViewPermissionForGroup("group1", "jez");
    Pipeline pipeline = pipelineOne.createPipelineWithFirstStagePassedAndSecondStageHasNotStarted();
    PipelineInstanceModels actual = pipelineHistoryService.findMatchingPipelineInstances(pipeline.getName(), pipeline.getBuildCause().getMaterialRevisions().getMaterialRevision(0).getLatestComment(), 2, new Username(new CaseInsensitiveString("jez")), new HttpLocalizedOperationResult());
    assertThat(actual.size(), is(1));
    PipelineInstanceModel actualPipeline = actual.get(0);
    assertThat(actualPipeline.getCounter(), is(1));
    assertThat(actualPipeline.getStageHistory().size(), is(3));
    assertThat(actualPipeline.getStageHistory().get(1).getState(), is(StageState.Unknown));
    assertThat(actualPipeline.getStageHistory().get(2).getState(), is(StageState.Unknown));
}
Also used : HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) PipelineInstanceModels(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels) Username(com.thoughtworks.go.server.domain.Username) PipelineInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel) EmptyPipelineInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.EmptyPipelineInstanceModel) Test(org.junit.Test)

Example 30 with PipelineInstanceModel

use of com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel in project gocd by gocd.

the class PipelineSqlMapDaoTest method shouldLoadPipelineHistoryFromCacheWhenQueriedViaNameAndCounter.

@Test
public void shouldLoadPipelineHistoryFromCacheWhenQueriedViaNameAndCounter() throws Exception {
    String pipelineName = "wholetthedogsout";
    int pipelineCounter = 42;
    PipelineInstanceModel expected = mock(PipelineInstanceModel.class);
    when(goCache.get(anyString())).thenReturn(expected);
    //returned from cache
    PipelineInstanceModel reFetch = pipelineSqlMapDao.findPipelineHistoryByNameAndCounter(pipelineName, pipelineCounter);
    assertThat(reFetch, is(expected));
    verify(goCache).get(anyString());
}
Also used : PipelineInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Aggregations

PipelineInstanceModel (com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel)69 Test (org.junit.Test)46 EmptyPipelineInstanceModel (com.thoughtworks.go.presentation.pipelinehistory.EmptyPipelineInstanceModel)20 PipelineInstanceModels (com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels)15 Username (com.thoughtworks.go.server.domain.Username)15 StageInstanceModels (com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModels)14 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)11 PipelineModel (com.thoughtworks.go.presentation.pipelinehistory.PipelineModel)10 StageInstanceModel (com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModel)8 Modification (com.thoughtworks.go.domain.materials.Modification)7 HttpOperationResult (com.thoughtworks.go.server.service.result.HttpOperationResult)7 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)6 NullStageHistoryItem (com.thoughtworks.go.presentation.pipelinehistory.NullStageHistoryItem)6 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)5 PipelineDependencyGraphOld (com.thoughtworks.go.domain.PipelineDependencyGraphOld)4 Material (com.thoughtworks.go.domain.materials.Material)4 PipelineHistoryGroups (com.thoughtworks.go.server.presentation.models.PipelineHistoryGroups)4 Date (java.util.Date)4 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)3 StageIdentifier (com.thoughtworks.go.domain.StageIdentifier)3