Search in sources :

Example 1 with PipelineGroupModel

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

the class PipelineHistoryServiceIntegrationTest method shouldReturnPipelinesInConfigOrder.

@Test
public void shouldReturnPipelinesInConfigOrder() throws Exception {
    pipelineTwo.createdPipelineWithAllStagesPassed();
    pipelineOne.createdPipelineWithAllStagesPassed();
    configHelper.setViewPermissionForGroup("group1", "jez");
    List<PipelineGroupModel> groupModels = pipelineHistoryService.allActivePipelineInstances(new Username(new CaseInsensitiveString("jez")), PipelineSelections.ALL);
    assertThat(groupModels.size(), is(2));
    List<PipelineModel> pipelineOneModels = groupModels.get(0).getPipelineModels();
    assertThat(pipelineOneModels.size(), is(1));
    assertThat(pipelineOneModels.get(0).getActivePipelineInstances().get(0).getName(), is(pipelineTwo.pipelineName));
    List<PipelineModel> pipelineTwoModels = groupModels.get(1).getPipelineModels();
    assertThat(pipelineTwoModels.size(), is(1));
    assertThat(pipelineTwoModels.get(0).getActivePipelineInstances().get(0).getName(), is(pipelineOne.pipelineName));
}
Also used : Username(com.thoughtworks.go.server.domain.Username) PipelineGroupModel(com.thoughtworks.go.presentation.pipelinehistory.PipelineGroupModel) PipelineModel(com.thoughtworks.go.presentation.pipelinehistory.PipelineModel) Test(org.junit.Test)

Example 2 with PipelineGroupModel

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

the class PipelineHistoryServiceIntegrationTest method shouldIncludePauseInformationWhenGettingLatestPipelineInstanceFromAllPipelineGroups.

@Test
public void shouldIncludePauseInformationWhenGettingLatestPipelineInstanceFromAllPipelineGroups() throws Exception {
    pipelineOne.createdPipelineWithAllStagesPassed();
    configHelper.setOperatePermissionForGroup("group1", "chris", "raghu");
    Username userNameChris = new Username(new CaseInsensitiveString("chris"));
    pipelinePauseService.pause(pipelineOne.pipelineName, "paused", userNameChris);
    Username userNameRaghu = new Username(new CaseInsensitiveString("raghu"));
    pipelinePauseService.pause(pipelineTwo.pipelineName, "other paused", userNameRaghu);
    configHelper.setViewPermissionForGroup("group1", "jez");
    List<PipelineGroupModel> groupModels = pipelineHistoryService.allActivePipelineInstances(new Username(new CaseInsensitiveString("jez")), PipelineSelections.ALL);
    assertThat(groupModels.size(), is(2));
    List<PipelineModel> pipelineOneModels = groupModels.get(0).getPipelineModels();
    assertThat(pipelineOneModels.size(), is(1));
    PipelinePauseInfo pausedInfo = pipelineOneModels.get(0).getPausedInfo();
    assertThat("isPaused", pausedInfo.isPaused(), is(true));
    assertThat(pausedInfo.getPauseBy(), is("chris"));
    assertThat(pausedInfo.getPauseCause(), is("paused"));
    List<PipelineModel> pipelineTwoModels = groupModels.get(1).getPipelineModels();
    assertThat(pipelineTwoModels.size(), is(1));
    PipelinePauseInfo pipelineTwoPausedInfo = pipelineTwoModels.get(0).getPausedInfo();
    assertThat("isPaused", pipelineTwoPausedInfo.isPaused(), is(true));
    assertThat(pipelineTwoPausedInfo.getPauseBy(), is("raghu"));
    assertThat(pipelineTwoPausedInfo.getPauseCause(), is("other paused"));
}
Also used : Username(com.thoughtworks.go.server.domain.Username) PipelineGroupModel(com.thoughtworks.go.presentation.pipelinehistory.PipelineGroupModel) PipelineModel(com.thoughtworks.go.presentation.pipelinehistory.PipelineModel) Test(org.junit.Test)

Example 3 with PipelineGroupModel

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

the class PipelineHistoryServiceIntegrationTest method shouldGetLatestPipelineInstanceWithPreviousStateFromAllPipelineGroups.

