Search in sources :

Example 6 with PipelineInstanceModel

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

the class PipelineHistoryGroupingUtilTest method shouldCreateTwoGroupsWithMultiplePipelineHistoryItems.

@Test
public void shouldCreateTwoGroupsWithMultiplePipelineHistoryItems() throws Exception {
    PipelineInstanceModel pipelineHistoryItem1 = PipelineHistoryItemMother.custom("stage1", "stage2");
    PipelineInstanceModel pipelineHistoryItem2 = PipelineHistoryItemMother.custom("stage1", "stage3");
    PipelineInstanceModels history = PipelineInstanceModels.createPipelineInstanceModels(pipelineHistoryItem1, pipelineHistoryItem2);
    PipelineHistoryGroups historyGroups = groupingUtil.createGroups(history);
    assertThat(historyGroups.size(), is(2));
    assertThat(historyGroups.first().hasSameStagesAs(pipelineHistoryItem1), is(true));
    assertThat(historyGroups.get(1).hasSameStagesAs(pipelineHistoryItem2), is(true));
}
Also used : PipelineInstanceModels(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels) PipelineInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel) PipelineHistoryGroups(com.thoughtworks.go.server.presentation.models.PipelineHistoryGroups) Test(org.junit.Test)

Example 7 with PipelineInstanceModel

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

the class PipelineHistoryGroupTest method shouldNotMatchSpecifiedItemIfNameNotMatched.

@Test
public void shouldNotMatchSpecifiedItemIfNameNotMatched() throws Exception {
    PipelineInstanceGroupModel group = new PipelineInstanceGroupModel();
    group.getStages().addAll(asList(new SimpleInfo("stage1", true), new SimpleInfo("stage2", false)));
    PipelineInstanceModel pipelineInstanceModel = PipelineHistoryItemMother.custom(StageHistoryItemMother.custom("stage1", true), StageHistoryItemMother.custom("stage3", false));
    assertThat(group.hasSameStagesAs(pipelineInstanceModel), is(false));
}
Also used : PipelineInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel) Test(org.junit.Test)

Example 8 with PipelineInstanceModel

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

the class ViewCacheKeyTest method shouldGenerateKeyForEnvironmentPipelineFragment.

@Test
public void shouldGenerateKeyForEnvironmentPipelineFragment() {
    MaterialRevisions materialRevisions = ModificationsMother.createHgMaterialRevisions();
    Modification latestModification = materialRevisions.getMaterialRevision(0).getModifications().remove(0);
    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.createWithModifications(materialRevisions, "someone"), stages);
    pipelineInstance.setMaterialConfigs(materialRevisions.getMaterials().convertToConfigs());
    pipelineInstance.setLatestRevisions(new MaterialRevisions(new MaterialRevision(materialRevisions.getMaterialRevision(0).getMaterial(), latestModification)));
    pipelineInstance.setId(12);
    model.addPipelineInstance(pipelineInstance);
    assertThat(model.hasNewRevisions(), is(true));
    assertThat(viewCacheKey.forEnvironmentPipelineBox(model), is("view_environmentPipelineFragment_pipelineName{false|false|false}[12|stageName|13|Building|stage2|0|Unknown|]true|true|false|||true|true"));
    model.updateAdministrability(false);
    assertThat(viewCacheKey.forEnvironmentPipelineBox(model), is("view_environmentPipelineFragment_pipelineName{false|false|false}[12|stageName|13|Building|stage2|0|Unknown|]true|true|false|||false|true"));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) NullStageHistoryItem(com.thoughtworks.go.presentation.pipelinehistory.NullStageHistoryItem) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) PipelineInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel) StageInstanceModels(com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModels) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) PipelineModel(com.thoughtworks.go.presentation.pipelinehistory.PipelineModel) Test(org.junit.Test)

Example 9 with PipelineInstanceModel

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

