Search in sources :

Example 6 with StageInstanceModel

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

the class PipelineHistoryMother method stageHistory.

public static StageInstanceModels stageHistory(PipelineConfig pipelineConfig, Date modificationDate) {
    StageInstanceModels history = new StageInstanceModels();
    for (StageConfig stageConfig : pipelineConfig) {
        StageInstanceModel item = new StageInstanceModel(CaseInsensitiveString.str(stageConfig.name()), "1", buildHistory(stageConfig, modificationDate));
        item.setCounter("1");
        item.setApprovalType(new InstanceFactory().createStageInstance(stageConfig, new DefaultSchedulingContext("anyone"), md5, new TimeProvider()).getApprovalType());
        if (stageConfig.requiresApproval()) {
            item.setApprovedBy(APPROVED_BY);
        } else {
            item.setApprovedBy(GoConstants.DEFAULT_APPROVED_BY);
        }
        history.add(item);
    }
    return history;
}
Also used : TimeProvider(com.thoughtworks.go.util.TimeProvider) InstanceFactory(com.thoughtworks.go.server.service.InstanceFactory) StageInstanceModels(com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModels) StageInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModel) StageConfig(com.thoughtworks.go.config.StageConfig) DefaultSchedulingContext(com.thoughtworks.go.domain.DefaultSchedulingContext)

Example 7 with StageInstanceModel

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

the class PipelineHistoryItemMother method custom.

public static PipelineInstanceModel custom(String... stageNames) {
    PipelineInstanceModel pipelineInstanceModel = PipelineInstanceModel.createEmptyModel();
    pipelineInstanceModel.setStageHistory(new StageInstanceModels());
    for (String stageName : stageNames) {
        StageInstanceModel stageHistoryItem = new StageInstanceModel();
        stageHistoryItem.setName(stageName);
        pipelineInstanceModel.getStageHistory().add(stageHistoryItem);
    }
    return pipelineInstanceModel;
}
Also used : PipelineInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel) StageInstanceModels(com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModels) StageInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModel)

Example 8 with StageInstanceModel

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

the class StageMother method toStageInstanceModel.

public static StageInstanceModel toStageInstanceModel(Stage stage) {
    StageInstanceModel stageInstanceModel = new StageInstanceModel(stage.getName(), String.valueOf(stage.getCounter()), stage.getResult(), stage.getIdentifier());
    stageInstanceModel.setApprovalType(stage.getApprovalType());
    stageInstanceModel.setApprovedBy(stage.getApprovedBy());
    stageInstanceModel.setRerunOfCounter(stage.getRerunOfCounter());
    JobHistory jobHistory = new JobHistory();
    for (JobInstance jobInstance : stage.getJobInstances()) {
        jobHistory.addJob(jobInstance.getName(), jobInstance.getState(), jobInstance.getResult(), jobInstance.getScheduledDate());
    }
    stageInstanceModel.setBuildHistory(jobHistory);
    return stageInstanceModel;
}
Also used : JobHistory(com.thoughtworks.go.presentation.pipelinehistory.JobHistory) StageInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModel)

Example 9 with StageInstanceModel

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

the class PipelineHistoryJsonPresentationModel method stageHistoryAsJson.

private List stageHistoryAsJson(PipelineInstanceModel pipelineInstanceModel, StageInstanceModels stageHistory) {
    List json = new ArrayList();
    for (StageInstanceModel stageHistoryItem : stageHistory) {
        Map<String, Object> jsonMap = new LinkedHashMap<>();
        jsonMap.put("stageName", stageHistoryItem.getName());
        jsonMap.put("stageId", stageHistoryItem.getId());
        jsonMap.put("stageStatus", stageHistoryItem.getState().toString());
        StageIdentifier stageIdentifier = new StageIdentifier(pipelineInstanceModel.getPipelineIdentifier(), stageHistoryItem.getName(), stageHistoryItem.getCounter());
        jsonMap.put("stageLocator", encodeInUtf8(stageIdentifier.stageLocator()));
        jsonMap.put("getCanRun", Boolean.toString(stageHistoryItem.getCanRun()));
        jsonMap.put("getCanCancel", Boolean.toString(stageHistoryItem.getCanCancel()));
        jsonMap.put("scheduled", Boolean.toString(stageHistoryItem.isScheduled()));
        jsonMap.put("stageCounter", stageHistoryItem.getCounter());
        handleApproval(stageHistoryItem, jsonMap);
        json.add(jsonMap);
    }
    return json;
}
Also used : StageIdentifier(com.thoughtworks.go.domain.StageIdentifier) StageInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModel)

Example 10 with StageInstanceModel

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

the class PipelineHistoryServiceIntegrationTest method shouldLoadPipelineHistory.

@Test
public void shouldLoadPipelineHistory() throws Exception {
    pipelineOne.createdPipelineWithAllStagesPassed();
    PipelineInstanceModels history = pipelineHistoryService.load(pipelineOne.pipelineName, Pagination.pageStartingAt(0, 1, 10), "jez", true);
    assertThat(history.size(), is(1));
    StageInstanceModels stageHistory = history.first().getStageHistory();
    assertThat(stageHistory.size(), is(3));
    for (StageInstanceModel stageHistoryItem : stageHistory) {
        assertThat(stageHistoryItem.isScheduled(), is(true));
        assertThat(stageHistoryItem.getCanRun(), is(true));
    }
}
Also used : PipelineInstanceModels(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels) StageInstanceModels(com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModels) StageInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModel) Test(org.junit.Test)

Aggregations

StageInstanceModel (com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModel)21 StageInstanceModels (com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModels)13 PipelineInstanceModel (com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel)8 Test (org.junit.Test)8 StageIdentifier (com.thoughtworks.go.domain.StageIdentifier)6 PipelineInstanceModels (com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels)5 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)4 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)3 PipelineDependencyGraphOld (com.thoughtworks.go.domain.PipelineDependencyGraphOld)3 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)2 JobHistory (com.thoughtworks.go.presentation.pipelinehistory.JobHistory)2 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)2 StageConfig (com.thoughtworks.go.config.StageConfig)1 DefaultSchedulingContext (com.thoughtworks.go.domain.DefaultSchedulingContext)1 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)1 PipelinePauseInfo (com.thoughtworks.go.domain.PipelinePauseInfo)1 PipelineTimelineEntry (com.thoughtworks.go.domain.PipelineTimelineEntry)1 EmptyPipelineInstanceModel (com.thoughtworks.go.presentation.pipelinehistory.EmptyPipelineInstanceModel)1 NullStageHistoryItem (com.thoughtworks.go.presentation.pipelinehistory.NullStageHistoryItem)1 PipelineGroupModel (com.thoughtworks.go.presentation.pipelinehistory.PipelineGroupModel)1