@Test
public void shouldGetLatestPipelineInstanceWithPreviousStateFromAllPipelineGroups() throws Exception {
    configHelper.setViewPermissionForGroup("group1", "jez");
    dbHelper.updateNaturalOrder(pipelineOne.createdPipelineWithAllStagesPassed().getId(), 1.0);
    dbHelper.updateNaturalOrder(pipelineTwo.createdPipelineWithAllStagesPassed().getId(), 1.0);
    dbHelper.updateNaturalOrder(pipelineTwo.createPipelineWithFirstStagePassedAndSecondStageRunning().getId(), 2.0);
    Pipeline toRerun = pipelineTwo.createPipelineWithFirstStagePassedAndSecondStageHasNotStarted();
    pipelineTwo.createPipelineWithFirstStagePassedAndSecondStageHasNotStarted();
    dbHelper.updateNaturalOrder(toRerun.getId(), 3);
    dbHelper.scheduleStage(toRerun, pipelineTwo.devStage());
    pipelineRepository.updatePipelineTimeline(pipelineTimeline, new ArrayList<>());
    List<PipelineGroupModel> groupModels = pipelineHistoryService.allActivePipelineInstances(new Username(new CaseInsensitiveString("jez")), PipelineSelections.ALL);
    assertThat(groupModels.size(), is(2));
    List<PipelineModel> pipelineOneModels = groupModels.get(1).getPipelineModels();
    assertThat(pipelineOneModels.size(), is(1));
    PipelineInstanceModels pipelineOneInstances = pipelineOneModels.get(0).getActivePipelineInstances();
    assertThat(pipelineOneInstances.size(), is(1));
    PipelineInstanceModel pipelineOne = pipelineOneInstances.get(0);
    assertThat(pipelineOne.getCounter(), is(1));
    List<PipelineModel> pipelineTwoModels = groupModels.get(0).getPipelineModels();
    assertThat(pipelineTwoModels.size(), is(1));
    PipelineInstanceModels pipelineTwoInstances = pipelineTwoModels.get(0).getActivePipelineInstances();
    assertThat(pipelineTwoInstances.size(), is(3));
    PipelineInstanceModel pipelineTwoJustScheduled = pipelineTwoInstances.get(0);
    assertThat(pipelineTwoJustScheduled.getCounter(), is(4));
    assertThat(pipelineTwoJustScheduled.getStageHistory().size(), is(2));
    StageInstanceModel activeStage = pipelineTwoJustScheduled.activeStage();
    assertThat(activeStage, is(nullValue()));
    PipelineInstanceModel pipelineTwoPostFirstStage = pipelineTwoInstances.get(1);
    assertThat(pipelineTwoPostFirstStage.getCounter(), is(3));
    assertThat(pipelineTwoPostFirstStage.getStageHistory().size(), is(2));
    activeStage = pipelineTwoPostFirstStage.activeStage();
    assertThat(activeStage.getName(), is("dev"));
    assertThat(activeStage.hasPreviousStage(), is(true));
    assertThat(activeStage.getPreviousStage().getResult(), is(StageResult.Passed));
    PipelineInstanceModel pipelineTwoWithSecondStageRunning = pipelineTwoInstances.get(2);
    assertThat(pipelineTwoWithSecondStageRunning.getCounter(), is(2));
    assertThat(pipelineTwoWithSecondStageRunning.getStageHistory().size(), is(2));
    activeStage = pipelineTwoWithSecondStageRunning.activeStage();
    assertThat(activeStage.getName(), is("ft"));
    assertThat(activeStage.hasPreviousStage(), is(true));
    assertThat(activeStage.getPreviousStage().getResult(), is(StageResult.Passed));
}
Also used : 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) PipelineGroupModel(com.thoughtworks.go.presentation.pipelinehistory.PipelineGroupModel) StageInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModel) PipelineModel(com.thoughtworks.go.presentation.pipelinehistory.PipelineModel) Test(org.junit.Test)

Example 4 with PipelineGroupModel

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

the class PipelineHistoryServiceIntegrationTest method shouldReturnActiveInstanceOfAPipeline.

@Test
public void shouldReturnActiveInstanceOfAPipeline() throws Exception {
    pipelineOne.createdPipelineWithAllStagesPassed();
    configHelper.setViewPermissionForGroup("group1", "jez");
    String pipelineName = pipelineOne.pipelineName;
    List<PipelineGroupModel> groupModels = pipelineHistoryService.getActivePipelineInstance(new Username(new CaseInsensitiveString("jez")), pipelineName.toUpperCase());
    assertThat(groupModels.size(), is(1));
    List<PipelineModel> pipelineOneModels = groupModels.get(0).getPipelineModels();
    assertThat(pipelineOneModels.size(), is(1));
    assertThat(pipelineOneModels.get(0).getActivePipelineInstances().get(0).getName(), is(pipelineName));
}
Also used : Username(com.thoughtworks.go.server.domain.Username) PipelineGroupModel(com.thoughtworks.go.presentation.pipelinehistory.PipelineGroupModel) PipelineModel(com.thoughtworks.go.presentation.pipelinehistory.PipelineModel) Test(org.junit.Test)

Example 5 with PipelineGroupModel

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

the class PipelineHistoryServiceIntegrationTest method shouldSkipPipelinesThatAreScheduledButNotInConfigFile.

@Test
public void shouldSkipPipelinesThatAreScheduledButNotInConfigFile() throws Exception {
    pipelineOne.createPipelineWithFirstStageScheduled();
    configHelper.removePipeline(pipelineOne.pipelineName);
    configHelper.removePipeline(pipelineTwo.pipelineName);
    List<PipelineGroupModel> groupModels = pipelineHistoryService.allActivePipelineInstances(new Username(new CaseInsensitiveString("jez")), PipelineSelections.ALL);
    assertThat(groupModels.size(), is(0));
}
Also used : Username(com.thoughtworks.go.server.domain.Username) PipelineGroupModel(com.thoughtworks.go.presentation.pipelinehistory.PipelineGroupModel) Test(org.junit.Test)

Aggregations

PipelineGroupModel (com.thoughtworks.go.presentation.pipelinehistory.PipelineGroupModel)6 Username (com.thoughtworks.go.server.domain.Username)6 Test (org.junit.Test)6 PipelineModel (com.thoughtworks.go.presentation.pipelinehistory.PipelineModel)5 PipelineInstanceModels (com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels)2 EmptyPipelineInstanceModel (com.thoughtworks.go.presentation.pipelinehistory.EmptyPipelineInstanceModel)1 PipelineInstanceModel (com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel)1 StageInstanceModel (com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModel)1