Search in sources :

Example 1 with DurationBeans

use of com.thoughtworks.go.dto.DurationBeans in project gocd by gocd.

the class StageJsonPresentationModelTest method shouldGetAPresenterWithLabelAndRelevantBuildPlans.

@Test
public void shouldGetAPresenterWithLabelAndRelevantBuildPlans() throws Exception {
    DurationBeans durations = new DurationBeans(new DurationBean(stage.getJobInstances().getByName("job-that-will-fail").getId(), 12L));
    StageJsonPresentationModel presenter = new StageJsonPresentationModel(pipeline, stage, null, agentService, durations, new TrackingTool());
    Map json = presenter.toJson();
    JSONAssert.assertEquals("{\n" + "  \"stageName\": \"stage\",\n" + "  \"builds\": [\n" + "    {\n" + "      \"name\": \"job-that-will-fail\",\n" + "      \"last_build_duration\": \"12\"\n" + "    },\n" + "    {\n" + "      \"name\": \"job-that-will-pass\"\n" + "    },\n" + "    {\n" + "      \"name\": \"scheduledBuild\"\n" + "    }\n" + "  ],\n" + "  \"current_label\": \"10\",\n" + "  \"id\": \"1\"\n" + "}", new Gson().toJson(json), false);
    assertFalse("JSON shouldn't contain last_successful_label", json.toString().contains("last_successful_label"));
}
Also used : DurationBean(com.thoughtworks.go.dto.DurationBean) Gson(com.google.gson.Gson) Map(java.util.Map) DurationBeans(com.thoughtworks.go.dto.DurationBeans) TrackingTool(com.thoughtworks.go.config.TrackingTool) Test(org.junit.Test)

Example 2 with DurationBeans

use of com.thoughtworks.go.dto.DurationBeans in project gocd by gocd.

the class CachedCurrentActivityService method stageModel.

private StageJsonPresentationModel stageModel(Pipeline currentPipeline, Stage stage) {
    StageIdentifier lastSuccessfulPipelineForStage = pipelineService.findLastSuccessfulStageIdentifier(currentPipeline.getName(), stage.getName());
    final DurationBeans durations = stageService.getBuildDurations(currentPipeline.getName(), stage);
    TrackingTool trackingTool = goConfigService.pipelineConfigNamed(new CaseInsensitiveString(currentPipeline.getName())).trackingTool();
    return new StageJsonPresentationModel(currentPipeline, stage, lastSuccessfulPipelineForStage, agentService, durations, trackingTool);
}
Also used : StageIdentifier(com.thoughtworks.go.domain.StageIdentifier) StageJsonPresentationModel(com.thoughtworks.go.server.presentation.models.StageJsonPresentationModel) DurationBeans(com.thoughtworks.go.dto.DurationBeans) TrackingTool(com.thoughtworks.go.config.TrackingTool) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString)

Aggregations

TrackingTool (com.thoughtworks.go.config.TrackingTool)2 DurationBeans (com.thoughtworks.go.dto.DurationBeans)2 Gson (com.google.gson.Gson)1 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)1 StageIdentifier (com.thoughtworks.go.domain.StageIdentifier)1 DurationBean (com.thoughtworks.go.dto.DurationBean)1 StageJsonPresentationModel (com.thoughtworks.go.server.presentation.models.StageJsonPresentationModel)1 Map (java.util.Map)1 Test (org.junit.Test)1