use of com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModels in project gocd by gocd.
the class PipelineHistoryServiceIntegrationTest method shouldNotLoadDuplicatPlaceholderStages.
@Test
public void shouldNotLoadDuplicatPlaceholderStages() throws Exception {
goConfigService.addPipeline(PipelineConfigMother.createPipelineConfig("pipeline", "stage", "job"), "pipeline-group");
PipelineInstanceModels history = pipelineHistoryService.load("pipeline", Pagination.pageStartingAt(0, 1, 10), "anyone", true);
PipelineInstanceModel instanceModel = history.first();
assertThat(instanceModel instanceof EmptyPipelineInstanceModel, is(true));
StageInstanceModels stageHistory = instanceModel.getStageHistory();
assertThat(stageHistory.size(), is(1));
assertThat(stageHistory.first() instanceof NullStageHistoryItem, is(true));
}
use of com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModels in project gocd by gocd.
the class PipelineHistoryServiceIntegrationTest method shouldMakePipelineInstanceCanRunFalseWhenDiskSpaceIsEmpty.
@Test
public void shouldMakePipelineInstanceCanRunFalseWhenDiskSpaceIsEmpty() throws Exception {
diskIsFull.onSetUp();
configHelper.updateArtifactRoot(TestFileUtil.createTempFolder("serverlogs").getAbsolutePath());
pipelineOne.createdPipelineWithAllStagesPassed();
PipelineInstanceModels history = pipelineHistoryService.load(pipelineOne.pipelineName, Pagination.pageStartingAt(0, 1, 10), "jez", true);
assertThat(history.size(), is(1));
assertThat(history.first().getCanRun(), is(false));
StageInstanceModels stageHistory = history.first().getStageHistory();
assertThat(stageHistory.size(), is(3));
for (StageInstanceModel stageHistoryItem : stageHistory) {
assertThat(stageHistoryItem.isScheduled(), is(true));
assertThat(stageHistoryItem.getCanRun(), is(false));
}
}
use of com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModels in project gocd by gocd.
the class StageServiceTest method shouldPopulateErrorWhenPipelineNotFound_findDetailedStageHistoryByOffset.
@Test
public void shouldPopulateErrorWhenPipelineNotFound_findDetailedStageHistoryByOffset() {
when(cruiseConfig.hasPipelineNamed(new CaseInsensitiveString("pipeline"))).thenReturn(false);
when(goConfigService.currentCruiseConfig()).thenReturn(cruiseConfig);
when(securityService.hasViewPermissionForPipeline(Username.valueOf("looser"), "pipeline")).thenReturn(true);
final StageService stageService = new StageService(stageDao, jobInstanceService, mock(StageStatusTopic.class), mock(StageStatusCache.class), securityService, pipelineDao, changesetService, goConfigService, transactionTemplate, transactionSynchronizationManager, goCache);
Pagination pagination = Pagination.pageStartingAt(1, 1, 1);
HttpOperationResult result = new HttpOperationResult();
StageInstanceModels stageInstanceModels = stageService.findDetailedStageHistoryByOffset("pipeline", "stage", pagination, "looser", result);
assertThat(stageInstanceModels, is(Matchers.nullValue()));
assertThat(result.httpCode(), is(404));
}
use of com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModels in project gocd by gocd.
the class StageServiceTest method shouldPopulateErrorWhenUnauthorized_findDetailedStageHistoryByOffset.
@Test
public void shouldPopulateErrorWhenUnauthorized_findDetailedStageHistoryByOffset() {
when(cruiseConfig.hasPipelineNamed(new CaseInsensitiveString("pipeline"))).thenReturn(true);
when(goConfigService.currentCruiseConfig()).thenReturn(cruiseConfig);
when(securityService.hasViewPermissionForPipeline(Username.valueOf("looser"), "pipeline")).thenReturn(false);
final StageService stageService = new StageService(stageDao, jobInstanceService, mock(StageStatusTopic.class), mock(StageStatusCache.class), securityService, pipelineDao, changesetService, goConfigService, transactionTemplate, transactionSynchronizationManager, goCache);
Pagination pagination = Pagination.pageStartingAt(1, 1, 1);
HttpOperationResult result = new HttpOperationResult();
StageInstanceModels stageInstanceModels = stageService.findDetailedStageHistoryByOffset("pipeline", "stage", pagination, "looser", result);
assertThat(stageInstanceModels, is(Matchers.nullValue()));
assertThat(result.httpCode(), is(401));
}
use of com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModels in project gocd by gocd.
the class ViewCacheKeyTest method shouldGenerateKeyForBuildCause.
@Test
public void shouldGenerateKeyForBuildCause() {
PipelineModel model = new PipelineModel("pipelineName", true, true, PipelinePauseInfo.notPaused());
PipelineInstanceModel pipelineInstance = PipelineInstanceModel.createPipeline("pipelineName", 10, "label-10", BuildCause.createExternal(), new StageInstanceModels());
pipelineInstance.setId(12);
TrackingTool trackingTool = new TrackingTool("link", "regex");
pipelineInstance.setTrackingTool(trackingTool);
model.addPipelineInstance(pipelineInstance);
PipelineInstanceModel pipelineInstance2 = PipelineInstanceModel.createPipeline("pipelineName", 7, "label-7", BuildCause.createExternal(), new StageInstanceModels());
pipelineInstance2.setId(14);
MingleConfig mingleConfig = new MingleConfig("mingle", "project", "mql");
pipelineInstance2.setMingleConfig(mingleConfig);
model.addPipelineInstance(pipelineInstance2);
assertThat(viewCacheKey.forPipelineModelBuildCauses(model), is(String.format("view_buildCausesForPipelineModel_pipelineName[12|%s|%s][14|%s|%s]", trackingTool.hashCode(), -1, -1, mingleConfig.hashCode())));
}
Aggregations