@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, new Agents(), durations, new TrackingTool()); Map json = presenter.toJson(); new JsonTester(json) .shouldContain( "{ 'stageName' : 'stage'," + " 'builds' : [" + " { 'name' : 'job-that-will-fail', 'last_build_duration' : '12' }," + " { 'name' : 'job-that-will-pass' }, " + " { 'name' : 'scheduledBuild' }" + " ]," + " 'current_label' : '" + pipeline.getLabel() + "'," + " 'id' : '1' " + "}"); assertFalse( "JSON shouldn't contain last_successful_label", json.toString().contains("last_successful_label")); }
@Test public void shouldGetAPresenterWithLabelAndRelevantBuildPlansAndPipelineNameAndId() throws Exception { StageJsonPresentationModel presenter = new StageJsonPresentationModel(pipeline, stage, null, new Agents()); Map json = presenter.toJson(); new JsonTester(json) .shouldContain( "{ 'pipelineName' : 'pipeline'," + " 'stageName' : 'stage'," + " 'builds' : [" + " { 'name' : 'job-that-will-fail' }," + " { 'name' : 'job-that-will-pass' }," + " { 'name' : 'scheduledBuild' }" + " ]," + " 'current_label' : '" + pipeline.getLabel() + "', " + " 'pipelineCounter' : '" + pipeline.getCounter() + "', " + " 'pipelineCounterOrLabel' : '" + pipeline.getIdentifier().instanceIdentifier() + "', " + " 'id' : '1' " + "}"); assertFalse( "JSON shouldn't contain last_successful_label", json.toString().contains("last_successful_label")); }