Search in sources :

Example 11 with StageInstanceModels

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

the class ViewCacheKeyTest method shouldGenerateKeyForPipelineModelViewFragmentWithLockStatus.

@Test
public void shouldGenerateKeyForPipelineModelViewFragmentWithLockStatus() {
    PipelineModel model = new PipelineModel("pipelineName", true, true, PipelinePauseInfo.notPaused()).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);
    pipelineInstance.setCanUnlock(false);
    pipelineInstance.setIsLockable(true);
    pipelineInstance.setCurrentlyLocked(true);
    model.addPipelineInstance(pipelineInstance);
    assertThat(viewCacheKey.forPipelineModelBox(model), is("view_dashboardPipelineFragment_pipelineName{true|true|false}[12|stageName|13|Building|stage2|0|Unknown|]true|true|false|||true"));
}
Also used : NullStageHistoryItem(com.thoughtworks.go.presentation.pipelinehistory.NullStageHistoryItem) 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)

Example 12 with StageInstanceModels

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

the class ViewCacheKeyTest method shouldGenerateKeyForPipelineModelViewIncludingUserAdminStatus.

@Test
public void shouldGenerateKeyForPipelineModelViewIncludingUserAdminStatus() {
    PipelineModel model = new PipelineModel("pipelineName", true, true, PipelinePauseInfo.notPaused()).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);
    pipelineInstance.setCanUnlock(false);
    pipelineInstance.setIsLockable(true);
    pipelineInstance.setCurrentlyLocked(true);
    model.addPipelineInstance(pipelineInstance);
    assertThat(viewCacheKey.forPipelineModelBox(model), is("view_dashboardPipelineFragment_pipelineName{true|true|false}[12|stageName|13|Building|stage2|0|Unknown|]true|true|false|||true"));
    model.updateAdministrability(false);
    assertThat(viewCacheKey.forPipelineModelBox(model), is("view_dashboardPipelineFragment_pipelineName{true|true|false}[12|stageName|13|Building|stage2|0|Unknown|]true|true|false|||false"));
}
Also used : NullStageHistoryItem(com.thoughtworks.go.presentation.pipelinehistory.NullStageHistoryItem) 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)

Example 13 with StageInstanceModels

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

the class PipelineSqlMapDaoIntegrationTest method shouldLoadPipelineHistoriesWithMultipleSameStage.

@Test
public void shouldLoadPipelineHistoriesWithMultipleSameStage() throws Exception {
    String stageName = "dev";
    PipelineConfig mingleConfig = PipelineMother.twoBuildPlansWithResourcesAndMaterials("mingle", stageName);
    Pipeline mingle = schedulePipelineWithStages(mingleConfig);
    Stage newInstance = rescheduleStage(stageName, mingleConfig, mingle);
    PipelineInstanceModels pipelineHistories = pipelineDao.loadHistory(mingle.getName(), 10, 0);
    assertThat(pipelineHistories.size(), is(1));
    StageInstanceModels stageHistories = pipelineHistories.first().getStageHistory();
    assertThat(stageHistories.size(), is(1));
    StageInstanceModel history = stageHistories.first();
    assertThat(history.getName(), is(stageName));
    assertThat(history.getId(), is(newInstance.getId()));
    assertThat(history.getBuildHistory().size(), is(2));
}
Also used : PipelineConfig(com.thoughtworks.go.config.PipelineConfig) PipelineInstanceModels(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels) StageInstanceModels(com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModels) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) StageInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModel) Test(org.junit.Test)

Example 14 with StageInstanceModels

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

the class PipelineHistoryMother method stagePerJob.

public static StageInstanceModels stagePerJob(String baseName, List<JobHistory> histories) {
    StageInstanceModels stageInstanceModels = new StageInstanceModels();
    for (int i = 0; i < histories.size(); i++) {
        String stageName = baseName + "-" + i;
        StageInstanceModel stage = new StageInstanceModel(stageName, "1", StageResult.Passed, new StageIdentifier("pipeline", 1, "1", stageName, "1"));
        stage.setBuildHistory(histories.get(i));
        stageInstanceModels.add(stage);
        stageInstanceModels.latestStage().setApprovedBy("cruise");
    }
    return stageInstanceModels;
}
Also used : StageIdentifier(com.thoughtworks.go.domain.StageIdentifier) StageInstanceModels(com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModels) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) StageInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModel)

Example 15 with StageInstanceModels

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

the class PipelineHistoryMother method pipeline.

public static PipelineModel pipeline() {
    PipelineModel pipelineModel = new PipelineModel("pipe1", true, true, PipelinePauseInfo.notPaused());
    MaterialRevisions materialRevisions = ModificationsMother.createHgMaterialRevisions();
    PipelineInstanceModel instanceModel = PipelineInstanceModel.createPipeline("pipe1", -1, "label1", BuildCause.createWithModifications(materialRevisions, "foo-bar"), new StageInstanceModels());
    instanceModel.setMaterialConfigs(new MaterialConfigs(materialRevisions.getMaterialRevision(0).getMaterial().config()));
    instanceModel.setLatestRevisions(materialRevisions);
    pipelineModel.addPipelineInstance(instanceModel);
    return pipelineModel;
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) PipelineInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel) StageInstanceModels(com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModels) PipelineModel(com.thoughtworks.go.presentation.pipelinehistory.PipelineModel)

Aggregations

StageInstanceModels (com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModels)32 Test (org.junit.Test)21 PipelineInstanceModel (com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel)14 StageInstanceModel (com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModel)13 PipelineInstanceModels (com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels)8 PipelineModel (com.thoughtworks.go.presentation.pipelinehistory.PipelineModel)8 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)6 NullStageHistoryItem (com.thoughtworks.go.presentation.pipelinehistory.NullStageHistoryItem)6 StageIdentifier (com.thoughtworks.go.domain.StageIdentifier)5 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)4 Pagination (com.thoughtworks.go.server.util.Pagination)4 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)3 PipelineDependencyGraphOld (com.thoughtworks.go.domain.PipelineDependencyGraphOld)3 HttpOperationResult (com.thoughtworks.go.server.service.result.HttpOperationResult)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 Username (com.thoughtworks.go.server.domain.Username)2 StageStatusTopic (com.thoughtworks.go.server.messaging.StageStatusTopic)2 ScheduleTestUtil (com.thoughtworks.go.server.service.ScheduleTestUtil)2