the class PipelineDependencyGraphOldTest method shouldShouldbeAbleToTellIfUpStreamMaterialIsAvailableForTrigger.

@Test
public void shouldShouldbeAbleToTellIfUpStreamMaterialIsAvailableForTrigger() throws Exception {
    StageInstanceModels stages = new StageInstanceModels();
    stages.add(new StageInstanceModel("stage-0", "21", StageResult.Cancelled, new StageIdentifier("blahUpStream", 23, "stage-0", "21")));
    PipelineInstanceModel upStream = PipelineHistoryMother.singlePipeline("blahUpStream", stages);
    PipelineInstanceModel down1 = pim("blahDown1");
    down1.setMaterialConfigs(new MaterialConfigs(dependencyMaterialConfig("blahUpStream", "stage-1")));
    PipelineDependencyGraphOld graph = new PipelineDependencyGraphOld(upStream, PipelineInstanceModels.createPipelineInstanceModels(down1));
    assertThat(graph.hasUpStreamRevisionFor(down1), is(false));
}
Also used : StageIdentifier(com.thoughtworks.go.domain.StageIdentifier) MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) PipelineInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel) StageInstanceModels(com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModels) StageInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModel) PipelineDependencyGraphOld(com.thoughtworks.go.domain.PipelineDependencyGraphOld) Test(org.junit.Test)

Example 10 with PipelineInstanceModel

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

the class PipelineDependencyGraphOldTest method assertThatTriggerIsPossibleOnlyIfUpStreamPassed.

private void assertThatTriggerIsPossibleOnlyIfUpStreamPassed(StageResult upstreamResult) {
    StageInstanceModels stages = new StageInstanceModels();
    stages.add(new StageInstanceModel("stage-0", "21", upstreamResult, new StageIdentifier("blahUpStream", 23, "stage-0", "21")));
    PipelineInstanceModel upStream = PipelineHistoryMother.singlePipeline("blahUpStream", stages);
    PipelineInstanceModel down1 = pim("blahDown1");
    down1.setMaterialConfigs(new MaterialConfigs(dependencyMaterialConfig("blahUpStream", "stage-0")));
    PipelineDependencyGraphOld graph = new PipelineDependencyGraphOld(upStream, PipelineInstanceModels.createPipelineInstanceModels(down1));
    assertThat(graph.hasUpStreamRevisionFor(graph.dependencies().find("blahDown1")), is(upstreamResult == StageResult.Passed));
}
Also used : StageIdentifier(com.thoughtworks.go.domain.StageIdentifier) MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) PipelineInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel) StageInstanceModels(com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModels) StageInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModel) PipelineDependencyGraphOld(com.thoughtworks.go.domain.PipelineDependencyGraphOld)

Aggregations

PipelineInstanceModel (com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel)69 Test (org.junit.Test)46 EmptyPipelineInstanceModel (com.thoughtworks.go.presentation.pipelinehistory.EmptyPipelineInstanceModel)20 PipelineInstanceModels (com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels)15 Username (com.thoughtworks.go.server.domain.Username)15 StageInstanceModels (com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModels)14 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)11 PipelineModel (com.thoughtworks.go.presentation.pipelinehistory.PipelineModel)10 StageInstanceModel (com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModel)8 Modification (com.thoughtworks.go.domain.materials.Modification)7 HttpOperationResult (com.thoughtworks.go.server.service.result.HttpOperationResult)7 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)6 NullStageHistoryItem (com.thoughtworks.go.presentation.pipelinehistory.NullStageHistoryItem)6 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)5 PipelineDependencyGraphOld (com.thoughtworks.go.domain.PipelineDependencyGraphOld)4 Material (com.thoughtworks.go.domain.materials.Material)4 PipelineHistoryGroups (com.thoughtworks.go.server.presentation.models.PipelineHistoryGroups)4 Date (java.util.Date)4 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)3 StageIdentifier (com.thoughtworks.go.domain.StageIdentifier)3