Search in sources :

Example 16 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 17 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 18 with PipelineInstanceModel

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

the class EnvironmentServiceTest method stubPipelineHistoryServiceToReturnPipelines.

private PipelineInstanceModel stubPipelineHistoryServiceToReturnPipelines(final String pipelineName) {
    PipelineInstanceModel pipelineInstanceModel = PipelineInstanceModel.createPipeline(pipelineName, -1, "1", BuildCause.createManualForced(), new StageInstanceModels());
    PipelineModel pipelineModel = new PipelineModel(pipelineInstanceModel.getName(), true, true, PipelinePauseInfo.notPaused());
    pipelineModel.addPipelineInstance(pipelineInstanceModel);
    when(pipelineHistoryService.latestPipelineModel(new Username(new CaseInsensitiveString("Foo")), pipelineName)).thenReturn(pipelineModel);
    return pipelineInstanceModel;
}
Also used : Username(com.thoughtworks.go.server.domain.Username) PipelineInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel) StageInstanceModels(com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModels) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) PipelineModel(com.thoughtworks.go.presentation.pipelinehistory.PipelineModel)

Example 19 with PipelineInstanceModel

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

the class EnvironmentServiceTest method shouldReturnPipelineHistoryForPipelinesInAnEnvironment.

@Test
public void shouldReturnPipelineHistoryForPipelinesInAnEnvironment() throws Exception {
    Username username = new Username(new CaseInsensitiveString("Foo"));
    when(environmentConfigService.pipelinesFor(new CaseInsensitiveString("uat"))).thenReturn(Arrays.asList(new CaseInsensitiveString("uat-pipeline"), new CaseInsensitiveString("staging-pipeline")));
    PipelineInstanceModel uatInstance = stubPipelineHistoryServiceToReturnPipelines("uat-pipeline");
    PipelineInstanceModel stagingInstance = stubPipelineHistoryServiceToReturnPipelines("staging-pipeline");
    ArrayList<Environment> environments = new ArrayList<>();
    environmentService.addEnvironmentFor(new CaseInsensitiveString("uat"), username, environments);
    assertThat(environments.size(), is(1));
    Environment environment = environments.get(0);
    assertThat(environment.getName(), is("uat"));
    List<PipelineModel> models = environment.getPipelineModels();
    assertThat(models.size(), is(2));
    PipelineModel model1 = new PipelineModel(uatInstance.getName(), true, true, PipelinePauseInfo.notPaused());
    model1.addPipelineInstance(uatInstance);
    assertThat(models, hasItem(model1));
    PipelineModel model2 = new PipelineModel(stagingInstance.getName(), true, true, PipelinePauseInfo.notPaused());
    model2.addPipelineInstance(stagingInstance);
    assertThat(models, hasItem(model2));
}
Also used : Username(com.thoughtworks.go.server.domain.Username) PipelineInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel) ArrayList(java.util.ArrayList) Environment(com.thoughtworks.go.presentation.pipelinehistory.Environment) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) PipelineModel(com.thoughtworks.go.presentation.pipelinehistory.PipelineModel) Test(org.junit.Test)

Example 20 with PipelineInstanceModel

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

the class BuildCauseControllerDelegate method index.

public String index(Request req, Response res) throws IOException {
    HttpOperationResult httpOperationResult = new HttpOperationResult();
    int result;
    try {
        result = Integer.parseInt(req.params(":pipeline_counter"));
    } catch (NumberFormatException nfe) {
        throw new RecordNotFoundException();
    }
    String pipelineName = req.params("pipeline_name");
    PipelineInstanceModel pipelineInstance = pipelineHistoryService.findPipelineInstance(pipelineName, result, currentUsername(), httpOperationResult);
    if (httpOperationResult.isSuccess()) {
        return writerForTopLevelObject(req, res, outputWriter -> BuildCauseRepresenter.toJSON(outputWriter, pipelineInstance.getBuildCause()));
    } else {
        return renderHTTPOperationResult(httpOperationResult, req, res);
    }
}
Also used : HttpOperationResult(com.thoughtworks.go.server.service.result.HttpOperationResult) RecordNotFoundException(com.thoughtworks.go.config.exceptions.RecordNotFoundException) PipelineInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel)

Aggregations

PipelineInstanceModel (com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel)60 Test (org.junit.Test)31 StageInstanceModels (com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModels)15 PipelineInstanceModels (com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels)12 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)11 PipelineModel (com.thoughtworks.go.presentation.pipelinehistory.PipelineModel)9 StageInstanceModel (com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModel)7 NullStageHistoryItem (com.thoughtworks.go.presentation.pipelinehistory.NullStageHistoryItem)6 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)5 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)5 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)4 PipelineDependencyGraphOld (com.thoughtworks.go.domain.PipelineDependencyGraphOld)4 Modification (com.thoughtworks.go.domain.materials.Modification)4 PipelineHistoryGroups (com.thoughtworks.go.server.presentation.models.PipelineHistoryGroups)4 Matchers.anyString (org.mockito.Matchers.anyString)4 StageIdentifier (com.thoughtworks.go.domain.StageIdentifier)3 EmptyPipelineInstanceModel (com.thoughtworks.go.presentation.pipelinehistory.EmptyPipelineInstanceModel)3 TimeProvider (com.thoughtworks.go.util.TimeProvider)3 MingleConfig (com.thoughtworks.go.config.MingleConfig)2 TrackingTool (com.thoughtworks.go.config.TrackingTool)2