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));
}
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));
}
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())));
}
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));
}
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());
}
Aggregations