Search in sources :

Example 31 with StageInstanceModels

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));
}
Also used : Pagination(com.thoughtworks.go.server.util.Pagination) HttpOperationResult(com.thoughtworks.go.server.service.result.HttpOperationResult) StageStatusTopic(com.thoughtworks.go.server.messaging.StageStatusTopic) StageStatusCache(com.thoughtworks.go.domain.activity.StageStatusCache) StageInstanceModels(com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModels) Test(org.junit.Test)

Example 32 with StageInstanceModels

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));
}
Also used : Pagination(com.thoughtworks.go.server.util.Pagination) HttpOperationResult(com.thoughtworks.go.server.service.result.HttpOperationResult) StageStatusTopic(com.thoughtworks.go.server.messaging.StageStatusTopic) StageStatusCache(com.thoughtworks.go.domain.activity.StageStatusCache) StageInstanceModels(com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModels) Test(org.junit.Test)

Example 33 with StageInstanceModels

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

the class ViewCacheKeyTest method shouldGenerateKeyForPipelineModelViewFragmentWithoutSpecialCharactersInPauseCause.

@Test
public void shouldGenerateKeyForPipelineModelViewFragmentWithoutSpecialCharactersInPauseCause() {
    PipelinePauseInfo pauseInfo = new PipelinePauseInfo(true, "pause& @Cause #with $special %char &*(){';/.,<>?", "admin");
    PipelineModel model = new PipelineModel("pipelineName", true, true, pauseInfo).updateAdministrability(true);
    StageInstanceModels stages = new StageInstanceModels();
    stages.add(stageInstance("stageName", 13, JobState.Building, JobResult.Unknown));
    stages.add(new NullStageHistoryItem("stage2", true));
    PipelineInstanceModel pipelineInstance = PipelineInstanceModel.createPipeline("pipelineName", 10, "label-10", BuildCause.createExternal(), stages);
    pipelineInstance.setId(12);
    model.addPipelineInstance(pipelineInstance);
    StageInstanceModels stages2 = new StageInstanceModels();
    stages2.add(stageInstance("stageName", 7, JobState.Completed, JobResult.Passed));
    stages2.add(stageInstance("stage2", 10, JobState.Assigned, JobResult.Unknown));
    PipelineInstanceModel pipelineInstance2 = PipelineInstanceModel.createPipeline("pipelineName", 7, "label-7", BuildCause.createExternal(), stages2);
    pipelineInstance2.setId(14);
    model.addPipelineInstance(pipelineInstance2);
    assertThat(viewCacheKey.forPipelineModelBox(model), is("view_dashboardPipelineFragment_pipelineName{false|false|false}[12|stageName|13|Building|stage2|0|Unknown|][14|stageName|7|Passed|stage2|10|Building|]true|true|true|pauseCausewithspecialchar|admin|true"));
}
Also used : NullStageHistoryItem(com.thoughtworks.go.presentation.pipelinehistory.NullStageHistoryItem) PipelinePauseInfo(com.thoughtworks.go.domain.PipelinePauseInfo) PipelineInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel) StageInstanceModels(com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModels) PipelineModel(com.thoughtworks.go.presentation.pipelinehistory.PipelineModel) Test(org.junit.Test)

Aggregations

StageInstanceModels (com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModels)33 Test (org.junit.Test)20 PipelineInstanceModel (com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel)15 StageInstanceModel (com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModel)13 PipelineInstanceModels (com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels)8 PipelineModel (com.thoughtworks.go.presentation.pipelinehistory.PipelineModel)8 NullStageHistoryItem (com.thoughtworks.go.presentation.pipelinehistory.NullStageHistoryItem)6 StageIdentifier (com.thoughtworks.go.domain.StageIdentifier)5 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)4 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)4 Pagination (com.thoughtworks.go.server.util.Pagination)4 PipelineDependencyGraphOld (com.thoughtworks.go.domain.PipelineDependencyGraphOld)3 HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)2 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)2 StageStatusCache (com.thoughtworks.go.domain.activity.StageStatusCache)2 StageStatusTopic (com.thoughtworks.go.server.messaging.StageStatusTopic)2 ScheduleTestUtil (com.thoughtworks.go.server.service.ScheduleTestUtil)2 HttpOperationResult (com.thoughtworks.go.server.service.result.HttpOperationResult)2 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)2 MingleConfig (com.thoughtworks.go.config.MingleConfig)1