Search in sources :

Example 11 with PipelineModel

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

the class PipelineHistoryMother method pipelineWithLatestRevisionAndMaterialRevision.

public static PipelineModel pipelineWithLatestRevisionAndMaterialRevision(MaterialRevisions latest, MaterialRevisions revision) {
    PipelineModel pipelineModel = pipelineWithLatestRevision(latest);
    pipelineModel.getLatestPipelineInstance().setMaterialRevisionsOnBuildCause(revision);
    return pipelineModel;
}
Also used : PipelineModel(com.thoughtworks.go.presentation.pipelinehistory.PipelineModel)

Example 12 with PipelineModel

use of com.thoughtworks.go.presentation.pipelinehistory.PipelineModel 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 13 with PipelineModel

use of com.thoughtworks.go.presentation.pipelinehistory.PipelineModel 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 14 with PipelineModel

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

the class PipelineHistoryServiceIntegrationTest method shouldRememberOldStagesWhenConfigFileChanges.

@Test
public void shouldRememberOldStagesWhenConfigFileChanges() throws Exception {
    configHelper.removePipeline(pipelineTwo.pipelineName);
    Pipeline toRerun = pipelineOne.createdPipelineWithAllStagesPassed();
    configHelper.addStageToPipeline(pipelineOne.pipelineName, "brand_new_stage", 1, "unit");
    pipelineOne.createdPipelineWithAllStagesPassed();
    dbHelper.scheduleStage(toRerun, pipelineOne.devStage());
    configHelper.setViewPermissionForGroup("group1", "jez");
    List<PipelineGroupModel> groupModels = pipelineHistoryService.allActivePipelineInstances(new Username(new CaseInsensitiveString("jez")), PipelineSelections.ALL);
    assertThat(groupModels.size(), is(1));
    List<PipelineModel> pipelineOneModels = groupModels.get(0).getPipelineModels();
    assertThat(pipelineOneModels.size(), is(1));
    PipelineInstanceModels pipelineTwoInstances = pipelineOneModels.get(0).getActivePipelineInstances();
    assertThat(pipelineTwoInstances.size(), is(2));
    assertThat(pipelineTwoInstances.get(0).getCounter(), is(2));
    assertThat(pipelineTwoInstances.get(0).getStageHistory().size(), is(4));
    assertThat(pipelineTwoInstances.get(1).getCounter(), is(1));
    assertThat(pipelineTwoInstances.get(1).getStageHistory().size(), is(3));
}
Also used : PipelineInstanceModels(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels) 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 15 with PipelineModel

use of com.thoughtworks.go.presentation.pipelinehistory.PipelineModel 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())));
}
Also used : PipelineInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel) StageInstanceModels(com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModels) MingleConfig(com.thoughtworks.go.config.MingleConfig) TrackingTool(com.thoughtworks.go.config.TrackingTool) PipelineModel(com.thoughtworks.go.presentation.pipelinehistory.PipelineModel) Test(org.junit.Test)

Aggregations

PipelineModel (com.thoughtworks.go.presentation.pipelinehistory.PipelineModel)17 Test (org.junit.Test)12 PipelineInstanceModel (com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel)10 StageInstanceModels (com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModels)8 Username (com.thoughtworks.go.server.domain.Username)7 NullStageHistoryItem (com.thoughtworks.go.presentation.pipelinehistory.NullStageHistoryItem)5 PipelineGroupModel (com.thoughtworks.go.presentation.pipelinehistory.PipelineGroupModel)5 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)3 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)2 Environment (com.thoughtworks.go.presentation.pipelinehistory.Environment)2 PipelineInstanceModels (com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels)2 ArrayList (java.util.ArrayList)2 MingleConfig (com.thoughtworks.go.config.MingleConfig)1 TrackingTool (com.thoughtworks.go.config.TrackingTool)1 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)1 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)1 PipelinePauseInfo (com.thoughtworks.go.domain.PipelinePauseInfo)1 Modification (com.thoughtworks.go.domain.materials.Modification)1 EmptyPipelineInstanceModel (com.thoughtworks.go.presentation.pipelinehistory.EmptyPipelineInstanceModel)1 StageInstanceModel (com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModel)1